LORENE
ye_eos_tabul.C
1 /*
2  * Methods of class Ye_eos_tabul
3  *
4  * (see file hoteos.h for documentation).
5  *
6  */
7 
8 /*
9  * Copyright (c) 2022 Jerome Novak, Gael Servignat
10  *
11  * This file is part of LORENE.
12  *
13  * LORENE is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * LORENE is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with LORENE; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  */
28 
29 // headers C
30 #include <cstdlib>
31 #include <cstring>
32 #include <cmath>
33 
34 // Headers Lorene
35 #include "hoteos.h"
36 #include "eos.h"
37 #include "utilitaires.h"
38 #include "unites.h"
39 
40 
41 namespace Lorene {
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) ;
46  Tbl extract_column(const Tbl&, const Tbl&, double) ;
47 
48 
49  //----------------------------//
50  // Constructors //
51  //----------------------------//
52 
53  // Standard constructor
54  // --------------------
55  Ye_eos_tabul::Ye_eos_tabul(const string& filename):
56  Hot_eos("Tabulated Y_e EoS"), tablename(filename), authors("Unknown"),
57  hmin(0.), hmax(1.), yemin(0.), yemax(1.)
58  {
59  set_arrays_0x0() ;
60  read_table() ;
61  }
62 
63 
64  // Constructor from binary file
65  // ----------------------------
66  Ye_eos_tabul::Ye_eos_tabul(FILE* fich) : Hot_eos(fich) {
67 
68  const int nc = 160 ;
69  char tmp_string[nc] ;
70  size_t ret = fread(tmp_string, sizeof(char), nc, fich) ;
71  if (int(ret) == nc)
72  tablename = tmp_string ;
73  else {
74  cerr << "Ye_tabul: constructor from a binary file:" << endl ;
75  cerr << "Problems in reading the table name." << endl ;
76  cerr << "Aborting..." << endl ;
77  abort() ;
78  }
79  set_arrays_0x0() ;
80  read_table() ;
81  }
82 
83  // Constructor from a formatted file
84  // ---------------------------------
85  Ye_eos_tabul::Ye_eos_tabul(ifstream& fich) :
86  Hot_eos(fich) {
87 
88  fich >> tablename ;
89  set_arrays_0x0() ;
90  read_table() ;
91  }
92 
93  //Sets the arrays to the null pointer
94  void Ye_eos_tabul::set_arrays_0x0() {
95  hhh = 0x0 ;
96  Y_e = 0x0 ;
97  nnn = 0x0 ;
98  c_sound2 = 0x0 ;
99  mu_l = 0x0 ;
100  ppp = 0x0 ;
101  dpdh = 0x0 ;
102  dpdye = 0x0 ;
103  d2p = 0x0 ;
104  Sourcetbl = 0x0 ;
105  }
106 
107  //--------------//
108  // Destructor //
109  //--------------//
110 
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 ;
120  }
121 
122  //------------//
123  // Outputs //
124  //------------//
125 
126  void Ye_eos_tabul::sauve(FILE* fich) const {
127 
128  Hot_eos::sauve(fich) ;
129 
130  char tmp_string[160] ;
131  strcpy(tmp_string, tablename.c_str()) ;
132  fwrite(tmp_string, sizeof(char), 160, fich) ;
133  }
134 
135  ostream& Ye_eos_tabul::operator>>(ostream & ost) const {
136 
137  ost << "Non-beta equilibrium EOS of class Ye_eos_tabul (tabulated out of beta-equilibrium EoS) : "
138  << endl ;
139  ost << "Built from file " << tablename << endl ;
140  ost << "Authors : " << authors << endl ;
141  ost << "Number of points in file : " << hhh->get_dim(0)
142  << " in enthalpy, and " << hhh->get_dim(1)
143  << " in electron fraction." << endl ;
144 
145  return ost ;
146 }
147 
148  //------------------------//
149  // Reading of the table //
150  //------------------------//
151 
153 
154  using namespace Unites ;
155 
156  ifstream fich(tablename.data()) ;
157 
158  if (!fich) {
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 ;
163  abort() ;
164  }
165 
166  fich.ignore(1000, '\n') ; // Jump over the first header
167  fich.ignore(1) ;
168  getline(fich, authors, '\n') ;
169  for (int i=0; i<3; i++) { // jump over the file
170  fich.ignore(1000, '\n') ; // header
171  } //
172 
173  int nbp1, nbp2 ;
174  fich >> nbp1 >> nbp2 ; fich.ignore(1000, '\n') ; // number of data
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 ;
180  abort() ;
181  }
182 
183  for (int i=0; i<3; i++) { // jump over the table
184  fich.ignore(1000, '\n') ; // description
185  }
186 
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) ;
191  mu_l = new Tbl(nbp2, nbp1) ;
192  c_sound2 = 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) ;
197 
198  ppp->set_etat_qcq() ;
199  hhh->set_etat_qcq() ;
200  Y_e->set_etat_qcq() ;
201  nnn->set_etat_qcq() ;
202  mu_l->set_etat_qcq() ;
204  dpdh->set_etat_qcq() ;
205  dpdye->set_etat_qcq() ;
206  d2p->set_etat_qcq() ;
207  Sourcetbl->set_etat_qcq() ;
208 
209  double c2 = c_si * c_si ;
210  double nb_fm3, rho_cgs, p_cgs, ent, ye, mul, der2, cs2, source_d ;
211  double ww = 0. ;
212  int no;
213 
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 ; //>> source_d ;
217 
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 ;
226  abort() ;
227  }
228 
229  double psc2 = 0.1*p_cgs/c2 ; // in kg m^-3
230  double rho_si = rho_cgs*1000. ; // in kg m^-3
231 
232  double h_read = ent ;
233  if ( (i==0) ) ww = h_read ;
234  double h_new = h_read - ww + 1e-14;
235 
236  ppp->set(j, i) = psc2/rhonuc_si ;
237  hhh->set(j, i) = h_new ;
238  Y_e->set(j, i) = ye ;
239  nnn->set(j, i) = 10.*nb_fm3 ;
240  c_sound2->set(j, i) = cs2 ;
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) ; // Bien revĂ©rifier l'expression !!
245  Sourcetbl->set(j, i) = source_d*t_unit ;
246  }
247  }
248 
249  hmin = (*hhh)(0, 0) ;
250  hmax = (*hhh)(0, nbp1-1) ;
251 
252  yemin = (*Y_e)(0, 0) ;
253  yemax = (*Y_e)(nbp2-1, 0) ;
254 
255  cout << "hmin: " << hmin << ", hmax: " << hmax << endl ;
256  cout << "yemin: " << yemin << ", yemax: " << yemax << endl ;
257 
258  fich.close();
259 }
260 
261  //-------------------------------//
262  // The corresponding cold Eos //
263  //-------------------------------//
264 
266 
267  if (p_cold_eos == 0x0) {
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;
271  p_cold_eos = new Eos_CompOSE(tablename.c_str()) ;
272  }
273 
274  return *p_cold_eos ;
275  }
276 
277 
278 
279 
280 
281  //------------------------//
282  // Comparison operators //
283  //------------------------//
284 
285 
286  bool Ye_eos_tabul::operator==(const Hot_eos& eos_i) const {
287 
288  bool resu = true ;
289 
290  if ( eos_i.identify() != identify() ) {
291  cout << "The second EOS is not of type Ye_eos_tabul !" << endl ;
292  resu = false ;
293  }
294 
295  return resu ;
296  }
297 
298 
299  bool Ye_eos_tabul::operator!=(const Hot_eos& eos_i) const {
300  return !(operator==(eos_i)) ;
301  }
302 
303 
304  //------------------------------//
305  // Computational routines //
306  //------------------------------//
307 
308 // Baryon density from enthalpy and electron fraction
309 //------------------------------------------
310 
311 double Ye_eos_tabul::nbar_Hs_p(double ent, double ye) const {
312 
313  if ((ent > hmin - 1.e-12) && (ent < hmin))
314  ent = hmin ;
315 
316  if (ye < yemin) ye = yemin ;
317 
318  if ( ent >= hmin ) {
319  if (ent > hmax) {
320  cout << "Ye_eos_tabul::nbar_Hs_p : ent > hmax !" << endl ;
321  abort() ;
322  }
323 
324  if (ye > yemax) {
325  cerr << "Ye_eos_tabul::nbar_Hs_p : Y_e not in the tabulated interval !"
326  << endl ;
327  cerr << "Y_e = " << ye << ", yemin = " << yemin << ", yemax = " << yemax
328  << endl ;
329  abort() ;
330  }
331 
332  double p_int, dpdye_int, dpdh_int ;
333 
334  interpol_herm_2d(*Y_e, *hhh, *ppp, *dpdye, *dpdh, *d2p, ye, ent, p_int,
335  dpdye_int, dpdh_int) ;
336 
337  double nbar_int = dpdh_int * exp(-ent) ;
338 
339  // Tbl ye_1D(Y_e->get_dim(1)) ; ye_1D.set_etat_qcq() ;
340  // for (int i=0 ; i<Y_e->get_dim(1) ; i++){
341  // ye_1D.set(i) = (*Y_e)(i,0) ;
342  // }
343  // int i_low = ye_1D.get_taille()/2;
344  // huntm(ye_1D, ye, i_low) ;
345 
346  // double mu = (ye - ye_1D(i_low)) / (ye_1D(i_low+1) - ye_1D(i_low)) ;
347 
348  // Tbl entha1(Y_e->get_dim(0)) ; entha1.set_etat_qcq() ;
349  // Tbl entha2(Y_e->get_dim(0)) ; entha2.set_etat_qcq() ;
350  // for (int i=0 ; i<Y_e->get_dim(0) ; i++){
351  // entha1.set(i) = (*hhh)(i_low, i) ;
352  // entha2.set(i) = (*hhh)(i_low+1, i) ;
353  // }
354 
355  // int j1_low = entha1.get_taille()/2 ;
356  // int j2_low = entha2.get_taille()/2 ;
357  // huntm(entha1, ent, j1_low) ;
358  // huntm(entha2, ent, j2_low) ;
359 
360  // double ent_low_l, ent_high_l, ent_low_r, ent_high_r ;
361  // double lambda, lambda1, lambda2 ;
362  // int jj_low ;
363  // if (j1_low == j2_low){
364  // ent_low_l = entha1(j1_low) ;
365  // ent_low_r = entha2(j1_low) ;
366  // ent_high_l = entha1(j1_low+1) ;
367  // ent_high_r = entha2(j1_low+1) ;
368 
369  // lambda = (ent - mu*ent_low_r - (1.-mu)*ent_low_l) / (mu*(ent_high_r - ent_low_r) + (1.-mu)*(ent_high_l - ent_low_l)) ;
370  // jj_low = j1_low ;
371  // }
372  // else {// if (abs(j1_low - j2_low) == 1){
373  // ent_low_l = entha1(j1_low) ;
374  // ent_low_r = entha2(j1_low) ;
375  // ent_high_l = entha1(j1_low+1) ;
376  // ent_high_r = entha2(j1_low+1) ;
377 
378  // lambda1 = (ent - mu*ent_low_r - (1.-mu)*ent_low_l) / (mu*(ent_high_r - ent_low_r) + (1.-mu)*(ent_high_l - ent_low_l)) ;
379 
380  // ent_low_l = entha1(j2_low) ;
381  // ent_low_r = entha2(j2_low) ;
382  // ent_high_l = entha1(j2_low+1) ;
383  // ent_high_r = entha2(j2_low+1) ;
384 
385  // lambda2 = (ent - mu*ent_low_r - (1.-mu)*ent_low_l) / (mu*(ent_high_r - ent_low_r) + (1.-mu)*(ent_high_l - ent_low_l)) ;
386 
387  // lambda = (0. < lambda1 && lambda1 < 1.) ? (lambda1) : (lambda2) ;
388  // jj_low = (0. < lambda1 && lambda1 < 1.) ? (j1_low) : (j2_low) ;
389  // }
390 
391  // double nbar_int = (1.-lambda)*(*nnn)(i_low, jj_low) + lambda*(*nnn)(i_low, jj_low+1) ;
392  return nbar_int ;
393  }
394  else{
395  return 0 ;
396  }
397 }
398 
399 
400 // Energy density from enthalpy and electron fraction
401 //-----------------------------------------
402 
403 double Ye_eos_tabul::ener_Hs_p(double ent, double ye) const {
404  static int i_near = hhh->get_dim(0) / 2 ;
405  static int j_near = Y_e->get_dim(1) / 2 ;
406 
407  if ((ent > hmin - 1.e-12) && (ent < hmin))
408  ent = hmin ;
409 
410  if (ye < yemin) ye = yemin ;
411 
412  if ( ent >= hmin ) {
413  if (ent > hmax) {
414  cout << "Ye_eos_tabul::ener_Hs_p : ent > hmax !" << endl ;
415  abort() ;
416  }
417 
418  if (ye > yemax) {
419  cerr << "Ye_eos_tabul::ener_Hs_p : Y_e not in the tabulated interval !"
420  << endl ;
421  cerr << "Y_e = " << ye << ", yemin = " << yemin << ", yemax = " << yemax
422  << endl ;
423  abort() ;
424  }
425 
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) ;
429 
430 
431  double f_int = - p_int + dpdh_int;
432 
433  // // double nbar = nbar_Hs_p(ent, ye) ;
434  // Tbl ye_1D(Y_e->get_dim(1)) ; ye_1D.set_etat_qcq() ;
435  // for (int i=0 ; i<Y_e->get_dim(1) ; i++){
436  // ye_1D.set(i) = (*Y_e)(i,0) ;
437  // }
438  // Tbl enthalpy = extract_column(*hhh,ye_1D,ye) ;
439 
440  // double f_int ;
441  // Tbl ener = -(*ppp) + (*dpdh) ;
442  // interpol_linear_2d(enthalpy, ye_1D, ener, ent, ye, i_near, j_near, f_int) ;
443 
444 
445  return f_int ;
446  }
447  else{
448  return 0 ;
449  }
450 }
451 
452 double Ye_eos_tabul::press_Hs_p(double ent, double ye) const {
453  static int i_near = hhh->get_dim(0) / 2 ;
454  static int j_near = Y_e->get_dim(1) / 2 ;
455 
456  if ((ent > hmin - 1.e-12) && (ent < hmin))
457  ent = hmin ;
458 
459  if (ye < yemin) ye = yemin ;
460 
461  if ( ent >= hmin ) {
462  if (ent > hmax) {
463  cout << "Ye_eos_tabul::press_Hs_p : ent > hmax !" << endl ;
464  abort() ;
465  }
466 
467  if (ye > yemax) {
468  cerr << "Ye_eos_tabul::press_Hs_p : Y_e not in the tabulated interval !"
469  << endl ;
470  cerr << "Y_e = " << ye << ", yemin = " << yemin << ", yemax = " << yemax
471  << endl ;
472  abort() ;
473  }
474 
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) ;
478 
479  // // double nbar = nbar_Hs_p(ent, ye) ;
480  // Tbl ye_1D(Y_e->get_dim(1)) ; ye_1D.set_etat_qcq() ;
481  // for (int i=0 ; i<Y_e->get_dim(1) ; i++){
482  // ye_1D.set(i) = (*Y_e)(i,0) ;
483  // }
484  // Tbl enthalpy = extract_column(*hhh,ye_1D,ye) ;
485 
486  // double p_int ;
487  // interpol_linear_2d(enthalpy, ye_1D, *ppp, ent, ye, i_near, j_near, p_int) ;
488 
489 
490  return p_int ;
491  }
492  else{
493  return 0 ;
494  }
495 }
496 
497 double Ye_eos_tabul::csound_square_Hs_p(double ent, double ye) const {
498  static int i_near = hhh->get_dim(0) / 2 ;
499  static int j_near = Y_e->get_dim(1) / 2 ;
500 
501  if ((ent > hmin - 1.e-12) && (ent < hmin))
502  ent = hmin ;
503 
504  if (ye < yemin) ye = yemin ;
505 
506  Tbl ye_1D(Y_e->get_dim(1)) ; ye_1D.set_etat_qcq() ;
507  for (int i=0 ; i<Y_e->get_dim(1) ; i++){
508  ye_1D.set(i) = (*Y_e)(i,0) ;
509  }
510  Tbl enthalpy = extract_column(*hhh,ye_1D,ye) ;
511  if ( ent > hmin ) {
512  if (ent > hmax) {
513  cout << "Eos_tabul::csound_square_Hs_p : ent>hmax !" << endl ;
514  abort() ;
515  }
516  if (ye > yemax) {
517  cerr << "Ye_eos_tabul::csound_square_Hs_p : Y_e not in the tabulated interval !"
518  << endl ;
519  cerr << "Y_e = " << ye << ", yemin = " << yemin << ", yemax = " << yemax
520  << endl ;
521  abort() ;
522  }
523  double csound0 ;
524  // double nbar = nbar_Hs_p(ent ,ye) ;
525 
526  interpol_linear_2d(enthalpy, ye_1D, *c_sound2, ent, ye, i_near, j_near, csound0) ;
527 
528 
529  return csound0 ;
530  }
531  else
532  {
533  double csound0 ;
534  interpol_linear_2d(enthalpy, ye_1D, *c_sound2, enthalpy(0), ye, i_near, j_near, csound0) ;
535  return csound0 ;
536  }
537  }
538 
539 double Ye_eos_tabul::chi2_Hs_p(double, double) const {
540 
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;
543  abort() ;
544 
545  return 0. ;
546  }
547 
548 double Ye_eos_tabul::mul_Hs_p(double ent, double ye) const {
549  static int i_near = hhh->get_dim(0) / 2 ;
550  static int j_near = Y_e->get_dim(1) / 2 ;
551 
552  if ((ent > hmin - 1.e-12) && (ent < hmin))
553  ent = hmin ;
554 
555  if (ye < yemin) ye = yemin ;
556 
557  Tbl ye_1D(Y_e->get_dim(1)) ; ye_1D.set_etat_qcq() ;
558  for (int i=0 ; i<Y_e->get_dim(1) ; i++){
559  ye_1D.set(i) = (*Y_e)(i,0) ;
560  }
561  Tbl enthalpy = extract_column(*hhh,ye_1D,ye) ;
562 
563  if ( ent > hmin ) {
564  if (ent > hmax) {
565  cout << "Eos_tabul::mul_Hs_p : ent>hmax !" << endl ;
566  abort() ;
567  }
568 
569  if (ye > yemax) {
570  cerr << "Ye_eos_tabul::mul_Hs_p : Y_e not in the tabulated interval !"
571  << endl ;
572  cerr << "Y_e = " << ye << ", yemin = " << yemin << ", yemax = " << yemax
573  << endl ;
574  abort() ;
575  }
576 
577  double mul0 ;
578  // double nbar = nbar_Hs_p(ent ,ye) ;
579 
580  interpol_linear_2d(enthalpy, ye_1D, *mu_l, ent, ye, i_near, j_near, mul0) ;
581 
582  return mul0 ;
583  }
584  else
585  {
586  double mul0 ;
587  interpol_linear_2d(enthalpy, ye_1D, *mu_l, enthalpy(0), ye, i_near, j_near, mul0) ;
588  return mul0 ;
589  }
590  }
591 
592  double Ye_eos_tabul::sigma_Hs_p(double ent, double ye) const {
593  static int i_near = hhh->get_dim(0) / 2 ;
594  static int j_near = Y_e->get_dim(1) / 2 ;
595 
596  if ((ent > hmin - 1.e-12) && (ent < hmin))
597  ent = hmin ;
598 
599  if (ye < yemin) ye = yemin ;
600 
601  Tbl ye_1D(Y_e->get_dim(1)) ; ye_1D.set_etat_qcq() ;
602  for (int i=0 ; i<Y_e->get_dim(1) ; i++){
603  ye_1D.set(i) = (*Y_e)(i,0) ;
604  }
605  Tbl enthalpy = extract_column(*hhh,ye_1D,ye) ;
606 
607  if ( ent > hmin ) {
608  if (ent > hmax) {
609  cout << "Eos_tabul::sigma_Hs_p : ent>hmax !" << endl ;
610  abort() ;
611  }
612 
613  if (ye > yemax) {
614  cerr << "Ye_eos_tabul::sigma_Hs_p : Y_e not in the tabulated interval !"
615  << endl ;
616  cerr << "Y_e = " << ye << ", yemin = " << yemin << ", yemax = " << yemax
617  << endl ;
618  abort() ;
619  }
620 
621  double sigma0 ;
622  // double nbar = nbar_Hs_p(ent ,ye) ;
623 
624  interpol_linear_2d(enthalpy, ye_1D, *Sourcetbl, ent, ye, i_near, j_near, sigma0) ;
625 
626  return sigma0 ;
627  }
628  else
629  {
630  double sigma0 ;
631  interpol_linear_2d(enthalpy, ye_1D, *Sourcetbl, enthalpy(0), ye, i_near, j_near, sigma0) ;
632  return sigma0 ;
633  }
634  }
635 
636  double Ye_eos_tabul::temp_Hs_p(double, double) const {
637 
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;
640  abort() ;
641 
642  return 0. ;
643  }
644 } //End of namespace Lorene
645 
646 
Tbl * nnn
Table of.
Definition: hoteos.h:1019
string authors
Authors - reference for the table.
Definition: hoteos.h:992
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...
Definition: ye_eos_tabul.C:539
Cmp exp(const Cmp &)
Exponential.
Definition: cmp_math.C:273
Eos * p_cold_eos
Corresponding cold Eos.
Definition: hoteos.h:126
Tbl * mu_l
Table of , the electronic chemical potential (MeV)
Definition: hoteos.h:1016
Lorene prototypes.
Definition: app_hor.h:67
Standard units of space, time and mass.
Equation of state base class.
Definition: eos.h:209
double & set(int i)
Read/write of a particular element (index i) (1D case)
Definition: tbl.h:301
virtual ostream & operator>>(ostream &) const
Operator >>
Definition: ye_eos_tabul.C:135
string tablename
Name of the file containing the tabulated data.
Definition: hoteos.h:990
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tbl.C:364
virtual double nbar_Hs_p(double ent, double ye) const
Computes the baryon density from the log-enthalpy and electronic fraction (virtual function implement...
Definition: ye_eos_tabul.C:311
virtual double mul_Hs_p(double ent, const double ye) const
Computes the electronic chemical potential from the enthapy with electronic fraction (virtual functio...
Definition: ye_eos_tabul.C:548
Tbl * c_sound2
Table of , sound speed squared (units of c^2).
Definition: hoteos.h:1013
Ye_eos_tabul(const string &filename)
Standard constructor from a filename.
Definition: ye_eos_tabul.C:55
Tbl * Y_e
Table of , electronic fraction (dimensionless).
Definition: hoteos.h:1010
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...
Definition: ye_eos_tabul.C:497
virtual void sauve(FILE *) const
Save in a file.
Definition: ye_eos_tabul.C:126
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i])
Definition: tbl.h:423
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...
Definition: ye_eos_tabul.C:403
Hot_eos()
Standard constructor.
Definition: hoteos.C:56
virtual ~Ye_eos_tabul()
Destructor.
Definition: ye_eos_tabul.C:111
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...
Definition: ye_eos_tabul.C:636
double yemax
Upper boundary of the electronic fraction interval.
Definition: hoteos.h:1004
virtual bool operator!=(const Hot_eos &) const =0
Comparison operator (difference)
Base class for 2-parameters equations of state (abstract class).
Definition: hoteos.h:85
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.
Definition: hoteos.C:129
void read_table()
Reads the file containing the table and initializes in the arrays hhh , s_B, ppp, ...
Definition: ye_eos_tabul.C:152
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...
Definition: ye_eos_tabul.C:592
virtual const Eos & new_cold_Eos() const
Returns the corresponding cold Eos.
Definition: ye_eos_tabul.C:265
double hmax
Upper boundary of the enthalpy interval.
Definition: hoteos.h:998
Basic array class.
Definition: tbl.h:164
Tbl * hhh
Table of .
Definition: hoteos.h:1007
virtual double press_Hs_p(double ent, double ye) const
Computes the pressure from the log-enthalpy and electronic fraction (virtual function implemented in ...
Definition: ye_eos_tabul.C:452
Equation of state for the CompOSE database.
Definition: eos_compose.h:93
double yemin
Lower boundary of the electronic fraction interval.
Definition: hoteos.h:1001
double hmin
Lower boundary of the enthalpy interval.
Definition: hoteos.h:995