mckit_nuclides package

Subpackages

Submodules

mckit_nuclides.abundance module

Methods to change nuclide abundance in compositions.

mckit_nuclides.abundance.MOLAR_MASS_TABLE = shape: (3_539, 3) ┌───────────────┬─────────────┬────────────┐ atomic_number mass_number molar_mass ---           ---         ---        u8            u16         f32        ╞═══════════════╪═════════════╪════════════╡ 1             0           1.008      1             1           1.007825   1             2           2.014102   1             3           3.016049   1             4           4.02643                                      117           294         294.210449 118           0           295.216003 118           293         293.213562 118           294         294.213928 118           295         295.216248 └───────────────┴─────────────┴────────────┘

The table contains molar masses for nuclides with specified and not specified mass numbers.

mckit_nuclides.abundance.convert_to_atomic_fraction(composition, fraction_column='fraction')[source]

Change fractions by mass to fractions by atoms.

Parameters:
  • composition (DataFrame) – DataFrame with columns atomic_number, mass_number

  • fraction_column (str) – name of column presenting fraction

Returns:

df with modified column “fraction”

Return type:

DataFrame

mckit_nuclides.abundance.expand_df_natural_presence(composition, fraction_column='fraction')[source]

Expand ‘natural’ presence in composition presented as a DataFrame.

Parameters:
  • composition (DataFrame) – table with columns atomic_number, mass_number (may be 0), fraction

  • fraction_column (str) – exact ‘fraction’ column name

Return type:

DataFrame

Returns:

Expanded composition as a DataFrame.

mckit_nuclides.abundance.expand_natural_presence(zaf)[source]

Convert sequence of nuclide-fraction specification with natural presence.

Substitute a sequence of nuclides when mass number is specified as 0. This means natural presence.

Parameters:

zaf (Iterable[tuple[int, int, float]]) – sequence of atomic number, mass number and fraction

Yields:

atomic number, mass_number, and corrected atomic fraction

Return type:

Generator[tuple[int, int, float]]

mckit_nuclides.abundance.normalize_column(table, column='fraction')[source]

Normalize the values in a column to have sum() == 1.0 over the column.

Parameters:
  • table (DataFrame) – … to normalize

  • column (str) – … over this column

Return type:

DataFrame

Returns:

Result of normalization

mckit_nuclides.elements module

Module elements provides access to information on chemical element level.

mckit_nuclides.elements.atomic_mass(z_or_symbol)[source]

Get standard atomic mass for and Element by atomic number.

Parameters:

z_or_symbol (int | str) – define either by atomic number or symbol

Return type:

float

Returns:

Average atomic mass of the Element with the atomic number.

mckit_nuclides.elements.atomic_number(_symbol)[source]

Get atomic number (Z) for an element.

Parameters:

_symbol (str) – element by chemical symbol

Returns:

Z - the atomic number for the element.

Return type:

int

mckit_nuclides.elements.from_molecular_formula(formula, *, mass_fraction=False)[source]

Create dataframe for material from chemical formula.

Minimalistic parser for chemical formula to define compositions on the fly.

Symbols of elements are to be in capitalized form: Ge, Si…

Parameters:
  • formula (str) – … H20, C2H5OH, etc.

  • mass_fraction (bool) – define mass fractions instead of atomic (default)

Return type:

DataFrame

Examples

>>> print(from_molecular_formula("H2O"))
shape: (2, 2)
┌───────────────┬──────────┐
│ atomic_number ┆ fraction │
│ ---           ┆ ---      │
│ u8            ┆ f64      │
╞═══════════════╪══════════╡
│ 1             ┆ 0.666667 │
│ 8             ┆ 0.333333 │
└───────────────┴──────────┘
>>> print(from_molecular_formula("C2H5OH"))
shape: (3, 2)
┌───────────────┬──────────┐
│ atomic_number ┆ fraction │
│ ---           ┆ ---      │
│ u8            ┆ f64      │
╞═══════════════╪══════════╡
│ 1             ┆ 0.666667 │
│ 6             ┆ 0.222222 │
│ 8             ┆ 0.111111 │
└───────────────┴──────────┘
>>> print(from_molecular_formula("H2O", mass_fraction=True))
shape: (2, 2)
┌───────────────┬──────────┐
│ atomic_number ┆ fraction │
│ ---           ┆ ---      │
│ u8            ┆ f64      │
╞═══════════════╪══════════╡
│ 1             ┆ 0.111907 │
│ 8             ┆ 0.888093 │
└───────────────┴──────────┘
Return type:

DataFrame

Returns:

composition

Parameters:
  • formula (str)

  • mass_fraction (bool)

mckit_nuclides.elements.get_property(z_or_symbol, column)[source]

Get column value for an element specified with atomic number or symbol.

Parameters:
  • z_or_symbol (int | str) – define either by atomic number or symbol

  • column (str) – column name in ELEMENTS_TABLE

Raises:

KeyError – if it cannot find the given element.

Return type:

int | float | str | None

Returns:

The column value for the given element.

mckit_nuclides.elements.symbol(_atomic_number)[source]

Get chemical symbol for a given Z (atomic number).

Parameters:

_atomic_number (int) – Z of an element

Returns:

Chemical symbol

Return type:

str

mckit_nuclides.elements.z(_symbol)

Synonym to atomic_number.

Return type:

int

Parameters:

_symbol (str)

mckit_nuclides.nuclides module

Information on nuclides: masses, natural presence and more.

mckit_nuclides.nuclides.get_nuclide_mass(z_or_symbol, mass_number)[source]

Retrieve mass of a nuclide by atomic and mass numbers, a.u.

Parameters:
  • z_or_symbol (int | str) – Z or symbol of a nuclide

  • mass_number (int) – A

Return type:

float

Returns:

Mass of the Nuclide (a.u).

mckit_nuclides.nuclides.get_property(z_or_symbol, mass_number, column)[source]

Retrieve mass of a nuclide by atomic and mass numbers, a.u.

Parameters:
  • z_or_symbol (int | str) – Z or symbol of a nuclide

  • mass_number (int) – A

  • column (str) – name of column to extract value from

Raises:

KeyError – if cannot find the given nuclide.

Return type:

int | float | str | None

Returns:

Value of a column for the given nuclide.

Module contents

The mckit_nuclides package.

Provides information on chemical elements and nuclides as Polars tables.

mckit_nuclides.atomic_mass(z_or_symbol)[source]

Get standard atomic mass for and Element by atomic number.

Parameters:

z_or_symbol (int | str) – define either by atomic number or symbol

Return type:

float

Returns:

Average atomic mass of the Element with the atomic number.

mckit_nuclides.atomic_number(_symbol)[source]

Get atomic number (Z) for an element.

Parameters:

_symbol (str) – element by chemical symbol

Returns:

Z - the atomic number for the element.

Return type:

int

mckit_nuclides.convert_to_atomic_fraction(composition, fraction_column='fraction')[source]

Change fractions by mass to fractions by atoms.

Parameters:
  • composition (DataFrame) – DataFrame with columns atomic_number, mass_number

  • fraction_column (str) – name of column presenting fraction

Returns:

df with modified column “fraction”

Return type:

DataFrame

mckit_nuclides.expand_df_natural_presence(composition, fraction_column='fraction')[source]

Expand ‘natural’ presence in composition presented as a DataFrame.

Parameters:
  • composition (DataFrame) – table with columns atomic_number, mass_number (may be 0), fraction

  • fraction_column (str) – exact ‘fraction’ column name

Return type:

DataFrame

Returns:

Expanded composition as a DataFrame.

mckit_nuclides.expand_natural_presence(zaf)[source]

Convert sequence of nuclide-fraction specification with natural presence.

Substitute a sequence of nuclides when mass number is specified as 0. This means natural presence.

Parameters:

zaf (Iterable[tuple[int, int, float]]) – sequence of atomic number, mass number and fraction

Yields:

atomic number, mass_number, and corrected atomic fraction

Return type:

Generator[tuple[int, int, float]]

mckit_nuclides.from_molecular_formula(formula, *, mass_fraction=False)[source]

Create dataframe for material from chemical formula.

Minimalistic parser for chemical formula to define compositions on the fly.

Symbols of elements are to be in capitalized form: Ge, Si…

Parameters:
  • formula (str) – … H20, C2H5OH, etc.

  • mass_fraction (bool) – define mass fractions instead of atomic (default)

Return type:

DataFrame

Examples

>>> print(from_molecular_formula("H2O"))
shape: (2, 2)
┌───────────────┬──────────┐
│ atomic_number ┆ fraction │
│ ---           ┆ ---      │
│ u8            ┆ f64      │
╞═══════════════╪══════════╡
│ 1             ┆ 0.666667 │
│ 8             ┆ 0.333333 │
└───────────────┴──────────┘
>>> print(from_molecular_formula("C2H5OH"))
shape: (3, 2)
┌───────────────┬──────────┐
│ atomic_number ┆ fraction │
│ ---           ┆ ---      │
│ u8            ┆ f64      │
╞═══════════════╪══════════╡
│ 1             ┆ 0.666667 │
│ 6             ┆ 0.222222 │
│ 8             ┆ 0.111111 │
└───────────────┴──────────┘
>>> print(from_molecular_formula("H2O", mass_fraction=True))
shape: (2, 2)
┌───────────────┬──────────┐
│ atomic_number ┆ fraction │
│ ---           ┆ ---      │
│ u8            ┆ f64      │
╞═══════════════╪══════════╡
│ 1             ┆ 0.111907 │
│ 8             ┆ 0.888093 │
└───────────────┴──────────┘
Return type:

DataFrame

Returns:

composition

Parameters:
  • formula (str)

  • mass_fraction (bool)

mckit_nuclides.get_element_property(z_or_symbol, column)

Get column value for an element specified with atomic number or symbol.

Parameters:
  • z_or_symbol (int | str) – define either by atomic number or symbol

  • column (str) – column name in ELEMENTS_TABLE

Raises:

KeyError – if it cannot find the given element.

Return type:

int | float | str | None

Returns:

The column value for the given element.

mckit_nuclides.get_nuclide_mass(z_or_symbol, mass_number)[source]

Retrieve mass of a nuclide by atomic and mass numbers, a.u.

Parameters:
  • z_or_symbol (int | str) – Z or symbol of a nuclide

  • mass_number (int) – A

Return type:

float

Returns:

Mass of the Nuclide (a.u).

mckit_nuclides.get_nuclide_property(z_or_symbol, mass_number, column)

Retrieve mass of a nuclide by atomic and mass numbers, a.u.

Parameters:
  • z_or_symbol (int | str) – Z or symbol of a nuclide

  • mass_number (int) – A

  • column (str) – name of column to extract value from

Raises:

KeyError – if cannot find the given nuclide.

Return type:

int | float | str | None

Returns:

Value of a column for the given nuclide.

mckit_nuclides.normalize_column(table, column='fraction')[source]

Normalize the values in a column to have sum() == 1.0 over the column.

Parameters:
  • table (DataFrame) – … to normalize

  • column (str) – … over this column

Return type:

DataFrame

Returns:

Result of normalization

mckit_nuclides.symbol(_atomic_number)[source]

Get chemical symbol for a given Z (atomic number).

Parameters:

_atomic_number (int) – Z of an element

Returns:

Chemical symbol

Return type:

str

mckit_nuclides.z(_symbol)

Get atomic number (Z) for an element.

Parameters:

_symbol (str) – element by chemical symbol

Returns:

Z - the atomic number for the element.

Return type:

int