eos_strange.C

00001 /*
00002  * Methods for the class Eos_strange
00003  *
00004  * (see file eos.h for documentation)
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2000 J. Leszek Zdunik
00010  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License as published by
00016  *   the Free Software Foundation; either version 2 of the License, or
00017  *   (at your option) any later version.
00018  *
00019  *   LORENE is distributed in the hope that it will be useful,
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *   GNU General Public License for more details.
00023  *
00024  *   You should have received a copy of the GNU General Public License
00025  *   along with LORENE; if not, write to the Free Software
00026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 
00031 char eos_strange_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_strange.C,v 1.5 2004/03/25 10:29:02 j_novak Exp $" ;
00032 
00033 /*
00034  * $Id: eos_strange.C,v 1.5 2004/03/25 10:29:02 j_novak Exp $
00035  * $Log: eos_strange.C,v $
00036  * Revision 1.5  2004/03/25 10:29:02  j_novak
00037  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00038  *
00039  * Revision 1.4  2002/10/16 14:36:35  j_novak
00040  * Reorganization of #include instructions of standard C++, in order to
00041  * use experimental version 3 of gcc.
00042  *
00043  * Revision 1.3  2002/04/09 14:32:15  e_gourgoulhon
00044  * 1/ Added extra parameters in EOS computational functions (argument par)
00045  * 2/ New class MEos for multi-domain EOS
00046  *
00047  * Revision 1.2  2001/12/04 21:27:53  e_gourgoulhon
00048  *
00049  * All writing/reading to a binary file are now performed according to
00050  * the big endian convention, whatever the system is big endian or
00051  * small endian, thanks to the functions fwrite_be and fread_be
00052  *
00053  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00054  * LORENE
00055  *
00056  * Revision 2.2  2001/02/07  09:49:47  eric
00057  * Suppression de la fonction derent_ent_p.
00058  * Ajout des fonctions donnant les derivees de l'EOS:
00059  *       der_nbar_ent_p
00060  *      der_ener_ent_p
00061  *      der_press_ent_p
00062  *
00063  * Revision 2.1  2000/10/25  10:54:41  eric
00064  * Correction erreur dans la densite d'energie (conversion d'unite).
00065  *
00066  * Revision 2.0  2000/10/24  15:29:11  eric
00067  * *** empty log message ***
00068  *
00069  *
00070  * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_strange.C,v 1.5 2004/03/25 10:29:02 j_novak Exp $
00071  *
00072  */
00073 
00074 // Headers C
00075 #include <stdlib.h>
00076 #include <string.h>
00077 #include <math.h>
00078 
00079 // Headers Lorene
00080 #include "eos.h"
00081 #include "cmp.h"
00082 #include "utilitaires.h"
00083 #include "unites.h"
00084 
00085             //------------------------------------//
00086             //      Constructors          //
00087             //------------------------------------//
00088 
00089 // Standard constructor
00090 // --------------------
00091 Eos_strange::Eos_strange(double n0_b60_i, double b60_i, double ent0_i, 
00092             double eps_fit_i, double rho0_b60_i) :
00093          Eos("Strange matter EOS from Zdunik (2000)"), 
00094          n0_b60(n0_b60_i), 
00095          b60(b60_i), 
00096          ent0(ent0_i), 
00097          eps_fit(eps_fit_i), 
00098          rho0_b60(rho0_b60_i) {
00099 
00100     set_auxiliary() ; 
00101             
00102 }           
00103 
00104 // Copy constructor
00105 // -----------------
00106 
00107 Eos_strange::Eos_strange(const Eos_strange& eos_i) : 
00108         Eos(eos_i), 
00109         n0_b60(eos_i.n0_b60), 
00110         b60(eos_i.b60), 
00111         ent0(eos_i.ent0), 
00112         eps_fit(eos_i.eps_fit), 
00113         rho0_b60(eos_i.rho0_b60)    {
00114 
00115     set_auxiliary() ; 
00116 
00117 }
00118 
00119 
00120 // Constructor from binary file
00121 // ----------------------------
00122 Eos_strange::Eos_strange(FILE* fich) : 
00123     Eos(fich) {
00124         
00125     fread_be(&n0_b60, sizeof(double), 1, fich) ;        
00126     fread_be(&b60, sizeof(double), 1, fich) ;       
00127     fread_be(&ent0, sizeof(double), 1, fich) ;      
00128     fread_be(&eps_fit, sizeof(double), 1, fich) ;       
00129     fread_be(&rho0_b60, sizeof(double), 1, fich) ;      
00130     
00131     set_auxiliary() ; 
00132 
00133 }
00134 
00135 // Constructor from a formatted file
00136 // ---------------------------------
00137 Eos_strange::Eos_strange(ifstream& fich) : 
00138     Eos(fich) {
00139 
00140     char blabla[80] ;
00141         
00142     fich >> n0_b60 ; fich.getline(blabla, 80) ;
00143     fich >> b60 ; fich.getline(blabla, 80) ;
00144     fich >> ent0 ; fich.getline(blabla, 80) ;
00145     fich >> eps_fit ; fich.getline(blabla, 80) ;
00146     fich >> rho0_b60 ; fich.getline(blabla, 80) ;
00147     
00148     set_auxiliary() ; 
00149 
00150 }
00151             //--------------//
00152             //  Destructor  //
00153             //--------------//
00154 
00155 Eos_strange::~Eos_strange(){
00156     
00157     // does nothing
00158         
00159 }
00160 
00161             //--------------//
00162             //  Assignment  //
00163             //--------------//
00164 
00165 void Eos_strange::operator=(const Eos_strange& eosi) {
00166     
00167     set_name(eosi.name) ; 
00168     
00169     n0_b60 = eosi.n0_b60 ; 
00170     b60 = eosi.b60 ; 
00171     ent0 = eosi.ent0 ; 
00172     eps_fit = eosi.eps_fit ; 
00173     rho0_b60 = eosi.rho0_b60 ; 
00174     
00175     set_auxiliary() ; 
00176     
00177 }
00178 
00179 
00180           //-----------------------//
00181           //    Miscellaneous      //
00182           //-----------------------//
00183 
00184 void Eos_strange::set_auxiliary() {
00185     
00186   using namespace Unites ;
00187     
00188     rho0 = b60 * rho0_b60 * mevpfm3 ;
00189     
00190     b34 = pow(b60, double(0.75)) ;
00191 
00192     n0 = b34 * n0_b60 * double(10) ;    // 10 : fm^{-3} --> 0.1 fm^{-3}
00193     
00194     fach = (double(4) + eps_fit) / (double(1) + eps_fit) ;
00195    
00196 }
00197 
00198 
00199             //------------------------//
00200             //  Comparison operators  //
00201             //------------------------//
00202 
00203 
00204 bool Eos_strange::operator==(const Eos& eos_i) const {
00205     
00206     bool resu = true ; 
00207     
00208     if ( eos_i.identify() != identify() ) {
00209     cout << "The second EOS is not of type Eos_strange !" << endl ; 
00210     resu = false ; 
00211     }
00212     else{
00213     
00214     const Eos_strange& eos = dynamic_cast<const Eos_strange&>( eos_i ) ; 
00215 
00216     if (eos.n0_b60 != n0_b60) {
00217         cout 
00218         << "The two Eos_strange have different n0_b60 : " << n0_b60 << " <-> " 
00219         << eos.n0_b60 << endl ; 
00220         resu = false ; 
00221     }
00222 
00223     if (eos.b60 != b60) {
00224         cout 
00225         << "The two Eos_strange have different b60 : " << b60 << " <-> " 
00226         << eos.b60 << endl ; 
00227         resu = false ; 
00228     }
00229 
00230     if (eos.ent0 != ent0) {
00231         cout 
00232         << "The two Eos_strange have different ent0 : " << ent0 << " <-> " 
00233         << eos.ent0 << endl ; 
00234         resu = false ; 
00235     }
00236 
00237     if (eos.eps_fit != eps_fit) {
00238         cout 
00239         << "The two Eos_strange have different eps_fit : " << eps_fit 
00240         << " <-> " << eos.eps_fit << endl ; 
00241         resu = false ; 
00242     }
00243 
00244     if (eos.rho0_b60 != rho0_b60) {
00245         cout 
00246         << "The two Eos_strange have different rho0_b60 : " << rho0_b60 
00247         << " <-> " << eos.rho0_b60 << endl ; 
00248         resu = false ; 
00249     }
00250 
00251     
00252     }
00253     
00254     return resu ; 
00255     
00256 }
00257 
00258 bool Eos_strange::operator!=(const Eos& eos_i) const {
00259  
00260     return !(operator==(eos_i)) ; 
00261        
00262 }
00263 
00264             //------------//
00265             //  Outputs   //
00266             //------------//
00267 
00268 void Eos_strange::sauve(FILE* fich) const {
00269 
00270     Eos::sauve(fich) ; 
00271     
00272     fwrite_be(&n0_b60, sizeof(double), 1, fich) ;   
00273     fwrite_be(&b60, sizeof(double), 1, fich) ;  
00274     fwrite_be(&ent0, sizeof(double), 1, fich) ; 
00275     fwrite_be(&eps_fit, sizeof(double), 1, fich) ;  
00276     fwrite_be(&rho0_b60, sizeof(double), 1, fich) ; 
00277 
00278 }           
00279 
00280 ostream& Eos_strange::operator>>(ostream & ost) const {
00281     
00282     ost << 
00283     "EOS of class Eos_strange (Strange matter EOS from Zdunik (2000)) : " 
00284     << endl ; 
00285     ost << "   Baryon density at zero pressure : " << n0_b60 
00286     << " * B_{60}^{3/4}" << endl ; 
00287     ost << "   Bag constant B :  " << b60 << " * 60 MeV/fm^3"<< endl ;
00288     ost << 
00289     "   Log-enthalpy threshold for setting the energy density to non-zero: " 
00290     << endl << "              " << ent0 << endl ; 
00291     ost << "   Fitting parameter eps_fit : " << eps_fit << endl ; 
00292     ost << "   Energy density at zero pressure : " << rho0_b60 
00293     << " * B_{60}  MeV/fm^3" << endl ; 
00294     
00295     return ost ;
00296 
00297 }
00298 
00299 
00300             //------------------------------//
00301             //    Computational routines    //
00302             //------------------------------//
00303 
00304 // Baryon density from enthalpy 
00305 //------------------------------
00306 
00307 double Eos_strange::nbar_ent_p(double ent, const Param* ) const {
00308 
00309     if ( ent > ent0 ) {
00310 
00311     return n0 * exp( double(3) * ent / (double(1) + eps_fit))  ;
00312 
00313     }
00314     else{
00315     return 0 ;
00316     }
00317 }
00318 
00319 // Energy density from enthalpy
00320 //------------------------------
00321 
00322 double Eos_strange::ener_ent_p(double ent, const Param* ) const {
00323 
00324 
00325     if ( ent > ent0 ) {
00326 
00327     double pp = ( exp(fach * ent) - 1) / fach  * rho0 ;
00328 
00329     return rho0 + double(3) * pp / (double(1) + eps_fit) ;
00330 
00331     }
00332     else{
00333     return 0 ;
00334     }
00335 }
00336 
00337 // Pressure from enthalpy
00338 //------------------------
00339 
00340 double Eos_strange::press_ent_p(double ent, const Param* ) const {
00341 
00342     if ( ent > ent0 ) {
00343 
00344     return ( exp(fach * ent) - 1) / fach  * rho0 ;
00345 
00346     }
00347     else{
00348     return 0 ;
00349     }
00350 }
00351 
00352 
00353 
00354 // dln(n)/ln(H) from enthalpy
00355 //---------------------------
00356 
00357 double Eos_strange::der_nbar_ent_p(double ent, const Param* ) const {
00358 
00359     if ( ent > ent0 ) {
00360 
00361     return double(3) * ent / ( double(1) +  eps_fit ) ;
00362 
00363     }
00364     else{
00365     return 0 ;
00366     }
00367 }
00368 
00369 // dln(e)/ln(H) from enthalpy
00370 //---------------------------
00371 
00372 double Eos_strange::der_ener_ent_p(double ent, const Param* ) const {
00373 
00374     if ( ent > ent0 ) {
00375 
00376     double xx = fach * ent ;
00377 
00378     return xx / ( double(1) +
00379         ( double(1) + eps_fit ) / double(3) * exp(-xx) ) ;
00380 
00381     }
00382     else{
00383     return 0 ;
00384     }
00385 }
00386 
00387 // dln(p)/ln(H) from enthalpy
00388 //---------------------------
00389 
00390 double Eos_strange::der_press_ent_p(double ent, const Param* ) const {
00391     
00392     if ( ent > ent0 ) {
00393 
00394     double xx = fach * ent ; 
00395 
00396     return xx / ( double(1) - exp(-xx) ) ;
00397 
00398     }
00399     else{
00400     return 0 ;
00401     }
00402 }
00403 

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