LORENE
hoteos.h
1 /*
2  * Definition of Lorene class Hot_eos.
3  *
4  */
5 
6 /*
7  * Copyright (c) 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 version 2
13  * as published by the Free Software Foundation.
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 #ifndef __HOTEOS_H_
27 #define __HOTEOS_H_
28 
29 /*
30  * $Id: hoteos.h,v 1.3 2015/12/08 10:52:17 j_novak Exp $
31  * $Log: hoteos.h,v $
32  * Revision 1.3 2015/12/08 10:52:17 j_novak
33  * New class Hoteos_tabul for tabulated temperature-dependent EoSs.
34  *
35  * Revision 1.2 2015/09/10 13:28:00 j_novak
36  * New methods for the class Hot_Eos
37  *
38  * Revision 1.1 2015/03/17 14:19:59 j_novak
39  * New class Hot_eos to deal with temperature-dependent EOSs.
40  *
41  *
42  * $Header: /cvsroot/Lorene/C++/Include/hoteos.h,v 1.3 2015/12/08 10:52:17 j_novak Exp $
43  *
44  */
45 
46 //C++ headers
47 #include "headcpp.h"
48 
49 //C headers
50 #include<cstdio>
51 #include "tbl.h"
52 
53 namespace Lorene{
54 
55 class Scalar ;
56 class Param ;
57 class Eos ;
58  //------------------------------------//
59  // class Hot_eos //
60  //------------------------------------//
61 
67  class Hot_eos {
68 
69  // Data :
70  // -----
71  protected:
72  string name ;
73 
74  // Constructors - Destructor
75  // -------------------------
76  protected:
77  Hot_eos() ;
78 
80  explicit Hot_eos(const string&) ;
81 
83  explicit Hot_eos(const char*) ;
84 
85  Hot_eos(const Hot_eos& ) ;
86 
93  Hot_eos(FILE* ) ;
94 
100  Hot_eos(ifstream& ) ;
101 
102  public:
103  virtual ~Hot_eos() ;
104 
105  // Derived data :
106  // ------------
107  protected:
108  mutable Eos* p_cold_eos ;
109 
111  virtual void del_deriv() const ;
112 
114  void set_der_0x0() const ;
115 
116  // Name manipulation
117  // -----------------
118  public:
120  const string& get_name() const {return name; };
121 
123  void set_name(const char* ) ;
124 
125  // Miscellaneous
126  // -------------
127  public:
131  static Hot_eos* hoteos_from_file(FILE* ) ;
132 
144  static Hot_eos* hoteos_from_file(ifstream& ) ;
145 
147  virtual bool operator==(const Hot_eos& ) const = 0 ;
148 
150  virtual bool operator!=(const Hot_eos& ) const = 0 ;
151 
155  virtual int identify() const = 0 ;
156 
157  // Outputs
158  // -------
159 
160  public:
161  virtual void sauve(FILE* ) const ;
162 
164  friend ostream& operator<<(ostream& , const Hot_eos& ) ;
165 
166  protected:
167  virtual ostream& operator>>(ostream &) const = 0 ;
168 
169  public:
171  virtual const Eos& new_cold_Eos() const = 0 ;
172 
173 
174  // Computational functions
175  // -----------------------
176  protected:
195  void calcule(const Scalar& thermo1, const Scalar& thermo2, int nzet, int l_min,
196  double (Hot_eos::*fait)(double, double) const, Scalar& resu) const ;
197 
198  public:
211  virtual double nbar_Hs_p(double ent, double sb) const = 0 ;
212 
233  Scalar nbar_Hs(const Scalar& ent, const Scalar& sb, int nzet, int l_min = 0) const ;
234 
247  virtual double ener_Hs_p(double ent, double sb) const = 0 ;
248 
268  Scalar ener_Hs(const Scalar& ent, const Scalar& sb, int nzet, int l_min = 0) const ;
269 
282  virtual double press_Hs_p(double ent, double sb) const = 0 ;
283 
302  Scalar press_Hs(const Scalar& ent, const Scalar& sb, int nzet, int l_min = 0) const ;
303 
316  virtual double temp_Hs_p(double ent, double sb) const = 0 ;
317 
338  Scalar temp_Hs(const Scalar& ent, const Scalar& sb, int nzet, int l_min = 0) const ;
339 
340  };
341  ostream& operator<<(ostream& , const Hot_eos& ) ;
342 
343  //------------------------------------//
344  // class Ideal_gas //
345  //------------------------------------//
346 
362  class Ideal_gas : public Hot_eos {
363 
364  // Data :
365  //-------
366 
367  protected:
369  double gam ;
370 
376  double kap ;
377 
381  double m_0 ;
382 
383  double gam1 ;
384  double unsgam1 ;
385  double gam1sgamkap ;
386 
387  // Constructors - Destructor
388  // -------------------------
389  public:
390 
400  Ideal_gas(double gamma, double kappa, double mass=1.) ;
401 
402  Ideal_gas(const Ideal_gas& ) ;
403 
404  protected:
411  Ideal_gas(FILE* ) ;
412 
418  Ideal_gas(ifstream& ) ;
419 
421  friend Hot_eos* Hot_eos::hoteos_from_file(FILE* ) ;
422  friend Hot_eos* Hot_eos::hoteos_from_file(ifstream& ) ;
423 
424  public:
425  virtual ~Ideal_gas() ;
426 
427  // Assignment
428  // ----------
430  void operator=(const Ideal_gas& ) ;
431 
432  // Miscellaneous
433  // -------------
434 
435  public :
437  virtual bool operator==(const Hot_eos& ) const ;
438 
440  virtual bool operator!=(const Hot_eos& ) const ;
441 
445  virtual int identify() const ;
446 
448  double get_gam() const ;
449 
451  double get_kap() const ;
452 
456  double get_m_0() const ;
457 
458  virtual const Eos& new_cold_Eos() const ;
459 
460  protected:
464  void set_auxiliary() ;
465 
466  // Outputs
467  // -------
468 
469  public:
470  virtual void sauve(FILE* ) const ;
471 
472  protected:
473  virtual ostream& operator>>(ostream &) const ;
474 
475 
476  // Computational functions
477  // -----------------------
478 
479  public:
492  virtual double nbar_Hs_p(double ent, double sb) const ;
493 
506  virtual double ener_Hs_p(double ent, double sb) const ;
507 
520  virtual double press_Hs_p(double ent, double sb) const ;
521 
534  virtual double temp_Hs_p(double ent, double sb) const ;
535 
536 };
537 
538  //------------------------------------//
539  // class Hoteos_tabul //
540  //------------------------------------//
541 
549  class Hoteos_tabul : public Hot_eos {
550 
551  // Data :
552  //-------
553 
554  protected:
556  string tablename ;
557 
558  string authors ;
559 
561  double hmin ;
562 
564  double hmax ;
565 
567  double sbmin ;
568 
570  double sbmax ;
571 
573  Tbl* hhh ;
574 
576  Tbl* s_B ;
577 
579  Tbl* ppp ;
580 
583 
586 
588  Tbl* d2p ;
589 
590  // Constructors - Destructor
591  // -------------------------
592  public:
593 
596  Hoteos_tabul(const string& filename) ;
597 
598  Hoteos_tabul(const Hoteos_tabul& ) ;
599 
600  protected:
607  Hoteos_tabul(FILE* ) ;
608 
614  Hoteos_tabul(ifstream& ) ;
615 
617  friend Hot_eos* Hot_eos::hoteos_from_file(FILE* ) ;
618  friend Hot_eos* Hot_eos::hoteos_from_file(ifstream& ) ;
619 
620  public:
621  virtual ~Hoteos_tabul() ;
622 
624  void operator=(const Hoteos_tabul& ) ;
625 
626  // Miscellaneous
627  // -------------
628 
629  protected:
633  void read_table() ;
634 
636  void set_arrays_0x0() ;
637 
638  public :
640  virtual bool operator==(const Hot_eos& ) const ;
641 
643  virtual bool operator!=(const Hot_eos& ) const ;
644 
648  virtual int identify() const ;
649 
650  virtual const Eos& new_cold_Eos() const ;
651 
652  // Outputs
653  // -------
654 
655  public:
656  virtual void sauve(FILE* ) const ;
657 
658  protected:
659  virtual ostream& operator>>(ostream &) const ;
660 
661 
662  // Computational functions
663  // -----------------------
664 
665  public:
678  virtual double nbar_Hs_p(double ent, double sb) const ;
679 
692  virtual double ener_Hs_p(double ent, double sb) const ;
693 
706  virtual double press_Hs_p(double ent, double sb) const ;
707 
720  virtual double temp_Hs_p(double ent, double sb) const ;
721 
722 };
723 
724 }
725 #endif
Lorene::Hoteos_tabul::operator==
virtual bool operator==(const Hot_eos &) const
Comparison operator (egality)
Definition: hoteos_tabul.C:269
Lorene::Ideal_gas::temp_Hs_p
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: ideal_gas.C:294
Lorene::Hoteos_tabul::Hoteos_tabul
Hoteos_tabul(const string &filename)
Standard constructor from a filename.
Definition: hoteos_tabul.C:70
Lorene::Hoteos_tabul::ppp
Tbl * ppp
Table of pressure $P$.
Definition: hoteos.h:579
Lorene::Hoteos_tabul::operator>>
virtual ostream & operator>>(ostream &) const
Operator >>
Definition: hoteos_tabul.C:136
Lorene::Hoteos_tabul::sbmax
double sbmax
Upper boundary of the entropy interval.
Definition: hoteos.h:570
Lorene::Hot_eos::nbar_Hs_p
virtual double nbar_Hs_p(double ent, double sb) const =0
Computes the baryon density from the log-enthalpy and entropy per baryon (virtual function implemente...
Lorene::Hot_eos::operator!=
virtual bool operator!=(const Hot_eos &) const =0
Comparison operator (difference)
Lorene::Ideal_gas::operator=
void operator=(const Ideal_gas &)
Assignment to another Ideal_gas.
Definition: ideal_gas.C:116
Lorene::Hot_eos::operator<<
friend ostream & operator<<(ostream &, const Hot_eos &)
Display.
Definition: hoteos.C:143
Lorene::Ideal_gas::m_0
double m_0
Individual particule mass (cf.
Definition: hoteos.h:381
Lorene::Ideal_gas::sauve
virtual void sauve(FILE *) const
Save in a file.
Definition: ideal_gas.C:221
Lorene::Hoteos_tabul::hmin
double hmin
Lower boundary of the enthalpy interval.
Definition: hoteos.h:561
Lorene::Hot_eos::temp_Hs
Scalar temp_Hs(const Scalar &ent, const Scalar &sb, int nzet, int l_min=0) const
Computes the temperature field from the log-enthalpy field and entropy per baryon.
Definition: hoteos.C:280
Lorene::Hoteos_tabul::d2p
Tbl * d2p
Table of .
Definition: hoteos.h:588
Lorene
Lorene prototypes.
Definition: app_hor.h:64
Lorene::Ideal_gas::unsgam1
double unsgam1
Definition: hoteos.h:384
Lorene::Hoteos_tabul::hmax
double hmax
Upper boundary of the enthalpy interval.
Definition: hoteos.h:564
Lorene::Ideal_gas::operator>>
virtual ostream & operator>>(ostream &) const
Operator >>
Definition: ideal_gas.C:231
Lorene::Ideal_gas::operator!=
virtual bool operator!=(const Hot_eos &) const
Comparison operator (difference)
Definition: ideal_gas.C:212
Lorene::Hoteos_tabul::dpdh
Tbl * dpdh
Table of .
Definition: hoteos.h:582
Lorene::Hot_eos::Hot_eos
Hot_eos()
Standard constructor.
Definition: hoteos.C:56
Lorene::Eos
Equation of state base class.
Definition: eos.h:190
Lorene::Scalar
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:387
Lorene::Hoteos_tabul::press_Hs_p
virtual double press_Hs_p(double ent, double sb) const
Computes the pressure from the log-enthalpy and entropy per baryon (virtual function implemented in t...
Definition: hoteos_tabul.C:369
Lorene::Hoteos_tabul::read_table
void read_table()
Reads the file containing the table and initializes in the arrays hhh , s_B, ppp, ....
Definition: hoteos_tabul.C:153
Lorene::Ideal_gas::kap
double kap
Pressure coefficient (cf.
Definition: hoteos.h:376
Lorene::Hoteos_tabul::identify
virtual int identify() const
Returns a number to identify the sub-classe of Hot_eos the object belongs to.
Definition: hoteos_from_file.C:60
Lorene::Ideal_gas::gam
double gam
Adiabatic index .
Definition: hoteos.h:369
Lorene::Ideal_gas::ener_Hs_p
virtual double ener_Hs_p(double ent, double sb) const
Computes the total energy density from the log-enthalpy and entropy per baryon (virtual function impl...
Definition: ideal_gas.C:263
Lorene::Hot_eos::ener_Hs
Scalar ener_Hs(const Scalar &ent, const Scalar &sb, int nzet, int l_min=0) const
Computes the total energy density from the log-enthalpy and entropy per baryon.
Definition: hoteos.C:252
Lorene::Hoteos_tabul::sauve
virtual void sauve(FILE *) const
Save in a file.
Definition: hoteos_tabul.C:127
Lorene::Ideal_gas::new_cold_Eos
virtual const Eos & new_cold_Eos() const
Returns the corresponding cold Eos.
Definition: ideal_gas.C:160
Lorene::Hot_eos::nbar_Hs
Scalar nbar_Hs(const Scalar &ent, const Scalar &sb, int nzet, int l_min=0) const
Computes the baryon density field from the log-enthalpy field and entropy per baryon.
Definition: hoteos.C:236
Lorene::Hot_eos::operator>>
virtual ostream & operator>>(ostream &) const =0
Operator >>
Lorene::Hot_eos::identify
virtual int identify() const =0
Returns a number to identify the sub-classe of Hot_eos the object belongs to.
Lorene::Hoteos_tabul::~Hoteos_tabul
virtual ~Hoteos_tabul()
Destructor.
Definition: hoteos_tabul.C:114
Lorene::Tbl
Basic array class.
Definition: tbl.h:161
Lorene::Hoteos_tabul::s_B
Tbl * s_B
Table of , entropy per baryon (in units of Boltzmann constant).
Definition: hoteos.h:576
Lorene::Hoteos_tabul::hhh
Tbl * hhh
Table of .
Definition: hoteos.h:573
Lorene::Hot_eos::set_name
void set_name(const char *)
Sets the hot EOS name.
Definition: hoteos.C:118
Lorene::Hoteos_tabul::authors
string authors
Authors - reference for the table.
Definition: hoteos.h:558
Lorene::Hoteos_tabul::set_arrays_0x0
void set_arrays_0x0()
Sets all the arrays to the null pointer.
Definition: hoteos_tabul.C:101
Lorene::Hot_eos::ener_Hs_p
virtual double ener_Hs_p(double ent, double sb) const =0
Computes the total energy density from the log-enthalpy and entropy per baryon (virtual function impl...
Lorene::Hoteos_tabul::operator=
void operator=(const Hoteos_tabul &)
Assignment to another Hoteos_tabul.
Lorene::Ideal_gas::operator==
virtual bool operator==(const Hot_eos &) const
Comparison operator (egality)
Definition: ideal_gas.C:175
Lorene::Hot_eos::press_Hs
Scalar press_Hs(const Scalar &ent, const Scalar &sb, int nzet, int l_min=0) const
Computes the pressure from the log-enthalpy and entropy per baryon.
Definition: hoteos.C:266
Lorene::Hoteos_tabul::temp_Hs_p
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: hoteos_tabul.C:403
Lorene::Hoteos_tabul::nbar_Hs_p
virtual double nbar_Hs_p(double ent, double sb) const
Computes the baryon density from the log-enthalpy and entropy per baryon (virtual function implemente...
Definition: hoteos_tabul.C:294
Lorene::Hot_eos::press_Hs_p
virtual double press_Hs_p(double ent, double sb) const =0
Computes the pressure from the log-enthalpy and entropy per baryon (virtual function implemented in t...
Lorene::Hoteos_tabul::sbmin
double sbmin
Lower boundary of the entropy interval.
Definition: hoteos.h:567
Lorene::Hot_eos::~Hot_eos
virtual ~Hot_eos()
Destructor.
Definition: hoteos.C:101
Lorene::Hoteos_tabul::tablename
string tablename
Name of the file containing the tabulated data.
Definition: hoteos.h:556
Lorene::Ideal_gas::get_m_0
double get_m_0() const
Return the individual particule mass (cf.
Definition: ideal_gas.C:151
Lorene::Hot_eos::sauve
virtual void sauve(FILE *) const
Save in a file.
Definition: hoteos.C:129
Lorene::Hoteos_tabul::operator!=
virtual bool operator!=(const Hot_eos &) const
Comparison operator (difference)
Definition: hoteos_tabul.C:282
Lorene::Ideal_gas::identify
virtual int identify() const
Returns a number to identify the sub-classe of Hot_eos the object belongs to.
Definition: hoteos_from_file.C:58
Lorene::Hoteos_tabul::dpds
Tbl * dpds
Table of .
Definition: hoteos.h:585
Lorene::Hoteos_tabul
Hot (temperature-dependent) tabulated equation of state, read from a file.
Definition: hoteos.h:549
Lorene::Ideal_gas::gam1
double gam1
Definition: hoteos.h:383
Lorene::Hot_eos::del_deriv
virtual void del_deriv() const
Deletes all the derived quantities.
Definition: hoteos.C:109
Lorene::Ideal_gas::get_kap
double get_kap() const
Returns the pressure coefficient (cf. Eq. (1)).
Definition: ideal_gas.C:147
Lorene::Ideal_gas::press_Hs_p
virtual double press_Hs_p(double ent, double sb) const
Computes the pressure from the log-enthalpy and entropy per baryon (virtual function implemented in t...
Definition: ideal_gas.C:279
Lorene::Hot_eos::calcule
void calcule(const Scalar &thermo1, const Scalar &thermo2, int nzet, int l_min, double(Hot_eos::*fait)(double, double) const, Scalar &resu) const
General computational method for Scalar 's.
Definition: hoteos.C:153
Lorene::Hoteos_tabul::ener_Hs_p
virtual double ener_Hs_p(double ent, double sb) const
Computes the total energy density from the log-enthalpy and entropy per baryon (virtual function impl...
Definition: hoteos_tabul.C:330
Lorene::Ideal_gas::Ideal_gas
Ideal_gas(double gamma, double kappa, double mass=1.)
Standard constructor.
Definition: ideal_gas.C:64
Lorene::Hot_eos::p_cold_eos
Eos * p_cold_eos
Corresponding cold Eos.
Definition: hoteos.h:108
Lorene::Hot_eos::new_cold_Eos
virtual const Eos & new_cold_Eos() const =0
Returns the corresponding cold Eos.
Lorene::Ideal_gas
Ideal-gas (temperature-dependent) equation of state, with mass-term in the energy density.
Definition: hoteos.h:362
Lorene::Ideal_gas::nbar_Hs_p
virtual double nbar_Hs_p(double ent, double sb) const
Computes the baryon density from the log-enthalpy and entropy per baryon (virtual function implemente...
Definition: ideal_gas.C:250
Lorene::Hot_eos::hoteos_from_file
static Hot_eos * hoteos_from_file(FILE *)
Construction of an EOS from a binary file.
Definition: hoteos_from_file.C:67
Lorene::Hoteos_tabul::new_cold_Eos
virtual const Eos & new_cold_Eos() const
Returns the corresponding cold Eos.
Definition: hoteos_tabul.C:252
Lorene::Ideal_gas::set_auxiliary
void set_auxiliary()
Computes the auxiliary quantities gam1 , unsgam1 , gam1sgamkap from the values of gam and kap.
Definition: ideal_gas.C:133
Lorene::Ideal_gas::get_gam
double get_gam() const
Returns the adiabatic index (cf. Eq. (1)).
Definition: ideal_gas.C:143
Lorene::Hot_eos::get_name
const string & get_name() const
Returns the hot EOS name.
Definition: hoteos.h:120
Lorene::Ideal_gas::~Ideal_gas
virtual ~Ideal_gas()
Destructor.
Definition: ideal_gas.C:110
Lorene::Hot_eos::name
string name
EOS name.
Definition: hoteos.h:72
Lorene::Hot_eos
Base class for temperature-dependent equations of state (abstract class).
Definition: hoteos.h:67
Lorene::Hot_eos::temp_Hs_p
virtual double temp_Hs_p(double ent, double sb) const =0
Computes the temperature from the log-enthalpy and entropy per baryon (virtual function implemented i...
Lorene::Ideal_gas::gam1sgamkap
double gam1sgamkap
Definition: hoteos.h:385
Lorene::Hot_eos::operator==
virtual bool operator==(const Hot_eos &) const =0
Comparison operator (egality)
Lorene::Hot_eos::set_der_0x0
void set_der_0x0() const
Sets to 0x0 all the pointers on derived quantities.
Definition: hoteos.C:114