LORENE
eos_incomp_newt.C
1 /*
2  * Methods of the class Eos_incomp_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 char Eos_incomp_newt_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_incomp_newt.C,v 1.5 2014/10/13 08:52:53 j_novak Exp $" ;
30 
31 /*
32  * $Id: eos_incomp_newt.C,v 1.5 2014/10/13 08:52:53 j_novak Exp $
33  * $Log: eos_incomp_newt.C,v $
34  * Revision 1.5 2014/10/13 08:52:53 j_novak
35  * Lorene classes and functions now belong to the namespace Lorene.
36  *
37  * Revision 1.4 2014/10/06 15:13:06 j_novak
38  * Modified #include directives to use c++ syntax.
39  *
40  * Revision 1.3 2002/10/16 14:36:35 j_novak
41  * Reorganization of #include instructions of standard C++, in order to
42  * use experimental version 3 of gcc.
43  *
44  * Revision 1.2 2002/04/09 14:32:15 e_gourgoulhon
45  * 1/ Added extra parameters in EOS computational functions (argument par)
46  * 2/ New class MEos for multi-domain EOS
47  *
48  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
49  * LORENE
50  *
51  * Revision 2.5 2001/02/07 09:48:48 eric
52  * Suppression de la fonction derent_ent_p.
53  * Ajout des fonctions donnant les derivees de l'EOS:
54  * der_nbar_ent_p
55  * der_ener_ent_p
56  * der_press_ent_p
57  *
58  * Revision 2.4 2000/02/14 14:49:55 eric
59  * Modif affichage.
60  *
61  * Revision 2.3 2000/02/14 14:34:02 eric
62  * Ajout du constructeur par lecture de fichier formate.
63  *
64  * Revision 2.2 2000/01/21 15:18:30 eric
65  * Ajout des operateurs de comparaison == et !=
66  *
67  * Revision 2.1 2000/01/19 08:53:39 eric
68  * Ajout du set_name dans les constructeurs standards.
69  *
70  * Revision 2.0 2000/01/18 16:11:38 eric
71  * *** empty log message ***
72  *
73  *
74  * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_incomp_newt.C,v 1.5 2014/10/13 08:52:53 j_novak Exp $
75  *
76  */
77 
78 
79 // Headers C
80 #include <cstdlib>
81 #include <cstring>
82 #include <cmath>
83 
84 // Headers Lorene
85 #include "eos.h"
86 #include "cmp.h"
87 
88  //--------------//
89  // Constructors //
90  //--------------//
91 
92 // Standard constructor with ent0 = 1
93 // ---------------------------------
94 namespace Lorene {
96 
97  set_name("Newtonian EOS for incompressible matter") ;
98 
99 }
100 
101 // Standard constructor with ent0 specified
102 // ---------------------------------------
103 Eos_incomp_newt::Eos_incomp_newt(double rho_c, double ent_c) :
104  Eos_incomp(rho_c, ent_c) {
105 
106  set_name("Newtonian EOS for incompressible matter") ;
107 
108 }
109 
110 // Copy constructor
111 // ----------------
113  Eos_incomp(eosi) {}
114 
115 
116 // Constructor from a binary file
117 // ------------------------------
119 
120 // Constructor from a formatted file
121 // ---------------------------------
123 
124  //--------------//
125  // Destructor //
126  //--------------//
127 
129 
130  // does nothing
131 
132 }
133  //--------------//
134  // Assignment //
135  //--------------//
136 
138 
139  set_name(eosi.name) ;
140 
141  rho0 = eosi.rho0 ;
142  ent0 = eosi.ent0 ;
143 
144 }
145 
146  //------------------------//
147  // Comparison operators //
148  //------------------------//
149 
150 bool Eos_incomp_newt::operator==(const Eos& eos_i) const {
151 
152  bool resu = true ;
153 
154  if ( eos_i.identify() != identify() ) {
155  cout << "The second EOS is not of type Eos_incomp_newt !" << endl ;
156  resu = false ;
157  }
158  else{
159 
160  const Eos_incomp_newt& eos =
161  dynamic_cast<const Eos_incomp_newt&>( eos_i ) ;
162 
163  if (eos.rho0 != rho0) {
164  cout
165  << "The two Eos_incomp_newt have different rho0 : " << rho0 << " <-> "
166  << eos.rho0 << endl ;
167  resu = false ;
168  }
169 
170  if (eos.ent0 != ent0) {
171  cout
172  << "The two Eos_incomp_newt have different ent0 : " << ent0 << " <-> "
173  << eos.ent0 << endl ;
174  resu = false ;
175  }
176 
177  }
178 
179  return resu ;
180 
181 }
182 
183 bool Eos_incomp_newt::operator!=(const Eos& eos_i) const {
184 
185  return !(operator==(eos_i)) ;
186 
187 }
188 
189 
190 
191  //------------//
192  // Outputs //
193  //------------//
194 
195 void Eos_incomp_newt::sauve(FILE* fich) const {
196 
197  Eos_incomp::sauve(fich) ;
198 
199 }
200 
201 ostream& Eos_incomp_newt::operator>>(ostream & ost) const {
202 
203  ost << "EOS of class Eos_incomp_newt (Newtonian incompressible matter) : "
204  << endl ;
205  ost << " Constant density : " << rho0 << " rho_nuc" << endl ;
206  ost << " Log-enthalpy threshold for non-zero density : " << ent0
207  << " c^2" << endl ;
208 
209  return ost ;
210 
211 }
212 
213 
214  //------------------------------//
215  // Computational routines //
216  //------------------------------//
217 
218 // Baryon density from enthalpy
219 //------------------------------
220 
221 double Eos_incomp_newt::nbar_ent_p(double ent, const Param* ) const {
222 
223  if ( ent >= ent0 ) {
224 
225  return rho0 ;
226  }
227  else{
228  return 0 ;
229  }
230 }
231 
232 // Energy density from enthalpy
233 //------------------------------
234 
235 double Eos_incomp_newt::ener_ent_p(double ent, const Param* ) const {
236 
237  if ( ent >= ent0 ) {
238 
239  return rho0 ;
240  }
241  else{
242  return 0 ;
243  }
244 }
245 
246 // Pressure from enthalpy
247 //------------------------
248 
249 double Eos_incomp_newt::press_ent_p(double ent, const Param* ) const {
250 
251  if ( ent >= ent0 ) {
252 
253  return rho0 * ent ;
254  }
255  else{
256  return 0 ;
257  }
258 }
259 
260 // dln(n)/ln(h) from enthalpy
261 //---------------------------
262 
263 double Eos_incomp_newt::der_nbar_ent_p(double ent, const Param* ) const {
264 
265  if ( ent >= ent0 ) {
266 
267  return 0 ;
268  }
269  else{
270  return 0 ;
271  }
272 }
273 
274 // dln(e)/ln(h) from enthalpy
275 //---------------------------
276 
277 double Eos_incomp_newt::der_ener_ent_p(double ent, const Param* ) const {
278 
279  if ( ent >= ent0 ) {
280 
281  return 0 ;
282  }
283  else{
284  return 0 ;
285  }
286 }
287 
288 // dln(p)/ln(h) from enthalpy
289 //---------------------------
290 
291 double Eos_incomp_newt::der_press_ent_p(double ent, const Param* ) const {
292 
293  if ( ent >= ent0 ) {
294 
295  return double(1) ;
296 
297  }
298  else{
299  return 0 ;
300  }
301 }
302 }
Equation of state of incompressible matter (Newtonian case).
Definition: eos.h:1376
virtual double ener_ent_p(double ent, const Param *par=0x0) const
Computes the total energy density from the specific enthalpy.
virtual double der_nbar_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the specific enthalpy.
virtual double nbar_ent_p(double ent, const Param *par=0x0) const
Computes the baryon density from the specific enthalpy.
virtual ~Eos_incomp_newt()
Destructor.
virtual double press_ent_p(double ent, const Param *par=0x0) const
Computes the pressure from the specific enthalpy.
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 (egality)
virtual double der_ener_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the specific enthalpy.
virtual double der_press_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the specific enthalpy.
Eos_incomp_newt(double rho_c)
Standard constructor.
virtual bool operator!=(const Eos &) const
Comparison operator (difference)
void operator=(const Eos_incomp_newt &)
Assignment to another Eos_incomp_newt.
virtual ostream & operator>>(ostream &) const
Operator >>
virtual void sauve(FILE *) const
Save in a file.
Equation of state of incompressible matter (relativistic case).
Definition: eos.h:1206
virtual void sauve(FILE *) const
Save in a file.
Definition: eos_incomp.C:211
double ent0
Log-enthalpy threshold for setting the energy density to a non zero value (should be negative).
Definition: eos.h:1218
double rho0
Constant density .
Definition: eos.h:1213
Equation of state base class.
Definition: eos.h:190
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:196
void set_name(const char *name_i)
Sets the EOS name.
Definition: eos.C:163
Parameter storage.
Definition: param.h:125
Lorene prototypes.
Definition: app_hor.h:64