LORENE
eos_strange.C
1 /*
2  * Methods for the class Eos_strange
3  *
4  * (see file eos.h for documentation)
5  *
6  */
7 
8 /*
9  * Copyright (c) 2000 J. Leszek Zdunik
10  * Copyright (c) 2000-2001 Eric Gourgoulhon
11  *
12  * This file is part of LORENE.
13  *
14  * LORENE is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * LORENE is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with LORENE; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  *
28  */
29 
30 
31 char eos_strange_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_strange.C,v 1.7 2014/10/13 08:52:54 j_novak Exp $" ;
32 
33 /*
34  * $Id: eos_strange.C,v 1.7 2014/10/13 08:52:54 j_novak Exp $
35  * $Log: eos_strange.C,v $
36  * Revision 1.7 2014/10/13 08:52:54 j_novak
37  * Lorene classes and functions now belong to the namespace Lorene.
38  *
39  * Revision 1.6 2014/10/06 15:13:07 j_novak
40  * Modified #include directives to use c++ syntax.
41  *
42  * Revision 1.5 2004/03/25 10:29:02 j_novak
43  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
44  *
45  * Revision 1.4 2002/10/16 14:36:35 j_novak
46  * Reorganization of #include instructions of standard C++, in order to
47  * use experimental version 3 of gcc.
48  *
49  * Revision 1.3 2002/04/09 14:32:15 e_gourgoulhon
50  * 1/ Added extra parameters in EOS computational functions (argument par)
51  * 2/ New class MEos for multi-domain EOS
52  *
53  * Revision 1.2 2001/12/04 21:27:53 e_gourgoulhon
54  *
55  * All writing/reading to a binary file are now performed according to
56  * the big endian convention, whatever the system is big endian or
57  * small endian, thanks to the functions fwrite_be and fread_be
58  *
59  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
60  * LORENE
61  *
62  * Revision 2.2 2001/02/07 09:49:47 eric
63  * Suppression de la fonction derent_ent_p.
64  * Ajout des fonctions donnant les derivees de l'EOS:
65  * der_nbar_ent_p
66  * der_ener_ent_p
67  * der_press_ent_p
68  *
69  * Revision 2.1 2000/10/25 10:54:41 eric
70  * Correction erreur dans la densite d'energie (conversion d'unite).
71  *
72  * Revision 2.0 2000/10/24 15:29:11 eric
73  * *** empty log message ***
74  *
75  *
76  * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_strange.C,v 1.7 2014/10/13 08:52:54 j_novak Exp $
77  *
78  */
79 
80 // Headers C
81 #include <cstdlib>
82 #include <cstring>
83 #include <cmath>
84 
85 // Headers Lorene
86 #include "eos.h"
87 #include "cmp.h"
88 #include "utilitaires.h"
89 #include "unites.h"
90 
91  //------------------------------------//
92  // Constructors //
93  //------------------------------------//
94 
95 // Standard constructor
96 // --------------------
97 namespace Lorene {
98 Eos_strange::Eos_strange(double n0_b60_i, double b60_i, double ent0_i,
99  double eps_fit_i, double rho0_b60_i) :
100  Eos("Strange matter EOS from Zdunik (2000)"),
101  n0_b60(n0_b60_i),
102  b60(b60_i),
103  ent0(ent0_i),
104  eps_fit(eps_fit_i),
105  rho0_b60(rho0_b60_i) {
106 
107  set_auxiliary() ;
108 
109 }
110 
111 // Copy constructor
112 // -----------------
113 
115  Eos(eos_i),
116  n0_b60(eos_i.n0_b60),
117  b60(eos_i.b60),
118  ent0(eos_i.ent0),
119  eps_fit(eos_i.eps_fit),
120  rho0_b60(eos_i.rho0_b60) {
121 
122  set_auxiliary() ;
123 
124 }
125 
126 
127 // Constructor from binary file
128 // ----------------------------
130  Eos(fich) {
131 
132  fread_be(&n0_b60, sizeof(double), 1, fich) ;
133  fread_be(&b60, sizeof(double), 1, fich) ;
134  fread_be(&ent0, sizeof(double), 1, fich) ;
135  fread_be(&eps_fit, sizeof(double), 1, fich) ;
136  fread_be(&rho0_b60, sizeof(double), 1, fich) ;
137 
138  set_auxiliary() ;
139 
140 }
141 
142 // Constructor from a formatted file
143 // ---------------------------------
144 Eos_strange::Eos_strange(ifstream& fich) :
145  Eos(fich) {
146 
147  char blabla[80] ;
148 
149  fich >> n0_b60 ; fich.getline(blabla, 80) ;
150  fich >> b60 ; fich.getline(blabla, 80) ;
151  fich >> ent0 ; fich.getline(blabla, 80) ;
152  fich >> eps_fit ; fich.getline(blabla, 80) ;
153  fich >> rho0_b60 ; fich.getline(blabla, 80) ;
154 
155  set_auxiliary() ;
156 
157 }
158  //--------------//
159  // Destructor //
160  //--------------//
161 
163 
164  // does nothing
165 
166 }
167 
168  //--------------//
169  // Assignment //
170  //--------------//
171 
173 
174  set_name(eosi.name) ;
175 
176  n0_b60 = eosi.n0_b60 ;
177  b60 = eosi.b60 ;
178  ent0 = eosi.ent0 ;
179  eps_fit = eosi.eps_fit ;
180  rho0_b60 = eosi.rho0_b60 ;
181 
182  set_auxiliary() ;
183 
184 }
185 
186 
187  //-----------------------//
188  // Miscellaneous //
189  //-----------------------//
190 
192 
193  using namespace Unites ;
194 
195  rho0 = b60 * rho0_b60 * mevpfm3 ;
196 
197  b34 = pow(b60, double(0.75)) ;
198 
199  n0 = b34 * n0_b60 * double(10) ; // 10 : fm^{-3} --> 0.1 fm^{-3}
200 
201  fach = (double(4) + eps_fit) / (double(1) + eps_fit) ;
202 
203 }
204 
205 
206  //------------------------//
207  // Comparison operators //
208  //------------------------//
209 
210 
211 bool Eos_strange::operator==(const Eos& eos_i) const {
212 
213  bool resu = true ;
214 
215  if ( eos_i.identify() != identify() ) {
216  cout << "The second EOS is not of type Eos_strange !" << endl ;
217  resu = false ;
218  }
219  else{
220 
221  const Eos_strange& eos = dynamic_cast<const Eos_strange&>( eos_i ) ;
222 
223  if (eos.n0_b60 != n0_b60) {
224  cout
225  << "The two Eos_strange have different n0_b60 : " << n0_b60 << " <-> "
226  << eos.n0_b60 << endl ;
227  resu = false ;
228  }
229 
230  if (eos.b60 != b60) {
231  cout
232  << "The two Eos_strange have different b60 : " << b60 << " <-> "
233  << eos.b60 << endl ;
234  resu = false ;
235  }
236 
237  if (eos.ent0 != ent0) {
238  cout
239  << "The two Eos_strange have different ent0 : " << ent0 << " <-> "
240  << eos.ent0 << endl ;
241  resu = false ;
242  }
243 
244  if (eos.eps_fit != eps_fit) {
245  cout
246  << "The two Eos_strange have different eps_fit : " << eps_fit
247  << " <-> " << eos.eps_fit << endl ;
248  resu = false ;
249  }
250 
251  if (eos.rho0_b60 != rho0_b60) {
252  cout
253  << "The two Eos_strange have different rho0_b60 : " << rho0_b60
254  << " <-> " << eos.rho0_b60 << endl ;
255  resu = false ;
256  }
257 
258 
259  }
260 
261  return resu ;
262 
263 }
264 
265 bool Eos_strange::operator!=(const Eos& eos_i) const {
266 
267  return !(operator==(eos_i)) ;
268 
269 }
270 
271  //------------//
272  // Outputs //
273  //------------//
274 
275 void Eos_strange::sauve(FILE* fich) const {
276 
277  Eos::sauve(fich) ;
278 
279  fwrite_be(&n0_b60, sizeof(double), 1, fich) ;
280  fwrite_be(&b60, sizeof(double), 1, fich) ;
281  fwrite_be(&ent0, sizeof(double), 1, fich) ;
282  fwrite_be(&eps_fit, sizeof(double), 1, fich) ;
283  fwrite_be(&rho0_b60, sizeof(double), 1, fich) ;
284 
285 }
286 
287 ostream& Eos_strange::operator>>(ostream & ost) const {
288 
289  ost <<
290  "EOS of class Eos_strange (Strange matter EOS from Zdunik (2000)) : "
291  << endl ;
292  ost << " Baryon density at zero pressure : " << n0_b60
293  << " * B_{60}^{3/4}" << endl ;
294  ost << " Bag constant B : " << b60 << " * 60 MeV/fm^3"<< endl ;
295  ost <<
296  " Log-enthalpy threshold for setting the energy density to non-zero: "
297  << endl << " " << ent0 << endl ;
298  ost << " Fitting parameter eps_fit : " << eps_fit << endl ;
299  ost << " Energy density at zero pressure : " << rho0_b60
300  << " * B_{60} MeV/fm^3" << endl ;
301 
302  return ost ;
303 
304 }
305 
306 
307  //------------------------------//
308  // Computational routines //
309  //------------------------------//
310 
311 // Baryon density from enthalpy
312 //------------------------------
313 
314 double Eos_strange::nbar_ent_p(double ent, const Param* ) const {
315 
316  if ( ent > ent0 ) {
317 
318  return n0 * exp( double(3) * ent / (double(1) + eps_fit)) ;
319 
320  }
321  else{
322  return 0 ;
323  }
324 }
325 
326 // Energy density from enthalpy
327 //------------------------------
328 
329 double Eos_strange::ener_ent_p(double ent, const Param* ) const {
330 
331 
332  if ( ent > ent0 ) {
333 
334  double pp = ( exp(fach * ent) - 1) / fach * rho0 ;
335 
336  return rho0 + double(3) * pp / (double(1) + eps_fit) ;
337 
338  }
339  else{
340  return 0 ;
341  }
342 }
343 
344 // Pressure from enthalpy
345 //------------------------
346 
347 double Eos_strange::press_ent_p(double ent, const Param* ) const {
348 
349  if ( ent > ent0 ) {
350 
351  return ( exp(fach * ent) - 1) / fach * rho0 ;
352 
353  }
354  else{
355  return 0 ;
356  }
357 }
358 
359 
360 
361 // dln(n)/ln(H) from enthalpy
362 //---------------------------
363 
364 double Eos_strange::der_nbar_ent_p(double ent, const Param* ) const {
365 
366  if ( ent > ent0 ) {
367 
368  return double(3) * ent / ( double(1) + eps_fit ) ;
369 
370  }
371  else{
372  return 0 ;
373  }
374 }
375 
376 // dln(e)/ln(H) from enthalpy
377 //---------------------------
378 
379 double Eos_strange::der_ener_ent_p(double ent, const Param* ) const {
380 
381  if ( ent > ent0 ) {
382 
383  double xx = fach * ent ;
384 
385  return xx / ( double(1) +
386  ( double(1) + eps_fit ) / double(3) * exp(-xx) ) ;
387 
388  }
389  else{
390  return 0 ;
391  }
392 }
393 
394 // dln(p)/ln(H) from enthalpy
395 //---------------------------
396 
397 double Eos_strange::der_press_ent_p(double ent, const Param* ) const {
398 
399  if ( ent > ent0 ) {
400 
401  double xx = fach * ent ;
402 
403  return xx / ( double(1) - exp(-xx) ) ;
404 
405  }
406  else{
407  return 0 ;
408  }
409 }
410 
411 }
Strange matter EOS (MIT Bag model).
Definition: eos.h:1540
double rho0
Energy density at zero pressure.
Definition: eos.h:1579
virtual bool operator!=(const Eos &) const
Comparison operator (difference)
Definition: eos_strange.C:265
virtual double press_ent_p(double ent, const Param *par=0x0) const
Computes the pressure from the log-enthalpy.
Definition: eos_strange.C:347
double eps_fit
Fitting parameter related to the square of sound velocity by .
Definition: eos.h:1563
virtual double ener_ent_p(double ent, const Param *par=0x0) const
Computes the total energy density from the log-enthalpy.
Definition: eos_strange.C:329
double n0
Baryon density at zero pressure.
Definition: eos.h:1573
virtual void sauve(FILE *) const
Save in a file.
Definition: eos_strange.C:275
virtual double der_press_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Definition: eos_strange.C:397
double fach
Factor .
Definition: eos.h:1589
Eos_strange(double n0_b60_i, double b60_i, double ent0_i, double eps_fit_i, double rho0_b60_i)
Standard constructor.
Definition: eos_strange.C:98
virtual bool operator==(const Eos &) const
Comparison operator (egality)
Definition: eos_strange.C:211
void set_auxiliary()
Computes the auxiliary quantities n0 , rh0 , b34 and fach from the values of the other parameters.
Definition: eos_strange.C:191
double b60
Bag constant [unit: ].
Definition: eos.h:1552
virtual double der_ener_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Definition: eos_strange.C:379
double ent0
Log-enthalpy threshold for setting the energy density to a non zero value (should be negative).
Definition: eos.h:1557
virtual ~Eos_strange()
Destructor.
Definition: eos_strange.C:162
virtual double der_nbar_ent_p(double ent, const Param *par=0x0) const
Computes the logarithmic derivative from the log-enthalpy.
Definition: eos_strange.C:364
double rho0_b60
Energy density at zero pressure divided by .
Definition: eos.h:1568
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
void operator=(const Eos_strange &)
Assignment to another Eos_strange.
Definition: eos_strange.C:172
virtual ostream & operator>>(ostream &) const
Operator >>
Definition: eos_strange.C:287
double n0_b60
Baryon density at zero pressure divided by .
Definition: eos.h:1549
virtual double nbar_ent_p(double ent, const Param *par=0x0) const
Computes the baryon density from the log-enthalpy.
Definition: eos_strange.C:314
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.
virtual void sauve(FILE *) const
Save in a file.
Definition: eos.C:179
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
Cmp exp(const Cmp &)
Exponential.
Definition: cmp_math.C:270
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:348
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Definition: fread_be.C:69
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Definition: fwrite_be.C:70
Lorene prototypes.
Definition: app_hor.h:64
Standard units of space, time and mass.