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