openmc.Materials

class openmc.Materials(materials=None)[source]

Collection of Materials used for an OpenMC simulation.

This class corresponds directly to the materials.xml input file. It can be thought of as a normal Python list where each member is a Material. It behaves like a list as the following example demonstrates:

>>> fuel = openmc.Material()
>>> clad = openmc.Material()
>>> water = openmc.Material()
>>> m = openmc.Materials([fuel])
>>> m.append(water)
>>> m += [clad]
Parameters:

materials (Iterable of openmc.Material) – Materials to add to the collection

Variables:

cross_sections (str or path-like) – Indicates the path to an XML cross section listing file (usually named cross_sections.xml). If it is not set, the OPENMC_CROSS_SECTIONS environment variable will be used for continuous-energy calculations and OPENMC_MG_CROSS_SECTIONS will be used for multi-group calculations to find the path to the HDF5 cross section file.

append(material)[source]

Append material to collection

Parameters:

material (openmc.Material) – Material to append

deplete(multigroup_fluxes: Sequence[Sequence[float]], energy_group_structures: Sequence[Sequence[float] | str], timesteps: Sequence[float] | Sequence[tuple[float, str]], source_rates: float | Sequence[float], timestep_units: str = 's', chain_file: cv.PathLike | 'openmc.deplete.Chain' | None = None, reactions: Sequence[str] | None = None) Dict[int, list[openmc.Material]][source]

Depletes that material, evolving the nuclide densities

Added in version 0.15.3.

Parameters:
  • multigroup_fluxes (Sequence[Sequence[float]]) – Energy-dependent multigroup flux values, where each sublist corresponds to a specific material. Will be normalized so that it sums to 1.

  • energy_group_structures' (Sequence[Sequence[float] | str]) – Energy group boundaries in [eV] or the name of the group structure.

  • timesteps (iterable of float or iterable of tuple) – Array of timesteps. Note that values are not cumulative. The units are specified by the timestep_units argument when timesteps is an iterable of float. Alternatively, units can be specified for each step by passing an iterable of (value, unit) tuples.

  • source_rates (float or iterable of float, optional) – Source rate in [neutron/sec] or neutron flux in [neutron/s-cm^2] for each interval in timesteps

  • timestep_units ({'s', 'min', 'h', 'd', 'a', 'MWd/kg'}) – Units for values specified in the timesteps argument. ‘s’ means seconds, ‘min’ means minutes, ‘h’ means hours, ‘a’ means Julian years and ‘MWd/kg’ indicates that the values are given in burnup (MW-d of energy deposited per kilogram of initial heavy metal).

  • chain_file (PathLike or Chain) – Path to the depletion chain XML file or instance of openmc.deplete.Chain. Defaults to openmc.config['chain_file'].

  • reactions (list of str, optional) – Reactions to get cross sections for. If not specified, all neutron reactions listed in the depletion chain file are used.

Return type:

list of openmc.Material, one for each timestep

export_to_xml(path: str | PathLike = 'materials.xml', nuclides_to_ignore: Iterable[str] | None = None)[source]

Export material collection to an XML file.

Parameters:
  • path (str) – Path to file to write. Defaults to ‘materials.xml’.

  • nuclides_to_ignore (list of str) – Nuclides to ignore when exporting to XML.

classmethod from_xml(path: str | PathLike = 'materials.xml') Materials[source]

Generate materials collection from XML file

Parameters:

path (str) – Path to materials XML file

Returns:

Materials collection

Return type:

openmc.Materials

classmethod from_xml_element(elem) Materials[source]

Generate materials collection from XML file

Parameters:

elem (lxml.etree._Element) – XML element

Returns:

Materials collection

Return type:

openmc.Materials

insert(index: int, material)[source]

Insert material before index

Parameters: