Debian Codegraph @

C++/Include/eos_mag.h

raw symbols SCIP
1 /*
2 * Definition of Lorene classes Eos_mag
3 */
4
5 /*
6 * Copyright (c) 2011 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_MAG_H_
28 #define __EOS_MAG_H_
29
30 /*
31 * $Id: eos_mag.h,v 1.4 2014/10/13 08:52:33 j_novak Exp $
32 * $Log: eos_mag.h,v $
33 * Revision 1.4 2014/10/13 08:52:33 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.3 2013/12/13 16:36:51 j_novak
37 * Addition and computation of magnetisation terms in the Einstein equations.
38 *
39 * Revision 1.2 2011/10/04 16:05:18 j_novak
40 * Update of Eos_mag class. Suppression of loge, re-definition of the derivatives
41 * and use of interpol_herm_2d.
42 *
43 * Revision 1.1 2011/06/16 10:49:18 j_novak
44 * New class Eos_mag for EOSs depending on density and magnetic field.
45 *
46 *
47 * $Header: /cvsroot/Lorene/C++/Include/eos_mag.h,v 1.4 2014/10/13 08:52:33 j_novak Exp $
48 *
49 */
50
51 // Standard C++
52 #include "headcpp.h"
53 #include <string>
54
55 // Headers C
56 #include <cstdio>
57
58 // Lorene classes
59 namespace Lorene {
60 class Tbl ;
61 class Cmp ;
62
63
64 //------------------------------------//
65 // class Eos_mag //
66 //------------------------------------//
67
68
69 /**
70 * Class for a magnetized (tabulated) equation of state. \ingroup (eos)
71 *
72 * This EOS depends on two variables \f$(n, B)\f$: density (or log-enthalpy)
73 * and the magnetic field amplitude. The interpolation through the tables is
74 * a cubic Hermite interpolation, which is thermodynamically consistent, i.e.
75 * preserves the Gibbs-Duhem relation.
76 *
77 */
78 class Eos_mag : public Eos {
79
80 // Data :
81 // -----
82
83 protected:
84 /// Name of the file containing the tabulated data
85 string tablename ;
86
87 /// Lower boundary of the log-enthalpy interval
88 double hmin ;
89
90 /// Upper boundary of the log-enthalpy interval
91 double hmax ;
92
93 /// Upper boundary of the magnetic field interval
94 double Bmax ;
95
96 /// Table of \f$\log p\f$
97 Tbl* logp ;
98
99 /// Table of \f$\log h\f$
100 Tbl* logh ;
101
102 /// Table of \f$B\f$
103 Tbl* Bfield ;
104
105 /// Table of \f$\frac{d \log p}{d \log h}\f$
106 Tbl* dlpsdlh ;
107
108 /// Table of \f$\frac{d \log p}{d \log B}\f$
109 Tbl* dlpsdB ;
110
111 /// Table of \f$\frac{d^2 \log p}{d \log h d \log B}\f$
112 Tbl* d2lp ;
113
114
115 // Constructors - Destructor
116 // -------------------------
117 protected:
118
119 /** Standard constructor.
120 *
121 * @param name_i Name of the equation of state
122 * @param table Name of the file containing the EOS table
123 * @param path Path to the directory containing the EOS file
124 */
125 Eos_mag(const char* name_i, const char* table, const char* path) ;
126
127 /** Standard constructor from the full filename.
128 *
129 * @param name_i Name of the equation of state
130 * @param table Full name of the file containing the EOS table
131 * (including the absolute path).
132 */
133 Eos_mag(const char* name_i, const char* file_name) ;
134
135 Eos_mag(const Eos_mag& ) ; ///< Copy constructor
136
137 protected:
138
139 /** Constructor from a binary file (created by the function
140 * \c sauve(FILE*) ).
141 * This constructor is protected because any EOS construction
142 * from a binary file must be done via the function
143 * \c Eos::eos_from_file(FILE*) .
144 */
145 Eos_mag(FILE* ) ;
146
147 /** Constructor from a formatted file.
148 * This constructor is protected because any EOS construction
149 * from a formatted file must be done via the function
150 * \c Eos::eos_from_file(ifstream\& ) .
151 *
152 * @param ist input file stream containing a name as first line
153 * and the path to the directory containing the EOS file
154 * as second line
155 * @param table Name of the file containing the EOS table
156 */
157 Eos_mag(ifstream& ist, const char* table) ;
158
159 /** Constructor from a formatted file.
160 * This constructor is protected because any EOS construction
161 * from a formatted file must be done via the function
162 * \c Eos::eos_from_file(ifstream\& ) .
163 *
164 * @param ist input file stream containing a name as first line
165 * and the full filename (including the path) containing
166 * the EOS file as second line
167 */
168 Eos_mag(ifstream& ist) ;
169
170 /// The construction functions from a file
171 friend Eos* Eos::eos_from_file(FILE* ) ;
172 friend Eos* Eos::eos_from_file(ifstream& ) ;
173
174 public:
175 virtual ~Eos_mag() ; ///< Destructor
176
177
178 // Miscellaneous
179 // -------------
180
181 protected:
182 /** Reads the file containing the table and initializes
183 * in the arrays \c logh , \c logp and \c dlpsdlh .
184 */
185 void read_table() ;
186
187 public :
188 /// Comparison operator (egality)
189 virtual bool operator==(const Eos& ) const ;
190
191 /// Comparison operator (difference)
192 virtual bool operator!=(const Eos& ) const ;
193
194 /** Returns a number to identify the sub-classe of \c Eos the
195 * object belongs to.
196 */
197 virtual int identify() const ;
198
199 // Outputs
200 // -------
201 public:
202 virtual void sauve(FILE* ) const ; ///< Save in a file
203
204
205 protected:
206 virtual ostream& operator>>(ostream &) const ; ///< Operator >>
207
208 // Computational functions
209 // -----------------------
210
211 public:
212 /** Computes the magnetisation.
213 */
214 double mag_ent_p(double ent, const Param* par=0x0) const ;
215
216 /** Computes the baryon density from the log-enthalpy.
217 *
218 * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H
219 *
220 * @return baryon density \e n [unit: \f$n_{\rm nuc} := 0.1 \ {\rm fm}^{-3}\f$]
221 *
222 */
223 virtual double nbar_ent_p(double ent, const Param* par=0x0) const ;
224
225
226 /** Computes the total energy density from the log-enthalpy.
227 *
228 * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H
229 *
230 * @return energy density \e e [unit: \f$\rho_{\rm nuc} c^2\f$], where
231 * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$
232 */
233 virtual double ener_ent_p(double ent, const Param* par=0x0) const ;
234
235 /** Computes the pressure from the log-enthalpy.
236 *
237 * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H
238 *
239 * @return pressure \e p [unit: \f$\rho_{\rm nuc} c^2\f$], where
240 * \f$\rho_{\rm nuc} := 1.66\ 10^{17} \ {\rm kg/m}^3\f$
241 */
242 virtual double press_ent_p(double ent, const Param* par=0x0) const ;
243
244 /** Computes the logarithmic derivative \f$d\ln n/d\ln H\f$
245 * from the log-enthalpy.
246 *
247 * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H
248 *
249 * @return dln(n)/dln(H)
250 */
251 virtual double der_nbar_ent_p(double ent, const Param* par=0x0) const ;
252
253 /** Computes the logarithmic derivative \f$d\ln e/d\ln H\f$
254 * from the log-enthalpy.
255 *
256 * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H
257 *
258 * @return dln(e)/dln(H)
259 */
260 virtual double der_ener_ent_p(double ent, const Param* par=0x0) const ;
261
262 /** Computes the logarithmic derivative \f$d\ln p/d\ln H\f$
263 * from the log-enthalpy.
264 *
265 * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H
266 *
267 * @return dln(p)/dln(H)
268 */
269 virtual double der_press_ent_p(double ent, const Param* par=0x0) const ;
270
271 /** Computes the logarithmic derivative \f$d\ln p/d\ln n\f$
272 * from the log-enthalpy.
273 *
274 * @param ent [input, unit: \f$c^2\f$] log-enthalpy \e H
275 *
276 * @return dln(p)/dln(n)
277 */
278 virtual double der_press_nbar_p(double ent, const Param* par=0x0) const ;
279
280 };
281
282
283 }
284 #endif
285