pttools.models.base

Base class for equation of state models and thermodynamics models

Classes

class pttools.models.base.BaseModel(name=None, T_min=None, T_max=None, restrict_to_valid=True, label_latex=None, label_unicode=None, gen_cs2=True, gen_cs2_neg=True, temperature_is_physical=None, silence_temp=False)

Bases: ABC

The base for both Model and ThermoModel

All temperatures must be in units of GeV for the frequency conversion in Spectrum to work.

Parameters:
  • name (str)

  • T_min (float)

  • T_max (float)

  • restrict_to_valid (bool)

  • label_latex (str)

  • label_unicode (str)

  • gen_cs2 (bool)

  • gen_cs2_neg (bool)

  • temperature_is_physical (bool)

  • silence_temp (bool)

DEFAULT_LABEL_LATEX: str = None
DEFAULT_LABEL_UNICODE: str = None
DEFAULT_NAME: str = None
DEFAULT_T_MAX: float = inf
DEFAULT_T_MIN: float = 0.001
TEMPERATURE_IS_PHYSICAL: bool = None

Whether the temperature is in proper physics units

abstract cs2(*args, **kwargs)

Speed of sound squared

Return type:

float | float64 | ndarray

abstract cs2_neg(*args, **kwargs)

Speed of sound squared with a minus sign. This is needed for finding the maximum of cs2.

Return type:

float | float64 | ndarray

export()

Export the model parameters to a dictionary. User-created model classes should extend this.

Return type:

Dict[str, any]

gen_cs2()

This function generates a Numba-jitted \(c_s^2\) function for the model.

Return type:

Callable[[float | float64 | ndarray, float | float64 | ndarray], float | float64 | ndarray] | CPUDispatcher

gen_cs2_neg()

This function generates a negative version of the Numba-jitted \(c_s^2\) function to be used for maximisation.

Return type:

Callable[[float | float64 | ndarray, float | float64 | ndarray], float | float64 | ndarray] | CPUDispatcher

validate_temp(temp)

Validate that the given temperatures are in the validity range of the model.

If invalid values are found, a copy of the array is created where those are set to np.nan.

Parameters:

temp (float | float64 | ndarray)

Return type:

float | float64 | ndarray