pttools.bubble.shock

Functions for shocks

Functions

pttools.bubble.shock.find_shock_index(model, v, w, xi, v_wall, wn, cs_n, sol_type, v_shock_atol=3.5e-8, error_on_failure=True, zero_on_failure=True, log_failure=True, warn_if_barely_exists=True)
Parameters:
  • model (Model)

  • v (ndarray)

  • w (ndarray)

  • xi (ndarray)

  • v_wall (float)

  • wn (float)

  • cs_n (float)

  • sol_type (SolutionType)

  • v_shock_atol (float)

  • error_on_failure (bool)

  • zero_on_failure (bool)

  • log_failure (bool)

  • warn_if_barely_exists (bool)

Return type:

int

pttools.bubble.shock.find_shock_index_bag(v_f, xi, v_wall, sol_type)

Array index of shock from first point where fluid velocity \(v_f\) goes below \(v_\text{shock}\). For detonation, returns wall position.

Parameters:
  • v_f (ndarray) – fluid velocity \(v_f\)

  • xi (ndarray) – \(\xi\)

  • v_wall (float) – wall velocity \(v_\text{wall}\)

  • sol_type (SolutionType) – solution type (detonation etc.)

Returns:

shock index

Return type:

int

pttools.bubble.shock.shock_curve(model, alpha_n, xi=None)
Parameters:
pttools.bubble.shock.shock_zoom_last_element(v, w, xi)

Replaces last element of \((v,w,\xi)\) arrays by better estimate of shock position and values of \(v, w\) there.

Parameters:
Returns:

given \(v, w, \xi\) arrays with the last elements replaced

Return type:

Tuple[ndarray, ndarray, ndarray]

pttools.bubble.shock.solve_shock(model, v1_tilde, w1, backwards, v2_tilde_guess=None, w2_guess=None, csp=None, phase=Phase.SYMMETRIC, allow_failure=False, warn_if_barely_exists=True)

Solve the boundary conditions at a shock

Parameters:
  • model (Model) – Hydrodynamics model

  • v1_tilde (float) – \(\tilde{v}_{1,sh}\)

  • w1 (float) – \(w_{1,sh}\)

  • backwards (bool) – whether to solve from \(+\) to \(-\) instead of from \(-\) to \(+\)

  • v2_tilde_guess (float) – Starting guess for \(\tilde{v}_{2,sh}\)

  • w2_guess (float) – Starting guess for \(w_{2,sh}\)

  • csp (float) – Speed of sound in front of the shock. Will be computed from the model if not given. The computation is only an approximation when solving forwards.

  • phase (Phase) – Phase in which the shock propagates

  • allow_failure (bool) – Whether to allow invalid values

  • warn_if_barely_exists (bool) – Warn if the shock barely exists

Returns:

\(\tilde{v}_{2,sh},w2\)

Return type:

Tuple[float, float]

pttools.bubble.shock.v_shock_bag(xi)

Fluid velocity at a shock at \(\xi\). No shocks exist for \(\xi < \frac{1}{\sqrt{3}}\), so this returns zero. $$ v_{sh}(\xi) = \frac{3 \xi^2 - 1}{2\xi} $$ Hindmarsh et al., 2019, eq. B.17.

Parameters:

xi (float | float64 | ndarray) – \(\xi\)

Returns:

\(v_{sh}\)

Return type:

float | float64 | ndarray | callable | CPUDispatcher

pttools.bubble.shock.v_shock_curve(model, wn, n_points=20, warn_if_barely_exists=False)
Parameters:
  • model (Model)

  • wn (float)

  • n_points (int)

  • warn_if_barely_exists (bool)

Return type:

Tuple[ndarray, ndarray]

pttools.bubble.shock.wm_shock_bag(xi, w_n=1., nan_on_negative=True)

Fluid enthalpy behind a shock at \(\xi\) in the bag model. No shocks exist for \(\xi < c_s\), so returns nan. Equation B.18 of Hindmarsh et al., 2019.

$$ w_{sh}(xi) = w_n frac{9xi^2 - 1}{3(1 - xi^2)} $$

Parameters:
  • xi (float | float64 | ndarray) – \(\xi\)

  • w_n (float) – enthalpy in front of the shock

  • nan_on_negative (bool)

Returns:

\(w_{sh}\), enthalpy behind the shock

Return type:

float | float64 | ndarray | callable | CPUDispatcher

pttools.bubble.shock.wp_shock_bag(xi, wm)

Fluid enthalpy in front of a shock at \(\xi\) in the bag model. No shocks exist for \(\xi < cs\), so returns nan. Derived from Hindmarsh et al., 2019 eq. B.18.

$$ w_n(xi) = w_{-,sh} frac{3(1 - xi^2)}{9xi^2 - 1} $$

Parameters:
  • xi (float | float64 | ndarray) – \(\xi\)

  • wm (float) – \(w_{-,sh}\), enthalpy behind the shock

Returns:

\(w_{+,sh}\), enthalpy in front of the shock

Return type:

float | float64 | ndarray | callable | CPUDispatcher