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 (dict) – Dictionary whose keys are cell IDs and values are
Cell
instancesvolume (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 (openmc.BoundingBox) – Lower-left and upper-right coordinates of an axis-aligned bounding box of the universe.
- 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
- 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
- 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
- classmethod from_hdf5(group, cells)[source]¶
Create universe from HDF5 group
- Parameters
group (h5py.Group) – Group in HDF5 file
cells (dict) – Dictionary mapping cell IDs to instances of
openmc.Cell
.
- Returns
Universe instance
- Return type
- get_nuclide_densities()[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
- get_nuclides()[source]¶
Returns all nuclides in the universe
- Returns
nuclides – List of nuclide names
- Return type
list of str
- plot(origin=None, width=None, pixels=40000, basis='xy', color_by='cell', colors=None, seed=None, openmc_exec='openmc', axes=None, legend=False, axis_units='cm', legend_kwargs={'bbox_to_anchor': (1.05, 1), 'borderaxespad': 0.0, 'loc': 2}, outline=False, **kwargs)[source]¶
Display a slice plot of the universe.
- Parameters
origin (iterable of float) – Coordinates at the origin of the plot. If left as None, universe.bounding_box.center will be used to attempt to ascertain the origin with infinite values being replaced by 0.
width (iterable of float) – Width of the plot in each basis direction. If left as none then the universe.bounding_box.width() will be used to attempt to ascertain the plot width. Defaults to (10, 10) if the bounding_box contains inf values
pixels (Iterable of int or int) – If iterable of ints provided then this directly sets the number of pixels to use in each basis direction. If int provided then this sets the total number of pixels in the plot and the number of pixels in each basis direction is calculated from this total and the image aspect ratio.
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
orMaterial
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 (int) – Seed for the random number generator
openmc_exec (str) – Path to OpenMC executable.
axes (matplotlib.Axes) –
Axes to draw to
New in version 0.13.1.
legend (bool) –
Whether a legend showing material or cell names should be drawn
New in version 0.14.0.
legend_kwargs (dict) –
Keyword arguments passed to
matplotlib.pyplot.legend()
.New in version 0.14.0.
outline (bool) –
Whether outlines between color boundaries should be drawn
New in version 0.14.0.
axis_units ({'km', 'm', 'cm', 'mm'}) –
Units used on the plot axis
New in version 0.14.0.
**kwargs – Keyword arguments passed to
matplotlib.pyplot.imshow()
- Returns
Axes containing resulting image
- Return type
- remove_cell(cell)[source]¶
Remove a cell from the universe.
- Parameters
cell (openmc.Cell) – Cell to remove