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 andOPENMC_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
- export_to_xml(path: str | os.PathLike = 'materials.xml', nuclides_to_ignore: collections.abc.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 | os.PathLike = 'materials.xml') Materials [source]¶
Generate materials collection from XML file
- Parameters
path (str) – Path to materials XML file
- Returns
Materials collection
- Return type
- 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
- insert(index: int, material)[source]¶
Insert material before index
- Parameters
index (int) – Index in list
material (openmc.Material) – Material to insert