Use multiple universes for TRISOs

This commit is contained in:
Sterling Harper 2016-06-07 17:11:59 -05:00 committed by Paul Romano
parent 07ef67fee0
commit 55e1ebff2d
5 changed files with 48 additions and 42 deletions

View file

@ -12,18 +12,17 @@ class TRISO(object):
Parameters
----------
materials : Iterable of openmc.Material
Material to be assigned to each layer of the TRISO particle starting
with the innermost and proceeding outwards
radii : Iterable of float
Outer radii in cm of each layer of the TRISO particle in ascending order
outer_radius : int
Outer radius of TRISO particle
inner_univ : openmc.Universe
Universe which contains all layers of the TRISO particle
center : Iterable of float
Cartesian coordinates of the center of the TRISO particle in cm
Attributes
----------
cells : list of opemc.Cell
Each layer of the TRISO particle
cell : opemc.Cell
Cell which contains the TRISO universe
center : numpy.ndarray
Cartesian coordinates of the center of the TRISO particle in cm
outside : openmc.Region
@ -34,27 +33,18 @@ class TRISO(object):
"""
def __init__(self, materials, radii, center=(0., 0., 0.)):
surfaces = [openmc.Sphere(R=r) for r in radii]
cells = []
for i, m in enumerate(materials):
c = openmc.Cell(fill=m)
if i == 0:
c.region = -surfaces[i]
else:
c.region = +surfaces[i-1] & -surfaces[i]
cells.append(c)
self._cells = cells
self._surfaces = surfaces
def __init__(self, outer_radius, inner_univ, center=(0., 0., 0.)):
self._surface = openmc.Sphere(R=outer_radius)
self._cell = openmc.Cell(fill=inner_univ, region=-self._surface)
self.center = np.asarray(center)
@property
def bounding_box(self):
return self.cells[-1].region.bounding_box
return self.cell.region.bounding_box
@property
def cells(self):
return self._cells
def cell(self):
return self._cell
@property
def center(self):
@ -62,13 +52,15 @@ class TRISO(object):
@property
def outside(self):
return ~self.cells[-1].region.nodes[-1]
return +self._surface
@center.setter
def center(self, center):
cv.check_type('TRISO center', center, Iterable, Real)
for s in self._surfaces:
s.x0, s.y0, s.z0 = center
self._surface.x0 = center[0]
self._surface.y0 = center[1]
self._surface.z0 = center[2]
self.cell.translation = center
self._center = center
def classify(self, lattice):
@ -136,11 +128,9 @@ def create_triso_lattice(trisos, lower_left, pitch, shape, background):
# Create copy of TRISO particle with materials preserved and
# different cell/surface IDs
t_copy = copy.deepcopy(t)
for c, c_copy in zip(t.cells, t_copy.cells):
c_copy.id = None
c_copy.fill = c.fill
for s in t_copy._surfaces:
s.id = None
t_copy.cell.id = None
t_copy.cell.fill = t.cell.fill
t_copy._surface.id = None
triso_locations[idx].append(t_copy)
# Create universes
@ -155,7 +145,7 @@ def create_triso_lattice(trisos, lower_left, pitch, shape, background):
u = openmc.Universe()
u.add_cell(background_cell)
for t in triso_list:
u.add_cells(t.cells)
u.add_cell(t.cell)
iz, iy, ix = idx
t.center = lattice.get_local_coordinates(t.center, (ix, iy, iz))

View file

@ -1 +1 @@
6c6fecedf3db0b91b69b7b7b57b3a52c42947253bea4ee3889d6bbd6e74935cc4e599c1c743eb589a1045868412f3f88c5fef7cf10e180bdc4bd182970c9ee15
2dcfd1a17cba671874e60192a7355deb57e2e51467a474fd168c8b51e454a977edb34df07ae11625c0a43906112152c75113e442a9a8f240a4c9d1a11ee4771d

View file

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<plots>
<plot id="1" type="slice" basis="xy" color="material"
origin="0.0 0.0 0.0" width="1.0 1.0" pixels="400 400">
</plot>
</plots>

View file

@ -1,2 +1,2 @@
k-combined:
1.685303E+00 1.121936E-01
1.662675E+00 1.475968E-02

View file

@ -50,22 +50,31 @@ class TRISOTestHarness(PyAPITestHarness):
graphite.add_s_alpha_beta('Graph', '71t')
# Create TRISO particles
materials = [fuel, porous_carbon, ipyc, sic, opyc]
radii = np.array([212.5, 312.5, 347.5, 382.5, 422.5])*1e-4
spheres = [openmc.Sphere(R=r*1e-4)
for r in [212.5, 312.5, 347.5, 382.5]]
c1 = openmc.Cell(fill=fuel, region=-spheres[0])
c2 = openmc.Cell(fill=porous_carbon, region=+spheres[0] & -spheres[1])
c3 = openmc.Cell(fill=ipyc, region=+spheres[1] & -spheres[2])
c4 = openmc.Cell(fill=sic, region=+spheres[2] & -spheres[3])
c5 = openmc.Cell(fill=opyc, region=+spheres[3])
inner_univ = openmc.Universe(cells=[c1, c2, c3, c4, c5])
outer_radius = 422.5*1e-4
trisos = []
random.seed(1)
for i in range(100):
# Randomly sample location
x = random.uniform(-0.5, 0.5)
y = random.uniform(-0.5, 0.5)
z = random.uniform(-0.5, 0.5)
t = openmc.model.TRISO(materials, radii, (x, y, z))
lim = 0.5 - outer_radius*1.001
x = random.uniform(-lim, lim)
y = random.uniform(-lim, lim)
z = random.uniform(-lim, lim)
t = openmc.model.TRISO(outer_radius, inner_univ, (x, y, z))
# Make sure TRISO doesn't overlap with another
for tp in trisos:
xp, yp, zp = tp.center
distance = sqrt((x - xp)**2 + (y - yp)**2 + (z - zp)**2)
if distance <= 2*radii[-1]:
if distance <= 2*outer_radius:
break
else:
trisos.append(t)
@ -82,8 +91,9 @@ class TRISOTestHarness(PyAPITestHarness):
# Create lattice
ll, ur = box.region.bounding_box
shape = (3, 3, 3)
pitch = (ur - ll) / shape
lattice = openmc.model.create_triso_lattice(
trisos, ll, (ur - ll)/shape, shape, graphite)
trisos, ll, pitch, shape, graphite)
box.fill = lattice
root = openmc.Universe(0, cells=[box])
@ -93,7 +103,7 @@ class TRISOTestHarness(PyAPITestHarness):
settings = openmc.Settings()
settings.batches = 5
settings.inactive = 0
settings.particles = 50
settings.particles = 100
settings.source = openmc.Source(space=openmc.stats.Point())
settings.export_to_xml()