LORENE
dyneos.h
1/*
2 * Definition of Lorene classes Dyn_eos
3 * Dyn_eos_poly
4 * Dyn_eos_tab
5 * Dyn_eos_cons
6 *
7 */
8
9/*
10 * Copyright (c) 2019 Jerome Novak
11 * (c) 2000 Eric Gourgoulhon for Eos classes
12 *
13 * This file is part of LORENE.
14 *
15 * LORENE is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * LORENE is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with LORENE; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 */
30
31
32#ifndef __DYNEOS_H_
33#define __DYNEOS_H_
34
35/*
36 * $Id: dyneos.h,v 1.3 2021/05/06 14:33:17 j_novak Exp $
37 * $Log: dyneos.h,v $
38 * Revision 1.3 2021/05/06 14:33:17 j_novak
39 * New conversion function from Eos to Dyn_eos.
40 *
41 * Revision 1.2 2020/12/17 17:00:27 j_novak
42 * Output of sound speed squared, instead of sound speed.
43 *
44 * Revision 1.1 2019/12/06 14:30:50 j_novak
45 * New classes Dyn_eos... for cold Eos's with baryon density as input.
46 *
47 *
48 *
49 * $Header: /cvsroot/Lorene/C++/Include/dyneos.h,v 1.3 2021/05/06 14:33:17 j_novak Exp $
50 *
51 */
52
53// Standard C++
54#include "headcpp.h"
55
56// Lorene classes
57namespace Lorene {
58 class Tbl ;
59 class Param ;
60 class Scalar ;
61 class Eos ;
62
63 //------------------------------------//
64 // base class Dyn_eos //
65 //------------------------------------//
66
75class Dyn_eos {
76
77 // Data :
78 // -----
79
80 protected:
81 string name ;
82
83
84 // Constructors - Destructor
85 // -------------------------
86 protected:
87 Dyn_eos() ;
88
90 explicit Dyn_eos(const string&) ;
91
92 Dyn_eos(const Dyn_eos& ) ;
93
94 protected:
101 Dyn_eos(FILE* ) ;
102
108 Dyn_eos(ifstream& ) ;
109
110 public:
114 static Dyn_eos* convert_from_Eos(const Eos&) ;
115
116 public:
117 virtual ~Dyn_eos() ;
118
119
120 // Name manipulation
121 // -----------------
122 public:
123 const string& get_name() const ;
124
126 void set_name(const string&) ;
127
128 // Miscellaneous
129 // -------------
130 public:
134 static Dyn_eos* eos_from_file(FILE* ) ;
135
149 static Dyn_eos* eos_from_file(ifstream& ) ;
150
152 virtual bool operator==(const Dyn_eos& ) const = 0 ;
153
155 virtual bool operator!=(const Dyn_eos& ) const = 0 ;
156
160 virtual int identify() const = 0 ;
161
162 // Outputs
163 // -------
164
165 public:
166 virtual void sauve(FILE* ) const ;
167
169 friend ostream& operator<<(ostream& , const Dyn_eos& ) ;
170
171 protected:
172 virtual ostream& operator>>(ostream &) const = 0 ;
173
174
175 // Computational functions
176 // -----------------------
177 protected:
195 void calcule(const Scalar& thermo, int nzet, int l_min,
196 double (Dyn_eos::*fait)(double, const Param*) const,
197 Param* par, Scalar& resu) const ;
198
199 public:
213 virtual double ent_nbar_p(double nbar, const Param* par=0x0) const = 0 ;
214
236 Scalar ent_nbar(const Scalar& nbar, int nzet, int l_min = 0, Param* par=0x0) const ;
237
248 virtual double ener_nbar_p(double nbar, const Param* par=0x0) const = 0 ;
249
267 Scalar ener_nbar(const Scalar& nbar, int nzet, int l_min = 0, Param* par=0x0) const ;
268
279 virtual double press_nbar_p(double nbar, const Param* par=0x0) const = 0 ;
280
281
299 Scalar press_nbar(const Scalar& nbar, int nzet, int l_min = 0, Param* par=0x0) const ;
300
311 virtual double csound_square_nbar_p(double nbar, const Param* par=0x0) const = 0 ;
312
332 Scalar csound_square_nbar(const Scalar& nbar, int nzet, int l_min = 0, Param* par=0x0) const ;
333
334
335};
336ostream& operator<<(ostream& , const Dyn_eos& ) ;
337
338
339 //------------------------------------//
340 // class Dyn_eos_poly //
341 //------------------------------------//
342
343
378class Dyn_eos_poly : public Dyn_eos {
379
380 // Data :
381 // -----
382
383 protected:
385 double gam ;
386
392 double kap ;
393
397 double m_0 ;
398
403 double mu_0 ;
404
405
406
407 double gam1 ;
408 double kapsgam1 ;
409 double gamkapsgam1 ;
410 double rel_mu_0 ;
411
412 // Constructors - Destructor
413 // -------------------------
414 public:
415
429 Dyn_eos_poly(double gamma, double kappa) ;
430
443 Dyn_eos_poly(double gamma, double kappa, double mass) ;
444
461 Dyn_eos_poly(double gamma, double kappa, double mass, double mu_zero) ;
462
463 Dyn_eos_poly(const Dyn_eos_poly& ) ;
464
465 protected:
472 Dyn_eos_poly(FILE* ) ;
473
479 Dyn_eos_poly(ifstream& ) ;
480
483 friend Dyn_eos* Dyn_eos::eos_from_file(ifstream& ) ;
484
485 public:
486 virtual ~Dyn_eos_poly() ;
487
488 // Assignment
489 // ----------
491 void operator=(const Dyn_eos_poly& ) ;
492
493
494 // Miscellaneous
495 // -------------
496
497 public :
499 virtual bool operator==(const Dyn_eos& ) const ;
500
502 virtual bool operator!=(const Dyn_eos& ) const ;
503
507 virtual int identify() const ;
508
510 double get_gam() const ;
511
517 double get_kap() const ;
518
523 double get_m_0() const ;
524
528 double get_mu_0() const ;
529
530 protected:
534 void set_auxiliary() ;
535
536
537 // Outputs
538 // -------
539
540 public:
541 virtual void sauve(FILE* ) const ;
542
543 protected:
544 virtual ostream& operator>>(ostream &) const ;
545
546
547 // Computational functions
548 // -----------------------
549
550 public:
564 virtual double ent_nbar_p(double nbar, const Param* par=0x0) const ;
565
576 virtual double ener_nbar_p(double nbar, const Param* par=0x0) const ;
577
588 virtual double press_nbar_p(double nbar, const Param* par=0x0) const ;
589
599 virtual double csound_square_nbar_p(double nbar, const Param* par=0x0) const ;
600
601};
602
603 //------------------------------------//
604 // class Dyn_eos_tab //
605 //------------------------------------//
606
607
648 class Dyn_eos_tab : public Dyn_eos {
649
650 // Data :
651 // -----
652
653 protected:
655 string tablename ;
656
657 string authors ;
658
660
662 double nbmin ;
663
665 double nbmax ;
666
669
672
675
678
679 // Constructors - Destructor
680 // -------------------------
681 public:
682
692 Dyn_eos_tab(const string& name_i, const string& table_name,
693 bool compose = true) ;
694
695 protected:
697 Dyn_eos_tab() ;
698
705 Dyn_eos_tab(FILE* ) ;
706
716 Dyn_eos_tab(ifstream& ist) ;
717
718 private:
723
724
727 friend Dyn_eos* Dyn_eos::eos_from_file(ifstream& ) ;
728
729 public:
730 virtual ~Dyn_eos_tab() ;
731
732 // Miscellaneous
733 // -------------
734
735 protected:
740 virtual void read_table_compose() ;
741
745 virtual void read_table_lorene() ;
746
747 public :
749 virtual bool operator==(const Dyn_eos& ) const ;
750
752 virtual bool operator!=(const Dyn_eos& ) const ;
753
757 virtual int identify() const ;
758
759 // Outputs
760 // -------
761
762 public:
763 virtual void sauve(FILE* ) const ;
764
765 protected:
766 virtual ostream& operator>>(ostream &) const ;
767
768 // Computational functions
769 // -----------------------
770
771 public:
785 virtual double ent_nbar_p(double nbar, const Param* par=0x0) const ;
786
797 virtual double ener_nbar_p(double nbar, const Param* par=0x0) const ;
798
809 virtual double press_nbar_p(double nbar, const Param* par=0x0) const ;
810
820 virtual double csound_square_nbar_p(double nbar, const Param* par=0x0) const ;
821
822 };
823
824 //------------------------------------//
825 // class Dyn_eos_cons //
826 //------------------------------------//
827
828
839 class Dyn_eos_cons : public Dyn_eos_tab {
840
841 // Constructors - Destructor
842 // -------------------------
843 public:
844
854 Dyn_eos_cons(const string& name_i, const string& table_name,
855 bool compose = true) ;
856
857 protected:
864 Dyn_eos_cons(FILE* ) ;
865
875 Dyn_eos_cons(ifstream& ist) ;
876
877 private:
882
885 friend Dyn_eos* Dyn_eos::eos_from_file(ifstream& ) ;
886
887 public:
888 virtual ~Dyn_eos_cons() ;
889
890 // Miscellaneous
891 // -------------
892
893 protected:
898 virtual void read_table_compose() ;
899
903 virtual void read_table_lorene() ;
904
905 public :
907 virtual bool operator==(const Dyn_eos& ) const ;
908
910 virtual bool operator!=(const Dyn_eos& ) const ;
911
915 virtual int identify() const ;
916
917 // Outputs
918 // -------
919
920 protected:
921 virtual ostream& operator>>(ostream &) const ;
922
923 };
924
925
926
927}
928
929#endif
virtual void read_table_compose()
Reads the files .nb and .thermo containing the table in CompOSE format and initializes the arrays log...
virtual ostream & operator>>(ostream &) const
Operator >>.
virtual bool operator==(const Dyn_eos &) const
Comparison operator (egality).
virtual ~Dyn_eos_cons()
Destructor.
virtual bool operator!=(const Dyn_eos &) const
Comparison operator (difference).
Dyn_eos_cons(const string &name_i, const string &table_name, bool compose=true)
Standard constructor.
Definition dyneos_cons.C:65
virtual int identify() const
Returns a number to identify the sub-classe of Dyn_eos the object belongs to.
Definition dyneos.C:317
Dyn_eos_cons(const Dyn_eos_cons &)
Copy constructor (private to make Dyn_eos_cons a non-copiable class).
virtual void read_table_lorene()
Reads the file containing the table in LORENE format and initializes the arrays lognb ,...
virtual void sauve(FILE *) const
Save in a file.
double get_kap() const
Returns the pressure coefficient (cf.
double get_gam() const
Returns the adiabatic index (cf. Eq. (3)).
virtual bool operator==(const Dyn_eos &) const
Comparison operator (egality).
virtual double csound_square_nbar_p(double nbar, const Param *par=0x0) const
Computes the sound speed squared from the baryon density with extra parameters.
double gam
Adiabatic index (cf. Eq. (3)).
Definition dyneos.h:385
double get_mu_0() const
Return the relativistic chemical potential at zero pressure [unit: , with ].
void set_auxiliary()
Computes the auxiliary quantities gam1 , unsgam1 , gam1sgamkap from the values of gam and kap.
virtual ~Dyn_eos_poly()
Destructor.
void operator=(const Dyn_eos_poly &)
Assignment to another Dyn_eos_poly.
double mu_0
Relativistic chemical potential at zero pressure [unit: , with ].
Definition dyneos.h:403
double get_m_0() const
Return the individual particule mass (cf.
double m_0
Individual particule mass (cf.
Definition dyneos.h:397
virtual double press_nbar_p(double nbar, const Param *par=0x0) const
Computes the pressure from the baryon density and extra parameters (virtual function implemented in t...
virtual double ener_nbar_p(double nbar, const Param *par=0x0) const
Computes the total energy density from the baryon density and extra parameters (virtual function impl...
virtual bool operator!=(const Dyn_eos &) const
Comparison operator (difference).
virtual int identify() const
Returns a number to identify the sub-classe of Dyn_eos the object belongs to.
Definition dyneos.C:313
Dyn_eos_poly(double gamma, double kappa)
Standard constructor (sets both m_0 and mu_0 to 1).
Definition dyneos_poly.C:67
virtual ostream & operator>>(ostream &) const
Operator >>.
virtual double ent_nbar_p(double nbar, const Param *par=0x0) const
Computes the log-enthalpy from the baryon density and extra parameters (virtual function implemented ...
double kap
Pressure coefficient (cf.
Definition dyneos.h:392
string authors
Authors - reference for the table.
Definition dyneos.h:657
virtual void read_table_lorene()
Reads the file containing the table in LORENE format and initializes the arrays lognb ,...
Definition dyneos_tab.C:202
virtual int identify() const
Returns a number to identify the sub-classe of Dyn_eos the object belongs to.
Definition dyneos.C:315
Dyn_eos_tab(const Dyn_eos_tab &)
Copy constructor (private to make Dyn_eos_tab a non-copiable class).
virtual ostream & operator>>(ostream &) const
Operator >>.
Definition dyneos_tab.C:187
Tbl * c_sound2
Table of .
Definition dyneos.h:677
Tbl * dlesdlnb
Table of .
Definition dyneos.h:674
Dyn_eos_tab()
Default constructor to be called by derived classes.
Definition dyneos_tab.C:87
virtual double press_nbar_p(double nbar, const Param *par=0x0) const
Computes the pressure from the baryon density and extra parameters (virtual function implemented in t...
Definition dyneos_tab.C:447
string tablename
Name of the file containing the tabulated data.
Definition dyneos.h:655
virtual bool operator!=(const Dyn_eos &) const
Comparison operator (difference).
Definition dyneos_tab.C:166
virtual void read_table_compose()
Reads the files .nb and .thermo containing the table in CompOSE format and initializes the arrays log...
Definition dyneos_tab.C:294
virtual double ent_nbar_p(double nbar, const Param *par=0x0) const
Computes the log-enthalpy from the baryon density and extra parameters (virtual function implemented ...
Definition dyneos_tab.C:399
virtual void sauve(FILE *) const
Save in a file.
Definition dyneos_tab.C:176
bool compose_format
Are(is) the table(s) in CompOSE format?
Definition dyneos.h:659
virtual ~Dyn_eos_tab()
Destructor.
Definition dyneos_tab.C:140
Tbl * lognb
Table of .
Definition dyneos.h:668
Tbl * loge
Table of .
Definition dyneos.h:671
Dyn_eos_tab(const string &name_i, const string &table_name, bool compose=true)
Standard constructor.
Definition dyneos_tab.C:74
virtual bool operator==(const Dyn_eos &) const
Comparison operator (egality).
Definition dyneos_tab.C:153
double nbmax
Upper boundary of the baryon density interval.
Definition dyneos.h:665
virtual double ener_nbar_p(double nbar, const Param *par=0x0) const
Computes the total energy density from the baryon density and extra parameters (virtual function impl...
Definition dyneos_tab.C:424
virtual double csound_square_nbar_p(double nbar, const Param *par=0x0) const
Computes the sound speed squared from the baryon density with extra parameters.
Definition dyneos_tab.C:474
double nbmin
Lower boundary of the baryon density interval.
Definition dyneos.h:662
Equation of state for use in dynamical code base class.
Definition dyneos.h:75
const string & get_name() const
Returns the EOS name.
Definition dyneos.C:110
virtual double ent_nbar_p(double nbar, const Param *par=0x0) const =0
Computes the log-enthalpy from the baryon density and extra parameters (virtual function implemented ...
static Dyn_eos * eos_from_file(FILE *)
Construction of an EOS from a binary file.
Definition dyneos.C:323
void set_name(const string &)
Sets the EOS name.
Definition dyneos.C:105
virtual ostream & operator>>(ostream &) const =0
Operator >>.
virtual ~Dyn_eos()
Destructor.
Definition dyneos.C:99
Scalar ener_nbar(const Scalar &nbar, int nzet, int l_min=0, Param *par=0x0) const
Computes the total energy density from the baryon density and extra parameters.
Definition dyneos.C:276
virtual double ener_nbar_p(double nbar, const Param *par=0x0) const =0
Computes the total energy density from the baryon density and extra parameters (virtual function impl...
virtual void sauve(FILE *) const
Save in a file.
Definition dyneos.C:178
virtual bool operator!=(const Dyn_eos &) const =0
Comparison operator (difference).
virtual double csound_square_nbar_p(double nbar, const Param *par=0x0) const =0
Computes the sound speed squared from the baryon density with extra parameters (virtual function imp...
virtual bool operator==(const Dyn_eos &) const =0
Comparison operator (egality).
string name
EOS name.
Definition dyneos.h:81
static Dyn_eos * convert_from_Eos(const Eos &)
Conversion operator from Eos to Dyn_eos.
Definition dyneos.C:120
Scalar csound_square_nbar(const Scalar &nbar, int nzet, int l_min=0, Param *par=0x0) const
Computes the sound speed squared from the baryon density with extra parameters.
Definition dyneos.C:300
void calcule(const Scalar &thermo, int nzet, int l_min, double(Dyn_eos::*fait)(double, const Param *) const, Param *par, Scalar &resu) const
General computational method for Scalar 's.
Definition dyneos.C:196
virtual double press_nbar_p(double nbar, const Param *par=0x0) const =0
Computes the pressure from the baryon density and extra parameters (virtual function implemented in t...
Scalar ent_nbar(const Scalar &nbar, int nzet, int l_min=0, Param *par=0x0) const
Computes the log-enthalpy field from the baryon density field and extra parameters.
Definition dyneos.C:263
Scalar press_nbar(const Scalar &nbar, int nzet, int l_min=0, Param *par=0x0) const
Computes the pressure from the baryon density and extra parameters.
Definition dyneos.C:288
friend ostream & operator<<(ostream &, const Dyn_eos &)
Display.
Definition dyneos.C:185
virtual int identify() const =0
Returns a number to identify the sub-classe of Dyn_eos the object belongs to.
Dyn_eos()
Standard constructor.
Definition dyneos.C:67
Equation of state base class.
Definition eos.h:206
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