pisces.models.stars.polytropes.PolytropicStarModel.from_mass_and_radius#

classmethod PolytropicStarModel.from_mass_and_radius(filename: Path | str, mass: unyt_quantity, radius: unyt_quantity, polytropic_index: float = 1.0, rmin: unyt_quantity = unyt_quantity(1, 'km'), rmax: unyt_quantity = None, num_points: int = 1000, overwrite: bool = False, **kwargs)[source]#

Construct a polytropic star model from its total mass and radius.

This method determines the core density and temperature required to match the given total mass and radius for a specified polytropic index. These parameters are then passed to the from_density_and_temperature() constructor to build the model.

Parameters:
  • filename (Path or str) – Output filename to write the model to. If the file already exists, then it will not be overwritten unless overwrite is set to True.

  • mass (unyt_quantity) – Total stellar mass (e.g., in Msun).

  • radius (unyt_quantity) – Total stellar radius (e.g., in Rsun).

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

  • rmin (unyt_quantity, default: 1 km) – Minimum radial value for the model grid.

  • rmax (unyt_quantity, optional) – Maximum radial value for the model grid. If None, uses radius.

  • num_points (int, default: 1000) – Number of radial grid points.

  • overwrite (bool, default: False) – Whether to overwrite an existing file.

  • **kwargs – Additional keyword arguments forwarded to from_density_and_temperature().

Returns:

An instance of the constructed model.

Return type:

PolytropicStarModel

Raises:

ValueError – If the Lane-Emden equation fails to converge.