Rename main Python API classes to get rid of File.

This commit is contained in:
Paul Romano 2016-04-25 10:37:06 -05:00
parent cccca4062a
commit 50a80693b5
37 changed files with 203 additions and 284 deletions

View file

@ -35,15 +35,15 @@ iron = openmc.Material(material_id=3, name='iron')
iron.set_density('g/cc', 7.9)
iron.add_nuclide(fe56, 1.)
# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
# Instantiate a Materials object, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel, iron])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate Surfaces
@ -105,22 +105,18 @@ lattice.outer = univ2
# Fill Cell with the Lattice
cell1.fill = lattice
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry and register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
settings_file = openmc.Settings()
settings_file.batches = batches
settings_file.inactive = inactive
settings_file.particles = particles
@ -137,7 +133,7 @@ settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC plots.xml File
# Exporting to OpenMC plots.xml file
###############################################################################
plot_xy = openmc.Plot(plot_id=1)
@ -155,8 +151,8 @@ 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()
# Instantiate a Plots object, add plots, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot_xy)
plot_file.add_plot(plot_yz)
plot_file.export_to_xml()
@ -171,7 +167,7 @@ tally = openmc.Tally(tally_id=1)
tally.filters = [openmc.Filter(type='distribcell', bins=[cell2.id])]
tally.scores = ['total']
# Instantiate a TalliesFile, register Tally/Mesh, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies object, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_tally(tally)
tallies_file.export_to_xml()

View file

@ -11,7 +11,7 @@ particles = 10000
###############################################################################
# Exporting to OpenMC materials.xml File
# Exporting to OpenMC materials.xml file
###############################################################################
# Instantiate some Nuclides
@ -30,15 +30,15 @@ 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()
# Instantiate a Materials object, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate Surfaces
@ -116,22 +116,18 @@ lattice2.universes = [[univ4, univ4],
cell1.fill = lattice2
cell2.fill = lattice1
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry and register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# Instantiate a Settings object, set all runtime parameters, and export to XML
settings_file = openmc.Settings()
settings_file.batches = batches
settings_file.inactive = inactive
settings_file.particles = particles
@ -145,7 +141,7 @@ settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC plots.xml File
# Exporting to OpenMC plots.xml file
###############################################################################
plot = openmc.Plot(plot_id=1)
@ -154,14 +150,14 @@ plot.width = [4, 4]
plot.pixels = [400, 400]
plot.color = 'mat'
# Instantiate a PlotsFile, add Plot, and export to XML
plot_file = openmc.PlotsFile()
# Instantiate a Plots object, add Plot, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot)
plot_file.export_to_xml()
###############################################################################
# Exporting to OpenMC tallies.xml File
# Exporting to OpenMC tallies.xml file
###############################################################################
# Instantiate a tally mesh
@ -180,8 +176,8 @@ tally = openmc.Tally(tally_id=1)
tally.filters = [mesh_filter]
tally.scores = ['total']
# Instantiate a TalliesFile, register Tally/Mesh, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies object, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file.export_to_xml()

View file

@ -11,7 +11,7 @@ particles = 10000
###############################################################################
# Exporting to OpenMC materials.xml File
# Exporting to OpenMC materials.xml file
###############################################################################
# Instantiate some Nuclides
@ -30,15 +30,15 @@ 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()
# Instantiate a Materials object, register all Materials, and export to XML
materials_file = openmc.Materials()
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel])
materials_file.export_to_xml()
###############################################################################
# Exporting to OpenMC geometry.xml File
# Exporting to OpenMC geometry.xml file
###############################################################################
# Instantiate Surfaces
@ -106,22 +106,18 @@ lattice.universes = [[univ1, univ2, univ1, univ2],
# Fill Cell with the Lattice
cell1.fill = lattice
# Instantiate a Geometry and register the root Universe
# Instantiate a Geometry and register the root Universe, and export to XML
geometry = openmc.Geometry()
geometry.root_universe = root
# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = geometry
geometry_file.export_to_xml()
geometry.export_to_xml()
###############################################################################
# Exporting to OpenMC settings.xml File
# Exporting to OpenMC settings.xml file
###############################################################################
# Instantiate a SettingsFile, set all runtime parameters, and export to XML
settings_file = openmc.SettingsFile()
# Instantiate a Settings object, set all runtime parameters, and export to XML
settings_file = openmc.Settings()
settings_file.batches = batches
settings_file.inactive = inactive
settings_file.particles = particles
@ -137,7 +133,7 @@ settings_file.export_to_xml()
###############################################################################
# Exporting to OpenMC plots.xml File
# Exporting to OpenMC plots.xml file
###############################################################################
plot = openmc.Plot(plot_id=1)
@ -146,14 +142,14 @@ plot.width = [4, 4]
plot.pixels = [400, 400]
plot.color = 'mat'
# Instantiate a PlotsFile, add Plot, and export to XML
plot_file = openmc.PlotsFile()
# Instantiate a Plots object, add Plot, and export to XML
plot_file = openmc.Plots()
plot_file.add_plot(plot)
plot_file.export_to_xml()
###############################################################################
# Exporting to OpenMC tallies.xml File
# Exporting to OpenMC tallies.xml file
###############################################################################
# Instantiate a tally mesh
@ -177,8 +173,8 @@ tally.filters = [mesh_filter]
tally.scores = ['total']
tally.triggers = [trigger]
# Instantiate a TalliesFile, register Tally/Mesh, and export to XML
tallies_file = openmc.TalliesFile()
# Instantiate a Tallies object, register Tally/Mesh, and export to XML
tallies_file = openmc.Tallies()
tallies_file.add_mesh(mesh)
tallies_file.add_tally(tally)
tallies_file.export_to_xml()