LALSimulation  5.4.0.1-fe68b98
LALSimNeutronStarEOS.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 J. Creighton, B. Lackey
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with with program; see the file COPYING. If not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  * MA 02110-1301 USA
18  */
19 /**
20  * @author Jolien Creighton, Benjamin Lackey
21  * @addtogroup LALSimNeutronStarEOS_c
22  * @brief Provides routines for handling neutron star equations of state.
23  * @{
24  */
25 
26 #include <ctype.h>
27 #include <math.h>
28 #include <stdio.h>
29 #include <string.h>
30 
31 #include <lal/LALStdlib.h>
32 #include <lal/LALString.h>
33 #include <lal/FileIO.h>
34 #include <lal/LALSimNeutronStar.h>
35 #include <lal/LALSimReadData.h>
36 
37 /** @cond */
38 
39 /* Enumeration for type of equation of state data storage. */
40 enum {
41  LALSIM_NEUTRON_STAR_EOS_DATA_TYPE_TABULAR,
42  LALSIM_NEUTRON_STAR_EOS_DATA_TYPE_PIECEWISE_POLYTROPE,
43  LALSIM_NEUTRON_STAR_EOS_DATA_TYPE_NUMBER
44 };
45 
46 /* Incomplete types for the equation of state data storage. */
47 typedef struct tagLALSimNeutronStarEOSDataTabular
48  LALSimNeutronStarEOSDataTabular;
49 typedef struct tagLALSimNeutronStarEOSDataPolytrope
50  LALSimNeutronStarEOSDataPolytrope;
51 typedef struct tagLALSimNeutronStarEOSDataPiecewisePolytrope
52  LALSimNeutronStarEOSDataPiecewisePolytrope;
53 
54 typedef union tagLALSimNeutronStarEOSData {
55  LALSimNeutronStarEOSDataTabular *tabular;
56  LALSimNeutronStarEOSDataPolytrope *polytrope;
57  LALSimNeutronStarEOSDataPiecewisePolytrope *piecewisePolytrope;
58 } LALSimNeutronStarEOSData;
59 
60 /* Contents of the equation of state structure. */
61 struct tagLALSimNeutronStarEOS {
62  char name[LALNameLength];
63  double pmax;
64  double hmax;
65  double hMinAcausal; /* Minimum pseudo-enthalpy at which EOS becomes acausal (speed of sound > 1) */
66  double (*e_of_p) (double p, LALSimNeutronStarEOS * myself);
67  double (*h_of_p) (double p, LALSimNeutronStarEOS * myself);
68  double (*p_of_h) (double h, LALSimNeutronStarEOS * myself);
69  double (*e_of_h) (double h, LALSimNeutronStarEOS * myself);
70  double (*rho_of_h) (double h, LALSimNeutronStarEOS * myself);
71  double (*p_of_e) (double e, LALSimNeutronStarEOS * myself);
72  double (*p_of_rho) (double rho, LALSimNeutronStarEOS * myself);
73  double (*dedp_of_p) (double p, LALSimNeutronStarEOS * myself);
74  double (*v_of_h) (double h, LALSimNeutronStarEOS * myself);
75  void (*free) (LALSimNeutronStarEOS * myself);
76  int datatype;
77  LALSimNeutronStarEOSData data;
78 };
79 
80 /** @endcond */
81 
82 /** Recognised equations of state names */
83 const char * const lalSimNeutronStarEOSNames[111] = {
84  "ALF1", "ALF2", "ALF3", "ALF4",
85  "AP1", "AP2", "AP3", "AP4", "APR4_EPP",
86  "BBB2", "BGN1H1", "BPAL12",
87  "BSK19", "BSK20", "BSK21",
88  "ENG", "FPS", "GNH3",
89  "GS1", "GS2",
90  "H1", "H2", "H3", "H4", "H5", "H6", "H7",
91  "MPA1", "MS1B", "MS1B_PP", "MS1_PP", "MS1", "MS2",
92  "PAL6", "PCL2", "PS",
93  "QMC700",
94  "SLY4", "SLY",
95  "SQM1", "SQM2", "SQM3",
96  "WFF1", "WFF2", "WFF3",
97  /* From here, EOSs are coming from CompOSE via Ian */
98  "APR", "BHF_BBB2",
99  "KDE0V", "KDE0V1", "RS", "SK255", "SK272",
100  "SKA", "SKB", "SKI2", "SKI3", "SKI4", "SKI5", "SKI6",
101  "SKMP", "SKOP",
102  "SLY2", "SLY230A", "SLY9",
103  /* This EOS was added by request from
104  * http://user.numazu-ct.ac.jp/~sumi/eos/HQC18_submit
105  */
106  "HQC18",
107  /* These EOS files are part of the new EOS framework via Micaela Oertel's group and the LUTH group */
108  "GMSR_BSK14_BSK24", "GMSR_DHSL59_BSK24", "GMSR_DHSL69_BSK24", "GMSR_F0_BSK24", "GMSR_H1_BSK24", "GMSR_H2_BSK24",
109  "GMSR_H3_BSK24", "GMSR_H4_BSK24", "GMSR_H5_BSK24", "GMSR_LN55_BSK24", "GMSR_SLY5_BSK24", "GPPVA_DD2_BSK24",
110  "GPPVA_DDME2_BSK24", "GPPVA_FSU2_BSK24", "GPPVA_FSU2H_BSK24", "GPPVA_NL3WRL55_BSK24",
111  "KDE0V_BSK24", "KDE0V1_BSK24", "PCP_BSK24_BSK24", "RG_SLY4_BSK24", "RS_BSK24",
112  "SK255_BSK24", "SKA_BSK24", "SKB_BSK24", "SKI2_BSK24", "SKI3_BSK24", "SKI4_BSK24", "SKI6_BSK24",
113  "SKOP_BSK24", "SLY2_BSK24", "SLY9_BSK24", "SLY230A_BSK24",
114  "XMLSLZ_DDLZ1_BSK24", "XMLSLZ_DDME2_BSK24", "XMLSLZ_DDMEX_BSK24", "XMLSLZ_GM1_BSK24", "XMLSLZ_MTVTC_BSK24",
115  "XMLSLZ_NL3_BSK24", "XMLSLZ_PKDD_BSK24", "XMLSLZ_TM1_BSK24", "XMLSLZ_TW99_BSK24", "ABHT_QMC_RMF1_META",
116  "ABHT_QMC_RMF2_META", "ABHT_QMC_RMF3_META", "ABHT_QMC_RMF4_META", "BL_CHIRAL_META"
117  };
118 
119 /**
120  * @name Destruction routine
121  * @{
122  */
123 
124 /**
125  * @brief Frees the memory associated with a pointer to an EOS structure.
126  * @param eos Pointer to the EOS structure to be freed.
127  */
129 {
130  eos->free(eos);
131  return;
132 }
133 
134 /** @} */
135 
136 /* Tabular Equation of State Code. */
138 
139 /* Piecewise-Polytrope Equation of State Code */
141 
142 /* Spectral Decomposition Equation of State Code */
144 
145 /* Dynamic Piecewise-Polytrope Equation of State Code */
147 
148 /**
149  * @name Routines to access equation of state variables
150  * @{
151  */
152 
153 /**
154  * @brief The name of the equation of state.
155  * @param[in] eos Pointer to the EOS structure.
156  * @return Pointer to a string containing the name of the equation of state.
157  * @warning The pointer returned might be shallow and might be left
158  * dangling if the @a eos structure is freed.
159  */
161 {
162  return eos->name;
163 }
164 
165 /**
166  * @brief Returns the maximum pressure of the EOS in geometrized units m^-2.
167  * @param eos Pointer to the EOS structure.
168  * @return The maximum pressure of the EOS in geometrized units m^-2.
169  */
171  eos)
172 {
173  return eos->pmax;
174 }
175 
176 /**
177  * @brief Returns the maximum pressure of the EOS in Pa.
178  * @param eos Pointer to the EOS structure.
179  * @return The maximum pressure of the EOS in Pa.
180  */
182 {
183  double pmax;
185  pmax /= LAL_G_C4_SI;
186  return pmax;
187 }
188 
189 /**
190  * @brief Returns the maximum pseudo enthalpy of the EOS (dimensionless).
191  * @param eos Pointer to the EOS structure.
192  * @return The maximum pseudo enthalpy of the EOS (dimensionless).
193  */
195 {
196  return eos->hmax;
197 }
198 
199 /**
200  * @brief Returns the minimum pseudo-enthalpy at which EOS becomes acausal
201  * (speed of sound > speed of light) (dimensionless).
202  * @param eos Pointer to the EOS structure.
203  * @return The minimum pseudo-enthalpy at which EOS becomes acausal
204  * (speed of sound > speed of light).
205  */
207  eos)
208 {
209  return eos->hMinAcausal;
210 }
211 
212 /* FUNCTIONS WITH GEOMETERIZED UNITS */
213 
214 /**
215  * @brief Returns the energy density in geometerized units (m^-2) at a given
216  * pressure in geometerized units (m^-2).
217  * @param p Pressure in geometerized units (m^-2)
218  * @param eos Pointer to the EOS structure.
219  * @return The energy density in geometerized units (m^-2).
220  */
222  LALSimNeutronStarEOS * eos)
223 {
224  double e;
225  e = eos->e_of_p(p, eos);
226  return e;
227 }
228 
229 /**
230  * @brief Returns the dimensionless pseudo-enthalpy at a given pressure in
231  * geometerized units (m^-2).
232  * @param p Pressure in geometerized units (m^-2)
233  * @param eos Pointer to the EOS structure.
234  * @return The pseudo-enthalpy (dimensionless).
235  */
237  LALSimNeutronStarEOS * eos)
238 {
239  double h;
240  h = eos->h_of_p(p, eos);
241  return h;
242 }
243 
244 /**
245  * @brief Returns the pressure in geometerized units (m^-2) at a given value of
246  * the dimensionless pseudo-enthalpy.
247  * @param h The value of the dimensionless pseudo-enthalpy.
248  * @param eos Pointer to the EOS structure.
249  * @return The pressure in geometerized units (m^-2).
250  */
252  LALSimNeutronStarEOS * eos)
253 {
254  double p;
255  p = eos->p_of_h(h, eos);
256  return p;
257 }
258 
259 /**
260  * @brief Returns the energy density in geometerized units (m^-2) at a given
261  * value of the dimensionless pseudo-enthalpy.
262  * @param h The value of the dimensionless pseudo-enthalpy.
263  * @param eos Pointer to the EOS structure.
264  * @return The energy density in geometerized units (m^-2).
265  */
267  h, LALSimNeutronStarEOS * eos)
268 {
269  double e;
270  e = eos->e_of_h(h, eos);
271  return e;
272 }
273 
274 /**
275  * @brief Returns the rest mass density in geometerized units (m^-2) at a given
276  * value of the dimensionless pseudo-enthalpy.
277  * @param h The value of the dimensionless pseudo-enthalpy.
278  * @param eos Pointer to the EOS structure.
279  * @return The rest mass density in geometerized units (m^-2).
280  */
282  h, LALSimNeutronStarEOS * eos)
283 {
284  double rho;
285  rho = eos->rho_of_h(h, eos);
286  return rho;
287 }
288 
289 /**
290  * @brief Returns the gradient of the energy density with respect to the
291  * pressure (dimensionless) at a given value of the pressure in geometerized
292  * units (m^-2).
293  * @param p Pressure in geometerized units (m^-2).
294  * @param eos Pointer to the EOS structure.
295  * @return The gradient of the energy density with respect to the pressure
296  * (dimensionless).
297  */
299  LALSimNeutronStarEOS * eos)
300 {
301  double dedp;
302  dedp = eos->dedp_of_p(p, eos);
303  return dedp;
304 }
305 
306 /**
307  * @brief Returns the speed of sound in geometerized units (dimensionless)
308  * at a given value of the pseudo-enthalpy (dimensionless).
309  * @param h The value of the dimensionless pseudo-enthalpy.
310  * @param eos Pointer to the EOS structure.
311  * @return The speed of sound in geometerized units (dimensionless).
312  */
314  LALSimNeutronStarEOS * eos)
315 {
316  double v;
317  v = eos->v_of_h(h, eos);
318  return v;
319 }
320 
321 /* FUNCTIONS WITH SI UNITS */
322 
323 /**
324  * @brief Returns the energy density (J m^-3) at a given pressure (Pa).
325  * @param p Pressure (Pa).
326  * @param eos Pointer to the EOS structure.
327  * @return The energy density (J m^3).
328  */
330  LALSimNeutronStarEOS * eos)
331 {
332  double e;
333  p *= LAL_G_C4_SI;
335  e /= LAL_G_C4_SI;
336  return e;
337 }
338 
339 /**
340  * @brief Returns the dimensionless pseudo-enthalpy at a given pressure (Pa).
341  * @param p Pressure (Pa).
342  * @param eos Pointer to the EOS structure.
343  * @return The pseudo-enthalpy (dimensionless).
344  */
346  LALSimNeutronStarEOS * eos)
347 {
348  double h;
349  p *= LAL_G_C4_SI;
351  return h;
352 }
353 
354 /**
355  * @brief Returns the pressure (Pa) at a given value of the dimensionless
356  * pseudo-enthalpy.
357  * @param h The value of the dimensionless pseudo-enthalpy.
358  * @param eos Pointer to the EOS structure.
359  * @return The pressure (Pa).
360  */
362  LALSimNeutronStarEOS * eos)
363 {
364  double p;
366  p /= LAL_G_C4_SI;
367  return p;
368 }
369 
370 /**
371  * @brief Returns the energy density (J m^-3) at a given value of the
372  * dimensionless pseudo-enthalpy.
373  * @param h The value of the dimensionless pseudo-enthalpy.
374  * @param eos Pointer to the EOS structure.
375  * @return The energy density (J m^-3).
376  */
378  LALSimNeutronStarEOS * eos)
379 {
380  double e;
382  eos);
383  e /= LAL_G_C4_SI;
384  return e;
385 }
386 
387 /**
388  * @brief Returns the rest mass density (kg m^-3) at a given value of the
389  * dimensionless pseudo-enthalpy.
390  * @param h The value of the dimensionless pseudo-enthalpy.
391  * @param eos Pointer to the EOS structure.
392  * @return The rest mass density (kg m^-3), which is the number density of
393  * baryons times the baryon rest mass.
394  */
396  LALSimNeutronStarEOS * eos)
397 {
398  double rho;
399  rho =
401  eos);
402  rho /= LAL_G_C2_SI;
403  return rho;
404 }
405 
406 /**
407  * @brief Returns the gradient of the energy density with respect to the
408  * pressure (dimensionless) at a given value of the pressure (Pa).
409  * @param p Pressure (Pa).
410  * @param eos Pointer to the EOS structure.
411  * @return The gradient of the energy density with respect to the pressure
412  * (dimensionless).
413  */
415  LALSimNeutronStarEOS * eos)
416 {
417  double dedp;
418  p *= LAL_G_C4_SI;
419  dedp =
421  return dedp;
422 }
423 
424 /**
425  * @brief Returns the speed of sound (m s^-1) at a given value of the
426  * pseudo-enthalpy (dimensionless).
427  * @param h The value of the dimensionless pseudo-enthalpy.
428  * @param eos Pointer to the EOS structure.
429  * @return The speed of sound (m s^-1).
430  */
432 {
433  double v;
435  v *= LAL_C_SI;
436  return v;
437 }
438 
439 /**
440  * @brief Returns the pressure in Pa at a given
441  * energy density in J/m^3.
442  * @param e energy density in J/m^3
443  * @param eos Pointer to the EOS structure.
444  * @return The pressure in Pa.
445  */
447  LALSimNeutronStarEOS * eos)
448 {
449  double p;
450  e *= LAL_G_C4_SI;
451  p = eos->p_of_e(e, eos);
452  p /= LAL_G_C4_SI;
453  return p;
454 }
455 
456 /**
457  * @brief Returns the pressure in Pa at a given
458  * rest-mass density in kg/m^3.
459  * @param rho rest-mass density in kg/m^3
460  * @param eos Pointer to the EOS structure.
461  * @return The pressure in Pa.
462  */
464  LALSimNeutronStarEOS * eos)
465 {
466  double p;
467  rho *= LAL_G_C2_SI;
468  p = eos->p_of_rho(rho, eos);
469  p /= LAL_G_C4_SI;
470  return p;
471 }
472 
473 
474 /** @} */
475 /** @} */
const char * name
#define LAL_G_C2_SI
Factor to convert density in kg/m^3 to geometerized units of m^-2.
struct tagLALSimNeutronStarEOS LALSimNeutronStarEOS
Incomplete type for the neutron star Equation of State (EOS).
#define LAL_G_C4_SI
Factor to convert pressure in Pa to geometerized units of m^-2.
double e
Definition: bh_ringdown.c:117
sigmaKerr data[0]
#define LAL_C_SI
LALNameLength
double XLALSimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(double h, LALSimNeutronStarEOS *eos)
Returns the rest mass density (kg m^-3) at a given value of the dimensionless pseudo-enthalpy.
double XLALSimNeutronStarEOSMinAcausalPseudoEnthalpy(LALSimNeutronStarEOS *eos)
Returns the minimum pseudo-enthalpy at which EOS becomes acausal (speed of sound > speed of light) (d...
double XLALSimNeutronStarEOSEnergyDensityDerivOfPressure(double p, LALSimNeutronStarEOS *eos)
Returns the gradient of the energy density with respect to the pressure (dimensionless) at a given va...
double XLALSimNeutronStarEOSPressureOfRestMassDensity(double rho, LALSimNeutronStarEOS *eos)
Returns the pressure in Pa at a given rest-mass density in kg/m^3.
double XLALSimNeutronStarEOSEnergyDensityOfPressureGeometerized(double p, LALSimNeutronStarEOS *eos)
Returns the energy density in geometerized units (m^-2) at a given pressure in geometerized units (m^...
const char *const lalSimNeutronStarEOSNames[111]
Recognised equations of state names.
double XLALSimNeutronStarEOSPressureOfPseudoEnthalpy(double h, LALSimNeutronStarEOS *eos)
Returns the pressure (Pa) at a given value of the dimensionless pseudo-enthalpy.
double XLALSimNeutronStarEOSEnergyDensityDerivOfPressureGeometerized(double p, LALSimNeutronStarEOS *eos)
Returns the gradient of the energy density with respect to the pressure (dimensionless) at a given va...
double XLALSimNeutronStarEOSPressureOfEnergyDensity(double e, LALSimNeutronStarEOS *eos)
Returns the pressure in Pa at a given energy density in J/m^3.
double XLALSimNeutronStarEOSEnergyDensityOfPseudoEnthalpyGeometerized(double h, LALSimNeutronStarEOS *eos)
Returns the energy density in geometerized units (m^-2) at a given value of the dimensionless pseudo-...
double XLALSimNeutronStarEOSSpeedOfSound(double h, LALSimNeutronStarEOS *eos)
Returns the speed of sound (m s^-1) at a given value of the pseudo-enthalpy (dimensionless).
double XLALSimNeutronStarEOSRestMassDensityOfPseudoEnthalpyGeometerized(double h, LALSimNeutronStarEOS *eos)
Returns the rest mass density in geometerized units (m^-2) at a given value of the dimensionless pseu...
double XLALSimNeutronStarEOSPseudoEnthalpyOfPressure(double p, LALSimNeutronStarEOS *eos)
Returns the dimensionless pseudo-enthalpy at a given pressure (Pa).
double XLALSimNeutronStarEOSSpeedOfSoundGeometerized(double h, LALSimNeutronStarEOS *eos)
Returns the speed of sound in geometerized units (dimensionless) at a given value of the pseudo-entha...
double XLALSimNeutronStarEOSMaxPressure(LALSimNeutronStarEOS *eos)
Returns the maximum pressure of the EOS in Pa.
char * XLALSimNeutronStarEOSName(LALSimNeutronStarEOS *eos)
The name of the equation of state.
double XLALSimNeutronStarEOSPressureOfPseudoEnthalpyGeometerized(double h, LALSimNeutronStarEOS *eos)
Returns the pressure in geometerized units (m^-2) at a given value of the dimensionless pseudo-enthal...
double XLALSimNeutronStarEOSEnergyDensityOfPressure(double p, LALSimNeutronStarEOS *eos)
Returns the energy density (J m^-3) at a given pressure (Pa).
double XLALSimNeutronStarEOSMaxPseudoEnthalpy(LALSimNeutronStarEOS *eos)
Returns the maximum pseudo enthalpy of the EOS (dimensionless).
double XLALSimNeutronStarEOSEnergyDensityOfPseudoEnthalpy(double h, LALSimNeutronStarEOS *eos)
Returns the energy density (J m^-3) at a given value of the dimensionless pseudo-enthalpy.
double XLALSimNeutronStarEOSMaxPressureGeometerized(LALSimNeutronStarEOS *eos)
Returns the maximum pressure of the EOS in geometrized units m^-2.
void XLALDestroySimNeutronStarEOS(LALSimNeutronStarEOS *eos)
Frees the memory associated with a pointer to an EOS structure.
double XLALSimNeutronStarEOSPseudoEnthalpyOfPressureGeometerized(double p, LALSimNeutronStarEOS *eos)
Returns the dimensionless pseudo-enthalpy at a given pressure in geometerized units (m^-2).
list p