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 ;
94 void Ye_eos_tabul::set_arrays_0x0() {
112 if (
hhh != 0x0)
delete hhh ;
113 if (
Y_e != 0x0)
delete Y_e ;
114 if (
nnn != 0x0)
delete nnn ;
115 if (ppp != 0x0)
delete ppp ;
116 if (dpdh != 0x0)
delete dpdh ;
117 if (dpdye != 0x0)
delete dpdye ;
118 if (d2p != 0x0)
delete d2p ;
119 if (Sourcetbl != 0x0)
delete Sourcetbl ;
130 char tmp_string[160] ;
132 fwrite(tmp_string,
sizeof(
char), 160, fich) ;
137 ost <<
"Non-beta equilibrium EOS of class Ye_eos_tabul (tabulated out of beta-equilibrium EoS) : " 139 ost <<
"Built from file " <<
tablename << endl ;
140 ost <<
"Authors : " <<
authors << endl ;
141 ost <<
"Number of points in file : " <<
hhh->
get_dim(0)
143 <<
" in electron fraction." << endl ;
159 cerr <<
"Ye_eos_tabul::read_table(): " << endl ;
160 cerr <<
"Problem in opening the EOS file!" << endl ;
161 cerr <<
"While trying to open " <<
tablename << endl ;
162 cerr <<
"Aborting..." << endl ;
166 fich.ignore(1000,
'\n') ;
169 for (
int i=0; i<3; i++) {
170 fich.ignore(1000,
'\n') ;
174 fich >> nbp1 >> nbp2 ; fich.ignore(1000,
'\n') ;
175 if ( (nbp1<=0) || (nbp2<=0) ) {
176 cerr <<
"Ye_eos_tabul::read_table(): " << endl ;
177 cerr <<
"Wrong value for the number of lines!" << endl ;
178 cerr <<
"nbp1 = " << nbp1 <<
", nbp2 = " << nbp2 << endl ;
179 cerr <<
"Aborting..." << endl ;
183 for (
int i=0; i<3; i++) {
184 fich.ignore(1000,
'\n') ;
187 ppp =
new Tbl(nbp2, nbp1) ;
188 hhh =
new Tbl(nbp2, nbp1) ;
189 Y_e =
new Tbl(nbp2, nbp1) ;
190 nnn =
new Tbl(nbp2, nbp1) ;
193 dpdh =
new Tbl(nbp2, nbp1) ;
194 dpdye =
new Tbl(nbp2, nbp1) ;
195 d2p =
new Tbl(nbp2, nbp1) ;
196 Sourcetbl =
new Tbl(nbp2, nbp1) ;
198 ppp->set_etat_qcq() ;
204 dpdh->set_etat_qcq() ;
205 dpdye->set_etat_qcq() ;
206 d2p->set_etat_qcq() ;
207 Sourcetbl->set_etat_qcq() ;
209 double c2 = c_si * c_si ;
210 double nb_fm3, rho_cgs, p_cgs, ent, ye, mul, der2, cs2, source_d ;
214 for (
int j=0; j<nbp2; j++) {
215 for (
int i=0; i<nbp1; i++) {
216 fich >> no >> nb_fm3>> rho_cgs >> p_cgs>> ent >> ye >> cs2 >> mul >> der2 ;
218 fich.ignore(1000,
'\n') ;
219 if ( (nb_fm3<0) || (rho_cgs<0) || (p_cgs < 0) ){
220 cerr <<
"Ye_eos_tabul::read_table(): " << endl ;
221 cerr <<
"Negative value in table!" << endl ;
222 cerr <<
"At entry no : " << no << endl;
223 cerr <<
"nb = " << nb_fm3 <<
", rho = " << rho_cgs <<
224 ", p = " << p_cgs << endl ;
225 cerr <<
"Aborting..." << endl ;
229 double psc2 = 0.1*p_cgs/c2 ;
230 double rho_si = rho_cgs*1000. ;
232 double h_read = ent ;
233 if ( (i==0) ) ww = h_read ;
234 double h_new = h_read - ww + 1e-14;
236 ppp->set(j, i) = psc2/rhonuc_si ;
239 nnn->
set(j, i) = 10.*nb_fm3 ;
241 mu_l->
set(j, i) = mul*mev_si*1e44/(rhonuc_si*c2) ;
242 dpdh->set(j, i) = (rho_si + psc2)/rhonuc_si ;
243 dpdye->set(j, i) = -mul*nb_fm3*mevpfm3 ;
244 d2p->set(j, i) = 0.1*der2/(c2*rhonuc_si) ;
245 Sourcetbl->set(j, i) = source_d*t_unit ;
249 hmin = (*hhh)(0, 0) ;
250 hmax = (*hhh)(0, nbp1-1) ;
252 yemin = (*Y_e)(0, 0) ;
253 yemax = (*Y_e)(nbp2-1, 0) ;
255 cout <<
"hmin: " <<
hmin <<
", hmax: " <<
hmax << endl ;
256 cout <<
"yemin: " <<
yemin <<
", yemax: " <<
yemax << endl ;
268 cerr <<
"Warning: Ye_eos_tabul::new_cold_Eos " <<
269 "The corresponding cold EoS is likely not to work" << endl ;
270 cout <<
"read from file: "<<
tablename.c_str() << endl;
291 cout <<
"The second EOS is not of type Ye_eos_tabul !" << endl ;
313 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
320 cout <<
"Ye_eos_tabul::nbar_Hs_p : ent > hmax !" << endl ;
325 cerr <<
"Ye_eos_tabul::nbar_Hs_p : Y_e not in the tabulated interval !" 327 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax 332 double p_int, dpdye_int, dpdh_int ;
334 interpol_herm_2d(*
Y_e, *
hhh, *ppp, *dpdye, *dpdh, *d2p, ye, ent, p_int,
335 dpdye_int, dpdh_int) ;
337 double nbar_int = dpdh_int *
exp(-ent) ;
407 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
414 cout <<
"Ye_eos_tabul::ener_Hs_p : ent > hmax !" << endl ;
419 cerr <<
"Ye_eos_tabul::ener_Hs_p : Y_e not in the tabulated interval !" 421 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax 426 double p_int, dpdye_int, dpdh_int ;
427 interpol_herm_2d(*
Y_e, *
hhh, *ppp, *dpdye, *dpdh, *d2p, ye, ent, p_int,
428 dpdye_int, dpdh_int) ;
431 double f_int = - p_int + dpdh_int;
456 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
463 cout <<
"Ye_eos_tabul::press_Hs_p : ent > hmax !" << endl ;
468 cerr <<
"Ye_eos_tabul::press_Hs_p : Y_e not in the tabulated interval !" 470 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax 475 double p_int, dpdye_int, dpdh_int ;
476 interpol_herm_2d(*
Y_e, *
hhh, *ppp, *dpdye, *dpdh, *d2p, ye, ent, p_int,
477 dpdye_int, dpdh_int) ;
501 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
508 ye_1D.set(i) = (*Y_e)(i,0) ;
513 cout <<
"Eos_tabul::csound_square_Hs_p : ent>hmax !" << endl ;
517 cerr <<
"Ye_eos_tabul::csound_square_Hs_p : Y_e not in the tabulated interval !" 519 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax 526 interpol_linear_2d(enthalpy, ye_1D, *
c_sound2, ent, ye, i_near, j_near, csound0) ;
534 interpol_linear_2d(enthalpy, ye_1D, *
c_sound2, enthalpy(0), ye, i_near, j_near, csound0) ;
541 cerr <<
"Warning : (H,Y_e) EoS have no contribution from chi^2 ; Ye_eos_tabul::chi2_Hs_p :function not implemented." << endl;
542 cerr <<
"Aborting ..." << endl;
552 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
559 ye_1D.set(i) = (*Y_e)(i,0) ;
565 cout <<
"Eos_tabul::mul_Hs_p : ent>hmax !" << endl ;
570 cerr <<
"Ye_eos_tabul::mul_Hs_p : Y_e not in the tabulated interval !" 572 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax 580 interpol_linear_2d(enthalpy, ye_1D, *
mu_l, ent, ye, i_near, j_near, mul0) ;
587 interpol_linear_2d(enthalpy, ye_1D, *
mu_l, enthalpy(0), ye, i_near, j_near, mul0) ;
596 if ((ent >
hmin - 1.e-12) && (ent <
hmin))
603 ye_1D.set(i) = (*Y_e)(i,0) ;
609 cout <<
"Eos_tabul::sigma_Hs_p : ent>hmax !" << endl ;
614 cerr <<
"Ye_eos_tabul::sigma_Hs_p : Y_e not in the tabulated interval !" 616 cerr <<
"Y_e = " << ye <<
", yemin = " <<
yemin <<
", yemax = " <<
yemax 624 interpol_linear_2d(enthalpy, ye_1D, *Sourcetbl, ent, ye, i_near, j_near, sigma0) ;
631 interpol_linear_2d(enthalpy, ye_1D, *Sourcetbl, enthalpy(0), ye, i_near, j_near, sigma0) ;
638 cerr <<
"Warning : (H,Y_e) EoS does not use T as a parameter ; Ye_eos_tabul::temp_Hs_p :function not implemented." << endl;
639 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)
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...
Hot_eos()
Standard constructor.
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.
virtual bool operator!=(const Hot_eos &) const =0
Comparison operator (difference)
Base class for 2-parameters equations of state (abstract class).
Tbl extract_column(const Tbl &, const Tbl &, double)
Extraction of a column of a 2D Tbl
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 bool operator==(const Hot_eos &) const =0
Comparison operator (egality)
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.