Created
March 2, 2022 12:56
-
-
Save pshriwise/8808238f2c87ff18a4e5055b6d80362b to your computer and use it in GitHub Desktop.
Lattice within manually defined cells
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openmc | |
# constants | |
l = 1.0 | |
h = 1.0 | |
model = openmc.model.Model() | |
# materials | |
m_fuel = openmc.Material() | |
m_fuel.set_density('kg/m3', 10820) | |
m_fuel.add_nuclide('U234', 0.0020301709666386285, 'ao') | |
m_fuel.add_nuclide('U235', 0.8413029718075326, 'ao') | |
m_fuel.add_nuclide('U238', 0.15666685722582877, 'ao') | |
m_fuel.add_nuclide('O16', 0.4998105, 'ao') | |
m_graphite_matrix = openmc.Material() | |
m_graphite_matrix.set_density('kg/m3', 1700) | |
m_graphite_matrix.add_element('C', 1.0) | |
m_graphite_matrix.add_s_alpha_beta('c_Graphite') | |
# infinite fuel and moterator cells | |
fuel_cell = openmc.Cell(name="Fuel", fill=m_fuel) | |
fuel_univ = openmc.Universe(cells=[fuel_cell]) | |
mod_cell = openmc.Cell(name="Moderator", fill=m_graphite_matrix) | |
mod_univ = openmc.Universe(cells=[mod_cell]) | |
# Define planes that will be defined for cells to fill with the universe | |
min_z = openmc.ZPlane(z0=0.0, boundary_type='reflective') | |
max_z = openmc.ZPlane(z0=h, boundary_type='reflective') | |
min_x = openmc.XPlane(x0=-l, boundary_type='reflective') | |
max_x = openmc.XPlane(x0=l, boundary_type='reflective') | |
min_y = openmc.YPlane(y0=-l, boundary_type='reflective') | |
max_y = openmc.YPlane(y0=0, boundary_type='reflective') | |
# separate into three sections along y | |
y0 = openmc.YPlane(y0=0) | |
y1 = openmc.YPlane(y0=-l/3) | |
y2 = openmc.YPlane(y0=-2*l/3) | |
y3 = openmc.YPlane(y0=-l) | |
quadrants = [+y3 & -y2, +y2 & -y1, +y1 & -y0] | |
# define a regular lattice | |
reg_lattice = openmc.RectLattice() | |
reg_lattice.universes = [[[fuel_univ, mod_univ], [mod_univ, fuel_univ]], # k = 0 | |
[[mod_univ, fuel_univ], [fuel_univ, mod_univ]]] # k = 1 | |
lattice_region = +min_y & -max_y & +min_x & -max_x & +min_z & -max_z | |
llc, urc = lattice_region.bounding_box | |
reg_lattice.lower_left = llc | |
reg_lattice.pitch = (urc - llc) / reg_lattice.shape | |
print("Regular lattice shape: {}".format(reg_lattice.shape)) | |
# uncomment and fill cells with lattice_univ to fix | |
# lattice_cell = openmc.Cell(fill=reg_lattice) | |
# lattice_univ = openmc.Universe(cells=[lattice_cell]) | |
y_section_0 = openmc.Cell(region=quadrants[0], fill=reg_lattice) | |
y_section_1 = openmc.Cell(region=quadrants[1], fill=reg_lattice) | |
y_section_2 = openmc.Cell(region=quadrants[2], fill=reg_lattice) | |
y_sections = [y_section_0, y_section_1, y_section_2] | |
inner_univ = openmc.Universe(cells=y_sections) | |
main_cell = openmc.Cell(region=lattice_region, fill=inner_univ) | |
model.geometry = openmc.Geometry([main_cell]) | |
# some settings | |
settings = openmc.Settings() | |
settings.particles = 1000 | |
settings.inactive = 2 | |
settings.batches = 10 | |
settings.temperature['method'] = 'interpolation' | |
settings.temperature['multipole'] = True | |
settings.temperature['range'] = (294.0, 1500.0) | |
settings.temperature['default'] = 500.0 | |
lower_left = (-l, -l, 0.0) | |
upper_right = (l, 0, h) | |
source_dist = openmc.stats.Box(lower_left, upper_right) | |
source = openmc.Source(space=source_dist) | |
settings.source = source | |
model.settings = settings | |
model.export_to_xml() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment