LORENE
eos_from_file.C
1/*
2 * Methods for Eos and file manipulation
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
29char eos_from_file_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_from_file.C,v 1.16 2015/08/04 14:41:29 j_novak Exp $" ;
30
31/*
32 * $Id: eos_from_file.C,v 1.16 2015/08/04 14:41:29 j_novak Exp $
33 * $Log: eos_from_file.C,v $
34 * Revision 1.16 2015/08/04 14:41:29 j_novak
35 * Back to previous version for Eos_CompOSE. Enthalpy-consistent EoS can be accessed using Eos_consistent class (derived from Eos_CompOSE).
36 *
37 * Revision 1.15 2015/01/27 14:22:38 j_novak
38 * New methods in Eos_tabul to correct for EoS themro consistency (optional).
39 *
40 * Revision 1.14 2014/10/13 08:52:53 j_novak
41 * Lorene classes and functions now belong to the namespace Lorene.
42 *
43 * Revision 1.13 2014/06/30 16:13:18 j_novak
44 * New methods for reading directly from CompOSE files.
45 *
46 * Revision 1.12 2014/03/06 15:53:35 j_novak
47 * Eos_compstar is now Eos_compOSE. Eos_tabul uses strings and contains informations about authors.
48 *
49 * Revision 1.11 2012/10/26 14:09:33 e_gourgoulhon
50 * Added new class Eos_Fermi
51 *
52 * Revision 1.10 2011/06/16 10:49:18 j_novak
53 * New class Eos_mag for EOSs depending on density and magnetic field.
54 *
55 * Revision 1.9 2010/02/02 13:22:16 j_novak
56 * New class Eos_Compstar.
57 *
58 * Revision 1.8 2005/05/22 20:51:41 k_taniguchi
59 * Add a new Eos Eos_fit_AkmalPR.
60 *
61 * Revision 1.7 2004/09/26 18:53:08 k_taniguchi
62 * Introduction of new EOSs: Eos_fit_SLy4 and Eos_fit_FPS
63 *
64 * Revision 1.6 2004/05/07 08:06:45 k_taniguchi
65 * Add the case of Eos_multi_poly.C
66 *
67 * Revision 1.5 2003/12/08 15:47:03 m_bejger
68 * GlendNH3 EOS (Glendenning 1985, case 3) added
69 *
70 * Revision 1.4 2002/10/16 14:36:35 j_novak
71 * Reorganization of #include instructions of standard C++, in order to
72 * use experimental version 3 of gcc.
73 *
74 * Revision 1.3 2002/04/09 14:32:15 e_gourgoulhon
75 * 1/ Added extra parameters in EOS computational functions (argument par)
76 * 2/ New class MEos for multi-domain EOS
77 *
78 * Revision 1.2 2001/12/04 21:27:53 e_gourgoulhon
79 *
80 * All writing/reading to a binary file are now performed according to
81 * the big endian convention, whatever the system is big endian or
82 * small endian, thanks to the functions fwrite_be and fread_be
83 *
84 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
85 * LORENE
86 *
87 * Revision 2.6 2001/09/11 16:23:08 eric
88 * Ajout de Eos_AkmalPR, Eos_BBB2 et Eos_BalbN1H1.
89 *
90 * Revision 2.5 2000/11/23 22:34:10 eric
91 * Ajout de Eos_BPAL12.
92 *
93 * Revision 2.4 2000/11/23 14:46:16 eric
94 * Ajout de Eos_strange_cr.
95 *
96 * Revision 2.3 2000/11/22 19:30:55 eric
97 * Ajout des Eos_SLy4 et Eos_FPS
98 *
99 * Revision 2.2 2000/10/24 15:29:22 eric
100 * Ajout de l'EOS matiere etrange (Eos_strange).
101 *
102 * Revision 2.1 2000/02/14 14:33:41 eric
103 * Ajout du constructeur par lecture de fichier formate.
104 *
105 * Revision 2.0 2000/01/21 15:18:08 eric
106 * *** empty log message ***
107 *
108 *
109 * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_from_file.C,v 1.16 2015/08/04 14:41:29 j_novak Exp $
110 *
111 */
112
113// Headers C
114#include <cstdlib>
115
116// Header Lorene
117#include "headcpp.h"
118#include "eos.h"
119#include "eos_multi_poly.h"
120#include "eos_fitting.h"
121#include "utilitaires.h"
122
123 //--------------------------------------//
124 // Identification virtual functions //
125 //--------------------------------------//
126
127
128namespace Lorene {
129int Eos_poly::identify() const { return 1; }
130
131int Eos_poly_newt::identify() const { return 2; }
132
133int Eos_incomp::identify() const { return 3; }
134
135int Eos_incomp_newt::identify() const { return 4; }
136
137int Eos_strange::identify() const { return 5; }
138
139int Eos_strange_cr::identify() const { return 6; }
140
141int Eos_SLy4::identify() const { return 10; }
142
143int Eos_FPS::identify() const { return 11; }
144
145int Eos_BPAL12::identify() const { return 12; }
146
147int Eos_AkmalPR::identify() const { return 13; }
148
149int Eos_BBB2::identify() const { return 14; }
150
151int Eos_BalbN1H1::identify() const { return 15; }
152
153int Eos_GlendNH3::identify() const { return 16; }
154
155int Eos_CompOSE::identify() const { return 17; }
156
157int Eos_mag::identify() const { return 18; }
158
159int Eos_Fermi::identify() const { return 19; }
160
161int Eos_consistent::identify() const { return 20; }
162
163int MEos::identify() const { return 100; }
164
165int Eos_multi_poly::identify() const { return 110; }
166
167int Eos_fit_SLy4::identify() const { return 120; }
168
169int Eos_fit_FPS::identify() const { return 121; }
170
171int Eos_fit_AkmalPR::identify() const { return 122; }
172
173 //---------------------------------------------//
174 // EOS construction from a binary file //
175 //---------------------------------------------//
176
178
179 Eos* p_eos ;
180
181 // Type (class) of EOS :
182 int identificator ;
183 fread_be(&identificator, sizeof(int), 1, fich) ;
184
185 switch(identificator) {
186
187 case 1 : {
188 p_eos = new Eos_poly(fich) ;
189 break ;
190 }
191
192 case 2 : {
193 p_eos = new Eos_poly_newt(fich) ;
194 break ;
195 }
196
197 case 3 : {
198 p_eos = new Eos_incomp(fich) ;
199 break ;
200 }
201
202 case 4 : {
203 p_eos = new Eos_incomp_newt(fich) ;
204 break ;
205 }
206
207 case 5 : {
208 p_eos = new Eos_strange(fich) ;
209 break ;
210 }
211
212 case 6 : {
213 p_eos = new Eos_strange_cr(fich) ;
214 break ;
215 }
216
217 case 10 : {
218 p_eos = new Eos_SLy4(fich) ;
219 break ;
220 }
221
222 case 11 : {
223 p_eos = new Eos_FPS(fich) ;
224 break ;
225 }
226
227 case 12 : {
228 p_eos = new Eos_BPAL12(fich) ;
229 break ;
230 }
231
232 case 13 : {
233 p_eos = new Eos_AkmalPR(fich) ;
234 break ;
235 }
236
237 case 14 : {
238 p_eos = new Eos_BBB2(fich) ;
239 break ;
240 }
241
242 case 15 : {
243 p_eos = new Eos_BalbN1H1(fich) ;
244 break ;
245 }
246
247 case 16 : {
248 p_eos = new Eos_GlendNH3(fich) ;
249 break ;
250 }
251
252 case 17 : {
253 p_eos = new Eos_CompOSE(fich) ;
254 break ;
255 }
256
257 case 18 : {
258 p_eos = new Eos_mag(fich) ;
259 break ;
260 }
261
262 case 19 : {
263 p_eos = new Eos_Fermi(fich) ;
264 break ;
265 }
266
267 case 20 : {
268 p_eos = new Eos_consistent(fich) ;
269 break ;
270 }
271
272 case 100 : {
273 p_eos = new MEos(fich) ;
274 break ;
275 }
276
277 case 110 : {
278 p_eos = new Eos_multi_poly(fich) ;
279 break ;
280 }
281
282 case 120 : {
283 p_eos = new Eos_fit_SLy4(fich) ;
284 break ;
285 }
286
287 case 121 : {
288 p_eos = new Eos_fit_FPS(fich) ;
289 break ;
290 }
291
292 case 122 : {
293 p_eos = new Eos_fit_AkmalPR(fich) ;
294 break ;
295 }
296
297 default : {
298 cout << "Eos::eos_from_file : unknown type of EOS !" << endl ;
299 cout << " identificator = " << identificator << endl ;
300 abort() ;
301 break ;
302 }
303
304 }
305
306 return p_eos ;
307
308}
309
310 //----------------------------------------------//
311 // EOS construction from a formatted file //
312 //----------------------------------------------//
313
314Eos* Eos::eos_from_file(ifstream& fich) {
315
316 int identificator ;
317
318 // EOS identificator :
319 fich >> identificator ; fich.ignore(1000, '\n') ;
320
321 Eos* p_eos ;
322
323 switch(identificator) {
324
325 case 1 : {
326 p_eos = new Eos_poly(fich) ;
327 break ;
328 }
329
330 case 2 : {
331 p_eos = new Eos_poly_newt(fich) ;
332 break ;
333 }
334
335 case 3 : {
336 p_eos = new Eos_incomp(fich) ;
337 break ;
338 }
339
340 case 4 : {
341 p_eos = new Eos_incomp_newt(fich) ;
342 break ;
343 }
344
345 case 5 : {
346 p_eos = new Eos_strange(fich) ;
347 break ;
348 }
349
350 case 6 : {
351 p_eos = new Eos_strange_cr(fich) ;
352 break ;
353 }
354
355 case 10 : {
356 p_eos = new Eos_SLy4(fich) ;
357 break ;
358 }
359
360 case 11 : {
361 p_eos = new Eos_FPS(fich) ;
362 break ;
363 }
364
365 case 12 : {
366 p_eos = new Eos_BPAL12(fich) ;
367 break ;
368 }
369
370 case 13 : {
371 p_eos = new Eos_AkmalPR(fich) ;
372 break ;
373 }
374
375 case 14 : {
376 p_eos = new Eos_BBB2(fich) ;
377 break ;
378 }
379
380 case 15 : {
381 p_eos = new Eos_BalbN1H1(fich) ;
382 break ;
383 }
384
385 case 16 : {
386 p_eos = new Eos_GlendNH3(fich) ;
387 break ;
388 }
389
390 case 17 : {
391 int format ;
392 fich >> format ;
393 fich.ignore(1000, '\n') ;
394#ifndef NDEBUG
395 cout << "Reading tabulated EoS, with "
396 << ( (format == 0) ? "standard LORENE " : "original CompOSE ")
397 << "format." << endl ;
398#endif
399 if (format == 1) {
400 fich.ignore(1000, '\n') ;
401 string files_path ;
402 fich >> files_path ;
403 p_eos = new Eos_CompOSE(files_path ) ;
404 }
405 else
406 p_eos = new Eos_CompOSE(fich ) ;
407 break ;
408 }
409
410 case 18 : {
411 p_eos = new Eos_mag(fich) ;
412 break ;
413 }
414
415 case 19 : {
416 p_eos = new Eos_Fermi(fich) ;
417 break ;
418 }
419
420 case 20 : {
421 int format ;
422 fich >> format ;
423 fich.ignore(1000, '\n') ;
424#ifndef NDEBUG
425 cout << "Reading tabulated EoS, with "
426 << ( (format == 0) ? "standard LORENE " : "original CompOSE ")
427 << "format." << endl ;
428#endif
429 if (format == 1) {
430 fich.ignore(1000, '\n') ;
431 string files_path ;
432 fich >> files_path ;
433 p_eos = new Eos_consistent(files_path ) ;
434 }
435 else
436 p_eos = new Eos_consistent(fich ) ;
437 break ;
438 }
439
440 case 100 : {
441 p_eos = new MEos(fich) ;
442 break ;
443 }
444
445 case 110 : {
446 p_eos = new Eos_multi_poly(fich) ;
447 break ;
448 }
449
450 case 120 : {
451 p_eos = new Eos_fit_SLy4(fich) ;
452 break ;
453 }
454
455 case 121 : {
456 p_eos = new Eos_fit_FPS(fich) ;
457 break ;
458 }
459
460 case 122 : {
461 p_eos = new Eos_fit_AkmalPR(fich) ;
462 break ;
463 }
464
465 default : {
466 cout << "Eos::eos_from_file : unknown type of EOS !" << endl ;
467 cout << " identificator = " << identificator << endl ;
468 abort() ;
469 break ;
470 }
471
472 }
473
474 return p_eos ;
475
476}
477
478
479
480
481
482
483}
Equation of state AkmalPR (Akmal, Pandharipande & Ravenhall 1998).
Definition eos_tabul.h:607
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state BBB2 (Baldo, Bombaci & Burgio 1997).
Definition eos_tabul.h:690
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state BPAL12 (Bombaci et al 1995).
Definition eos_tabul.h:520
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state BalbN1H1 (Balberg 2000).
Definition eos_tabul.h:769
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state for the CompOSE database.
Definition eos_compose.h:77
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state FPS (Friedman-Pandharipande + Skyrme).
Definition eos_tabul.h:442
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Degenerate ideal Fermi gas.
Definition eos.h:2090
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state GlendNH3 (Glendenning 1985, case 3 ).
Definition eos_tabul.h:850
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state SLy4 (Douchin & Haensel 2001).
Definition eos_tabul.h:363
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state for the CompOSE database with a consistent computation of the log-enthalpy (derived...
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Fitted equation of state of AkmalPR.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Fitted equation of state of FPS.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Fitted equation of state of SLy4.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state of incompressible matter (Newtonian case).
Definition eos.h:1376
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state of incompressible matter (relativistic case).
Definition eos.h:1206
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Class for a magnetized (tabulated) equation of state.
Definition eos_mag.h:78
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Base class for a multiple polytropic equation of state.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Polytropic equation of state (Newtonian case).
Definition eos.h:1044
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Polytropic equation of state (relativistic case).
Definition eos.h:757
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Strange matter EOS (MIT Bag model) with crust.
Definition eos.h:1779
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Strange matter EOS (MIT Bag model).
Definition eos.h:1540
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
Equation of state base class.
Definition eos.h:190
static Eos * eos_from_file(FILE *)
Construction of an EOS from a binary file.
EOS with domain dependency.
Definition eos.h:2279
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
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
Lorene prototypes.
Definition app_hor.h:64