ecp-benchmarks/2x2-reflector/geometry.py
2017-03-18 21:42:59 -04:00

151 lines
5.4 KiB
Python

import openmc
from beavrs.builder import BEAVRS
def find_assembly(assembly_name, wrap_geometry=True):
"""Find a fuel assembly with some string name in the BEAVRS OpenMC model.
This method extracts the fuel assembly and wraps it in an OpenMC Geometry.
The returned geometry has reflective boundary conditions along all
boundaries. The z-axis is bounded between z=200 and z=210 cm.
Parameters
----------
assembly_name : str
The name of the fuel assembly lattice
wrap_geometry : bool
If false, the fuel assembly Lattice is returned. If true, the fuel
assembly Lattice is wrapped in an OpenMC Geometry and returned (default).
Returns
-------
fuel_assembly
The OpenMC Lattice or Geometry for the assembly or None if not found
"""
# Get OpenMC Lattices for the fuel assembly
fuel_assembly = \
beavrs.openmc_geometry.get_lattices_by_name(assembly_name)[0]
# Wrap lattice in a Geometry if requested by the user
if wrap_geometry:
# Create a root Cell
root_cell = openmc.Cell(name='root cell')
root_cell.fill = fuel_assembly
# Make mixed reflective / vacuum boundaries
min_x = openmc.XPlane(x0=-10.70864, boundary_type='reflective')
max_x = openmc.XPlane(x0=+-10.70864, boundary_type='reflective')
min_y = openmc.YPlane(y0=-10.70864, boundary_type='reflective')
max_y = openmc.YPlane(y0=+-10.70864, boundary_type='reflective')
max_z = openmc.ZPlane(z0=197.5, boundary_type='reflective')
min_z = openmc.ZPlane(z0=192.5, boundary_type='reflective')
# Add boundaries to the root Cell
root_cell.region = \
+min_x & -max_x & +min_y & -max_y & +min_z & -max_z
# Create a root Universe
root_univ = openmc.Universe(universe_id=0, name='root universe')
root_univ.add_cell(root_cell)
# Create a Geometry
fuel_assembly = openmc.Geometry(root_univ)
return fuel_assembly
def build_reflector(assembly1_name, assembly2_name):
"""Build a 2x2 fuel assembly geometry with a water reflector on the
bottom and right.
This routine puts reflective boundary conditions along min x, max y and z
and vacuum boundary conditions along the max x and min y boundaries.
Parameters
----------
assembly1_name : str
The BEAVRS fuel assembly to place in the bottom right and top left
assembly2_name : str
The BEAVRS fuel assembly to place in the bottom left and top right
Returns
-------
openmc.Geometry
A 2x2 fuel assembly and reflector OpenMC Geometry
"""
fuel_assembly1 = find_assembly(assembly1_name, wrap_geometry=False)
fuel_assembly2 = find_assembly(assembly2_name, wrap_geometry=False)
# Find the water material
all_cells = beavrs.main_universe.get_all_cells()
for cell_uuid, cell in all_cells.items():
if cell.fill_type == 'material' and cell.fill.name == 'Borated Water':
water = cell.fill
# Create a Cell/Universe around the first fuel assembly
fuel_cell1 = openmc.Cell(name='assm1 cell')
fuel_cell1.fill = fuel_assembly1
fuel_univ1 = openmc.Universe(name='assm1 universe')
fuel_univ1.add_cell(fuel_cell1)
# Create a Cell/Universe around the second fuel assembly
fuel_cell2 = openmc.Cell(name='assm2 cell')
fuel_cell2.fill = fuel_assembly2
fuel_univ2 = openmc.Universe(name='assm2 universe')
fuel_univ2.add_cell(fuel_cell2)
# Create a Cell/Universe with water
water_cell = openmc.Cell(name='water cell', fill=water)
water_univ = openmc.Universe(name='water universe')
water_univ.add_cell(water_cell)
# Create a 3x3 lattice two fuel assemblies surrounded by a water reflector
reflector_lattice = openmc.RectLattice(name='reflector')
reflector_lattice.lower_left = [-32.12592, -32.12592, -500.]
reflector_lattice.pitch = [21.41728, 21.41728, 1000.]
reflector_lattice.universes = [[[fuel_univ1, fuel_univ2, water_univ],
[fuel_univ2, fuel_univ1, water_univ],
[water_univ, water_univ, water_univ]]]
# Create a Geometry around the reflected lattice
root_cell = openmc.Cell(name='root cell')
root_cell.fill = reflector_lattice
# Make mixed reflective / vacuum boundaries
min_x = openmc.XPlane(x0=-32.12592, boundary_type='reflective')
max_x = openmc.XPlane(x0=+32.12592, boundary_type='vacuum')
min_y = openmc.YPlane(y0=-32.12592, boundary_type='vacuum')
max_y = openmc.YPlane(y0=+32.12592, boundary_type='reflective')
min_z = openmc.ZPlane(z0=192.5, boundary_type='reflective')
max_z = openmc.ZPlane(z0=197.5, boundary_type='reflective')
# Add boundaries to the root Cell
root_cell.region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z
# Create a root Universe for this fuel assembly
root_univ = openmc.Universe(universe_id=0, name='root universe')
root_univ.add_cell(root_cell)
# Create an OpenMC Geometry for this fuel assembly
reflector = openmc.Geometry()
reflector.root_universe = root_univ
return reflector
#### Create OpenMC "materials.xml" and "geometry.xml" files
# Instantiate a BEAVRS object
beavrs = BEAVRS()
# Write all BEAVRS materials to materials.xml file
beavrs.write_openmc_materials()
# Extract fuel assemblies of interest from BEAVRS model
openmc_geometry = build_reflector('Fuel 1.6% enr instr no BAs',
'Fuel 3.1% enr instr 20')