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 w,
double z,
double k2);
49int main(
int argc,
char *argv[])
51 double logpmin = 75.5;
76 double pc = exp(logpmin + (0.5 +
i) * dlogp);
77 double c,
m,
r,
k2, I1, I2, I3, J1, J2, J3,
w, z;
100 XLALSimNeutronStarVirialODEIntegrate(&
r, &
m, &I1, &I2, &I3, &J1, &J2, &J3, &
k2,
pc,
global_eos);
104 XLALSimNeutronStarVirialODEIntegrateWithTolerance(&
r, &
m, &I1, &I2, &I3, &J1, &J2, &J3, &
k2,
pc,
global_eos,
global_epsrel);
110 w = fabs(I1/(I2 + I3) - 1.0);
111 z = fabs(J1/(J2 + J3) - 1.0);
122int output(
const char *fmt,
double c,
double m,
double r,
double w,
double z,
double k2)
125 for (
i = 0; fmt[
i]; ++
i) {
128 switch (fmt[
i + 1]) {
139 fprintf(stdout,
"%.18e", (2.0 / 3.0) *
k2 / pow(
c, 5));
155 "unrecognized conversion %%%c in output format\n",
163 switch (fmt[
i + 1]) {
190 "impossible escaped NUL character in format\n");
193 fputc(fmt[
i + 1], stdout);
199 fputc(fmt[
i], stdout);
227 {
"4parameterspectraldecomposition",
no_argument, 0,
'S'},
234 char args[] =
"hUE:f:n:d:e:F:N:PG:p:r:Qq:1:2:3:Sw:x:y:z:";
237 int polytropeFlag = 0;
238 double Gamma = 0, reference_pressure_si = 0, reference_density_si = 0;
241 int piecewisePolytropeFlag = 0;
242 double logp1_si = 0, gamma1 = 0, gamma2 = 0, gamma3 = 0;
245 int spectralFlag = 0;
246 double SDgamma0 = 0, SDgamma1 = 0, SDgamma2 = 0, SDgamma3 = 0;
249 int option_index = 0;
258 if (long_options[option_index].
flag)
261 fprintf(stderr,
"error parsing option %s with argument %s\n",
275 if (global_epsrel < 0 || global_epsrel == 0 || global_epsrel > 1) {
276 fprintf(stderr,
"invalid value of TOV solver routine relative error\n");
289 fprintf(stderr,
"invalid value of central rest-mass density\n");
296 fprintf(stderr,
"invalid value of central energy density\n");
306 fprintf(stderr,
"invalid number of points\n");
327 piecewisePolytropeFlag = 1;
360 fprintf(stderr,
"unknown error while parsing options\n");
366 if (polytropeFlag == 1)
369 reference_density_si);
372 if (piecewisePolytropeFlag == 1)
375 gamma1, gamma2, gamma3);
378 if (spectralFlag == 1)
381 SDgamma1, SDgamma2, SDgamma3);
384 fprintf(stderr,
"extraneous command line arguments:\n");
391 fprintf(stderr,
"error: no equation of state selected\n");
404 "\t-h, --help \tprint this message and exit\n");
406 "\t-f FILE, --eos-file=FILE \tuse EOS with from data filename FILE\n");
408 "\t-n NAME, --eos-name=NAME \tuse EOS with name NAME\n");
411 "\t-U, --calculate-virial-theorem \tcalculate and print Virial theorem besides M, R\n");
414 "\t-E, --choose-relative-error \tchoose a value for the TOV solver routine relative error (default epsrel=1e-6)\n");
417 "\tYou may choose a central value for the rest-mass density (in kg/m^3) or the energy density (in J/m^3) as follows\n");
419 "\t-d, --central-rest-mass-density \tcentral rest-mass density\n");
421 "\t-e, --central-energy-density \tcentral energy density\n");
423 "\tIf none are chosen the the program will use a standard fixed value\n");
426 "\t-P, --polytrope \tuse single polytrope\n");
427 fprintf(stderr,
"\t-G GAMMA, --gamma=GAMMA \tadiabatic index\n");
429 "\t-p PRESSURE, --pressure=PRESSURE \tpressure at reference density\n");
431 "\t-r DENSITY, --density=DENSITY \treference density\n");
434 "\t-Q, --piecewisepolytrope \tuse 4-parameter piecewise polytrope (PRD 79, 124032 (2009))\n");
436 "\t-q log(p_1), --logp1=log(p_1) \tlog of pressure at rho_1=10^17.7 kg/m^3\n");
438 "\t-1 Gamma_1, --gamma1=Gamma_1 \tadiabatic index <10^17.7 kg/m^3\n");
440 "\t-2 Gamma_2, --gamma2=Gamma_2 \tadiabatic index 10^17.7--10^18 kg/m^3\n");
442 "\t-3 Gamma_3, --gamma3=Gamma_3 \tadiabatic index >10^18.0 kg/m^3\n");
445 "\t-S --4paramspectraldecomp \tuse 4-parameter spectral decomposition (PRD 82, 103011 (2010))\n");
447 "\t-w SDgamma0, --SDgamma0=SDgamma0 \tadiabatic index spectral decomposition coefficient 1 0.2--2.0\n");
449 "\t-x SDgamma1, --SDgamma1=SDgamma1 \tadiabatic index spectral decomposition coefficient 2 -1.6--1.7\n");
451 "\t-y SDgamma2, --SDgamma2=SDgamma2 \tadiabatic index spectral decomposition coefficient 3 -0.8--0.6\n");
453 "\t-z SDgamma3, --SDgamma3=SDgamma3 \tadiabatic index spectral decomposition coefficient 4 -0.2--0.2\n");
456 "\t-N NPTS, --npts=NPTS \toutput NPTS points [%ld]\n",
459 "\t-F FORMAT, --format=FORMAT \toutput format FORMAT [\"%s\"]\n",
461 fprintf(stderr,
"format string conversions:\n");
463 "\t%%c\t is replaced by the dimensionless compactness M/R\n");
465 "\t%%l\t is replaced by the dimensionless tidal parameter\n");
466 fprintf(stderr,
"\t%%k\t is replaced by the tidal love number k2\n");
467 fprintf(stderr,
"\t%%m\t is replaced by the mass in solar masses\n");
468 fprintf(stderr,
"\t%%r\t is replaced by the radius in kilometers\n");
469 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
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 XLALSimNeutronStarEOSPressureOfRestMassDensity(double rho, LALSimNeutronStarEOS *eos)
Returns the pressure in Pa at a given rest-mass density in kg/m^3.
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.
double XLALSimNeutronStarEOSPressureOfEnergyDensity(double e, LALSimNeutronStarEOS *eos)
Returns the pressure in Pa at a given energy density in J/m^3.
LALSimNeutronStarEOS * XLALSimNeutronStarEOSFromFile(const char *fname)
Reads a data file containing a tabulated equation of state.
double XLALSimNeutronStarEOSMaxPressure(LALSimNeutronStarEOS *eos)
Returns the maximum pressure of the EOS in Pa.
LALSimNeutronStarEOS * XLALSimNeutronStarEOS4ParameterPiecewisePolytrope(double logp1_si, double gamma1, double gamma2, double gamma3)
Creates a 4-parameter piecewise-polytrope Equation of State.
void XLALDestroySimNeutronStarEOS(LALSimNeutronStarEOS *eos)
Frees the memory associated with a pointer to an EOS structure.
int XLALSimNeutronStarTOVODEIntegrate(double *radius, double *mass, double *love_number_k2, double central_pressure_si, LALSimNeutronStarEOS *eos)
int XLALSimNeutronStarVirialODEIntegrateWithTolerance(double *radius, double *mass, double *int1, double *int2, double *int3, double *int4, double *int5, double *int6, double *love_number_k2, double central_pressure_si, LALSimNeutronStarEOS *eos, double epsrel)
Integrates the Tolman-Oppenheimer-Volkov stellar structure equations and the Virial Equations.
int XLALSimNeutronStarTOVODEIntegrateWithTolerance(double *radius, double *mass, double *love_number_k2, double central_pressure_si, LALSimNeutronStarEOS *eos, double epsrel)
Integrates the Tolman-Oppenheimer-Volkov stellar structure equations.
int XLALSimNeutronStarVirialODEIntegrate(double *radius, double *mass, double *int1, double *int2, double *int3, double *int4, double *int5, double *int6, double *love_number_k2, double central_pressure_si, LALSimNeutronStarEOS *eos)
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)
const char *const default_fmt_U
const char *const default_fmt
int output(const char *fmt, double c, double m, double r, double w, double z, double k2)
int parseargs(int argc, char *argv[])
LALSimNeutronStarEOS * global_eos