mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Improved hex lattice example for #331
This commit is contained in:
parent
f82103a3a9
commit
a996bccbef
1 changed files with 46 additions and 63 deletions
|
|
@ -19,6 +19,7 @@ particles = 10000
|
|||
h1 = openmc.Nuclide('H-1')
|
||||
o16 = openmc.Nuclide('O-16')
|
||||
u235 = openmc.Nuclide('U-235')
|
||||
fe56 = openmc.Nuclide('Fe-56')
|
||||
|
||||
# Instantiate some Materials and register the appropriate Nuclides
|
||||
fuel = openmc.Material(material_id=1, name='fuel')
|
||||
|
|
@ -31,10 +32,14 @@ moderator.add_nuclide(h1, 2.)
|
|||
moderator.add_nuclide(o16, 1.)
|
||||
moderator.add_s_alpha_beta('HH2O', '71t')
|
||||
|
||||
iron = openmc.Material(material_id=3, name='iron')
|
||||
iron.set_density('g/cc', 7.9)
|
||||
iron.add_nuclide(fe56, 1.)
|
||||
|
||||
# Instantiate a MaterialsFile, register all Materials, and export to XML
|
||||
materials_file = openmc.MaterialsFile()
|
||||
materials_file.set_default_xs('71c')
|
||||
materials_file.add_materials([moderator, fuel])
|
||||
materials_file.add_materials([moderator, fuel, iron])
|
||||
materials_file.export_to_xml()
|
||||
|
||||
|
||||
|
|
@ -43,13 +48,11 @@ materials_file.export_to_xml()
|
|||
###############################################################################
|
||||
|
||||
# Instantiate Surfaces
|
||||
left = openmc.XPlane(surface_id=1, x0=-2, name='left')
|
||||
right = openmc.XPlane(surface_id=2, x0=2, name='right')
|
||||
bottom = openmc.YPlane(surface_id=3, y0=-2, name='bottom')
|
||||
top = openmc.YPlane(surface_id=4, y0=2, name='top')
|
||||
fuel1 = openmc.ZCylinder(surface_id=5, x0=0, y0=0, R=0.4)
|
||||
fuel2 = openmc.ZCylinder(surface_id=6, x0=0, y0=0, R=0.3)
|
||||
fuel3 = openmc.ZCylinder(surface_id=7, x0=0, y0=0, R=0.2)
|
||||
left = openmc.XPlane(surface_id=1, x0=-3, name='left')
|
||||
right = openmc.XPlane(surface_id=2, x0=3, name='right')
|
||||
bottom = openmc.YPlane(surface_id=3, y0=-4, name='bottom')
|
||||
top = openmc.YPlane(surface_id=4, y0=4, name='top')
|
||||
fuel_surf = openmc.ZCylinder(surface_id=5, x0=0, y0=0, R=0.4)
|
||||
|
||||
left.set_boundary_type('vacuum')
|
||||
right.set_boundary_type('vacuum')
|
||||
|
|
@ -60,51 +63,48 @@ bottom.set_boundary_type('vacuum')
|
|||
cell1 = openmc.Cell(cell_id=1, name='Cell 1')
|
||||
cell2 = openmc.Cell(cell_id=101, name='cell 2')
|
||||
cell3 = openmc.Cell(cell_id=102, name='cell 3')
|
||||
cell4 = openmc.Cell(cell_id=201, name='cell 4')
|
||||
cell5 = openmc.Cell(cell_id=202, name='cell 5')
|
||||
cell6 = openmc.Cell(cell_id=301, name='cell 6')
|
||||
cell7 = openmc.Cell(cell_id=302, name='cell 7')
|
||||
cell4 = openmc.Cell(cell_id=500, name='cell 4')
|
||||
cell5 = openmc.Cell(cell_id=600, name='cell 5')
|
||||
cell6 = openmc.Cell(cell_id=601, name='cell 6')
|
||||
|
||||
# Register Surfaces with Cells
|
||||
cell1.add_surface(left, halfspace=+1)
|
||||
cell1.add_surface(right, halfspace=-1)
|
||||
cell1.add_surface(bottom, halfspace=+1)
|
||||
cell1.add_surface(top, halfspace=-1)
|
||||
cell2.add_surface(fuel1, halfspace=-1)
|
||||
cell3.add_surface(fuel1, halfspace=+1)
|
||||
cell4.add_surface(fuel2, halfspace=-1)
|
||||
cell5.add_surface(fuel2, halfspace=+1)
|
||||
cell6.add_surface(fuel3, halfspace=-1)
|
||||
cell7.add_surface(fuel3, halfspace=+1)
|
||||
cell2.add_surface(fuel_surf, halfspace=-1)
|
||||
cell3.add_surface(fuel_surf, halfspace=+1)
|
||||
cell5.add_surface(fuel_surf, halfspace=-1)
|
||||
cell6.add_surface(fuel_surf, halfspace=+1)
|
||||
|
||||
# Register Materials with Cells
|
||||
cell2.set_fill(fuel)
|
||||
cell3.set_fill(moderator)
|
||||
cell4.set_fill(fuel)
|
||||
cell5.set_fill(moderator)
|
||||
cell6.set_fill(fuel)
|
||||
cell7.set_fill(moderator)
|
||||
cell4.set_fill(moderator)
|
||||
cell5.set_fill(iron)
|
||||
cell6.set_fill(moderator)
|
||||
|
||||
# Instantiate Universe
|
||||
univ1 = openmc.Universe(universe_id=1)
|
||||
univ2 = openmc.Universe(universe_id=2)
|
||||
univ3 = openmc.Universe(universe_id=3)
|
||||
univ2 = openmc.Universe(universe_id=3)
|
||||
univ3 = openmc.Universe(universe_id=4)
|
||||
root = openmc.Universe(universe_id=0, name='root universe')
|
||||
|
||||
# Register Cells with Universe
|
||||
univ1.add_cells([cell2, cell3])
|
||||
univ2.add_cells([cell4, cell5])
|
||||
univ3.add_cells([cell6, cell7])
|
||||
univ2.add_cells([cell4])
|
||||
univ3.add_cells([cell5, cell6])
|
||||
root.add_cell(cell1)
|
||||
|
||||
# Instantiate a Lattice
|
||||
lattice = openmc.HexLattice(lattice_id=5)
|
||||
lattice.set_center([0., 0., 0.])
|
||||
lattice.set_pitch([1., 1.])
|
||||
lattice.set_pitch([1., 2.])
|
||||
lattice.set_universes([
|
||||
[ [univ2]*12, [univ2]*6, [univ1] ],
|
||||
[ [univ2]*12, [univ2]*6, [univ1] ]])
|
||||
lattice.set_outer(univ1)
|
||||
[ [univ2] + [univ3]*11, [univ2] + [univ3]*5, [univ3] ],
|
||||
[ [univ2] + [univ1]*11, [univ2] + [univ1]*5, [univ1] ],
|
||||
[ [univ2] + [univ3]*11, [univ2] + [univ3]*5, [univ3] ]])
|
||||
lattice.set_outer(univ2)
|
||||
|
||||
# Fill Cell with the Lattice
|
||||
cell1.set_fill(lattice)
|
||||
|
|
@ -136,40 +136,23 @@ settings_file.export_to_xml()
|
|||
# Exporting to OpenMC plots.xml File
|
||||
###############################################################################
|
||||
|
||||
plot = openmc.Plot(plot_id=1)
|
||||
plot.set_origin([0, 0, 0])
|
||||
plot.set_width([4, 4])
|
||||
plot.set_pixels([400, 400])
|
||||
plot.set_color('mat')
|
||||
plot_xy = openmc.Plot(plot_id=1)
|
||||
plot_xy.set_filename('plot_xy')
|
||||
plot_xy.set_origin([0, 0, 0])
|
||||
plot_xy.set_width([6, 6])
|
||||
plot_xy.set_pixels([400, 400])
|
||||
plot_xy.set_color('mat')
|
||||
|
||||
plot_yz = openmc.Plot(plot_id=2)
|
||||
plot_yz.set_filename('plot_yz')
|
||||
plot_yz.set_basis('yz')
|
||||
plot_yz.set_origin([0, 0, 0])
|
||||
plot_yz.set_width([8, 8])
|
||||
plot_yz.set_pixels([400, 400])
|
||||
plot_yz.set_color('mat')
|
||||
|
||||
# Instantiate a PlotsFile, add Plot, and export to XML
|
||||
plot_file = openmc.PlotsFile()
|
||||
plot_file.add_plot(plot)
|
||||
plot_file.add_plot(plot_xy)
|
||||
plot_file.add_plot(plot_yz)
|
||||
plot_file.export_to_xml()
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Exporting to OpenMC tallies.xml File
|
||||
###############################################################################
|
||||
|
||||
# Instantiate a tally mesh
|
||||
mesh = openmc.Mesh(mesh_id=1)
|
||||
mesh.set_type('rectangular')
|
||||
mesh.set_dimension([4, 4])
|
||||
mesh.set_lower_left([-2, -2])
|
||||
mesh.set_width([1, 1])
|
||||
|
||||
# Instantiate tally Filter
|
||||
mesh_filter = openmc.Filter()
|
||||
mesh_filter.set_mesh(mesh)
|
||||
|
||||
# Instantiate the Tally
|
||||
tally = openmc.Tally(tally_id=1)
|
||||
tally.add_filter(mesh_filter)
|
||||
tally.add_score('total')
|
||||
|
||||
# Instantiate a TalliesFile, register Tally/Mesh, and export to XML
|
||||
tallies_file = openmc.TalliesFile()
|
||||
tallies_file.add_mesh(mesh)
|
||||
tallies_file.add_tally(tally)
|
||||
tallies_file.export_to_xml()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue