Updated sample input scripts for Python API to conform to new API specs

This commit is contained in:
Will Boyd 2014-11-03 20:05:34 -05:00
parent 2767d3f53f
commit 3bb1f8faf7
8 changed files with 291 additions and 330 deletions

View file

@ -22,20 +22,20 @@ u235 = openmc.Nuclide('U-235')
# Instantiate some Materials and register the appropriate Nuclides
fuel = openmc.Material(material_id=1, name='fuel')
fuel.setDensity('g/cc', 4.5)
fuel.addNuclide(u235, 1.)
fuel.set_density('g/cc', 4.5)
fuel.add_nuclide(u235, 1.)
moderator = openmc.Material(material_id=2, name='moderator')
moderator.setDensity('g/cc', 1.0)
moderator.addNuclide(h1, 2.)
moderator.addNuclide(o16, 1.)
moderator.addSAlphaBeta('HH2O', '71t')
moderator.set_density('g/cc', 1.0)
moderator.add_nuclide(h1, 2.)
moderator.add_nuclide(o16, 1.)
moderator.add_s_alpha_beta('HH2O', '71t')
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
materials_file.setDefaultXS('71c')
materials_file.addMaterials([moderator, fuel])
materials_file.exportToXML()
materials_file.set_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.setBoundaryType('vacuum')
right.setBoundaryType('vacuum')
top.setBoundaryType('vacuum')
bottom.setBoundaryType('vacuum')
left.set_boundary_type('vacuum')
right.set_boundary_type('vacuum')
top.set_boundary_type('vacuum')
bottom.set_boundary_type('vacuum')
# Instantiate Cells
cell1 = openmc.Cell(cell_id=1, name='Cell 1')
@ -67,28 +67,28 @@ cell7 = openmc.Cell(cell_id=301, name='cell 7')
cell8 = openmc.Cell(cell_id=302, name='cell 8')
# Register Surfaces with Cells
cell1.addSurface(left, halfspace=+1)
cell1.addSurface(right, halfspace=-1)
cell1.addSurface(bottom, halfspace=+1)
cell1.addSurface(top, halfspace=-1)
cell2.addSurface(left, halfspace=+1)
cell2.addSurface(right, halfspace=-1)
cell2.addSurface(bottom, halfspace=+1)
cell2.addSurface(top, halfspace=-1)
cell3.addSurface(fuel1, halfspace=-1)
cell4.addSurface(fuel1, halfspace=+1)
cell5.addSurface(fuel2, halfspace=-1)
cell6.addSurface(fuel2, halfspace=+1)
cell7.addSurface(fuel3, halfspace=-1)
cell8.addSurface(fuel3, halfspace=+1)
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(left, halfspace=+1)
cell2.add_surface(right, halfspace=-1)
cell2.add_surface(bottom, halfspace=+1)
cell2.add_surface(top, halfspace=-1)
cell3.add_surface(fuel1, halfspace=-1)
cell4.add_surface(fuel1, halfspace=+1)
cell5.add_surface(fuel2, halfspace=-1)
cell6.add_surface(fuel2, halfspace=+1)
cell7.add_surface(fuel3, halfspace=-1)
cell8.add_surface(fuel3, halfspace=+1)
# Register Materials with Cells
cell3.setFill(fuel)
cell4.setFill(moderator)
cell5.setFill(fuel)
cell6.setFill(moderator)
cell7.setFill(fuel)
cell8.setFill(moderator)
cell3.set_fill(fuel)
cell4.set_fill(moderator)
cell5.set_fill(fuel)
cell6.set_fill(moderator)
cell7.set_fill(fuel)
cell8.set_fill(moderator)
# Instantiate Universe
univ1 = openmc.Universe(universe_id=1)
@ -98,39 +98,39 @@ univ4 = openmc.Universe(universe_id=5)
root = openmc.Universe(universe_id=0, name='root universe')
# Register Cells with Universe
univ1.addCells([cell3, cell4])
univ2.addCells([cell5, cell6])
univ3.addCells([cell7, cell8])
root.addCell(cell1)
univ4.addCell(cell2)
univ1.add_cells([cell3, cell4])
univ2.add_cells([cell5, cell6])
univ3.add_cells([cell7, cell8])
root.add_cell(cell1)
univ4.add_cell(cell2)
# Instantiate nested Lattices
lattice1 = openmc.Lattice(lattice_id=4, name='4x4 assembly')
lattice1.setDimension([2, 2])
lattice1.setLowerLeft([-1., -1.])
lattice1.setWidth([1., 1.])
lattice1.setUniverses([[univ1, univ2],
lattice1.set_dimension([2, 2])
lattice1.set_lower_left([-1., -1.])
lattice1.set_width([1., 1.])
lattice1.set_universes([[univ1, univ2],
[univ2, univ3]])
lattice2 = openmc.Lattice(lattice_id=6, name='4x4 core')
lattice2.setDimension([2, 2])
lattice2.setLowerLeft([-2., -2.])
lattice2.setWidth([2., 2.])
lattice2.setUniverses([[univ4, univ4],
lattice2.set_dimension([2, 2])
lattice2.set_lower_left([-2., -2.])
lattice2.set_width([2., 2.])
lattice2.set_universes([[univ4, univ4],
[univ4, univ4]])
# Fill Cell with the Lattice
cell1.setFill(lattice2)
cell2.setFill(lattice1)
cell1.set_fill(lattice2)
cell2.set_fill(lattice1)
# Instantiate a Geometry and register the root Universe
geometry = openmc.Geometry()
geometry.setRootUniverse(root)
geometry.set_root_universe(root)
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.setGeometry(geometry)
geometry_file.exportToXML()
geometry_file.set_geometry(geometry)
geometry_file.export_to_xml()
###############################################################################
@ -139,11 +139,11 @@ geometry_file.exportToXML()
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
settings_file.setBatches(batches)
settings_file.setInactive(inactive)
settings_file.setParticles(particles)
settings_file.setSourceSpace('box', [-1, -1, -1, 1, 1, 1])
settings_file.exportToXML()
settings_file.set_batches(batches)
settings_file.set_inactive(inactive)
settings_file.set_particles(particles)
settings_file.set_source_space('box', [-1, -1, -1, 1, 1, 1])
settings_file.export_to_xml()
###############################################################################
@ -151,15 +151,15 @@ settings_file.exportToXML()
###############################################################################
plot = openmc.Plot(plot_id=1)
plot.setOrigin([0, 0, 0])
plot.setWidth([4, 4])
plot.setPixels([400, 400])
plot.setColor('mat')
plot.set_origin([0, 0, 0])
plot.set_width([4, 4])
plot.set_pixels([400, 400])
plot.set_color('mat')
# Instantiate a PlotsFile, add Plot, and export to XML
plot_file = openmc.PlotsFile()
plot_file.addPlot(plot)
plot_file.exportToXML()
plot_file.add_plot(plot)
plot_file.export_to_xml()
###############################################################################
@ -168,22 +168,22 @@ plot_file.exportToXML()
# Instantiate a tally mesh
mesh = openmc.Mesh(mesh_id=1)
mesh.setType('rectangular')
mesh.setDimension([4, 4])
mesh.setLowerLeft([-2, -2])
mesh.setWidth([1, 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.setMesh(mesh)
mesh_filter.set_mesh(mesh)
# Instantiate the Tally
tally = openmc.Tally(tally_id=1)
tally.addFilter(mesh_filter)
tally.addScore('total')
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.addMesh(mesh)
tallies_file.addTally(tally)
tallies_file.exportToXML()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file.export_to_xml()