openmc.Region¶
- class openmc.Region[source]¶
Region of space that can be assigned to a cell.
Region is an abstract base class that is inherited by
openmc.Halfspace
,openmc.Intersection
,openmc.Union
, andopenmc.Complement
. Each of those respective classes are typically not instantiated directly but rather are created through operators of the Surface and Region classes.- Variables
bounding_box (openmc.BoundingBox) – Axis-aligned bounding box of the region
- clone(memo=None)[source]¶
Create a copy of this region - each of the surfaces in the region’s nodes will be cloned and will have new unique IDs.
- Parameters
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 region
- Return type
- static from_expression(expression, surfaces)[source]¶
Generate a region given an infix expression.
- Parameters
expression (str) – Boolean expression relating surface half-spaces. The possible operators are union ‘|’, intersection ‘ ‘, and complement ‘~’. For example, ‘(1 -2) | 3 ~(4 -5)’.
surfaces (dict) – Dictionary whose keys are surface IDs that appear in the Boolean expression and whose values are Surface objects.
- get_surfaces(surfaces=None)[source]¶
Recursively find all surfaces referenced by a region and return them
- Parameters
surfaces (dict, optional) – Dictionary mapping surface IDs to
openmc.Surface
instances- Returns
surfaces – Dictionary mapping surface IDs to
openmc.Surface
instances- Return type
- plot(*args, **kwargs)[source]¶
Display a slice plot of the region.
New in version 0.15.0.
- Parameters
origin (iterable of float) – Coordinates at the origin of the plot. If left as None, the center of the bounding box 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 width of the bounding box 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.
axis_units ({'km', 'm', 'cm', 'mm'}) –
Units used on the plot axis
New in version 0.14.0.
Whether outlines between color boundaries should be drawn. If set to ‘only’, only outlines will be drawn.
New in version 0.14.0.
show_overlaps (bool) – Indicate whether or not overlapping regions are shown. Default is False.
overlap_color (Iterable of int or str) – Color to apply to overlapping regions. Default is red.
n_samples (int, optional) – The number of source particles to sample and add to plot. Defaults to None which doesn’t plot any particles on the plot.
plane_tolerance (float) – When plotting a plane the source locations within the plane +/- the plane_tolerance will be included and those outside of the plane_tolerance will not be shown
legend_kwargs (dict) –
Keyword arguments passed to
matplotlib.pyplot.legend()
.New in version 0.14.0.
source_kwargs (dict, optional) – Keyword arguments passed to
matplotlib.pyplot.scatter()
.contour_kwargs (dict, optional) – Keyword arguments passed to
matplotlib.pyplot.contour()
.**kwargs – Keyword arguments passed to
matplotlib.pyplot.imshow()
.
- Returns
Axes containing resulting image
- Return type
- remove_redundant_surfaces(redundant_surfaces)[source]¶
Recursively remove all redundant surfaces referenced by this region
New in version 0.12.
- Parameters
redundant_surfaces (dict) – Dictionary mapping redundant surface IDs to class:openmc.Surface instances that should replace them.
- rotate(rotation, pivot=(0.0, 0.0, 0.0), order='xyz', inplace=False, memo=None)[source]¶
Rotate surface by angles provided or by applying matrix directly.
New in version 0.12.
- Parameters
rotation (3-tuple of float, or 3x3 iterable) – A 3-tuple of angles \((\phi, \theta, \psi)\) in degrees where the first element is the rotation about the x-axis in the fixed laboratory frame, the second element is the rotation about the y-axis in the fixed laboratory frame, and the third element is the rotation about the z-axis in the fixed laboratory frame. The rotations are active rotations. Additionally a 3x3 rotation matrix can be specified directly either as a nested iterable or array.
pivot (iterable of float, optional) – (x, y, z) coordinates for the point to rotate about. Defaults to (0., 0., 0.)
order (str, optional) – A string of ‘x’, ‘y’, and ‘z’ in some order specifying which rotation to perform first, second, and third. Defaults to ‘xyz’ which means, the rotation by angle \(\phi\) about x will be applied first, followed by \(\theta\) about y and then \(\psi\) about z. This corresponds to an x-y-z extrinsic rotation as well as a z-y’-x’’ intrinsic rotation using Tait-Bryan angles \((\phi, \theta, \psi)\).
inplace (bool) – Whether or not to return a new instance of Surface or to modify the coefficients of this Surface in place. Defaults to False.
memo (dict or None) – Dictionary used for memoization
- Returns
Translated region
- Return type
- translate(vector, inplace=False, memo=None)[source]¶
Translate region in given direction
- Parameters
vector (iterable of float) – Direction in which region should be translated
inplace (bool) –
Whether or not to return a region based on new surfaces or one based on the original surfaces that have been modified.
New in version 0.13.1.
memo (dict or None) – Dictionary used for memoization. This parameter is used internally and should not be specified by the user.
- Returns
Translated region
- Return type