diff --git a/docs/source/pythonapi/model.rst b/docs/source/pythonapi/model.rst
index c9c6e117a..99459f64d 100644
--- a/docs/source/pythonapi/model.rst
+++ b/docs/source/pythonapi/model.rst
@@ -11,8 +11,6 @@ Convenience Functions
:template: myfunction.rst
openmc.model.borated_water
- openmc.model.hexagonal_prism
- openmc.model.rectangular_prism
openmc.model.subdivide
openmc.model.pin
@@ -26,9 +24,11 @@ Composite Surfaces
openmc.model.CruciformPrism
openmc.model.CylinderSector
+ openmc.model.HexagonalPrism
openmc.model.IsogonalOctagon
openmc.model.Polygon
openmc.model.RectangularParallelepiped
+ openmc.model.RectangularPrism
openmc.model.RightCircularCylinder
openmc.model.XConeOneSided
openmc.model.YConeOneSided
diff --git a/docs/source/usersguide/geometry.rst b/docs/source/usersguide/geometry.rst
index 379642996..3a3d02231 100644
--- a/docs/source/usersguide/geometry.rst
+++ b/docs/source/usersguide/geometry.rst
@@ -147,12 +147,13 @@ For many regions, a bounding-box can be determined automatically::
While a bounding box can be determined for regions involving half-spaces of
spheres, cylinders, and axis-aligned planes, it generally cannot be determined
if the region involves cones, non-axis-aligned planes, or other exotic
-second-order surfaces. For example, the :func:`openmc.model.hexagonal_prism`
-function returns the interior region of a hexagonal prism; because it is bounded
-by a :class:`openmc.Plane`, trying to get its bounding box won't work::
+second-order surfaces. For example, the :class:`openmc.model.HexagonalPrism`
+class returns a hexagonal prism surface; because it utilizes a
+:class:`openmc.Plane`, trying to get the bounding box of its interior won't
+work::
- >>> hex = openmc.model.hexagonal_prism()
- >>> hex.bounding_box
+ >>> hex = openmc.model.HexagonalPrism()
+ >>> (-hex).bounding_box
(array([-0.8660254, -inf, -inf]),
array([ 0.8660254, inf, inf]))
@@ -428,7 +429,7 @@ code would work::
hexlat.universes = [outer_ring, middle_ring, inner_ring]
If you need to create a hexagonal boundary (composed of six planar surfaces) for
-a hexagonal lattice, :func:`openmc.model.hexagonal_prism` can be used.
+a hexagonal lattice, :class:`openmc.model.HexagonalPrism` can be used.
.. _usersguide_geom_export:
diff --git a/examples/assembly/assembly.py b/examples/assembly/assembly.py
index 1355374f1..a370a3611 100644
--- a/examples/assembly/assembly.py
+++ b/examples/assembly/assembly.py
@@ -99,11 +99,11 @@ def assembly_model():
assembly.universes[gt_pos[:, 0], gt_pos[:, 1]] = guide_tube_pin()
# Create outer boundary of the geometry to surround the lattice
- outer_boundary = openmc.model.rectangular_prism(
+ outer_boundary = openmc.model.RectangularPrism(
pitch, pitch, boundary_type='reflective')
# Create a cell filled with the lattice
- main_cell = openmc.Cell(fill=assembly, region=outer_boundary)
+ main_cell = openmc.Cell(fill=assembly, region=-outer_boundary)
# Finally, create geometry by providing a list of cells that fill the root
# universe
diff --git a/examples/custom_source/build_xml.py b/examples/custom_source/build_xml.py
index 6db136216..ff6dae2bb 100644
--- a/examples/custom_source/build_xml.py
+++ b/examples/custom_source/build_xml.py
@@ -8,8 +8,8 @@ mats = openmc.Materials([iron])
mats.export_to_xml()
# Create a 5 cm x 5 cm box filled with iron
-box = openmc.model.rectangular_prism(10.0, 10.0, boundary_type='vacuum')
-cell = openmc.Cell(fill=iron, region=box)
+box = openmc.model.RectangularPrism(10.0, 10.0, boundary_type='vacuum')
+cell = openmc.Cell(fill=iron, region=-box)
geometry = openmc.Geometry([cell])
geometry.export_to_xml()
diff --git a/examples/parameterized_custom_source/build_xml.py b/examples/parameterized_custom_source/build_xml.py
index 23d9930c0..5ac6bf928 100644
--- a/examples/parameterized_custom_source/build_xml.py
+++ b/examples/parameterized_custom_source/build_xml.py
@@ -8,8 +8,8 @@ mats = openmc.Materials([iron])
mats.export_to_xml()
# Create a 5 cm x 5 cm box filled with iron
-box = openmc.model.rectangular_prism(10.0, 10.0, boundary_type='vacuum')
-cell = openmc.Cell(fill=iron, region=box)
+box = openmc.model.RectangularPrism(10.0, 10.0, boundary_type='vacuum')
+cell = openmc.Cell(fill=iron, region=-box)
geometry = openmc.Geometry([cell])
geometry.export_to_xml()
diff --git a/examples/pincell/build_xml.py b/examples/pincell/build_xml.py
index cd8923fbe..d008c8822 100644
--- a/examples/pincell/build_xml.py
+++ b/examples/pincell/build_xml.py
@@ -43,13 +43,13 @@ clad_or = openmc.ZCylinder(r=0.45720, name='Clad OR')
# Create a region represented as the inside of a rectangular prism
pitch = 1.25984
-box = openmc.rectangular_prism(pitch, pitch, boundary_type='reflective')
+box = openmc.model.RectangularPrism(pitch, pitch, boundary_type='reflective')
# Create cells, mapping materials to regions
fuel = openmc.Cell(fill=uo2, region=-fuel_or)
gap = openmc.Cell(fill=helium, region=+fuel_or & -clad_ir)
clad = openmc.Cell(fill=zircaloy, region=+clad_ir & -clad_or)
-water = openmc.Cell(fill=borated_water, region=+clad_or & box)
+water = openmc.Cell(fill=borated_water, region=+clad_or & -box)
# Create a geometry and export to XML
geometry = openmc.Geometry([fuel, gap, clad, water])
diff --git a/examples/pincell_depletion/run_depletion.py b/examples/pincell_depletion/run_depletion.py
index 493e31178..e1959938f 100644
--- a/examples/pincell_depletion/run_depletion.py
+++ b/examples/pincell_depletion/run_depletion.py
@@ -41,13 +41,13 @@ pitch = 1.25984
fuel_or = openmc.ZCylinder(r=0.39218, name='Fuel OR')
clad_ir = openmc.ZCylinder(r=0.40005, name='Clad IR')
clad_or = openmc.ZCylinder(r=0.45720, name='Clad OR')
-box = openmc.model.rectangular_prism(pitch, pitch, boundary_type='reflective')
+box = openmc.model.RectangularPrism(pitch, pitch, boundary_type='reflective')
# Define cells
fuel = openmc.Cell(fill=uo2, region=-fuel_or)
gap = openmc.Cell(fill=helium, region=+fuel_or & -clad_ir)
clad = openmc.Cell(fill=zircaloy, region=+clad_ir & -clad_or)
-water = openmc.Cell(fill=borated_water, region=+clad_or & box)
+water = openmc.Cell(fill=borated_water, region=+clad_or & -box)
# Define overall geometry
geometry = openmc.Geometry([fuel, gap, clad, water])
diff --git a/examples/pincell_multigroup/build_xml.py b/examples/pincell_multigroup/build_xml.py
index 48671698d..019ae6a11 100644
--- a/examples/pincell_multigroup/build_xml.py
+++ b/examples/pincell_multigroup/build_xml.py
@@ -90,11 +90,11 @@ fuel_or = openmc.ZCylinder(r=0.54, name='Fuel OR')
# Create a region represented as the inside of a rectangular prism
pitch = 1.26
-box = openmc.rectangular_prism(pitch, pitch, boundary_type='reflective')
+box = openmc.model.RectangularPrism(pitch, pitch, boundary_type='reflective')
# Instantiate Cells
fuel = openmc.Cell(fill=uo2, region=-fuel_or, name='fuel')
-moderator = openmc.Cell(fill=water, region=+fuel_or & box, name='moderator')
+moderator = openmc.Cell(fill=water, region=+fuel_or & -box, name='moderator')
# Create a geometry with the two cells and export to XML
geometry = openmc.Geometry([fuel, moderator])
diff --git a/openmc/__init__.py b/openmc/__init__.py
index 7da055d6e..03d373121 100644
--- a/openmc/__init__.py
+++ b/openmc/__init__.py
@@ -36,7 +36,7 @@ from . import examples
from .config import *
# Import a few names from the model module
-from openmc.model import rectangular_prism, hexagonal_prism, Model
+from openmc.model import Model
__version__ = '0.14.0-dev'
diff --git a/openmc/model/funcs.py b/openmc/model/funcs.py
index d185c13df..815d03829 100644
--- a/openmc/model/funcs.py
+++ b/openmc/model/funcs.py
@@ -1,11 +1,10 @@
from collections.abc import Iterable
-from functools import partial
from math import sqrt
-from numbers import Real
from operator import attrgetter
from warnings import warn
-from openmc import Plane, Cylinder, Universe, Cell
+from openmc import Cylinder, Universe, Cell
+from .surface_composite import RectangularPrism, HexagonalPrism
from ..checkvalue import (check_type, check_value, check_length,
check_less_than, check_iterable_type)
import openmc.data
@@ -108,299 +107,26 @@ def borated_water(boron_ppm, temperature=293., pressure=0.1013, temp_unit='K',
return out
-# Define function to create a plane on given axis
-def _plane(axis, name, value, boundary_type='transmission', albedo=1.):
- cls = getattr(openmc, f'{axis.upper()}Plane')
- return cls(value, name=f'{name} {axis}',
- boundary_type=boundary_type,
- albedo=albedo)
def rectangular_prism(width, height, axis='z', origin=(0., 0.),
- boundary_type='transmission', albedo=1.,
- corner_radius=0.):
- """Get an infinite rectangular prism from four planar surfaces.
-
- .. versionchanged:: 0.11
- This function was renamed from `get_rectangular_prism` to
- `rectangular_prism`.
-
- Parameters
- ----------
- width: float
- Prism width in units of cm. The width is aligned with the y, x,
- or x axes for prisms parallel to the x, y, or z axis, respectively.
- height: float
- Prism height in units of cm. The height is aligned with the z, z,
- or y axes for prisms parallel to the x, y, or z axis, respectively.
- axis : {'x', 'y', 'z'}
- Axis with which the infinite length of the prism should be aligned.
- Defaults to 'z'.
- origin: Iterable of two floats
- Origin of the prism. The two floats correspond to (y,z), (x,z) or
- (x,y) for prisms parallel to the x, y or z axis, respectively.
- Defaults to (0., 0.).
- boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}
- Boundary condition that defines the behavior for particles hitting the
- surfaces comprising the rectangular prism (default is 'transmission').
- albedo : float, optional
- Albedo of the prism's surfaces as a ratio of particle weight after
- interaction with the surface to the initial weight. Values must be
- positive. Only applicable if the boundary type is 'reflective',
- 'periodic', or 'white'.
- corner_radius: float
- Prism corner radius in units of cm. Defaults to 0.
-
- Returns
- -------
- openmc.Region
- The inside of a rectangular prism
-
- """
-
- check_type('width', width, Real)
- check_type('height', height, Real)
- check_type('albedo', albedo, Real)
- check_type('corner_radius', corner_radius, Real)
- check_value('axis', axis, ['x', 'y', 'z'])
- check_type('origin', origin, Iterable, Real)
-
- if axis == 'x':
- x1, x2 = 'y', 'z'
- elif axis == 'y':
- x1, x2 = 'x', 'z'
- else:
- x1, x2 = 'x', 'y'
-
- # Get cylinder class corresponding to given axis
- cyl = getattr(openmc, f'{axis.upper()}Cylinder')
-
- # Create container for boundary arguments
- bc_args = {'boundary_type': boundary_type, 'albedo': albedo}
-
- # Create rectangular region
- min_x1 = _plane(x1, 'minimum', -width/2 + origin[0], **bc_args)
- max_x1 = _plane(x1, 'maximum', width/2 + origin[0], **bc_args)
- min_x2 = _plane(x2, 'minimum', -height/2 + origin[1], **bc_args)
- max_x2 = _plane(x2, 'maximum', height/2 + origin[1], **bc_args)
- if boundary_type == 'periodic':
- min_x1.periodic_surface = max_x1
- min_x2.periodic_surface = max_x2
- prism = +min_x1 & -max_x1 & +min_x2 & -max_x2
-
- # Handle rounded corners if given
- if corner_radius > 0.:
- if boundary_type == 'periodic':
- raise ValueError('Periodic boundary conditions not permitted when '
- 'rounded corners are used.')
-
- args = {'r': corner_radius, 'boundary_type': boundary_type, 'albedo' : albedo}
-
- args[x1 + '0'] = origin[0] - width/2 + corner_radius
- args[x2 + '0'] = origin[1] - height/2 + corner_radius
- x1_min_x2_min = cyl(name='{} min {} min'.format(x1, x2), **args)
-
- args[x1 + '0'] = origin[0] - width/2 + corner_radius
- args[x2 + '0'] = origin[1] - height/2 + corner_radius
- x1_min_x2_min = cyl(name='{} min {} min'.format(x1, x2), **args)
-
- args[x1 + '0'] = origin[0] - width/2 + corner_radius
- args[x2 + '0'] = origin[1] + height/2 - corner_radius
- x1_min_x2_max = cyl(name='{} min {} max'.format(x1, x2), **args)
-
- args[x1 + '0'] = origin[0] + width/2 - corner_radius
- args[x2 + '0'] = origin[1] - height/2 + corner_radius
- x1_max_x2_min = cyl(name='{} max {} min'.format(x1, x2), **args)
-
- args[x1 + '0'] = origin[0] + width/2 - corner_radius
- args[x2 + '0'] = origin[1] + height/2 - corner_radius
- x1_max_x2_max = cyl(name='{} max {} max'.format(x1, x2), **args)
-
- x1_min = _plane(x1, 'min', -width/2 + origin[0] + corner_radius,
- **bc_args)
- x1_max = _plane(x1, 'max', width/2 + origin[0] - corner_radius,
- **bc_args)
- x2_min = _plane(x2, 'min', -height/2 + origin[1] + corner_radius,
- **bc_args)
- x2_max = _plane(x2, 'max', height/2 + origin[1] - corner_radius,
- **bc_args)
-
- corners = (+x1_min_x2_min & -x1_min & -x2_min) | \
- (+x1_min_x2_max & -x1_min & +x2_max) | \
- (+x1_max_x2_min & +x1_max & -x2_min) | \
- (+x1_max_x2_max & +x1_max & +x2_max)
-
- prism = prism & ~corners
-
- return prism
-
-
-def get_rectangular_prism(*args, **kwargs):
- warn("get_rectangular_prism(...) has been renamed rectangular_prism(...). "
- "Future versions of OpenMC will not accept get_rectangular_prism.",
- FutureWarning)
- return rectangular_prism(*args, **kwargs)
+ boundary_type='transmission', corner_radius=0.):
+ warn("The rectangular_prism(...) function has been replaced by the "
+ "RectangularPrism(...) class. Future versions of OpenMC will not "
+ "accept rectangular_prism.", FutureWarning)
+ return -RectangularPrism(
+ width=width, height=height, axis=axis, origin=origin,
+ boundary_type=boundary_type, corner_radius=corner_radius)
def hexagonal_prism(edge_length=1., orientation='y', origin=(0., 0.),
- boundary_type='transmission', albedo=1., corner_radius=0.):
- """Create a hexagon region from six surface planes.
-
- .. versionchanged:: 0.11
- This function was renamed from `get_hexagonal_prism` to
- `hexagonal_prism`.
-
- Parameters
- ----------
- edge_length : float
- Length of a side of the hexagon in cm
- orientation : {'x', 'y'}
- An 'x' orientation means that two sides of the hexagon are parallel to
- the x-axis and a 'y' orientation means that two sides of the hexagon are
- parallel to the y-axis.
- origin: Iterable of two floats
- Origin of the prism. Defaults to (0., 0.).
- boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}
- Boundary condition that defines the behavior for particles hitting the
- surfaces comprising the hexagonal prism (default is 'transmission').
- albedo : float, optional
- Albedo of the prism's surfaces as a ratio of particle weight after
- interaction with the surface to the initial weight. Values must be
- positive. Only applicable if the boundary type is 'reflective',
- 'periodic', or 'white'.
- corner_radius: float
- Prism corner radius in units of cm. Defaults to 0.
-
- Returns
- -------
- openmc.Region
- The inside of a hexagonal prism
-
- """
-
- check_type('edge_length', edge_length, Real)
- check_type('albedo', albedo, Real)
- check_type('corner_radius', corner_radius, Real)
- check_value('orientation', orientation, ['x', 'y'])
- check_type('origin', origin, Iterable, Real)
-
- l = edge_length
- x, y = origin
-
-
- # Create container for boundary arguments
- bc_args = {'boundary_type': boundary_type, 'albedo' : albedo}
-
- if orientation == 'y':
- right = openmc.XPlane(x + sqrt(3.)/2*l, **bc_args)
- left = openmc.XPlane(x - sqrt(3.)/2*l, **bc_args)
- c = sqrt(3.)/3.
-
- # y = -x/sqrt(3) + a
- upper_right = Plane(a=c, b=1., d=l+x*c+y, **bc_args)
-
- # y = x/sqrt(3) + a
- upper_left = Plane(a=-c, b=1., d=l-x*c+y, **bc_args)
-
- # y = x/sqrt(3) - a
- lower_right = Plane(a=-c, b=1., d=-l-x*c+y, **bc_args)
-
- # y = -x/sqrt(3) - a
- lower_left = Plane(a=c, b=1., d=-l+x*c+y, **bc_args)
-
- prism = -right & +left & -upper_right & -upper_left & \
- +lower_right & +lower_left
-
- if boundary_type == 'periodic':
- right.periodic_surface = left
- upper_right.periodic_surface = lower_left
- lower_right.periodic_surface = upper_left
-
- elif orientation == 'x':
- top = openmc.YPlane(y0=y + sqrt(3.)/2*l, **bc_args)
- bottom = openmc.YPlane(y0=y - sqrt(3.)/2*l, **bc_args)
- c = sqrt(3.)
-
- # y = -sqrt(3)*(x - a)
- upper_right = Plane(a=c, b=1., d=c*l+x*c+y, **bc_args)
-
- # y = sqrt(3)*(x + a)
- lower_right = Plane(a=-c, b=1., d=-c*l-x*c+y, **bc_args)
-
- # y = -sqrt(3)*(x + a)
- lower_left = Plane(a=c, b=1., d=-c*l+x*c+y, **bc_args)
-
- # y = sqrt(3)*(x + a)
- upper_left = Plane(a=-c, b=1., d=c*l-x*c+y, **bc_args)
-
- prism = -top & +bottom & -upper_right & +lower_right & \
- +lower_left & -upper_left
-
- if boundary_type == 'periodic':
- top.periodic_surface = bottom
- upper_right.periodic_surface = lower_left
- lower_right.periodic_surface = upper_left
-
- # Handle rounded corners if given
- if corner_radius > 0.:
- if boundary_type == 'periodic':
- raise ValueError('Periodic boundary conditions not permitted when '
- 'rounded corners are used.')
-
- c = sqrt(3.)/2
- t = l - corner_radius/c
-
- # Cylinder with corner radius and boundary conditions pre-applied
- cyl1 = partial(openmc.ZCylinder, r=corner_radius, **bc_args)
- cyl2 = partial(openmc.ZCylinder, r=corner_radius/(2*c), **bc_args)
-
- if orientation == 'x':
- x_min_y_min_in = cyl1(name='x min y min in', x0=x-t/2, y0=y-c*t)
- x_min_y_max_in = cyl1(name='x min y max in', x0=x+t/2, y0=y-c*t)
- x_max_y_min_in = cyl1(name='x max y min in', x0=x-t/2, y0=y+c*t)
- x_max_y_max_in = cyl1(name='x max y max in', x0=x+t/2, y0=y+c*t)
- x_min_in = cyl1(name='x min in', x0=x-t, y0=y)
- x_max_in = cyl1(name='x max in', x0=x+t, y0=y)
-
- x_min_y_min_out = cyl2(name='x min y min out', x0=x-l/2, y0=y-c*l)
- x_min_y_max_out = cyl2(name='x min y max out', x0=x+l/2, y0=y-c*l)
- x_max_y_min_out = cyl2(name='x max y min out', x0=x-l/2, y0=y+c*l)
- x_max_y_max_out = cyl2(name='x max y max out', x0=x+l/2, y0=y+c*l)
- x_min_out = cyl2(name='x min out', x0=x-l, y0=y)
- x_max_out = cyl2(name='x max out', x0=x+l, y0=y)
-
- corners = (+x_min_y_min_in & -x_min_y_min_out |
- +x_min_y_max_in & -x_min_y_max_out |
- +x_max_y_min_in & -x_max_y_min_out |
- +x_max_y_max_in & -x_max_y_max_out |
- +x_min_in & -x_min_out |
- +x_max_in & -x_max_out)
-
- elif orientation == 'y':
- x_min_y_min_in = cyl1(name='x min y min in', x0=x-c*t, y0=y-t/2)
- x_min_y_max_in = cyl1(name='x min y max in', x0=x-c*t, y0=y+t/2)
- x_max_y_min_in = cyl1(name='x max y min in', x0=x+c*t, y0=y-t/2)
- x_max_y_max_in = cyl1(name='x max y max in', x0=x+c*t, y0=y+t/2)
- y_min_in = cyl1(name='y min in', x0=x, y0=y-t)
- y_max_in = cyl1(name='y max in', x0=x, y0=y+t)
-
- x_min_y_min_out = cyl2(name='x min y min out', x0=x-c*l, y0=y-l/2)
- x_min_y_max_out = cyl2(name='x min y max out', x0=x-c*l, y0=y+l/2)
- x_max_y_min_out = cyl2(name='x max y min out', x0=x+c*l, y0=y-l/2)
- x_max_y_max_out = cyl2(name='x max y max out', x0=x+c*l, y0=y+l/2)
- y_min_out = cyl2(name='y min out', x0=x, y0=y-l)
- y_max_out = cyl2(name='y max out', x0=x, y0=y+l)
-
- corners = (+x_min_y_min_in & -x_min_y_min_out |
- +x_min_y_max_in & -x_min_y_max_out |
- +x_max_y_min_in & -x_max_y_min_out |
- +x_max_y_max_in & -x_max_y_max_out |
- +y_min_in & -y_min_out |
- +y_max_in & -y_max_out)
-
- prism = prism & ~corners
-
- return prism
+ boundary_type='transmission', corner_radius=0.):
+ warn("The hexagonal_prism(...) function has been replaced by the "
+ "HexagonalPrism(...) class. Future versions of OpenMC will not "
+ "accept hexagonal_prism.", FutureWarning)
+ return -HexagonalPrism(
+ edge_length=edge_length, orientation=orientation, origin=origin,
+ boundary_type=boundary_type, corner_radius=corner_radius)
def get_hexagonal_prism(*args, **kwargs):
diff --git a/openmc/model/surface_composite.py b/openmc/model/surface_composite.py
index 918bd8444..eb5a7e740 100644
--- a/openmc/model/surface_composite.py
+++ b/openmc/model/surface_composite.py
@@ -1,8 +1,12 @@
from abc import ABC, abstractmethod
+from collections.abc import Iterable
from copy import copy
+from functools import partial
from math import sqrt, pi, sin, cos, isclose
+from numbers import Real
import warnings
import operator
+from typing import Sequence
import numpy as np
from scipy.spatial import ConvexHull, Delaunay
@@ -50,13 +54,13 @@ class CompositeSurface(ABC):
"""Iterable of attribute names corresponding to underlying surfaces."""
@abstractmethod
- def __pos__(self):
- """Return the positive half-space of the composite surface."""
-
- @abstractmethod
- def __neg__(self):
+ def __neg__(self) -> openmc.Region:
"""Return the negative half-space of the composite surface."""
+ def __pos__(self) -> openmc.Region:
+ """Return the positive half-space of the composite surface."""
+ return ~(-self)
+
class CylinderSector(CompositeSurface):
"""Infinite cylindrical sector composite surface.
@@ -836,9 +840,6 @@ class Polygon(CompositeSurface):
def __neg__(self):
return self._region
- def __pos__(self):
- return ~self._region
-
@property
def _surface_names(self):
return self._surfnames
@@ -1309,5 +1310,295 @@ class CruciformPrism(CompositeSurface):
)
return openmc.Union(regions)
- def __pos__(self):
- return ~(-self)
+
+# Define function to create a plane on given axis
+def _plane(axis, name, value, boundary_type='transmission', albedo=1.0):
+ cls = getattr(openmc, f'{axis.upper()}Plane')
+ return cls(value, name=f'{name} {axis}',
+ boundary_type=boundary_type, albedo=albedo)
+
+
+class RectangularPrism(CompositeSurface):
+ """Infinite rectangular prism bounded by four planar surfaces.
+
+ .. versionadded:: 0.13.4
+
+ Parameters
+ ----------
+ width : float
+ Prism width in units of [cm]. The width is aligned with the x, x, or z
+ axes for prisms parallel to the x, y, or z axis, respectively.
+ height : float
+ Prism height in units of [cm]. The height is aligned with the x, y, or z
+ axes for prisms parallel to the x, y, or z axis, respectively.
+ axis : {'x', 'y', 'z'}
+ Axis with which the infinite length of the prism should be aligned.
+ origin : Iterable of two floats
+ Origin of the prism. The two floats correspond to (y,z), (x,z) or (x,y)
+ for prisms parallel to the x, y or z axis, respectively.
+ boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}
+ Boundary condition that defines the behavior for particles hitting the
+ surfaces comprising the rectangular prism.
+ albedo : float, optional
+ Albedo of the prism's surfaces as a ratio of particle weight after
+ interaction with the surface to the initial weight. Values must be
+ positive. Only applicable if the boundary type is 'reflective',
+ 'periodic', or 'white'.
+ corner_radius : float
+ Prism corner radius in units of [cm].
+
+ """
+ _surface_names = ('min_x1', 'max_x1', 'min_x2', 'max_x2')
+
+ def __init__(
+ self,
+ width: float,
+ height: float,
+ axis: str = 'z',
+ origin: Sequence[float] = (0., 0.),
+ boundary_type: str = 'transmission',
+ albedo: float = 1.,
+ corner_radius: float = 0.
+ ):
+ check_type('width', width, Real)
+ check_type('height', height, Real)
+ check_type('albedo', albedo, Real)
+ check_type('corner_radius', corner_radius, Real)
+ check_value('axis', axis, ('x', 'y', 'z'))
+ check_type('origin', origin, Iterable, Real)
+
+ if axis == 'x':
+ x1, x2 = 'y', 'z'
+ elif axis == 'y':
+ x1, x2 = 'x', 'z'
+ else:
+ x1, x2 = 'x', 'y'
+
+ # Get cylinder class corresponding to given axis
+ cyl = getattr(openmc, f'{axis.upper()}Cylinder')
+
+ # Create container for boundary arguments
+ bc_args = {'boundary_type': boundary_type, 'albedo': albedo}
+
+ # Create rectangular region
+ self.min_x1 = _plane(x1, 'minimum', -width/2 + origin[0], **bc_args)
+ self.max_x1 = _plane(x1, 'maximum', width/2 + origin[0], **bc_args)
+ self.min_x2 = _plane(x2, 'minimum', -height/2 + origin[1], **bc_args)
+ self.max_x2 = _plane(x2, 'maximum', height/2 + origin[1], **bc_args)
+ if boundary_type == 'periodic':
+ self.min_x1.periodic_surface = self.max_x1
+ self.min_x2.periodic_surface = self.max_x2
+
+ # Handle rounded corners if given
+ if corner_radius > 0.:
+ if boundary_type == 'periodic':
+ raise ValueError('Periodic boundary conditions not permitted when '
+ 'rounded corners are used.')
+
+ args = {'r': corner_radius, 'boundary_type': boundary_type, 'albedo': albedo}
+
+ args[x1 + '0'] = origin[0] - width/2 + corner_radius
+ args[x2 + '0'] = origin[1] - height/2 + corner_radius
+ self.x1_min_x2_min = cyl(name=f'{x1} min {x2} min', **args)
+
+ args[x1 + '0'] = origin[0] - width/2 + corner_radius
+ args[x2 + '0'] = origin[1] + height/2 - corner_radius
+ self.x1_min_x2_max = cyl(name=f'{x1} min {x2} max', **args)
+
+ args[x1 + '0'] = origin[0] + width/2 - corner_radius
+ args[x2 + '0'] = origin[1] - height/2 + corner_radius
+ self.x1_max_x2_min = cyl(name=f'{x1} max {x2} min', **args)
+
+ args[x1 + '0'] = origin[0] + width/2 - corner_radius
+ args[x2 + '0'] = origin[1] + height/2 - corner_radius
+ self.x1_max_x2_max = cyl(name=f'{x1} max {x2} max', **args)
+
+ self.x1_min = _plane(x1, 'min', -width/2 + origin[0] + corner_radius,
+ **bc_args)
+ self.x1_max = _plane(x1, 'max', width/2 + origin[0] - corner_radius,
+ **bc_args)
+ self.x2_min = _plane(x2, 'min', -height/2 + origin[1] + corner_radius,
+ **bc_args)
+ self.x2_max = _plane(x2, 'max', height/2 + origin[1] - corner_radius,
+ **bc_args)
+ self._surface_names += (
+ 'x1_min_x2_min', 'x1_min_x2_max', 'x1_max_x2_min',
+ 'x1_max_x2_max', 'x1_min', 'x1_max', 'x2_min', 'x2_max'
+ )
+
+ def __neg__(self):
+ prism = +self.min_x1 & -self.max_x1 & +self.min_x2 & -self.max_x2
+
+ # Cut out corners if a corner radius was given
+ if hasattr(self, 'x1_min'):
+ corners = (
+ (+self.x1_min_x2_min & -self.x1_min & -self.x2_min) |
+ (+self.x1_min_x2_max & -self.x1_min & +self.x2_max) |
+ (+self.x1_max_x2_min & +self.x1_max & -self.x2_min) |
+ (+self.x1_max_x2_max & +self.x1_max & +self.x2_max)
+ )
+ prism &= ~corners
+
+ return prism
+
+
+class HexagonalPrism(CompositeSurface):
+ """Hexagonal prism comoposed of six planar surfaces
+
+ Parameters
+ ----------
+ edge_length : float
+ Length of a side of the hexagon in [cm]
+ orientation : {'x', 'y'}
+ An 'x' orientation means that two sides of the hexagon are parallel to
+ the x-axis and a 'y' orientation means that two sides of the hexagon are
+ parallel to the y-axis.
+ origin : Iterable of two floats
+ Origin of the prism.
+ boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic', 'white'}
+ Boundary condition that defines the behavior for particles hitting the
+ surfaces comprising the hexagonal prism.
+ albedo : float, optional
+ Albedo of the prism's surfaces as a ratio of particle weight after
+ interaction with the surface to the initial weight. Values must be
+ positive. Only applicable if the boundary type is 'reflective',
+ 'periodic', or 'white'.
+ corner_radius : float
+ Prism corner radius in units of [cm].
+
+ """
+ _surface_names = ('plane_max', 'plane_min', 'upper_right', 'upper_left',
+ 'lower_right', 'lower_left')
+
+ def __init__(
+ self,
+ edge_length: float = 1.,
+ orientation: str = 'y',
+ origin: Sequence[float] = (0., 0.),
+ boundary_type: str = 'transmission',
+ albedo: float = 1.,
+ corner_radius: float = 0.
+ ):
+ check_type('edge_length', edge_length, Real)
+ check_type('albedo', albedo, Real)
+ check_type('corner_radius', corner_radius, Real)
+ check_value('orientation', orientation, ('x', 'y'))
+ check_type('origin', origin, Iterable, Real)
+
+ l = edge_length
+ x, y = origin
+
+ # Create container for boundary arguments
+ bc_args = {'boundary_type': boundary_type, 'albedo': albedo}
+
+ if orientation == 'y':
+ # Left and right planes
+ self.plane_max = openmc.XPlane(x + sqrt(3.)/2*l, **bc_args)
+ self.plane_min = openmc.XPlane(x - sqrt(3.)/2*l, **bc_args)
+ c = sqrt(3.)/3.
+
+ # y = -x/sqrt(3) + a
+ self.upper_right = openmc.Plane(a=c, b=1., d=l+x*c+y, **bc_args)
+
+ # y = x/sqrt(3) + a
+ self.upper_left = openmc.Plane(a=-c, b=1., d=l-x*c+y, **bc_args)
+
+ # y = x/sqrt(3) - a
+ self.lower_right = openmc.Plane(a=-c, b=1., d=-l-x*c+y, **bc_args)
+
+ # y = -x/sqrt(3) - a
+ self.lower_left = openmc.Plane(a=c, b=1., d=-l+x*c+y, **bc_args)
+
+ elif orientation == 'x':
+ self.plane_max = openmc.YPlane(y + sqrt(3.)/2*l, **bc_args)
+ self.plane_min = openmc.YPlane(y - sqrt(3.)/2*l, **bc_args)
+ c = sqrt(3.)
+
+ # Upper-right surface: y = -sqrt(3)*(x - a)
+ self.upper_right = openmc.Plane(a=c, b=1., d=c*l+x*c+y, **bc_args)
+
+ # Lower-right surface: y = sqrt(3)*(x + a)
+ self.lower_right = openmc.Plane(a=-c, b=1., d=-c*l-x*c+y, **bc_args)
+
+ # Lower-left surface: y = -sqrt(3)*(x + a)
+ self.lower_left = openmc.Plane(a=c, b=1., d=-c*l+x*c+y, **bc_args)
+
+ # Upper-left surface: y = sqrt(3)*(x + a)
+ self.upper_left = openmc.Plane(a=-c, b=1., d=c*l-x*c+y, **bc_args)
+
+ # Handle periodic boundary conditions
+ if boundary_type == 'periodic':
+ self.plane_min.periodic_surface = self.plane_max
+ self.upper_right.periodic_surface = self.lower_left
+ self.lower_right.periodic_surface = self.upper_left
+
+ # Handle rounded corners if given
+ if corner_radius > 0.:
+ if boundary_type == 'periodic':
+ raise ValueError('Periodic boundary conditions not permitted '
+ 'when rounded corners are used.')
+
+ c = sqrt(3.)/2
+ t = l - corner_radius/c
+
+ # Cylinder with corner radius and boundary type pre-applied
+ cyl1 = partial(openmc.ZCylinder, r=corner_radius, **bc_args)
+ cyl2 = partial(openmc.ZCylinder, r=corner_radius/(2*c), **bc_args)
+
+ if orientation == 'x':
+ self.x_min_y_min_in = cyl1(name='x min y min in', x0=x-t/2, y0=y-c*t)
+ self.x_min_y_max_in = cyl1(name='x min y max in', x0=x+t/2, y0=y-c*t)
+ self.x_max_y_min_in = cyl1(name='x max y min in', x0=x-t/2, y0=y+c*t)
+ self.x_max_y_max_in = cyl1(name='x max y max in', x0=x+t/2, y0=y+c*t)
+ self.min_in = cyl1(name='x min in', x0=x-t, y0=y)
+ self.max_in = cyl1(name='x max in', x0=x+t, y0=y)
+
+ self.x_min_y_min_out = cyl2(name='x min y min out', x0=x-l/2, y0=y-c*l)
+ self.x_min_y_max_out = cyl2(name='x min y max out', x0=x+l/2, y0=y-c*l)
+ self.x_max_y_min_out = cyl2(name='x max y min out', x0=x-l/2, y0=y+c*l)
+ self.x_max_y_max_out = cyl2(name='x max y max out', x0=x+l/2, y0=y+c*l)
+ self.min_out = cyl2(name='x min out', x0=x-l, y0=y)
+ self.max_out = cyl2(name='x max out', x0=x+l, y0=y)
+
+ elif orientation == 'y':
+ self.x_min_y_min_in = cyl1(name='x min y min in', x0=x-c*t, y0=y-t/2)
+ self.x_min_y_max_in = cyl1(name='x min y max in', x0=x-c*t, y0=y+t/2)
+ self.x_max_y_min_in = cyl1(name='x max y min in', x0=x+c*t, y0=y-t/2)
+ self.x_max_y_max_in = cyl1(name='x max y max in', x0=x+c*t, y0=y+t/2)
+ self.min_in = cyl1(name='y min in', x0=x, y0=y-t)
+ self.max_in = cyl1(name='y max in', x0=x, y0=y+t)
+
+ self.x_min_y_min_out = cyl2(name='x min y min out', x0=x-c*l, y0=y-l/2)
+ self.x_min_y_max_out = cyl2(name='x min y max out', x0=x-c*l, y0=y+l/2)
+ self.x_max_y_min_out = cyl2(name='x max y min out', x0=x+c*l, y0=y-l/2)
+ self.x_max_y_max_out = cyl2(name='x max y max out', x0=x+c*l, y0=y+l/2)
+ self.min_out = cyl2(name='y min out', x0=x, y0=y-l)
+ self.max_out = cyl2(name='y max out', x0=x, y0=y+l)
+
+ # Add to tuple of surface names
+ for s in ('in', 'out'):
+ self._surface_names += (
+ f'x_min_y_min_{s}', f'x_min_y_max_{s}',
+ f'x_max_y_min_{s}', f'x_max_y_max_{s}',
+ f'min_{s}', f'max_{s}')
+
+ def __neg__(self) -> openmc.Region:
+ prism = (
+ -self.plane_max & +self.plane_min &
+ -self.upper_right & -self.upper_left &
+ +self.lower_right & +self.lower_left
+ )
+
+ # Cut out corners if a corner radius was given
+ if hasattr(self, 'min_in'):
+ corners = (
+ +self.x_min_y_min_in & -self.x_min_y_min_out |
+ +self.x_min_y_max_in & -self.x_min_y_max_out |
+ +self.x_max_y_min_in & -self.x_max_y_min_out |
+ +self.x_max_y_max_in & -self.x_max_y_max_out |
+ +self.min_in & -self.min_out |
+ +self.max_in & -self.max_out
+ )
+ prism &= ~corners
+
+ return prism
diff --git a/openmc/region.py b/openmc/region.py
index 51e1820fe..534ee9b82 100644
--- a/openmc/region.py
+++ b/openmc/region.py
@@ -30,6 +30,11 @@ class Region(ABC):
def __contains__(self, point):
pass
+ @property
+ @abstractmethod
+ def bounding_box(self) -> BoundingBox:
+ pass
+
@abstractmethod
def __str__(self):
pass
@@ -413,7 +418,7 @@ class Intersection(Region, MutableSequence):
return '(' + ' '.join(map(str, self)) + ')'
@property
- def bounding_box(self):
+ def bounding_box(self) -> BoundingBox:
box = BoundingBox.infinite()
for n in self:
box &= n.bounding_box
@@ -501,7 +506,7 @@ class Union(Region, MutableSequence):
return '(' + ' | '.join(map(str, self)) + ')'
@property
- def bounding_box(self):
+ def bounding_box(self) -> BoundingBox:
bbox = BoundingBox(np.array([np.inf]*3),
np.array([-np.inf]*3))
for n in self:
@@ -571,7 +576,7 @@ class Complement(Region):
self._node = node
@property
- def bounding_box(self):
+ def bounding_box(self) -> BoundingBox:
# Use De Morgan's laws to distribute the complement operator so that it
# only applies to surface half-spaces, thus allowing us to calculate the
# bounding box in the usual recursive manner.
diff --git a/tests/regression_tests/adj_cell_rotation/test.py b/tests/regression_tests/adj_cell_rotation/test.py
index 9b867c18e..3fe240536 100644
--- a/tests/regression_tests/adj_cell_rotation/test.py
+++ b/tests/regression_tests/adj_cell_rotation/test.py
@@ -24,14 +24,14 @@ def model():
# Create one cell on top of the other. Only one
# has a rotation
- box = openmc.rectangular_prism(15., 15., 'z', boundary_type='vacuum')
+ box = openmc.model.RectangularPrism(15., 15., 'z', boundary_type='vacuum')
lower_z = openmc.ZPlane(-7.5, boundary_type='vacuum')
upper_z = openmc.ZPlane(22.5, boundary_type='vacuum')
middle_z = openmc.ZPlane(7.5)
- lower_cell = openmc.Cell(fill=univ, region=box & +lower_z & -middle_z)
+ lower_cell = openmc.Cell(fill=univ, region=-box & +lower_z & -middle_z)
lower_cell.rotation = (10, 20, 30)
- upper_cell = openmc.Cell(fill=univ, region=box & +middle_z & -upper_z)
+ upper_cell = openmc.Cell(fill=univ, region=-box & +middle_z & -upper_z)
upper_cell.translation = (0, 0, 15)
model.geometry = openmc.Geometry(root=[lower_cell, upper_cell])
diff --git a/tests/regression_tests/cpp_driver/test.py b/tests/regression_tests/cpp_driver/test.py
index e8b1c62ac..79c30967c 100644
--- a/tests/regression_tests/cpp_driver/test.py
+++ b/tests/regression_tests/cpp_driver/test.py
@@ -92,10 +92,9 @@ def model():
lattice.pitch = (4.0, 4.0)
lattice.lower_left = (-4.0, -4.0)
lattice.universes = [[extra_univ, extra_univ], [extra_univ, extra_univ]]
- lattice_region = openmc.model.rectangular_prism(8.0,
- 8.0,
- boundary_type='reflective')
- lattice_cell = openmc.Cell(fill=lattice, region=lattice_region)
+ lattice_prism = openmc.model.RectangularPrism(
+ 8.0, 8.0, boundary_type='reflective')
+ lattice_cell = openmc.Cell(fill=lattice, region=-lattice_prism)
model.geometry = openmc.Geometry([lattice_cell])
diff --git a/tests/regression_tests/deplete_decay_only/test.py b/tests/regression_tests/deplete_decay_only/test.py
index cb716a5ad..4345b86b8 100644
--- a/tests/regression_tests/deplete_decay_only/test.py
+++ b/tests/regression_tests/deplete_decay_only/test.py
@@ -36,8 +36,8 @@ def model():
pin_surfaces = [openmc.ZCylinder(r=r) for r in radii]
pin_univ = openmc.model.pin(pin_surfaces, materials)
- bound_box = openmc.rectangular_prism(1.24, 1.24, boundary_type="reflective")
- root_cell = openmc.Cell(fill=pin_univ, region=bound_box)
+ bound_box = openmc.model.RectangularPrism(1.24, 1.24, boundary_type="reflective")
+ root_cell = openmc.Cell(fill=pin_univ, region=-bound_box)
geometry = openmc.Geometry([root_cell])
settings = openmc.Settings()
diff --git a/tests/regression_tests/filter_cellinstance/test.py b/tests/regression_tests/filter_cellinstance/test.py
index 0d6ad9366..61f17d88a 100644
--- a/tests/regression_tests/filter_cellinstance/test.py
+++ b/tests/regression_tests/filter_cellinstance/test.py
@@ -60,8 +60,8 @@ def model():
[u3, u3, u2, u3],
[u3, u3, u3, u2]
]
- box = openmc.model.rectangular_prism(8.0, 8.0, boundary_type='reflective')
- main_cell = openmc.Cell(fill=lat, region=box)
+ box = openmc.model.RectangularPrism(8.0, 8.0, boundary_type='reflective')
+ main_cell = openmc.Cell(fill=lat, region=-box)
model.geometry.root_universe = openmc.Universe(cells=[main_cell])
model.geometry.determine_paths()
diff --git a/tests/regression_tests/filter_mesh/test.py b/tests/regression_tests/filter_mesh/test.py
index 62f0ed015..6214e0486 100644
--- a/tests/regression_tests/filter_mesh/test.py
+++ b/tests/regression_tests/filter_mesh/test.py
@@ -19,12 +19,12 @@ def model():
zr.add_nuclide('Zr90', 1.0)
model.materials.extend([fuel, zr])
- box1 = openmc.model.rectangular_prism(10.0, 10.0)
- box2 = openmc.model.rectangular_prism(20.0, 20.0, boundary_type='reflective')
+ box1 = openmc.model.RectangularPrism(10.0, 10.0)
+ box2 = openmc.model.RectangularPrism(20.0, 20.0, boundary_type='reflective')
top = openmc.ZPlane(z0=10.0, boundary_type='vacuum')
bottom = openmc.ZPlane(z0=-10.0, boundary_type='vacuum')
- cell1 = openmc.Cell(fill=fuel, region=box1 & +bottom & -top)
- cell2 = openmc.Cell(fill=zr, region=~box1 & box2 & +bottom & -top)
+ cell1 = openmc.Cell(fill=fuel, region=-box1 & +bottom & -top)
+ cell2 = openmc.Cell(fill=zr, region=+box1 & -box2 & +bottom & -top)
model.geometry = openmc.Geometry([cell1, cell2])
model.settings.batches = 5
diff --git a/tests/regression_tests/filter_translations/test.py b/tests/regression_tests/filter_translations/test.py
index d61667b01..4f0fe7141 100644
--- a/tests/regression_tests/filter_translations/test.py
+++ b/tests/regression_tests/filter_translations/test.py
@@ -19,12 +19,12 @@ def model():
zr.add_nuclide('Zr90', 1.0)
model.materials.extend([fuel, zr])
- box1 = openmc.model.rectangular_prism(10.0, 10.0)
- box2 = openmc.model.rectangular_prism(20.0, 20.0, boundary_type='reflective')
+ box1 = openmc.model.RectangularPrism(10.0, 10.0)
+ box2 = openmc.model.RectangularPrism(20.0, 20.0, boundary_type='reflective')
top = openmc.ZPlane(z0=10.0, boundary_type='vacuum')
bottom = openmc.ZPlane(z0=-10.0, boundary_type='vacuum')
- cell1 = openmc.Cell(fill=fuel, region=box1 & +bottom & -top)
- cell2 = openmc.Cell(fill=zr, region=~box1 & box2 & +bottom & -top)
+ cell1 = openmc.Cell(fill=fuel, region=-box1 & +bottom & -top)
+ cell2 = openmc.Cell(fill=zr, region=+box1 & -box2 & +bottom & -top)
model.geometry = openmc.Geometry([cell1, cell2])
model.settings.batches = 5
diff --git a/tests/regression_tests/lattice_hex_coincident/inputs_true.dat b/tests/regression_tests/lattice_hex_coincident/inputs_true.dat
index 7a83fb471..ac82de0ad 100644
--- a/tests/regression_tests/lattice_hex_coincident/inputs_true.dat
+++ b/tests/regression_tests/lattice_hex_coincident/inputs_true.dat
@@ -38,7 +38,7 @@
|
|
|
- |
+ |
1.4
3
diff --git a/tests/regression_tests/lattice_hex_coincident/test.py b/tests/regression_tests/lattice_hex_coincident/test.py
index 5a4760cd7..f971098c0 100644
--- a/tests/regression_tests/lattice_hex_coincident/test.py
+++ b/tests/regression_tests/lattice_hex_coincident/test.py
@@ -104,10 +104,10 @@ class HexLatticeCoincidentTestHarness(PyAPITestHarness):
inf_mat_univ = openmc.Universe(cells=[inf_mat,])
# a hex surface for the core to go inside of
- hexprism = openmc.model.hexagonal_prism(edge_length=edge_length,
- origin=(0.0, 0.0),
- boundary_type = 'reflective',
- orientation='x')
+ hexprism = openmc.model.HexagonalPrism(edge_length=edge_length,
+ origin=(0.0, 0.0),
+ boundary_type = 'reflective',
+ orientation='x')
pincell_only_lattice = openmc.HexLattice(name="regular fuel assembly")
pincell_only_lattice.center = (0., 0.)
@@ -120,7 +120,7 @@ class HexLatticeCoincidentTestHarness(PyAPITestHarness):
pincell_only_lattice.universes = [ring1, ring0]
pincell_only_cell = openmc.Cell(name="container cell")
- pincell_only_cell.region = hexprism & +fuel_btm & -fuel_top
+ pincell_only_cell.region = -hexprism & +fuel_btm & -fuel_top
pincell_only_cell.fill = pincell_only_lattice
root_univ = openmc.Universe(name="root universe", cells=[pincell_only_cell,])
diff --git a/tests/regression_tests/lattice_hex_x/inputs_true.dat b/tests/regression_tests/lattice_hex_x/inputs_true.dat
index 2946258e8..252fbfc0b 100644
--- a/tests/regression_tests/lattice_hex_x/inputs_true.dat
+++ b/tests/regression_tests/lattice_hex_x/inputs_true.dat
@@ -42,7 +42,7 @@
|
|
|
- |
+ |
1.235 5.0
4
diff --git a/tests/regression_tests/lattice_hex_x/test.py b/tests/regression_tests/lattice_hex_x/test.py
index 23aec77d3..dd5c53d0c 100644
--- a/tests/regression_tests/lattice_hex_x/test.py
+++ b/tests/regression_tests/lattice_hex_x/test.py
@@ -139,11 +139,11 @@ class HexLatticeOXTestHarness(PyAPITestHarness):
# a hex surface for the core to go inside of
- hexprism = openmc.model.hexagonal_prism(edge_length=edge_length,
- origin=(0.0, 0.0),
- boundary_type='reflective',
- orientation='x')
- region = hexprism & +fuel_bottom & -fuel_top
+ hexprism = openmc.model.HexagonalPrism(edge_length=edge_length,
+ origin=(0.0, 0.0),
+ boundary_type='reflective',
+ orientation='x')
+ region = -hexprism & +fuel_bottom & -fuel_top
inf_mat = openmc.Cell(cell_id=12)
inf_mat.fill = coolant
diff --git a/tests/regression_tests/lattice_multiple/test.py b/tests/regression_tests/lattice_multiple/test.py
index c287c0102..10d9e50bc 100644
--- a/tests/regression_tests/lattice_multiple/test.py
+++ b/tests/regression_tests/lattice_multiple/test.py
@@ -42,8 +42,8 @@ def model():
lattice.pitch = (2*d, 2*d)
lattice.universes = np.full((2, 2), inner_univ)
- box = openmc.model.rectangular_prism(4*d, 4*d, boundary_type='reflective')
- main_cell = openmc.Cell(fill=lattice, region=box)
+ box = openmc.model.RectangularPrism(4*d, 4*d, boundary_type='reflective')
+ main_cell = openmc.Cell(fill=lattice, region=-box)
model.geometry = openmc.Geometry([main_cell])
model.settings.batches = 10
diff --git a/tests/regression_tests/mg_temperature_multi/test.py b/tests/regression_tests/mg_temperature_multi/test.py
index 2090f1b0c..404c8c0cd 100755
--- a/tests/regression_tests/mg_temperature_multi/test.py
+++ b/tests/regression_tests/mg_temperature_multi/test.py
@@ -108,14 +108,14 @@ def test_mg_temperature_multi():
# Create a region represented as the inside of a rectangular prism
pitch = 1.26
- box = openmc.rectangular_prism(pitch, pitch, boundary_type='reflective')
+ box = openmc.model.RectangularPrism(pitch, pitch, boundary_type='reflective')
# Instantiate Cells
fuel_inner = openmc.Cell(fill=uo2, region=-fuel_ir, name='fuel inner')
fuel_inner.temperature = 600.0
fuel_outer = openmc.Cell(fill=uo2, region=+fuel_ir & -fuel_or, name='fuel outer')
fuel_outer.temperature = 294.0
- moderator = openmc.Cell(fill=water, region=+fuel_or & box, name='moderator')
+ moderator = openmc.Cell(fill=water, region=+fuel_or & -box, name='moderator')
# Create a geometry with the two cells and export to XML
geometry = openmc.Geometry([fuel_inner, fuel_outer, moderator])
diff --git a/tests/regression_tests/mgxs_library_mesh/test.py b/tests/regression_tests/mgxs_library_mesh/test.py
index 3660d3eb7..89c68a75a 100644
--- a/tests/regression_tests/mgxs_library_mesh/test.py
+++ b/tests/regression_tests/mgxs_library_mesh/test.py
@@ -19,12 +19,12 @@ def model():
zr.add_nuclide('Zr90', 1.0)
model.materials.extend([fuel, zr])
- box1 = openmc.model.rectangular_prism(10.0, 10.0)
- box2 = openmc.model.rectangular_prism(20.0, 20.0, boundary_type='reflective')
+ box1 = openmc.model.RectangularPrism(10.0, 10.0)
+ box2 = openmc.model.RectangularPrism(20.0, 20.0, boundary_type='reflective')
top = openmc.ZPlane(z0=10.0, boundary_type='vacuum')
bottom = openmc.ZPlane(z0=-10.0, boundary_type='vacuum')
- cell1 = openmc.Cell(fill=fuel, region=box1 & +bottom & -top)
- cell2 = openmc.Cell(fill=zr, region=~box1 & box2 & +bottom & -top)
+ cell1 = openmc.Cell(fill=fuel, region=-box1 & +bottom & -top)
+ cell2 = openmc.Cell(fill=zr, region=+box1 & -box2 & +bottom & -top)
model.geometry = openmc.Geometry([cell1, cell2])
model.settings.batches = 5
diff --git a/tests/regression_tests/microxs/test.py b/tests/regression_tests/microxs/test.py
index dbdb1c8fe..a35150a1b 100644
--- a/tests/regression_tests/microxs/test.py
+++ b/tests/regression_tests/microxs/test.py
@@ -34,8 +34,8 @@ def model():
pin_surfaces = [openmc.ZCylinder(r=r) for r in radii]
pin_univ = openmc.model.pin(pin_surfaces, materials)
- bound_box = openmc.rectangular_prism(1.24, 1.24, boundary_type="reflective")
- root_cell = openmc.Cell(fill=pin_univ, region=bound_box)
+ bound_box = openmc.model.RectangularPrism(1.24, 1.24, boundary_type="reflective")
+ root_cell = openmc.Cell(fill=pin_univ, region=-bound_box)
geometry = openmc.Geometry([root_cell])
settings = openmc.Settings()
diff --git a/tests/regression_tests/periodic_hex/test.py b/tests/regression_tests/periodic_hex/test.py
index a21819b1a..db9f6cfd5 100644
--- a/tests/regression_tests/periodic_hex/test.py
+++ b/tests/regression_tests/periodic_hex/test.py
@@ -12,8 +12,8 @@ def hex_model():
fuel.add_nuclide('U235', 1.0)
fuel.set_density('g/cc', 4.5)
- hex_region = openmc.model.hexagonal_prism(10.0, boundary_type='periodic')
- cell = openmc.Cell(fill=fuel, region=hex_region)
+ hex_prism = openmc.model.HexagonalPrism(10.0, boundary_type='periodic')
+ cell = openmc.Cell(fill=fuel, region=-hex_prism)
model.geometry = openmc.Geometry([cell])
# Define settings
diff --git a/tests/regression_tests/score_current/test.py b/tests/regression_tests/score_current/test.py
index 1309584d2..a338a6626 100644
--- a/tests/regression_tests/score_current/test.py
+++ b/tests/regression_tests/score_current/test.py
@@ -16,12 +16,12 @@ def model():
zr.add_nuclide('Zr90', 1.0)
model.materials.extend([fuel, zr])
- box1 = openmc.model.rectangular_prism(10.0, 10.0)
- box2 = openmc.model.rectangular_prism(20.0, 20.0, boundary_type='reflective')
+ box1 = openmc.model.RectangularPrism(10.0, 10.0)
+ box2 = openmc.model.RectangularPrism(20.0, 20.0, boundary_type='reflective')
top = openmc.ZPlane(z0=10.0, boundary_type='vacuum')
bottom = openmc.ZPlane(z0=-10.0, boundary_type='vacuum')
- cell1 = openmc.Cell(fill=fuel, region=box1 & +bottom & -top)
- cell2 = openmc.Cell(fill=zr, region=~box1 & box2 & +bottom & -top)
+ cell1 = openmc.Cell(fill=fuel, region=-box1 & +bottom & -top)
+ cell2 = openmc.Cell(fill=zr, region=+box1 & -box2 & +bottom & -top)
model.geometry = openmc.Geometry([cell1, cell2])
model.settings.batches = 5
diff --git a/tests/regression_tests/tally_aggregation/test.py b/tests/regression_tests/tally_aggregation/test.py
index a29839a6f..08d911660 100644
--- a/tests/regression_tests/tally_aggregation/test.py
+++ b/tests/regression_tests/tally_aggregation/test.py
@@ -33,8 +33,8 @@ def model():
[pin, pin],
[pin, pin],
]
- box = openmc.model.rectangular_prism(2*d, 2*d, boundary_type='reflective')
- main_cell = openmc.Cell(fill=lattice, region=box)
+ box = openmc.model.RectangularPrism(2*d, 2*d, boundary_type='reflective')
+ main_cell = openmc.Cell(fill=lattice, region=-box)
model.geometry = openmc.Geometry([main_cell])
model.settings.batches = 10
diff --git a/tests/unit_tests/test_deplete_coupled_operator.py b/tests/unit_tests/test_deplete_coupled_operator.py
index 4fa1dac2e..8765020de 100644
--- a/tests/unit_tests/test_deplete_coupled_operator.py
+++ b/tests/unit_tests/test_deplete_coupled_operator.py
@@ -38,8 +38,8 @@ def model():
pin_surfaces = [openmc.ZCylinder(r=r) for r in radii]
pin_univ = openmc.model.pin(pin_surfaces, materials)
- bound_box = openmc.rectangular_prism(1.24, 1.24, boundary_type="reflective")
- root_cell = openmc.Cell(fill=pin_univ, region=bound_box)
+ bound_box = openmc.model.RectangularPrism(1.24, 1.24, boundary_type="reflective")
+ root_cell = openmc.Cell(fill=pin_univ, region=-bound_box)
geometry = openmc.Geometry([root_cell])
settings = openmc.Settings()
diff --git a/tests/unit_tests/test_deplete_fission_yields.py b/tests/unit_tests/test_deplete_fission_yields.py
index b603710f3..1937e61e3 100644
--- a/tests/unit_tests/test_deplete_fission_yields.py
+++ b/tests/unit_tests/test_deplete_fission_yields.py
@@ -27,8 +27,8 @@ def materials(tmpdir_factory):
mfuel.add_nuclide(nuclide, 1.0)
openmc.Materials([mfuel]).export_to_xml()
# Geometry
- box = openmc.rectangular_prism(1.0, 1.0, boundary_type="reflective")
- cell = openmc.Cell(fill=mfuel, region=box)
+ box = openmc.model.RectangularPrism(1.0, 1.0, boundary_type="reflective")
+ cell = openmc.Cell(fill=mfuel, region=-box)
root = openmc.Universe(cells=[cell])
openmc.Geometry(root).export_to_xml()
# settings
diff --git a/tests/unit_tests/test_filter_mesh.py b/tests/unit_tests/test_filter_mesh.py
index 36beed25d..a8bd4996d 100644
--- a/tests/unit_tests/test_filter_mesh.py
+++ b/tests/unit_tests/test_filter_mesh.py
@@ -127,9 +127,9 @@ def test_cylindrical_mesh_coincident(scale, run_in_tmpdir):
fuel.set_density('g/cm3', 4.5)
zcyl = openmc.ZCylinder(r=1.25*scale)
- box = openmc.rectangular_prism(4*scale, 4*scale, boundary_type='reflective')
+ box = openmc.model.RectangularPrism(4*scale, 4*scale, boundary_type='reflective')
cell1 = openmc.Cell(fill=fuel, region=-zcyl)
- cell2 = openmc.Cell(fill=None, region=+zcyl & box)
+ cell2 = openmc.Cell(fill=None, region=+zcyl & -box)
model = openmc.Model()
model.geometry = openmc.Geometry([cell1, cell2])
@@ -193,7 +193,7 @@ def test_spherical_mesh_coincident(scale, run_in_tmpdir):
phi_grid=[0., 2*math.pi],
theta_grid=[0., math.pi],
)
-
+
sph_mesh_filter = openmc.MeshFilter(sph_mesh)
cell_filter = openmc.CellFilter([cell1])
diff --git a/tests/unit_tests/test_filters.py b/tests/unit_tests/test_filters.py
index ff064d5c2..4ace59e72 100644
--- a/tests/unit_tests/test_filters.py
+++ b/tests/unit_tests/test_filters.py
@@ -10,8 +10,8 @@ def box_model():
m.add_nuclide('U235', 1.0)
m.set_density('g/cm3', 1.0)
- box = openmc.model.rectangular_prism(10., 10., boundary_type='vacuum')
- c = openmc.Cell(fill=m, region=box)
+ box = openmc.model.RectangularPrism(10., 10., boundary_type='vacuum')
+ c = openmc.Cell(fill=m, region=-box)
model.geometry.root_universe = openmc.Universe(cells=[c])
model.settings.particles = 100
diff --git a/tests/unit_tests/test_geometry.py b/tests/unit_tests/test_geometry.py
index ebb185642..ff94bc932 100644
--- a/tests/unit_tests/test_geometry.py
+++ b/tests/unit_tests/test_geometry.py
@@ -213,27 +213,27 @@ def test_get_by_name():
def test_hex_prism():
- hex_prism = openmc.model.hexagonal_prism(edge_length=5.0,
- origin=(0.0, 0.0),
- orientation='y')
+ hex_prism = openmc.model.HexagonalPrism(edge_length=5.0,
+ origin=(0.0, 0.0),
+ orientation='y')
# clear checks
- assert (0.0, 0.0, 0.0) in hex_prism
- assert (10.0, 10.0, 10.0) not in hex_prism
+ assert (0.0, 0.0, 0.0) in -hex_prism
+ assert (10.0, 10.0, 10.0) not in -hex_prism
# edge checks
- assert (0.0, 5.01, 0.0) not in hex_prism
- assert (0.0, 4.99, 0.0) in hex_prism
+ assert (0.0, 5.01, 0.0) not in -hex_prism
+ assert (0.0, 4.99, 0.0) in -hex_prism
- rounded_hex_prism = openmc.model.hexagonal_prism(edge_length=5.0,
- origin=(0.0, 0.0),
- orientation='y',
- corner_radius=1.0)
+ rounded_hex_prism = openmc.model.HexagonalPrism(edge_length=5.0,
+ origin=(0.0, 0.0),
+ orientation='y',
+ corner_radius=1.0)
# clear checks
- assert (0.0, 0.0, 0.0) in rounded_hex_prism
- assert (10.0, 10.0, 10.0) not in rounded_hex_prism
+ assert (0.0, 0.0, 0.0) in -rounded_hex_prism
+ assert (10.0, 10.0, 10.0) not in -rounded_hex_prism
# edge checks
- assert (0.0, 5.01, 0.0) not in rounded_hex_prism
- assert (0.0, 4.99, 0.0) not in rounded_hex_prism
+ assert (0.0, 5.01, 0.0) not in -rounded_hex_prism
+ assert (0.0, 4.99, 0.0) not in -rounded_hex_prism
def test_get_lattice_by_name(cell_with_lattice):
diff --git a/tests/unit_tests/test_model.py b/tests/unit_tests/test_model.py
index f78f95637..682afb41a 100644
--- a/tests/unit_tests/test_model.py
+++ b/tests/unit_tests/test_model.py
@@ -35,8 +35,8 @@ def pin_model_attributes():
pitch = 1.25984
fuel_or = openmc.ZCylinder(r=0.39218, name='Fuel OR')
clad_or = openmc.ZCylinder(r=0.45720, name='Clad OR')
- box = openmc.model.rectangular_prism(pitch, pitch,
- boundary_type='reflective')
+ box = openmc.model.RectangularPrism(pitch, pitch,
+ boundary_type='reflective')
# Define cells
fuel_inf_cell = openmc.Cell(cell_id=1, name='inf fuel', fill=uo2)
@@ -44,7 +44,7 @@ def pin_model_attributes():
fuel = openmc.Cell(cell_id=2, name='fuel',
fill=fuel_inf_univ, region=-fuel_or)
clad = openmc.Cell(cell_id=3, fill=zirc, region=+fuel_or & -clad_or)
- water = openmc.Cell(cell_id=4, fill=borated_water, region=+clad_or & box)
+ water = openmc.Cell(cell_id=4, fill=borated_water, region=+clad_or & -box)
# Define overall geometry
geom = openmc.Geometry([fuel, clad, water])
@@ -566,4 +566,4 @@ def test_single_xml_exec(run_in_tmpdir):
openmc.run(path_input='./inputs/pincell.xml')
with pytest.raises(RuntimeError, match='input_dir'):
- openmc.run(path_input='input_dir/pincell.xml')
\ No newline at end of file
+ openmc.run(path_input='input_dir/pincell.xml')
diff --git a/tests/unit_tests/test_no_visible_boundary.py b/tests/unit_tests/test_no_visible_boundary.py
index 8f07b8da9..7c53e4e3f 100644
--- a/tests/unit_tests/test_no_visible_boundary.py
+++ b/tests/unit_tests/test_no_visible_boundary.py
@@ -13,9 +13,9 @@ def test_no_visible_boundary(run_in_tmpdir):
# disc of copper. Neutrons leaving the back of the disc see no surfaces in
# front of them.
disc = openmc.model.RightCircularCylinder((0., 0., 1.), 0.1, 1.2)
- box = openmc.rectangular_prism(width=10, height=10, boundary_type='vacuum')
+ box = openmc.model.RectangularPrism(width=10, height=10, boundary_type='vacuum')
c1 = openmc.Cell(fill=copper, region=-disc)
- c2 = openmc.Cell(fill=air, region=+disc & box)
+ c2 = openmc.Cell(fill=air, region=+disc & -box)
model = openmc.Model()
model.geometry = openmc.Geometry([c1, c2])
model.settings.run_mode = 'fixed source'