class openmc.Universe(universe_id=None, name='', cells=None)[source]

A collection of cells that can be repeated.

  • 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.
  • cells (Iterable of openmc.Cell, optional) – Cells to add to the universe. By default no cells are added.
  • id (int) – Unique identifier of the universe
  • name (str) – Name of the universe
  • cells (collections.OrderedDict) – Dictionary whose keys are cell IDs and values are Cell instances
  • volume (float) – Volume of the universe in cm^3. This can either be set manually or calculated in a stochastic volume calculation and added via the Universe.add_volume_information() method.
  • bounding_box (2-tuple of numpy.array) – Lower-left and upper-right coordinates of an axis-aligned bounding box of the universe.

Add a cell to the universe.

Parameters:cell (openmc.Cell) – Cell to add

Add multiple cells to the universe.

Parameters:cells (Iterable of openmc.Cell) – Cells to add

Add volume information to a universe.

Parameters:volume_calc (openmc.VolumeCalculation) – Results from a stochastic volume calculation

Remove all cells from the universe.

clone(clone_materials=True, clone_regions=True, memo=None)[source]

Create a copy of this universe with a new unique ID, and clones all cells within this universe.

  • clone_materials (bool) – Whether to create separates copies of the materials filling cells contained in this universe.
  • clone_regions (bool) – Whether to create separates copies of the regions bounding cells contained in this universe.
  • memo (dict or None) – A nested dictionary of previously cloned objects. This parameter is used internally and should not be specified by the user.

clone – The clone of this universe

Return type:


create_xml_subelement(xml_element, memo=None)[source]

Add the universe xml representation to an incoming xml element

  • xml_element (xml.etree.ElementTree.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:



Find cells/universes/lattices which contain a given point

Parameters:point (3-tuple of float) – Cartesian coordinates of the point
Returns:Sequence of universes, cells, and lattices which are traversed to find the given point
Return type:list
classmethod from_hdf5(group, cells)[source]

Create universe from HDF5 group

  • group (h5py.Group) – Group in HDF5 file
  • cells (dict) – Dictionary mapping cell IDs to instances of openmc.Cell.

Universe instance

Return type:



Return all cells that are contained within the universe

Returns:cells – Dictionary whose keys are cell IDs and values are Cell instances
Return type:collections.OrderedDict

Return all materials that are contained within the universe

Returns:materials – Dictionary whose keys are material IDs and values are Material instances
Return type:collections.OrderedDict

Return all universes that are contained within this one.

Returns:universes – Dictionary whose keys are universe IDs and values are Universe instances
Return type:collections.OrderedDict

Return all nuclides contained in the universe

Returns:nuclides – Dictionary whose keys are nuclide names and values are 2-tuples of (nuclide, density)
Return type:collections.OrderedDict

Returns all nuclides in the universe

Returns:nuclides – List of nuclide names
Return type:list of str
plot(origin=(0.0, 0.0, 0.0), width=(1.0, 1.0), pixels=(200, 200), basis='xy', color_by='cell', colors=None, seed=None, **kwargs)[source]

Display a slice plot of the universe.

To display or save the plot, call or matplotlib.pyplot.savefig(). In a Jupyter notebook, enabling the matplotlib inline backend will show the plot inline.

  • origin (Iterable of float) – Coordinates at the origin of the plot
  • width (Iterable of float) – Width of the plot in each basis direction
  • pixels (Iterable of int) – Number of pixels to use in each basis direction
  • basis ({'xy', 'xz', 'yz'}) – The basis directions for the plot
  • color_by ({'cell', 'material'}) – Indicate whether the plot should be colored by cell or by material
  • colors (dict) –

    Assigns colors to specific materials or cells. Keys are instances of Cell or Material and values are RGB 3-tuples, RGBA 4-tuples, or strings indicating SVG color names. Red, green, blue, and alpha should all be floats in the range [0.0, 1.0], for example:

    # Make water blue
    water = openmc.Cell(fill=h2o)
    universe.plot(..., colors={water: (0., 0., 1.))
  • seed (hashable object or None) – Hashable object which is used to seed the random number generator used to select colors. If None, the generator is seeded from the current time.
  • **kwargs – All keyword arguments are passed to matplotlib.pyplot.imshow().

Resulting image

Return type:



Remove a cell from the universe.

Parameters:cell (openmc.Cell) – Cell to remove