pisces.models.stars.polytropes.PolytropicStarModel.from_density_and_temperature#

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

Construct a polytropic star model from core density and core temperature.

This method generates a complete stellar model assuming a polytropic equation of state defined by the given core density, core temperature, and polytropic index. It solves the Lane-Emden equation, builds physical profiles, and writes out all relevant fields.

Parameters:
  • filename (Path or str) – The path to the file where the resulting model will be stored. If the file already exists, it will not be overwritten unless overwrite is set to True.

  • core_density (unyt_quantity) – The central density of the star (e.g., in kg/m**3).

  • core_temperature (unyt_quantity) – The central temperature of the star (e.g., in K).

  • polytropic_index (float) – The polytropic index n governing the stellar structure equation. By default, this is set to 1.0.

  • rmin (unyt_quantity) – Minimum radial value of the stellar model grid. Default is 1 km.

  • rmax (unyt_quantity) – Maximum radial value of the stellar model grid. Default is 100,000 km.

  • num_points (int) – Number of radial points in the model grid. Default is 1000.

  • overwrite (bool, default: False) – Whether to overwrite the existing file if it already exists.

  • **kwargs

    Additional keyword arguments:

    • spacing{“log”, “linear”}, default: “log”

      Whether to use logarithmic or linear spacing for the radial grid.

Returns:

An instance of the constructed polytropic star model.

Return type:

PolytropicStarModel

Raises:

ValueError – If the Lane-Emden equation does not converge before hitting the maximum value of xi.