openmc.DAGMCUniverse

class openmc.DAGMCUniverse(filename: str | os.PathLike, universe_id=None, name='', auto_geom_ids=False, auto_mat_ids=False, material_overrides=None)[source]

A reference to a DAGMC file to be used in the model.

New in version 0.13.0.

Parameters
  • filename (str) – Path to the DAGMC file used to represent this universe.

  • universe_id (int, optional) – Unique identifier of the universe. If not specified, an identifier will automatically be assigned.

  • name (str, optional) – Name of the universe. If not specified, the name is the empty string.

  • auto_geom_ids (bool) – Set IDs automatically on initialization (True) or report overlaps in ID space between CSG and DAGMC (False)

  • auto_mat_ids (bool) – Set IDs automatically on initialization (True) or report overlaps in ID space between OpenMC and UWUW materials (False)

  • material_overrides (dict, optional) – A dictionary of material overrides. The keys are material name strings and the values are Iterables of openmc.Material objects. If a material name is found in the DAGMC file, the material will be replaced with the openmc.Material object in the value.

Variables
  • id (int) – Unique identifier of the universe

  • name (str) – Name of the universe

  • filename (str) – Path to the DAGMC file used to represent this universe.

  • auto_geom_ids (bool) – Set IDs automatically on initialization (True) or report overlaps in ID space between CSG and DAGMC (False)

  • auto_mat_ids (bool) – Set IDs automatically on initialization (True) or report overlaps in ID space between OpenMC and UWUW materials (False)

  • bounding_box (openmc.BoundingBox) –

    Lower-left and upper-right coordinates of an axis-aligned bounding box of the universe.

    New in version 0.13.1.

  • material_names (list of str) –

    Return a sorted list of materials names that are contained within the DAGMC h5m file. This is useful when naming openmc.Material() objects as each material name present in the DAGMC h5m file must have a matching openmc.Material() with the same name.

    New in version 0.13.2.

  • n_cells (int) –

    The number of cells in the DAGMC model. This is the number of cells at runtime and accounts for the implicit complement whether or not is it present in the DAGMC file.

    New in version 0.13.2.

  • n_surfaces (int) –

    The number of surfaces in the model.

    New in version 0.13.2.

  • material_overrides (dict) –

    A dictionary of material overrides. Keys are cell IDs; values are iterables of openmc.Material objects. The material assignment of each DAGMC cell ID key will be replaced with the Material object in the value. If the value contains multiple Material objects, each Material in the list will be assigned to the corresponding instance of the cell.

    New in version 0.15.1.

add_cell(cell)[source]

Add a cell to the universe.

Parameters

cell (openmc.DAGMCCell) – Cell to add

add_material_override(key, overrides=None)[source]

Add a material override to the universe.

New in version 0.15.

Parameters
  • key (openmc.DAGMCCell or int) – Cell object or ID of the Cell to override

  • value (openmc.Material or Iterable of openmc.Material) – Material(s) to be applied to the Cell passed as the key

bounded_universe(bounding_cell_id=10000, **kwargs)[source]

Returns an openmc.Universe filled with this DAGMCUniverse and bounded with a cell. Defaults to a box cell with a vacuum surface however this can be changed using the kwargs which are passed directly to DAGMCUniverse.bounding_region().

Parameters

bounding_cell_id (int) – The cell ID number to use for the bounding cell, defaults to 10000 to reduce the chance of overlapping ID numbers with the DAGMC geometry.

Returns

Universe instance

Return type

openmc.Universe

bounding_region(bounded_type: str = 'box', boundary_type: str = 'vacuum', starting_id: int = 10000, padding_distance: float = 0.0)[source]

Creates a either a spherical or box shaped bounding region around the DAGMC geometry.

New in version 0.13.1.

Parameters
  • bounded_type (str) – The type of bounding surface(s) to use when constructing the region. Options include a single spherical surface (sphere) or a rectangle made from six planes (box).

  • boundary_type (str) – Boundary condition that defines the behavior for particles hitting the surface. Defaults to vacuum boundary condition. Passed into the surface construction.

  • starting_id (int) – Starting ID of the surface(s) used in the region. For bounded_type ‘box’, the next 5 IDs will also be used. Defaults to 10000 to reduce the chance of an overlap of surface IDs with the DAGMC geometry.

  • padding_distance (float) – Distance between the bounding region surfaces and the minimal bounding box. Allows for the region to be larger than the DAGMC geometry.

Returns

Region instance

Return type

openmc.Region

create_xml_subelement(xml_element, memo=None)[source]

Add the universe xml representation to an incoming xml element

Parameters
  • xml_element (lxml.etree._Element) – XML element to be added to

  • memo (set or None) – A set of object id’s representing geometry entities already written to the xml_element. This parameter is used internally and should not be specified by users.

Return type

None

classmethod from_hdf5(group)[source]

Create DAGMC universe from HDF5 group

Parameters

group (h5py.Group) – Group in HDF5 file

Returns

DAGMCUniverse instance

Return type

openmc.DAGMCUniverse

classmethod from_xml_element(elem, mats=None)[source]

Generate DAGMC universe from XML element

Parameters
Returns

DAGMCUniverse instance

Return type

openmc.DAGMCUniverse

remove_cell(cell)[source]

Remove a cell from the universe.

Parameters

cell (openmc.Cell) – Cell to remove

replace_material_assignment(material_name: str, material: Material)[source]

Replace a material assignment within the DAGMC universe.

Replace the material assignment of all cells filled with a material in the DAGMC universe. The universe must be synchronized in an initialized Model (see sync_dagmc_cells()) before calling this method.

New in version 0.15.1.

Parameters
  • material_name (str) – Material name to replace

  • material (openmc.Material) – Material to replace the material_name with

sync_dagmc_cells(mats: Iterable[Material])[source]

Synchronize DAGMC cell information between Python and C API

New in version 0.15.1.

Parameters

mats (iterable of openmc.Material) – Iterable of materials to assign to the DAGMC cells