LORENE
eos_tabul.h
1/*
2 * Definition of Lorene classes Eos_tabul
3 * Eos_SLy4
4 * Eos_FPS
5 * Eos_BPAL12
6 * Eos_AkmalPR
7 * Eos_BBB2
8 * Eos_BalbN1H1
9 * Eos_GlendNH3
10 */
11
12/*
13 * Copyright (c) 2000-2001 Eric Gourgoulhon
14 * (c) 2014 Jerome Novak
15 *
16 * This file is part of LORENE.
17 *
18 * LORENE is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * LORENE is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with LORENE; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 *
32 */
33
34
35#ifndef __EOS_TABUL_H_
36#define __EOS_TABUL_H_
37
38/*
39 * $Id: eos_tabul.h,v 1.22 2023/01/04 10:24:16 j_novak Exp $
40 * $Log: eos_tabul.h,v $
41 * Revision 1.22 2023/01/04 10:24:16 j_novak
42 * Added access to hmin and hmax
43 *
44 * Revision 1.21 2022/03/10 16:38:39 j_novak
45 * log(cs^2) is tabulated instead of cs^2.
46 *
47 * Revision 1.20 2021/05/14 15:39:22 g_servignat
48 * Added sound speed computation from enthalpy to Eos class and tabulated+polytropic derived classes
49 *
50 * Revision 1.19 2021/05/06 14:33:17 j_novak
51 * New conversion function from Eos to Dyn_eos.
52 *
53 * Revision 1.18 2019/04/09 12:50:22 j_novak
54 * Improved documentation
55 *
56 * Revision 1.17 2019/03/28 13:41:01 j_novak
57 * Improved managed of saved EoS (functions sauve and constructor form FILE*)
58 *
59 * Revision 1.16 2015/08/04 14:41:28 j_novak
60 * Back to previous version for Eos_CompOSE. Enthalpy-consistent EoS can be accessed using Eos_consistent class (derived from Eos_CompOSE).
61 *
62 * Revision 1.15 2015/01/27 14:22:38 j_novak
63 * New methods in Eos_tabul to correct for EoS themro consistency (optional).
64 *
65 * Revision 1.14 2014/10/13 08:52:34 j_novak
66 * Lorene classes and functions now belong to the namespace Lorene.
67 *
68 * Revision 1.13 2014/07/01 09:26:20 j_novak
69 * Improvement of comments
70 *
71 * Revision 1.12 2014/06/30 16:13:18 j_novak
72 * New methods for reading directly from CompOSE files.
73 *
74 * Revision 1.11 2014/03/06 15:53:34 j_novak
75 * Eos_compstar is now Eos_compOSE. Eos_tabul uses strings and contains informations about authors.
76 *
77 * Revision 1.10 2010/02/02 14:26:10 j_novak
78 * *** empty log message ***
79 *
80 * Revision 1.9 2010/02/02 13:21:52 j_novak
81 * New class Eos_Compstar.
82 *
83 * Revision 1.8 2004/03/22 13:12:41 j_novak
84 * Modification of comments to use doxygen instead of doc++
85 *
86 * Revision 1.7 2003/12/08 15:48:43 m_bejger
87 * GlendNH3 EOS (Glendenning 1985, case 3) added
88 *
89 * Revision 1.6 2003/11/25 13:44:15 m_bejger
90 * Declared some vectors for Eos_tabul::read_table()
91 *
92 * Revision 1.5 2003/11/21 16:19:09 m_bejger
93 * Added new tables: lognb, dlpsdlnb
94 *
95 * Revision 1.4 2002/10/16 14:36:29 j_novak
96 * Reorganization of #include instructions of standard C++, in order to
97 * use experimental version 3 of gcc.
98 *
99 * Revision 1.3 2002/09/13 09:17:31 j_novak
100 * Modif. commentaires
101 *
102 * Revision 1.2 2002/04/09 14:32:15 e_gourgoulhon
103 * 1/ Added extra parameters in EOS computational functions (argument par)
104 * 2/ New class MEos for multi-domain EOS
105 *
106 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
107 * LORENE
108 *
109 * Revision 2.5 2001/09/11 16:15:46 eric
110 * Ajout des classes Eos_BBB2 et Eos_BalbN1H1
111 *
112 * Revision 2.4 2001/09/11 15:05:48 eric
113 * Ajout de la classe Eos_AkmalPR
114 *
115 * Revision 2.3 2001/03/23 13:40:23 eric
116 * Modifs commentaires.
117 *
118 * Revision 2.2 2001/02/07 09:45:28 eric
119 * Suppression de la fonction derent_ent_p.
120 * Ajout des fonctions donnant les derivees de l'EOS:
121 * der_nbar_ent_p
122 * der_ener_ent_p
123 * der_press_ent_p
124 *
125 * Revision 2.1 2000/11/23 22:33:48 eric
126 * Ajout de Eos_BPAL12.
127 *
128 * Revision 2.0 2000/11/22 19:29:18 eric
129 * *** empty log message ***
130 *
131 *
132 * $Header: /cvsroot/Lorene/C++/Include/eos_tabul.h,v 1.22 2023/01/04 10:24:16 j_novak Exp $
133 *
134 */
135
136// Standard C++
137#include <string>
138#include "headcpp.h"
139
140// Headers C
141#include <cstdio>
142
143// Lorene classes
144namespace Lorene {
145class Tbl ;
146
147
148 //------------------------------------//
149 // class Eos_tabul //
150 //------------------------------------//
151
152
185class Eos_tabul : public Eos {
186
187 // Data :
188 // -----
189
190 protected:
192 string tablename ;
193
194 string authors ;
195
197 double hmin ;
198
200 double hmax ;
201
204
207
210
213
216
219
220 double* press ;
221 double* nb ;
222 double* ro ;
223
224
225 // Constructors - Destructor
226 // -------------------------
227 protected:
228
235 Eos_tabul(const char* name_i, const char* table, const char* path) ;
236
243 Eos_tabul(const char* name_i, const char* file_name) ;
244
246
247 Eos_tabul(const char* name_i) ;
248
249 protected:
250
257 Eos_tabul(FILE* ) ;
258
269 Eos_tabul(ifstream& ist, const char* table) ;
270
281 Eos_tabul(ifstream& ist) ;
282
284 friend Eos* Eos::eos_from_file(FILE* ) ;
285 friend Eos* Eos::eos_from_file(ifstream& ) ;
286
287 public:
288 virtual ~Eos_tabul() ;
289
290
291 // Miscellaneous
292 // -------------
293public:
294 const string& get_tablename() const { return tablename ; } ;
295
296 const Tbl& get_logh() const {return *logh ; } ;
297
299 double get_hmin() const {return hmin ; } ;
300
302 double get_hmax() const {return hmax ; } ;
303
304 protected:
308 virtual void read_table() ;
309
310
311 // Outputs
312 // -------
313
314 public:
315 virtual void sauve(FILE* ) const ;
316
317
318 // Computational functions
319 // -----------------------
320
321 public:
329 virtual double nbar_ent_p(double ent, const Param* par=0x0) const ;
330 /* mb test version for linear interpolation
331
332 virtual double nbar_ent_p_mbtest(double ent, const Param* par=0x0) const ;
333 */
334
342 virtual double ener_ent_p(double ent, const Param* par=0x0) const ;
343
351 virtual double press_ent_p(double ent, const Param* par=0x0) const ;
352 /* mb test version for linear interpolation
353 virtual double press_ent_p_mbtest(double ent, const Param* par=0x0) const ;
354 */
355
363 virtual double der_nbar_ent_p(double ent, const Param* par=0x0) const ;
364
372 virtual double der_ener_ent_p(double ent, const Param* par=0x0) const ;
373
381 virtual double der_press_ent_p(double ent, const Param* par=0x0) const ;
382
390
391 virtual double der_press_nbar_p(double ent, const Param* par=0x0) const ;
392
403 virtual double csound_square_ent_p(double, const Param*) const ;
404};
405
406 //------------------------------------//
407 // class Eos_SLy4 //
408 //------------------------------------//
409
410
423class Eos_SLy4 : public Eos_tabul {
424
425
426 // Constructors - Destructor
427 // -------------------------
428 public:
429
434 Eos_SLy4(const char* path) ;
435
436
437 protected:
444 Eos_SLy4(FILE* ) ;
445
451 Eos_SLy4(ifstream& ) ;
452
453 private:
457 Eos_SLy4(const Eos_SLy4& ) ;
458
459
461 friend Eos* Eos::eos_from_file(FILE* ) ;
462 friend Eos* Eos::eos_from_file(ifstream& ) ;
463
464 public:
465 virtual ~Eos_SLy4() ;
466
467 // Miscellaneous
468 // -------------
469
470 public :
472 virtual bool operator==(const Eos& ) const ;
473
475 virtual bool operator!=(const Eos& ) const ;
476
480 virtual int identify() const ;
481
482 // Outputs
483 // -------
484
485 protected:
486 virtual ostream& operator>>(ostream &) const ;
487
488};
489
490 //------------------------------------//
491 // class Eos_FPS //
492 //------------------------------------//
493
494
501class Eos_FPS : public Eos_tabul {
502
503
504 // Constructors - Destructor
505 // -------------------------
506 public:
507
512 Eos_FPS(const char* path) ;
513
514
515 protected:
522 Eos_FPS(FILE* ) ;
523
529 Eos_FPS(ifstream& ) ;
530
531 private:
535 Eos_FPS(const Eos_FPS& ) ;
536
537
539 friend Eos* Eos::eos_from_file(FILE* ) ;
540 friend Eos* Eos::eos_from_file(ifstream& ) ;
541
542 public:
543 virtual ~Eos_FPS() ;
544
545 // Miscellaneous
546 // -------------
547
548 public :
550 virtual bool operator==(const Eos& ) const ;
551
553 virtual bool operator!=(const Eos& ) const ;
554
558 virtual int identify() const ;
559
560 // Outputs
561 // -------
562
563 protected:
564 virtual ostream& operator>>(ostream &) const ;
565
566};
567
568 //------------------------------------//
569 // class Eos_BPAL12 //
570 //------------------------------------//
571
572
578class Eos_BPAL12 : public Eos_tabul {
579
580
581 // Constructors - Destructor
582 // -------------------------
583 public:
584
589 Eos_BPAL12(const char* path) ;
590
591
592 protected:
599 Eos_BPAL12(FILE* ) ;
600
606 Eos_BPAL12(ifstream& ) ;
607
608 private:
613
614
616 friend Eos* Eos::eos_from_file(FILE* ) ;
617 friend Eos* Eos::eos_from_file(ifstream& ) ;
618
619 public:
620 virtual ~Eos_BPAL12() ;
621
622 // Miscellaneous
623 // -------------
624
625 public :
627 virtual bool operator==(const Eos& ) const ;
628
630 virtual bool operator!=(const Eos& ) const ;
631
635 virtual int identify() const ;
636
637 // Outputs
638 // -------
639
640 protected:
641 virtual ostream& operator>>(ostream &) const ;
642
643};
644
645
646 //------------------------------------//
647 // class Eos_AkmalPR //
648 //------------------------------------//
649
650
664class Eos_AkmalPR : public Eos_tabul {
665
666
667 // Constructors - Destructor
668 // -------------------------
669 public:
670
675 Eos_AkmalPR(const char* path) ;
676
677
678 protected:
685 Eos_AkmalPR(FILE* ) ;
686
692 Eos_AkmalPR(ifstream& ) ;
693
694 private:
699
700
702 friend Eos* Eos::eos_from_file(FILE* ) ;
703 friend Eos* Eos::eos_from_file(ifstream& ) ;
704
705 public:
706 virtual ~Eos_AkmalPR() ;
707
708 // Miscellaneous
709 // -------------
710
711 public :
713 virtual bool operator==(const Eos& ) const ;
714
716 virtual bool operator!=(const Eos& ) const ;
717
721 virtual int identify() const ;
722
723 // Outputs
724 // -------
725
726 protected:
727 virtual ostream& operator>>(ostream &) const ;
728
729};
730
731 //------------------------------------//
732 // class Eos_BBB2 //
733 //------------------------------------//
734
735
746class Eos_BBB2 : public Eos_tabul {
747
748
749 // Constructors - Destructor
750 // -------------------------
751 public:
752
757 Eos_BBB2(const char* path) ;
758
759
760 protected:
767 Eos_BBB2(FILE* ) ;
768
774 Eos_BBB2(ifstream& ) ;
775
776 private:
780 Eos_BBB2(const Eos_BBB2& ) ;
781
782
784 friend Eos* Eos::eos_from_file(FILE* ) ;
785 friend Eos* Eos::eos_from_file(ifstream& ) ;
786
787 public:
788 virtual ~Eos_BBB2() ;
789
790 // Miscellaneous
791 // -------------
792
793 public :
795 virtual bool operator==(const Eos& ) const ;
796
798 virtual bool operator!=(const Eos& ) const ;
799
803 virtual int identify() const ;
804
805 // Outputs
806 // -------
807
808 protected:
809 virtual ostream& operator>>(ostream &) const ;
810
811};
812
813
814 //------------------------------------//
815 // class Eos_BalbN1H1 //
816 //------------------------------------//
817
818
824class Eos_BalbN1H1 : public Eos_tabul {
825
826
827 // Constructors - Destructor
828 // -------------------------
829 public:
830
835 Eos_BalbN1H1(const char* path) ;
836
837
838 protected:
845 Eos_BalbN1H1(FILE* ) ;
846
852 Eos_BalbN1H1(ifstream& ) ;
853
854 private:
859
860
862 friend Eos* Eos::eos_from_file(FILE* ) ;
863 friend Eos* Eos::eos_from_file(ifstream& ) ;
864
865 public:
866 virtual ~Eos_BalbN1H1() ;
867
868 // Miscellaneous
869 // -------------
870
871 public :
873 virtual bool operator==(const Eos& ) const ;
874
876 virtual bool operator!=(const Eos& ) const ;
877
881 virtual int identify() const ;
882
883 // Outputs
884 // -------
885
886 protected:
887 virtual ostream& operator>>(ostream &) const ;
888
889};
890
891
892
893 //------------------------------------//
894 // class Eos_GlendNH3 //
895 //------------------------------------//
896
897
904class Eos_GlendNH3 : public Eos_tabul {
905
906
907 // Constructors - Destructor
908 // -------------------------
909 public:
910
915 Eos_GlendNH3(const char* path) ;
916
917
918 protected:
925 Eos_GlendNH3(FILE* ) ;
926
932 Eos_GlendNH3(ifstream& ) ;
933
934 private:
939
940
942 friend Eos* Eos::eos_from_file(FILE* ) ;
943 friend Eos* Eos::eos_from_file(ifstream& ) ;
944
945 public:
946 virtual ~Eos_GlendNH3() ;
947
948 // Miscellaneous
949 // -------------
950
951 public :
953 virtual bool operator==(const Eos& ) const ;
954
956 virtual bool operator!=(const Eos& ) const ;
957
961 virtual int identify() const ;
962
963 // Outputs
964 // -------
965
966 protected:
967 virtual ostream& operator>>(ostream &) const ;
968
969};
970
971}
972#endif
973
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
virtual bool operator==(const Eos &) const
Comparison operator (egality).
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Eos_AkmalPR(const Eos_AkmalPR &)
Copy constructor (private to make Eos_AkmalPR a non-copiable class).
Eos_AkmalPR(const char *path)
Standard constructor.
Definition eos_akmalpr.C:69
virtual ~Eos_AkmalPR()
Destructor.
Definition eos_akmalpr.C:92
virtual ostream & operator>>(ostream &) const
Operator >>.
Eos_BBB2(const char *path)
Standard constructor.
Definition eos_bbb2.C:68
virtual ostream & operator>>(ostream &) const
Operator >>.
Definition eos_bbb2.C:127
virtual ~Eos_BBB2()
Destructor.
Definition eos_bbb2.C:91
Eos_BBB2(const Eos_BBB2 &)
Copy constructor (private to make Eos_BBB2 a non-copiable class).
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
Definition eos_bbb2.C:116
virtual bool operator==(const Eos &) const
Comparison operator (egality).
Definition eos_bbb2.C:103
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
Definition eos_bpal12.C:115
virtual ~Eos_BPAL12()
Destructor.
Definition eos_bpal12.C:90
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_bpal12.C:126
Eos_BPAL12(const Eos_BPAL12 &)
Copy constructor (private to make Eos_BPAL12 a non-copiable class).
Eos_BPAL12(const char *path)
Standard constructor.
Definition eos_bpal12.C:67
virtual bool operator==(const Eos &) const
Comparison operator (egality).
Definition eos_bpal12.C:102
virtual ~Eos_BalbN1H1()
Destructor.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
Eos_BalbN1H1(const Eos_BalbN1H1 &)
Copy constructor (private to make Eos_BalbN1H1 a non-copiable class).
Eos_BalbN1H1(const char *path)
Standard constructor.
virtual bool operator==(const Eos &) const
Comparison operator (egality).
virtual ostream & operator>>(ostream &) const
Operator >>.
Eos_FPS(const char *path)
Standard constructor.
Definition eos_fps.C:67
virtual ~Eos_FPS()
Destructor.
Definition eos_fps.C:89
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Eos_FPS(const Eos_FPS &)
Copy constructor (private to make Eos_FPS a non-copiable class).
virtual ostream & operator>>(ostream &) const
Operator >>.
Definition eos_fps.C:125
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
Definition eos_fps.C:114
virtual bool operator==(const Eos &) const
Comparison operator (egality).
Definition eos_fps.C:101
virtual ostream & operator>>(ostream &) const
Operator >>.
Eos_GlendNH3(const Eos_GlendNH3 &)
Copy constructor (private to make Eos_GlendNH3 a non-copiable class).
Eos_GlendNH3(const char *path)
Standard constructor.
virtual ~Eos_GlendNH3()
Destructor.
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
virtual bool operator==(const Eos &) const
Comparison operator (egality).
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
virtual ~Eos_SLy4()
Destructor.
Definition eos_sly4.C:89
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
Definition eos_sly4.C:114
virtual ostream & operator>>(ostream &) const
Operator >>.
Definition eos_sly4.C:125
virtual bool operator==(const Eos &) const
Comparison operator (egality).
Definition eos_sly4.C:101
Eos_SLy4(const Eos_SLy4 &)
Copy constructor (private to make Eos_SLy4 a non-copiable class).
Eos_SLy4(const char *path)
Standard constructor.
Definition eos_sly4.C:67
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
virtual double press_ent_p(double ent, const Param *par=0x0) const
Computes the pressure from the log-enthalpy.
Definition eos_tabul.C:475
virtual double ener_ent_p(double ent, const Param *par=0x0) const
Computes the total energy density from the log-enthalpy.
Definition eos_tabul.C:447
virtual double der_press_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Definition eos_tabul.C:543
virtual void read_table()
Reads the file containing the table and initializes in the arrays logh , logp and dlpsdlh .
Definition eos_tabul.C:258
virtual ~Eos_tabul()
Destructor.
Definition eos_tabul.C:232
Tbl * lognb
Table of .
Definition eos_tabul.h:212
Eos_tabul(const char *name_i, const char *table, const char *path)
Standard constructor.
Definition eos_tabul.C:164
double get_hmax() const
Returns maximal value of log-enthalpy in the table.
Definition eos_tabul.h:302
Tbl * dlpsdlh
Table of .
Definition eos_tabul.h:209
Tbl * dlpsdlnb
Table of .
Definition eos_tabul.h:215
virtual double nbar_ent_p(double ent, const Param *par=0x0) const
Computes the baryon density from the log-enthalpy.
Definition eos_tabul.C:419
virtual double der_nbar_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Definition eos_tabul.C:500
virtual double der_ener_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Definition eos_tabul.C:523
double get_hmin() const
Returns minimal value of log-enthalpy in the table.
Definition eos_tabul.h:299
virtual void sauve(FILE *) const
Save in a file.
Definition eos_tabul.C:245
virtual double csound_square_ent_p(double, const Param *) const
Computes the sound speed squared from the enthapy with extra parameters (virtual function implemente...
Definition eos_tabul.C:599
Tbl * logh
Table of .
Definition eos_tabul.h:203
Tbl * log_cs2
Table of .
Definition eos_tabul.h:218
string tablename
Name of the file containing the tabulated data.
Definition eos_tabul.h:192
Eos_tabul(const Eos_tabul &)
Copy constructor.
double hmin
Lower boundary of the enthalpy interval.
Definition eos_tabul.h:197
Tbl * logp
Table of .
Definition eos_tabul.h:206
virtual double der_press_nbar_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Definition eos_tabul.C:573
string authors
Authors - reference for the table.
Definition eos_tabul.h:194
double hmax
Upper boundary of the enthalpy interval.
Definition eos_tabul.h:200
Equation of state base class.
Definition eos.h:206
static Eos * eos_from_file(FILE *)
Construction of an EOS from a binary file.
Eos()
Standard constructor.
Definition eos.C:118
Parameter storage.
Definition param.h:125
Basic array class.
Definition tbl.h:161
Lorene prototypes.
Definition app_hor.h:67