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
60namespace Lorene {
61
62
63 //------------------------------------//
64 // class Eos_compose_fit //
65 //------------------------------------//
66
67
90class Eos_compose_fit : public Eos {
91
92 // Data
93 //--------
94
95 protected:
97 string tablename ;
98
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:
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
199protected:
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 der_ener_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
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 read_and_compute(ifstream &)
Reads the Compose data and makes the fit.
virtual double press_ent_p(double ent, const Param *par=0x0) const
Computes the pressure from the log-enthalpy.
const Eos_poly * p_eos_low
Pointer on a polytropic EoS for the description of low densities (nb<nb_min).
virtual void sauve(FILE *) const
Save in a file.
const Map_af * mp
Mapping in .
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.
void write_lorene_table(const string &, int nlines=200) const
Save into a table in Lorene format.
virtual double der_press_nbar_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
const Mg3d * mg
Multi-grid defining the number of domains and spectral coefficients.
virtual double nbar_ent_p(double ent, const Param *par=0x0) const
Higher bound in density.
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.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
double hmin
Values of enthalpy corresponding to nb_min and nb_max.
double nb_min
Lower bound in baryon density, below which the EoS is assumed to be a polytrope.
double nb_mid
Middle bound in baryon density, above which which the EoS is determined from the polynomial fit to th...
Scalar * log_nb
Table of .
virtual ~Eos_compose_fit()
Destructor.
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
Eos_compose_fit(const string &param_file)
Constructor from a parameter file.
virtual bool operator==(const Eos &) const
Comparison operator (egality).
Scalar * log_e
Table of .
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...
string tablename
Name of the file containing the tabulated data.
Eos_compose_fit(const Eos_compose_fit &)
Copy constructor (private to make Eos_compose_fit a non-copiable class).
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...
const Eos_poly * p_eos_high
Pointer on a polytropic EoS for the description of high densities (nb>nb_max).
double nb_max
Higher bound on the density, above which the EoS is assumed to be a polytrope.
virtual double der_nbar_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Scalar * log_p
Table of .
const string & get_tablename() const
Returns the name (given in the parameter file, see the introduction of the class).
virtual ostream & operator>>(ostream &) const
Operator >>.
int n_coefs
Number of coeficients for polynomial regression.
Scalar * log_cs2
Table of .
virtual double der_press_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Polytropic equation of state (relativistic case).
Definition eos.h:809
static Eos * eos_from_file(FILE *)
Construction of an EOS from a binary file.
Eos()
Standard constructor.
Definition eos.C:118
Affine radial mapping.
Definition map.h:2042
Multi-domain grid.
Definition grilles.h:279
Parameter storage.
Definition param.h:125
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:393
Basic array class.
Definition tbl.h:161
Lorene prototypes.
Definition app_hor.h:67