eos_strange_cr.C

00001 /*
00002  * Methods for the class Eos_strange_cr_cr
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_cr_cr_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_strange_cr.C,v 1.5 2004/03/25 10:29:02 j_novak Exp $" ;
00032 
00033 /*
00034  * $Id: eos_strange_cr.C,v 1.5 2004/03/25 10:29:02 j_novak Exp $
00035  * $Log: eos_strange_cr.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:26  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  *
00064  * Revision 2.1  2000/11/24  13:26:50  eric
00065  * Correction erreur dans set_auxillary(): rho_nd_nucl est un membre !
00066  *
00067  * Revision 2.0  2000/11/23  14:46:35  eric
00068  * *** empty log message ***
00069  *
00070  *
00071  * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_strange_cr.C,v 1.5 2004/03/25 10:29:02 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 #include "unites.h"
00086 
00087             //------------------------------------//
00088             //      Constructors          //
00089             //------------------------------------//
00090 
00091 // Standard constructor
00092 // --------------------
00093 Eos_strange_cr::Eos_strange_cr(double n0_b60_i, double b60_i, double ent0_i,
00094             double eps_fit_i, double rho0_b60_i,
00095             double ent_nd_i, double rho_nd_i, double gam_i) :
00096          Eos("Strange matter EOS from Zdunik (2000) with crust"),
00097          n0_b60(n0_b60_i), 
00098          b60(b60_i), 
00099          ent0(ent0_i), 
00100          eps_fit(eps_fit_i), 
00101          rho0_b60(rho0_b60_i),
00102          ent_nd(ent_nd_i),
00103          rho_nd(rho_nd_i),
00104          gam(gam_i) {
00105     
00106     set_auxiliary() ; 
00107             
00108 }           
00109 
00110 // Copy constructor
00111 // -----------------
00112 
00113 Eos_strange_cr::Eos_strange_cr(const Eos_strange_cr& eos_i) :
00114         Eos(eos_i), 
00115         n0_b60(eos_i.n0_b60), 
00116         b60(eos_i.b60), 
00117         ent0(eos_i.ent0), 
00118         eps_fit(eos_i.eps_fit), 
00119         rho0_b60(eos_i.rho0_b60),
00120         ent_nd(eos_i.ent_nd),
00121         rho_nd(eos_i.rho_nd),
00122         gam(eos_i.gam)      {
00123 
00124     set_auxiliary() ; 
00125 
00126 }
00127 
00128 
00129 // Constructor from binary file
00130 // ----------------------------
00131 Eos_strange_cr::Eos_strange_cr(FILE* fich) :
00132     Eos(fich) {
00133         
00134     fread_be(&n0_b60, sizeof(double), 1, fich) ;        
00135     fread_be(&b60, sizeof(double), 1, fich) ;       
00136     fread_be(&ent0, sizeof(double), 1, fich) ;      
00137     fread_be(&eps_fit, sizeof(double), 1, fich) ;       
00138     fread_be(&rho0_b60, sizeof(double), 1, fich) ;      
00139     fread_be(&ent_nd, sizeof(double), 1, fich) ;        
00140     fread_be(&rho_nd, sizeof(double), 1, fich) ;        
00141     fread_be(&gam, sizeof(double), 1, fich) ;       
00142 
00143     set_auxiliary() ; 
00144 
00145 }
00146 
00147 // Constructor from a formatted file
00148 // ---------------------------------
00149 Eos_strange_cr::Eos_strange_cr(ifstream& fich) :
00150     Eos(fich) {
00151 
00152     char blabla[80] ;
00153 
00154     fich >> n0_b60 ; fich.getline(blabla, 80) ;
00155     fich >> b60 ; fich.getline(blabla, 80) ;
00156     fich >> ent0 ; fich.getline(blabla, 80) ;
00157     fich >> eps_fit ; fich.getline(blabla, 80) ;
00158     fich >> rho0_b60 ; fich.getline(blabla, 80) ;
00159     fich >> ent_nd ; fich.getline(blabla, 80) ;
00160     fich >> rho_nd ; fich.getline(blabla, 80) ;
00161     fich >> gam ; fich.getline(blabla, 80) ;
00162 
00163     set_auxiliary() ;
00164 
00165 }
00166             //--------------//
00167             //  Destructor  //
00168             //--------------//
00169 
00170 Eos_strange_cr::~Eos_strange_cr(){
00171 
00172     // does nothing
00173 
00174 }
00175 
00176             //--------------//
00177             //  Assignment  //
00178             //--------------//
00179 
00180 void Eos_strange_cr::operator=(const Eos_strange_cr& eosi) {
00181 
00182     set_name(eosi.name) ;
00183 
00184     n0_b60 = eosi.n0_b60 ;
00185     b60 = eosi.b60 ;
00186     ent0 = eosi.ent0 ;
00187     eps_fit = eosi.eps_fit ;
00188     rho0_b60 = eosi.rho0_b60 ;
00189     ent_nd = eosi.ent_nd ;
00190     rho_nd = eosi.rho_nd ;
00191     gam = eosi.gam ;
00192 
00193     set_auxiliary() ;
00194 
00195 }
00196 
00197 
00198           //-----------------------//
00199           //    Miscellaneous      //
00200           //-----------------------//
00201 
00202 void Eos_strange_cr::set_auxiliary() {
00203 
00204   using namespace Unites ;
00205 
00206     rho_nd_nucl = rho_nd * mevpfm3 ;
00207 
00208     rho0 = b60 * rho0_b60 * mevpfm3 ;
00209 
00210     b34 = pow(b60, double(0.75)) ;
00211 
00212     n0 = b34 * n0_b60 * double(10) ;    // 10 : fm^{-3} --> 0.1 fm^{-3}
00213 
00214     fach = (double(4) + eps_fit) / (double(1) + eps_fit) ;
00215 
00216     x_nd = (exp (ent_nd) - 1. )/( 1. +exp(ent_nd)/( gam - 1. ) );
00217 
00218     delent = log(1+fach*x_nd*rho_nd_nucl/rho0) / fach - ent_nd;
00219 
00220     ncr_nd = (1. + x_nd) * n0 * rho_nd_nucl/rho0
00221                 / exp(ent_nd) / exp(delent);
00222 
00223     unsgam1 = double(1) / ( gam - double(1) ) ;
00224 
00225     gam1sx = ( gam - double(1) - x_nd) / gam / x_nd ;
00226 
00227 
00228     cout << "ncr_nd =" << ncr_nd << endl ;
00229 
00230     cout << "eos ent_nd, x_nd, delent,  ent_nd +delent " << ent_nd << "    "<< x_nd << "    "
00231     << delent <<"      "<< (ent_nd+delent) << endl ;
00232 
00233     double pcr = x_nd * rho_nd_nucl *
00234              pow(( gam - 1. - x_nd)/gam/x_nd *
00235                    fabs((exp(ent_nd)-1.)), gam/(gam-1.)) ;
00236             
00237     double psq = ( exp(fach * (ent_nd + delent)) - 1) / fach
00238         * rho0 ;
00239         
00240     cout << " eos sqm fach =" << fach << "      PNS_s  " <<
00241             psq << "      PNS_cr = " << pcr << endl ;
00242     //double relp=psq/pcr ;
00243     cout << " 1+fach ... " << (1+fach*x_nd*rho_nd_nucl/rho0) << endl;
00244     cout << " log(miu) " <<
00245         log(pow((1+fach*x_nd*rho_nd_nucl/rho0),1./fach)) << endl;
00246     double miu_rate = rho0/n0*pow((1+fach*x_nd*rho_nd_nucl/rho0),1./fach)/
00247                       rho_nd_nucl/(1-x_nd/(gam-1.))*ncr_nd/exp(ent_nd) ;
00248     cout << " miu_rate -1 " << miu_rate -1. ;
00249 
00250     double aa0 = log(1+fach*x_nd*rho_nd_nucl/rho0) / fach ;
00251     double aa1 = log(pow(1+fach*x_nd*rho_nd_nucl/rho0,  1./fach)) ;
00252     cout << "aa0, aa1,  aa0-aa1 : " << aa0 << "  " <<  aa1 << "  " <<
00253         aa0-aa1 << endl ;
00254     cout << "fach : " << fach << endl ;
00255     cout << "1+fach*x_nd*rho_nd_nucl/rho0 : " << 1+fach*x_nd*rho_nd_nucl/rho0 << endl ; 
00256     
00257 }
00258 
00259 
00260             //------------------------//
00261             //  Comparison operators  //
00262             //------------------------//
00263 
00264 
00265 bool Eos_strange_cr::operator==(const Eos& eos_i) const {
00266 
00267     bool resu = true ;
00268 
00269     if ( eos_i.identify() != identify() ) {
00270     cout << "The second EOS is not of type Eos_strange_cr !" << endl ;
00271     resu = false ;
00272     }
00273     else{
00274     
00275     const Eos_strange_cr& eos = dynamic_cast<const Eos_strange_cr&>( eos_i ) ;
00276 
00277     if (eos.n0_b60 != n0_b60) {
00278         cout
00279         << "The two Eos_strange_cr have different n0_b60 : " << n0_b60 << " <-> "
00280         << eos.n0_b60 << endl ;
00281         resu = false ;
00282     }
00283 
00284     if (eos.b60 != b60) {
00285         cout
00286         << "The two Eos_strange_cr have different b60 : " << b60 << " <-> "
00287         << eos.b60 << endl ;
00288         resu = false ;
00289     }
00290 
00291     if (eos.ent0 != ent0) {
00292         cout
00293         << "The two Eos_strange_cr have different ent0 : " << ent0 << " <-> "
00294         << eos.ent0 << endl ;
00295         resu = false ;
00296     }
00297 
00298     if (eos.eps_fit != eps_fit) {
00299         cout
00300         << "The two Eos_strange_cr have different eps_fit : " << eps_fit
00301         << " <-> " << eos.eps_fit << endl ;
00302         resu = false ;
00303     }
00304 
00305     if (eos.rho0_b60 != rho0_b60) {
00306         cout
00307         << "The two Eos_strange_cr have different rho0_b60 : " << rho0_b60
00308         << " <-> " << eos.rho0_b60 << endl ;
00309         resu = false ;
00310     }
00311 
00312     
00313     if (eos.ent_nd != ent_nd) {
00314         cout
00315         << "The two Eos_strange_cr have different ent_nd : "
00316         << ent_nd
00317         << " <-> " << eos.ent_nd << endl ;
00318         resu = false ;
00319     }
00320 
00321     
00322     if (eos.rho_nd != rho_nd) {
00323         cout
00324         << "The two Eos_strange_cr have different rho_nd : "
00325         << rho_nd
00326         << " <-> " << eos.rho_nd << endl ;
00327         resu = false ;
00328     }
00329 
00330     
00331     if (eos.gam != gam) {
00332         cout
00333         << "The two Eos_strange_cr have different gam : " << gam
00334         << " <-> " << eos.gam << endl ;
00335         resu = false ;
00336     }
00337 
00338     
00339     
00340     }
00341 
00342     return resu ;
00343 
00344 }
00345 
00346 bool Eos_strange_cr::operator!=(const Eos& eos_i) const {
00347 
00348     return !(operator==(eos_i)) ;
00349 
00350 }
00351 
00352             //------------//
00353             //  Outputs   //
00354             //------------//
00355 
00356 void Eos_strange_cr::sauve(FILE* fich) const {
00357 
00358     Eos::sauve(fich) ;
00359 
00360     fwrite_be(&n0_b60, sizeof(double), 1, fich) ;   
00361     fwrite_be(&b60, sizeof(double), 1, fich) ;  
00362     fwrite_be(&ent0, sizeof(double), 1, fich) ; 
00363     fwrite_be(&eps_fit, sizeof(double), 1, fich) ;  
00364     fwrite_be(&rho0_b60, sizeof(double), 1, fich) ; 
00365     fwrite_be(&ent_nd, sizeof(double), 1, fich) ;   
00366     fwrite_be(&rho_nd, sizeof(double), 1, fich) ;   
00367     fwrite_be(&gam, sizeof(double), 1, fich) ;  
00368 
00369 }       
00370 
00371 ostream& Eos_strange_cr::operator>>(ostream & ost) const {
00372 
00373     ost <<
00374     "EOS of class Eos_strange_cr " << endl
00375       << " (Strange matter EOS from Zdunik (2000) with crust) "
00376     << endl ;
00377     ost << "   Baryon density at zero pressure : " << n0_b60
00378     << " * B_{60}^{3/4}" << endl ;
00379     ost << "   Bag constant B :  " << b60 << " * 60 MeV/fm^3"<< endl ;
00380     ost <<
00381     "   Log-enthalpy threshold for setting the energy density to non-zero: "
00382     << endl << "              " << ent0 << endl ;
00383     ost << "   Fitting parameter eps_fit : " << eps_fit << endl ;
00384     ost << "   Energy density at zero pressure : " << rho0_b60
00385     << " * B_{60}  MeV/fm^3" << endl ;
00386     ost << "   Log-enthalpy at neutron drip point : " << ent_nd << endl ;
00387     ost << "   Energy density at neutron drip point : " << rho_nd
00388         << " MeV/fm^3" << endl ;
00389     ost << "   Adiabatic index for the crust : " << gam << endl ;
00390 
00391     return ost ;
00392 
00393 }
00394 
00395 
00396             //------------------------------//
00397             //    Computational routines    //
00398             //------------------------------//
00399 
00400 // Baryon density from enthalpy
00401 //------------------------------
00402 
00403 double Eos_strange_cr::nbar_ent_p(double ent, const Param* ) const {
00404 
00405     if ( ent > ent0 ) {
00406 
00407         if (ent > ent_nd) { // Strange quark matter
00408 
00409             double entsqm = ent + delent ;
00410 
00411         return n0 * exp( double(3) * entsqm / (double(1) + eps_fit))  ;
00412     }
00413     else {      // crust
00414 
00415         double fn_au = pow( gam1sx * ( exp(ent)- double(1) ), unsgam1) ;
00416 
00417         return ncr_nd * fn_au ;
00418 
00419     }
00420 
00421     }
00422     else{
00423     return 0 ;
00424     }
00425 }
00426 
00427 // Energy density from enthalpy
00428 //------------------------------
00429 
00430 double Eos_strange_cr::ener_ent_p(double ent, const Param* ) const {
00431 
00432 
00433     if ( ent > ent0 ) {
00434 
00435         if (ent > ent_nd) { // Strange quark matter
00436 
00437             double entsqm = ent + delent ;
00438 
00439         double pp = ( exp(fach * entsqm) - double(1)) / fach  * rho0 ;
00440 
00441         return rho0 + double(3) * pp / (double(1) + eps_fit) ;
00442 
00443     }
00444     else {      // crust
00445 
00446         double fn_au = pow( gam1sx *(exp(ent) - double(1) ), unsgam1) ;
00447 
00448         return  rho_nd_nucl * ( (double(1) - x_nd * unsgam1 ) * fn_au
00449              + x_nd * unsgam1 * pow(fn_au,  gam)) ;
00450     }
00451 
00452     }
00453     else{
00454     return 0 ;
00455     }
00456 }
00457 
00458 // Pressure from enthalpy
00459 //------------------------
00460 
00461 double Eos_strange_cr::press_ent_p(double ent, const Param* ) const {
00462 
00463     if ( ent > ent0 ) {
00464 
00465         if (ent > ent_nd) { // Strange quark matter
00466 
00467             double entsqm = ent + delent ;
00468 
00469         return ( exp(fach * entsqm) - double(1) ) / fach  * rho0 ;
00470         }
00471         else{       // crust
00472 
00473         double fn_au = pow( gam1sx *(exp(ent) - double(1) ), unsgam1) ;
00474 
00475         return x_nd * rho_nd_nucl * pow(fn_au, gam) ;
00476 
00477         }
00478 
00479 
00480     }
00481     else{
00482     return 0 ;
00483     }
00484 }
00485 
00486 
00487 // dln(n)/ln(H) from enthalpy
00488 //---------------------------
00489 
00490 double Eos_strange_cr::der_nbar_ent_p(double ent, const Param* ) const {
00491 
00492     if ( ent > ent0 ) {
00493 
00494     if (ent > ent_nd) { // Strange quark matter
00495 
00496             double entsqm = ent + delent ;
00497 
00498         return double(3) * entsqm / ( double(1) +  eps_fit ) ;
00499     }
00500         else{       // crust
00501 
00502         cout << "Eos_strange_cr::der_nbar_ent_p not ready yet !" << endl ;
00503         abort() ;
00504         return 0 ;
00505         }
00506 
00507     }
00508     else{
00509     return 0 ;
00510     }
00511 }
00512 
00513 // dln(e)/ln(H) from enthalpy
00514 //---------------------------
00515 
00516 double Eos_strange_cr::der_ener_ent_p(double ent, const Param* ) const {
00517 
00518     if ( ent > ent0 ) {
00519 
00520     if (ent > ent_nd) { // Strange quark matter
00521 
00522             double entsqm = ent + delent ;
00523 
00524         double xx = fach * entsqm ;
00525 
00526         return xx / ( double(1) +
00527             ( double(1) + eps_fit ) / double(3) * exp(-xx) ) ;
00528     }
00529         else{       // crust
00530 
00531         cout << "Eos_strange_cr::der_ener_ent_p not ready yet !" << endl ;
00532         abort() ;
00533         return 0 ;
00534         }
00535     }
00536     else{
00537     return 0 ;
00538     }
00539 }
00540 
00541 // dln(p)/ln(H) from enthalpy
00542 //---------------------------
00543 
00544 double Eos_strange_cr::der_press_ent_p(double ent, const Param* ) const {
00545     
00546     if ( ent > ent0 ) {
00547 
00548 
00549     if (ent > ent_nd) { // Strange quark matter
00550             
00551             double entsqm = ent + delent ;
00552 
00553         double xx = fach * entsqm ; 
00554 
00555         return xx / ( double(1) - exp(-xx) ) ;
00556     }
00557         else{       // crust
00558 
00559         cout << "Eos_strange_cr::der_press_ent_p not ready yet !" << endl ;
00560         abort() ;
00561         return 0 ;      
00562         }
00563 
00564     }
00565     else{
00566     return 0 ;
00567     }
00568 }
00569 
00570 
00571 
00572         

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