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) ;
56 Hot_eos(
"Tabulated Y_e EoS"), tablename(filename), authors(
"Unknown"),
57 hmin(0.), hmax(1.), yemin(0.), yemax(1.)
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)
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) ;
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 ;
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) ;
414 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
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;
465 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
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) ;
508 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
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;
string authors
Authors - reference for the table.
virtual int identify() const
Returns a number to identify the sub-classe of Hot_eos the object belongs to.
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...
Cmp exp(const Cmp &)
Exponential.
Eos * p_cold_eos
Corresponding cold Eos.
Tbl * mu_l
Table of , the electronic chemical potential (MeV)
void set_arrays_0x0()
Sets all the arrays to the null pointer.
Standard units of space, time and mass.
Equation of state base class.
double & set(int i)
Read/write of a particular element (index i) (1D case)
virtual ostream & operator>>(ostream &) const
Operator >>
string tablename
Name of the file containing the tabulated data.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
virtual double nbar_Hs_p(double ent, double ye) const
Computes the baryon density from the log-enthalpy and electronic fraction (virtual function implement...
virtual double mul_Hs_p(double ent, const double ye) const
Computes the electronic chemical potential from the enthapy with electronic fraction (virtual functio...
Tbl * c_sound2
Table of , sound speed squared (units of c^2).
Ye_eos_tabul(const string &filename)
Standard constructor from a filename.
Tbl * Y_e
Table of , electronic fraction (dimensionless).
virtual int identify() const =0
Returns a number to identify the sub-classe of Hot_eos the object belongs to.
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 void sauve(FILE *) const
Save in a file.
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i])
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...
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...
double yemax
Upper boundary of the electronic fraction interval.
Tbl * Sourcetbl
Table of electronic fraction source.
virtual bool operator!=(const Hot_eos &) const
Comparison operator (difference)
Base class for 2-parameters equations of state (abstract class).
virtual bool operator==(const Hot_eos &) const
Comparison operator (egality)
Tbl extract_column(const Tbl &, const Tbl &, double)
Extraction of a column of a 2D Tbl
Tbl * ppp
Table of pressure $P$.
virtual void sauve(FILE *) const
Save in a file.
void read_table()
Reads the file containing the table and initializes in the arrays hhh , s_B, ppp, ...
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...
virtual const Eos & new_cold_Eos() const
Returns the corresponding cold Eos.
double hmax
Upper boundary of the enthalpy interval.
virtual double press_Hs_p(double ent, double ye) const
Computes the pressure from the log-enthalpy and electronic fraction (virtual function implemented in ...
Equation of state for the CompOSE database.
double yemin
Lower boundary of the electronic fraction interval.
double hmin
Lower boundary of the enthalpy interval.