mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Geometric intrinsics now use property setter/getter decorators
This commit is contained in:
parent
9cada4df0e
commit
5dac75297d
14 changed files with 1014 additions and 466 deletions
|
|
@ -33,7 +33,7 @@ fuel.add_nuclide(u235, 1.)
|
|||
|
||||
# Instantiate a MaterialsFile, register all Materials, and export to XML
|
||||
materials_file = openmc.MaterialsFile()
|
||||
materials_file.set_default_xs('71c')
|
||||
materials_file.default_xs = '71c'
|
||||
materials_file.add_materials([moderator, fuel])
|
||||
materials_file.export_to_xml()
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ materials_file.export_to_xml()
|
|||
surf1 = openmc.ZCylinder(surface_id=1, x0=0, y0=0, R=7, name='surf 1')
|
||||
surf2 = openmc.ZCylinder(surface_id=2, x0=0, y0=0, R=9, name='surf 2')
|
||||
surf3 = openmc.ZCylinder(surface_id=3, x0=0, y0=0, R=11, name='surf 3')
|
||||
surf3.set_boundary_type('vacuum')
|
||||
surf3.boundary_type = 'vacuum'
|
||||
|
||||
# Instantiate Cells
|
||||
cell1 = openmc.Cell(cell_id=1, name='cell 1')
|
||||
|
|
@ -62,14 +62,14 @@ cell4.add_surface(surface=surf2, halfspace=+1)
|
|||
cell4.add_surface(surface=surf3, halfspace=-1)
|
||||
|
||||
# Register Materials with Cells
|
||||
cell2.set_fill(fuel)
|
||||
cell3.set_fill(moderator)
|
||||
cell4.set_fill(moderator)
|
||||
cell2.fill = fuel
|
||||
cell3.fill = moderator
|
||||
cell4.fill = moderator
|
||||
|
||||
# Instantiate Universes
|
||||
universe1 = openmc.Universe(universe_id=37)
|
||||
root = openmc.Universe(universe_id=0, name='root universe')
|
||||
cell1.set_fill(universe1)
|
||||
cell1.fill = universe1
|
||||
|
||||
# Register Cells with Universes
|
||||
universe1.add_cells([cell2, cell3])
|
||||
|
|
@ -77,11 +77,11 @@ root.add_cells([cell1, cell4])
|
|||
|
||||
# Instantiate a Geometry and register the root Universe
|
||||
geometry = openmc.Geometry()
|
||||
geometry.set_root_universe(root)
|
||||
geometry.root_universe = root
|
||||
|
||||
# Instantiate a GeometryFile, register Geometry, and export to XML
|
||||
geometry_file = openmc.GeometryFile()
|
||||
geometry_file.set_geometry(geometry)
|
||||
geometry_file.geometry = geometry
|
||||
geometry_file.export_to_xml()
|
||||
|
||||
|
||||
|
|
@ -91,9 +91,9 @@ geometry_file.export_to_xml()
|
|||
|
||||
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
|
||||
settings_file = openmc.SettingsFile()
|
||||
settings_file.set_batches(batches)
|
||||
settings_file.set_inactive(inactive)
|
||||
settings_file.set_particles(particles)
|
||||
settings_file.batches = batches
|
||||
settings_file.inactive = inactive
|
||||
settings_file.particles = particles
|
||||
settings_file.set_source_space('box', [-4, -4, -4, 4, 4, 4])
|
||||
settings_file.export_to_xml()
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ 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.default_xs = '71c'
|
||||
materials_file.add_materials([moderator, fuel, iron])
|
||||
materials_file.export_to_xml()
|
||||
|
||||
|
|
@ -54,10 +54,10 @@ 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')
|
||||
top.set_boundary_type('vacuum')
|
||||
bottom.set_boundary_type('vacuum')
|
||||
left.boundary_type = 'vacuum'
|
||||
right.boundary_type = 'vacuum'
|
||||
top.boundary_type = 'vacuum'
|
||||
bottom.boundary_type = 'vacuum'
|
||||
|
||||
# Instantiate Cells
|
||||
cell1 = openmc.Cell(cell_id=1, name='Cell 1')
|
||||
|
|
@ -78,11 +78,11 @@ 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(moderator)
|
||||
cell5.set_fill(iron)
|
||||
cell6.set_fill(moderator)
|
||||
cell2.fill = fuel
|
||||
cell3.fill = moderator
|
||||
cell4.fill = moderator
|
||||
cell5.fill = iron
|
||||
cell6.fill = moderator
|
||||
|
||||
# Instantiate Universe
|
||||
univ1 = openmc.Universe(universe_id=1)
|
||||
|
|
@ -98,24 +98,24 @@ root.add_cell(cell1)
|
|||
|
||||
# Instantiate a Lattice
|
||||
lattice = openmc.HexLattice(lattice_id=5)
|
||||
lattice.set_center([0., 0., 0.])
|
||||
lattice.set_pitch([1., 2.])
|
||||
lattice.set_universes([
|
||||
[ [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)
|
||||
lattice.center = [0., 0., 0.]
|
||||
lattice.pitch = [1., 2.]
|
||||
lattice.universes = \
|
||||
[ [ [univ2] + [univ3]*11, [univ2] + [univ3]*5, [univ3] ],
|
||||
[ [univ2] + [univ1]*11, [univ2] + [univ1]*5, [univ1] ],
|
||||
[ [univ2] + [univ3]*11, [univ2] + [univ3]*5, [univ3] ] ]
|
||||
lattice.outer = univ2
|
||||
|
||||
# Fill Cell with the Lattice
|
||||
cell1.set_fill(lattice)
|
||||
cell1.fill = lattice
|
||||
|
||||
# Instantiate a Geometry and register the root Universe
|
||||
geometry = openmc.Geometry()
|
||||
geometry.set_root_universe(root)
|
||||
geometry.root_universe = root
|
||||
|
||||
# Instantiate a GeometryFile, register Geometry, and export to XML
|
||||
geometry_file = openmc.GeometryFile()
|
||||
geometry_file.set_geometry(geometry)
|
||||
geometry_file.geometry = geometry
|
||||
geometry_file.export_to_xml()
|
||||
|
||||
|
||||
|
|
@ -125,9 +125,9 @@ geometry_file.export_to_xml()
|
|||
|
||||
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
|
||||
settings_file = openmc.SettingsFile()
|
||||
settings_file.set_batches(batches)
|
||||
settings_file.set_inactive(inactive)
|
||||
settings_file.set_particles(particles)
|
||||
settings_file.batches = batches
|
||||
settings_file.inactive = inactive
|
||||
settings_file.particles = particles
|
||||
settings_file.set_source_space('box', [-1, -1, -1, 1, 1, 1])
|
||||
settings_file.export_to_xml()
|
||||
|
||||
|
|
@ -137,19 +137,19 @@ settings_file.export_to_xml()
|
|||
###############################################################################
|
||||
|
||||
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_xy.filename = 'plot_xy'
|
||||
plot_xy.origin = [0, 0, 0]
|
||||
plot_xy.width = [6, 6]
|
||||
plot_xy.pixels = [400, 400]
|
||||
plot_xy.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')
|
||||
plot_yz.filename = 'plot_yz'
|
||||
plot_yz.basis = 'yz'
|
||||
plot_yz.origin = [0, 0, 0]
|
||||
plot_yz.width = [8, 8]
|
||||
plot_yz.pixels = [400, 400]
|
||||
plot_yz.color = 'mat'
|
||||
|
||||
# Instantiate a PlotsFile, add Plot, and export to XML
|
||||
plot_file = openmc.PlotsFile()
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ moderator.add_s_alpha_beta('HH2O', '71t')
|
|||
|
||||
# Instantiate a MaterialsFile, register all Materials, and export to XML
|
||||
materials_file = openmc.MaterialsFile()
|
||||
materials_file.set_default_xs('71c')
|
||||
materials_file.default_xs = '71c'
|
||||
materials_file.add_materials([moderator, fuel])
|
||||
materials_file.export_to_xml()
|
||||
|
||||
|
|
@ -51,10 +51,10 @@ 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.set_boundary_type('vacuum')
|
||||
right.set_boundary_type('vacuum')
|
||||
top.set_boundary_type('vacuum')
|
||||
bottom.set_boundary_type('vacuum')
|
||||
left.boundary_type = 'vacuum'
|
||||
right.boundary_type = 'vacuum'
|
||||
top.boundary_type = 'vacuum'
|
||||
bottom.boundary_type = 'vacuum'
|
||||
|
||||
# Instantiate Cells
|
||||
cell1 = openmc.Cell(cell_id=1, name='Cell 1')
|
||||
|
|
@ -83,12 +83,12 @@ cell7.add_surface(fuel3, halfspace=-1)
|
|||
cell8.add_surface(fuel3, halfspace=+1)
|
||||
|
||||
# Register Materials with Cells
|
||||
cell3.set_fill(fuel)
|
||||
cell4.set_fill(moderator)
|
||||
cell5.set_fill(fuel)
|
||||
cell6.set_fill(moderator)
|
||||
cell7.set_fill(fuel)
|
||||
cell8.set_fill(moderator)
|
||||
cell3.fill = fuel
|
||||
cell4.fill = moderator
|
||||
cell5.fill = fuel
|
||||
cell6.fill = moderator
|
||||
cell7.fill = fuel
|
||||
cell8.fill = moderator
|
||||
|
||||
# Instantiate Universe
|
||||
univ1 = openmc.Universe(universe_id=1)
|
||||
|
|
@ -106,30 +106,30 @@ univ4.add_cell(cell2)
|
|||
|
||||
# Instantiate nested Lattices
|
||||
lattice1 = openmc.RectLattice(lattice_id=4, name='4x4 assembly')
|
||||
lattice1.set_dimension([2, 2])
|
||||
lattice1.set_lower_left([-1., -1.])
|
||||
lattice1.set_pitch([1., 1.])
|
||||
lattice1.set_universes([[univ1, univ2],
|
||||
[univ2, univ3]])
|
||||
lattice1.dimension = [2, 2]
|
||||
lattice1.lower_left = [-1., -1.]
|
||||
lattice1.pitch = [1., 1.]
|
||||
lattice1.universes = [[univ1, univ2],
|
||||
[univ2, univ3]]
|
||||
|
||||
lattice2 = openmc.RectLattice(lattice_id=6, name='4x4 core')
|
||||
lattice2.set_dimension([2, 2])
|
||||
lattice2.set_lower_left([-2., -2.])
|
||||
lattice2.set_pitch([2., 2.])
|
||||
lattice2.set_universes([[univ4, univ4],
|
||||
[univ4, univ4]])
|
||||
lattice2.dimension = [2, 2]
|
||||
lattice2.lower_left = [-2., -2.]
|
||||
lattice2.pitch = [2., 2.]
|
||||
lattice2.universes = [[univ4, univ4],
|
||||
[univ4, univ4]]
|
||||
|
||||
# Fill Cell with the Lattice
|
||||
cell1.set_fill(lattice2)
|
||||
cell2.set_fill(lattice1)
|
||||
cell1.fill = lattice2
|
||||
cell2.fill = lattice1
|
||||
|
||||
# Instantiate a Geometry and register the root Universe
|
||||
geometry = openmc.Geometry()
|
||||
geometry.set_root_universe(root)
|
||||
geometry.root_universe = root
|
||||
|
||||
# Instantiate a GeometryFile, register Geometry, and export to XML
|
||||
geometry_file = openmc.GeometryFile()
|
||||
geometry_file.set_geometry(geometry)
|
||||
geometry_file.geometry = geometry
|
||||
geometry_file.export_to_xml()
|
||||
|
||||
|
||||
|
|
@ -139,9 +139,9 @@ geometry_file.export_to_xml()
|
|||
|
||||
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
|
||||
settings_file = openmc.SettingsFile()
|
||||
settings_file.set_batches(batches)
|
||||
settings_file.set_inactive(inactive)
|
||||
settings_file.set_particles(particles)
|
||||
settings_file.batches = batches
|
||||
settings_file.inactive = inactive
|
||||
settings_file.particles = particles
|
||||
settings_file.set_source_space('box', [-1, -1, -1, 1, 1, 1])
|
||||
settings_file.export_to_xml()
|
||||
|
||||
|
|
@ -151,10 +151,10 @@ settings_file.export_to_xml()
|
|||
###############################################################################
|
||||
|
||||
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.origin = [0, 0, 0]
|
||||
plot.width = [4, 4]
|
||||
plot.pixels = [400, 400]
|
||||
plot.color = 'mat'
|
||||
|
||||
# Instantiate a PlotsFile, add Plot, and export to XML
|
||||
plot_file = openmc.PlotsFile()
|
||||
|
|
@ -168,14 +168,14 @@ plot_file.export_to_xml()
|
|||
|
||||
# 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])
|
||||
mesh.type = 'rectangular'
|
||||
mesh.dimension = [4, 4]
|
||||
mesh.lower_left = [-2, -2]
|
||||
mesh.width = [1, 1]
|
||||
|
||||
# Instantiate tally Filter
|
||||
mesh_filter = openmc.Filter()
|
||||
mesh_filter.set_mesh(mesh)
|
||||
mesh_filter.mesh = mesh
|
||||
|
||||
# Instantiate the Tally
|
||||
tally = openmc.Tally(tally_id=1)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ moderator.add_s_alpha_beta('HH2O', '71t')
|
|||
|
||||
# Instantiate a MaterialsFile, register all Materials, and export to XML
|
||||
materials_file = openmc.MaterialsFile()
|
||||
materials_file.set_default_xs('71c')
|
||||
materials_file.default_xs = '71c'
|
||||
materials_file.add_materials([moderator, fuel])
|
||||
materials_file.export_to_xml()
|
||||
|
||||
|
|
@ -51,10 +51,10 @@ 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.set_boundary_type('vacuum')
|
||||
right.set_boundary_type('vacuum')
|
||||
top.set_boundary_type('vacuum')
|
||||
bottom.set_boundary_type('vacuum')
|
||||
left.boundary_type = 'vacuum'
|
||||
right.boundary_type = 'vacuum'
|
||||
top.boundary_type = 'vacuum'
|
||||
bottom.boundary_type = 'vacuum'
|
||||
|
||||
# Instantiate Cells
|
||||
cell1 = openmc.Cell(cell_id=1, name='Cell 1')
|
||||
|
|
@ -78,12 +78,12 @@ cell6.add_surface(fuel3, halfspace=-1)
|
|||
cell7.add_surface(fuel3, 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)
|
||||
cell2.fill = fuel
|
||||
cell3.fill = moderator
|
||||
cell4.fill = fuel
|
||||
cell5.fill = moderator
|
||||
cell6.fill = fuel
|
||||
cell7.fill = moderator
|
||||
|
||||
# Instantiate Universe
|
||||
univ1 = openmc.Universe(universe_id=1)
|
||||
|
|
@ -99,24 +99,24 @@ root.add_cell(cell1)
|
|||
|
||||
# Instantiate a Lattice
|
||||
lattice = openmc.RectLattice(lattice_id=5)
|
||||
lattice.set_dimension([4, 4])
|
||||
lattice.set_lower_left([-2., -2.])
|
||||
lattice.set_pitch([1., 1.])
|
||||
lattice.set_universes([[univ1, univ2, univ1, univ2],
|
||||
[univ2, univ3, univ2, univ3],
|
||||
[univ1, univ2, univ1, univ2],
|
||||
[univ2, univ3, univ2, univ3]])
|
||||
lattice.dimension = [4, 4]
|
||||
lattice.lower_left = [-2., -2.]
|
||||
lattice.pitch = [1., 1.]
|
||||
lattice.universes = [[univ1, univ2, univ1, univ2],
|
||||
[univ2, univ3, univ2, univ3],
|
||||
[univ1, univ2, univ1, univ2],
|
||||
[univ2, univ3, univ2, univ3]]
|
||||
|
||||
# Fill Cell with the Lattice
|
||||
cell1.set_fill(lattice)
|
||||
cell1.fill = lattice
|
||||
|
||||
# Instantiate a Geometry and register the root Universe
|
||||
geometry = openmc.Geometry()
|
||||
geometry.set_root_universe(root)
|
||||
geometry.root_universe = root
|
||||
|
||||
# Instantiate a GeometryFile, register Geometry, and export to XML
|
||||
geometry_file = openmc.GeometryFile()
|
||||
geometry_file.set_geometry(geometry)
|
||||
geometry_file.geometry = geometry
|
||||
geometry_file.export_to_xml()
|
||||
|
||||
|
||||
|
|
@ -126,9 +126,9 @@ geometry_file.export_to_xml()
|
|||
|
||||
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
|
||||
settings_file = openmc.SettingsFile()
|
||||
settings_file.set_batches(batches)
|
||||
settings_file.set_inactive(inactive)
|
||||
settings_file.set_particles(particles)
|
||||
settings_file.batches = batches
|
||||
settings_file.inactive = inactive
|
||||
settings_file.particles = particles
|
||||
settings_file.set_source_space('box', [-1, -1, -1, 1, 1, 1])
|
||||
settings_file.export_to_xml()
|
||||
|
||||
|
|
@ -138,10 +138,10 @@ settings_file.export_to_xml()
|
|||
###############################################################################
|
||||
|
||||
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.origin = [0, 0, 0]
|
||||
plot.width = [4, 4]
|
||||
plot.pixels = [400, 400]
|
||||
plot.color = 'mat'
|
||||
|
||||
# Instantiate a PlotsFile, add Plot, and export to XML
|
||||
plot_file = openmc.PlotsFile()
|
||||
|
|
@ -155,14 +155,14 @@ plot_file.export_to_xml()
|
|||
|
||||
# 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])
|
||||
mesh.type = 'rectangular'
|
||||
mesh.dimension = [4, 4]
|
||||
mesh.lower_left = [-2, -2]
|
||||
mesh.width = [1, 1]
|
||||
|
||||
# Instantiate tally Filter
|
||||
mesh_filter = openmc.Filter()
|
||||
mesh_filter.set_mesh(mesh)
|
||||
mesh_filter.mesh = mesh
|
||||
|
||||
# Instantiate the Tally
|
||||
tally = openmc.Tally(tally_id=1)
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ borated_water.add_s_alpha_beta('HH2O', '71t')
|
|||
|
||||
# Instantiate a MaterialsFile, register all Materials, and export to XML
|
||||
materials_file = openmc.MaterialsFile()
|
||||
materials_file.set_default_xs('71c')
|
||||
materials_file.default_xs = '71c'
|
||||
materials_file.add_materials([uo2, helium, zircaloy, borated_water])
|
||||
materials_file.export_to_xml()
|
||||
|
||||
|
|
@ -121,10 +121,10 @@ right = openmc.XPlane(surface_id=5, x0=0.62992, name='right')
|
|||
bottom = openmc.YPlane(surface_id=6, y0=-0.62992, name='bottom')
|
||||
top = openmc.YPlane(surface_id=7, y0=0.62992, name='top')
|
||||
|
||||
left.set_boundary_type('reflective')
|
||||
right.set_boundary_type('reflective')
|
||||
top.set_boundary_type('reflective')
|
||||
bottom.set_boundary_type('reflective')
|
||||
left.boundary_type = 'reflective'
|
||||
right.boundary_type = 'reflective'
|
||||
top.boundary_type = 'reflective'
|
||||
bottom.boundary_type = 'reflective'
|
||||
|
||||
# Instantiate Cells
|
||||
fuel = openmc.Cell(cell_id=1, name='cell 1')
|
||||
|
|
@ -145,10 +145,10 @@ water.add_surface(bottom, halfspace=+1)
|
|||
water.add_surface(top, halfspace=-1)
|
||||
|
||||
# Register Materials with Cells
|
||||
fuel.set_fill(uo2)
|
||||
gap.set_fill(helium)
|
||||
clad.set_fill(zircaloy)
|
||||
water.set_fill(borated_water)
|
||||
fuel.fill = uo2
|
||||
gap.fill = helium
|
||||
clad.fill = zircaloy
|
||||
water.fill = borated_water
|
||||
|
||||
# Instantiate Universe
|
||||
root = openmc.Universe(universe_id=0, name='root universe')
|
||||
|
|
@ -158,11 +158,11 @@ root.add_cells([fuel, gap, clad, water])
|
|||
|
||||
# Instantiate a Geometry and register the root Universe
|
||||
geometry = openmc.Geometry()
|
||||
geometry.set_root_universe(root)
|
||||
geometry.root_universe = root
|
||||
|
||||
# Instantiate a GeometryFile, register Geometry, and export to XML
|
||||
geometry_file = openmc.GeometryFile()
|
||||
geometry_file.set_geometry(geometry)
|
||||
geometry_file.geometry = geometry
|
||||
geometry_file.export_to_xml()
|
||||
|
||||
|
||||
|
|
@ -172,14 +172,14 @@ geometry_file.export_to_xml()
|
|||
|
||||
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
|
||||
settings_file = openmc.SettingsFile()
|
||||
settings_file.set_batches(batches)
|
||||
settings_file.set_inactive(inactive)
|
||||
settings_file.set_particles(particles)
|
||||
settings_file.batches = batches
|
||||
settings_file.inactive = inactive
|
||||
settings_file.particles = particles
|
||||
settings_file.set_source_space('box', [-0.62992, -0.62992, -1, \
|
||||
0.62992, 0.62992, 1])
|
||||
settings_file.set_entropy_lower_left([-0.39218, -0.39218, -1.e50])
|
||||
settings_file.set_entropy_upper_right([0.39218, 0.39218, 1.e50])
|
||||
settings_file.set_entropy_dimension([10, 10, 1])
|
||||
settings_file.entropy_lower_left = [-0.39218, -0.39218, -1.e50]
|
||||
settings_file.entropy_upper_right = [0.39218, 0.39218, 1.e50]
|
||||
settings_file.entropy_dimension = [10, 10, 1]
|
||||
settings_file.export_to_xml()
|
||||
|
||||
|
||||
|
|
@ -189,15 +189,15 @@ settings_file.export_to_xml()
|
|||
|
||||
# Instantiate a tally mesh
|
||||
mesh = openmc.Mesh(mesh_id=1)
|
||||
mesh.set_type('rectangular')
|
||||
mesh.set_dimension([100, 100, 1])
|
||||
mesh.set_lower_left([-0.62992, -0.62992, -1.e50])
|
||||
mesh.set_upper_right([0.62992, 0.62992, 1.e50])
|
||||
mesh.type = 'rectangular'
|
||||
mesh.dimension = [100, 100, 1]
|
||||
mesh.lower_left = [-0.62992, -0.62992, -1.e50]
|
||||
mesh.upper_right = [0.62992, 0.62992, 1.e50]
|
||||
|
||||
# Instantiate some tally Filters
|
||||
energy_filter = openmc.Filter(type='energy', bins=[0., 4.e-6, 20.])
|
||||
mesh_filter = openmc.Filter()
|
||||
mesh_filter.set_mesh(mesh)
|
||||
mesh_filter.mesh = mesh
|
||||
|
||||
# Instantiate the Tally
|
||||
tally = openmc.Tally(tally_id=1)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ fuel.add_nuclide(u235, 1.)
|
|||
|
||||
# Instantiate a MaterialsFile, register Material, and export to XML
|
||||
materials_file = openmc.MaterialsFile()
|
||||
materials_file.set_default_xs('71c')
|
||||
materials_file.default_xs = '71c'
|
||||
materials_file.add_material(fuel)
|
||||
materials_file.export_to_xml()
|
||||
|
||||
|
|
@ -42,12 +42,12 @@ surf4 = openmc.YPlane(surface_id=4, y0=+1, name='surf 4')
|
|||
surf5 = openmc.ZPlane(surface_id=5, z0=-1, name='surf 5')
|
||||
surf6 = openmc.ZPlane(surface_id=6, z0=+1, name='surf 6')
|
||||
|
||||
surf1.set_boundary_type('vacuum')
|
||||
surf2.set_boundary_type('vacuum')
|
||||
surf3.set_boundary_type('reflective')
|
||||
surf4.set_boundary_type('reflective')
|
||||
surf5.set_boundary_type('reflective')
|
||||
surf6.set_boundary_type('reflective')
|
||||
surf1.boundary_type = 'vacuum'
|
||||
surf2.boundary_type = 'vacuum'
|
||||
surf3.boundary_type = 'reflective'
|
||||
surf4.boundary_type = 'reflective'
|
||||
surf5.boundary_type = 'reflective'
|
||||
surf6.boundary_type = 'reflective'
|
||||
|
||||
# Instantiate Cell
|
||||
cell = openmc.Cell(cell_id=1, name='cell 1')
|
||||
|
|
@ -61,7 +61,7 @@ cell.add_surface(surface=surf5, halfspace=+1)
|
|||
cell.add_surface(surface=surf6, halfspace=-1)
|
||||
|
||||
# Register Material with Cell
|
||||
cell.set_fill(fuel)
|
||||
cell.fill = fuel
|
||||
|
||||
# Instantiate Universes
|
||||
root = openmc.Universe(universe_id=0, name='root universe')
|
||||
|
|
@ -71,11 +71,11 @@ root.add_cell(cell)
|
|||
|
||||
# Instantiate a Geometry and register the root Universe
|
||||
geometry = openmc.Geometry()
|
||||
geometry.set_root_universe(root)
|
||||
geometry.root_universe = root
|
||||
|
||||
# Instantiate a GeometryFile, register Geometry, and export to XML
|
||||
geometry_file = openmc.GeometryFile()
|
||||
geometry_file.set_geometry(geometry)
|
||||
geometry_file.geometry = geometry
|
||||
geometry_file.export_to_xml()
|
||||
|
||||
|
||||
|
|
@ -85,8 +85,8 @@ geometry_file.export_to_xml()
|
|||
|
||||
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
|
||||
settings_file = openmc.SettingsFile()
|
||||
settings_file.set_batches(batches)
|
||||
settings_file.set_inactive(inactive)
|
||||
settings_file.set_particles(particles)
|
||||
settings_file.batches = batches
|
||||
settings_file.inactive = inactive
|
||||
settings_file.particles = particles
|
||||
settings_file.set_source_space('box', [-1, -1, -1, 1, 1, 1])
|
||||
settings_file.export_to_xml()
|
||||
|
|
|
|||
|
|
@ -20,6 +20,28 @@ class Geometry(object):
|
|||
self._offsets = {}
|
||||
|
||||
|
||||
@property
|
||||
def root_universe(self):
|
||||
return self._root_universe
|
||||
|
||||
|
||||
@root_universe.setter
|
||||
def root_universe(self, root_universe):
|
||||
|
||||
if not isinstance(root_universe, openmc.Universe):
|
||||
msg = 'Unable to add root Universe {0} to Geometry since ' \
|
||||
'it is not a Universe'.format(root_universe)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif root_universe._id != 0:
|
||||
msg = 'Unable to add root Universe {0} to Geometry since ' \
|
||||
'it has ID={1} instead of ' \
|
||||
'ID=0'.format(root_universe, root_universe._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._root_universe = root_universe
|
||||
|
||||
|
||||
def get_offset(self, path, filter_offset):
|
||||
"""
|
||||
Returns the corresponding location in the results array for a given
|
||||
|
|
@ -111,22 +133,6 @@ class Geometry(object):
|
|||
return list(material_universes)
|
||||
|
||||
|
||||
def set_root_universe(self, root_universe):
|
||||
|
||||
if not isinstance(root_universe, openmc.Universe):
|
||||
msg = 'Unable to add root Universe {0} to Geometry since ' \
|
||||
'it is not a Universe'.format(root_universe)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif root_universe._id != 0:
|
||||
msg = 'Unable to add root Universe {0} to Geometry since ' \
|
||||
'it has ID={1} instead of ' \
|
||||
'ID=0'.format(root_universe, root_universe._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._root_universe = root_universe
|
||||
|
||||
|
||||
|
||||
class GeometryFile(object):
|
||||
|
||||
|
|
@ -137,7 +143,13 @@ class GeometryFile(object):
|
|||
self._geometry_file = ET.Element("geometry")
|
||||
|
||||
|
||||
def set_geometry(self, geometry):
|
||||
@property
|
||||
def geometry(self):
|
||||
return self._geometry
|
||||
|
||||
|
||||
@geometry.setter
|
||||
def geometry(self, geometry):
|
||||
|
||||
if not isinstance(geometry, Geometry):
|
||||
msg = 'Unable to set the Geometry to {0} for the GeometryFile ' \
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@ from copy import deepcopy
|
|||
import warnings
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
from openmc.checkvalue import *
|
||||
from openmc.clean_xml import *
|
||||
|
|
@ -142,8 +140,7 @@ class Material(object):
|
|||
self._name = name
|
||||
|
||||
|
||||
@density.setter
|
||||
def density(self, units, density=NO_DENSITY):
|
||||
def set_density(self, units, density=NO_DENSITY):
|
||||
|
||||
if not is_float(density):
|
||||
msg = 'Unable to set the density for Material ID={0} to a ' \
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ def get_opencg_surface(openmc_surface):
|
|||
name = openmc_surface._name
|
||||
|
||||
# Correct for OpenMC's syntax for Surfaces dividing Cells
|
||||
boundary = openmc_surface._bc_type
|
||||
boundary = openmc_surface._boundary_type
|
||||
if boundary == 'transmission':
|
||||
boundary = 'interface'
|
||||
|
||||
|
|
@ -562,15 +562,15 @@ def get_openmc_cell(opencg_cell):
|
|||
fill = opencg_cell._fill
|
||||
|
||||
if (opencg_cell._type == 'universe'):
|
||||
openmc_cell.set_fill(get_openmc_universe(fill))
|
||||
openmc_cell.fill = get_openmc_universe(fill)
|
||||
elif (opencg_cell._type == 'lattice'):
|
||||
openmc_cell.set_fill(get_openmc_lattice(fill))
|
||||
openmc_cell.fill = get_openmc_lattice(fill)
|
||||
else:
|
||||
openmc_cell.set_fill(get_openmc_material(fill))
|
||||
openmc_cell.fill = get_openmc_material(fill)
|
||||
|
||||
if opencg_cell._rotation:
|
||||
rotation = np.asarray(opencg_cell._rotation, dtype=np.int)
|
||||
openmc_cell.set_rotation(rotation)
|
||||
openmc_cell.rotation = rotation
|
||||
|
||||
if opencg_cell._translation:
|
||||
translation = np.asarray(opencg_cell._translation, dtype=np.float64)
|
||||
|
|
@ -679,11 +679,21 @@ def get_opencg_lattice(openmc_lattice):
|
|||
return OPENCG_LATTICES[lattice_id]
|
||||
|
||||
# Create an OpenCG Lattice to represent this OpenMC Lattice
|
||||
name = openmc_lattice._name
|
||||
dimension = openmc_lattice._dimension
|
||||
pitch = openmc_lattice._pitch
|
||||
lower_left = openmc_lattice._lower_left
|
||||
universes = openmc_lattice._universes
|
||||
name = openmc_lattice.name
|
||||
dimension = openmc_lattice.dimension
|
||||
pitch = openmc_lattice.pitch
|
||||
lower_left = openmc_lattice.lower_left
|
||||
universes = openmc_lattice.universes
|
||||
|
||||
if len(pitch) == 2:
|
||||
new_pitch = np.ones(3, dtype=np.float64)
|
||||
new_pitch[:2] = pitch
|
||||
pitch = new_pitch
|
||||
|
||||
if len(lower_left) == 2:
|
||||
new_lower_left = np.ones(3, dtype=np.float64)
|
||||
new_lower_left[:2] = lower_left
|
||||
lower_left = new_lower_left
|
||||
|
||||
# Initialize an empty array for the OpenCG nested Universes in this Lattice
|
||||
universe_array = np.ndarray(tuple(np.array(dimension)[::-1]), \
|
||||
|
|
@ -765,10 +775,10 @@ def get_openmc_lattice(opencg_lattice):
|
|||
np.array(dimension, dtype=np.float64))) / -2.0
|
||||
|
||||
openmc_lattice = openmc.RectLattice(lattice_id=lattice_id)
|
||||
openmc_lattice.set_dimension(dimension)
|
||||
openmc_lattice.set_pitch(width)
|
||||
openmc_lattice.set_universes(universe_array)
|
||||
openmc_lattice.set_lower_left(lower_left)
|
||||
openmc_lattice.dimension = dimension
|
||||
openmc_lattice.pitch = width
|
||||
openmc_lattice.universes = universe_array
|
||||
openmc_lattice.lower_left = lower_left
|
||||
|
||||
# Add the OpenMC Lattice to the global collection of all OpenMC Lattices
|
||||
OPENMC_LATTICES[lattice_id] = openmc_lattice
|
||||
|
|
@ -843,6 +853,6 @@ def get_openmc_geometry(opencg_geometry):
|
|||
openmc_root_universe = get_openmc_universe(opencg_root_universe)
|
||||
|
||||
openmc_geometry = openmc.Geometry()
|
||||
openmc_geometry.set_root_universe(openmc_root_universe)
|
||||
openmc_geometry.root_universe = openmc_root_universe
|
||||
|
||||
return openmc_geometry
|
||||
|
|
|
|||
|
|
@ -83,7 +83,237 @@ class SettingsFile(object):
|
|||
self._source_element = None
|
||||
|
||||
|
||||
def set_batches(self, batches):
|
||||
@property
|
||||
def batches(self):
|
||||
return self._batches
|
||||
|
||||
|
||||
@property
|
||||
def generations_per_batch(self):
|
||||
return self._generations_per_batch
|
||||
|
||||
|
||||
@property
|
||||
def inactive(self):
|
||||
return self._inactive
|
||||
|
||||
|
||||
@property
|
||||
def particles(self):
|
||||
return self._particles
|
||||
|
||||
|
||||
@property
|
||||
def source_file(self):
|
||||
return self._source_file
|
||||
|
||||
|
||||
@property
|
||||
def source_space_type(self):
|
||||
return self._source_space_type
|
||||
|
||||
|
||||
@property
|
||||
def source_space_params(self):
|
||||
return self._source_space_params
|
||||
|
||||
|
||||
@property
|
||||
def source_angle_type(self):
|
||||
return self._source_angle_type
|
||||
|
||||
|
||||
@property
|
||||
def source_angle_params(self):
|
||||
return self._source_angle_params
|
||||
|
||||
|
||||
@property
|
||||
def source_energy_type(self):
|
||||
return self._source_energy_type
|
||||
|
||||
|
||||
@property
|
||||
def source_energy_params(self):
|
||||
return self._source_energy_params
|
||||
|
||||
|
||||
@property
|
||||
def confidence_intervals(self):
|
||||
return self._confidence_intervals
|
||||
|
||||
|
||||
@property
|
||||
def cross_sections(self):
|
||||
return self._cross_sections
|
||||
|
||||
|
||||
@property
|
||||
def energy_grid(self):
|
||||
return self._energy_grid
|
||||
|
||||
|
||||
@property
|
||||
def ptables(self):
|
||||
return self._ptables
|
||||
|
||||
|
||||
@property
|
||||
def run_cmfd(self):
|
||||
return self._run_cmfd
|
||||
|
||||
|
||||
@property
|
||||
def seed(self):
|
||||
return self._seed
|
||||
|
||||
|
||||
@property
|
||||
def survival_biasing(self):
|
||||
return self._survival_biasing
|
||||
|
||||
|
||||
@property
|
||||
def entropy_dimension(self):
|
||||
return self._entropy_dimension
|
||||
|
||||
|
||||
@property
|
||||
def entropy_lower_left(self):
|
||||
return self._entropy_lower_left
|
||||
|
||||
|
||||
@property
|
||||
def entropy_upper_right(self):
|
||||
return self._entropy_upper_right
|
||||
|
||||
|
||||
@property
|
||||
def output(self):
|
||||
return self._output
|
||||
|
||||
|
||||
@property
|
||||
def output_path(self):
|
||||
return self._output_path
|
||||
|
||||
|
||||
@property
|
||||
def statepoint_batches(self):
|
||||
return self._statepoint_batches
|
||||
|
||||
|
||||
@property
|
||||
def statepoint_interval(self):
|
||||
return self._statepoint_interval
|
||||
|
||||
@property
|
||||
def sourcepoint_batches(self):
|
||||
return self._sourcepoint_interval
|
||||
|
||||
|
||||
@property
|
||||
def sourcepoint_interval(self):
|
||||
return self._sourcepoint_interval
|
||||
|
||||
|
||||
@property
|
||||
def sourcepoint_separate(self):
|
||||
return self._sourcepoint_separate
|
||||
|
||||
|
||||
@property
|
||||
def sourcepoint_write(self):
|
||||
return self._sourcepoint_write
|
||||
|
||||
|
||||
@property
|
||||
def sourcepoint_overwrite(self):
|
||||
return self._sourcepoint_overwrite
|
||||
|
||||
|
||||
@property
|
||||
def threads(self):
|
||||
return self._threads
|
||||
|
||||
|
||||
@property
|
||||
def no_reduce(self):
|
||||
return self._no_reduce
|
||||
|
||||
|
||||
@property
|
||||
def verbosity(self):
|
||||
return self._verbosity
|
||||
|
||||
|
||||
@property
|
||||
def trace(self):
|
||||
return self._trace
|
||||
|
||||
|
||||
@property
|
||||
def track(self):
|
||||
return self._track
|
||||
|
||||
|
||||
@property
|
||||
def weight(self):
|
||||
return self._weight
|
||||
|
||||
|
||||
@property
|
||||
def weight_avg(self):
|
||||
return self._weight_avg
|
||||
|
||||
|
||||
@property
|
||||
def ufs_dimension(self):
|
||||
return self._ufs_dimension
|
||||
|
||||
|
||||
@property
|
||||
def ufs_lower_left(self):
|
||||
return self._ufs_lower_left
|
||||
|
||||
|
||||
@property
|
||||
def ufs_upper_right(self):
|
||||
return self._ufs_upper_right
|
||||
|
||||
|
||||
@property
|
||||
def dd_mesh_dimension(self):
|
||||
return self._dd_mesh_dimension
|
||||
|
||||
|
||||
@property
|
||||
def dd_mesh_lower_left(self):
|
||||
return self._dd_mesh_lower_left
|
||||
|
||||
|
||||
@property
|
||||
def dd_mesh_upper_right(self):
|
||||
return self._dd_mesh_upper_right
|
||||
|
||||
|
||||
@property
|
||||
def dd_nodemap(self):
|
||||
return self._dd_nodemap
|
||||
|
||||
|
||||
@property
|
||||
def dd_allow_leakage(self):
|
||||
return self._dd_allow_leakage
|
||||
|
||||
|
||||
@property
|
||||
def dd_count_interactions(self):
|
||||
return self._dd_count_interactions
|
||||
|
||||
|
||||
@batches.setter
|
||||
def batches(self, batches):
|
||||
|
||||
if not is_integer(batches):
|
||||
msg = 'Unable to set batches to a non-integer ' \
|
||||
|
|
@ -98,7 +328,8 @@ class SettingsFile(object):
|
|||
self._batches = batches
|
||||
|
||||
|
||||
def set_generations_per_batch(self, generations_per_batch):
|
||||
@generations_per_batch.setter
|
||||
def generations_per_batch(self, generations_per_batch):
|
||||
|
||||
if not is_integer(generations_per_batch):
|
||||
msg = 'Unable to set generations per batch to a non-integer ' \
|
||||
|
|
@ -113,7 +344,8 @@ class SettingsFile(object):
|
|||
self._generations_per_batch = generations_per_batch
|
||||
|
||||
|
||||
def set_inactive(self, inactive):
|
||||
@inactive.setter
|
||||
def inactive(self, inactive):
|
||||
|
||||
if not is_integer(inactive):
|
||||
msg = 'Unable to set inactive batches to a non-integer ' \
|
||||
|
|
@ -128,7 +360,8 @@ class SettingsFile(object):
|
|||
self._inactive = inactive
|
||||
|
||||
|
||||
def set_particles(self, particles):
|
||||
@particles.setter
|
||||
def particles(self, particles):
|
||||
|
||||
if not is_integer(particles):
|
||||
msg = 'Unable to set particles to a non-integer ' \
|
||||
|
|
@ -143,7 +376,8 @@ class SettingsFile(object):
|
|||
self._particles = particles
|
||||
|
||||
|
||||
def set_source_file(self, source_file):
|
||||
@source_file.setter
|
||||
def source_file(self, source_file):
|
||||
|
||||
if not is_string(source_file):
|
||||
msg = 'Unable to set source file to a non-string ' \
|
||||
|
|
@ -271,7 +505,8 @@ class SettingsFile(object):
|
|||
self._source_energy_params = params
|
||||
|
||||
|
||||
def set_output(self, output):
|
||||
@output.setter
|
||||
def output(self, output):
|
||||
|
||||
if not isinstance(output, dict):
|
||||
msg = 'Unable to set output to {0} which is not a Python ' \
|
||||
|
|
@ -295,7 +530,8 @@ class SettingsFile(object):
|
|||
self._output = output
|
||||
|
||||
|
||||
def set_output_path(self, output_path):
|
||||
@output_path.setter
|
||||
def output_path(self, output_path):
|
||||
|
||||
if not is_string(output_path):
|
||||
msg = 'Unable to set output path to non-string ' \
|
||||
|
|
@ -305,7 +541,8 @@ class SettingsFile(object):
|
|||
self._output_path = output_path
|
||||
|
||||
|
||||
def set_verbosity(self, verbosity):
|
||||
@verbosity.setter
|
||||
def verbosity(self, verbosity):
|
||||
|
||||
if not is_integer(verbosity):
|
||||
msg = 'Unable to set verbosity to non-integer ' \
|
||||
|
|
@ -320,7 +557,8 @@ class SettingsFile(object):
|
|||
self._verbosity = verbosity
|
||||
|
||||
|
||||
def set_statepoint_batches(self, batches):
|
||||
@statepoint_batches.setter
|
||||
def statepoint_batches(self, batches):
|
||||
|
||||
if not isinstance(batches, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set statepoint batches to {0} which is not a ' \
|
||||
|
|
@ -342,7 +580,8 @@ class SettingsFile(object):
|
|||
self._statepoint_batches = batches
|
||||
|
||||
|
||||
def set_statepoint_interval(self, interval):
|
||||
@statepoint_interval.setter
|
||||
def statepoint_interval(self, interval):
|
||||
|
||||
if not is_integer(interval):
|
||||
msg = 'Unable to set statepoint interval to non-integer ' \
|
||||
|
|
@ -352,7 +591,8 @@ class SettingsFile(object):
|
|||
self._statepoint_interval = interval
|
||||
|
||||
|
||||
def set_sourcepoint_batches(self, batches):
|
||||
@sourcepoint_batches.setter
|
||||
def sourcepoint_batches(self, batches):
|
||||
|
||||
if not isinstance(batches, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set sourcepoint batches to {0} which is ' \
|
||||
|
|
@ -374,7 +614,8 @@ class SettingsFile(object):
|
|||
self._sourcepoint_batches = batches
|
||||
|
||||
|
||||
def set_sourcepoint_interval(self, interval):
|
||||
@sourcepoint_interval.setter
|
||||
def sourcepoint_interval(self, interval):
|
||||
|
||||
if not is_integer(interval):
|
||||
msg = 'Unable to set sourcepoint interval to non-integer ' \
|
||||
|
|
@ -384,7 +625,8 @@ class SettingsFile(object):
|
|||
self._sourcepoint_interval = interval
|
||||
|
||||
|
||||
def set_sourcepoint_separate(self, source_separate):
|
||||
@sourcepoint_separate.setter
|
||||
def sourcepoint_separate(self, source_separate):
|
||||
|
||||
if not isinstance(source_separate, (bool, np.bool)):
|
||||
msg = 'Unable to set sourcepoint separate to non-boolean ' \
|
||||
|
|
@ -394,7 +636,8 @@ class SettingsFile(object):
|
|||
self._sourcepoint_separate = source_separate
|
||||
|
||||
|
||||
def set_sourcepoint_write(self, source_write):
|
||||
@sourcepoint_write.setter
|
||||
def sourcepoint_write(self, source_write):
|
||||
|
||||
if not isinstance(source_write, (bool, np.bool)):
|
||||
msg = 'Unable to set sourcepoint write to non-boolean ' \
|
||||
|
|
@ -404,7 +647,8 @@ class SettingsFile(object):
|
|||
self._sourcepoint_write = source_write
|
||||
|
||||
|
||||
def set_sourcepoint_overwrite(self, source_overwrite):
|
||||
@sourcepoint_overwrite.setter
|
||||
def sourcepoint_overwrite(self, source_overwrite):
|
||||
|
||||
if not isinstance(source_overwrite, (bool, np.bool)):
|
||||
msg = 'Unable to set sourcepoint overwrite to non-boolean ' \
|
||||
|
|
@ -414,7 +658,8 @@ class SettingsFile(object):
|
|||
self._sourcepoint_overwrite = source_overwrite
|
||||
|
||||
|
||||
def set_confidence_intervals(self, confidence_intervals):
|
||||
@confidence_intervals.setter
|
||||
def confidence_intervals(self, confidence_intervals):
|
||||
|
||||
if not isinstance(confidence_intervals, (bool, np.bool)):
|
||||
msg = 'Unable to set confidence interval to non-boolean ' \
|
||||
|
|
@ -424,7 +669,8 @@ class SettingsFile(object):
|
|||
self._confidence_intervals = confidence_intervals
|
||||
|
||||
|
||||
def set_cross_sections(self, cross_sections):
|
||||
@cross_sections.setter
|
||||
def cross_sections(self, cross_sections):
|
||||
|
||||
if not is_string(cross_sections):
|
||||
msg = 'Unable to set cross sections to non-string ' \
|
||||
|
|
@ -434,7 +680,8 @@ class SettingsFile(object):
|
|||
self._cross_sections = cross_sections
|
||||
|
||||
|
||||
def set_energy_grid(self, energy_grid):
|
||||
@energy_grid.setter
|
||||
def energy_grid(self, energy_grid):
|
||||
|
||||
if not energy_grid in ['nuclide', 'logarithm', 'material-union']:
|
||||
msg = 'Unable to set energy grid to {0} which is neither ' \
|
||||
|
|
@ -444,7 +691,8 @@ class SettingsFile(object):
|
|||
self._energy_grid = energy_grid
|
||||
|
||||
|
||||
def set_ptables(self, ptables):
|
||||
@ptables.setter
|
||||
def ptables(self, ptables):
|
||||
|
||||
if not isinstance(ptables, (bool, np.bool)):
|
||||
msg = 'Unable to set ptables to non-boolean ' \
|
||||
|
|
@ -454,7 +702,8 @@ class SettingsFile(object):
|
|||
self._ptables = ptables
|
||||
|
||||
|
||||
def set_run_cmfd(self, run_cmfd):
|
||||
@run_cmfd.setter
|
||||
def run_cmfd(self, run_cmfd):
|
||||
|
||||
if not isinstance(run_cmfd, (bool, np.bool)):
|
||||
msg = 'Unable to set run_cmfd to non-boolean ' \
|
||||
|
|
@ -464,7 +713,8 @@ class SettingsFile(object):
|
|||
self._run_cmfd = run_cmfd
|
||||
|
||||
|
||||
def set_seed(self, seed):
|
||||
@seed.setter
|
||||
def seed(self, seed):
|
||||
|
||||
if not is_integer(seed):
|
||||
msg = 'Unable to set seed to non-integer value {0}'.format(seed)
|
||||
|
|
@ -477,7 +727,8 @@ class SettingsFile(object):
|
|||
self._seed = seed
|
||||
|
||||
|
||||
def set_survival_biasing(self, survival_biasing):
|
||||
@survival_biasing.setter
|
||||
def survival_biasing(self, survival_biasing):
|
||||
|
||||
if not isinstance(survival_biasing, (bool, np.bool)):
|
||||
msg = 'Unable to set survival biasing to non-boolean ' \
|
||||
|
|
@ -487,7 +738,8 @@ class SettingsFile(object):
|
|||
self._survival_biasing = survival_biasing
|
||||
|
||||
|
||||
def set_weight(self, weight, weight_avg):
|
||||
@weight.setter
|
||||
def weight(self, weight, weight_avg):
|
||||
|
||||
if not is_float(weight):
|
||||
msg = 'Unable to set weight cutoff to non-floating point ' \
|
||||
|
|
@ -513,7 +765,8 @@ class SettingsFile(object):
|
|||
self._weight_avg = weight_avg
|
||||
|
||||
|
||||
def set_entropy_dimension(self, dimension):
|
||||
@entropy_dimension.setter
|
||||
def entropy_dimension(self, dimension):
|
||||
|
||||
if not isinstance(dimension, (tuple, list)):
|
||||
msg = 'Unable to set entropy mesh dimension to {0} which is ' \
|
||||
|
|
@ -535,7 +788,8 @@ class SettingsFile(object):
|
|||
self._entropy_dimension = dimension
|
||||
|
||||
|
||||
def set_entropy_lower_left(self, lower_left):
|
||||
@entropy_lower_left.setter
|
||||
def entropy_lower_left(self, lower_left):
|
||||
|
||||
if not isinstance(lower_left, (tuple, list)):
|
||||
msg = 'Unable to set entropy mesh lower left corner to {0} which ' \
|
||||
|
|
@ -558,7 +812,8 @@ class SettingsFile(object):
|
|||
self._entropy_lower_left = lower_left
|
||||
|
||||
|
||||
def set_entropy_upper_right(self, upper_right):
|
||||
@entropy_upper_right.setter
|
||||
def entropy_upper_right(self, upper_right):
|
||||
|
||||
if not isinstance(upper_right, (tuple, list)):
|
||||
msg = 'Unable to set entropy mesh upper right corner to {0} ' \
|
||||
|
|
@ -581,7 +836,8 @@ class SettingsFile(object):
|
|||
self._entropy_upper_right = upper_right
|
||||
|
||||
|
||||
def set_no_reduce(self, no_reduce):
|
||||
@no_reduce.setter
|
||||
def no_reduce(self, no_reduce):
|
||||
|
||||
if not isinstance(no_reduce, (bool, np.bool)):
|
||||
msg = 'Unable to set the no_reduce to a non-boolean ' \
|
||||
|
|
@ -591,7 +847,8 @@ class SettingsFile(object):
|
|||
self._no_reduce = no_reduce
|
||||
|
||||
|
||||
def set_threads(self, threads):
|
||||
@threads.setter
|
||||
def threads(self, threads):
|
||||
|
||||
if not is_integer(threads):
|
||||
msg = 'Unable to set the threads to a non-integer ' \
|
||||
|
|
@ -606,7 +863,8 @@ class SettingsFile(object):
|
|||
self._threads = threads
|
||||
|
||||
|
||||
def set_trace(self, trace):
|
||||
@trace.setter
|
||||
def trace(self, trace):
|
||||
|
||||
if not isinstance(trace, (list, tuple)):
|
||||
msg = 'Unable to set the trace to {0} which is not a Python ' \
|
||||
|
|
@ -636,7 +894,8 @@ class SettingsFile(object):
|
|||
self._trace = trace
|
||||
|
||||
|
||||
def set_track(self, track):
|
||||
@track.setter
|
||||
def track(self, track):
|
||||
|
||||
if not isinstance(track, (list, tuple)):
|
||||
msg = 'Unable to set the track to {0} which is not a Python ' \
|
||||
|
|
@ -667,7 +926,8 @@ class SettingsFile(object):
|
|||
self._track = track
|
||||
|
||||
|
||||
def set_ufs_dimension(self, dimension):
|
||||
@ufs_dimension.setter
|
||||
def ufs_dimension(self, dimension):
|
||||
|
||||
if not is_integer(dimension) and not is_float(dimension):
|
||||
msg = 'Unable to set UFS dimension to non-integer or ' \
|
||||
|
|
@ -682,7 +942,8 @@ class SettingsFile(object):
|
|||
self._ufs_dimension = dimension
|
||||
|
||||
|
||||
def set_ufs_lower_left(self, lower_left):
|
||||
@ufs_lower_left.setter
|
||||
def ufs_lower_left(self, lower_left):
|
||||
|
||||
if not isinstance(lower_left, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set UFS mesh lower left corner to {0} which is ' \
|
||||
|
|
@ -697,7 +958,8 @@ class SettingsFile(object):
|
|||
self._ufs_lower_left = lower_left
|
||||
|
||||
|
||||
def set_ufs_upper_right(self, upper_right):
|
||||
@ufs_upper_right.setter
|
||||
def ufs_upper_right(self, upper_right):
|
||||
|
||||
if not isinstance(upper_right, tuple) and \
|
||||
not isinstance(upper_right, list):
|
||||
|
|
@ -713,7 +975,8 @@ class SettingsFile(object):
|
|||
self._ufs_upper_right = upper_right
|
||||
|
||||
|
||||
def set_dd_mesh_dimension(self, dimension):
|
||||
@dd_mesh_dimension.setter
|
||||
def dd_mesh_dimension(self, dimension):
|
||||
|
||||
# TODO: remove this when domain decomposition is merged
|
||||
warnings.warn('This feature is not yet implemented in a release ' \
|
||||
|
|
@ -733,7 +996,8 @@ class SettingsFile(object):
|
|||
self._dd_mesh_dimension = dimension
|
||||
|
||||
|
||||
def set_dd_mesh_lower_left(self, lower_left):
|
||||
@dd_mesh_lower_left.setter
|
||||
def dd_mesh_lower_left(self, lower_left):
|
||||
|
||||
# TODO: remove this when domain decomposition is merged
|
||||
warnings.warn('This feature is not yet implemented in a release ' \
|
||||
|
|
@ -752,7 +1016,8 @@ class SettingsFile(object):
|
|||
self._dd_mesh_lower_left = lower_left
|
||||
|
||||
|
||||
def set_dd_mesh_upper_right(self, upper_right):
|
||||
@dd_mesh_upper_right.setter
|
||||
def dd_mesh_upper_right(self, upper_right):
|
||||
|
||||
# TODO: remove this when domain decomposition is merged
|
||||
warnings.warn('This feature is not yet implemented in a release ' \
|
||||
|
|
@ -772,7 +1037,8 @@ class SettingsFile(object):
|
|||
self._dd_mesh_upper_right = upper_right
|
||||
|
||||
|
||||
def set_dd_nodemap(self, nodemap):
|
||||
@dd_nodemap.setter
|
||||
def dd_nodemap(self, nodemap):
|
||||
|
||||
# TODO: remove this when domain decomposition is merged
|
||||
warnings.warn('This feature is not yet implemented in a release ' \
|
||||
|
|
@ -781,7 +1047,7 @@ class SettingsFile(object):
|
|||
if not isinstance(nodemap, tuple) and \
|
||||
not isinstance(nodemap, list):
|
||||
msg = 'Unable to set DD nodemap {0} which is ' \
|
||||
'not a Python tuple or list'.format(dimension)
|
||||
'not a Python tuple or list'.format(nodemap)
|
||||
raise ValueError(msg)
|
||||
|
||||
nodemap = np.array(nodemap).flatten()
|
||||
|
|
@ -801,7 +1067,8 @@ class SettingsFile(object):
|
|||
self._dd_nodemap = nodemap
|
||||
|
||||
|
||||
def set_dd_allow_leakage(self, allow):
|
||||
@dd_allow_leakage.setter
|
||||
def dd_allow_leakage(self, allow):
|
||||
|
||||
# TODO: remove this when domain decomposition is merged
|
||||
warnings.warn('This feature is not yet implemented in a release ' \
|
||||
|
|
@ -809,13 +1076,14 @@ class SettingsFile(object):
|
|||
|
||||
if not isinstance(allow, bool):
|
||||
msg = 'Unable to set DD allow_leakage {0} which is ' \
|
||||
'not a Python bool'.format(dimension)
|
||||
'not a Python bool'.format(allow)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._dd_allow_leakage = allow
|
||||
|
||||
|
||||
def set_dd_count_interactions(self, interactions):
|
||||
@dd_count_interactions.setter
|
||||
def dd_count_interactions(self, interactions):
|
||||
|
||||
# TODO: remove this when domain decomposition is merged
|
||||
warnings.warn('This feature is not yet implemented in a release ' \
|
||||
|
|
@ -823,7 +1091,7 @@ class SettingsFile(object):
|
|||
|
||||
if not isinstance(interactions, bool):
|
||||
msg = 'Unable to set DD count_interactions {0} which is ' \
|
||||
'not a Python bool'.format(dimension)
|
||||
'not a Python bool'.format(interactions)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._dd_count_interactions = interactions
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class Summary(object):
|
|||
self.nuclides[zaid] = openmc.Element(name=name, xs=xs)
|
||||
else:
|
||||
self.nuclides[zaid] = openmc.Nuclide(name=name, xs=xs)
|
||||
self.nuclides[zaid].set_zaid(zaid)
|
||||
self.nuclides[zaid].zaid = zaid
|
||||
|
||||
|
||||
def _read_materials(self):
|
||||
|
|
@ -278,14 +278,14 @@ class Summary(object):
|
|||
translation = \
|
||||
self._f['geometry/cells'][key]['translation'][...]
|
||||
translation = np.asarray(translation, dtype=np.float64)
|
||||
cell.set_translation(translation)
|
||||
cell.translation = translation
|
||||
|
||||
rotated = self._f['geometry/cells'][key]['rotated'][0]
|
||||
if rotated:
|
||||
rotation = \
|
||||
self._f['geometry/cells'][key]['rotation'][...]
|
||||
rotation = np.asarray(rotation, dtype=np.int)
|
||||
cell.set_rotation(rotation)
|
||||
cell.rotation = rotation
|
||||
|
||||
# Store Cell fill information for after Universe/Lattice creation
|
||||
self._cell_fills[index] = (fill_type, fill)
|
||||
|
|
@ -351,7 +351,7 @@ class Summary(object):
|
|||
lattice_type = self._f['geometry/lattices'][key]['type'][...][0]
|
||||
|
||||
if lattice_type == 'rectangular':
|
||||
dimension = self._f['geometry/lattices'][key]['n_cells'][...]
|
||||
dimension = self._f['geometry/lattices'][key]['dimension'][...]
|
||||
lower_left = \
|
||||
self._f['geometry/lattices'][key]['lower_left'][...]
|
||||
pitch = self._f['geometry/lattices'][key]['pitch'][...]
|
||||
|
|
@ -364,13 +364,13 @@ class Summary(object):
|
|||
|
||||
# Create the Lattice
|
||||
lattice = openmc.RectLattice(lattice_id=lattice_id)
|
||||
lattice.set_dimension(tuple(dimension))
|
||||
lattice.set_lower_left(lower_left)
|
||||
lattice.set_pitch(pitch)
|
||||
lattice.dimension = tuple(dimension)
|
||||
lattice.lower_left = lower_left
|
||||
lattice.pitch = pitch
|
||||
|
||||
# If the Universe specified outer the Lattice is not void (-22)
|
||||
if outer != -22:
|
||||
lattice.set_outer(self.universes[outer])
|
||||
lattice.outer = self.universes[outer]
|
||||
|
||||
# Build array of Universe pointers for the Lattice
|
||||
universes = \
|
||||
|
|
@ -387,7 +387,7 @@ class Summary(object):
|
|||
universes = np.transpose(universes, (1,0,2))
|
||||
universes.shape = shape
|
||||
universes = universes[:,::-1,:]
|
||||
lattice.set_universes(universes)
|
||||
lattice.universes = universes
|
||||
|
||||
# Add the Lattice to the global dictionary of all Lattices
|
||||
self.lattices[index] = lattice
|
||||
|
|
@ -404,14 +404,14 @@ class Summary(object):
|
|||
|
||||
# Create the Lattice
|
||||
lattice = openmc.HexLattice(lattice_id=lattice_id)
|
||||
lattice.set_num_rings(n_rings)
|
||||
lattice.set_num_axial(n_axial)
|
||||
lattice.set_center(center)
|
||||
lattice.set_pitch(pitch)
|
||||
lattice.num_rings(n_rings)
|
||||
lattice.num_axial = n_axial
|
||||
lattice.center = center
|
||||
lattice.pitch = pitch
|
||||
|
||||
# If the Universe specified outer the Lattice is not void (-22)
|
||||
if outer != -22:
|
||||
lattice.set_outer(self.universes[outer])
|
||||
lattice.outer = self.universes[outer]
|
||||
|
||||
# Build array of Universe pointers for the Lattice
|
||||
universes = \
|
||||
|
|
@ -452,11 +452,11 @@ class Summary(object):
|
|||
fill = self.get_lattice_by_id(fill_id)
|
||||
|
||||
# Set the fill for the Cell
|
||||
self.cells[cell_key].set_fill(fill)
|
||||
self.cells[cell_key].fill = fill
|
||||
|
||||
# Set the root universe for the Geometry
|
||||
root_universe = self.get_universe_by_id(0)
|
||||
self.openmc_geometry.set_root_universe(root_universe)
|
||||
self.openmc_geometry.root_universe = root_universe
|
||||
|
||||
|
||||
def make_opencg_geometry(self):
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ def reset_auto_surface_id():
|
|||
|
||||
class Surface(object):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission', name=''):
|
||||
def __init__(self, surface_id=None, boundary_type='transmission', name=''):
|
||||
|
||||
# Initialize class attributes
|
||||
self._id = None
|
||||
self._name = ''
|
||||
self.id = surface_id
|
||||
self.name = name
|
||||
self._type = ''
|
||||
self._bc_type = ''
|
||||
self.boundary_type = boundary_type
|
||||
|
||||
# A dictionary of the quadratic surface coefficients
|
||||
# Key - coefficeint name
|
||||
|
|
@ -32,12 +32,34 @@ class Surface(object):
|
|||
# proper order
|
||||
self._coeff_keys = []
|
||||
|
||||
self.set_id(surface_id)
|
||||
self.set_boundary_type(bc_type)
|
||||
self.set_name(name)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
|
||||
def set_id(self, surface_id=None):
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
|
||||
@property
|
||||
def boundary_type(self):
|
||||
return self._boundary_type
|
||||
|
||||
|
||||
@property
|
||||
def coeffs(self):
|
||||
return self._coeffs
|
||||
|
||||
|
||||
@id.setter
|
||||
def id(self, surface_id):
|
||||
|
||||
if surface_id is None:
|
||||
global AUTO_SURFACE_ID
|
||||
|
|
@ -59,7 +81,8 @@ class Surface(object):
|
|||
self._id = surface_id
|
||||
|
||||
|
||||
def set_name(self, name):
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
|
||||
if not is_string(name):
|
||||
msg = 'Unable to set name for Surface ID={0} with a non-string ' \
|
||||
|
|
@ -70,21 +93,22 @@ class Surface(object):
|
|||
self._name = name
|
||||
|
||||
|
||||
def set_boundary_type(self, bc_type):
|
||||
@boundary_type.setter
|
||||
def boundary_type(self, boundary_type):
|
||||
|
||||
if not is_string(bc_type):
|
||||
if not is_string(boundary_type):
|
||||
msg = 'Unable to set boundary type for Surface ID={0} with a ' \
|
||||
'non-string value {1}'.format(self._id, bc_type)
|
||||
'non-string value {1}'.format(self._id, boundary_type)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not bc_type in BC_TYPES.values():
|
||||
elif not boundary_type in BC_TYPES.values():
|
||||
msg = 'Unable to set boundary type for Surface ID={0} to ' \
|
||||
'{1} which is not trasmission, vacuum or ' \
|
||||
'reflective'.format(bc_type)
|
||||
'reflective'.format(boundary_type)
|
||||
raise ValueError(msg)
|
||||
|
||||
else:
|
||||
self._bc_type = bc_type
|
||||
self._boundary_type = boundary_type
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
|
|
@ -93,7 +117,7 @@ class Surface(object):
|
|||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tBoundary', '=\t', self._bc_type)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tBoundary', '=\t', self._boundary_type)
|
||||
|
||||
coeffs = '{0: <16}'.format('\tCoefficients') + '\n'
|
||||
|
||||
|
|
@ -110,7 +134,7 @@ class Surface(object):
|
|||
element = ET.Element("surface")
|
||||
element.set("id", str(self._id))
|
||||
element.set("type", self._type)
|
||||
element.set("boundary", self._bc_type)
|
||||
element.set("boundary", self._boundary_type)
|
||||
|
||||
coeffs = ''
|
||||
|
||||
|
|
@ -125,33 +149,50 @@ class Surface(object):
|
|||
|
||||
class Plane(Surface):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
A=None, B=None, C=None, D=None, name='',):
|
||||
|
||||
# Initialize Plane class attributes
|
||||
super(Plane, self).__init__(surface_id, bc_type, name=name)
|
||||
super(Plane, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
||||
self._A = None
|
||||
self._B = None
|
||||
self._C = None
|
||||
self._D = None
|
||||
self._type = 'plane'
|
||||
self._coeff_keys = ['A', 'B', 'C', 'D']
|
||||
|
||||
if not A is None:
|
||||
self.set_A(A)
|
||||
self.a = A
|
||||
|
||||
if not B is None:
|
||||
self.set_B(B)
|
||||
self.b = B
|
||||
|
||||
if not C is None:
|
||||
self.set_C(C)
|
||||
self.c = C
|
||||
|
||||
if not D is None:
|
||||
self.set_D(D)
|
||||
self.d = D
|
||||
|
||||
|
||||
def set_A(self, A):
|
||||
@property
|
||||
def a(self):
|
||||
return self.coeffs['A']
|
||||
|
||||
|
||||
@property
|
||||
def b(self):
|
||||
return self.coeffs['B']
|
||||
|
||||
|
||||
@property
|
||||
def c(self):
|
||||
return self.coeffs['C']
|
||||
|
||||
|
||||
@property
|
||||
def d(self):
|
||||
return self.coeffs['D']
|
||||
|
||||
|
||||
@a.setter
|
||||
def a(self, A):
|
||||
|
||||
if not is_integer(A) and not is_float(A):
|
||||
msg = 'Unable to set A coefficient for Plane ID={0} to a ' \
|
||||
|
|
@ -161,7 +202,8 @@ class Plane(Surface):
|
|||
self._coeffs['A'] = A
|
||||
|
||||
|
||||
def set_B(self, B):
|
||||
@b.setter
|
||||
def b(self, B):
|
||||
|
||||
if not is_integer(B) and not is_float(B):
|
||||
msg = 'Unable to set B coefficient for Plane ID={0} to a ' \
|
||||
|
|
@ -171,7 +213,8 @@ class Plane(Surface):
|
|||
self._coeffs['B'] = B
|
||||
|
||||
|
||||
def set_C(self, C):
|
||||
@c.setter
|
||||
def c(self, C):
|
||||
|
||||
if not is_integer(C) and not is_float(C):
|
||||
msg = 'Unable to set C coefficient for Plane ID={0} to a ' \
|
||||
|
|
@ -181,7 +224,8 @@ class Plane(Surface):
|
|||
self._coeffs['C'] = C
|
||||
|
||||
|
||||
def set_D(self, D):
|
||||
@d.setter
|
||||
def d(self, D):
|
||||
|
||||
if not is_integer(D) and not is_float(D):
|
||||
msg = 'Unable to set D coefficient for Plane ID={0} to a ' \
|
||||
|
|
@ -194,21 +238,26 @@ class Plane(Surface):
|
|||
|
||||
class XPlane(Plane):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=None, name=''):
|
||||
|
||||
# Initialize XPlane class attributes
|
||||
super(XPlane, self).__init__(surface_id, bc_type, name=name)
|
||||
super(XPlane, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
||||
self._x0 = None
|
||||
self._type = 'x-plane'
|
||||
self._coeff_keys = ['x0']
|
||||
|
||||
if not x0 is None:
|
||||
self.set_X0(x0)
|
||||
self.x0 = x0
|
||||
|
||||
|
||||
def set_X0(self, x0):
|
||||
@property
|
||||
def x0(self):
|
||||
return self.coeff['x0']
|
||||
|
||||
|
||||
@x0.setter
|
||||
def x0(self, x0):
|
||||
|
||||
if not is_integer(x0) and not is_float(x0):
|
||||
msg = 'Unable to set x0 coefficient for XPlane ID={0} to a ' \
|
||||
|
|
@ -221,21 +270,26 @@ class XPlane(Plane):
|
|||
|
||||
class YPlane(Plane):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
y0=None, name=''):
|
||||
|
||||
# Initialize YPlane class attributes
|
||||
super(YPlane, self).__init__(surface_id, bc_type, name=name)
|
||||
super(YPlane, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
||||
self._y0 = None
|
||||
self._type = 'y-plane'
|
||||
self._coeff_keys = ['y0']
|
||||
|
||||
if not y0 is None:
|
||||
self.set_Y0(y0)
|
||||
self.y0 = y0
|
||||
|
||||
|
||||
def set_Y0(self, y0):
|
||||
@property
|
||||
def y0(self):
|
||||
return self.coeffs['y0']
|
||||
|
||||
|
||||
@y0.setter
|
||||
def y0(self, y0):
|
||||
|
||||
if not is_integer(y0) and not is_float(y0):
|
||||
msg = 'Unable to set y0 coefficient for XPlane ID={0} to a ' \
|
||||
|
|
@ -248,21 +302,26 @@ class YPlane(Plane):
|
|||
|
||||
class ZPlane(Plane):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
z0=None, name=''):
|
||||
|
||||
# Initialize ZPlane class attributes
|
||||
super(ZPlane, self).__init__(surface_id, bc_type, name=name)
|
||||
super(ZPlane, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
||||
self._z0 = None
|
||||
self._type = 'z-plane'
|
||||
self._coeff_keys = ['z0']
|
||||
|
||||
if not z0 is None:
|
||||
self.set_Z0(z0)
|
||||
self.z0 = z0
|
||||
|
||||
|
||||
def set_Z0(self, z0):
|
||||
@property
|
||||
def z0(self):
|
||||
return self.coeffs['z0']
|
||||
|
||||
|
||||
@z0.setter
|
||||
def z0(self, z0):
|
||||
|
||||
if not is_integer(z0) and not is_float(z0):
|
||||
msg = 'Unable to set z0 coefficient for ZPlane ID={0} to a ' \
|
||||
|
|
@ -275,20 +334,25 @@ class ZPlane(Plane):
|
|||
|
||||
class Cylinder(Surface):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
R=None, name=''):
|
||||
|
||||
# Initialize Cylinder class attributes
|
||||
super(Cylinder, self).__init__(surface_id, bc_type, name=name)
|
||||
super(Cylinder, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
||||
self._R = None
|
||||
self._coeff_keys = ['R']
|
||||
|
||||
if not R is None:
|
||||
self.set_R(R)
|
||||
self.r = R
|
||||
|
||||
|
||||
def set_R(self, R):
|
||||
@property
|
||||
def r(self):
|
||||
return self.coeffs['R']
|
||||
|
||||
|
||||
@r.setter
|
||||
def r(self, R):
|
||||
|
||||
if not is_integer(R) and not is_float(R):
|
||||
msg = 'Unable to set R coefficient for Cylinder ID={0} to a ' \
|
||||
|
|
@ -301,25 +365,34 @@ class Cylinder(Surface):
|
|||
|
||||
class XCylinder(Cylinder):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
y0=None, z0=None, R=None, name=''):
|
||||
|
||||
# Initialize XCylinder class attributes
|
||||
super(XCylinder, self).__init__(surface_id, bc_type, R, name=name)
|
||||
super(XCylinder, self).__init__(surface_id, boundary_type, R, name=name)
|
||||
|
||||
self._type = 'x-cylinder'
|
||||
self._y0 = None
|
||||
self._z0 = None
|
||||
self._coeff_keys = ['y0', 'z0', 'R']
|
||||
|
||||
if not y0 is None:
|
||||
self.set_Y0(y0)
|
||||
self.y0 = y0
|
||||
|
||||
if not z0 is None:
|
||||
self.set_Z0(z0)
|
||||
self.z0 = z0
|
||||
|
||||
|
||||
def set_Y0(self, y0):
|
||||
@property
|
||||
def y0(self):
|
||||
return self.coeffs['y0']
|
||||
|
||||
|
||||
@property
|
||||
def z0(self):
|
||||
return self.coeffs['z0']
|
||||
|
||||
|
||||
@y0.setter
|
||||
def y0(self, y0):
|
||||
|
||||
if not is_integer(y0) and not is_float(y0):
|
||||
msg = 'Unable to set y0 coefficient for XCylinder ID={0} to a ' \
|
||||
|
|
@ -329,7 +402,8 @@ class XCylinder(Cylinder):
|
|||
self._coeffs['y0'] = y0
|
||||
|
||||
|
||||
def set_Z0(self, z0):
|
||||
@z0.setter
|
||||
def z0(self, z0):
|
||||
|
||||
if not is_integer(z0) and not is_float(z0):
|
||||
msg = 'Unable to set z0 coefficient for XCylinder ID={0} to a ' \
|
||||
|
|
@ -342,25 +416,34 @@ class XCylinder(Cylinder):
|
|||
|
||||
class YCylinder(Cylinder):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=None, z0=None, R=None, name=''):
|
||||
|
||||
# Initialize YCylinder class attributes
|
||||
super(YCylinder, self).__init__(surface_id, bc_type, R, name=name)
|
||||
super(YCylinder, self).__init__(surface_id, boundary_type, R, name=name)
|
||||
|
||||
self._type = 'y-cylinder'
|
||||
self._x0 = None
|
||||
self._z0 = None
|
||||
self._coeff_keys = ['x0', 'z0', 'R']
|
||||
|
||||
if not x0 is None:
|
||||
self.set_X0(x0)
|
||||
self.x0 = x0
|
||||
|
||||
if not z0 is None:
|
||||
self.set_Z0(z0)
|
||||
self.z0 = z0
|
||||
|
||||
|
||||
def set_X0(self, x0):
|
||||
@property
|
||||
def x0(self):
|
||||
return self.coeffs['x0']
|
||||
|
||||
|
||||
@property
|
||||
def z0(self):
|
||||
return self.coeffs['z0']
|
||||
|
||||
|
||||
@x0.setter
|
||||
def x0(self, x0):
|
||||
|
||||
if not is_integer(x0) and not is_float(x0):
|
||||
msg = 'Unable to set x0 coefficient for YCylinder ID={0} to a ' \
|
||||
|
|
@ -370,7 +453,8 @@ class YCylinder(Cylinder):
|
|||
self._coeffs['x0'] = x0
|
||||
|
||||
|
||||
def set_Z0(self, z0):
|
||||
@z0.setter
|
||||
def z0(self, z0):
|
||||
|
||||
if not is_integer(z0) and not is_float(z0):
|
||||
msg = 'Unable to set z0 coefficient for YCylinder ID={0} to a ' \
|
||||
|
|
@ -382,26 +466,35 @@ class YCylinder(Cylinder):
|
|||
|
||||
class ZCylinder(Cylinder):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=None, y0=None, R=None, name=''):
|
||||
|
||||
# Initialize ZCylinder class attributes
|
||||
# Initialize YPlane class attributes
|
||||
super(ZCylinder, self).__init__(surface_id, bc_type, R, name=name)
|
||||
super(ZCylinder, self).__init__(surface_id, boundary_type, R, name=name)
|
||||
|
||||
self._type = 'z-cylinder'
|
||||
self._x0 = None
|
||||
self._y0 = None
|
||||
self._coeff_keys = ['x0', 'y0', 'R']
|
||||
|
||||
if not x0 is None:
|
||||
self.set_X0(x0)
|
||||
self.x0 = x0
|
||||
|
||||
if not y0 is None:
|
||||
self.set_Y0(y0)
|
||||
self.y0 = y0
|
||||
|
||||
|
||||
def set_X0(self, x0):
|
||||
@property
|
||||
def x0(self):
|
||||
return self.coeffs['x0']
|
||||
|
||||
|
||||
@property
|
||||
def y0(self):
|
||||
return self.coeffs['y0']
|
||||
|
||||
|
||||
@x0.setter
|
||||
def x0(self, x0):
|
||||
|
||||
if not is_integer(x0) and not is_float(x0):
|
||||
msg = 'Unable to set x0 coefficient for ZCylinder ID={0} to a ' \
|
||||
|
|
@ -411,7 +504,8 @@ class ZCylinder(Cylinder):
|
|||
self._coeffs['x0'] = x0
|
||||
|
||||
|
||||
def set_Y0(self, y0):
|
||||
@y0.setter
|
||||
def y0(self, y0):
|
||||
|
||||
if not is_integer(y0) and not is_float(y0):
|
||||
msg = 'Unable to set y0 coefficient for ZCylinder ID={0} to a ' \
|
||||
|
|
@ -424,33 +518,50 @@ class ZCylinder(Cylinder):
|
|||
|
||||
class Sphere(Surface):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=None, y0=None, z0=None, R=None, name=''):
|
||||
|
||||
# Initialize Sphere class attributes
|
||||
super(Sphere, self).__init__(surface_id, bc_type, name=name)
|
||||
super(Sphere, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
||||
self._type = 'sphere'
|
||||
self._x0 = None
|
||||
self._y0 = None
|
||||
self._z0 = None
|
||||
self._R = None
|
||||
self._coeff_keys = ['x0', 'y0', 'z0', 'R']
|
||||
|
||||
if not x0 is None:
|
||||
self.set_X0(x0)
|
||||
self.x0 = x0
|
||||
|
||||
if not y0 is None:
|
||||
self.set_Y0(y0)
|
||||
self.y0 = y0
|
||||
|
||||
if not z0 is None:
|
||||
self.set_Z0(z0)
|
||||
self.z0 = z0
|
||||
|
||||
if not R is None:
|
||||
self.set_Z0(R)
|
||||
self.r = R
|
||||
|
||||
|
||||
def set_X0(self, x0):
|
||||
@property
|
||||
def x0(self):
|
||||
return self.coeffs['x0']
|
||||
|
||||
|
||||
@property
|
||||
def y0(self):
|
||||
return self.coeffs['y0']
|
||||
|
||||
|
||||
@property
|
||||
def z0(self):
|
||||
return self.coeffs['z0']
|
||||
|
||||
|
||||
@property
|
||||
def r(self):
|
||||
return self.coeffs['R']
|
||||
|
||||
|
||||
@x0.setter
|
||||
def x0(self, x0):
|
||||
|
||||
if not is_integer(x0) and not is_float(x0):
|
||||
msg = 'Unable to set x0 coefficient for Sphere ID={0} to a ' \
|
||||
|
|
@ -460,7 +571,8 @@ class Sphere(Surface):
|
|||
self._coeffs['x0'] = x0
|
||||
|
||||
|
||||
def set_Y0(self, y0):
|
||||
@y0.setter
|
||||
def y0(self, y0):
|
||||
|
||||
if not is_integer(y0) and not is_float(y0):
|
||||
msg = 'Unable to set y0 coefficient for Sphere ID={0} to a ' \
|
||||
|
|
@ -470,7 +582,8 @@ class Sphere(Surface):
|
|||
self._coeffs['y0'] = y0
|
||||
|
||||
|
||||
def set_Z0(self, z0):
|
||||
@z0.setter
|
||||
def z0(self, z0):
|
||||
|
||||
if not is_integer(z0) and not is_float(z0):
|
||||
msg = 'Unable to set z0 coefficient for Sphere ID={0} to a ' \
|
||||
|
|
@ -480,7 +593,8 @@ class Sphere(Surface):
|
|||
self._coeffs['z0'] = z0
|
||||
|
||||
|
||||
def set_R(self, R):
|
||||
@r.setter
|
||||
def r(self, R):
|
||||
|
||||
if not is_integer(R) and not is_float(R):
|
||||
msg = 'Unable to set R coefficient for Sphere ID={0} to a ' \
|
||||
|
|
@ -493,32 +607,49 @@ class Sphere(Surface):
|
|||
|
||||
class Cone(Surface):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=None, y0=None, z0=None, R2=None, name=''):
|
||||
|
||||
# Initialize Cone class attributes
|
||||
super(Cone, self).__init__(surface_id, bc_type, name=name)
|
||||
super(Cone, self).__init__(surface_id, boundary_type, name=name)
|
||||
|
||||
self._x0 = None
|
||||
self._y0 = None
|
||||
self._z0 = None
|
||||
self._R2 = None
|
||||
self._coeff_keys = ['x0', 'y0', 'z0', 'R2']
|
||||
|
||||
if not x0 is None:
|
||||
self.set_X0(x0)
|
||||
self.x0 = x0
|
||||
|
||||
if not y0 is None:
|
||||
self.set_Y0(y0)
|
||||
self.y0 = y0
|
||||
|
||||
if not z0 is None:
|
||||
self.set_Z0(z0)
|
||||
self.z0 = z0
|
||||
|
||||
if not R2 is None:
|
||||
self.set_Z0(R2)
|
||||
self.r2 = R2
|
||||
|
||||
|
||||
def set_X0(self, x0):
|
||||
@property
|
||||
def x0(self):
|
||||
return self.coeffs['x0']
|
||||
|
||||
|
||||
@property
|
||||
def y0(self):
|
||||
return self.coeffs['y0']
|
||||
|
||||
|
||||
@property
|
||||
def z0(self):
|
||||
return self.coeffs['z0']
|
||||
|
||||
|
||||
@property
|
||||
def r2(self):
|
||||
return self.coeffs['r2']
|
||||
|
||||
|
||||
@x0.setter
|
||||
def x0(self, x0):
|
||||
|
||||
if not is_integer(x0) and not is_float(x0):
|
||||
msg = 'Unable to set x0 coefficient for Cone ID={0} to a ' \
|
||||
|
|
@ -528,7 +659,8 @@ class Cone(Surface):
|
|||
self._coeffs['x0'] = x0
|
||||
|
||||
|
||||
def set_Y0(self, y0):
|
||||
@y0.setter
|
||||
def y0(self, y0):
|
||||
|
||||
if not is_integer(y0) and not is_float(y0):
|
||||
msg = 'Unable to set y0 coefficient for Cone ID={0} to a ' \
|
||||
|
|
@ -538,7 +670,8 @@ class Cone(Surface):
|
|||
self._coeffs['y0'] = y0
|
||||
|
||||
|
||||
def set_Z0(self, z0):
|
||||
@z0.setter
|
||||
def z0(self, z0):
|
||||
|
||||
if not is_integer(z0) and not is_float(z0):
|
||||
msg = 'Unable to set z0 coefficient for Cone ID={0} to a ' \
|
||||
|
|
@ -548,7 +681,8 @@ class Cone(Surface):
|
|||
self._coeffs['z0'] = z0
|
||||
|
||||
|
||||
def set_R2(self, R2):
|
||||
@r2.setter
|
||||
def r2(self, R2):
|
||||
|
||||
if not is_integer(R2) and not is_float(R2):
|
||||
msg = 'Unable to set R^2 coefficient for Cone ID={0} to a ' \
|
||||
|
|
@ -561,11 +695,12 @@ class Cone(Surface):
|
|||
|
||||
class XCone(Cone):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=None, y0=None, z0=None, R2=None, name=''):
|
||||
|
||||
# Initialize XCone class attributes
|
||||
super(XCone, self).__init__(surface_id, bc_type, x0, y0, z0, R2, name=name)
|
||||
super(XCone, self).__init__(surface_id, boundary_type, x0, y0,
|
||||
z0, R2, name=name)
|
||||
|
||||
self._type = 'x-cone'
|
||||
|
||||
|
|
@ -573,11 +708,12 @@ class XCone(Cone):
|
|||
|
||||
class YCone(Cone):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=None, y0=None, z0=None, R2=None, name=''):
|
||||
|
||||
# Initialize YCone class attributes
|
||||
super(YCone, self).__init__(surface_id, bc_type, x0, y0, z0, R2, name=name)
|
||||
super(YCone, self).__init__(surface_id, boundary_type, x0, y0, z0,
|
||||
R2, name=name)
|
||||
|
||||
self._type = 'y-cone'
|
||||
|
||||
|
|
@ -585,10 +721,11 @@ class YCone(Cone):
|
|||
|
||||
class ZCone(Cone):
|
||||
|
||||
def __init__(self, surface_id=None, bc_type='transmission',
|
||||
def __init__(self, surface_id=None, boundary_type='transmission',
|
||||
x0=None, y0=None, z0=None, R2=None, name=''):
|
||||
|
||||
# Initialize ZCone class attributes
|
||||
super(ZCone, self).__init__(surface_id, bc_type, x0, y0, z0, R2, name=name)
|
||||
super(ZCone, self).__init__(surface_id, boundary_type, x0, y0, z0,
|
||||
R2, name=name)
|
||||
|
||||
self._type = 'z-cone'
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import copy
|
|||
import os
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
|
||||
from openmc import Nuclide
|
||||
from openmc.clean_xml import *
|
||||
from openmc.checkvalue import *
|
||||
|
|
@ -119,7 +117,10 @@ class Filter(object):
|
|||
@type.setter
|
||||
def type(self, type):
|
||||
|
||||
if not type in FILTER_TYPES.values():
|
||||
if type is None:
|
||||
self._type = type
|
||||
|
||||
elif not type in FILTER_TYPES.values():
|
||||
msg = 'Unable to set Filter type to {0} since it is not one ' \
|
||||
'of the supported types'.format(type)
|
||||
raise ValueError(msg)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ import abc
|
|||
from collections import OrderedDict
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
from openmc.checkvalue import *
|
||||
|
||||
|
|
@ -29,8 +27,8 @@ class Cell(object):
|
|||
def __init__(self, cell_id=None, name=''):
|
||||
|
||||
# Initialize Cell class attributes
|
||||
self._id = None
|
||||
self._name = None
|
||||
self.id = cell_id
|
||||
self.name= name
|
||||
self._fill = None
|
||||
self._type = None
|
||||
self._surfaces = {}
|
||||
|
|
@ -38,39 +36,49 @@ class Cell(object):
|
|||
self._translation = None
|
||||
self._offset = None
|
||||
|
||||
self.set_id(cell_id)
|
||||
self.set_name(name)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
|
||||
def get_offset(self, path, filter_offset):
|
||||
|
||||
# Get the current element and remove it from the list
|
||||
cell_id = path[0]
|
||||
path = path[1:]
|
||||
|
||||
# If the Cell is filled by a Material
|
||||
if self._type == 'normal':
|
||||
offset = 0
|
||||
|
||||
# If the Cell is filled by a Universe
|
||||
elif self._type == 'fill':
|
||||
offset = self._offset[filter_offset-1]
|
||||
offset += self._fill.get_offset(path, filter_offset)
|
||||
|
||||
# If the Cell is filled by a Lattice
|
||||
else:
|
||||
offset = self._fill.get_offset(path, filter_offset)
|
||||
|
||||
return offset
|
||||
|
||||
# Make a recursive call to the Universe filling this Cell
|
||||
offset = self._cells[cell_id].get_offset(path, filter_offset)
|
||||
|
||||
# Return the offset computed at all nested Universe levels
|
||||
return offset
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
|
||||
def set_id(self, cell_id=None):
|
||||
@property
|
||||
def fill(self):
|
||||
return self._fill
|
||||
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return self._fill
|
||||
|
||||
|
||||
@property
|
||||
def surfaces(self):
|
||||
return self._surfaces
|
||||
|
||||
|
||||
@property
|
||||
def rotation(self):
|
||||
return self._rotation
|
||||
|
||||
|
||||
@property
|
||||
def translation(self):
|
||||
return self._translation
|
||||
|
||||
|
||||
@property
|
||||
def offset(self):
|
||||
return self._offset
|
||||
|
||||
|
||||
@id.setter
|
||||
def id(self, cell_id):
|
||||
|
||||
if cell_id is None:
|
||||
global AUTO_CELL_ID
|
||||
|
|
@ -91,7 +99,8 @@ class Cell(object):
|
|||
self._id = cell_id
|
||||
|
||||
|
||||
def set_name(self, name):
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
|
||||
if not isinstance(name, str):
|
||||
msg = 'Unable to set name for Cell ID={0} with a non-string ' \
|
||||
|
|
@ -102,7 +111,8 @@ class Cell(object):
|
|||
self._name = name
|
||||
|
||||
|
||||
def set_fill(self, fill):
|
||||
@fill.setter
|
||||
def fill(self, fill):
|
||||
|
||||
if not isinstance(fill, (openmc.Material, Universe, Lattice)) \
|
||||
and fill != 'void':
|
||||
|
|
@ -122,6 +132,67 @@ class Cell(object):
|
|||
self._type = 'normal'
|
||||
|
||||
|
||||
@rotation.setter
|
||||
def rotation(self, rotation):
|
||||
|
||||
if not isinstance(rotation, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to add rotation {0} to Cell ID={1} since ' \
|
||||
'it is not a Python tuple/list or NumPy ' \
|
||||
'array'.format(rotation, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif len(rotation) != 3:
|
||||
msg = 'Unable to add rotation {0} to Cell ID={1} since ' \
|
||||
'it does not contain 3 values'.format(rotation, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
for axis in rotation:
|
||||
|
||||
if not is_integer(axis) and not is_float(axis):
|
||||
msg = 'Unable to add rotation {0} to Cell ID={1} since ' \
|
||||
'it is not an integer or floating point ' \
|
||||
'value'.format(axis, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._rotation = rotation
|
||||
|
||||
|
||||
@translation.setter
|
||||
def translation(self, translation):
|
||||
|
||||
if not isinstance(translation, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to add translation {0} to Cell ID={1} since ' \
|
||||
'it is not a Python tuple/list or NumPy ' \
|
||||
'array'.format(translation, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif len(translation) != 3:
|
||||
msg = 'Unable to add translation {0} to Cell ID={1} since ' \
|
||||
'it does not contain 3 values'.format(translation, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
for axis in translation:
|
||||
if not is_integer(axis) and not is_float(axis):
|
||||
msg = 'Unable to add translation {0} to Cell ID={1} since ' \
|
||||
'it is not an integer or floating point ' \
|
||||
'value'.format(axis, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._translation = translation
|
||||
|
||||
|
||||
@offset.setter
|
||||
def offset(self, offset):
|
||||
|
||||
if not isinstance(offset, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set offset {0} to Cell ID={1} since ' \
|
||||
'it is not a Python tuple/list or NumPy ' \
|
||||
'array'.format(offset, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._offset = offset
|
||||
|
||||
|
||||
def add_surface(self, surface, halfspace):
|
||||
|
||||
if not isinstance(surface, openmc.Surface):
|
||||
|
|
@ -169,61 +240,32 @@ class Cell(object):
|
|||
self.add_surface(surface)
|
||||
|
||||
|
||||
def set_rotation(self, rotation):
|
||||
def get_offset(self, path, filter_offset):
|
||||
|
||||
if not isinstance(rotation, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to add rotation {0} to Cell ID={1} since ' \
|
||||
'it is not a Python tuple/list or NumPy ' \
|
||||
'array'.format(rotation, self._id)
|
||||
raise ValueError(msg)
|
||||
# Get the current element and remove it from the list
|
||||
cell_id = path[0]
|
||||
path = path[1:]
|
||||
|
||||
elif len(rotation) != 3:
|
||||
msg = 'Unable to add rotation {0} to Cell ID={1} since ' \
|
||||
'it does not contain 3 values'.format(rotation, self._id)
|
||||
raise ValueError(msg)
|
||||
# If the Cell is filled by a Material
|
||||
if self._type == 'normal':
|
||||
offset = 0
|
||||
|
||||
for axis in rotation:
|
||||
# If the Cell is filled by a Universe
|
||||
elif self._type == 'fill':
|
||||
offset = self._offset[filter_offset-1]
|
||||
offset += self._fill.get_offset(path, filter_offset)
|
||||
|
||||
if not is_integer(axis) and not is_float(axis):
|
||||
msg = 'Unable to add rotation {0} to Cell ID={1} since ' \
|
||||
'it is not an integer or floating point ' \
|
||||
'value'.format(axis, self._id)
|
||||
raise ValueError(msg)
|
||||
# If the Cell is filled by a Lattice
|
||||
else:
|
||||
offset = self._fill.get_offset(path, filter_offset)
|
||||
|
||||
self._rotation = rotation
|
||||
return offset
|
||||
|
||||
# Make a recursive call to the Universe filling this Cell
|
||||
offset = self._cells[cell_id].get_offset(path, filter_offset)
|
||||
|
||||
def set_translation(self, translation):
|
||||
|
||||
if not isinstance(translation, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to add translation {0} to Cell ID={1} since ' \
|
||||
'it is not a Python tuple/list or NumPy ' \
|
||||
'array'.format(translation, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif len(translation) != 3:
|
||||
msg = 'Unable to add translation {0} to Cell ID={1} since ' \
|
||||
'it does not contain 3 values'.format(translation, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
for axis in translation:
|
||||
if not is_integer(axis) and not is_float(axis):
|
||||
msg = 'Unable to add translation {0} to Cell ID={1} since ' \
|
||||
'it is not an integer or floating point ' \
|
||||
'value'.format(axis, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._translation = translation
|
||||
|
||||
def set_offset(self, offset):
|
||||
|
||||
if not isinstance(offset, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set offset {0} to Cell ID={1} since ' \
|
||||
'it is not a Python tuple/list or NumPy ' \
|
||||
'array'.format(offset, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._offset = offset
|
||||
# Return the offset computed at all nested Universe levels
|
||||
return offset
|
||||
|
||||
|
||||
def get_all_nuclides(self):
|
||||
|
|
@ -377,8 +419,8 @@ class Universe(object):
|
|||
def __init__(self, universe_id=None, name=''):
|
||||
|
||||
# Initialize Cell class attributes
|
||||
self._id = None
|
||||
self._name = None
|
||||
self.id = universe_id
|
||||
self.name = name
|
||||
|
||||
# Keys - Cell IDs
|
||||
# Values - Cells
|
||||
|
|
@ -389,11 +431,24 @@ class Universe(object):
|
|||
self._cell_offsets = OrderedDict()
|
||||
self._num_regions = 0
|
||||
|
||||
self.set_id(universe_id)
|
||||
self.set_name(name)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
|
||||
def set_id(self, universe_id=None):
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
|
||||
@property
|
||||
def cells(self):
|
||||
return self._cells
|
||||
|
||||
|
||||
@id.setter
|
||||
def id(self, universe_id):
|
||||
|
||||
if universe_id is None:
|
||||
global AUTO_UNIVERSE_ID
|
||||
|
|
@ -415,7 +470,8 @@ class Universe(object):
|
|||
self._id = universe_id
|
||||
|
||||
|
||||
def set_name(self, name):
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
|
||||
if not is_string(name):
|
||||
msg = 'Unable to set name for Universe ID={0} with a non-string ' \
|
||||
|
|
@ -569,17 +625,40 @@ class Lattice(object):
|
|||
def __init__(self, lattice_id=None, name=''):
|
||||
|
||||
# Initialize Lattice class attributes
|
||||
self._id = None
|
||||
self._name = None
|
||||
self.id = lattice_id
|
||||
self.name = name
|
||||
self._pitch = None
|
||||
self._outer = None
|
||||
self._universes = None
|
||||
|
||||
self.set_id(lattice_id)
|
||||
self.set_name(name)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
|
||||
def set_id(self, lattice_id=None):
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
|
||||
@property
|
||||
def pitch(self):
|
||||
return self._pitch
|
||||
|
||||
|
||||
@property
|
||||
def outer(self):
|
||||
return self._outer
|
||||
|
||||
|
||||
@property
|
||||
def universes(self):
|
||||
return self._universes
|
||||
|
||||
|
||||
@id.setter
|
||||
def id(self, lattice_id):
|
||||
|
||||
if lattice_id is None:
|
||||
global AUTO_UNIVERSE_ID
|
||||
|
|
@ -600,7 +679,8 @@ class Lattice(object):
|
|||
self._id = lattice_id
|
||||
|
||||
|
||||
def set_name(self, name):
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
|
||||
if not is_string(name):
|
||||
msg = 'Unable to set name for Lattice ID={0} with a non-string ' \
|
||||
|
|
@ -611,7 +691,8 @@ class Lattice(object):
|
|||
self._name = name
|
||||
|
||||
|
||||
def set_outer(self, outer):
|
||||
@outer.setter
|
||||
def outer(self, outer):
|
||||
|
||||
if not isinstance(outer, Universe):
|
||||
msg = 'Unable to set Lattice ID={0} outer universe to {1} ' \
|
||||
|
|
@ -621,7 +702,8 @@ class Lattice(object):
|
|||
self._outer = outer
|
||||
|
||||
|
||||
def set_universes(self, universes):
|
||||
@universes.setter
|
||||
def universes(self, universes):
|
||||
|
||||
if not isinstance(universes, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set Lattice ID={0} universes to {1} since ' \
|
||||
|
|
@ -706,7 +788,23 @@ class RectLattice(Lattice):
|
|||
self._offsets = None
|
||||
|
||||
|
||||
def set_dimension(self, dimension):
|
||||
@property
|
||||
def dimension(self):
|
||||
return self._dimension
|
||||
|
||||
|
||||
@property
|
||||
def lower_left(self):
|
||||
return self._lower_left
|
||||
|
||||
|
||||
@property
|
||||
def offsets(self):
|
||||
return self._offsets
|
||||
|
||||
|
||||
@dimension.setter
|
||||
def dimension(self, dimension):
|
||||
|
||||
if not isinstance(dimension, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set RectLattice ID={0} dimension to {1} since ' \
|
||||
|
|
@ -737,7 +835,8 @@ class RectLattice(Lattice):
|
|||
self._dimension = dimension
|
||||
|
||||
|
||||
def set_lower_left(self, lower_left):
|
||||
@lower_left.setter
|
||||
def lower_left(self, lower_left):
|
||||
|
||||
if not isinstance(lower_left, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set RectLattice ID={0} lower_left to {1} since ' \
|
||||
|
|
@ -763,7 +862,8 @@ class RectLattice(Lattice):
|
|||
self._lower_left = lower_left
|
||||
|
||||
|
||||
def set_offsets(self, offsets):
|
||||
@offsets.setter
|
||||
def offsets(self, offsets):
|
||||
|
||||
if not isinstance(offsets, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set Lattice ID={0} offsets to {1} since ' \
|
||||
|
|
@ -774,7 +874,8 @@ class RectLattice(Lattice):
|
|||
self._offsets = offsets
|
||||
|
||||
|
||||
def set_pitch(self, pitch):
|
||||
@Lattice.pitch.setter
|
||||
def pitch(self, pitch):
|
||||
|
||||
if not isinstance(pitch, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set Lattice ID={0} pitch to {1} since ' \
|
||||
|
|
@ -991,7 +1092,23 @@ class HexLattice(Lattice):
|
|||
self._center = None
|
||||
|
||||
|
||||
def set_num_rings(self, num_rings):
|
||||
@property
|
||||
def num_rings(self):
|
||||
return self._num_rings
|
||||
|
||||
|
||||
@property
|
||||
def num_axial(self):
|
||||
return self._num_axial
|
||||
|
||||
|
||||
@property
|
||||
def center(self):
|
||||
return self._center
|
||||
|
||||
|
||||
@num_rings.setter
|
||||
def num_rings(self, num_rings):
|
||||
|
||||
if not is_integer(num_rings) and num_rings < 1:
|
||||
msg = 'Unable to set HexLattice ID={0} number of rings to {1} ' \
|
||||
|
|
@ -1001,7 +1118,8 @@ class HexLattice(Lattice):
|
|||
self._num_rings = num_rings
|
||||
|
||||
|
||||
def set_num_axial(self, num_axial):
|
||||
@num_axial.setter
|
||||
def num_axial(self, num_axial):
|
||||
|
||||
if not is_integer(num_axial) and num_axial < 1:
|
||||
msg = 'Unable to set HexLattice ID={0} number of axial to {1} ' \
|
||||
|
|
@ -1011,7 +1129,8 @@ class HexLattice(Lattice):
|
|||
self._num_axial = num_axial
|
||||
|
||||
|
||||
def set_center(self, center):
|
||||
@center.setter
|
||||
def center(self, center):
|
||||
|
||||
if not isinstance(center, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set HexLattice ID={0} dimension to {1} since ' \
|
||||
|
|
@ -1036,7 +1155,8 @@ class HexLattice(Lattice):
|
|||
self._center = center
|
||||
|
||||
|
||||
def set_pitch(self, pitch):
|
||||
@Lattice.pitch.setter
|
||||
def pitch(self, pitch):
|
||||
|
||||
if not isinstance(pitch, (tuple, list, np.ndarray)):
|
||||
msg = 'Unable to set Lattice ID={0} pitch to {1} since ' \
|
||||
|
|
@ -1066,8 +1186,11 @@ class HexLattice(Lattice):
|
|||
self._pitch = pitch
|
||||
|
||||
|
||||
def set_universes(self, universes):
|
||||
super(HexLattice, self).set_universes(universes)
|
||||
@Lattice.universes.setter
|
||||
def universes(self, universes):
|
||||
|
||||
# Call Lattice.universes parent class setter property
|
||||
Lattice.universes.fset(self, universes)
|
||||
|
||||
# NOTE: This routine assumes that the user creates a "ragged" list of
|
||||
# lists, where each sub-list corresponds to one ring of Universes.
|
||||
|
|
@ -1090,7 +1213,7 @@ class HexLattice(Lattice):
|
|||
|
||||
# Set the number of axial positions.
|
||||
if n_dims == 3:
|
||||
self.set_num_axial(self._universes.shape[0])
|
||||
self.num_axial = self._universes.shape[0]
|
||||
|
||||
else:
|
||||
self._num_axial = None
|
||||
|
|
@ -1098,7 +1221,7 @@ class HexLattice(Lattice):
|
|||
# Set the number of rings and make sure this number is consistent for
|
||||
# all axial positions.
|
||||
if n_dims == 3:
|
||||
self.set_num_rings(len(self._universes[0]))
|
||||
self.num_rings = len(self._universes[0])
|
||||
for rings in self._universes:
|
||||
if len(rings) != self._num_rings:
|
||||
msg = 'HexLattice ID={0:d} has an inconsistent number of ' \
|
||||
|
|
@ -1106,7 +1229,7 @@ class HexLattice(Lattice):
|
|||
raise ValueError(msg)
|
||||
|
||||
else:
|
||||
self.set_num_rings(self._universes.shape[0])
|
||||
self.num_rings = self._universes.shape[0]
|
||||
|
||||
# Make sure there are the correct number of elements in each ring.
|
||||
if n_dims == 3:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue