Skip to content

reactivity_data

Reactivity data.

BOSCH_HALE_DD_3HEN = 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])) module-attribute

Bosch-Hale parameterisation dataclass.

H.-S. Bosch and G.M. Hale 1992 Nucl. Fusion 32 611 DOI 10.1088/0029-5515/32/4/I07

BOSCH_HALE_DD_TP = 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])) module-attribute

Bosch-Hale parameterisation dataclass.

H.-S. Bosch and G.M. Hale 1992 Nucl. Fusion 32 611 DOI 10.1088/0029-5515/32/4/I07

BOSCH_HALE_DT_4HEN = 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])) module-attribute

Bosch-Hale parameterisation dataclass.

H.-S. Bosch and G.M. Hale 1992 Nucl. Fusion 32 611 DOI 10.1088/0029-5515/32/4/I07

MOLAR_MASSES = {'D': 2.01410177784, 'T': 3.01604928132, 'He': 4.002602, 'He3': 3.01602932197, 'n': 1.0086649171167301, 'p': 1.0072764676333197, 'e': 0.0005485799096195737} module-attribute

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

ReactionCrossSection

Fusion reaction cross-section.

Source code in tokamak_neutron_source/reactivity_data.py
class ReactionCrossSection:
    """Fusion reaction cross-section."""

    def __init__(self, file_name: str):
        """
        Parameters
        ----------
        file_name:
            Cross-sectional data file (ENDF format)

        Raises
        ------
        ReactivityError
            Data file path is not a file
        """
        path = get_tns_path("data/cross_sections")
        path = Path(path, file_name)
        if not path.is_file():
            raise ReactivityError(f"Cross-section data file {path} is not a file!")

        file = path.as_posix()
        # Read in the cross section (in barn) as a function of energy (MeV).
        energy, sigma = np.genfromtxt(file, comments="#", skip_footer=2, unpack=True)

        split = file_name.split(".", maxsplit=1)[0].split("_")
        collider, target = split[:2]
        self.name = f"{collider} + {target} -> {split[2]} + {split[3]}"

        mass_1, mass_2 = MOLAR_MASSES[collider], MOLAR_MASSES[target]

        self.reduced_mass = raw_uc(mass_1 * mass_2 / (mass_1 + mass_2), "amu", "kg")

        # Convert to center of mass frame
        # NOTE MC: Choice of target/collider thing makes Bosch-Hale line up...
        energy *= mass_2 / (mass_1 + mass_2)

        # Convert to kev / m^2
        self._cross_section = interp1d(energy * 1e3, sigma * 1e-28)

    def __call__(self, temp_kev: float | npt.NDArray) -> float | npt.NDArray:
        """Get cross section at a give temperature"""  # noqa: DOC201
        return self._cross_section(temp_kev)

BoschHaleCoefficients

Bosch-Hale parameterisation dataclass.

H.-S. Bosch and G.M. Hale 1992 Nucl. Fusion 32 611 DOI 10.1088/0029-5515/32/4/I07

Source code in tokamak_neutron_source/reactivity_data.py
@dataclass
class BoschHaleCoefficients:
    """
    Bosch-Hale parameterisation dataclass.

    H.-S. Bosch and G.M. Hale 1992 Nucl. Fusion 32 611
    DOI 10.1088/0029-5515/32/4/I07
    """

    name: str
    t_min: float  # [keV]
    t_max: float  # [keV]
    bg: float  # [keV**0.5]
    mrc2: float  # [keV]
    c: npt.NDArray

ReactivityError

Bases: tokamak_neutron_source.error.TNSError

Reactivity error class

Source code in tokamak_neutron_source/error.py
class ReactivityError(TNSError):
    """Reactivity error class"""

DD_HE3N_XS(temp_kev)

Fusion reaction cross-section.

DD_TP_XS(temp_kev)

Fusion reaction cross-section.

DHE3_HEP_XS(temp_kev)

Fusion reaction cross-section.

DT_XS(temp_kev)

Fusion reaction cross-section.

TT_XS(temp_kev)

Fusion reaction cross-section.

get_tns_path(path='', subfolder='tokamak_neutron_source')

Get a tns path of a module subfolder. Defaults to root folder.

Parameters:

Name Type Description Default
path str

The desired path from which to create a full path

''
subfolder str

The subfolder (from the tokamak_neutron_source root) in which to create a path Defaults to the source code folder, but can be e.g. 'tests', or 'data'

'tokamak_neutron_source'

Returns:

Type Description
Path

The full path to the desired path in the subfolder specified

Source code in tokamak_neutron_source/tools.py
def get_tns_path(path: str = "", subfolder: str = "tokamak_neutron_source") -> Path:
    """
    Get a tns path of a module subfolder. Defaults to root folder.

    Parameters
    ----------
    path:
        The desired path from which to create a full path
    subfolder:
        The subfolder (from the tokamak_neutron_source root) in which to create a path
        Defaults to the source code folder, but can be e.g. 'tests', or 'data'

    Returns
    -------
    :
        The full path to the desired `path` in the subfolder specified
    """
    root = get_tns_root()
    if "egg" in root:
        return Path(f"/{subfolder}")

    path = path.replace("/", os.sep)
    main_path = _get_relpath(root, subfolder)
    return Path(_get_relpath(main_path, path))

raw_uc(value, unit_from, unit_to)

Raw unit converter Converts a value from one unit to another

Parameters:

Name Type Description Default
value ValueLikeT

value to convert

required
unit_from str | Unit

unit to convert from

required
unit_to str | Unit

unit to convert to

required

Returns:

Type Description
ValueLikeT

converted value

Source code in tokamak_neutron_source/constants.py
def raw_uc(
    value: ValueLikeT,
    unit_from: str | ureg.Unit,
    unit_to: str | ureg.Unit,
) -> ValueLikeT:
    """
    Raw unit converter
    Converts a value from one unit to another

    Parameters
    ----------
    value:
        value to convert
    unit_from:
        unit to convert from
    unit_to:
        unit to convert to

    Returns
    -------
    :
        converted value
    """
    try:
        return (
            ureg.Quantity(value, ureg.Unit(unit_from)).to(ureg.Unit(unit_to)).magnitude
        )
    except ValueError:
        # Catch scales on units eg the ridculousness of this unit: 10^19/m^3
        unit_from_q = ureg.Quantity(unit_from)
        unit_to_q = ureg.Quantity(unit_to)
        return (
            ureg.Quantity(value * unit_from_q).to(unit_to_q.units).magnitude
            / unit_to_q.magnitude
        )