39 if (p_ental !=
nullptr)
delete p_ental ;
40 if (p_entro !=
nullptr)
delete p_entro ;
41 if (p_press !=
nullptr)
delete p_press ;
42 if (p_ener !=
nullptr)
delete p_ener ;
43 if (p_nb !=
nullptr)
delete p_nb ;
44 if (p_temp !=
nullptr)
delete p_temp ;
45 if (p_ye !=
nullptr)
delete p_ye ;
49 string file_nb = tablename +
".nb" ;
50 string file_t = tablename +
".t" ;
51 string file_ye = tablename +
".yq" ;
52 string file_thermo = tablename +
".thermo" ;
54 ifstream in_nb(file_nb.data()) ;
55 ifstream in_t(file_t.data()) ;
56 ifstream in_ye(file_ye.data()) ;
57 if ((!in_nb)||(!in_t)||(!in_ye)) {
58 cerr <<
"Problem in opening the EOS files!" << endl ;
59 cerr <<
"While trying to open " << tablename << endl ;
60 cerr <<
"Aborting ... " << endl ;
66 int index1_n, index2_n ;
67 in_nb >> index1_n >> index2_n ;
68 int nbn = index2_n - index1_n + 1 ;
70 for (
int i=0; i<nbn; i++)
71 in_nb >> p_nb->
set(i) ;
73 int index1_t, index2_t ;
74 in_t >> index1_t >> index2_t ;
75 int nbt = index2_t - index1_t + 1 ;
77 for (
int j=0; j<nbt; j++)
78 in_t >> p_temp->
set(j) ;
80 int index1_y, index2_y ;
81 in_ye >> index1_y >> index2_y ;
82 int nby = index2_y - index1_y + 1 ;
84 for (
int k=0; k<nby; k++)
85 in_ye >> p_ye->
set(k) ;
89 p_ener =
new Tbl(nby, nbn, nbt) ; p_ener->
set_etat_qcq() ; (*p_ener) = NAN ;
96 double e_compose, p_compose, p_over_nb_comp, s_per_bar, mub_shifted, eps_comp ;
101 double p_convert = Unites::mev_si * 1.e45 * 10. ;
103 double eps_convert = Unites::mev_si * 1.e42 / (Unites::c_si*Unites::c_si) ;
104 double rhonuc_cgs = Unites::rhonuc_si * 1e-3 ;
105 double c2_cgs = Unites::c_si * Unites::c_si * 1e4 ;
107 double m_neutron_MeV, m_proton_MeV ;
109 ifstream in_thermo(file_thermo.data()) ;
111 cerr <<
"Problem in opening the EOS file!" << endl ;
112 cerr <<
"While trying to open " << file_thermo << endl ;
113 cerr <<
"Aborting ... " << endl ;
118 in_thermo >> m_neutron_MeV >> m_proton_MeV >> dummy_n;
120 long int ntot = nby*nbn*nbt ;
125 cout <<
"Reading " << file_thermo <<
" ... " << flush ;
128 for (
int i=0; i<ntot; i++) {
131 cerr <<
"Problem in EOS file: seems too small!" << endl ;
132 cerr <<
"Name: " << file_thermo << endl ;
133 cerr <<
"Aborting ... " << endl ;
138 in_thermo >> it >> inb >> iye >> p_over_nb_comp ;
139 in_thermo >> s_per_bar >> mub_shifted >> dummy_x >> dummy_x >> dummy_x
141 in_thermo.ignore(1000,
'\n') ;
142 double nb0 = (*p_nb)(inb - index1_n) ;
143 p_compose = p_over_nb_comp * nb0 ;
144 e_compose = ( eps_comp + 1. ) * m_neutron_MeV * nb0 ;
146 if ( (e_compose<0) || (p_compose < 0) ){
147 cout <<
"Negative value in table!" << endl ;
148 cout <<
"e = " << e_compose <<
", p = " << p_compose << endl ;
149 cout <<
"x = " << it <<
", y = " << inb <<
", z = " << iye << endl ;
152 p_ener->
set(iye-index1_y, inb-index1_n, it-index1_t)
153 = e_compose*eps_convert / rhonuc_cgs;
154 p_press->
set(iye-index1_y, inb-index1_n, it-index1_t)
155 = p_compose * p_convert / (c2_cgs*rhonuc_cgs) ;
156 double ent = ( e_compose + p_compose) / (m_neutron_MeV*nb0) ;
157 p_ental->
set(iye-index1_y, inb-index1_n, it-index1_t)
159 p_entro->
set(iye-index1_y, inb-index1_n, it-index1_t)
162 cout <<
"done! " << endl ;
164 for (
int i=0; i<ntot; i++) {
165 if (isnan(p_ener->
t[i])) {
166 cerr <<
"Missing points in EoS table for " << file_thermo << endl ;
double & set(int i)
Read/write of a particular element (index i) (1D case)
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
bool read_compose_table(const string &tablename, Tbl *&p_ental, Tbl *&p_entro, Tbl *&p_press, Tbl *&p_ener, Tbl *&p_nb, Tbl *&p_temp, Tbl *&p_ye)
A function to read CompOSE table and return themro quantities in Lorene units.
double * t
The array of double.