boss_bench

boss_bench.confinement#

Alpha-particle losses, computed over the particles born on one surface.

boss_bench.confinement.is_lost(confinement_time, t_max)[source]#

Flag the particles that left the plasma before the end of the simulation.

Particle \(i\) is lost if its confinement time is shorter than the simulation time, \(t_i < t_\text{max}\), up to round-off.

Parameters:
  • confinement_time (np.ndarray) – confinement times [s], shape (..., n).

  • t_max (float or np.ndarray) – simulation time [s], a scalar or shape (...).

Returns:

True for the lost particles, shape (..., n).

Return type:

np.ndarray

Raises:

ValueError – if an input contains NaN or inf.

boss_bench.confinement.loss_fraction(confinement_time, t_max, s_init, s0=0.1)[source]#

Compute the fraction of the particles born on one surface that are lost.

Parameters:
  • confinement_time (np.ndarray) – confinement times [s], shape (..., n).

  • t_max (float or np.ndarray) – simulation time [s], a scalar or shape (...).

  • s_init (np.ndarray) – birth surfaces, shape (..., n).

  • s0 (float) – the birth surface \(s_0\) to average over.

Returns:

the loss fraction, shape (...).

Return type:

float or np.ndarray

Raises:

ValueError – if an input contains NaN or inf.

boss_bench.confinement.energy_loss(confinement_time, t_max, s_init, s0=0.1)[source]#

Compute the mean energy lost per particle born on one surface.

\[E = \frac{1}{N} \sum_i e^{-2 t_i / t_\text{max}} \cdot 3.5\ \text{MeV},\]

where the sum runs over the \(N\) particles born on \(s_0\), and the slowing-down time in the exponent is approximated by \(t_\text{max} = 0.1\) s. A confined particle (\(t_i = t_\text{max}\)) counts \(3.5\,e^{-2}\) MeV.

Parameters:
  • confinement_time (np.ndarray) – confinement times [s], shape (..., n).

  • t_max (float or np.ndarray) – simulation time [s], a scalar or shape (...).

  • s_init (np.ndarray) – birth surfaces, shape (..., n).

  • s0 (float) – the birth surface \(s_0\) to average over.

Returns:

the energy loss [MeV], shape (...).

Return type:

float or np.ndarray

Raises:

ValueError – if an input contains NaN or inf.

boss_bench.confinement.normalized_energy_loss(confinement_time, t_max, s_init, s0=0.1)[source]#

Compute the energy loss, rescaled to \([0, 1]\).

\[\bar E = \frac{1}{N} \sum_i \frac{e^{-2 t_i / t_\text{max}} - e^{-2}}{1 - e^{-2}},\]

where the sum runs over the \(N\) particles born on \(s_0\), so \(\bar E\) is 0 if every particle is confined and 1 if every particle is lost at once.

Parameters:
  • confinement_time (np.ndarray) – confinement times [s], shape (..., n).

  • t_max (float or np.ndarray) – simulation time [s], a scalar or shape (...).

  • s_init (np.ndarray) – birth surfaces, shape (..., n).

  • s0 (float) – the birth surface \(s_0\) to average over.

Returns:

the normalized energy loss, shape (...).

Return type:

float or np.ndarray

Raises:

ValueError – if an input contains NaN or inf.

boss_bench.confinement.mean_confinement_time(confinement_time, t_max, s_init, s0=0.1)[source]#

Compute the mean confinement time of the particles born on one surface.

\[\bar t = \frac{1}{N} \sum_i t_i,\]

where the sum runs over the \(N\) particles born on \(s_0\), so a confined particle counts \(t_i = t_\text{max}\), and \(\bar t\) is at most \(t_\text{max}\).

Parameters:
  • confinement_time (np.ndarray) – confinement times [s], shape (..., n).

  • t_max (float or np.ndarray) – simulation time [s], a scalar or shape (...).

  • s_init (np.ndarray) – birth surfaces, shape (..., n).

  • s0 (float) – the birth surface \(s_0\) to average over.

Returns:

the mean confinement time [s], shape (...).

Return type:

float or np.ndarray

Raises:

ValueError – if an input contains NaN or inf.