63 #include "eos_fitting.h" 65 #include "utilitaires.h" 82 const char* path) :
Eos(name_i) {
96 fread(
dataname,
sizeof(
char), 160, fich) ;
108 fich.getline(path, 160) ;
134 fwrite(
dataname,
sizeof(
char), 160, fich) ;
147 for (
int i=0; i<3; i++) {
148 fich.getline(blabla, 120) ;
152 fich >> nb_coef ; fich.getline(blabla, 120) ;
154 for (
int i=0; i<3; i++) {
155 fich.getline(blabla, 120) ;
158 pp =
new double[nb_coef] ;
160 for (
int i=0; i<nb_coef; i++) {
161 fich >>
pp[i] ; fich.getline(blabla, 120) ;
180 if ( ent >
double(0) ) {
189 double trans_dens = msol_si /
pow(g_si*msol_si/c_si/c_si,3.)
192 while (xx > 1.e-15) {
198 while (ent_value > 1.e-15) {
208 double eee = -
pp[7]*yy+
pp[9] ;
209 double fff = -
pp[8]*yy+
pp[10] ;
212 ent_value =
exp(ent) - 1.0
213 -( aaa*bbb - 1. ) * fc(eee)
214 -
pp[11]*
pow(yy,
pp[12])*fc(-eee)*fc(fff)
215 -
pp[13]*
pow(yy,
pp[14])*fc(-fff)
216 -( ccc*bbb + aaa*ddd*ggg )*fc(eee)
217 -yy*( aaa*bbb - 1. )*
pp[7]*gc(eee)
218 -
pp[11]*
pp[12]*
pow(yy,
pp[12])*fc(-eee)*fc(fff)
219 +
pp[11]*
pow(yy,
pp[12]+1.)*(
pp[7]*gc(-eee)*fc(fff)
220 -
pp[8]*fc(-eee)*gc(fff))
222 -
pp[8]*yy*gc(-fff)) ;
230 nb = rhob * trans_dens ;
247 if ( ent >
double(0) ) {
255 double trans_dens = msol_si /
pow(g_si*msol_si/c_si/c_si,3.)
259 double yy = nb / trans_dens ;
263 double eee = -
pp[7]*yy+
pp[9] ;
264 double fff = -
pp[8]*yy+
pp[10] ;
266 double epsil = ( aaa*bbb - 1. ) * fc(eee)
267 +
pp[11]*
pow(yy,
pp[12])*fc(-eee)*fc(fff)
268 +
pp[13]*
pow(yy,
pp[14])*fc(-fff) ;
274 double ee = nb * (1. + epsil) ;
291 if ( ent >
double(0) ) {
299 double trans_dens = msol_si /
pow(g_si*msol_si/c_si/c_si,3.)
303 double yy = nb / trans_dens ;
309 double eee = -
pp[7]*yy+
pp[9] ;
310 double fff = -
pp[8]*yy+
pp[10] ;
313 double ppp = yy*( ccc*bbb + aaa*ddd*ggg )*fc(eee)
314 +yy*yy*( aaa*bbb - 1. )*
pp[7]*gc(eee)
315 +
pp[11]*
pp[12]*
pow(yy,
pp[12]+1.)*fc(-eee)*fc(fff)
316 -
pp[11]*
pow(yy,
pp[12]+2.)*(
pp[7]*gc(-eee)*fc(fff)
317 -
pp[8]*fc(-eee)*gc(fff))
318 +
pp[13]*
pow(yy,
pp[14]+1.)*(
pp[14]*fc(-fff)-
pp[8]*yy*gc(-fff)) ;
324 double pres = ppp * trans_dens ;
341 if ( ent >
double(0) ) {
349 double trans_dens = msol_si /
pow(g_si*msol_si/c_si/c_si,3.)
353 double yy = nb / trans_dens ;
359 double eee = -
pp[7]*yy+
pp[9] ;
360 double fff = -
pp[8]*yy+
pp[10] ;
365 double dlnsdlh =
exp(ent) * ent /
366 ( ( ccc*bbb + aaa*ddd*ggg )*( fc(eee) + 2.*yy*
pp[7]*gc(eee) )
367 +yy*
pp[7]*( aaa*bbb - 1. )*( 2.*gc(eee) - yy*
pp[7]*hc(eee) )
368 +
pp[11]*
pp[12]*(
pp[12]+1.)*
pow(yy,
pp[12])*fc(-eee)*fc(fff)
370 *( -
pp[7]*gc(-eee)*fc(fff) +
pp[8]*fc(-eee)*gc(fff) )
371 -
pp[11]*
pow(yy,
pp[12]+2.)*(
pp[7]*
pp[7]*hc(-eee)*fc(fff)
372 +2.*
pp[7]*
pp[8]*gc(-eee)*gc(fff)
373 +
pp[8]*
pp[8]*fc(-eee)*hc(fff) )
375 -2.*
pp[8]*
pp[13]*(
pp[14]+1.)*
pow(yy,
pp[14]+1.)*gc(-fff)
377 +( jjj*bbb + 2.*ccc*ddd*ggg
379 *ggg*(ggg+
pp[5]) )*fc(eee)
387 return double(1) /
pp[12] ;
400 if ( ent >
double(0) ) {
408 double trans_dens = msol_si /
pow(g_si*msol_si/c_si/c_si,3.)
412 double yy = nb / trans_dens ;
418 double eee = -
pp[7]*yy+
pp[9] ;
419 double fff = -
pp[8]*yy+
pp[10] ;
424 double dlesdlh = dlnsdlh
425 * (1. + ( ( ccc*bbb + aaa*ddd*ggg )*fc(eee)
426 +yy*
pp[7]*( aaa*bbb - 1. )*gc(eee)
427 +
pp[11]*
pp[12]*
pow(yy,
pp[12])*fc(-eee)*fc(fff)
428 +
pp[11]*
pow(yy,
pp[12]+1.)*( -
pp[7]*gc(-eee)*fc(fff)
429 +
pp[8]*fc(-eee)*gc(fff) )
431 -
pp[8]*
pp[13]*
pow(yy,
pp[14]+1.)*gc(-fff) )
432 / ( 1. + ( aaa*bbb - 1. )*fc(eee)
433 +
pp[11]*
pow(yy,
pp[12])*fc(-eee)*fc(fff)
434 +
pp[13]*
pow(yy,
pp[14])*fc(-fff) ) ) ;
441 return double(1) /
pp[12] ;
454 if ( ent >
double(0) ) {
462 double trans_dens = msol_si /
pow(g_si*msol_si/c_si/c_si,3.)
466 double yy = nb / trans_dens ;
472 double eee = -
pp[7]*yy+
pp[9] ;
473 double fff = -
pp[8]*yy+
pp[10] ;
480 double dlpsdlh = dlnsdlh
481 * ( ( ccc*bbb + aaa*ddd*ggg )*fc(eee)
482 +( jjj*bbb + 2.*ccc*ddd*ggg
485 +2.*yy*
pp[7]*( ccc*bbb + aaa*ddd*ggg )*gc(eee)
486 +yy*
pp[7]*( aaa*bbb - 1. )*(2.*gc(eee) - yy*
pp[7]*hc(eee))
487 +
pp[11]*
pp[12]*(
pp[12]+1.)*
pow(yy,
pp[12])*fc(-eee)*fc(fff)
489 *( -
pp[7]*gc(-eee)*fc(fff) +
pp[8]*fc(-eee)*gc(fff) )
490 -
pp[11]*
pow(yy,
pp[12]+2.)*(
pp[7]*
pp[7]*hc(-eee)*fc(fff)
491 +2.*
pp[7]*
pp[8]*gc(-eee)*gc(fff)
492 +
pp[8]*
pp[8]*fc(-eee)*hc(fff) )
493 +
pp[13]*(
pp[14]+1.)*
pow(yy,
pp[14])*(
pp[14]*fc(-fff)
494 -2.*
pp[8]*yy*gc(-fff) )
496 / ( ( ccc*bbb + aaa*ddd*ggg )*fc(eee)
497 +yy*
pp[7]*( aaa*bbb - 1. )*gc(eee)
498 +
pp[11]*
pow(yy,
pp[12])*(
pp[12]*fc(-eee)*fc(fff)
499 -yy*
pp[7]*gc(-eee)*fc(fff)
500 +yy*
pp[8]*fc(-eee)*gc(fff) )
502 -yy*
pp[8]*gc(-fff) ) ) ;
509 return (
pp[12] + 1.) /
pp[12] ;
519 double fc(
double xx) {
521 double resu = double(1) / (double(1) +
exp(xx)) ;
527 double gc(
double xx) {
532 resu =
exp(-xx) /
pow(
exp(-xx)+
double(1),
double(2)) ;
535 resu =
exp(xx) /
pow(
double(1)+
exp(xx),
double(2)) ;
542 double hc(
double xx) {
547 resu =
exp(-xx) * (
exp(-xx)-double(1)) /
548 pow(
exp(-xx)+double(1),double(3)) ;
551 resu =
exp(xx) * (double(1)-
exp(xx)) /
552 pow(
double(1)+
exp(xx),double(3)) ;
Cmp exp(const Cmp &)
Exponential.
virtual double ener_ent_p(double ent, const Param *par=0x0) const
Computes the total energy density from the log-enthalpy.
Eos_fitting(const char *name_i, const char *data, const char *path)
Standard constructor.
Standard units of space, time and mass.
Equation of state base class.
virtual void sauve(FILE *) const
Save in a file.
virtual void sauve(FILE *) const
Save in a file.
virtual double press_ent_p(double ent, const Param *par=0x0) const
Computes the pressure from the log-enthalpy.
double * pp
Array of the coefficients of the fitting data.
virtual double der_ener_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
virtual double nbar_ent_p(double ent, const Param *par=0x0) const
Computes the baryon density from the log-enthalpy.
void read_coef()
Reading coefficients of the fitting equation for the energy density, the pressure, and the enthalpy.
virtual double der_nbar_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Cmp pow(const Cmp &, int)
Power .
char dataname[160]
Name of the file containing the fitting data.
virtual ~Eos_fitting()
Destructor.
virtual double der_press_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.