Solve TOV Equation
Function to solve the TOV equation from EOS equation of state given by user.
Maximum central density
Import the maximum-mass search using the corrected spelling:
from TOVsolver.maximum_central_density import maximum_central_density
TOVsolver/maxium_central_density.py is a compatibility module for existing
notebooks that use the historical typo. Both names refer to the same function;
there is only one implementation in maximum_central_density.py.
The search refines a five-point logarithmic density bracket and returns the central density in g/cm3, mass in solar masses, and radius in km for the same stellar solution. It does not exhaustively search arbitrarily narrow or disconnected stable branches.
Stellar structure equations
- TOVsolver.solver_code.TOV_def(r, y, inveos, ad_index)[source]
Packs the complete set of TOV equations for neutron stars with tidal deformability
- Parameters:
r (float) – Radius as integration variable
y (array) – Array of integration variables containing [pressure, mass, h, b] where h and b are variables used for tidal deformability calculation
inveos (function) – Inverse equation of state function that maps pressure to energy density
ad_index (float) – Adiabatic index used in the tidal deformability equations
- Returns:
Array containing derivatives [dpdr, dmdr, dhdr, dfdr] for the integration
- Return type:
array
- TOVsolver.solver_code.m1_from_mc_m2(mc, m2)[source]
a function that feed back the companion star mass from GW event measurement.
- Parameters:
mc (float) – chrip mass of a GW event, unit in solar mass.
m2 (float or numpy array) – the determined mass for one of the star, this is computed from sampling of EoS.
- Returns:
the companion star mass in solar mass.
- Return type:
m1 (array)
- TOVsolver.solver_code.solveTOV(center_rho, Pmin, eos, inveos, max_radius=3e+19)[source]
Solve the Tolman-Oppenheimer-Volkoff (TOV) equation to determine the structure of a neutron star
This function numerically integrates the TOV equations from the center outward to find the mass and radius of a neutron star with a given central density and equation of state. The integration uses an adaptive step size method to ensure numerical stability, especially near the surface where pressure gradients become steep.
- Parameters:
center_rho (float) – Central geometric energy density, in inverse squared natural length units (energy density times G/c^2).
Pmin (float) – Surface geometric pressure, in inverse squared natural length units (pressure times G/c^4).
eos (function) – Maps geometric energy density to geometric pressure, using the same input units as center_rho and Pmin.
inveos (function) – Inverse EOS in those same geometric units.
max_radius (float, optional) – Safety parameter to prevent runaway integration in case the star’s surface is not properly detected. Defaults to 30e5*unit.cm
- Returns:
- Mass and radius in the package’s natural units.
Divide by
unit.Msunandunit.kmfor solar masses and km.
- Return type:
tuple[float, float]
Notes
Integration begins at a small non-zero radius (r = 1e-18 * unit.cm) to avoid the coordinate singularity at r=0
Initial pressure is calculated using a Taylor expansion around r=0 since the TOV equation has an indeterminate form (0/0) at the origin
We use adaptive step sizing for numerical stability
Multiple stopping conditions ensure robustness against EoS-related numerical issues
- TOVsolver.solver_code.solveTOV_tidal(center_rho, energy_density, pressure, max_radius=3e+19)[source]
Solve TOV equation from given Equation of state in the neutron star core density range
- Parameters:
center_rho (array) – This is the energy density here is fixed in main that is np.logspace(14.3, 15.6, 50)
energy_density (array) – Desity array of the neutron star EoS, in MeV/fm^{-3}. Notice here for simiplicity, we omitted G/c**4 magnitude, so (value in MeV/fm^{-3})*G/c**4, could convert to the energy density we are using, please check the Test_EOS.csv to double check the order of magnitude.
pressure (array) – Pressure array of neutron star EoS, also in nautral unit with MeV/fm^{-3}, still please check the Test_EOS.csv, the conversion is (value in dyn/cm3)*G/c**4.
- Returns:
- Mass and radius in the package’s natural
units, followed by dimensionless tidal deformability. Divide mass by
unit.Msunand radius byunit.kmfor customary units.
- Return type:
tuple[float, float, float]
- TOVsolver.solver_code.tidal_deformability(y2, Mns, Rns)[source]
Compute Tidal deformability from y2, neutron star mass and raius
- Parameters:
y2 (array) – midiate varrible that computing tidal
Mns (array) – neutron star mass in g/cm3
Rns (array) – neutron star radius in cm.
- Returns:
neutron star tidal deformability with unit-less.
- Return type:
tidal_def (array)