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 and OPENMC_MG_CROSS_SECTIONS will be used for multi-group calculations to find the path to the HDF5 cross section file.
  • multipole_library (str) – Indicates the path to a directory containing a windowed multipole cross section library. If it is not set, the OPENMC_MULTIPOLE_LIBRARY environment variable will be used. A multipole library is optional.
add_material(material)[source]

Append material to collection

Deprecated since version 0.8: Use Materials.append() instead.

Parameters:material (openmc.Material) – Material to add
add_materials(materials)[source]

Add multiple materials to the collection

Deprecated since version 0.8: Use compound assignment instead.

Parameters:materials (Iterable of openmc.Material) – Materials to add
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’.
insert(index, material)[source]

Insert material before index

Parameters:
remove_material(material)[source]

Remove a material from the file

Deprecated since version 0.8: Use Materials.remove() instead.

Parameters:material (openmc.Material) – Material to remove