openmc.Cell

class openmc.Cell(cell_id=None, name='', fill=None, region=None)[source]

A region of space defined as the intersection of half-space created by quadric surfaces.

Parameters
  • cell_id (int, optional) – Unique identifier for the cell. If not specified, an identifier will automatically be assigned.

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

  • fill (openmc.Material or openmc.UniverseBase or openmc.Lattice or None or iterable of openmc.Material, optional) – Indicates what the region of space is filled with

  • region (openmc.Region, optional) – Region of space that is assigned to the cell.

Variables
  • id (int) – Unique identifier for the cell

  • name (str) – Name of the cell

  • fill (openmc.Material or openmc.UniverseBase or openmc.Lattice or None or iterable of openmc.Material) – Indicates what the region of space is filled with. If None, the cell is treated as a void. An iterable of materials is used to fill repeated instances of a cell with different materials.

  • fill_type ({'material', 'universe', 'lattice', 'distribmat', 'void'}) – Indicates what the cell is filled with.

  • region (openmc.Region or None) – Region of space that is assigned to the cell.

  • rotation (Iterable of float) –

    If the cell is filled with a universe, this array specifies the angles in degrees about the x, y, and z axes that the filled universe should be rotated. The rotation applied is an intrinsic rotation with specified Tait-Bryan angles. That is to say, if the angles are \((\phi, \theta, \psi)\), then the rotation matrix applied is \(R_z(\psi) R_y(\theta) R_x(\phi)\) or

    \[\left [ \begin{array}{ccc} \cos\theta \cos\psi & -\cos\phi \sin\psi + \sin\phi \sin\theta \cos\psi & \sin\phi \sin\psi + \cos\phi \sin\theta \cos\psi \\ \cos\theta \sin\psi & \cos\phi \cos\psi + \sin\phi \sin\theta \sin\psi & -\sin\phi \cos\psi + \cos\phi \sin\theta \sin\psi \\ -\sin\theta & \sin\phi \cos\theta & \cos\phi \cos\theta \end{array} \right ]\]

    A rotation matrix can also be specified directly by setting this attribute to a nested list (or 2D numpy array) that specifies each element of the matrix.

  • rotation_matrix (numpy.ndarray) – The rotation matrix defined by the angles specified in the Cell.rotation property.

  • temperature (float or iterable of float) – Temperature of the cell in Kelvin. Multiple temperatures can be given to give each distributed cell instance a unique temperature.

  • translation (Iterable of float) – If the cell is filled with a universe, this array specifies a vector that is used to translate (shift) the universe.

  • paths (list of str) – The paths traversed through the CSG tree to reach each cell instance. This property is initialized by calling the Geometry.determine_paths() method.

  • num_instances (int) – The number of instances of this cell throughout the geometry.

  • volume (float) – Volume of the cell in cm^3. This can either be set manually or calculated in a stochastic volume calculation and added via the Cell.add_volume_information() method. For ‘distribmat’ cells it is the total volume of all instances.

  • atoms (dict) –

    Mapping of nuclides to the total number of atoms for each nuclide present in the cell, or in all of its instances for a ‘distribmat’ fill. For example, {‘U235’: 1.0e22, ‘U238’: 5.0e22, …}.

    New in version 0.12.

  • bounding_box (openmc.BoundingBox) – Axis-aligned bounding box of the cell

add_volume_information(volume_calc)[source]

Add volume information to a cell.

Parameters

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

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

Create a copy of this cell with a new unique ID, and clones the cell’s region and fill.

Parameters
  • clone_materials (bool) – Whether to create separate copies of the materials filling cells contained in this cell, or the material filling this cell.

  • clone_regions (bool) – Whether to create separate copies of the regions bounding cells contained in this cell, and the region bounding this cell.

  • memo (dict or None) – A nested dictionary of previously cloned objects. This parameter is used internally and should not be specified by the user.

Returns

clone – The clone of this cell

Return type

openmc.Cell

create_xml_subelement(xml_element, memo=None)[source]

Add the cell’s 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 IDs representing geometry entities already written to xml_element. This parameter is used internally and should not be specified by users.

Return type

None

classmethod from_xml_element(elem, surfaces, materials, get_universe)[source]

Generate cell from XML element

Parameters
Returns

Cell instance

Return type

openmc.Cell

get_all_cells(memo=None)[source]

Return all cells that are contained within this one if it is filled with a universe or lattice

Returns

cells – Dictionary whose keys are cell IDs and values are Cell instances

Return type

dict

get_all_materials(memo=None)[source]

Return all materials that are contained within the cell

Returns

materials – Dictionary whose keys are material IDs and values are Material instances

Return type

dict

get_all_universes(memo=None)[source]

Return all universes that are contained within this one if any of its cells are filled with a universe or lattice.

Returns

universes – Dictionary whose keys are universe IDs and values are Universe instances

Return type

dict

get_nuclide_densities()[source]

Return all nuclides contained in the cell and their densities

Returns

nuclides – Dictionary whose keys are nuclide names and values are 2-tuples of (nuclide, density)

Return type

dict

get_nuclides()[source]

Returns all nuclides in the cell

Returns

nuclides – List of nuclide names

Return type

list of str

plot(*args, **kwargs)[source]

Display a slice plot of the cell.

New in version 0.14.0.

Parameters
  • origin (iterable of float) – Coordinates at the origin of the plot. If left as None then the bounding box center will be used to attempt to ascertain the origin. Defaults to (0, 0, 0) if the bounding box is not finite

  • width (iterable of float) – Width of the plot in each basis direction. If left as none then the bounding box width will be used to attempt to ascertain the plot width. Defaults to (10, 10) if the bounding box is not finite

  • 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 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)
    water.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

  • legend (bool) – Whether a legend showing material or cell names should be drawn

  • legend_kwargs (dict) – Keyword arguments passed to matplotlib.pyplot.legend().

  • outline (bool) – Whether outlines between color boundaries should be drawn

  • axis_units ({'km', 'm', 'cm', 'mm'}) – Units used on the plot axis

  • **kwargs – Keyword arguments passed to matplotlib.pyplot.imshow()

Returns

Axes containing resulting image

Return type

matplotlib.axes.Axes