openmc.Universe

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

A collection of cells that can be repeated.

Parameters:
  • 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.
Variables:
  • 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
add_cell(cell)[source]

Add a cell to the universe.

Parameters:cell (openmc.Cell) – Cell to add
add_cells(cells)[source]

Add multiple cells to the universe.

Parameters:cells (Iterable of openmc.Cell) – Cells to add
clear_cells()[source]

Remove all cells from the universe.

find(point)[source]

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
get_all_cells()[source]

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
get_all_materials()[source]

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
get_all_nuclides()[source]

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
get_all_universes()[source]

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
plot(center=(0.0, 0.0, 0.0), width=(1.0, 1.0), pixels=(200, 200), basis='xy', color_by='cell', colors=None, filename=None, seed=None)[source]

Display a slice plot of the universe.

Parameters:
  • center (Iterable of float) – Coordinates at the center 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 or RGBA 4-tuples. 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.))
    
  • filename (str or None) – Filename to save plot to. If no filename is given, the plot will be displayed using the currently enabled matplotlib backend.
  • 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.
remove_cell(cell)[source]

Remove a cell from the universe.

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