LORENE
eos_compose.h
1 /*
2  * Definition of Lorene classes Eos_CompOSE
3  * Eos_consistent
4  */
5 
6 /*
7  * Copyright (c) 2014-2015 Jerome Novak
8  *
9  * This file is part of LORENE.
10  *
11  * LORENE is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * LORENE is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with LORENE; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  *
25  */
26 
27 
28 #ifndef __EOS_COMPOSE_H_
29 #define __EOS_COMPOSE_H_
30 
31 /*
32  * $Id: eos_compose.h,v 1.6 2021/05/31 11:31:23 g_servignat Exp $
33  * $Log: eos_compose.h,v $
34  * Revision 1.6 2021/05/31 11:31:23 g_servignat
35  * Added csound_square_ent routine to calculate the sound speed from enthalpy to Eos_consistent and corrected error outputs
36  *
37  * Revision 1.5 2021/05/14 15:39:22 g_servignat
38  * Added sound speed computation from enthalpy to Eos class and tabulated+polytropic derived classes
39  *
40  * Revision 1.4 2021/05/06 14:33:17 j_novak
41  * New conversion function from Eos to Dyn_eos.
42  *
43  * Revision 1.3 2019/04/09 12:50:22 j_novak
44  * Improved documentation
45  *
46  * Revision 1.2 2019/03/28 13:41:01 j_novak
47  * Improved managed of saved EoS (functions sauve and constructor form FILE*)
48  *
49  * Revision 1.1 2015/08/04 14:41:28 j_novak
50  * Back to previous version for Eos_CompOSE. Enthalpy-consistent EoS can be accessed using Eos_consistent class (derived from Eos_CompOSE).
51  *
52  *
53  *
54  * $Header: /cvsroot/Lorene/C++/Include/eos_compose.h,v 1.6 2021/05/31 11:31:23 g_servignat Exp $
55  *
56  */
57 
58 // Standard C++
59 #include <string>
60 #include "headcpp.h"
61 
62 // Headers C
63 #include <cstdio>
64 
65 // Lorene classes
66 namespace Lorene {
67 class Tbl ;
68 
69 
70  //------------------------------------//
71  // class Eos_CompOSE //
72  //------------------------------------//
73 
74 
93 class Eos_CompOSE : public Eos_tabul {
94 
95  // Data
96  //--------
97 
98  protected:
99  int format ;
100 
101  // Constructors - Destructor
102  // -------------------------
103  public:
104 
114  Eos_CompOSE(const string& files_path) ;
115 
134  Eos_CompOSE(const char* file_name) ;
135 
136 
137  protected:
144  Eos_CompOSE(FILE* ) ;
145 
151  Eos_CompOSE(ifstream&) ;
152 
153  private:
157  Eos_CompOSE(const Eos_CompOSE& ) ;
158 
159 
161  friend Eos* Eos::eos_from_file(FILE* ) ;
162  friend Eos* Eos::eos_from_file(ifstream& ) ;
163 
164  public:
165  virtual ~Eos_CompOSE() ;
166 
167  // Miscellaneous
168  // -------------
169 public:
170  int get_format() const {return format ;} ;
171 
172  protected:
176  virtual void read_compose_data() ;
177 
178  public :
180  virtual bool operator==(const Eos& ) const ;
181 
183  virtual bool operator!=(const Eos& ) const ;
184 
188  virtual int identify() const ;
189 
190  // Outputs
191  // -------
192  public:
193 
194  virtual void sauve(FILE* ) const ;
195 
196  protected:
197 
198  virtual ostream& operator>>(ostream &) const ;
199 
200 
201 };
202 
203  //------------------------------------//
204  // class Eos_consistent //
205  //------------------------------------//
206 
207 
227 class Eos_consistent : public Eos_CompOSE {
228 
229  // Constructors - Destructor
230  // -------------------------
231  public:
232 
242  Eos_consistent(const string& files_path) ;
243 
262  Eos_consistent(const char* file_name) ;
263 
264 
265  protected:
272  Eos_consistent(FILE* ) ;
273 
279  Eos_consistent(ifstream&) ;
280 
281  private:
285  Eos_consistent(const Eos_consistent& ) ;
286 
287 
289  friend Eos* Eos::eos_from_file(FILE* ) ;
290  friend Eos* Eos::eos_from_file(ifstream& ) ;
291 
292  public:
293  virtual ~Eos_consistent() ;
294 
295  // Miscellaneous
296  // -------------
297 
298  public :
300  virtual bool operator==(const Eos& ) const ;
301 
303  virtual bool operator!=(const Eos& ) const ;
304 
308  virtual int identify() const ;
309 
310  protected:
314  virtual void read_table() ;
315 
319  virtual void read_compose_data() ;
320 
321  // Outputs
322  // -------
323 
324  protected:
325  virtual ostream& operator>>(ostream &) const ;
326 
327  // Computational functions
328  // -----------------------
329 
330  public:
338  virtual double nbar_ent_p(double ent, const Param* par=0x0) const ;
339 
347  virtual double ener_ent_p(double ent, const Param* par=0x0) const ;
348 
356  virtual double press_ent_p(double ent, const Param* par=0x0) const ;
357 
368  virtual double csound_square_ent_p(double, const Param*) const ;
369 };
370 
371 
372 
373 }
374 #endif
375 
virtual ostream & operator>>(ostream &) const
Operator >>
virtual bool operator==(const Eos &) const
Comparison operator (egality)
Definition: eos_compose.C:300
virtual ~Eos_consistent()
Destructor.
Lorene prototypes.
Definition: app_hor.h:67
virtual double ener_ent_p(double ent, const Param *par=0x0) const
Computes the total energy density from the log-enthalpy.
Equation of state base class.
Definition: eos.h:209
Eos_CompOSE(const string &files_path)
Constructor from CompOSE data.
Definition: eos_compose.C:135
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 format
0 for standard (old) LORENE format, 1 for CompOSE format
Definition: eos_compose.h:99
virtual double csound_square_ent_p(double, const Param *) const
Computes the sound speed squared from the enthapy with extra parameters (virtual function implemente...
virtual double press_ent_p(double ent, const Param *par=0x0) const
Computes the pressure from the log-enthalpy.
static Eos * eos_from_file(FILE *)
Construction of an EOS from a binary file.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state for the CompOSE database with a consistent computation of the log-enthalpy (deriv...
Definition: eos_compose.h:227
virtual void sauve(FILE *) const
Save in a file.
Definition: eos_compose.C:322
Parameter storage.
Definition: param.h:125
virtual bool operator!=(const Eos &) const
Comparison operator (difference)
Base class for tabulated equations of state.
Definition: eos_tabul.h:185
virtual void read_compose_data()
Reads the files containing the table and initializes in the arrays logh , logp and dlpsdlh (CompOSE f...
Definition: eos_compose.C:145
virtual double nbar_ent_p(double ent, const Param *par=0x0) const
Computes the baryon density from the log-enthalpy.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
virtual ostream & operator>>(ostream &) const
Operator >>
Definition: eos_compose.C:330
virtual bool operator!=(const Eos &) const
Comparison operator (difference)
Definition: eos_compose.C:313
virtual bool operator==(const Eos &) const
Comparison operator (egality)
virtual ~Eos_CompOSE()
Destructor.
Definition: eos_compose.C:288
Eos_consistent(const string &files_path)
Constructor from CompOSE data.
Equation of state for the CompOSE database.
Definition: eos_compose.h:93