89 #include "utilitaires.h" 112 fread(
name,
sizeof(
char), 100, fich) ;
113 char tmp_string[160] ;
114 fread(tmp_string,
sizeof(
char), 160, fich) ;
119 if (format_read != 1)
format = 0 ;
152 string file_thermo =
tablename +
".thermo" ;
154 ifstream in_nb(file_nb.data()) ;
156 cerr <<
"Eos_CompOSE::read_compose_data(): " << endl ;
157 cerr <<
"Problem in opening the EOS file!" << endl ;
158 cerr <<
"While trying to open " << file_nb << endl ;
159 cerr <<
"Aborting..." << endl ;
166 in_nb >> index1 >> index2 ;
167 int nbp = index2 - index1 + 1 ;
170 press =
new double[nbp] ;
171 nb =
new double[nbp] ;
172 ro =
new double[nbp] ;
192 double nb_fm3, rho_cgs, p_cgs, p_over_nb_comp, eps_comp ;
196 double rhonuc_cgs = rhonuc_si * 1e-3 ;
197 double c2_cgs = c_si * c_si * 1e4 ;
198 double m_neutron_MeV, m_proton_MeV ;
200 ifstream in_p_rho (file_thermo.data()) ;
202 cerr <<
"Eos_CompOSE::read_compose_data(): " << endl ;
203 cerr <<
"Problem in opening the EOS file!" << endl ;
204 cerr <<
"While trying to open " << file_thermo << endl ;
205 cerr <<
"Aborting..." << endl ;
208 in_p_rho >> m_neutron_MeV >> m_proton_MeV ;
209 in_p_rho.ignore(1000,
'\n') ;
211 double p_convert = mev_si * 1.e45 * 10. ;
212 double eps_convert = mev_si * 1.e42 / (c_si*c_si) ;
216 for (
int i=0; i<nbp; i++) {
218 in_p_rho >> dummy_n >> dummy_n >> dummy_n >> p_over_nb_comp ;
219 in_p_rho >> dummy_x >> dummy_x >> dummy_x >> dummy_x >> dummy_x >> eps_comp ;
220 in_p_rho.ignore(1000,
'\n') ;
221 p_cgs = p_over_nb_comp * nb_fm3 * p_convert ;
222 rho_cgs = ( eps_comp + 1. ) * m_neutron_MeV * nb_fm3 * eps_convert ;
224 if ( (nb_fm3<0) || (rho_cgs<0) || (p_cgs < 0) ){
225 cout <<
"Eos_CompOSE::read_compose_data(): " << endl ;
226 cout <<
"Negative value in table!" << endl ;
227 cout <<
"nb = " << nb_fm3 <<
", rho = " << rho_cgs <<
228 ", p = " << p_cgs << endl ;
229 cout <<
"Aborting..." << endl ;
233 press[i] = p_cgs / c2_cgs ;
237 press_tbl.
set(i) = press[i] ;
238 nb_tbl.
set(i) = nb[i] ;
239 ro_tbl.
set(i) = ro[i] ;
243 for (
int i=0; i<nbp; i++) {
244 double h =
log( (ro[i] + press[i]) / (10 * nb[i] * rhonuc_cgs) ) ;
246 if (i==0) { ww = h ; }
247 h = h - ww + 1.e-14 ;
251 dlpsdlh->
set(i) = h * (ro[i] + press[i]) / press[i] ;
258 Tbl logp0 = ((*logp) +
log10(rhonuc_cgs)) *
log(10.) ;
265 for (
int i=0; i<nbp; i++) {
267 tmp.
set(i) = - tmp(i) ;
274 cout <<
"hmin, hmax : " <<
hmin <<
" " <<
hmax << endl ;
305 cout <<
"The second EOS is not of type Eos_CompOSE !" << endl ;
332 ost <<
"EOS of class Eos_CompOSE." << endl ;
333 ost <<
"Built from file " <<
tablename << endl ;
334 ost << ((
format == 0) ?
"Old LORENE format" :
"CompOSE format") << endl ;
335 ost <<
"Authors : " <<
authors << endl ;
336 ost <<
"Number of points in file : " <<
logh->
get_taille() << endl ;
virtual bool operator==(const Eos &) const
Comparison operator (egality)
Cmp log(const Cmp &)
Neperian logarithm.
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)
Eos_CompOSE(const string &files_path)
Constructor from CompOSE data.
virtual int identify() const =0
Returns a number to identify the sub-classe of Eos the object belongs to.
double hmin
Lower boundary of the enthalpy interval.
int format
0 for standard (old) LORENE format, 1 for CompOSE format
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
string tablename
Name of the file containing the tabulated data.
string authors
Authors - reference for the table.
virtual void sauve(FILE *) const
Save in a file.
virtual void sauve(FILE *) const
Save in a file.
double hmax
Upper boundary of the enthalpy interval.
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 fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Base class for tabulated equations of state.
Cmp pow(const Cmp &, int)
Power .
virtual void read_compose_data()
Reads the files containing the table and initializes in the arrays logh , logp and dlpsdlh (CompOSE f...
virtual void read_table()
Reads the file containing the table and initializes in the arrays logh , logp and dlpsdlh ...
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Cmp log10(const Cmp &)
Basis 10 logarithm.
virtual ostream & operator>>(ostream &) const
Operator >>
int get_taille() const
Gives the total size (ie dim.taille)
virtual bool operator!=(const Eos &) const
Comparison operator (difference)
virtual ~Eos_CompOSE()
Destructor.