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:default_xs (str) – The default cross section identifier applied to a nuclide when none is specified
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()[source]

Create a materials.xml file that can be used for a simulation.

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