Add RectangularPrism and HexagonalPrism composite surfaces (#2739)

Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
This commit is contained in:
Paul Romano 2023-11-01 09:13:40 -05:00 committed by GitHub
parent 94f02ae10b
commit ac941f79e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 425 additions and 403 deletions

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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()

View file

@ -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()

View file

@ -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])

View file

@ -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])

View file

@ -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])

View file

@ -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'

View file

@ -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):

View file

@ -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

View file

@ -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.

View file

@ -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])

View file

@ -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])

View file

@ -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()

View file

@ -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()

View file

@ -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

View file

@ -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

View file

@ -38,7 +38,7 @@
<cell id="5" material="3" name="lead_shell" region="5 -6 2 -3" universe="2"/>
<cell id="6" material="2" name="matrix coolant surround" region="6 2 -3" universe="2"/>
<cell id="7" material="2" universe="3"/>
<cell fill="4" id="8" name="container cell" region="-7 8 -9 10 11 -12 2 -3" universe="5"/>
<cell fill="4" id="8" name="container cell" region="-7 8 -9 -12 10 11 2 -3" universe="5"/>
<hex_lattice id="4" n_rings="2" name="regular fuel assembly">
<pitch>1.4</pitch>
<outer>3</outer>

View file

@ -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,])

View file

@ -42,7 +42,7 @@
<cell id="10" material="4" region="-8 7" universe="3"/>
<cell id="11" material="2" region="8" universe="3"/>
<cell id="12" material="2" universe="4"/>
<cell fill="6" id="13" name="container assembly cell" region="-11 12 -13 14 15 -16 9 -10" universe="5"/>
<cell fill="6" id="13" name="container assembly cell" region="-11 12 -13 -16 14 15 9 -10" universe="5"/>
<hex_lattice id="6" n_axial="2" n_rings="11" name="regular fuel assembly" orientation="x">
<pitch>1.235 5.0</pitch>
<outer>4</outer>

View file

@ -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

View file

@ -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

View file

@ -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])

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -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])

View file

@ -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

View file

@ -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):

View file

@ -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')
openmc.run(path_input='input_dir/pincell.xml')

View file

@ -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'