Skip to content

energy

Neutron energy spectrum calculations.

EnergySpectrumMethod

Bases: enum.Enum

Energy spectrum calculation method.

Source code in tokamak_neutron_source/energy.py
class EnergySpectrumMethod(Enum):
    """Energy spectrum calculation method."""

    DATA = auto()
    BALLABIO_GAUSSIAN = auto()
    BALLABIO_M_GAUSSIAN = auto()
    AUTO = auto()

AUTO = <EnergySpectrumMethod.AUTO: 4> class-attribute

Energy spectrum calculation method.

BALLABIO_GAUSSIAN = <EnergySpectrumMethod.BALLABIO_GAUSSIAN: 2> class-attribute

Energy spectrum calculation method.

BALLABIO_M_GAUSSIAN = <EnergySpectrumMethod.BALLABIO_M_GAUSSIAN: 3> class-attribute

Energy spectrum calculation method.

DATA = <EnergySpectrumMethod.DATA: 1> class-attribute

Energy spectrum calculation method.

BallabioEnergySpectrum

Ballabio et al. fit data for relativistic fusion reaction neutron energy Gaussian spectra.

Source code in tokamak_neutron_source/energy_data.py
@dataclass
class BallabioEnergySpectrum:
    """
    Ballabio et al. fit data for relativistic fusion reaction neutron energy Gaussian
    spectra.
    """

    """E_0"""
    energy_0: float  # [keV]

    omega_0: float  # [keV]

    r"""\Delta E_{th} coefficients"""
    energy_shift_coeffs: BallabioCoefficients

    r"""\delta_{\omega} coefficients"""
    width_correction_coeffs: BallabioCoefficients

    def energy_shift(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
        r"""
        Calculate the energy shift \Delta E_{th} at a given ion temperature.
        """  # noqa: DOC201
        return self.energy_shift_coeffs.fit(temp_kev)

    def width_correction(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
        r"""
        Calculate the width correction \delta_{\omega} at a given ion temperature.
        """  # noqa: DOC201
        return self.width_correction_coeffs.fit(temp_kev)

    def mean_energy(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
        """
        Calculate the mean neutron energy at a given ion temperature
        (primary first moment: mu).
        """  # noqa: DOC201
        return self.energy_0 + self.energy_shift(temp_kev)

    def std_deviation(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
        """
        Calculate the standard deviation of the neutron energy spectrum at a given ion
        temperature (primary second moment: sigma)
        """  # noqa: DOC201
        # Full width at half maximum (FWHM)
        w_12 = self.omega_0 * (1 + self.width_correction(temp_kev)) * np.sqrt(temp_kev)
        return w_12 / TWO_SQRT_2LN2

energy_shift(temp_kev)

Calculate the energy shift \Delta E_{th} at a given ion temperature.

Source code in tokamak_neutron_source/energy_data.py
def energy_shift(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
    r"""
    Calculate the energy shift \Delta E_{th} at a given ion temperature.
    """  # noqa: DOC201
    return self.energy_shift_coeffs.fit(temp_kev)

mean_energy(temp_kev)

Calculate the mean neutron energy at a given ion temperature (primary first moment: mu).

Source code in tokamak_neutron_source/energy_data.py
def mean_energy(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
    """
    Calculate the mean neutron energy at a given ion temperature
    (primary first moment: mu).
    """  # noqa: DOC201
    return self.energy_0 + self.energy_shift(temp_kev)

std_deviation(temp_kev)

Calculate the standard deviation of the neutron energy spectrum at a given ion temperature (primary second moment: sigma)

Source code in tokamak_neutron_source/energy_data.py
def std_deviation(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
    """
    Calculate the standard deviation of the neutron energy spectrum at a given ion
    temperature (primary second moment: sigma)
    """  # noqa: DOC201
    # Full width at half maximum (FWHM)
    w_12 = self.omega_0 * (1 + self.width_correction(temp_kev)) * np.sqrt(temp_kev)
    return w_12 / TWO_SQRT_2LN2

width_correction(temp_kev)

Calculate the width correction \delta_{\omega} at a given ion temperature.

Source code in tokamak_neutron_source/energy_data.py
def width_correction(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
    r"""
    Calculate the width correction \delta_{\omega} at a given ion temperature.
    """  # noqa: DOC201
    return self.width_correction_coeffs.fit(temp_kev)

EnergySpectrumError

Bases: tokamak_neutron_source.error.TNSError

Energy spectrum error class

Source code in tokamak_neutron_source/error.py
class EnergySpectrumError(TNSError):
    """Energy spectrum error class"""

Reactions

Bases: tokamak_neutron_source.reactions.ReactionEnumMixin, enum.Enum

Neutronic reaction channels.

Source code in tokamak_neutron_source/reactions.py
class Reactions(ReactionEnumMixin, Enum):
    """Neutronic reaction channels."""

    D_T = ReactionData(
        label="D + T → ⁴He + n",
        total_energy=E_DT_FUSION,
        num_neutrons=1,
        cross_section=DT_XS,
        bosch_hale_coefficients=BOSCH_HALE_DT_4HEN,
        ballabio_spectrum=BALLABIO_DT_NEUTRON,
    )
    D_D = ReactionData(
        label="D + D → ³He + n",
        total_energy=E_DD_HE3N_FUSION,
        num_neutrons=1,
        cross_section=DD_HE3N_XS,
        bosch_hale_coefficients=BOSCH_HALE_DD_3HEN,
        ballabio_spectrum=BALLABIO_DD_NEUTRON,
    )
    T_T = ReactionData(
        label="T + T → ⁴He + 2n",
        total_energy=E_TT_FUSION,
        num_neutrons=2,
        cross_section=TT_XS,
        bosch_hale_coefficients=None,
        ballabio_spectrum=None,
    )

D_D = <Reactions.D_D: ReactionData(label='D + D → ³He + n', total_energy=5.237367559215132e-13, num_neutrons=1, cross_section=<tokamak_neutron_source.reactivity_data.ReactionCrossSection object at 0x7ff2008dfb10>, bosch_hale_coefficients=BoschHaleCoefficients(name='D + D --> 3He + n', t_min=0.2, t_max=100.0, bg=31.397, mrc2=937814.0, c=array([ 5.43360e-12, 5.85778e-03, 7.68222e-03, 0.00000e+00,-2.96400e-06, 0.00000e+00, 0.00000e+00])), ballabio_spectrum=BallabioEnergySpectrum(energy_0=2449.5, omega_0=82.542, energy_shift_coeffs=BallabioCoefficients(a1=4.69515, a2=-0.040729, a3=0.47, a4=0.81844), width_correction_coeffs=BallabioCoefficients(a1=0.0017013, a2=0.16888, a3=0.49, a4=0.0007946)))> class-attribute

Neutronic reaction channels.

D_T = <Reactions.D_T: ReactionData(label='D + T → ⁴He + n', total_energy=2.8183035155819573e-12, num_neutrons=1, cross_section=<tokamak_neutron_source.reactivity_data.ReactionCrossSection object at 0x7ff2008d4c50>, bosch_hale_coefficients=BoschHaleCoefficients(name='D + T --> 4He + n', t_min=0.2, t_max=100.0, bg=34.3827, mrc2=1124656.0, c=array([ 1.17302e-09, 1.51361e-02, 7.51886e-02, 4.60643e-03,1.35000e-02, -1.06750e-04, 1.36600e-05])), ballabio_spectrum=BallabioEnergySpectrum(energy_0=14021.0, omega_0=177.259, energy_shift_coeffs=BallabioCoefficients(a1=5.30509, a2=0.0024736, a3=1.84, a4=1.3818), width_correction_coeffs=BallabioCoefficients(a1=0.00051068, a2=0.0076223, a3=1.78, a4=8.7691e-05)))> class-attribute

Neutronic reaction channels.

T_T = <Reactions.T_T: ReactionData(label='T + T → ⁴He + 2n', total_energy=1.8157845541890245e-12, num_neutrons=2, cross_section=<tokamak_neutron_source.reactivity_data.ReactionCrossSection object at 0x7ff20ad03850>, bosch_hale_coefficients=None, ballabio_spectrum=None)> class-attribute

Neutronic reaction channels.

energy_spectrum(temp_kev, reaction, method=<EnergySpectrumMethod.BALLABIO_M_GAUSSIAN: 3>)

Calculate the tabulated energy spectrum of a reaction at a given ion temperature.

Parameters:

Name Type Description Default
temp_kev float

Ion temperature

required
reaction Reactions

Neutronic fusion reaction

required
method EnergySpectrumMethod

Method to use to calculate the energy spectrum

<EnergySpectrumMethod.BALLABIO_M_GAUSSIAN: 3>

Returns:

Name Type Description
energies ndarray[tuple[Any, ...], dtype[~_ScalarT]]

The energy bins of the probability distribution function

pdf ndarray[tuple[Any, ...], dtype[~_ScalarT]]

The PDF values

Source code in tokamak_neutron_source/energy.py
def energy_spectrum(
    temp_kev: float,
    reaction: Reactions,
    method: EnergySpectrumMethod = EnergySpectrumMethod.BALLABIO_M_GAUSSIAN,
) -> tuple[npt.NDArray, npt.NDArray]:
    """
    Calculate the tabulated energy spectrum of a reaction at a given ion temperature.

    Parameters
    ----------
    temp_kev:
        Ion temperature
    reaction:
        Neutronic fusion reaction
    method:
        Method to use to calculate the energy spectrum

    Returns
    -------
    energies:
        The energy bins of the probability distribution function
    pdf:
        The PDF values
    """
    match method:
        case (
            EnergySpectrumMethod.BALLABIO_GAUSSIAN
            | EnergySpectrumMethod.BALLABIO_M_GAUSSIAN
        ):
            if reaction.ballabio_spectrum is not None:
                return _ballabio_spectrum(reaction.ballabio_spectrum, temp_kev, method)

            logger.warning(
                f"There is no Ballabio parameterisation for reaction {reaction.name}, "
                "returning energy spectrum calculated by data.",
                stacklevel=5,
            )
            return _data_spectrum(reaction, temp_kev)

        case EnergySpectrumMethod.DATA:
            return _data_spectrum(reaction, temp_kev)
        case EnergySpectrumMethod.AUTO:
            match reaction:
                case Reactions.D_D | Reactions.D_T:
                    return energy_spectrum(
                        temp_kev, reaction, EnergySpectrumMethod.BALLABIO_M_GAUSSIAN
                    )
                case Reactions.T_T:
                    return energy_spectrum(temp_kev, reaction, EnergySpectrumMethod.DATA)

TT_N_SPECTRUM(temp_kev)

Fusion neutron energy data spectrum.