API Reference
This page documents the public API of NeSST. The main entry point is:
import NeSST as nst
Core Module
- NeSST.core.A1s_2_rhoR(A_1S: float | ndarray[tuple[Any, ...], dtype[_ScalarT]], frac_D: float = 0.5, frac_T: float = 0.5) float | ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the DT areal density in kg/m^2 given a scattering amplitude
- NeSST.core.DDprimspecmoments(Tion: float) Tuple[float, float, float][source]
Calculates the mean energy and the variance of the neutron energy emitted during DD fusion accounting for temperature of the incident ions. Based on Ballabio fits, see Table III of L. Ballabio et al 1998 Nucl. Fusion 38 1723
- NeSST.core.DT_asym_scatter_spec(I_E: ndarray[tuple[Any, ...], dtype[_ScalarT]], rhoL_func: callable, frac_D: float = 0.5, frac_T: float = 0.5) Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]]]][source]
Calculates the single scattered neutron spectrum for DT given a primary neutron spectrum of I_E from anisotropic areal density
This requires the scattering matrices to have been pre-calculated
The primary neutron spectrum, I_E, is assumed to be on the same energy grid as the incoming energy grid used to calculate the scattering matrices
The areal density function rhoL_func needs to be a callable function with a single argument (cosine[theta])
- Parameters:
- Returns:
the total scattered spectrum and a tuple of the components (nD,nT,Dn2n,Tn2n)
- Return type:
Tuple of numpy.arrays
- NeSST.core.DT_scatter_spec_w_ionkin(I_E: ndarray[tuple[Any, ...], dtype[_ScalarT]], vbar: float, dv: float, rhoL_func: callable, frac_D: float = 0.5, frac_T: float = 0.5) Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]]]][source]
Calculates the single scattered neutron spectrum for DT given a primary neutron spectrum of I_E from anisotropic areal density and including ion velocities kinematics
This requires the scattering matrices with ion kinematics to have been pre-calculated
The primary neutron spectrum, I_E, is assumed to be on the same energy grid as the incoming energy grid used to calculate the scattering matrices
The areal density function rhoL_func needs to be a callable function with a single argument (cosine[theta])
- Parameters:
I_E (numpy.array) – the neutron spectrum at Ein energies
vbar (float) – mean velocity of the scattering ions
dv (float) – standard deviation velocity of the scattering ions
rhoL_func (callable) – must be a single argument function f(x),
[-1 (where x e)
f (1] and)
frac_D (float) – fraction of D in fuel
frac_T (float) – fraction of T in fuel
- Returns:
the total scattered spectrum and a tuple of the components (nD,nT,Dn2n,Tn2n)
- Return type:
Tuple of numpy.arrays
- NeSST.core.DT_sym_scatter_spec(I_E: ndarray[tuple[Any, ...], dtype[_ScalarT]], frac_D: float = 0.5, frac_T: float = 0.5) Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]]]][source]
Calculates the single scattered neutron spectrum for DT given a primary neutron spectrum of I_E from isotropic areal density
This requires the scattering matrices to have been pre-calculated
The primary neutron spectrum, I_E, is assumed to be on the same energy grid as the incoming energy grid used to calculate the scattering matrices
- Parameters:
I_E (numpy.array) – the neutron spectrum at Ein energies
- Returns:
the total scattered spectrum and a tuple of the components (nD,nT,Dn2n,Tn2n)
- Return type:
Tuple of numpy.arrays
- NeSST.core.DT_transmission(rhoL: float, E_in: ndarray[tuple[Any, ...], dtype[_ScalarT]], rhoL_func: callable, frac_D: float = 0.5, frac_T: float = 0.5) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the straight line transmission of primary fusion sources through the DT areal density
The areal density function rhoL_func needs to be a callable function with a single argument (cosine[theta])
- Parameters:
- Returns:
the total transmission coefficient as calculated
exp[ - A_1S rhoL_func(1) (f_D sigma_{D,tot}(Ein) + f_T sigma_{T,tot}(Ein)) ]
- Return type:
numpy.array
- NeSST.core.DTprimspecmoments(Tion: float) Tuple[float, float, float][source]
Calculates the mean energy and the variance of the neutron energy emitted during DT fusion accounting for temperature of the incident ions. Based on Ballabio fits, see Table III of L. Ballabio et al 1998 Nucl. Fusion 38 1723
- NeSST.core.QBallabio(Ein: ndarray[tuple[Any, ...], dtype[_ScalarT]], mean: float, variance: float) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the primary spectrum with a Ballabio shape i.e. modified Gaussian See equations 44 - 46 of Ballabio et al.
- NeSST.core.QBrysk(Ein: ndarray[tuple[Any, ...], dtype[_ScalarT]], mean: float, variance: float) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the primary spectrum with a Brysk shape i.e. Gaussian :param Ein: array of energy values on which to compute spectrum :type Ein: numpy.array :param mean: mean of spectrum :type mean: float :param variance: variance of spectraum :type variance: float
- Returns:
array with Gaussian spectrum on array Ein
- Return type:
numpy.array
- NeSST.core.QDress_DD(Ein: ndarray[tuple[Any, ...], dtype[_ScalarT]], Tion: float, n_samples: int = 1000000) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the DD primary neutron spectrum using the DRESS Monte Carlo code.
- Parameters:
- Returns:
normalised DD spectrum (1/eV) evaluated at the bin centres of Ein
- Return type:
numpy.array
- NeSST.core.QDress_DT(Ein: ndarray[tuple[Any, ...], dtype[_ScalarT]], T_D: float, T_T: float | None = None, n_samples: int = 1000000) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the DT primary neutron spectrum using the DRESS Monte Carlo code.
- Parameters:
- Returns:
normalised DT spectrum (1/eV) evaluated at the bin centres of Ein
- Return type:
numpy.array
- NeSST.core.calc_DT_ionkin_primspec_rhoL_integral(I_E: ndarray[tuple[Any, ...], dtype[_ScalarT]], rhoL_func=None, nT: bool = False, nD: bool = False)[source]
- NeSST.core.calc_DT_sigmabar(Ein: ndarray[tuple[Any, ...], dtype[_ScalarT]], I_E: ndarray[tuple[Any, ...], dtype[_ScalarT]], frac_D: float = 0.5, frac_T: float = 0.5) float[source]
Calculates the spectral-averaged cross section for DT
- Parameters:
- Returns:
the spectrally averaged total DT cross section
- Return type:
- NeSST.core.dNdE_TT(E: ndarray[tuple[Any, ...], dtype[_ScalarT]], Tion: float, model: str = 'Brune') ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the TT primary spectrum with Doppler broadening effect as calculated in Appelbe et al. HEDP 2016
- Parameters:
- Returns:
array with normalised TT spectral shape at energies E
- Return type:
numpy.array
- NeSST.core.init_DT_ionkin_scatter(varr: ndarray[tuple[Any, ...], dtype[_ScalarT]], nT: bool = False, nD: bool = False)[source]
Initialise the scattering matrices including the effect of ion velocities in the kinematics
N.B. the static ion scattering matrices must already be calculated e.g. by calling init_DT_scatter
- Parameters:
Ein (numpy.array) – the array on incoming neutron energies
Eout (numpy.array) – the array on outgoing neutron energies
- NeSST.core.init_DT_scatter(Eout: ndarray[tuple[Any, ...], dtype[_ScalarT]], Ein: ndarray[tuple[Any, ...], dtype[_ScalarT]])[source]
Initialise the scattering matrices for D and T materials
- Parameters:
Ein (numpy.array) – the array on incoming neutron energies
Eout (numpy.array) – the array on outgoing neutron energies
- NeSST.core.init_mat_scatter(Eout: ndarray[tuple[Any, ...], dtype[_ScalarT]], Ein: ndarray[tuple[Any, ...], dtype[_ScalarT]], mat_label: str)[source]
General material version of init_DT_scatter as specified by material label
N.B. the mat_lable must match those in available_materials_dict
- Parameters:
Ein (numpy.array) – the array on incoming neutron energies
Eout (numpy.array) – the array on outgoing neutron energies
mat_label (str) – material label
- NeSST.core.mat_scatter_spec(mat: Type[material_data], I_E: ndarray[tuple[Any, ...], dtype[_ScalarT]], rhoL_func: callable) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates a material’s single scattered neutron spectrum given a primary neutron spectrum of I_E from anisotropic areal density
This requires the scattering matrices to have been pre-calculated
The primary neutron spectrum, I_E, is assumed to be on the same energy grid as the incoming energy grid used to calculate the scattering matrices
The areal density function rhoL_func needs to be a callable function with a single argument (cosine[theta])
- Parameters:
I_E (numpy.array) – the neutron spectrum at Ein energies
rhoL_func (callable) – must be a single argument function f(x),
[-1 (where x e)
f (1] and)
- Returns:
the total scattered spectrum
- Return type:
numpy.array
- NeSST.core.mat_transmission(mat: Type[material_data], rhoL: float, E_in: ndarray[tuple[Any, ...], dtype[_ScalarT]], rhoL_func: callable) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the straight line transmission of primary fusion sources through a material’s areal density
The areal density function rhoL_func needs to be a callable function with a single argument (cosine[theta])
- Parameters:
mat (material_data) – Material data class for attenuating medium
rhoL (float) – the (4-pi averaged) areal density of the DT
E_in (numpy.array) – the energy array of the primary neutron spectrum
rhoL_func (callable) – must be a single argument function f(x),
[-1 (where x e)
f (1] and)
- Returns:
the total transmission coefficient as calculated
exp[ - A_1S rhoL_func(1) (f_D sigma_{D,tot}(Ein) + f_T sigma_{T,tot}(Ein)) ]
- Return type:
numpy.array
- NeSST.core.rhoR_2_A1s(rhoR: float | ndarray[tuple[Any, ...], dtype[_ScalarT]], frac_D: float = 0.5, frac_T: float = 0.5) float | ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Calculates the scattering amplitude given a DT areal density in kg/m^2
- NeSST.core.yield_from_dt_yield_ratio(reaction: str, dt_yield: float, Tion: float, frac_D: float = 0.5, frac_T: float = 0.5) float[source]
- Reactivity ratio to predict yield from the DT yield assuming same volume and burn time
rate_ij = (f_{i}*f_{j}*sigmav_{i,j}(T))/(1+delta_{i,j}) # dN/dVdt yield_ij = (rate_ij/rate_dt)*yield_dt
Uses default models for reactivities Note that the TT reaction produces two neutrons.
- Parameters:
- Raises:
ValueError – if the Tion is below 0 then a ValueError is raised
- Returns:
Yield of requested reaction
- Return type:
- NeSST.core.yields_normalised(Tion: float, frac_D: float = 0.5, frac_T: float = 0.5) Tuple[float, float, float][source]
Assuming same volume and burn time, find fractional yields of DT, DD and TT respectively
Uses default models for reactivities Note that the TT reaction produces two neutrons.
- Parameters:
- Raises:
ValueError – if the Tion is below 0 then a ValueError is raised
- Returns:
DT, DD and TT yields, normalised sum of unity
- Return type:
Fitting Module
- class NeSST.fitting.DT_fit_function(E_DTspec, E_sspec, vion_arr=None)[source]
Bases:
objectA class which constructs various simple models for the full spectrum in DT for fitting data
User must provide energy grids (and velocity grids if including ion kinematics)
One can create a model function from the following list of approximations:
– Symmetric areal density – Asymmetric Mode 1 areal density
The primary spectra are assumed isotropic and with moments defined by a single temperature
This class doesn’t represent the full set of spectrum models which can be produced by NeSST! Just a common few…
- init_modeone_model(P1_arr)[source]
Creates a callable model function for a mode 1 asymmetric areal density distribution
Time-of-Flight Module
- class NeSST.time_of_flight.BirksBetheBlochNLOModel(akB, Enorm)[source]
Bases:
ProtonScintillationModelakB in eV
Combining: kB in m/eV a in eV^2/m Bethe-Bloch formula for stopping power:
dE/dx = a/E
- Birks relation for light response:
dL/dx propto (dEdx)/(1+kB (dE/dx))
- class NeSST.time_of_flight.BirksBetheNLOModel(akB, excitation_energy, mp, Enorm, Emin, Emax, NE_interp)[source]
Bases:
ProtonScintillationModelakB in eV
Combining: kB in m/eV a in eV^2/m
I = excitation_energy in eV
- Bethe formula for stopping power:
dE/dx = a/E * ln(4 me E / mp I)
- Birks relation for light response:
dL/dx propto (dEdx)/(1+kB (dE/dx))
- class NeSST.time_of_flight.CraunSmithBetheModel(C, akB, excitation_energy, mp, Enorm, Emin, Emax, NE_interp)[source]
Bases:
BirksBetheNLOModelCraun, R. L., and D. L. Smith. “Analysis of response data for several organic scintillators.” Nuclear Instruments and Methods 80.2 (1970): 239-244.
We use:
dLdE propto 1 / (1 + kB * dE/dx + C (kb * dE/dx)**2)
where dE/dx is given by the Bethe formula.
Note that this is a slight redefinition of C compared with the original paper, which is more convenient for our purposes (dimensionless).
- class NeSST.time_of_flight.LOS_material(density: float, length: float, components: List[NeSST.time_of_flight.LOS_material_component])[source]
Bases:
object- components: List[LOS_material_component]
- class NeSST.time_of_flight.LOS_material_component(number_fraction: float, A: float, ENDF_file: str)[source]
Bases:
object
- class NeSST.time_of_flight.PowerLawScintillationModel(p, Enorm)[source]
Bases:
ProtonScintillationModel
- class NeSST.time_of_flight.ProtonScintillationModel(Enorm)[source]
Bases:
ABCUsing equation (3) from
Qi Tang, Zifeng Song, Pinyang Liu, Bo Yu, Jiamin Yang, Calibration of the sensitivity of the bibenzyl-based scintillation detector to 1–5 MeV neutrons, Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, Volume 1068, 2024, 169779, ISSN 0168-9002, https://doi.org/10.1016/j.nima.2024.169779.
- class NeSST.time_of_flight.VerbinskiNLOModel(Enorm)[source]
Bases:
ProtonScintillationModelData from Verbinski, VVl, et al. “Calibration of an organic scintillator for neutron spectrometry.” Nuclear Instruments and Methods 65.1 (1968): 8-25.
- NeSST.time_of_flight.decaying_gaussian_kernel(FWHM, tau, shift_sigma=2.0)[source]
Single exponential tail multiplied by Gaussian.
- NeSST.time_of_flight.double_decay_gaussian_kernel(FWHM, taus, frac, shift_sigma=2.0)[source]
Weighted sum of two decaying-Gaussian components.
- NeSST.time_of_flight.gated_decaying_gaussian_kernel(sig, tau, shift_t, sig_turnon)[source]
Exponentially decaying Gaussian with logistic gate.
- NeSST.time_of_flight.get_BirksBetheBloch_NLO(akB, Enorm=14028394.353912354)
- NeSST.time_of_flight.get_BirksBethe_NLO(akB, excitation_energy, mp=1.67262192595e-27, Enorm=14028394.353912354, Emin=1000.0, Emax=20000000.0, NE_interp=1000)
- NeSST.time_of_flight.get_CraunSmithBethe_NLO(C, akB, excitation_energy, mp=1.67262192595e-27, Enorm=14028394.353912354, Emin=1000.0, Emax=20000000.0, NE_interp=1000)
- NeSST.time_of_flight.get_LOS_attenuation(LOS_materials: List[LOS_material])[source]
- NeSST.time_of_flight.get_Verbinski_NLO(Enorm=14028394.353912354)
- NeSST.time_of_flight.get_power_law_NLO(p, Enorm=14028394.353912354)
- NeSST.time_of_flight.inversegaussian_nIRF(scint_thickness, ni_scin=8.79e+28, CH_ratio=0.4444444444444444, E_lower=50000.0, E_upper=25000000.0, NE_interp=1000)[source]
- NeSST.time_of_flight.make_transit_time_IRF(thickness, kernel_fn, base_matrix_fn=None)[source]
Parameters
- thicknessfloat
Sets the detector thickness
- kernel_fncallable(t) -> 1-D array
Builds the convolution kernel on the same time grid.
- base_matrix_fncallable(thickness) -> callable(t_detected, En) -> 2-D array [optional]
Anything that returns an (N×N) response matrix before filtering. If omitted, we fall back to the canonical top-hat.
- class NeSST.time_of_flight.nToF(distance, sensitivity, instrument_response_function, normtime_start=5.0, normtime_end=20.0, normtime_N=2048, detector_normtime=None)[source]
Bases:
object- get_time_resolved_dNdt(En, d2NdEdt)[source]
Interpolate d²N/dE dt_emit onto the detector energy grid and apply the energy-to-normtime Jacobian.
Parameters
- Enarray_like, shape (N_E,)
Energy bin centres (eV). Must be sorted ascending.
- d2NdEdtarray_like, shape (N_E, N_temit)
Double-differential spectrum d²N/dE dt_emit [1/eV/s].
Returns
- dNdt2dndarray, shape (N_td, N_temit)
d²N/dt_norm dt_emit on the detector normtime grid [1/s/s].
- get_time_resolved_signal(En, d2NdEdt, temit)[source]
Full time-resolved forward model: interpolation → sensitivity → IRF → emission-time shift.
Parameters
- Enarray_like, shape (N_E,)
Energy bin centres (eV). Must be sorted ascending.
- d2NdEdtarray_like, shape (N_E, N_temit)
d²N/dE dt_emit [1/eV/s].
- temitarray_like, shape (N_temit,)
Emission time bin centres (s). Must be > 0 and sorted ascending.
Returns
detector_time : ndarray, shape (N_td,) detector_normtime : ndarray, shape (N_td,) signal : ndarray, shape (N_td,)
- get_time_resolved_signal_no_IRF(En, d2NdEdt, temit)[source]
Time-resolved forward model without IRF application.
Parameters
- Enarray_like, shape (N_E,)
Energy bin centres (eV). Must be sorted ascending.
- d2NdEdtarray_like, shape (N_E, N_temit)
d²N/dE dt_emit [1/eV/s].
- temitarray_like, shape (N_temit,)
Emission time bin centres (s). Must be > 0 and sorted ascending.
Returns
detector_time : ndarray, shape (N_td,) detector_normtime : ndarray, shape (N_td,) signal : ndarray, shape (N_td,)
Constants
Utilities
- NeSST.utils.interpolate_1d(x_points, values, method='linear', bounds_error=True, fill_value=nan, axis=None)[source]