jesterTOV.utils module
Utility functions for unit conversions, physical constants, and numerical methods.
Utilities
- jesterTOV.utils.calculate_rest_mass_density(e: Float[Array, 'n'], p: Float[Array, 'n'])[source]
Compute rest-mass density given arrays of energy density and pressure.
Parameters: - e (jax.numpy array): Array of specific energy values. - p (jax.numpy array): Array of pressure values.
Returns: - rho (jax.numpy array): Array of density values.
- jesterTOV.utils.cubic_root_for_proton_fraction(coefficients)[source]
Vectorized version of cubic_root_for_proton_fraction. Takes similar arguments as cubic_root_for_proton_fraction but with additional array axes over which cubic_root_for_proton_fraction is mapped.
- jesterTOV.utils.cubic_spline(xq: Float[Array, 'n'], xp: Float[Array, 'n'], fp: Float[Array, 'n'])[source]
Create a cubic spline interpolating function through (xp, fp) with interpax (https://github.com/f0uriest/interpax) :param xq: x values at which we are going to evaluate the spline interpolator :type xq: Float[Array, “n”] :param xp: x values of the data points :type xp: Float[Array, “n”] :param fp: y values of the data points, i.e. fp = f(xp) :type fp: Float[Array, “n”]
- jesterTOV.utils.cumtrapz(y, x)[source]
Cumulatively integrate y(x) using the composite trapezoidal rule.
- Parameters:
y (jax.numpy.ndarray) – Values to integrate.
x (jax.numpy.ndarray) – The coordinate to integrate along.
- Returns:
res – The result of cumulative integration of y along x.
- Return type:
jax.numpy.ndarray
- jesterTOV.utils.limit_by_MTOV(pc: Array, m: Array, r: Array, l: Array) tuple[Array, Array, Array, Array][source]
Limits the M, R and Lambda curves to be below MTOV in a jit-friendly manner (i.e., static shape sizes). The idea now is to feed this into some routine that creates an interpolation out of this, which then uses jnp.unique to get rid of these duplicates
- Parameters:
pcs (Array["npoints"]) – Original pressure
m (Array["npoints"]) – Original mass curve
r (Array["npoints"]) – Original radius curve
l (Array["npoints"]) – Original lambdas curve
- Returns:
Tuple of new mass, radius and lambdas curves, where the part of the curves where mass decreases is replaced with duplication of the first entry of the M, R and Lambda arrays.
- Return type:
tuple[Array[“npoints”], Array[“npoints”], Array[“npoints”]]
Physical Constants
The module provides physical constants in geometric units where \(G = c = 1\):
Nuclear saturation density: \(n_{\text{sat}} = 0.16 \text{ fm}^{-3}\)
Solar mass: \(M_{\odot} = 1.477 \text{ km}\)
Conversion factors between CGS and geometric units
Numerical Methods
Key numerical utilities include:
Cubic spline interpolation: For smooth interpolation between data points
Cumulative trapezoidal integration: For integrating differential equations
Unit conversions: Between different unit systems used in neutron star physics