pttools.models.const_cs

Constant sound speed model, aka. \(\mu, \nu\) model

Classes

class pttools.models.const_cs.ConstCSModel(css2, csb2, V_s=AnalyticModel.DEFAULT_V_S, V_b=AnalyticModel.DEFAULT_V_B, a_s=None, a_b=None, g_s=None, g_b=None, alpha_n_min=None, T_min=None, T_max=None, T_ref=1, T_crit_guess=None, name=None, label_latex=None, label_unicode=None, allow_invalid=False, log_info=True)

Bases: AnalyticModel

Constant sound speed model, aka. \(\mu, \nu\) model

Parameters:
  • css2 (float | Fraction)

  • csb2 (float | Fraction)

  • V_s (float)

  • V_b (float)

  • a_s (float)

  • a_b (float)

  • g_s (float)

  • g_b (float)

  • alpha_n_min (float)

  • T_min (float)

  • T_max (float)

  • T_ref (float)

  • T_crit_guess (float)

  • name (str)

  • label_latex (str)

  • label_unicode (str)

  • allow_invalid (bool)

  • log_info (bool)

DEFAULT_LABEL_LATEX: str = 'Constant $c_s$ model'
DEFAULT_LABEL_UNICODE: str = 'Constant cₛ model'
DEFAULT_NAME: str = 'const_cs'
TEMPERATURE_IS_PHYSICAL: bool = False

Whether the temperature is in proper physics units

alpha_n(wn, error_on_invalid=True, nan_on_invalid=True, log_invalid=True)

Transition strength parameter at nucleation temperature, \(\alpha_n\), Hindmarsh et al., 2021, eq. 7.40.

\[\alpha_n = \frac{4}{3} \left( \frac{1}{\nu} - \frac{1}{\mu} + \frac{1}{w_n} (V_s - V_b) \right)\]

Parameters:
  • wn (float | float64 | ndarray) – \(w_n\), enthalpy of the symmetric phase at the nucleation temperature

  • error_on_invalid (bool) – raise error for invalid values

  • nan_on_invalid (bool) – return nan for invalid values

  • log_invalid (bool) – whether to log invalid values

Return type:

float | float64 | ndarray

alpha_n_min_find(w_min=None, w_max=None)

Find \(\text{min} \alpha_n(w)\) for \(w \in ({w}_\text{min}, {w}_\text{max})\)

Parameters:
  • w_min (float)

  • w_max (float)

Return type:

Tuple[float, float]

alpha_n_min_find_params(alpha_n_min_target, a_s_default, a_b, V_s_default=None, V_b=None, safety_factor_alpha=None, safety_factor_a=1.001, safety_factor_V=0.001, a_max=1e4, error_on_invalid=True, nan_on_invalid=True, log_invalid=True, cancel_on_invalid=True)

Find the model parameters that allow the given \(\alpha_{n,\text{min,target}}\)

Parameters:
  • alpha_n_min_target (float)

  • a_s_default (float)

  • a_b (float)

  • V_s_default (float)

  • V_b (float)

  • safety_factor_alpha (float)

  • safety_factor_a (float)

  • safety_factor_V (float)

  • a_max (float)

  • error_on_invalid (bool)

  • nan_on_invalid (bool)

  • log_invalid (bool)

  • cancel_on_invalid (bool)

Return type:

Tuple[float, float, float, float]

static alpha_n_min_find_params_solvable(a_s, V_s, a_b, V_b, css2, csb2, alpha_n_target)
Parameters:
  • a_s (float)

  • V_s (float)

  • a_b (float)

  • V_b (float)

  • css2 (float)

  • csb2 (float)

  • alpha_n_target (float)

classmethod alpha_n_min_find_params_solvable2(args, a_b, V_b, css2, csb2, alpha_n_target)
Parameters:
  • args (ndarray)

  • a_b (float)

  • V_b (float)

  • css2 (float)

  • csb2 (float)

  • alpha_n_target (float)

alpha_plus(wp, wm, vp_tilde=None, sol_type=None, error_on_invalid=True, nan_on_invalid=True, log_invalid=True)

If \(\mu_-=4 \Leftrightarrow c_{sb}=\frac{1}{\sqrt{3}}\), then \(w_-\) does not affect the result.

Parameters:
  • wp (float | float64 | ndarray)

  • wm (float | float64 | ndarray)

  • vp_tilde (float)

  • sol_type (SolutionType)

  • error_on_invalid (bool)

  • nan_on_invalid (bool)

  • log_invalid (bool)

Return type:

float | float64 | ndarray

alpha_theta_bar_n(wn, error_on_invalid=True, nan_on_invalid=True, log_invalid=True)

Transition strength parameter, Giese et al., 2021, eq. 13

\[\alpha_{\bar{\theta}+} = \frac{D \bar{\theta}(T_n)}{3 w_n}\]

Parameters:
  • wn (float | float64 | ndarray)

  • error_on_invalid (bool)

  • nan_on_invalid (bool)

  • log_invalid (bool)

Return type:

float | float64 | ndarray

alpha_theta_bar_n_max_lte(wn, sol_type, Psi_n=None)

\(\alpha_{n,\text{max}}^\text{def}\), Ai et al., 2023, eq. 28, 31

Parameters:
Return type:

float

alpha_theta_bar_n_min_lte(wn, sol_type, Psi_n=None)

\(\alpha_{n,\text{min}}^\text{def}\), Ai et al., 2023, eq. 27, 30

Parameters:
Return type:

float

alpha_theta_bar_plus(wp, error_on_invalid=True, nan_on_invalid=True, log_invalid=True)

Transition strength parameter, Giese et al., 2021, eq. 9

\[\alpha_{\bar{\theta}+} = \frac{D \bar{\theta}(T_+)}{3 w_+}\]

Parameters:
  • wp (float | float64 | ndarray)

  • error_on_invalid (bool)

  • nan_on_invalid (bool)

  • log_invalid (bool)

Return type:

float | float64 | ndarray

critical_temp_opt(temp)

This function should be zero at the critical temperature \(T_c\), where $p_s(T_c)=p_b(T_c).

Parameters:

temp (float)

Return type:

float

cs2_max(w_max, phase, w_min=0, allow_fail=False, **kwargs)
Parameters:
  • w_max (float)

  • phase (Phase)

  • w_min (float)

  • allow_fail (bool)

Return type:

Tuple[float, float]

cs2_min(w_max, phase, w_min=0, allow_fail=False, **kwargs)
Parameters:
  • w_max (float)

  • phase (Phase)

  • w_min (float)

  • allow_fail (bool)

Return type:

Tuple[float, float]

cs2_temp(temp, phase)
Parameters:
Return type:

float | float64 | ndarray

delta_theta(wp, wm, error_on_invalid=True, nan_on_invalid=True, log_invalid=True)
Parameters:
  • wp (float | float64 | ndarray)

  • wm (float | float64 | ndarray)

  • error_on_invalid (bool)

  • nan_on_invalid (bool)

  • log_invalid (bool)

Return type:

float | float64 | ndarray

e_temp(temp, phase)

Energy density \(e(T,\phi)\)

\[{e}_{\pm} = {a}_{\pm} (\mu_\pm - 1) T^{\mu_\pm} + {V}_\pm\]
Giese et al., 2021, eq. 15. In the article there is a typo: the 4 there should be a \(\mu\).

Parameters:
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.

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

inverse_enthalpy_ratio(temp)

Inverse enthalpy ratio \(\Psi(T)\) Ai et al., 2023, eq. 19

\[\Psi(T) = \frac{w_b(T)}{w_s(T)}\]
:param temp: temperature \(T\)

Parameters:

temp (float | float64 | ndarray)

Return type:

float | float64 | ndarray

p_temp(temp, phase)

Pressure \(p(T,\phi)\)

\[p_{\pm} = {a}_{\pm} T^{\mu_\pm} - {V}_{\pm}\]
Giese et al., 2021, eq. 15.

Parameters:
Return type:

float | float64 | ndarray

params_str()

Model parameters as a string

Return type:

str

s_temp(temp, phase)

Entropy density \(s=\frac{dp}{dT}\)

\[s_\pm = \mu {a}_\pm \left( \frac{T}{T_0} \right)^{\mu_\pm-1} T_0^3\]
Derived from Giese et al., 2021, eq. 15.

Parameters:
Return type:

float | float64 | ndarray

solution_type(v_wall, alpha_n, wn=None, wn_guess=None, wm_guess=None)
Parameters:
  • v_wall (float)

  • alpha_n (float)

  • wn (float)

  • wn_guess (float)

  • wm_guess (float)

Return type:

SolutionType

temp(w, phase)

Temperature \(T(w,\phi)\). Inverted from the equation of \(w(T,\phi)\).

\[T_\pm = T_0 \left( \frac{w}{\mu a_{\pm} T_0^4} \right)^\frac{1}{\mu_\pm}\]

Parameters:
Return type:

float | float64 | ndarray

static validate_cs2(cs2, name='cs2')
Parameters:
  • cs2 (float)

  • name (str)

Return type:

float

w(temp, phase)

Enthalpy density \(w(T,\phi)\)

\[w_\pm = \mu a_{\pm} \left( \frac{T}{T_0} \right)^{\mu_\pm} T_0^4\]

Parameters:
Return type:

float | float64 | ndarray

wn(alpha_n, wn_guess=1, analytical=True, theta_bar=False, error_on_invalid=True, nan_on_invalid=True, log_invalid=True)

Enthalpy at nucleation temperature

Parameters:
  • alpha_n (float | float64 | ndarray)

  • wn_guess (float)

  • analytical (bool)

  • theta_bar (bool)

  • error_on_invalid (bool)

  • nan_on_invalid (bool)

  • log_invalid (bool)

Return type:

float | float64 | ndarray

Functions

pttools.models.const_cs.cs2_to_float_and_label(cs2, max_denominator=100, label_prec=3)

Convert the speed of sound value to a float and a string label.

Parameters:
  • cs2 (float | Fraction)

  • max_denominator (int)

  • label_prec (int)

Return type:

Tuple[float, str]

pttools.models.const_cs.cs2_to_mu(cs2)

Convert speed of sound squared \(c_s^2\) to \(\mu\)

\[\mu = 1 + \frac{1}{c_s^2}\]

Parameters:

cs2 (float | float64 | ndarray)

Return type:

float | float64 | ndarray