LORENE
eos_poly_newt.C
1/*
2 * Methods of the class Eos_poly_newt.
3 *
4 * (see file eos.h for documentation).
5 */
6
7/*
8 * Copyright (c) 2000-2001 Eric Gourgoulhon
9 *
10 * This file is part of LORENE.
11 *
12 * LORENE is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28
29
30
31/*
32 * $Id: eos_poly_newt.C,v 1.6 2016/12/05 16:17:51 j_novak Exp $
33 * $Log: eos_poly_newt.C,v $
34 * Revision 1.6 2016/12/05 16:17:51 j_novak
35 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
36 *
37 * Revision 1.5 2014/10/13 08:52:53 j_novak
38 * Lorene classes and functions now belong to the namespace Lorene.
39 *
40 * Revision 1.4 2014/10/06 15:13:06 j_novak
41 * Modified #include directives to use c++ syntax.
42 *
43 * Revision 1.3 2002/10/16 14:36:35 j_novak
44 * Reorganization of #include instructions of standard C++, in order to
45 * use experimental version 3 of gcc.
46 *
47 * Revision 1.2 2002/04/09 14:32:15 e_gourgoulhon
48 * 1/ Added extra parameters in EOS computational functions (argument par)
49 * 2/ New class MEos for multi-domain EOS
50 *
51 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
52 * LORENE
53 *
54 * Revision 2.5 2001/02/23 15:16:51 eric
55 * Continuite en ent=0 des quantites derivees.
56 *
57 * Revision 2.4 2001/02/07 09:50:11 eric
58 * Suppression de la fonction derent_ent_p.
59 * Ajout des fonctions donnant les derivees de l'EOS:
60 * der_nbar_ent_p
61 * der_ener_ent_p
62 * der_press_ent_p
63 *
64 * Revision 2.3 2000/02/14 14:49:41 eric
65 * Modif affichage.
66 *
67 * Revision 2.2 2000/02/14 14:33:33 eric
68 * Ajout du constructeur par lecture de fichier formate.
69 *
70 * Revision 2.1 2000/01/21 15:18:56 eric
71 * Ajout des operateurs de comparaison == et !=
72 *
73 * Revision 2.0 2000/01/18 15:14:12 eric
74 * *** empty log message ***
75 *
76 *
77 * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_poly_newt.C,v 1.6 2016/12/05 16:17:51 j_novak Exp $
78 *
79 */
80
81// Headers C
82#include <cstdlib>
83#include <cstring>
84#include <cmath>
85
86// Headers Lorene
87#include "eos.h"
88#include "cmp.h"
89
90 //--------------//
91 // Constructors //
92 //--------------//
93
94// Standard constructor
95// --------------------
96namespace Lorene {
97Eos_poly_newt::Eos_poly_newt(double gamma, double kappa) :
98 Eos_poly(gamma, kappa) {
99
100 set_name("Newtonian polytropic EOS") ;
101
102}
103
104
105// Copy constructor
106// ----------------
108
109
110// Constructor from a binary file
111// ------------------------------
113
114// Constructor from a formatted file
115// ---------------------------------
116Eos_poly_newt::Eos_poly_newt(ifstream& fich) : Eos_poly(fich) {}
117
118
119 //--------------//
120 // Destructor //
121 //--------------//
122
124
125 // does nothing
126
127}
128 //--------------//
129 // Assignment //
130 //--------------//
131
133
134 set_name(eosi.name) ;
135
136 gam = eosi.gam ;
137 kap = eosi.kap ;
138 m_0 = eosi.m_0 ;
139
140 set_auxiliary() ;
141
142}
143 //------------------------//
144 // Comparison operators //
145 //------------------------//
146
147bool Eos_poly_newt::operator==(const Eos& eos_i) const {
148
149 bool resu = true ;
150
151 if ( eos_i.identify() != identify() ) {
152 cout << "The second EOS is not of type Eos_poly_newt !" << endl ;
153 resu = false ;
154 }
155 else{
156
157 const Eos_poly_newt& eos = dynamic_cast<const Eos_poly_newt&>( eos_i ) ;
158
159 if (eos.gam != gam) {
160 cout
161 << "The two Eos_poly_newt have different gamma : " << gam << " <-> "
162 << eos.gam << endl ;
163 resu = false ;
164 }
165
166 if (eos.kap != kap) {
167 cout
168 << "The two Eos_poly_newt have different kappa : " << kap << " <-> "
169 << eos.kap << endl ;
170 resu = false ;
171 }
172
173 if (eos.m_0 != m_0) {
174 cout
175 << "The two Eos_poly_newt have different m_0 : " << m_0 << " <-> "
176 << eos.m_0 << endl ;
177 resu = false ;
178 }
179
180 }
181
182 return resu ;
183
184}
185
186bool Eos_poly_newt::operator!=(const Eos& eos_i) const {
187
188 return !(operator==(eos_i)) ;
189
190}
191
192
193 //------------//
194 // Outputs //
195 //------------//
196
197void Eos_poly_newt::sauve(FILE* fich) const {
198
199 Eos_poly::sauve(fich) ;
200
201}
202
203ostream& Eos_poly_newt::operator>>(ostream & ost) const {
204
205 ost << "EOS of class Eos_poly_newt (Newtonian polytrope) : " << endl ;
206 ost << " Adiabatic index gamma : " << gam << endl ;
207 ost << " Pressure coefficient kappa : " << kap <<
208 " rho_nuc c^2 / n_nuc^gamma" << endl ;
209
210 return ost ;
211
212}
213
214
215 //------------------------------//
216 // Computational routines //
217 //------------------------------//
218
219// Baryon density from enthalpy
220//------------------------------
221
222double Eos_poly_newt::nbar_ent_p(double ent, const Param* ) const {
223
224 if ( ent > double(0) ) {
225
226 return pow( gam1sgamkap * ent, unsgam1 ) ;
227 }
228 else{
229 return 0 ;
230 }
231}
232
233// Energy density from enthalpy
234//------------------------------
235
236double Eos_poly_newt::ener_ent_p(double ent, const Param* ) const {
237
238 if ( ent > double(0) ) {
239
240 double nn = pow( gam1sgamkap * ent, unsgam1 ) ;
241
242 double pp = kap * pow( nn, gam ) ;
243
244 return unsgam1 * pp + m_0 * nn ;
245 }
246 else{
247 return 0 ;
248 }
249}
250
251// Pressure from enthalpy
252//------------------------
253
254double Eos_poly_newt::press_ent_p(double ent, const Param* ) const {
255
256 if ( ent > double(0) ) {
257
258 double nn = pow( gam1sgamkap * ent, unsgam1 ) ;
259
260 return kap * pow( nn, gam ) ;
261
262 }
263 else{
264 return 0 ;
265 }
266}
267
268// dln(n)/ln(h) from enthalpy
269//---------------------------
270
271double Eos_poly_newt::der_nbar_ent_p(double , const Param* ) const {
272
273 return double(1) / gam1 ;
274
275}
276
277// dln(e)/ln(h) from enthalpy
278//---------------------------
279
280double Eos_poly_newt::der_ener_ent_p(double ent, const Param* ) const {
281
282 if ( ent > double(0) ) {
283
284
285 double nn = pow( gam1sgamkap * ( exp(ent) - double(1) ),
286 unsgam1 ) ;
287
288 double pp = kap * pow( nn, gam ) ;
289
290 double ee = unsgam1 * pp + m_0 * nn ;
291
292
293 return ( double(1) + pp / ee) / gam1 ;
294
295 }
296 else{
297 return double(1) / gam1 ; // to ensure continuity at ent=0
298 }
299}
300
301// dln(p)/ln(h) from enthalpy
302//---------------------------
303
304double Eos_poly_newt::der_press_ent_p(double, const Param* ) const {
305
306 return gam / gam1 ;
307
308}
309
310}
virtual double der_press_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the specific enthalpy.
virtual bool operator==(const Eos &) const
Comparison operator (egality).
void operator=(const Eos_poly_newt &)
Assignment to another Eos_poly_newt.
virtual double ener_ent_p(double ent, const Param *par=0x0) const
Computes the total energy density from the specific enthalpy.
virtual double press_ent_p(double ent, const Param *par=0x0) const
Computes the pressure from the specific enthalpy.
virtual double der_ener_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the specific enthalpy.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
virtual void sauve(FILE *) const
Save in a file.
virtual ~Eos_poly_newt()
Destructor.
virtual bool operator!=(const Eos &) const
Comparison operator (difference).
virtual double der_nbar_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the specific enthalpy.
virtual ostream & operator>>(ostream &) const
Operator >>.
virtual double nbar_ent_p(double ent, const Param *par=0x0) const
Computes the baryon density from the specific enthalpy.
Eos_poly_newt(double gamma, double kappa)
Standard constructor.
double kap
Pressure coefficient (cf.
Definition eos.h:823
virtual void sauve(FILE *) const
Save in a file.
Definition eos_poly.C:350
Eos_poly(double gamma, double kappa)
Standard constructor (sets both m_0 and mu_0 to 1).
Definition eos_poly.C:141
double gam1sgamkap
Definition eos.h:840
double unsgam1
Definition eos.h:839
double gam
Adiabatic index (cf. Eq. (3)).
Definition eos.h:816
double m_0
Individual particule mass (cf.
Definition eos.h:828
double gam1
Definition eos.h:838
void set_auxiliary()
Computes the auxiliary quantities gam1 , unsgam1 , gam1sgamkap from the values of gam and kap.
Definition eos_poly.C:257
Equation of state base class.
Definition eos.h:206
virtual int identify() const =0
Returns a number to identify the sub-classe of Eos the object belongs to.
char name[100]
EOS name.
Definition eos.h:212
void set_name(const char *name_i)
Sets the EOS name.
Definition eos.C:173
Parameter storage.
Definition param.h:125
Cmp exp(const Cmp &)
Exponential.
Definition cmp_math.C:273
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:351
Lorene prototypes.
Definition app_hor.h:67