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