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
moderator = openmc.Material(material_id=41, 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')
fuel = openmc.Material(material_id=40, name='fuel')
fuel.setDensity('g/cc', 4.5)
fuel.addNuclide(u235, 1.)
fuel.set_density('g/cc', 4.5)
fuel.add_nuclide(u235, 1.)
# 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()
###############################################################################
@ -46,7 +46,7 @@ materials_file.exportToXML()
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.setBoundaryType('vacuum')
surf3.set_boundary_type('vacuum')
# Instantiate Cells
cell1 = openmc.Cell(cell_id=1, name='cell 1')
@ -55,34 +55,34 @@ cell3 = openmc.Cell(cell_id=101, name='cell 3')
cell4 = openmc.Cell(cell_id=2, name='cell 4')
# Register Surfaces with Cells
cell1.addSurface(surface=surf2, halfspace=-1)
cell2.addSurface(surface=surf1, halfspace=-1)
cell3.addSurface(surface=surf1, halfspace=+1)
cell4.addSurface(surface=surf2, halfspace=+1)
cell4.addSurface(surface=surf3, halfspace=-1)
cell1.add_surface(surface=surf2, halfspace=-1)
cell2.add_surface(surface=surf1, halfspace=-1)
cell3.add_surface(surface=surf1, halfspace=+1)
cell4.add_surface(surface=surf2, halfspace=+1)
cell4.add_surface(surface=surf3, halfspace=-1)
# Register Materials with Cells
cell2.setFill(fuel)
cell3.setFill(moderator)
cell4.setFill(moderator)
cell2.set_fill(fuel)
cell3.set_fill(moderator)
cell4.set_fill(moderator)
# Instantiate Universes
universe1 = openmc.Universe(universe_id=37)
root = openmc.Universe(universe_id=0, name='root universe')
cell1.setFill(universe1)
cell1.set_fill(universe1)
# Register Cells with Universes
universe1.addCells([cell2, cell3])
root.addCells([cell1, cell4])
universe1.add_cells([cell2, cell3])
root.add_cells([cell1, cell4])
# 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()
###############################################################################
@ -91,11 +91,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', [-4, -4, -4, 4, 4, 4])
settings_file.exportToXML()
settings_file.set_batches(batches)
settings_file.set_inactive(inactive)
settings_file.set_particles(particles)
settings_file.set_source_space('box', [-4, -4, -4, 4, 4, 4])
settings_file.export_to_xml()
###############################################################################
@ -109,33 +109,33 @@ energyout_filter = openmc.Filter(type='energyout', bins=[0., 20.])
# Instantiate the first Tally
first_tally = openmc.Tally(tally_id=1, label='first tally')
first_tally.addFilter(cell_filter)
first_tally.add_filter(cell_filter)
scores = ['total', 'scatter', 'nu-scatter', \
'absorption', 'fission', 'nu-fission']
for score in scores:
first_tally.addScore(score)
first_tally.add_score(score)
# Instantiate the second Tally
second_tally = openmc.Tally(tally_id=2, label='second tally')
second_tally.addFilter(cell_filter)
second_tally.addFilter(energy_filter)
second_tally.add_filter(cell_filter)
second_tally.add_filter(energy_filter)
scores = ['total', 'scatter', 'nu-scatter', \
'absorption', 'fission', 'nu-fission']
for score in scores:
second_tally.addScore(score)
second_tally.add_score(score)
# Instantiate the third Tally
third_tally = openmc.Tally(tally_id=3, label='third tally')
third_tally.addFilter(cell_filter)
third_tally.addFilter(energy_filter)
third_tally.addFilter(energyout_filter)
third_tally.add_filter(cell_filter)
third_tally.add_filter(energy_filter)
third_tally.add_filter(energyout_filter)
scores = ['scatter', 'nu-scatter', 'nu-fission']
for score in scores:
third_tally.addScore(score)
third_tally.add_score(score)
# Instantiate a TalliesFile, register all Tallies, and export to XML
tallies_file = openmc.TalliesFile()
tallies_file.addTally(first_tally)
tallies_file.addTally(second_tally)
tallies_file.addTally(third_tally)
tallies_file.exportToXML()
tallies_file.add_tally(first_tally)
tallies_file.add_tally(second_tally)
tallies_file.add_tally(third_tally)
tallies_file.export_to_xml()