37#include "utilitaires.h"
42 void interpol_herm_2d(
const Tbl&,
const Tbl&,
const Tbl&,
const Tbl&,
const Tbl&,
43 const Tbl&,
double,
double,
double&,
double&,
double&) ;
44 void interpol_linear_2d(
const Tbl&,
const Tbl&,
const Tbl&,
double,
double,
int&,
int&,
double&) ;
45 void huntm(
const Tbl& xx,
double&
x,
int& i_low) ;
70 size_t ret = fread(tmp_string,
sizeof(
char), nc, fich) ;
74 cerr <<
"Ye_tabul: constructor from a binary file:" << endl ;
75 cerr <<
"Problems in reading the table name." << endl ;
76 cerr <<
"Aborting..." << endl ;
111 if (
hhh != 0x0)
delete hhh ;
112 if (
Y_e != 0x0)
delete Y_e ;
113 if (
ppp != 0x0)
delete ppp ;
116 if (
d2p != 0x0)
delete d2p ;
128 char tmp_string[160] ;
130 fwrite(tmp_string,
sizeof(
char), 160, fich) ;
135 ost <<
"Non-beta equilibrium EOS of class Ye_eos_tabul (tabulated out of beta-equilibrium EoS) : "
137 ost <<
"Built from file " <<
tablename << endl ;
138 ost <<
"Authors : " <<
authors << endl ;
139 ost <<
"Number of points in file : " <<
hhh->get_dim(0)
140 <<
" in enthalpy, and " <<
hhh->get_dim(1)
141 <<
" in electronic fraction." << endl ;
157 cerr <<
"Ye_eos_tabul::read_table(): " << endl ;
158 cerr <<
"Problem in opening the EOS file!" << endl ;
159 cerr <<
"While trying to open " <<
tablename << endl ;
160 cerr <<
"Aborting..." << endl ;
164 fich.ignore(1000,
'\n') ;
167 for (
int i=0; i<3; i++) {
168 fich.ignore(1000,
'\n') ;
172 fich >> nbp1 >> nbp2 ; fich.ignore(1000,
'\n') ;
173 if ( (nbp1<=0) || (nbp2<=0) ) {
174 cerr <<
"Ye_eos_tabul::read_table(): " << endl ;
175 cerr <<
"Wrong value for the number of lines!" << endl ;
176 cerr <<
"nbp1 = " << nbp1 <<
", nbp2 = " << nbp2 << endl ;
177 cerr <<
"Aborting..." << endl ;
181 for (
int i=0; i<3; i++) {
182 fich.ignore(1000,
'\n') ;
185 ppp =
new Tbl(nbp2, nbp1) ;
186 hhh =
new Tbl(nbp2, nbp1) ;
187 Y_e =
new Tbl(nbp2, nbp1) ;
192 d2p =
new Tbl(nbp2, nbp1) ;
195 ppp->set_etat_qcq() ;
196 hhh->set_etat_qcq() ;
197 Y_e->set_etat_qcq() ;
198 mu_l->set_etat_qcq() ;
200 dpdh->set_etat_qcq() ;
201 dpdye->set_etat_qcq() ;
202 d2p->set_etat_qcq() ;
205 double c2 = c_si * c_si ;
206 double nb_fm3, rho_cgs, p_cgs, ent, ye, mul, der2, cs2, source_d ;
210 for (
int j=0; j<nbp2; j++) {
211 for (
int i=0; i<nbp1; i++) {
212 fich >> no >> nb_fm3>> rho_cgs >> p_cgs>> ent >> ye >> cs2 >> mul >> der2 >> source_d ;
214 fich.ignore(1000,
'\n') ;
215 if ( (nb_fm3<0) || (rho_cgs<0) || (p_cgs < 0) ){
216 cerr <<
"Ye_eos_tabul::read_table(): " << endl ;
217 cerr <<
"Negative value in table!" << endl ;
218 cerr <<
"nb = " << nb_fm3 <<
", rho = " << rho_cgs <<
219 ", p = " << p_cgs << endl ;
220 cerr <<
"Aborting..." << endl ;
224 double psc2 = 0.1*p_cgs/c2 ;
225 double rho_si = rho_cgs*1000. ;
227 double h_read = ent ;
228 if ( (i==0) ) ww = h_read ;
229 double h_new = h_read - ww + 1e-14;
231 ppp->set(j, i) = psc2/rhonuc_si ;
232 hhh->set(j, i) = h_new ;
233 Y_e->set(j, i) = ye ;
235 mu_l->set(j, i) = mul*mev_si*1e44/(rhonuc_si*c2) ;
236 dpdh->set(j, i) = (rho_si + psc2)/rhonuc_si ;
237 dpdye->set(j, i) = -mul*nb_fm3*mevpfm3 ;
238 d2p->set(j, i) = 0.1*der2/(c2*rhonuc_si) ;
243 hmin = (*hhh)(0, 0) ;
244 hmax = (*hhh)(0, nbp1-1) ;
246 yemin = (*Y_e)(0, 0) ;
247 yemax = (*Y_e)(nbp2-1, 0) ;
249 cout <<
"hmin: " <<
hmin <<
", hmax: " <<
hmax << endl ;
250 cout <<
"yemin: " <<
yemin <<
", yemax: " <<
yemax << endl ;
262 cerr <<
"Warning: Ye_eos_tabul::new_cold_Eos " <<
263 "The corresponding cold EoS is likely not to work" << endl ;
264 cout <<
"read from file: "<<
tablename.c_str() << endl;
285 cout <<
"The second EOS is not of type Ye_eos_tabul !" << endl ;
307 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
314 cout <<
"Ye_eos_tabul::nbar_Hs_p : ent > hmax !" << endl ;
319 cerr <<
"Ye_eos_tabul::nbar_Hs_p : Y_e not in the tabulated interval !"
321 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax
326 double p_int, dpdye_int, dpdh_int ;
329 dpdye_int, dpdh_int) ;
331 double nbar_int = dpdh_int *
exp(-ent) ;
345 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
352 cout <<
"Ye_eos_tabul::ener_Hs_p : ent > hmax !" << endl ;
357 cerr <<
"Ye_eos_tabul::ener_Hs_p : Y_e not in the tabulated interval !"
359 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax
364 double p_int, dpdye_int, dpdh_int ;
366 dpdye_int, dpdh_int) ;
369 double f_int = - p_int + dpdh_int;
380 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
387 cout <<
"Ye_eos_tabul::press_Hs_p : ent > hmax !" << endl ;
392 cerr <<
"Ye_eos_tabul::press_Hs_p : Y_e not in the tabulated interval !"
394 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax
399 double p_int, dpdye_int, dpdh_int ;
401 dpdye_int, dpdh_int) ;
411 static int i_near =
hhh->get_dim(0) / 2 ;
412 static int j_near =
Y_e->get_dim(1) / 2 ;
414 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
420 for (
int i=0 ; i<
Y_e->get_dim(1) ; i++){
421 ye_1D.
set(i) = (*Y_e)(i,0) ;
426 cout <<
"Eos_tabul::csound_square_Hs_p : ent>hmax !" << endl ;
430 cerr <<
"Ye_eos_tabul::csound_square_Hs_p : Y_e not in the tabulated interval !"
432 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax
439 interpol_linear_2d(enthalpy, ye_1D, *
c_sound2, ent, ye, i_near, j_near, csound0) ;
447 interpol_linear_2d(enthalpy, ye_1D, *
c_sound2,
hmin, ye, i_near, j_near, csound0) ;
454 cerr <<
"Warning : (H,Y_e) EoS have no contribution from chi^2 ; Ye_eos_tabul::chi2_Hs_p :function not implemented." << endl;
455 cerr <<
"Aborting ..." << endl;
462 static int i_near =
hhh->get_dim(0) / 2 ;
463 static int j_near =
Y_e->get_dim(1) / 2 ;
465 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
471 for (
int i=0 ; i<
Y_e->get_dim(1) ; i++){
472 ye_1D.
set(i) = (*Y_e)(i,0) ;
478 cout <<
"Eos_tabul::mul_Hs_p : ent>hmax !" << endl ;
483 cerr <<
"Ye_eos_tabul::mul_Hs_p : Y_e not in the tabulated interval !"
485 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax
492 interpol_linear_2d(enthalpy, ye_1D, *
mu_l, ent, ye, i_near, j_near, mul0) ;
499 interpol_linear_2d(enthalpy, ye_1D, *
mu_l,
hmin, ye, i_near, j_near, mul0) ;
505 static int i_near =
hhh->get_dim(0) / 2 ;
506 static int j_near =
Y_e->get_dim(1) / 2 ;
508 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
514 for (
int i=0 ; i<
Y_e->get_dim(1) ; i++){
515 ye_1D.
set(i) = (*Y_e)(i,0) ;
521 cout <<
"Eos_tabul::sigma_Hs_p : ent>hmax !" << endl ;
526 cerr <<
"Ye_eos_tabul::sigma_Hs_p : Y_e not in the tabulated interval !"
528 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax
535 interpol_linear_2d(enthalpy, ye_1D, *
Sourcetbl, ent, ye, i_near, j_near, sigma0) ;
542 interpol_linear_2d(enthalpy, ye_1D, *
Sourcetbl,
hmin, ye, i_near, j_near, sigma0) ;
549 cerr <<
"Warning : (H,Y_e) EoS does not use T as a parameter ; Ye_eos_tabul::temp_Hs_p :function not implemented." << endl;
550 cerr <<
"Aborting ..." << endl;
Equation of state for the CompOSE database.
Equation of state base class.
virtual int identify() const =0
Returns a number to identify the sub-classe of Hot_eos the object belongs to.
Eos * p_cold_eos
Corresponding cold Eos.
Hot_eos()
Standard constructor.
virtual void sauve(FILE *) const
Save in a file.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
double & set(int i)
Read/write of a particular element (index i) (1D case).
void set_arrays_0x0()
Sets all the arrays to the null pointer.
virtual double mul_Hs_p(double ent, const double ye) const
Computes the electronic chemical potential from the enthapy with electronic fraction (virtual functio...
virtual double sigma_Hs_p(double ent, const double ye) const
Computes the source terms for electronic fraction advection equation from the enthapy with electronic...
string tablename
Name of the file containing the tabulated data.
Tbl * Y_e
Table of , electronic fraction (dimensionless).
virtual double press_Hs_p(double ent, double ye) const
Computes the pressure from the log-enthalpy and electronic fraction (virtual function implemented in ...
void read_table()
Reads the file containing the table and initializes in the arrays hhh , s_B, ppp, ....
Tbl * Sourcetbl
Table of electronic fraction source.
double yemax
Upper boundary of the electronic fraction interval.
virtual double chi2_Hs_p(double ent, const double ye) const
Computes the chi^2 coefficient from the enthapy with electronic fraction (virtual function implemente...
virtual int identify() const
Returns a number to identify the sub-classe of Hot_eos the object belongs to.
Tbl * c_sound2
Table of , sound speed squared (units of c^2).
Tbl * ppp
Table of pressure $P$.
virtual ostream & operator>>(ostream &) const
Operator >>.
double hmin
Lower boundary of the enthalpy interval.
virtual bool operator!=(const Hot_eos &) const
Comparison operator (difference).
virtual double csound_square_Hs_p(double ent, const double ye) const
Computes the sound speed squared from the enthapy with electronic fraction (virtual function impleme...
virtual double ener_Hs_p(double ent, double ye) const
Computes the total energy density from the log-enthalpy and electronic fraction (virtual function imp...
double yemin
Lower boundary of the electronic fraction interval.
virtual double nbar_Hs_p(double ent, double ye) const
Computes the baryon density from the log-enthalpy and electronic fraction (virtual function implement...
Ye_eos_tabul(const string &filename)
Standard constructor from a filename.
Tbl * mu_l
Table of , the electronic chemical potential (MeV).
string authors
Authors - reference for the table.
virtual void sauve(FILE *) const
Save in a file.
double hmax
Upper boundary of the enthalpy interval.
virtual bool operator==(const Hot_eos &) const
Comparison operator (egality).
virtual const Eos & new_cold_Eos() const
Returns the corresponding cold Eos.
virtual ~Ye_eos_tabul()
Destructor.
virtual double temp_Hs_p(double ent, double sb) const
Computes the temperature from the log-enthalpy and entropy per baryon (virtual function implemented i...
Cmp exp(const Cmp &)
Exponential.
Tbl extract_column(const Tbl &, const Tbl &, double)
Coord x
x coordinate centered on the grid
Standard units of space, time and mass.