eos_incomp.C

00001 /*
00002  * Methods of the class Eos_incomp.
00003  *
00004  * (see file eos.h for documentation).
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License as published by
00014  *   the Free Software Foundation; either version 2 of the License, or
00015  *   (at your option) any later version.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 
00029 char eos_incomp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_incomp.C,v 1.4 2002/10/16 14:36:35 j_novak Exp $" ;
00030 
00031 /*
00032  * $Id: eos_incomp.C,v 1.4 2002/10/16 14:36:35 j_novak Exp $
00033  * $Log: eos_incomp.C,v $
00034  * Revision 1.4  2002/10/16 14:36:35  j_novak
00035  * Reorganization of #include instructions of standard C++, in order to
00036  * use experimental version 3 of gcc.
00037  *
00038  * Revision 1.3  2002/04/09 14:32:15  e_gourgoulhon
00039  * 1/ Added extra parameters in EOS computational functions (argument par)
00040  * 2/ New class MEos for multi-domain EOS
00041  *
00042  * Revision 1.2  2001/12/04 21:27:53  e_gourgoulhon
00043  *
00044  * All writing/reading to a binary file are now performed according to
00045  * the big endian convention, whatever the system is big endian or
00046  * small endian, thanks to the functions fwrite_be and fread_be
00047  *
00048  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00049  * LORENE
00050  *
00051  * Revision 2.4  2001/02/07  09:49:08  eric
00052  * Suppression de la fonction derent_ent_p.
00053  * Ajout des fonctions donnant les derivees de l'EOS:
00054  *      der_nbar_ent_p
00055  *      der_ener_ent_p
00056  *      der_press_ent_p
00057  *
00058  * Revision 2.3  2000/02/14  14:49:48  eric
00059  * Modif affichage.
00060  *
00061  * Revision 2.2  2000/02/14  14:33:51  eric
00062  * Ajout du constructeur par lecture de fichier formate.
00063  *
00064  * Revision 2.1  2000/01/21  15:18:15  eric
00065  * Ajout des operateurs de comparaison == et !=
00066  *
00067  * Revision 2.0  2000/01/18  16:11:25  eric
00068  * *** empty log message ***
00069  *
00070  *
00071  * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_incomp.C,v 1.4 2002/10/16 14:36:35 j_novak Exp $
00072  *
00073  */
00074 
00075 
00076 // Headers C
00077 #include <stdlib.h>
00078 #include <string.h>
00079 #include <math.h>
00080 
00081 // Headers Lorene
00082 #include "eos.h"
00083 #include "cmp.h"
00084 #include "utilitaires.h"
00085 
00086             //--------------//
00087             // Constructors //
00088             //--------------//
00089 
00090 // Standard constructor with ent0 = 1
00091 // ---------------------------------
00092 Eos_incomp::Eos_incomp(double rho_c) : 
00093     Eos("EOS for relativistic incompressible matter"), 
00094     rho0(rho_c), ent0( double(-1.e-6) ) {}
00095 
00096 // Standard constructor with ent0 specified
00097 // ---------------------------------------
00098 Eos_incomp::Eos_incomp(double rho_c, double ent_c) : 
00099     Eos("EOS for relativistic incompressible matter"), 
00100     rho0(rho_c), ent0( ent_c ) {
00101 
00102     assert( ent_c <= double(0) ) ; 
00103     
00104 }
00105   
00106 // Copy constructor
00107 // ----------------
00108 Eos_incomp::Eos_incomp(const Eos_incomp& eosi) : 
00109     Eos(eosi), 
00110     rho0(eosi.rho0), ent0(eosi.ent0) {}
00111   
00112 
00113 // Constructor from a binary file
00114 // ------------------------------
00115 Eos_incomp::Eos_incomp(FILE* fich) : 
00116     Eos(fich) {
00117         
00118     fread_be(&rho0, sizeof(double), 1, fich) ;      
00119     fread_be(&ent0, sizeof(double), 1, fich) ;      
00120 
00121 }
00122 
00123 // Constructor from a formatted file
00124 // ---------------------------------
00125 Eos_incomp::Eos_incomp(ifstream& fich) : 
00126     Eos(fich) {
00127         
00128     char blabla[80] ;
00129         
00130     fich >> rho0 ; fich.getline(blabla, 80) ;
00131     fich >> ent0 ; fich.getline(blabla, 80) ;
00132 
00133 }
00134             //--------------//
00135             //  Destructor  //
00136             //--------------//
00137 
00138 Eos_incomp::~Eos_incomp(){
00139     
00140     // does nothing
00141         
00142 }
00143             //--------------//
00144             //  Assignment  //
00145             //--------------//
00146 
00147 void Eos_incomp::operator=(const Eos_incomp& eosi) {
00148     
00149     set_name(eosi.name) ; 
00150     
00151     rho0 = eosi.rho0 ; 
00152     ent0 = eosi.ent0 ; 
00153 
00154 }
00155 
00156             //------------------------//
00157             //  Comparison operators  //
00158             //------------------------//
00159 
00160 bool Eos_incomp::operator==(const Eos& eos_i) const {
00161     
00162     bool resu = true ; 
00163     
00164     if ( eos_i.identify() != identify() ) {
00165     cout << "The second EOS is not of type Eos_incomp !" << endl ; 
00166     resu = false ; 
00167     }
00168     else{
00169     
00170     const Eos_incomp& eos = dynamic_cast<const Eos_incomp&>( eos_i ) ; 
00171 
00172     if (eos.rho0 != rho0) {
00173         cout 
00174         << "The two Eos_incomp have different rho0 : " << rho0 << " <-> " 
00175         << eos.rho0 << endl ; 
00176         resu = false ; 
00177     }
00178 
00179     if (eos.ent0 != ent0) {
00180         cout 
00181         << "The two Eos_incomp have different ent0 : " << ent0 << " <-> " 
00182         << eos.ent0 << endl ; 
00183         resu = false ; 
00184     }
00185 
00186     }
00187     
00188     return resu ; 
00189     
00190 }
00191 
00192 bool Eos_incomp::operator!=(const Eos& eos_i) const {
00193  
00194     return !(operator==(eos_i)) ; 
00195        
00196 }
00197 
00198 
00199 
00200             //------------//
00201             //  Outputs   //
00202             //------------//
00203 
00204 void Eos_incomp::sauve(FILE* fich) const {
00205 
00206     Eos::sauve(fich) ; 
00207     
00208     fwrite_be(&rho0, sizeof(double), 1, fich) ; 
00209     fwrite_be(&ent0, sizeof(double), 1, fich) ; 
00210    
00211 }
00212 
00213 ostream& Eos_incomp::operator>>(ostream & ost) const {
00214     
00215     ost << "EOS of class Eos_incomp (relativistic incompressible matter) : " 
00216     << endl ; 
00217     ost << "   Constant density : " << rho0 << " rho_nuc" << endl ; 
00218     ost << "   Log-enthalpy threshold for non-zero density : " << ent0 
00219     << " c^2" <<  endl ; 
00220     
00221     return ost ;
00222 
00223 }
00224 
00225 
00226             //------------------------------//
00227             //    Computational routines    //
00228             //------------------------------//
00229 
00230 // Baryon density from enthalpy 
00231 //------------------------------
00232 
00233 double Eos_incomp::nbar_ent_p(double ent, const Param* ) const {
00234     
00235     if ( ent >= ent0 ) {
00236 
00237     return rho0 ;
00238     }
00239     else{
00240     return 0 ;
00241     }
00242 }
00243 
00244 // Energy density from enthalpy 
00245 //------------------------------
00246 
00247 double Eos_incomp::ener_ent_p(double ent, const Param* ) const {
00248     
00249     if ( ent >= ent0 ) {
00250 
00251     return rho0 ;
00252     }
00253     else{
00254     return 0 ;
00255     }
00256 }
00257 
00258 // Pressure from enthalpy 
00259 //------------------------
00260 
00261 double Eos_incomp::press_ent_p(double ent, const Param* ) const {
00262     
00263     if ( ent >= ent0 ) {
00264 
00265     return rho0 * (exp(ent) - double(1)) ;
00266     }
00267     else{
00268     return 0 ;
00269     }
00270 }
00271 
00272 
00273 // dln(n)/ln(H) from enthalpy 
00274 //---------------------------
00275 
00276 double Eos_incomp::der_nbar_ent_p(double ent, const Param* ) const {
00277     
00278     if ( ent >= ent0 ) {
00279     
00280     return 0 ;
00281     }
00282     else{
00283     return 0 ;
00284     }
00285 }
00286 
00287 // dln(e)/ln(H) from enthalpy 
00288 //---------------------------
00289 
00290 double Eos_incomp::der_ener_ent_p(double ent, const Param* ) const {
00291     
00292     if ( ent >= ent0 ) {
00293 
00294     return 0 ;
00295     }
00296     else{
00297     return 0 ;
00298     }
00299 }
00300 
00301 // dln(p)/ln(H) from enthalpy 
00302 //---------------------------
00303 
00304 double Eos_incomp::der_press_ent_p(double ent, const Param* ) const {
00305     
00306     if ( ent >= ent0 ) {
00307 
00308     return ent / (double(1) - exp(-ent)) ;
00309 
00310     }
00311     else{
00312     return 0 ;
00313     }
00314 }
00315 
00316 
00317 

Generated on Tue Feb 7 01:35:16 2012 for LORENE by  doxygen 1.4.6