Make surfaces take coefficients as first arguments

This commit is contained in:
Paul Romano 2019-09-04 15:10:53 -05:00
parent e4e824fe4d
commit d85df13ae7
17 changed files with 218 additions and 225 deletions

View file

@ -350,18 +350,14 @@ class RegularMesh(MeshBase):
n_dim = len(self.dimension)
# Build the cell which will contain the lattice
xplanes = [openmc.XPlane(x0=self.lower_left[0],
boundary_type=bc[0]),
openmc.XPlane(x0=self.upper_right[0],
boundary_type=bc[1])]
xplanes = [openmc.XPlane(self.lower_left[0], bc[0]),
openmc.XPlane(self.upper_right[0], bc[1])]
if n_dim == 1:
yplanes = [openmc.YPlane(y0=-1e10, boundary_type='reflective'),
openmc.YPlane(y0=1e10, boundary_type='reflective')]
yplanes = [openmc.YPlane(-1e10, 'reflective'),
openmc.YPlane(1e10, 'reflective')]
else:
yplanes = [openmc.YPlane(y0=self.lower_left[1],
boundary_type=bc[2]),
openmc.YPlane(y0=self.upper_right[1],
boundary_type=bc[3])]
yplanes = [openmc.YPlane(self.lower_left[1], bc[2]),
openmc.YPlane(self.upper_right[1], bc[3])]
if n_dim <= 2:
# Would prefer to have the z ranges be the max supported float, but
@ -371,13 +367,11 @@ class RegularMesh(MeshBase):
# inconsistency between what numpy uses as the max float and what
# Fortran expects for a real(8), so this avoids code complication
# and achieves the same goal.
zplanes = [openmc.ZPlane(z0=-1e10, boundary_type='reflective'),
openmc.ZPlane(z0=1e10, boundary_type='reflective')]
zplanes = [openmc.ZPlane(-1e10, 'reflective'),
openmc.ZPlane(1e10, 'reflective')]
else:
zplanes = [openmc.ZPlane(z0=self.lower_left[2],
boundary_type=bc[4]),
openmc.ZPlane(z0=self.upper_right[2],
boundary_type=bc[5])]
zplanes = [openmc.ZPlane(self.lower_left[2], bc[4]),
openmc.ZPlane(self.upper_right[2], bc[5])]
root_cell = openmc.Cell()
root_cell.region = ((+xplanes[0] & -xplanes[1]) &
(+yplanes[0] & -yplanes[1]) &

View file

@ -253,8 +253,8 @@ def hexagonal_prism(edge_length=1., orientation='y', origin=(0., 0.),
x, y = origin
if orientation == 'y':
right = XPlane(x0=x + sqrt(3.)/2*l, boundary_type=boundary_type)
left = XPlane(x0=x - sqrt(3.)/2*l, boundary_type=boundary_type)
right = XPlane(x + sqrt(3.)/2*l, boundary_type)
left = XPlane(x - sqrt(3.)/2*l, boundary_type)
c = sqrt(3.)/3.
# y = -x/sqrt(3) + a

View file

@ -527,10 +527,10 @@ class Complement(Region):
The Complement of an existing :class:`openmc.Region` can be created by using
the ~ operator as the following example demonstrates:
>>> xl = openmc.XPlane(x0=-10.0)
>>> xr = openmc.XPlane(x0=10.0)
>>> yl = openmc.YPlane(y0=-10.0)
>>> yr = openmc.YPlane(y0=10.0)
>>> xl = openmc.XPlane(-10.0)
>>> xr = openmc.XPlane(10.0)
>>> yl = openmc.YPlane(-10.0)
>>> yr = openmc.YPlane(10.0)
>>> inside_box = +xl & -xr & +yl & -yr
>>> outside_box = ~inside_box
>>> type(outside_box)

View file

@ -277,49 +277,48 @@ class Surface(IDManagerMixin, metaclass=ABCMeta):
# Create the Surface based on its type
if surf_type == 'x-plane':
x0 = coeffs[0]
surface = XPlane(surface_id, bc, x0, name)
surface = XPlane(x0, bc, name, surface_id)
elif surf_type == 'y-plane':
y0 = coeffs[0]
surface = YPlane(surface_id, bc, y0, name)
surface = YPlane(y0, bc, name, surface_id)
elif surf_type == 'z-plane':
z0 = coeffs[0]
surface = ZPlane(surface_id, bc, z0, name)
surface = ZPlane(z0, bc, name, surface_id)
elif surf_type == 'plane':
A, B, C, D = coeffs
surface = Plane(surface_id, bc, A, B, C, D, name)
surface = Plane(A, B, C, D, bc, name, surface_id)
elif surf_type == 'x-cylinder':
y0, z0, r = coeffs
surface = XCylinder(surface_id, bc, y0, z0, r, name)
surface = XCylinder(y0, z0, r, bc, name, surface_id)
elif surf_type == 'y-cylinder':
x0, z0, r = coeffs
surface = YCylinder(surface_id, bc, x0, z0, r, name)
surface = YCylinder(x0, z0, r, bc, name, surface_id)
elif surf_type == 'z-cylinder':
x0, y0, r = coeffs
surface = ZCylinder(surface_id, bc, x0, y0, r, name)
surface = ZCylinder(x0, y0, r, bc, name, surface_id)
elif surf_type == 'sphere':
x0, y0, z0, r = coeffs
surface = Sphere(surface_id, bc, x0, y0, z0, r, name)
surface = Sphere(x0, y0, z0, r, bc, name, surface_id)
elif surf_type in ['x-cone', 'y-cone', 'z-cone']:
x0, y0, z0, r2 = coeffs
if surf_type == 'x-cone':
surface = XCone(surface_id, bc, x0, y0, z0, r2, name)
surface = XCone(x0, y0, z0, r2, bc, name, surface_id)
elif surf_type == 'y-cone':
surface = YCone(surface_id, bc, x0, y0, z0, r2, name)
surface = YCone(x0, y0, z0, r2, bc, name, surface_id)
elif surf_type == 'z-cone':
surface = ZCone(surface_id, bc, x0, y0, z0, r2, name)
surface = ZCone(x0, y0, z0, r2, bc, name, surface_id)
elif surf_type == 'quadric':
a, b, c, d, e, f, g, h, j, k = coeffs
surface = Quadric(surface_id, bc, a, b, c, d, e, f, g,
h, j, k, name)
surface = Quadric(a, b, c, d, e, f, g, h, j, k, bc, name, surface_id)
return surface
@ -329,13 +328,6 @@ class Plane(Surface):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
a : float, optional
The 'A' parameter for the plane. Defaults to 1.
b : float, optional
@ -344,8 +336,15 @@ class Plane(Surface):
The 'C' parameter for the plane. Defaults to 0.
d : float, optional
The 'D' parameter for the plane. Defaults to 0.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
name : str, optional
Name of the plane. If not specified, the name will be the empty string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -377,8 +376,8 @@ class Plane(Surface):
_type = 'plane'
_coeff_keys = ('a', 'b', 'c', 'd')
def __init__(self, surface_id=None, boundary_type='transmission',
a=1., b=0., c=0., d=0., name='', **kwargs):
def __init__(self, a=1., b=0., c=0., d=0., boundary_type='transmission',
name='', surface_id=None, **kwargs):
super().__init__(surface_id, boundary_type, name=name)
self._periodic_surface = None
self.a = a
@ -532,18 +531,18 @@ class XPlane(Plane):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
x0 : float, optional
Location of the plane. Defaults to 0.
boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface. Only axis-aligned periodicity is
supported, i.e., x-planes can only be paired with x-planes.
x0 : float, optional
Location of the plane. Defaults to 0.
name : str, optional
Name of the plane. If not specified, the name will be the empty string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -569,9 +568,9 @@ class XPlane(Plane):
_type = 'x-plane'
_coeff_keys = ('x0',)
def __init__(self, surface_id=None, boundary_type='transmission',
x0=0., name=''):
super().__init__(surface_id, boundary_type, name=name)
def __init__(self, x0=0., boundary_type='transmission',
name='', surface_id=None):
super().__init__(surface_id=surface_id, boundary_type=boundary_type, name=name)
self.x0 = x0
@property
@ -657,18 +656,18 @@ class YPlane(Plane):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
y0 : float, optional
Location of the plane
boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface. Only axis-aligned periodicity is
supported, i.e., x-planes can only be paired with x-planes.
y0 : float, optional
Location of the plane
name : str, optional
Name of the plane. If not specified, the name will be the empty string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -694,10 +693,9 @@ class YPlane(Plane):
_type = 'y-plane'
_coeff_keys = ('y0',)
def __init__(self, surface_id=None, boundary_type='transmission',
y0=0., name=''):
# Initialize YPlane class attributes
super().__init__(surface_id, boundary_type, name=name)
def __init__(self, y0=0., boundary_type='transmission',
name='', surface_id=None):
super().__init__(surface_id=surface_id, boundary_type=boundary_type, name=name)
self.y0 = y0
@property
@ -820,10 +818,9 @@ class ZPlane(Plane):
_type = 'z-plane'
_coeff_keys = ('z0',)
def __init__(self, surface_id=None, boundary_type='transmission',
z0=0., name=''):
# Initialize ZPlane class attributes
super().__init__(surface_id, boundary_type, name=name)
def __init__(self, z0=0., boundary_type='transmission',
name='', surface_id=None):
super().__init__(surface_id=surface_id, boundary_type=boundary_type, name=name)
self.z0 = z0
@property
@ -909,18 +906,18 @@ class Cylinder(Surface):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
r : float, optional
Radius of the cylinder. Defaults to 1.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
r : float, optional
Radius of the cylinder. Defaults to 1.
name : str, optional
Name of the cylinder. If not specified, the name will be the empty
string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -939,8 +936,8 @@ class Cylinder(Surface):
Type of the surface
"""
def __init__(self, surface_id=None, boundary_type='transmission',
r=1., name=''):
def __init__(self, r=1., boundary_type='transmission',
name='', surface_id=None):
super().__init__(surface_id, boundary_type, name=name)
self.r = r
@ -960,22 +957,22 @@ class XCylinder(Cylinder):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
y0 : float, optional
y-coordinate of the center of the cylinder. Defaults to 0.
z0 : float, optional
z-coordinate of the center of the cylinder. Defaults to 0.
r : float, optional
Radius of the cylinder. Defaults to 0.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
name : str, optional
Name of the cylinder. If not specified, the name will be the empty
string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -1000,12 +997,12 @@ class XCylinder(Cylinder):
_type = 'x-cylinder'
_coeff_keys = ('y0', 'z0', 'r')
def __init__(self, surface_id=None, boundary_type='transmission',
y0=0., z0=0., r=1., name='', *, R=None):
def __init__(self, y0=0., z0=0., r=1., boundary_type='transmission',
name='', surface_id=None, *, R=None):
if R is not None:
warn(_WARNING_UPPER.format(type(self).__name__, 'r', 'R'), FutureWarning)
r = R
super().__init__(surface_id, boundary_type, r, name=name)
super().__init__(r, boundary_type, name, surface_id)
self.y0 = y0
self.z0 = z0
@ -1107,22 +1104,22 @@ class YCylinder(Cylinder):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
x0 : float, optional
x-coordinate of the center of the cylinder. Defaults to 0.
z0 : float, optional
z-coordinate of the center of the cylinder. Defaults to 0.
r : float, optional
Radius of the cylinder. Defaults to 1.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
name : str, optional
Name of the cylinder. If not specified, the name will be the empty
string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -1147,12 +1144,12 @@ class YCylinder(Cylinder):
_type = 'y-cylinder'
_coeff_keys = ('x0', 'z0', 'r')
def __init__(self, surface_id=None, boundary_type='transmission',
x0=0., z0=0., r=1., name='', *, R=None):
def __init__(self, x0=0., z0=0., r=1., boundary_type='transmission',
name='', surface_id=None, *, R=None):
if R is not None:
warn(_WARNING_UPPER.format(type(self).__name__, 'r', 'R'), FutureWarning)
r = R
super().__init__(surface_id, boundary_type, r, name=name)
super().__init__(r, boundary_type, name, surface_id)
self.x0 = x0
self.z0 = z0
@ -1294,12 +1291,12 @@ class ZCylinder(Cylinder):
_type = 'z-cylinder'
_coeff_keys = ('x0', 'y0', 'r')
def __init__(self, surface_id=None, boundary_type='transmission',
x0=0., y0=0., r=1., name='', *, R=None):
def __init__(self, x0=0., y0=0., r=1., boundary_type='transmission',
name='', surface_id=None, *, R=None):
if R is not None:
warn(_WARNING_UPPER.format(type(self).__name__, 'r', 'R'), FutureWarning)
r = R
super().__init__(surface_id, boundary_type, r, name=name)
super().__init__(r, boundary_type, name, surface_id)
self.x0 = x0
self.y0 = y0
@ -1400,13 +1397,6 @@ class Sphere(Surface):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
x0 : float, optional
x-coordinate of the center of the sphere. Defaults to 0.
y0 : float, optional
@ -1415,8 +1405,15 @@ class Sphere(Surface):
z-coordinate of the center of the sphere. Defaults to 0.
r : float, optional
Radius of the sphere. Defaults to 1.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
name : str, optional
Name of the sphere. If not specified, the name will be the empty string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -1445,8 +1442,8 @@ class Sphere(Surface):
_type = 'sphere'
_coeff_keys = ('x0', 'y0', 'z0', 'r')
def __init__(self, surface_id=None, boundary_type='transmission',
x0=0., y0=0., z0=0., r=1., name='', *, R=None):
def __init__(self, x0=0., y0=0., z0=0., r=1., boundary_type='transmission',
name='', surface_id=None, *, R=None):
if R is not None:
warn(_WARNING_UPPER.format(type(self).__name__, 'r', 'R'), FutureWarning)
r = R
@ -1574,6 +1571,14 @@ class Cone(Surface):
Parameters
----------
x0 : float, optional
x-coordinate of the apex. Defaults to 0.
y0 : float, optional
y-coordinate of the apex. Defaults to 0.
z0 : float, optional
z-coordinate of the apex. Defaults to 0.
r2 : float, optional
Parameter related to the aperature. Defaults to 1.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
@ -1581,14 +1586,6 @@ class Cone(Surface):
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
x0 : float, optional
x-coordinate of the apex. Defaults to 0.
y0 : float
y-coordinate of the apex. Defaults to 0.
z0 : float
z-coordinate of the apex. Defaults to 0.
r2 : float
Parameter related to the aperature. Defaults to 1.
name : str
Name of the cone. If not specified, the name will be the empty string.
@ -1618,8 +1615,8 @@ class Cone(Surface):
_coeff_keys = ('x0', 'y0', 'z0', 'r2')
def __init__(self, surface_id=None, boundary_type='transmission',
x0=0., y0=0., z0=0., r2=1., name='', *, R2=None):
def __init__(self, x0=0., y0=0., z0=0., r2=1., boundary_type='transmission',
name='', surface_id=None, *, R2=None):
if R2 is not None:
warn(_WARNING_UPPER.format(type(self).__name__, 'r2', 'R2'), FutureWarning)
r2 = R2
@ -1695,13 +1692,6 @@ class XCone(Cone):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
x0 : float, optional
x-coordinate of the apex. Defaults to 0.
y0 : float, optional
@ -1710,8 +1700,15 @@ class XCone(Cone):
z-coordinate of the apex. Defaults to 0.
r2 : float, optional
Parameter related to the aperature. Defaults to 1.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
name : str, optional
Name of the cone. If not specified, the name will be the empty string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -1766,13 +1763,6 @@ class YCone(Cone):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
x0 : float, optional
x-coordinate of the apex. Defaults to 0.
y0 : float, optional
@ -1781,8 +1771,15 @@ class YCone(Cone):
z-coordinate of the apex. Defaults to 0.
r2 : float, optional
Parameter related to the aperature. Defaults to 1.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
name : str, optional
Name of the cone. If not specified, the name will be the empty string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -1837,13 +1834,6 @@ class ZCone(Cone):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
x0 : float, optional
x-coordinate of the apex. Defaults to 0.
y0 : float, optional
@ -1852,8 +1842,15 @@ class ZCone(Cone):
z-coordinate of the apex. Defaults to 0.
r2 : float, optional
Parameter related to the aperature. Defaults to 1.
boundary_type : {'transmission, 'vacuum', 'reflective'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
name : str, optional
Name of the cone. If not specified, the name will be the empty string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -1908,17 +1905,17 @@ class Quadric(Surface):
Parameters
----------
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
a, b, c, d, e, f, g, h, j, k : float, optional
coefficients for the surface. All default to 0.
boundary_type : {'transmission, 'vacuum', 'reflective', 'periodic'}, optional
Boundary condition that defines the behavior for particles hitting the
surface. Defaults to transmissive boundary condition where particles
freely pass through the surface.
a, b, c, d, e, f, g, h, j, k : float, optional
coefficients for the surface. All default to 0.
name : str, optional
Name of the surface. If not specified, the name will be the empty string.
surface_id : int, optional
Unique identifier for the surface. If not specified, an identifier will
automatically be assigned.
Attributes
----------
@ -1941,9 +1938,8 @@ class Quadric(Surface):
_type = 'quadric'
_coeff_keys = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k')
def __init__(self, surface_id=None, boundary_type='transmission',
a=0., b=0., c=0., d=0., e=0., f=0., g=0.,
h=0., j=0., k=0., name=''):
def __init__(self, a=0., b=0., c=0., d=0., e=0., f=0., g=0., h=0., j=0.,
k=0., boundary_type='transmission', name='', surface_id=None):
super().__init__(surface_id, boundary_type, name=name)
self.a = a
self.b = b

View file

@ -25,12 +25,12 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
[water, water, water]]
# Create bounding surfaces
min_x = openmc.XPlane(x0=-32.13, boundary_type='reflective')
max_x = openmc.XPlane(x0=+32.13, boundary_type='reflective')
min_y = openmc.YPlane(y0=-32.13, boundary_type='reflective')
max_y = openmc.YPlane(y0=+32.13, boundary_type='reflective')
min_z = openmc.ZPlane(z0=0, boundary_type='reflective')
max_z = openmc.ZPlane(z0=+32.13, boundary_type='reflective')
min_x = openmc.XPlane(-32.13, 'reflective')
max_x = openmc.XPlane(+32.13, 'reflective')
min_y = openmc.YPlane(-32.13, 'reflective')
max_y = openmc.YPlane(+32.13, 'reflective')
min_z = openmc.ZPlane(0, 'reflective')
max_z = openmc.ZPlane(+32.13, 'reflective')
# Define root universe
root_univ = openmc.Universe(universe_id=0, name='root universe')

View file

@ -158,6 +158,7 @@ def generate_initial_number_density():
return temperature, sab, initial_density, burn
def segment_pin(n_rings, n_wedges, r_fuel, r_gap, r_clad):
""" Calculates a segmented pin.
@ -248,6 +249,7 @@ def segment_pin(n_rings, n_wedges, r_fuel, r_gap, r_clad):
return fuel_u, v_segment, v_gap, v_clad
def generate_geometry(n_rings, n_wedges):
""" Generates example geometry.
@ -296,12 +298,12 @@ def generate_geometry(n_rings, n_wedges):
lattice.outer = all_water_u
# Bound universe
x_low = openmc.XPlane(x0=-pitch*n_pin/2, boundary_type='reflective')
x_high = openmc.XPlane(x0=pitch*n_pin/2, boundary_type='reflective')
y_low = openmc.YPlane(y0=-pitch*n_pin/2, boundary_type='reflective')
y_high = openmc.YPlane(y0=pitch*n_pin/2, boundary_type='reflective')
z_low = openmc.ZPlane(z0=-10, boundary_type='reflective')
z_high = openmc.ZPlane(z0=10, boundary_type='reflective')
x_low = openmc.XPlane(-pitch*n_pin/2, 'reflective')
x_high = openmc.XPlane(pitch*n_pin/2, 'reflective')
y_low = openmc.YPlane(-pitch*n_pin/2, 'reflective')
y_high = openmc.YPlane(pitch*n_pin/2, 'reflective')
z_low = openmc.ZPlane(-10, 'reflective')
z_high = openmc.ZPlane(10, 'reflective')
# Compute bounding box
lower_left = [-pitch*n_pin/2, -pitch*n_pin/2, -10]
@ -317,10 +319,11 @@ def generate_geometry(n_rings, n_wedges):
v_cool = pitch**2 - (v_gap + v_clad + n_rings * n_wedges * v_segment)
# Store volumes for later usage
volume = {'fuel': v_segment, 'gap':v_gap, 'clad':v_clad, 'cool':v_cool}
volume = {'fuel': v_segment, 'gap': v_gap, 'clad': v_clad, 'cool': v_cool}
return geometry, volume, mapping, lower_left, upper_right
def generate_problem(n_rings=5, n_wedges=8):
""" Merges geometry and materials.

View file

@ -21,16 +21,16 @@ class PeriodicTest(PyAPITestHarness):
materials.export_to_xml()
# Define geometry
x_min = openmc.XPlane(1, x0=-5., boundary_type='periodic')
x_max = openmc.XPlane(2, x0=5., boundary_type='periodic')
x_min = openmc.XPlane(surface_id=1, x0=-5., boundary_type='periodic')
x_max = openmc.XPlane(surface_id=2, x0=5., boundary_type='periodic')
x_max.periodic_surface = x_min
y_min = openmc.YPlane(3, y0=-5., boundary_type='periodic')
y_max = openmc.YPlane(4, y0=5., boundary_type='periodic')
y_min = openmc.YPlane(surface_id=3, y0=-5., boundary_type='periodic')
y_max = openmc.YPlane(surface_id=4, y0=5., boundary_type='periodic')
z_min = openmc.ZPlane(5, z0=-5., boundary_type='reflective')
z_max = openmc.ZPlane(6, z0=5., boundary_type='reflective')
z_cyl = openmc.ZCylinder(7, x0=-2.5, y0=2.5, r=2.0)
z_min = openmc.ZPlane(surface_id=5, z0=-5., boundary_type='reflective')
z_max = openmc.ZPlane(surface_id=6, z0=5., boundary_type='reflective')
z_cyl = openmc.ZCylinder(surface_id=7, x0=-2.5, y0=2.5, r=2.0)
outside_cyl = openmc.Cell(1, fill=water, region=(
+x_min & -x_max & +y_min & -y_max & +z_min & -z_max & +z_cyl))

View file

@ -14,10 +14,10 @@ class SourceTestHarness(PyAPITestHarness):
materials = openmc.Materials([mat])
materials.export_to_xml()
cyl = openmc.XCylinder(boundary_type='vacuum', r=1.0)
x_plane_left = openmc.XPlane(boundary_type='vacuum', x0=-1.0)
x_plane_center = openmc.XPlane(boundary_type='transmission', x0=1.0)
x_plane_right = openmc.XPlane(boundary_type='vacuum', x0=1.0e9)
cyl = openmc.XCylinder(r=1.0, boundary_type='vacuum')
x_plane_left = openmc.XPlane(-1.0, 'vacuum')
x_plane_center = openmc.XPlane(1.0)
x_plane_right = openmc.XPlane(1.0e9, 'vacuum')
inner_cyl_left = openmc.Cell()
inner_cyl_right = openmc.Cell()
@ -31,7 +31,7 @@ class SourceTestHarness(PyAPITestHarness):
geometry.export_to_xml()
source = openmc.Source()
source.space = openmc.stats.Point((0,0,0))
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Monodirectional()
source.energy = openmc.stats.Discrete([14.0e6], [1.0])
source.particle = 'neutron'

View file

@ -17,7 +17,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness):
mats_file.export_to_xml()
# Geometry
dumb_surface = openmc.XPlane(x0=100, boundary_type='reflective')
dumb_surface = openmc.XPlane(100, 'reflective')
c1 = openmc.Cell(cell_id=1, fill=mat, region=-dumb_surface)
root_univ = openmc.Universe(universe_id=0, cells=[c1])
geometry = openmc.Geometry(root_univ)

View file

@ -44,11 +44,11 @@ def make_model():
model.materials += [m1, m2, m3, m4]
# Geometry
x0 = openmc.XPlane(x0=-10, boundary_type='vacuum')
x1 = openmc.XPlane(x0=-5)
x2 = openmc.XPlane(x0=0)
x3 = openmc.XPlane(x0=5)
x4 = openmc.XPlane(x0=10, boundary_type='vacuum')
x0 = openmc.XPlane(-10, 'vacuum')
x1 = openmc.XPlane(-5)
x2 = openmc.XPlane(0)
x3 = openmc.XPlane(5)
x4 = openmc.XPlane(10, 'vacuum')
root_univ = openmc.Universe()

View file

@ -54,12 +54,12 @@ class TRISOTestHarness(PyAPITestHarness):
inner_univ = openmc.Universe(cells=[c1, c2, c3, c4, c5])
# Define box to contain lattice and to pack TRISO particles in
min_x = openmc.XPlane(x0=-0.5, boundary_type='reflective')
max_x = openmc.XPlane(x0=0.5, boundary_type='reflective')
min_y = openmc.YPlane(y0=-0.5, boundary_type='reflective')
max_y = openmc.YPlane(y0=0.5, boundary_type='reflective')
min_z = openmc.ZPlane(z0=-0.5, boundary_type='reflective')
max_z = openmc.ZPlane(z0=0.5, boundary_type='reflective')
min_x = openmc.XPlane(-0.5, 'reflective')
max_x = openmc.XPlane(0.5, 'reflective')
min_y = openmc.YPlane(-0.5, 'reflective')
max_y = openmc.YPlane(0.5, 'reflective')
min_z = openmc.ZPlane(-0.5, 'reflective')
max_z = openmc.ZPlane(0.5, 'reflective')
box_region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z
box = openmc.Cell(region=box_region)

View file

@ -25,11 +25,11 @@ class VolumeTest(PyAPITestHarness):
materials = openmc.Materials((water, fuel))
materials.export_to_xml()
cyl = openmc.ZCylinder(1, r=1.0, boundary_type='vacuum')
top_sphere = openmc.Sphere(2, z0=5., r=1., boundary_type='vacuum')
top_plane = openmc.ZPlane(3, z0=5.)
bottom_sphere = openmc.Sphere(4, z0=-5., r=1., boundary_type='vacuum')
bottom_plane = openmc.ZPlane(5, z0=-5.)
cyl = openmc.ZCylinder(surface_id=1, r=1.0, boundary_type='vacuum')
top_sphere = openmc.Sphere(surface_id=2, z0=5., r=1., boundary_type='vacuum')
top_plane = openmc.ZPlane(surface_id=3, z0=5.)
bottom_sphere = openmc.Sphere(surface_id=4, z0=-5., r=1., boundary_type='vacuum')
bottom_plane = openmc.ZPlane(surface_id=5, z0=-5.)
# Define geometry
inside_cyl = openmc.Cell(1, fill=fuel, region=-cyl & -top_plane & +bottom_plane)

View file

@ -97,11 +97,11 @@ def mixed_lattice_model(uo2, water):
[empty_univ, u]
]
xmin = openmc.XPlane(x0=-d, boundary_type='periodic')
xmax = openmc.XPlane(x0=d, boundary_type='periodic')
xmin = openmc.XPlane(-d, 'periodic')
xmax = openmc.XPlane(d, 'periodic')
xmin.periodic_surface = xmax
ymin = openmc.YPlane(y0=-d, boundary_type='periodic')
ymax = openmc.YPlane(y0=d, boundary_type='periodic')
ymin = openmc.YPlane(-d, 'periodic')
ymax = openmc.YPlane(d, 'periodic')
main_cell = openmc.Cell(fill=rect_lattice,
region=+xmin & -xmax & +ymin & -ymax)

View file

@ -27,21 +27,21 @@ def complex_cell(run_in_tmpdir):
model.materials = (u235, u238, zr90, n14)
s1 = openmc.XPlane(x0=-10.0, boundary_type='vacuum')
s2 = openmc.XPlane(x0=-7.0)
s3 = openmc.XPlane(x0=-4.0)
s4 = openmc.XPlane(x0=4.0)
s5 = openmc.XPlane(x0=7.0)
s6 = openmc.XPlane(x0=10.0, boundary_type='vacuum')
s7 = openmc.XPlane(x0=0.0)
s1 = openmc.XPlane(-10.0, 'vacuum')
s2 = openmc.XPlane(-7.0)
s3 = openmc.XPlane(-4.0)
s4 = openmc.XPlane(4.0)
s5 = openmc.XPlane(7.0)
s6 = openmc.XPlane(10.0, 'vacuum')
s7 = openmc.XPlane(0.0)
s11 = openmc.YPlane(y0=-10.0, boundary_type='vacuum')
s12 = openmc.YPlane(y0=-7.0)
s13 = openmc.YPlane(y0=-4.0)
s14 = openmc.YPlane(y0=4.0)
s15 = openmc.YPlane(y0=7.0)
s16 = openmc.YPlane(y0=10.0, boundary_type='vacuum')
s17 = openmc.YPlane(y0=0.0)
s11 = openmc.YPlane(-10.0, 'vacuum')
s12 = openmc.YPlane(-7.0)
s13 = openmc.YPlane(-4.0)
s14 = openmc.YPlane(4.0)
s15 = openmc.YPlane(7.0)
s16 = openmc.YPlane(10.0, 'vacuum')
s17 = openmc.YPlane(0.0)
c1 = openmc.Cell(fill=u235)
c1.region = ~(-s3 | +s4 | ~(+s13 & -s14))

View file

@ -34,12 +34,12 @@ def centers(request, container):
@pytest.fixture(scope='module')
def centers_rectangular_prism():
min_x = openmc.XPlane(x0=0)
max_x = openmc.XPlane(x0=1)
min_y = openmc.YPlane(y0=0)
max_y = openmc.YPlane(y0=1)
min_z = openmc.ZPlane(z0=0)
max_z = openmc.ZPlane(z0=1)
min_x = openmc.XPlane(0)
max_x = openmc.XPlane(1)
min_y = openmc.YPlane(0)
max_y = openmc.YPlane(1)
min_z = openmc.ZPlane(0)
max_z = openmc.ZPlane(1)
region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z
return openmc.model.pack_spheres(radius=_RADIUS, region=region,
pf=_PACKING_FRACTION, initial_pf=0.2)
@ -48,8 +48,8 @@ def centers_rectangular_prism():
@pytest.fixture(scope='module')
def centers_x_cylinder():
cylinder = openmc.XCylinder(r=1, y0=1, z0=2)
min_x = openmc.XPlane(x0=0)
max_x = openmc.XPlane(x0=1)
min_x = openmc.XPlane(0)
max_x = openmc.XPlane(1)
region = +min_x & -max_x & -cylinder
return openmc.model.pack_spheres(radius=_RADIUS, region=region,
pf=_PACKING_FRACTION, initial_pf=0.2)
@ -58,8 +58,8 @@ def centers_x_cylinder():
@pytest.fixture(scope='module')
def centers_y_cylinder():
cylinder = openmc.YCylinder(r=1, x0=1, z0=2)
min_y = openmc.YPlane(y0=0)
max_y = openmc.YPlane(y0=1)
min_y = openmc.YPlane(0)
max_y = openmc.YPlane(1)
region = +min_y & -max_y & -cylinder
return openmc.model.pack_spheres(radius=_RADIUS, region=region,
pf=_PACKING_FRACTION, initial_pf=0.2)
@ -68,8 +68,8 @@ def centers_y_cylinder():
@pytest.fixture(scope='module')
def centers_z_cylinder():
cylinder = openmc.ZCylinder(r=1, x0=1, y0=2)
min_z = openmc.ZPlane(z0=0)
max_z = openmc.ZPlane(z0=1)
min_z = openmc.ZPlane(0)
max_z = openmc.ZPlane(1)
region = +min_z & -max_z & -cylinder
return openmc.model.pack_spheres(radius=_RADIUS, region=region,
pf=_PACKING_FRACTION, initial_pf=0.2)

View file

@ -11,8 +11,8 @@ def reset():
def test_union(reset):
s1 = openmc.XPlane(surface_id=1, x0=5)
s2 = openmc.XPlane(surface_id=2, x0=-5)
s1 = openmc.XPlane(x0=5, surface_id=1)
s2 = openmc.XPlane(x0=-5, surface_id=2)
region = +s1 | -s2
assert isinstance(region, openmc.Union)
@ -42,8 +42,8 @@ def test_union(reset):
def test_intersection(reset):
s1 = openmc.XPlane(surface_id=1, x0=5)
s2 = openmc.XPlane(surface_id=2, x0=-5)
s1 = openmc.XPlane(x0=5, surface_id=1)
s2 = openmc.XPlane(x0=-5, surface_id=2)
region = -s1 & +s2
assert isinstance(region, openmc.Intersection)
@ -75,9 +75,9 @@ def test_intersection(reset):
def test_complement(reset):
zcyl = openmc.ZCylinder(surface_id=1, r=1.)
z0 = openmc.ZPlane(surface_id=2, z0=-5.)
z1 = openmc.ZPlane(surface_id=3, z0=5.)
zcyl = openmc.ZCylinder(r=1., surface_id=1)
z0 = openmc.ZPlane(-5., surface_id=2)
z1 = openmc.ZPlane(5., surface_id=3)
outside = +zcyl | -z0 | +z1
inside = ~outside
outside_equiv = ~(-zcyl & +z0 & -z1)
@ -151,8 +151,8 @@ def test_extend_clone():
def test_from_expression(reset):
# Create surface dictionary
s1 = openmc.ZCylinder(surface_id=1)
s2 = openmc.ZPlane(surface_id=2, z0=-10.)
s3 = openmc.ZPlane(surface_id=3, z0=10.)
s2 = openmc.ZPlane(-10., surface_id=2)
s3 = openmc.ZPlane(10., surface_id=3)
surfs = {1: s1, 2: s2, 3: s3}
r = openmc.Region.from_expression('-1 2 -3', surfs)

View file

@ -55,7 +55,7 @@ def test_plane_from_points():
def test_xplane():
s = openmc.XPlane(x0=3., boundary_type='reflective')
s = openmc.XPlane(3., 'reflective')
assert s.x0 == 3.
assert s.boundary_type == 'reflective'