53#include "utilitaires.h"
84 size_t ret = fread(tmp_s1,
sizeof(
char), nc1, fich) ;
88 ret = fread(tmp_s2,
sizeof(
char), nc2, fich) ;
92 fread_be(&comp,
sizeof(
int), 1, fich) ;
106 fich.seekg(0, fich.beg) ;
107 fich.ignore(1000,
'\n') ;
109 fich.ignore(1000,
'\n') ;
110 getline(fich,
name,
'\n') ;
137 cout <<
"The second EOS is not of type Dyn_eos_cons !" << endl ;
157 ost <<
"EOS of class Dyn_eos_cons." << endl ;
158 ost <<
"Built from file " <<
tablename << endl ;
159 ost << ((
compose_format == 0) ?
"LORENE format" :
"CompOSE format") << endl ;
160 ost <<
"Authors : " <<
authors << endl ;
161 ost <<
"Number of points in file : " <<
lognb->get_taille() << endl ;
162 ost <<
"Table eventually slightly modified to ensure the relation" << endl ;
163 ost <<
"de/dn = (e+p)/n" << endl ;
179 cerr <<
"Dyn_eos_cons::read_table_lorene(): " << endl ;
180 cerr <<
"Problem in opening the EOS file!" << endl ;
181 cerr <<
"While trying to open " <<
tablename << endl ;
182 cerr <<
"Aborting..." << endl ;
186 fich.ignore(1000,
'\n') ;
189 for (
int i=0; i<3; i++) {
190 fich.ignore(1000,
'\n') ;
194 fich >> nbp ; fich.ignore(1000,
'\n') ;
196 cerr <<
"Dyn_eos_cons::read_table_lorene(): " << endl ;
197 cerr <<
"Wrong value for the number of lines!" << endl ;
198 cerr <<
"nbp = " << nbp << endl ;
199 cerr <<
"Aborting..." << endl ;
203 for (
int i=0; i<3; i++) {
204 fich.ignore(1000,
'\n') ;
215 lognb->set_etat_qcq() ;
216 loge->set_etat_qcq() ;
219 double rhonuc_cgs = rhonuc_si * 1e-3 ;
220 double c2_cgs = c_si * c_si * 1e4 ;
223 double nb_fm3, rho_cgs, p_cgs ;
225 cout <<
"Dyn_eos_cons: reading Lorene format table from the file "
227 for (
int i=0; i<nbp; i++) {
232 fich >> p_cgs ; fich.ignore(1000,
'\n') ;
233 if ( (nb_fm3<0) || (rho_cgs<0) || (p_cgs < 0) ){
234 cout <<
"Dyn_eos_cons::read_table_lorene(): " << endl ;
235 cout <<
"Negative value in table!" << endl ;
236 cout <<
"nb = " << nb_fm3 <<
", rho = " << rho_cgs <<
237 ", p = " << p_cgs << endl ;
238 cout <<
"Aborting..." << endl ;
242 press.
set(i) = p_cgs / (c2_cgs*rhonuc_cgs) ;
243 nb.
set(i) = 10.*nb_fm3 ;
244 ro.
set(i) = rho_cgs / rhonuc_cgs ;
250 dn = ro / ( ro + press ) ;
254 cout <<
"Dyn_eos_cons: max. relative difference between new (consistent)" << endl ;
255 cout <<
"and old density data: " << maxdif << endl ;
267 cout <<
"nbmin, nbmax : " << 0.1*
nbmin <<
" " << 0.1*
nbmax <<
" fm^-3" << endl ;
281 string file_thermo =
tablename +
".thermo" ;
283 ifstream in_nb(file_nb.data()) ;
285 cerr <<
"Dyn_eos_cons::read_table_compose(): " << endl ;
286 cerr <<
"Problem in opening the EOS file!" << endl ;
287 cerr <<
"While trying to open " << file_nb << endl ;
288 cerr <<
"Aborting..." << endl ;
295 in_nb >> index1 >> index2 ;
296 int nbp = index2 - index1 + 1 ;
307 lognb->set_etat_qcq() ;
308 loge->set_etat_qcq() ;
313 double nb_fm3, rho_cgs, p_cgs, p_over_nb_comp, eps_comp ;
317 double rhonuc_cgs = rhonuc_si * 1e-3 ;
318 double c2_cgs = c_si * c_si * 1e4 ;
319 double m_neutron_MeV, m_proton_MeV ;
321 ifstream in_p_rho (file_thermo.data()) ;
323 cerr <<
"Dyn_eos_cons::read_table_compose(): " << endl ;
324 cerr <<
"Problem in opening the EOS file!" << endl ;
325 cerr <<
"While trying to open " << file_thermo << endl ;
326 cerr <<
"Aborting..." << endl ;
329 in_p_rho >> m_neutron_MeV >> m_proton_MeV ;
330 in_p_rho.ignore(1000,
'\n') ;
332 double p_convert = mev_si * 1.e45 * 10. ;
333 double eps_convert = mev_si * 1.e42 / (c_si*c_si) ;
337 cout <<
"Dyn_eos_cons: reading CompOSE format table from the file "
339 for (
int i=0; i<nbp; i++) {
341 in_p_rho >> dummy_n >> dummy_n >> dummy_n >> p_over_nb_comp ;
342 in_p_rho >> dummy_x >> dummy_x >> dummy_x >> dummy_x >> dummy_x >> eps_comp ;
343 in_p_rho.ignore(1000,
'\n') ;
344 p_cgs = p_over_nb_comp * nb_fm3 * p_convert ;
345 rho_cgs = ( eps_comp + 1. ) * m_neutron_MeV * nb_fm3 * eps_convert ;
347 if ( (nb_fm3<0) || (rho_cgs<0) || (p_cgs < 0) ){
348 cout <<
"Dyn_eos_cons::read_table_compose(): " << endl ;
349 cout <<
"Negative value in table!" << endl ;
350 cout <<
"nb = " << nb_fm3 <<
", rho = " << rho_cgs <<
351 ", p = " << p_cgs << endl ;
352 cout <<
"Aborting..." << endl ;
356 press.
set(i) = (p_cgs / c2_cgs) / rhonuc_cgs ;
357 nb.
set(i) = 10. * nb_fm3 ;
358 ro.
set(i) = rho_cgs / rhonuc_cgs ;
364 dn = ro / ( ro + press ) ;
368 cout <<
"Dyn_eos_cons: max. relative difference between new (consistent)" << endl ;
369 cout <<
"and old density data: " << maxdif << endl ;
381 cout <<
"nbmin, nbmax : " <<
nbmin <<
" " <<
nbmax << endl ;
virtual void read_table_compose()
Reads the files .nb and .thermo containing the table in CompOSE format and initializes the arrays log...
virtual ostream & operator>>(ostream &) const
Operator >>.
virtual bool operator==(const Dyn_eos &) const
Comparison operator (egality).
virtual ~Dyn_eos_cons()
Destructor.
virtual bool operator!=(const Dyn_eos &) const
Comparison operator (difference).
Dyn_eos_cons(const string &name_i, const string &table_name, bool compose=true)
Standard constructor.
virtual int identify() const
Returns a number to identify the sub-classe of Dyn_eos the object belongs to.
virtual void read_table_lorene()
Reads the file containing the table in LORENE format and initializes the arrays lognb ,...
string authors
Authors - reference for the table.
string tablename
Name of the file containing the tabulated data.
bool compose_format
Are(is) the table(s) in CompOSE format?
Dyn_eos_tab(const string &name_i, const string &table_name, bool compose=true)
Standard constructor.
double nbmax
Upper boundary of the baryon density interval.
double nbmin
Lower boundary of the baryon density interval.
Equation of state for use in dynamical code base class.
virtual int identify() const =0
Returns a number to identify the sub-classe of Dyn_eos the object belongs to.
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).
Cmp log10(const Cmp &)
Basis 10 logarithm.
Cmp exp(const Cmp &)
Exponential.
Cmp pow(const Cmp &, int)
Power .
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Cmp log(const Cmp &)
Neperian logarithm.
Tbl integ1D(const Tbl &xx, const Tbl &ff)
Integrates a function defined on an unequally-spaced grid, approximating it by piecewise parabolae.
void compute_derivative(const Tbl &xx, const Tbl &ff, Tbl &dfdx)
Derives a function defined on an unequally-spaced grid, approximating it by piecewise parabolae.
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Standard units of space, time and mass.