LORENE
eos_compose_fit.h
1 /*
2  * Definition of Lorene class Eos_compose_fit
3  */
4 
5 /*
6  * Copyright (c) 2022 Jerome Novak
7  *
8  * This file is part of LORENE.
9  *
10  * LORENE is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * LORENE is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with LORENE; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */
25 
26 
27 #ifndef __EOS_COMPOSE_FIT_H_
28 #define __EOS_COMPOSE_FIT_H_
29 
30 /*
31  * $Id: eos_compose_fit.h,v 1.6 2023/07/12 15:39:30 j_novak Exp $
32  * $Log: eos_compose_fit.h,v $
33  * Revision 1.6 2023/07/12 15:39:30 j_novak
34  * Reversed order of matching the EoS fit: it now starts from the crust (polytrope) and adjusts the kappa of this crust so as to have the right pressure at the highest density in the original table.
35  *
36  * Revision 1.4 2023/01/27 16:10:35 j_novak
37  * A polytrope (class Eos_poly) is used for low and high enthalpies.
38  *
39  * Revision 1.3 2022/07/21 12:33:51 j_novak
40  * Improved comments
41  *
42  * Revision 1.2 2022/07/20 12:59:43 j_novak
43  * Added methods for saving into files and constructor from a file
44  *
45  * Revision 1.1 2022/04/15 13:39:24 j_novak
46  * New class Eos_compose_fit to generate fitted EoSs from CompOSE tables.
47  *
48  *
49  *
50  *
51  * $Header: /cvsroot/Lorene/C++/Include/eos_compose_fit.h,v 1.6 2023/07/12 15:39:30 j_novak Exp $
52  *
53  */
54 
55 // Standard C++
56 #include "eos.h"
57 #include "scalar.h"
58 
59 // Lorene classes
60 namespace Lorene {
61 
62 
63  //------------------------------------//
64  // class Eos_compose_fit //
65  //------------------------------------//
66 
67 
90 class Eos_compose_fit : public Eos {
91 
92  // Data
93  //--------
94 
95  protected:
97  string tablename ;
98 
103  int n_coefs ;
104 
106  double nb_min ;
107 
111  double nb_mid ;
112 
114  double nb_max ;
115 
117  double hmin, hmax ;
118 
121 
124 
126  const Mg3d* mg ;
127 
129  const Map_af* mp ;
130 
133 
136 
139 
142 
143 
144  // Constructors - Destructor
145  // -------------------------
146  public:
147 
152  Eos_compose_fit(const string& param_file) ;
153 
154 
155  protected:
162  Eos_compose_fit(FILE* ) ;
163 
169  Eos_compose_fit(ifstream&) ;
170 
171  private:
175  Eos_compose_fit(const Eos_compose_fit& ) ;
176 
178  friend Eos* Eos::eos_from_file(FILE* ) ;
179  friend Eos* Eos::eos_from_file(ifstream& ) ;
180 
181  public:
182  virtual ~Eos_compose_fit() ;
183 
184  // Miscellaneous
185  // -------------
186 
187  public :
189  virtual bool operator==(const Eos& ) const ;
190 
192  virtual bool operator!=(const Eos& ) const ;
193 
197  virtual int identify() const ;
198 
199 protected:
200 
202  void read_and_compute(ifstream&) ;
203 
205  void read_compose_data(int& nbp, Tbl*& logh, Tbl*& logp, Tbl*& loge,
206  Tbl*& lognb, Tbl*& gam1) ;
207 
211  void adiabatic_index_fit(int i_min, int i_max, const Tbl& logh_read,
212  const Tbl& logp_read, const Tbl& loge_read,
213  const Tbl& lognb_read, const Tbl& gam1_read) ;
214 
220  double integrate_equations(double kappa, double mean_gam, const Scalar& gamma1,
221  const Scalar& log_ent, const Scalar& ent, Scalar& YYY) ;
222 
223  // Outputs
224  // -------
225  public:
226 
227  virtual void sauve(FILE* ) const ;
228 
230  void write_lorene_table(const string&, int nlines = 200) const ;
231 
232  protected:
233 
234  virtual ostream& operator>>(ostream &) const ;
235 
236  // Accessors
237  //-------------
238 
240  const string& get_tablename() const {return tablename ;} ;
241 
242  double get_nbmin() const { return nb_min ;} ;
243  double get_nbmax() const { return nb_max ;} ;
244 
245  // Computational functions
246  // -----------------------
247 
248  public:
256  virtual double nbar_ent_p(double ent, const Param* par=0x0) const ;
257 
265  virtual double ener_ent_p(double ent, const Param* par=0x0) const ;
266 
274  virtual double press_ent_p(double ent, const Param* par=0x0) const ;
275 
283  virtual double der_nbar_ent_p(double ent, const Param* par=0x0) const ;
284 
292  virtual double der_ener_ent_p(double ent, const Param* par=0x0) const ;
293 
301  virtual double der_press_ent_p(double ent, const Param* par=0x0) const ;
302 
310  virtual double der_press_nbar_p(double ent, const Param* par=0x0) const ;
311 
322  virtual double csound_square_ent_p(double, const Param* par=0x0) const ;
323 
324 };
325 
326 
327 
328 }
329 #endif
330 
virtual double nbar_ent_p(double ent, const Param *par=0x0) const
Higher bound in density.
void read_compose_data(int &nbp, Tbl *&logh, Tbl *&logp, Tbl *&loge, Tbl *&lognb, Tbl *&gam1)
Reads Compose data and stores the values of thermodynamic quantities.
Eos_compose_fit(const string &param_file)
Constructor from a parameter file.
virtual double der_press_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
virtual void sauve(FILE *) const
Save in a file.
const Mg3d * mg
Multi-grid defining the number of domains and spectral coefficients.
Lorene prototypes.
Definition: app_hor.h:67
Equation of state base class.
Definition: eos.h:209
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
virtual double der_nbar_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
virtual bool operator!=(const Eos &) const
Comparison operator (difference)
string tablename
Name of the file containing the tabulated data.
virtual double press_ent_p(double ent, const Param *par=0x0) const
Computes the pressure from the log-enthalpy.
virtual double der_press_nbar_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
virtual double csound_square_ent_p(double, const Param *par=0x0) const
Computes the sound speed squared from the enthapy with extra parameters (virtual function implemente...
void read_and_compute(ifstream &)
Reads the Compose data and makes the fit.
virtual double ener_ent_p(double ent, const Param *par=0x0) const
Computes the total energy density from the log-enthalpy.
double get_nbmax() const
Lower bound in density.
void adiabatic_index_fit(int i_min, int i_max, const Tbl &logh_read, const Tbl &logp_read, const Tbl &loge_read, const Tbl &lognb_read, const Tbl &gam1_read)
From the read values, makes the fit on the adiabatic index and deduces the other quantities from ther...
Scalar * log_cs2
Table of .
double integrate_equations(double kappa, double mean_gam, const Scalar &gamma1, const Scalar &log_ent, const Scalar &ent, Scalar &YYY)
Integrates the differential system giving all thermo quantities from the adiabatic index...
static Eos * eos_from_file(FILE *)
Construction of an EOS from a binary file.
virtual ostream & operator>>(ostream &) const
Operator >>
Scalar * log_nb
Table of .
Scalar * log_e
Table of .
int n_coefs
Number of coeficients for polynomial regression.
const Map_af * mp
Mapping in .
double nb_max
Higher bound on the density, above which the EoS is assumed to be a polytrope.
Parameter storage.
Definition: param.h:125
Polytropic equation of state (relativistic case).
Definition: eos.h:812
const Eos_poly * p_eos_low
Pointer on a polytropic EoS for the description of low densities (nb<nb_min)
const Eos_poly * p_eos_high
Pointer on a polytropic EoS for the description of high densities (nb>nb_max)
virtual double der_ener_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
double nb_min
Lower bound in baryon density, below which the EoS is assumed to be a polytrope.
const string & get_tablename() const
Returns the name (given in the parameter file, see the introduction of the class).
Multi-domain grid.
Definition: grilles.h:279
Affine radial mapping.
Definition: map.h:2042
double hmin
Values of enthalpy corresponding to nb_min and nb_max.
double nb_mid
Middle bound in baryon density, above which which the EoS is determined from the polynomial fit to th...
Scalar * log_p
Table of .
void write_lorene_table(const string &, int nlines=200) const
Save into a table in Lorene format.
virtual bool operator==(const Eos &) const
Comparison operator (egality)
Basic array class.
Definition: tbl.h:164
Equation of state for fitting the 1-parameter EoSs from the CompOSE database.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
virtual ~Eos_compose_fit()
Destructor.