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
- cross_sections (str) – 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='materials.xml')[source]¶ Export material collection to an XML file.
Parameters: path (str) – Path to file to write. Defaults to ‘materials.xml’.
-
classmethod
from_xml
(path='materials.xml')[source]¶ Generate materials collection from XML file
Parameters: path (str, optional) – Path to materials XML file Returns: Materials collection Return type: openmc.Materials
-
insert
(index, material)[source]¶ Insert material before index
Parameters: - index (int) – Index in list
- material (openmc.Material) – Material to insert