pisces.models.stars.polytropes.PolytropicStarModel.compute_parameters_from_mass_and_radius#

classmethod PolytropicStarModel.compute_parameters_from_mass_and_radius(mass: unyt_quantity, radius: unyt_quantity, polytropic_index: float = 1.0, mu: float = None, xi_max: float = 10.0) tuple[unyt_quantity, unyt_quantity][source]#

Compute the central density and temperature of a polytropic star from its mass and radius.

This method derives the core properties of a polytropic stellar model, specifically the central density (\(\rho_c\)) and central temperature (\(T_c\)), based on the total stellar mass, total stellar radius, and the chosen polytropic index. It numerically solves the Lane-Emden equation for the given index to determine the structure of the polytrope, and uses scaling relations to connect the dimensionless solution to physical units.

The computed central density is determined by matching the Lane-Emden mass integral to the desired total mass. The central temperature is then derived from the ideal gas law assuming hydrostatic equilibrium and a known mean molecular weight.

Parameters:
  • mass (unyt_quantity) – Total stellar mass (e.g., in solar masses). This must be consistent with units of mass. If no unit is provided, it defaults to solar masses (Msun).

  • radius (unyt_quantity) – Total stellar radius (e.g., in solar radii). This must have dimensions of length. If no unit is provided, it defaults to solar radii (Rsun).

  • polytropic_index (float, default: 1.0) – The polytropic index \(n\) controlling the equation of state.

  • mu (float, optional) – Mean molecular weight. If None, pulled from the class configuration.

  • xi_max (float, default: 10) –

    Maximum dimensionless radius to use when integrating the Lane-Emden equation. If this is too small, the Lane-Emden equation will not hit its first zero before reaching the truncation point and an error will be raised.

    If this occurs, it is generally safe to simply increase this value to ensure the solution is valid.

Returns:

Raises:

ValueError – If the Lane-Emden solver does not encounter a zero crossing before xi_max.

Notes

For a given polytropic index \(n\), the Lane-Emden equation is solved numerically via a call to the low-level compute_lame_emden_solution(). Given the truncation point \(\xi_{\rm max}\), the scale parameter \(\alpha\) is computed as the ratio of the total radius to the truncation point, i.e., \(\alpha = R / \xi_{\rm max}\).

The total mass of the star is

\[M_{\rm total} = 4\pi \alpha^3 \rho_c \int_0^{\xi_{\rm max}} \theta^n \xi^2 d\xi.\]

As such, the integral is computed and used to determine the core density \(\rho_c\) as.

Finally, the central temperature is computed using the ideal gas law.