Make Materials, Plots, and Tallies list-like

This commit is contained in:
Paul Romano 2016-04-29 16:14:02 -05:00
parent ae083cf5d4
commit d9b097dbaf
31 changed files with 373 additions and 297 deletions

View file

@ -31,10 +31,9 @@ fuel = openmc.Material(material_id=40, name='fuel')
fuel.set_density('g/cc', 4.5)
fuel.add_nuclide(u235, 1.)
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([moderator, fuel])
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel])
materials_file.export_to_xml()
@ -124,9 +123,6 @@ third_tally = openmc.Tally(tally_id=3, name='third tally')
third_tally.filters = [cell_filter, energy_filter, energyout_filter]
third_tally.scores = ['scatter', 'nu-scatter', 'nu-fission']
# Instantiate a Tallies collection, register all Tallies, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_tally(first_tally)
tallies_file.add_tally(second_tally)
tallies_file.add_tally(third_tally)
# Instantiate a Tallies collection and export to XML
tallies_file = openmc.Tallies((first_tally, second_tally, third_tally))
tallies_file.export_to_xml()

View file

@ -36,10 +36,9 @@ moderator.add_nuclide(h1, 2.)
moderator.add_nuclide(o16, 1.)
moderator.add_s_alpha_beta('HH2O', '71t')
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([fuel1, fuel2, moderator])
materials_file.default_xs = '71c'
materials_file.add_materials([fuel1, fuel2, moderator])
materials_file.export_to_xml()
@ -129,7 +128,6 @@ plot.width = [20, 20]
plot.pixels = [200, 200]
plot.color = 'cell'
# Instantiate a Plots collection, add Plot, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot)
# Instantiate a Plots collection and export to XML
plot_file = openmc.Plots([plot])
plot_file.export_to_xml()

View file

@ -35,10 +35,9 @@ iron = openmc.Material(material_id=3, name='iron')
iron.set_density('g/cc', 7.9)
iron.add_nuclide(fe56, 1.)
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([moderator, fuel, iron])
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel, iron])
materials_file.export_to_xml()
@ -152,9 +151,7 @@ plot_yz.pixels = [400, 400]
plot_yz.color = 'mat'
# Instantiate a Plots collection, add plots, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot_xy)
plot_file.add_plot(plot_yz)
plot_file = openmc.Plots((plot_xy, plot_yz))
plot_file.export_to_xml()
@ -167,7 +164,6 @@ tally = openmc.Tally(tally_id=1)
tally.filters = [openmc.Filter(type='distribcell', bins=[cell2.id])]
tally.scores = ['total']
# Instantiate a Tallies collection, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_tally(tally)
# Instantiate a Tallies collection and export to XML
tallies_file = openmc.Tallies([tally])
tallies_file.export_to_xml()

View file

@ -30,10 +30,9 @@ moderator.add_nuclide(h1, 2.)
moderator.add_nuclide(o16, 1.)
moderator.add_s_alpha_beta('HH2O', '71t')
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials((moderator, fuel))
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel])
materials_file.export_to_xml()
@ -150,9 +149,8 @@ plot.width = [4, 4]
plot.pixels = [400, 400]
plot.color = 'mat'
# Instantiate a Plots object, add Plot, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot)
# Instantiate a Plots object and export to XML
plot_file = openmc.Plots([plot])
plot_file.export_to_xml()
@ -177,7 +175,5 @@ tally.filters = [mesh_filter]
tally.scores = ['total']
# Instantiate a Tallies collection, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file = openmc.Tallies([tally])
tallies_file.export_to_xml()

View file

@ -30,10 +30,9 @@ moderator.add_nuclide(h1, 2.)
moderator.add_nuclide(o16, 1.)
moderator.add_s_alpha_beta('HH2O', '71t')
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([moderator, fuel])
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel])
materials_file.export_to_xml()
@ -142,9 +141,8 @@ plot.width = [4, 4]
plot.pixels = [400, 400]
plot.color = 'mat'
# Instantiate a Plots collection, add Plot, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot)
# Instantiate a Plots collection and export to XML
plot_file = openmc.Plots([plot])
plot_file.export_to_xml()
@ -173,8 +171,6 @@ tally.filters = [mesh_filter]
tally.scores = ['total']
tally.triggers = [trigger]
# Instantiate a Tallies collection, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
# Instantiate a Tallies collection and export to XML
tallies_file = openmc.Tallies([tally])
tallies_file.export_to_xml()

View file

@ -100,10 +100,9 @@ borated_water.add_nuclide(o16, 2.4672e-2)
borated_water.add_nuclide(o17, 6.0099e-5)
borated_water.add_s_alpha_beta('HH2O', '71t')
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([uo2, helium, zircaloy, borated_water])
materials_file.default_xs = '71c'
materials_file.add_materials([uo2, helium, zircaloy, borated_water])
materials_file.export_to_xml()
@ -197,8 +196,6 @@ tally = openmc.Tally(tally_id=1, name='tally 1')
tally.filters = [energy_filter, mesh_filter]
tally.scores = ['flux', 'fission', 'nu-fission']
# Instantiate a Tallies collection, register all Tallies, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
# Instantiate a Tallies collection and export to XML
tallies_file = openmc.Tallies([tally])
tallies_file.export_to_xml()

View file

@ -81,10 +81,9 @@ water = openmc.Material(material_id=2, name='Water')
water.set_density('macro', 1.0)
water.add_macroscopic(h2o_data)
# Instantiate a Materials collection, register all Materials, and export to XML
materials_file = openmc.Materials()
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([uo2, water])
materials_file.default_xs = '300K'
materials_file.add_materials([uo2, water])
materials_file.export_to_xml()
@ -167,14 +166,9 @@ mesh_filter.mesh = mesh
# Instantiate the Tally
tally = openmc.Tally(tally_id=1, name='tally 1')
tally.add_filter(energy_filter)
tally.add_filter(mesh_filter)
tally.add_score('flux')
tally.add_score('fission')
tally.add_score('nu-fission')
tally.filters = [energy_filter, mesh_filter]
tally.scores = ['flux', 'fission', 'nu-fission']
# Instantiate a Tallies collection, register all Tallies, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file = openmc.Tallies([tally])
tallies_file.export_to_xml()

View file

@ -23,10 +23,9 @@ fuel = openmc.Material(material_id=1, name='fuel')
fuel.set_density('g/cc', 4.5)
fuel.add_nuclide(u235, 1.)
# Instantiate a Materials collection, register Material, and export to XML
materials_file = openmc.Materials()
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([fuel])
materials_file.default_xs = '71c'
materials_file.add_material(fuel)
materials_file.export_to_xml()