24#include <lal/LALConstants.h>
25#include <lal/LALgetopt.h>
26#include <lal/LALStdlib.h>
27#include <lal/LALSimNeutronStar.h>
31int output(
const char *fmt,
double c,
double m,
double r,
double k2);
38int main(
int argc,
char *argv[])
47 printf(
"Maximum Mass (solar) = %g\n",
55 double l = (2.0 / 3.0) * k / pow(
c, 5);
56 printf(
"Parameters for Neutron Star Mass (solar) = %g\n",
global_mass);
57 printf(
"- Central Pressure (Pa) = %g\n",
p);
58 printf(
"- Radius (km) = %g\n",
r / 1000.0);
59 printf(
"- Compactness (dimensionless) = %g\n",
c);
60 printf(
"- Love Number (dimensionless) = %g\n", k);
61 printf(
"- Tidal Parameter (dimensionless) = %g\n",
l);
86 {
"4parameterspectraldecomposition",
no_argument, 0,
'S'},
93 char args[] =
"hm:f:n:PG:p:r:Qq:1:2:3:Sw:x:y:z:";
96 int polytropeFlag = 0;
97 double Gamma = 0, reference_pressure_si = 0, reference_density_si = 0;
100 int piecewisePolytropeFlag = 0;
101 double logp1_si = 0, gamma1 = 0, gamma2 = 0, gamma3 = 0;
104 int spectralFlag = 0;
105 double SDgamma0 = 0, SDgamma1 = 0, SDgamma2 = 0, SDgamma3 = 0;
108 int option_index = 0;
117 if (long_options[option_index].
flag)
120 fprintf(stderr,
"error parsing option %s with argument %s\n",
153 piecewisePolytropeFlag = 1;
186 fprintf(stderr,
"unknown error while parsing options\n");
192 if (polytropeFlag == 1)
195 reference_density_si);
198 if (piecewisePolytropeFlag == 1)
201 gamma1, gamma2, gamma3);
204 if (spectralFlag == 1)
207 SDgamma1, SDgamma2, SDgamma3);
210 fprintf(stderr,
"extraneous command line arguments:\n");
217 fprintf(stderr,
"error: no equation of state selected\n");
230 "\t-h, --help \tprint this message and exit\n");
232 "\t-m MASS, --mass=MASS \tparameters of a neutron star of mass MASS (solar)\n");
234 "\t-f FILE, --eos-file=FILE \tuse EOS with from data filename FILE\n");
236 "\t-n NAME, --eos-name=NAME \tuse EOS with name NAME\n");
239 "\t-P, --polytrope \tuse single polytrope\n");
240 fprintf(stderr,
"\t-G GAMMA, --gamma=GAMMA \tadiabatic index\n");
242 "\t-p PRESSURE, --pressure=PRESSURE \tpressure at reference density\n");
244 "\t-r DENSITY, --density=DENSITY \treference density\n");
247 "\t-Q, --piecewisepolytrope \tuse 4-parameter piecewise polytrope (PRD 79, 124032 (2009))\n");
249 "\t-q log(p_1), --logp1=log(p_1) \tlog of pressure at rho_1=10^17.7 kg/m^3\n");
251 "\t-1 Gamma_1, --gamma1=Gamma_1 \tadiabatic index <10^17.7 kg/m^3\n");
253 "\t-2 Gamma_2, --gamma2=Gamma_2 \tadiabatic index 10^17.7--10^18 kg/m^3\n");
255 "\t-3 Gamma_3, --gamma3=Gamma_3 \tadiabatic index >10^18.0 kg/m^3\n");
258 "\t-S --4paramspectraldecomp \tuse 4-parameter spectral decomposition (PRD 82, 103011 (2010))\n");
260 "\t-w SDgamma0, --SDgamma0=SDgamma0 \tadiabatic index spectral decomposition coefficient 1 0.2--2.0\n");
262 "\t-x SDgamma1, --SDgamma1=SDgamma1 \tadiabatic index spectral decomposition coefficient 2 -1.6--1.7\n");
264 "\t-y SDgamma2, --SDgamma2=SDgamma2 \tadiabatic index spectral decomposition coefficient 3 -0.8--0.6\n");
266 "\t-z SDgamma3, --SDgamma3=SDgamma3 \tadiabatic index spectral decomposition coefficient 4 -0.2--0.2\n");
267 fprintf(stderr,
"recognized tabulated equations of state:");
void LALCheckMemoryLeaks(void)
struct tagLALSimNeutronStarFamily LALSimNeutronStarFamily
Incomplete type for a neutron star family having a particular EOS.
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
LALSimNeutronStarEOS * XLALSimNeutronStarEOSPolytrope(double Gamma, double reference_pressure_si, double reference_density_si)
Creates a polytrope Equation of State defined by p = K rho^Gamma.
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.
LALSimNeutronStarEOS * XLALSimNeutronStarEOS4ParameterSpectralDecomposition(double SDgamma0, double SDgamma1, double SDgamma2, double SDgamma3)
Reads 4 spectral decomposition eos parameters to make an eos.
LALSimNeutronStarEOS * XLALSimNeutronStarEOSFromFile(const char *fname)
Reads a data file containing a tabulated equation of state.
LALSimNeutronStarEOS * XLALSimNeutronStarEOS4ParameterPiecewisePolytrope(double logp1_si, double gamma1, double gamma2, double gamma3)
Creates a 4-parameter piecewise-polytrope Equation of State.
char * XLALSimNeutronStarEOSName(LALSimNeutronStarEOS *eos)
The name of the equation of state.
void XLALDestroySimNeutronStarEOS(LALSimNeutronStarEOS *eos)
Frees the memory associated with a pointer to an EOS structure.
LALSimNeutronStarFamily * XLALCreateSimNeutronStarFamily(LALSimNeutronStarEOS *eos)
Creates a neutron star family structure for a given equation of state.
double XLALSimNeutronStarLoveNumberK2(double m, LALSimNeutronStarFamily *fam)
Returns the tidal Love number k2 of a neutron star of mass m.
void XLALDestroySimNeutronStarFamily(LALSimNeutronStarFamily *fam)
Frees the memory associated with a pointer to a neutron star family.
double XLALSimNeutronStarRadius(double m, LALSimNeutronStarFamily *fam)
Returns the radius of a neutron star of mass m.
double XLALSimNeutronStarCentralPressure(double m, LALSimNeutronStarFamily *fam)
Returns the central pressure of a neutron star of mass m.
double XLALSimNeutronStarMaximumMass(LALSimNeutronStarFamily *fam)
Returns the maximum mass of a neutron star family.
void XLALAbortErrorHandler(const char *func, const char *file, int line, int errnum)
XLALErrorHandlerType * XLALSetErrorHandler(XLALErrorHandlerType *newHandler)
int main(int argc, char *argv[])
int usage(const char *program)
int output(const char *fmt, double c, double m, double r, double k2)
int parseargs(int argc, char *argv[])
LALSimNeutronStarEOS * global_eos