23#include <lal/LALConstants.h>
24#include <lal/LALgetopt.h>
25#include <lal/LALStdlib.h>
26#include <lal/LALSimNeutronStar.h>
30int output(
const char *fmt,
double h,
double p,
double epsilon,
double rho,
31 double dedp,
double vsound);
45#define CENTIMETER_SI 0.01
46#define DYNE_PER_CENTIMETER_SQUARED_SI 0.1
47#define GRAM_PER_CENTIMETER_CUBED_SI 1000.0
49int main(
int argc,
char *argv[])
110int output(
const char *fmt,
double h,
double p,
double epsilon,
double rho,
111 double dedp,
double vsound)
114 for (
i = 0; fmt[
i]; ++
i) {
117 switch (fmt[
i + 1]) {
128 fprintf(stdout,
"%.18e", epsilon);
134 fprintf(stdout,
"%.18e", dedp);
137 fprintf(stdout,
"%.18e", vsound);
141 "unrecognized conversion %%%c in output format\n",
149 switch (fmt[
i + 1]) {
176 "impossible escaped NUL character in format\n");
179 fputc(fmt[
i + 1], stdout);
185 fputc(fmt[
i], stdout);
211 {
"4parameterspectraldecomposition",
no_argument, 0,
'S'},
218 char args[] =
"hcgf:n:F:N:PG:p:r:Qq:1:2:3:Sw:x:y:z:";
221 int polytropeFlag = 0;
222 double Gamma = 0, reference_pressure_si = 0, reference_density_si = 0;
225 int piecewisePolytropeFlag = 0;
226 double logp1_si = 0, gamma1 = 0, gamma2 = 0, gamma3 = 0;
229 int spectralFlag = 0;
230 double SDgamma0 = 0, SDgamma1 = 0, SDgamma2 = 0, SDgamma3 = 0;
233 int option_index = 0;
242 if (long_options[option_index].
flag)
245 fprintf(stderr,
"error parsing option %s with argument %s\n",
270 fprintf(stderr,
"invalid number of points\n");
291 piecewisePolytropeFlag = 1;
324 fprintf(stderr,
"unknown error while parsing options\n");
330 if (polytropeFlag == 1)
333 reference_density_si);
336 if (piecewisePolytropeFlag == 1)
339 gamma1, gamma2, gamma3);
342 if (spectralFlag == 1)
345 SDgamma1, SDgamma2, SDgamma3);
348 fprintf(stderr,
"extraneous command line arguments:\n");
355 fprintf(stderr,
"error: no equation of state selected\n");
368 "\t-h, --help \tprint this message and exit\n");
370 "\t-f FILE, --eos-file=FILE \tuse EOS with from data filename FILE\n");
372 "\t-n NAME, --eos-name=NAME \tuse EOS with name NAME\n");
375 "\t-P, --polytrope \tuse single polytrope\n");
376 fprintf(stderr,
"\t-G GAMMA, --gamma=GAMMA \tadiabatic index\n");
378 "\t-p PRESSURE, --pressure=PRESSURE \tpressure at reference density\n");
380 "\t-r DENSITY, --density=DENSITY \treference density\n");
383 "\t-Q, --piecewisepolytrope \tuse 4-parameter piecewise polytrope (PRD 79, 124032 (2009))\n");
385 "\t-q log(p_1), --logp1=log(p_1) \tlog of pressure at rho_1=10^17.7 kg/m^3\n");
387 "\t-1 Gamma_1, --gamma1=Gamma_1 \tadiabatic index <10^17.7 kg/m^3\n");
389 "\t-2 Gamma_2, --gamma2=Gamma_2 \tadiabatic index 10^17.7--10^18 kg/m^3\n");
391 "\t-3 Gamma_3, --gamma3=Gamma_3 \tadiabatic index >10^18.0 kg/m^3\n");
394 "\t-S --4paramspectraldecomp \tuse 4-parameter spectral decomposition (PRD 82, 103011 (2010))\n");
396 "\t-w SDgamma0, --SDgamma0=SDgamma0 \tadiabatic index spectral decomposition coefficient 1 (4-coeff) 0.2--2.0\n");
398 "\t-x SDgamma1, --SDgamma1=SDgamma1 \tadiabatic index spectral decomposition coefficient 2 (4-coeff) -1.6--1.7\n");
400 "\t-y SDgamma2, --SDgamma2=SDgamma2 \tadiabatic index spectral decomposition coefficient 3 (4-coeff) -0.8--0.6\n");
402 "\t-z SDgamma3, --SDgamma3=SDgamma3 \tadiabatic index spectral decomposition coefficient 4 (4-coeff) -0.2--0.2\n");
404 fprintf(stderr,
"\t-c, --cgs \tuse CGS units\n");
406 "\t-g, --geom \tuse geometerized units of length (G=c=1)\n");
408 "\t-N NPTS, --npts=NPTS \toutput NPTS points [%ld]\n",
411 "\t-F FORMAT, --format=FORMAT \toutput format FORMAT [\"%s\"]\n",
413 fprintf(stderr,
"format string conversions:\n");
414 fprintf(stderr,
"\t%%h\t is replaced by the pseudo-enthalpy\n");
415 fprintf(stderr,
"\t%%p\t is replaced by the pressure\n");
416 fprintf(stderr,
"\t%%e\t is replaced by the energy density\n");
417 fprintf(stderr,
"\t%%r\t is replaced by the rest-mass density\n");
418 fprintf(stderr,
"\t%%v\t is replaced by the speed of sound\n");
419 fprintf(stderr,
"recognized tabulated equations of state:");
void LALCheckMemoryLeaks(void)
struct tagLALSimNeutronStarEOS LALSimNeutronStarEOS
Incomplete type for the neutron star Equation of State (EOS).
int LALgetopt_long_only(int argc, char *const *argv, const char *options, const struct LALoption *long_options, int *opt_index)
#define required_argument
double XLALSimNeutronStarEOSRestMassDensityOfPseudoEnthalpy(double h, LALSimNeutronStarEOS *eos)
Returns the rest mass density (kg m^-3) at a given value of the dimensionless pseudo-enthalpy.
LALSimNeutronStarEOS * XLALSimNeutronStarEOSPolytrope(double Gamma, double reference_pressure_si, double reference_density_si)
Creates a polytrope Equation of State defined by p = K rho^Gamma.
double XLALSimNeutronStarEOSEnergyDensityDerivOfPressure(double p, LALSimNeutronStarEOS *eos)
Returns the gradient of the energy density with respect to the pressure (dimensionless) at a given va...
LALSimNeutronStarEOS * XLALSimNeutronStarEOSByName(const char *name)
Creates an equation of state structure from tabulated equation of state data of a known name.
const char *const lalSimNeutronStarEOSNames[111]
Recognised names of equations of state.
double XLALSimNeutronStarEOSPressureOfPseudoEnthalpy(double h, LALSimNeutronStarEOS *eos)
Returns the pressure (Pa) at a given value of the dimensionless pseudo-enthalpy.
LALSimNeutronStarEOS * XLALSimNeutronStarEOS4ParameterSpectralDecomposition(double SDgamma0, double SDgamma1, double SDgamma2, double SDgamma3)
Reads 4 spectral decomposition eos parameters to make an eos.
double XLALSimNeutronStarEOSEnergyDensityDerivOfPressureGeometerized(double p, LALSimNeutronStarEOS *eos)
Returns the gradient of the energy density with respect to the pressure (dimensionless) at a given va...
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...
LALSimNeutronStarEOS * XLALSimNeutronStarEOSFromFile(const char *fname)
Reads a data file containing a tabulated equation of state.
double XLALSimNeutronStarEOSSpeedOfSoundGeometerized(double h, LALSimNeutronStarEOS *eos)
Returns the speed of sound in geometerized units (dimensionless) at a given value of the pseudo-entha...
LALSimNeutronStarEOS * XLALSimNeutronStarEOS4ParameterPiecewisePolytrope(double logp1_si, double gamma1, double gamma2, double gamma3)
Creates a 4-parameter piecewise-polytrope 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 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.
void XLALDestroySimNeutronStarEOS(LALSimNeutronStarEOS *eos)
Frees the memory associated with a pointer to an EOS structure.
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
int main(int argc, char *argv[])
#define GRAM_PER_CENTIMETER_CUBED_SI
int usage(const char *program)
const char *const default_fmt
int parseargs(int argc, char *argv[])
#define DYNE_PER_CENTIMETER_SQUARED_SI
int output(const char *fmt, double h, double p, double epsilon, double rho, double dedp, double vsound)
LALSimNeutronStarEOS * global_eos