main
Neutromak user-facing API.
            AllReactions = tokamak_neutron_source.reactions.Reactions | tokamak_neutron_source.reactions.AneutronicReactions
  
      module-attribute
  
    Represent a PEP 604 union type
E.g. for int | str
            CUSTOM_ORDER = [<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)))>, <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)))>, <AneutronicReactions.D_D: ReactionData(label='D + D → T + p', total_energy=6.461016407480568e-13, num_neutrons=0, cross_section=<tokamak_neutron_source.reactivity_data.ReactionCrossSection object at 0x7ff2008b80d0>, bosch_hale_coefficients=BoschHaleCoefficients(name='D + D --> T + p', t_min=0.2, t_max=100.0, bg=31.397, mrc2=937814.0, c=array([5.65718e-12, 3.41267e-03, 1.99167e-03, 0.00000e+00, 1.05060e-05,0.00000e+00, 0.00000e+00])), ballabio_spectrum=None)>, <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)>, <AneutronicReactions.D_He3: ReactionData(label='D + ³He → ⁴He + p', total_energy=2.940668400408501e-12, num_neutrons=0, cross_section=<tokamak_neutron_source.reactivity_data.ReactionCrossSection object at 0x7ff200901310>, bosch_hale_coefficients=None, ballabio_spectrum=None)>]
  
      module-attribute
  
    Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
            TYPE_CHECKING = False
  
      module-attribute
  
    bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
            annotations = _Feature((3, 7, 0, 'beta', 1), None, 16777216)
  
      module-attribute
  
    
            TokamakNeutronSource
    Tokamak neutron source object.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| transport | TransportInformation | Plasma profile information and species composition. | required | 
| flux_map | FluxMap | Magneto-hydrodynamic equilibrium poloidal magnetic flux map containing LCFS geometry and the psi_norm inside of it. | required | 
| source_type | AllReactions | list[AllReactions] | None | Which neutronic reaction(s) to include in the neutron source. | None | 
| cell_side_length | float | Discretisation in [m] for sampling the 2-D poloidal plane within the LCFS.
Square cells of side length  | 0.1 | 
| total_fusion_power | float | None | If specified, will be used to normalise the source strength to a prescribed fusion power | None | 
| reactivity_method | ReactivityMethod | Which method to use when calculating reactivities | <ReactivityMethod.AUTO: 3> | 
Source code in tokamak_neutron_source/main.py
                | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |  | 
            source_T_rate
  
      property
  
    The T consumption rate in [tritons / s].
Notes
If you are using a "(n,Xt)" tally to calculate TBR, note that the definition of TBR is relative to the number of D-T reactions, not the total number of fusion reactions.
To correctly scale your "(n,Xt)" tally in [1/particles], you should scale by: tbr *= source_rate / source_T_rate
            source_rate
  
      property
  
    The total source rate in [neutrons / s].
            calculate_total_fusion_power()
    Calculate the total fusion power from all reaction channels.
Returns:
| Type | Description | 
|---|---|
| total_fusion_power | The total fusion power | 
Notes
The aneutronic fusion reactions are included here.
Source code in tokamak_neutron_source/main.py
              
            normalise_fusion_power(total_fusion_power)
    Renormalise the source strength to match a total fusion power across all channels.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| total_fusion_power | float | The total fusion power to normalise to [W] | required | 
Notes
This is done assuming the provided total fusion power is for the same channels as the source_type. The ratios of the strengths of each reaction is assumed to be same as modelled here.
Source code in tokamak_neutron_source/main.py
              
            to_openmc_source(energy_method=<EnergySpectrumMethod.AUTO: 4>)
    Create an OpenMC tokamak neutron source.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| energy_method | EnergySpectrumMethod | Which method to use when calculating neutron spectra | <EnergySpectrumMethod.AUTO: 4> | 
Returns:
| Type | Description | 
|---|---|
| list[IndependentSource] | List of native OpenMC source objects | 
Source code in tokamak_neutron_source/main.py
              
            to_sdef_card(filename)
    Create an SDEF card which MCNP/openmc can use to make a tokamak neutron source.
Notes
The position-dependence of neutron energies be captured by SDEF. Therefore the energy distribution of neutrons is averaged, and the same (frozen) distribution is used everywhere in the reactor.
Source code in tokamak_neutron_source/main.py
              
            to_h5_source()
    Create a source in the HDF5 format such that the full distribution of neutron energies and position
Returns:
| Type | Description | 
|---|---|
| H5 format | 
            plot(reactions=None)
    Plot the tokamak neutron source.
Returns:
| Name | Type | Description | 
|---|---|---|
| f | Figure | Matplotlib figure object | 
| ax | Axes | Matplotlib axes object | 
Raises:
| Type | Description | 
|---|---|
| TNSError | If the requested reactions are not in the source | 
Source code in tokamak_neutron_source/main.py
              
            AneutronicReactions
    
              Bases: tokamak_neutron_source.reactions.ReactionEnumMixin, enum.Enum
Aneutronic reaction channels.
Source code in tokamak_neutron_source/reactions.py
                
            D_D = <AneutronicReactions.D_D: ReactionData(label='D + D → T + p', total_energy=6.461016407480568e-13, num_neutrons=0, cross_section=<tokamak_neutron_source.reactivity_data.ReactionCrossSection object at 0x7ff2008b80d0>, bosch_hale_coefficients=BoschHaleCoefficients(name='D + D --> T + p', t_min=0.2, t_max=100.0, bg=31.397, mrc2=937814.0, c=array([5.65718e-12, 3.41267e-03, 1.99167e-03, 0.00000e+00, 1.05060e-05,0.00000e+00, 0.00000e+00])), ballabio_spectrum=None)>
  
      class-attribute
  
    Aneutronic reaction channels.
            D_He3 = <AneutronicReactions.D_He3: ReactionData(label='D + ³He → ⁴He + p', total_energy=2.940668400408501e-12, num_neutrons=0, cross_section=<tokamak_neutron_source.reactivity_data.ReactionCrossSection object at 0x7ff200901310>, bosch_hale_coefficients=None, ballabio_spectrum=None)>
  
      class-attribute
  
    Aneutronic reaction channels.
            EnergySpectrumMethod
    
              Bases: enum.Enum
Energy spectrum calculation method.
Source code in tokamak_neutron_source/energy.py
                
              
            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.
            Reactions
    
              Bases: tokamak_neutron_source.reactions.ReactionEnumMixin, enum.Enum
Neutronic reaction channels.
Source code in tokamak_neutron_source/reactions.py
                
            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.
            ReactivityError
    
            ReactivityMethod
    
              Bases: enum.Enum
Reactivity calculation method.
Source code in tokamak_neutron_source/reactivity.py
                
              
            AUTO = <ReactivityMethod.AUTO: 3>
  
      class-attribute
  
    Reactivity calculation method.
            BOSCH_HALE = <ReactivityMethod.BOSCH_HALE: 2>
  
      class-attribute
  
    Reactivity calculation method.
            XS = <ReactivityMethod.XS: 1>
  
      class-attribute
  
    Reactivity calculation method.
            TNSError
    
              Bases: builtins.Exception
Base exception class. Sub-class from this for module level Errors.
Source code in tokamak_neutron_source/error.py
                
            density_weighted_reactivity(temp_kev, density_d, density_t, density_he3, reaction=<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)))>, method=<ReactivityMethod.AUTO: 3>)
    Calculate the density-weighted thermal reactivity of a fusion reaction in
Maxwellian plasmas, \t:math:n_1 n_2 <\sigma v>.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| temp_kev | float | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Temperature [keV] | required | 
| density_d | float | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Deuterium density [m^-3] | required | 
| density_t | float | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Tritium density [m^-3] | required | 
| density_he3 | float | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Helium-3 density [m^-3] | required | 
| reaction | str | Reactions | AneutronicReactions | The fusion reaction | <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)))> | 
| method | ReactivityMethod | The method to use when calculating the reactivity | <ReactivityMethod.AUTO: 3> | 
Returns:
| Type | Description | 
|---|---|
| float | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Density-weighted reactivity of the reaction at the specified temperature(s) [1/m^3/s] | 
Source code in tokamak_neutron_source/reactivity.py
              
            sample_space_2d(lcfs, o_point, cell_side_length)
    Sample the 2-D poloidal plane within the LCFS.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| lcfs | ClosedFluxSurface | Last closed flux surface | required | 
| o_point | FluxPoint | O-point location | required | 
| cell_side_length | float | Side length of square cells [m] | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| x | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Radial coordinates of sampled points [m] | 
| z | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Vertical coordinates of sampled points [m] | 
| d_volume | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Volumes of cells centred at points [m^3] | 
Notes
Creates points at the centres of square cells of fixed size (cell_side_length by cell_side_length). Only cells whose centres fall inside the LCFS polygon are kept. Cells are positioned such that the centre of one cell lies on the O-point.
Source code in tokamak_neutron_source/space.py
              
            write_mcnp_sdef_source(file, r, z, cell_side_length, temperature, strength)
    Write an MCNP SDEF source for a ring source at (r,z).
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| file | str | Path | The file name stub to which to write the SDEF source | required | 
| r | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Radial positions of the rings [m] | required | 
| z | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Vertical positions of the rings [m] | required | 
| cell_side_length | float | side length of square source cell | required | 
| temperature | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | Ion temperatures at the rings [keV] | required | 
| strength | dict[Reactions | AneutronicReactions, ndarray[tuple[Any, ...], dtype[~_ScalarT]]] | Dictionary of strengths for each reaction at the rings [arbitrary units] | required | 
Notes
Only Neutronic reactions are written to SDEF file Aneutronic reactions are ignored. The radial distribution bouldaries and probabilities are set to the SI3 and SP3 cards The DS4 card is used as the dependent distribution numbers for the vertical distributions