diff --git a/docs/source/_templates/myfunction.rst b/docs/source/_templates/myfunction.rst new file mode 100644 index 000000000..4d7ea38a1 --- /dev/null +++ b/docs/source/_templates/myfunction.rst @@ -0,0 +1,6 @@ +{{ fullname }} +{{ underline }} + +.. currentmodule:: {{ module }} + +.. autofunction:: {{ objname }} diff --git a/docs/source/pythonapi/index.rst b/docs/source/pythonapi/index.rst index 9fd70cb5a..3bedaf2c7 100644 --- a/docs/source/pythonapi/index.rst +++ b/docs/source/pythonapi/index.rst @@ -29,7 +29,7 @@ Classes :template: myclass.rst openmc.XSdata - openmc.MGXSLibraryFile + openmc.MGXSLibrary Functions +++++++++ @@ -50,7 +50,7 @@ Simulation Settings openmc.Source openmc.ResonanceScattering - openmc.SettingsFile + openmc.Settings Material Specification ---------------------- @@ -64,7 +64,7 @@ Material Specification openmc.Element openmc.Macroscopic openmc.Material - openmc.MaterialsFile + openmc.Materials Building geometry ----------------- @@ -96,7 +96,6 @@ Building geometry openmc.RectLattice openmc.HexLattice openmc.Geometry - openmc.GeometryFile Many of the above classes are derived from several abstract classes: @@ -121,7 +120,7 @@ Constructing Tallies openmc.Mesh openmc.Trigger openmc.Tally - openmc.TalliesFile + openmc.Tallies Coarse Mesh Finite Difference Acceleration ------------------------------------------ @@ -132,7 +131,7 @@ Coarse Mesh Finite Difference Acceleration :template: myclass.rst openmc.CMFDMesh - openmc.CMFDFile + openmc.CMFD Plotting -------- @@ -143,7 +142,7 @@ Plotting :template: myclass.rst openmc.Plot - openmc.PlotsFile + openmc.Plots Running OpenMC -------------- @@ -151,9 +150,10 @@ Running OpenMC .. autosummary:: :toctree: generated :nosignatures: - :template: myclass.rst + :template: myfunction.rst - openmc.Executor + openmc.run + openmc.plot_geometry Post-processing --------------- diff --git a/examples/python/basic/build-xml.py b/examples/python/basic/build-xml.py index fbe683661..19737cf91 100644 --- a/examples/python/basic/build-xml.py +++ b/examples/python/basic/build-xml.py @@ -12,7 +12,7 @@ particles = 10000 ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate some Nuclides @@ -31,15 +31,15 @@ fuel = openmc.Material(material_id=40, name='fuel') 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() +# Instantiate a Materials collection, 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 ZCylinder surfaces @@ -74,22 +74,18 @@ cell1.fill = universe1 universe1.add_cells([cell2, cell3]) root.add_cells([cell1, cell4]) -# 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 @@ -103,7 +99,7 @@ settings_file.export_to_xml() ############################################################################### -# Exporting to OpenMC tallies.xml File +# Exporting to OpenMC tallies.xml file ############################################################################### # Instantiate some tally Filters @@ -128,8 +124,8 @@ 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 TalliesFile, register all Tallies, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, 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) diff --git a/examples/python/boxes/build-xml.py b/examples/python/boxes/build-xml.py index ea3e81d17..196a10ca7 100644 --- a/examples/python/boxes/build-xml.py +++ b/examples/python/boxes/build-xml.py @@ -36,15 +36,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([fuel1, fuel2, moderator]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate planar surfaces @@ -97,14 +97,10 @@ outer_box.fill = moderator root = openmc.Universe(universe_id=0, name='root universe') root.add_cells([inner_box, middle_box, outer_box]) -# 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() ############################################################################### @@ -112,7 +108,7 @@ geometry_file.export_to_xml() ############################################################################### # 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 @@ -133,7 +129,7 @@ plot.width = [20, 20] plot.pixels = [200, 200] plot.color = 'cell' -# 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() diff --git a/examples/python/lattice/hexagonal/build-xml.py b/examples/python/lattice/hexagonal/build-xml.py index 7f92e6602..a9d7f6899 100644 --- a/examples/python/lattice/hexagonal/build-xml.py +++ b/examples/python/lattice/hexagonal/build-xml.py @@ -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() diff --git a/examples/python/lattice/nested/build-xml.py b/examples/python/lattice/nested/build-xml.py index f54f06453..eb16c8327 100644 --- a/examples/python/lattice/nested/build-xml.py +++ b/examples/python/lattice/nested/build-xml.py @@ -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() diff --git a/examples/python/lattice/simple/build-xml.py b/examples/python/lattice/simple/build-xml.py index f633fa96f..6e44e4da0 100644 --- a/examples/python/lattice/simple/build-xml.py +++ b/examples/python/lattice/simple/build-xml.py @@ -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() diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index 2e72d82ab..10cd4944d 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -11,7 +11,7 @@ particles = 1000 ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate some Nuclides @@ -100,15 +100,15 @@ 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 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([uo2, helium, zircaloy, borated_water]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate ZCylinder surfaces @@ -149,22 +149,18 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cells with Universe root.add_cells([fuel, gap, clad, water]) -# 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 @@ -181,7 +177,7 @@ settings_file.export_to_xml() ############################################################################### -# Exporting to OpenMC tallies.xml File +# Exporting to OpenMC tallies.xml file ############################################################################### # Instantiate a tally mesh @@ -201,8 +197,8 @@ tally = openmc.Tally(tally_id=1, name='tally 1') tally.filters = [energy_filter, mesh_filter] tally.scores = ['flux', 'fission', 'nu-fission'] -# Instantiate a TalliesFile, register all Tallies, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, register all Tallies, and export to XML +tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) tallies_file.export_to_xml() diff --git a/examples/python/pincell_multigroup/build-xml.py b/examples/python/pincell_multigroup/build-xml.py index 60026c089..233728142 100644 --- a/examples/python/pincell_multigroup/build-xml.py +++ b/examples/python/pincell_multigroup/build-xml.py @@ -12,7 +12,7 @@ inactive = 10 particles = 1000 ############################################################################### -# Exporting to OpenMC mg_cross_sections.xml File +# Exporting to OpenMC mg_cross_sections.xml file ############################################################################### # Instantiate the energy group data @@ -59,13 +59,13 @@ scatter = [[[0.0444777, 0.1134000, 0.0007235, 0.0000037, 0.0000001, 0.0000000, 0 [0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1324400, 2.4807000]]] h2o_xsdata.scatter = np.array(scatter) -mg_cross_sections_file = openmc.MGXSLibraryFile(groups) +mg_cross_sections_file = openmc.MGXSLibrary(groups) mg_cross_sections_file.add_xsdatas([uo2_xsdata,h2o_xsdata]) mg_cross_sections_file.export_to_xml() ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate some Macroscopic Data @@ -81,15 +81,15 @@ water = openmc.Material(material_id=2, name='Water') water.set_density('macro', 1.0) water.add_macroscopic(h2o_data) -# 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 = '300K' materials_file.add_materials([uo2, water]) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate ZCylinder surfaces @@ -122,22 +122,18 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cells with Universe root.add_cells([fuel, moderator]) -# 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.energy_mode = "multi-group" settings_file.cross_sections = "./mg_cross_sections.xml" settings_file.batches = batches @@ -152,7 +148,7 @@ settings_file.source = openmc.source.Source(space=uniform_dist) settings_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.add_score('flux') tally.add_score('fission') tally.add_score('nu-fission') -# Instantiate a TalliesFile, register all Tallies, and export to XML -tallies_file = openmc.TalliesFile() +# Instantiate a Tallies object, register all Tallies, and export to XML +tallies_file = openmc.Tallies() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) tallies_file.export_to_xml() diff --git a/examples/python/reflective/build-xml.py b/examples/python/reflective/build-xml.py index 01a5c7815..7d96e296d 100644 --- a/examples/python/reflective/build-xml.py +++ b/examples/python/reflective/build-xml.py @@ -12,7 +12,7 @@ particles = 10000 ############################################################################### -# Exporting to OpenMC materials.xml File +# Exporting to OpenMC materials.xml file ############################################################################### # Instantiate a Nuclides @@ -23,15 +23,15 @@ fuel = openmc.Material(material_id=1, name='fuel') fuel.set_density('g/cc', 4.5) fuel.add_nuclide(u235, 1.) -# Instantiate a MaterialsFile, register Material, and export to XML -materials_file = openmc.MaterialsFile() +# Instantiate a Materials object, register Material, and export to XML +materials_file = openmc.Materials() materials_file.default_xs = '71c' materials_file.add_material(fuel) materials_file.export_to_xml() ############################################################################### -# Exporting to OpenMC geometry.xml File +# Exporting to OpenMC geometry.xml file ############################################################################### # Instantiate Surfaces @@ -64,22 +64,18 @@ root = openmc.Universe(universe_id=0, name='root universe') # Register Cell with Universe root.add_cell(cell) -# 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 diff --git a/openmc/cmfd.py b/openmc/cmfd.py index b9977a288..d4cce2af5 100644 --- a/openmc/cmfd.py +++ b/openmc/cmfd.py @@ -187,7 +187,7 @@ class CMFDMesh(object): return element -class CMFDFile(object): +class CMFD(object): """Parameters that control the use of coarse-mesh finite difference acceleration in OpenMC. This corresponds directly to the cmfd.xml input file. diff --git a/openmc/executor.py b/openmc/executor.py index 89bcc2e10..9bb3477c5 100644 --- a/openmc/executor.py +++ b/openmc/executor.py @@ -27,7 +27,7 @@ def _run(command, output, cwd): return p.returncode -def plot(output=True, openmc_exec='openmc', cwd='.'): +def plot_geometry(output=True, openmc_exec='openmc', cwd='.'): """Run OpenMC in plotting mode Parameters diff --git a/openmc/geometry.py b/openmc/geometry.py index f5dfe97e4..ed437f6e1 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -23,7 +23,6 @@ class Geometry(object): """ def __init__(self): - # Initialize Geometry class attributes self._root_universe = None self._offsets = {} @@ -42,6 +41,27 @@ class Geometry(object): self._root_universe = root_universe + def export_to_xml(self): + """Create a geometry.xml file that can be used for a simulation. + + """ + + # Clear OpenMC written IDs used to optimize XML generation + openmc.universe.WRITTEN_IDS = {} + + # Create XML representation + geometry_file = ET.Element("geometry") + self.root_universe.create_xml_subelement(geometry_file) + + # Clean the indentation in the file to be user-readable + sort_xml_elements(geometry_file) + clean_xml_indentation(geometry_file) + + # Write the XML Tree to the geometry.xml file + tree = ET.ElementTree(geometry_file) + tree.write("geometry.xml", xml_declaration=True, encoding='utf-8', + method="xml") + def get_cell_instance(self, path): """Return the instance number for the final cell in a geometry path. @@ -436,52 +456,3 @@ class Geometry(object): lattices = list(lattices) lattices.sort(key=lambda x: x.id) return lattices - - -class GeometryFile(object): - """Geometry file used for an OpenMC simulation. Corresponds directly to the - geometry.xml input file. - - Attributes - ---------- - geometry : openmc.Geometry - The geometry to be used - - """ - - def __init__(self): - # Initialize GeometryFile class attributes - self._geometry = None - self._geometry_file = ET.Element("geometry") - - @property - def geometry(self): - return self._geometry - - @geometry.setter - def geometry(self, geometry): - check_type('the geometry', geometry, Geometry) - self._geometry = geometry - - def export_to_xml(self): - """Create a geometry.xml file that can be used for a simulation. - - """ - - # Clear OpenMC written IDs used to optimize XML generation - openmc.universe.WRITTEN_IDS = {} - - # Reset xml element tree - self._geometry_file.clear() - - root_universe = self.geometry.root_universe - root_universe.create_xml_subelement(self._geometry_file) - - # Clean the indentation in the file to be user-readable - sort_xml_elements(self._geometry_file) - clean_xml_indentation(self._geometry_file) - - # Write the XML Tree to the geometry.xml file - tree = ET.ElementTree(self._geometry_file) - tree.write("geometry.xml", xml_declaration=True, - encoding='utf-8', method="xml") diff --git a/openmc/material.py b/openmc/material.py index 16af82439..6b0a0f246 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -642,8 +642,8 @@ class Material(object): return element -class MaterialsFile(object): - """Materials file used for an OpenMC simulation. Corresponds directly to the +class Materials(object): + """Materials used for an OpenMC simulation. Corresponds directly to the materials.xml input file. Attributes @@ -655,7 +655,6 @@ class MaterialsFile(object): """ def __init__(self): - # Initialize MaterialsFile class attributes self._materials = [] self._default_xs = None self._materials_file = ET.Element("materials") @@ -681,7 +680,7 @@ class MaterialsFile(object): if not isinstance(material, Material): msg = 'Unable to add a non-Material "{0}" to the ' \ - 'MaterialsFile'.format(material) + 'Materials instance'.format(material) raise ValueError(msg) self._materials.append(material) @@ -716,7 +715,7 @@ class MaterialsFile(object): if not isinstance(material, Material): msg = 'Unable to remove a non-Material "{0}" from the ' \ - 'MaterialsFile'.format(material) + 'Materials instance'.format(material) raise ValueError(msg) self._materials.remove(material) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 4de4bb48a..ca7bf39cd 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -354,8 +354,8 @@ class Library(object): Parameters ---------- - tallies_file : openmc.TalliesFile - A TalliesFile object to add each MGXS' tallies to generate a + tallies_file : openmc.Tallies + A Tallies object to add each MGXS' tallies to generate a "tallies.xml" input file for OpenMC merge : bool Indicate whether tallies should be merged when possible. Defaults @@ -363,7 +363,7 @@ class Library(object): """ - cv.check_type('tallies_file', tallies_file, openmc.TalliesFile) + cv.check_type('tallies_file', tallies_file, openmc.Tallies) # Add tallies from each MGXS for each domain and mgxs type for domain in self.domains: diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index c0b04fed1..8db3c84ff 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -647,7 +647,7 @@ class XSdata(object): return element -class MGXSLibraryFile(object): +class MGXSLibrary(object): """Multi-Group Cross Sections file used for an OpenMC simulation. Corresponds directly to the MG version of the cross_sections.xml input file. @@ -662,7 +662,6 @@ class MGXSLibraryFile(object): """ def __init__(self, energy_groups): - # Initialize MGXSLibraryFile class attributes self._xsdatas = [] self._energy_groups = energy_groups self._inverse_velocities = None @@ -701,12 +700,12 @@ class MGXSLibraryFile(object): # Check the type if not isinstance(xsdata, XSdata): msg = 'Unable to add a non-XSdata "{0}" to the ' \ - 'MGXSLibraryFile'.format(xsdata) + 'MGXSLibrary instance'.format(xsdata) raise ValueError(msg) # Make sure energy groups match. if xsdata.energy_groups != self._energy_groups: - msg = 'Energy groups of XSdata do not match that of MGXSLibraryFile!' + msg = 'Energy groups of XSdata do not match that of MGXSLibrary!' raise ValueError(msg) self._xsdatas.append(xsdata) @@ -741,7 +740,7 @@ class MGXSLibraryFile(object): if not isinstance(xsdata, XSdata): msg = 'Unable to remove a non-XSdata "{0}" from the ' \ - 'XSdatasFile'.format(xsdata) + 'MGXSLibrary instance'.format(xsdata) raise ValueError(msg) self._xsdatas.remove(xsdata) diff --git a/openmc/plots.py b/openmc/plots.py index 5e7c47743..ae34678bb 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -401,14 +401,13 @@ class Plot(object): return element -class PlotsFile(object): +class Plots(object): """Plots file used for an OpenMC simulation. Corresponds directly to the plots.xml input file. """ def __init__(self): - # Initialize PlotsFile class attributes self._plots = [] self._plots_file = ET.Element("plots") @@ -423,7 +422,7 @@ class PlotsFile(object): """ if not isinstance(plot, Plot): - msg = 'Unable to add a non-Plot "{0}" to the PlotsFile'.format(plot) + msg = 'Unable to add a non-Plot "{0}" to the Plots instance'.format(plot) raise ValueError(msg) self._plots.append(plot) diff --git a/openmc/settings.py b/openmc/settings.py index 0be50bc56..ec38bf54c 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -16,7 +16,7 @@ if sys.version_info[0] >= 3: basestring = str -class SettingsFile(object): +class Settings(object): """Settings file used for an OpenMC simulation. Corresponds directly to the settings.xml input file. diff --git a/openmc/tallies.py b/openmc/tallies.py index 2ee03c675..1af3b12bc 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -3419,14 +3419,13 @@ class Tally(object): return new_tally -class TalliesFile(object): +class Tallies(object): """Tallies file used for an OpenMC simulation. Corresponds directly to the tallies.xml input file. """ def __init__(self): - # Initialize TalliesFile class attributes self._tallies = [] self._meshes = [] self._tallies_file = ET.Element("tallies") @@ -3453,7 +3452,7 @@ class TalliesFile(object): """ if not isinstance(tally, Tally): - msg = 'Unable to add a non-Tally "{0}" to the TalliesFile'.format(tally) + msg = 'Unable to add a non-Tally "{0}" to the Tallies instance'.format(tally) raise ValueError(msg) if merge: @@ -3524,7 +3523,7 @@ class TalliesFile(object): """ if not isinstance(mesh, Mesh): - msg = 'Unable to add a non-Mesh "{0}" to the TalliesFile'.format(mesh) + msg = 'Unable to add a non-Mesh "{0}" to the Tallies instance'.format(mesh) raise ValueError(msg) self._meshes.append(mesh) diff --git a/tests/input_set.py b/tests/input_set.py index daff38ba1..3be6c1db4 100644 --- a/tests/input_set.py +++ b/tests/input_set.py @@ -5,9 +5,9 @@ from openmc.stats import Box class InputSet(object): def __init__(self): - self.settings = openmc.SettingsFile() - self.materials = openmc.MaterialsFile() - self.geometry = openmc.GeometryFile() + self.settings = openmc.Settings() + self.materials = openmc.Materials() + self.geometry = openmc.Geometry() self.tallies = None self.plots = None @@ -550,11 +550,8 @@ class InputSet(object): root.add_cells((c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12)) - # Define the geometry file. - geometry = openmc.Geometry() - geometry.root_universe = root - - self.geometry.geometry = geometry + # Assign root universe to geometry + self.geometry.root_universe = root def build_default_settings(self): self.settings.batches = 10 @@ -630,12 +627,8 @@ class MGInputSet(InputSet): root.add_cells((c1,c2,c3)) - # Define the geometry file. - geometry = openmc.Geometry() - geometry.root_universe = root - - self.geometry.geometry = geometry - + # Assign root universe to geometry + self.geometry.root_universe = root def build_default_settings(self): self.settings.batches = 10 @@ -656,8 +649,3 @@ class MGInputSet(InputSet): plot.color = 'mat' self.plots.add_plot(plot) - - - - - diff --git a/tests/test_asymmetric_lattice/test_asymmetric_lattice.py b/tests/test_asymmetric_lattice/test_asymmetric_lattice.py index fdb21db33..94562e6d9 100644 --- a/tests/test_asymmetric_lattice/test_asymmetric_lattice.py +++ b/tests/test_asymmetric_lattice/test_asymmetric_lattice.py @@ -7,8 +7,6 @@ import hashlib sys.path.insert(0, os.pardir) from testing_harness import PyAPITestHarness import openmc -from openmc.source import Source -from openmc.stats import Box class AsymmetricLatticeTestHarness(PyAPITestHarness): @@ -20,7 +18,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness): self._input_set.build_default_materials_and_geometry() # Extract universes encapsulating fuel and water assemblies - geometry = self._input_set.geometry.geometry + geometry = self._input_set.geometry water = geometry.get_universes_by_name('water assembly (hot)')[0] fuel = geometry.get_universes_by_name('fuel assembly (hot)')[0] @@ -49,7 +47,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness): root_univ.add_cell(root_cell) # Over-ride geometry in the input set with this 3x3 lattice - self._input_set.geometry.geometry.root_universe = root_univ + self._input_set.geometry.root_universe = root_univ # Initialize a "distribcell" filter for the fuel pin cell distrib_filter = openmc.Filter(type='distribcell', bins=[27]) @@ -60,7 +58,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness): tally.add_score('nu-fission') # Initialize the tallies file - tallies_file = openmc.TalliesFile() + tallies_file = openmc.Tallies() tallies_file.add_tally(tally) # Assign the tallies file to the input set @@ -70,7 +68,7 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness): self._input_set.build_default_settings() # Specify summary output and correct source sampling box - source = Source(space=Box([-32, -32, 0], [32, 32, 32])) + source = openmc.Source(space=openmc.stats.Box([-32, -32, 0], [32, 32, 32])) source.space.only_fissionable = True self._input_set.settings.source = source self._input_set.settings.output = {'summary': True} diff --git a/tests/test_distribmat/test_distribmat.py b/tests/test_distribmat/test_distribmat.py index a0608c108..ded2863bd 100644 --- a/tests/test_distribmat/test_distribmat.py +++ b/tests/test_distribmat/test_distribmat.py @@ -28,7 +28,7 @@ class DistribmatTestHarness(PyAPITestHarness): light_fuel.set_density('g/cc', 2.0) light_fuel.add_nuclide('U-235', 1.0) - mats_file = openmc.MaterialsFile() + mats_file = openmc.Materials() mats_file.default_xs = '71c' mats_file.add_materials([moderator, dense_fuel, light_fuel]) mats_file.export_to_xml() @@ -74,16 +74,14 @@ class DistribmatTestHarness(PyAPITestHarness): geometry = openmc.Geometry() geometry.root_universe = root_univ - geo_file = openmc.GeometryFile() - geo_file.geometry = geometry - geo_file.export_to_xml() + geometry.export_to_xml() #################### # Settings #################### - sets_file = openmc.SettingsFile() + sets_file = openmc.Settings() sets_file.batches = 5 sets_file.inactive = 0 sets_file.particles = 1000 @@ -96,7 +94,7 @@ class DistribmatTestHarness(PyAPITestHarness): # Plots #################### - plots_file = openmc.PlotsFile() + plots_file = openmc.Plots() plot = openmc.Plot(plot_id=1) plot.basis = 'xy' diff --git a/tests/test_mg_max_order/test_mg_max_order.py b/tests/test_mg_max_order/test_mg_max_order.py index 2f5ee4e4e..2c4db58df 100644 --- a/tests/test_mg_max_order/test_mg_max_order.py +++ b/tests/test_mg_max_order/test_mg_max_order.py @@ -68,7 +68,7 @@ class MGNuclideInputSet(MGInputSet): geometry = openmc.Geometry() geometry.root_universe = root - self.geometry.geometry = geometry + self.geometry = geometry class MGMaxOrderTestHarness(PyAPITestHarness): def __init__(self, statepoint_name, tallies_present, mg=False): diff --git a/tests/test_mg_nuclide/test_mg_nuclide.py b/tests/test_mg_nuclide/test_mg_nuclide.py index deb784bad..0fa7184a3 100644 --- a/tests/test_mg_nuclide/test_mg_nuclide.py +++ b/tests/test_mg_nuclide/test_mg_nuclide.py @@ -67,7 +67,7 @@ class MGNuclideInputSet(MGInputSet): geometry = openmc.Geometry() geometry.root_universe = root - self.geometry.geometry = geometry + self.geometry = geometry class MGNuclideTestHarness(PyAPITestHarness): def __init__(self, statepoint_name, tallies_present, mg=False): diff --git a/tests/test_mg_tallies/test_mg_tallies.py b/tests/test_mg_tallies/test_mg_tallies.py index c54fb4d32..ffc57f9e9 100644 --- a/tests/test_mg_tallies/test_mg_tallies.py +++ b/tests/test_mg_tallies/test_mg_tallies.py @@ -41,7 +41,7 @@ class MGTalliesTestHarness(PyAPITestHarness): tally2.add_score('scatter') tally2.add_score('nu-scatter') - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self._input_set.tallies.add_mesh(mesh) self._input_set.tallies.add_tally(tally1) self._input_set.tallies.add_tally(tally2) diff --git a/tests/test_mgxs_library_condense/test_mgxs_library_condense.py b/tests/test_mgxs_library_condense/test_mgxs_library_condense.py index 82ce3acab..97bb853b6 100644 --- a/tests/test_mgxs_library_condense/test_mgxs_library_condense.py +++ b/tests/test_mgxs_library_condense/test_mgxs_library_condense.py @@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness): energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.]) # Initialize MGXS Library for a few cross section types - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = False self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() diff --git a/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py b/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py index 1de21a603..681266186 100644 --- a/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py +++ b/tests/test_mgxs_library_distribcell/test_mgxs_library_distribcell.py @@ -24,7 +24,7 @@ class MGXSTestHarness(PyAPITestHarness): # Initialize MGXS Library for a few cross section types # for one material-filled cell in the geometry - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = False self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -35,7 +35,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() diff --git a/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py b/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py index 642073104..30be46b4c 100644 --- a/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py +++ b/tests/test_mgxs_library_hdf5/test_mgxs_library_hdf5.py @@ -24,7 +24,7 @@ class MGXSTestHarness(PyAPITestHarness): energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.]) # Initialize MGXS Library for a few cross section types - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = False self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -33,7 +33,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() @@ -51,7 +51,7 @@ class MGXSTestHarness(PyAPITestHarness): # Load the MGXS library from the statepoint self.mgxs_lib.load_from_statepoint(sp) - + # Export the MGXS Library to an HDF5 file self.mgxs_lib.build_hdf5_store(directory='.') @@ -67,7 +67,7 @@ class MGXSTestHarness(PyAPITestHarness): outstr += str(f[key][...]) + '\n' key = 'material/{0}/{1}/std. dev.'.format(domain.id, mgxs_type) outstr += str(f[key][...]) + '\n' - + # Close the MGXS HDF5 file f.close() diff --git a/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py b/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py index 2afa9039e..381b5b87c 100644 --- a/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py +++ b/tests/test_mgxs_library_no_nuclides/test_mgxs_library_no_nuclides.py @@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness): energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.]) # Initialize MGXS Library for a few cross section types - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = False self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() diff --git a/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py b/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py index 173043cf0..c3e4f5f77 100644 --- a/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py +++ b/tests/test_mgxs_library_nuclides/test_mgxs_library_nuclides.py @@ -23,7 +23,7 @@ class MGXSTestHarness(PyAPITestHarness): energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6, 20.]) # Initialize MGXS Library for a few cross section types - self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry.geometry) + self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry) self.mgxs_lib.by_nuclide = True self.mgxs_lib.mgxs_types = ['transport', 'nu-fission', 'nu-scatter matrix', 'chi'] @@ -32,7 +32,7 @@ class MGXSTestHarness(PyAPITestHarness): self.mgxs_lib.build_library() # Initialize a tallies file - self._input_set.tallies = openmc.TalliesFile() + self._input_set.tallies = openmc.Tallies() self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False) self._input_set.tallies.export_to_xml() diff --git a/tests/test_plot/test_plot.py b/tests/test_plot/test_plot.py index e40cef49c..606a1fd64 100644 --- a/tests/test_plot/test_plot.py +++ b/tests/test_plot/test_plot.py @@ -19,7 +19,7 @@ class PlotTestHarness(TestHarness): self._plot_names = plot_names def _run_openmc(self): - returncode = openmc.plot(openmc_exec=self._opts.exe) + returncode = openmc.plot_geometry(openmc_exec=self._opts.exe) assert returncode == 0, 'OpenMC did not exit successfully.' def _test_output_created(self): diff --git a/tests/test_resonance_scattering/test_resonance_scattering.py b/tests/test_resonance_scattering/test_resonance_scattering.py index d977488bf..5cecfedc4 100644 --- a/tests/test_resonance_scattering/test_resonance_scattering.py +++ b/tests/test_resonance_scattering/test_resonance_scattering.py @@ -17,7 +17,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness): mat.add_nuclide('Pu-239', 0.02) mat.add_nuclide('H-1', 20.0) - mats_file = openmc.MaterialsFile() + mats_file = openmc.Materials() mats_file.default_xs = '71c' mats_file.add_material(mat) mats_file.export_to_xml() @@ -35,9 +35,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness): geometry = openmc.Geometry() geometry.root_universe = root_univ - geo_file = openmc.GeometryFile() - geo_file.geometry = geometry - geo_file.export_to_xml() + geometry.export_to_xml() # Settings nuclide = openmc.Nuclide('U-238', '71c') @@ -67,7 +65,7 @@ class ResonanceScatteringTestHarness(PyAPITestHarness): res_scatt_ares.E_min = 1e-6 res_scatt_ares.E_max = 210e-6 - sets_file = openmc.SettingsFile() + sets_file = openmc.Settings() sets_file.batches = 10 sets_file.inactive = 5 sets_file.particles = 1000 diff --git a/tests/test_source/test_source.py b/tests/test_source/test_source.py index 9d303b06b..1e41bd10e 100644 --- a/tests/test_source/test_source.py +++ b/tests/test_source/test_source.py @@ -9,8 +9,6 @@ import numpy as np sys.path.insert(0, os.pardir) from testing_harness import PyAPITestHarness import openmc -import openmc.stats -from openmc.source import Source class SourceTestHarness(PyAPITestHarness): @@ -18,7 +16,7 @@ class SourceTestHarness(PyAPITestHarness): mat1 = openmc.Material(material_id=1) mat1.set_density('g/cm3', 4.5) mat1.add_nuclide(openmc.Nuclide('U-235', '71c'), 1.0) - materials = openmc.MaterialsFile() + materials = openmc.Materials() materials.add_material(mat1) materials.export_to_xml() @@ -31,9 +29,7 @@ class SourceTestHarness(PyAPITestHarness): root.add_cell(inside_sphere) geometry = openmc.Geometry() geometry.root_universe = root - geometry_xml = openmc.GeometryFile() - geometry_xml.geometry = geometry - geometry_xml.export_to_xml() + geometry.export_to_xml() # Create an array of different sources x_dist = openmc.stats.Uniform(-3., 3.) @@ -56,11 +52,11 @@ class SourceTestHarness(PyAPITestHarness): energy2 = openmc.stats.Watt(0.988, 2.249) energy3 = openmc.stats.Tabular(E, p, interpolation='histogram') - source1 = Source(spatial1, angle1, energy1, strength=0.5) - source2 = Source(spatial2, angle2, energy2, strength=0.3) - source3 = Source(spatial3, angle3, energy3, strength=0.2) + source1 = openmc.Source(spatial1, angle1, energy1, strength=0.5) + source2 = openmc.Source(spatial2, angle2, energy2, strength=0.3) + source3 = openmc.Source(spatial3, angle3, energy3, strength=0.2) - settings = openmc.SettingsFile() + settings = openmc.Settings() settings.batches = 10 settings.inactive = 5 settings.particles = 1000 diff --git a/tests/test_tallies/test_tallies.py b/tests/test_tallies/test_tallies.py index 81e8641de..bb0273589 100644 --- a/tests/test_tallies/test_tallies.py +++ b/tests/test_tallies/test_tallies.py @@ -4,7 +4,7 @@ import os import sys sys.path.insert(0, os.pardir) from testing_harness import PyAPITestHarness -from openmc import Filter, Mesh, Tally, TalliesFile +from openmc import Filter, Mesh, Tally, Tallies from openmc.source import Source from openmc.stats import Box @@ -170,7 +170,7 @@ class TalliesTestHarness(PyAPITestHarness): all_nuclide_tallies[0].estimator = 'tracklength' all_nuclide_tallies[0].estimator = 'collision' - self._input_set.tallies = TalliesFile() + self._input_set.tallies = Tallies() self._input_set.tallies.add_tally(azimuthal_tally1) self._input_set.tallies.add_tally(azimuthal_tally2) self._input_set.tallies.add_tally(azimuthal_tally3) diff --git a/tests/test_tally_aggregation/test_tally_aggregation.py b/tests/test_tally_aggregation/test_tally_aggregation.py index 7d682b698..009a7dc09 100644 --- a/tests/test_tally_aggregation/test_tally_aggregation.py +++ b/tests/test_tally_aggregation/test_tally_aggregation.py @@ -16,7 +16,7 @@ class TallyAggregationTestHarness(PyAPITestHarness): self._input_set.settings.output = {'summary': True} # Initialize the tallies file - tallies_file = openmc.TalliesFile() + tallies_file = openmc.Tallies() # Initialize the nuclides u235 = openmc.Nuclide('U-235') diff --git a/tests/test_tally_arithmetic/test_tally_arithmetic.py b/tests/test_tally_arithmetic/test_tally_arithmetic.py index cf8d012e8..ffea74603 100644 --- a/tests/test_tally_arithmetic/test_tally_arithmetic.py +++ b/tests/test_tally_arithmetic/test_tally_arithmetic.py @@ -16,7 +16,7 @@ class TallyArithmeticTestHarness(PyAPITestHarness): self._input_set.settings.output = {'summary': True} # Initialize the tallies file - tallies_file = openmc.TalliesFile() + tallies_file = openmc.Tallies() # Initialize the nuclides u235 = openmc.Nuclide('U-235') diff --git a/tests/test_tally_slice_merge/test_tally_slice_merge.py b/tests/test_tally_slice_merge/test_tally_slice_merge.py index 79acf182d..933fdf6fa 100644 --- a/tests/test_tally_slice_merge/test_tally_slice_merge.py +++ b/tests/test_tally_slice_merge/test_tally_slice_merge.py @@ -17,7 +17,7 @@ class TallySliceMergeTestHarness(PyAPITestHarness): self._input_set.settings.output = {'summary': True} # Initialize the tallies file - tallies_file = openmc.TalliesFile() + tallies_file = openmc.Tallies() # Define nuclides and scores to add to both tallies self.nuclides = ['U-235', 'U-238'] @@ -69,8 +69,8 @@ class TallySliceMergeTestHarness(PyAPITestHarness): for nuclide in self.nuclides: distribcell_tally.add_nuclide(nuclide) - # Add tallies to a TalliesFile - tallies_file = openmc.TalliesFile() + # Add tallies to a Tallies object + tallies_file = openmc.Tallies() tallies_file.add_tally(tallies[0]) tallies_file.add_tally(distribcell_tally) @@ -95,7 +95,7 @@ class TallySliceMergeTestHarness(PyAPITestHarness): # Slice the tallies by cell filter bins cell_filter_prod = itertools.product(tallies, self.cell_filters) - tallies = map(lambda tf: tf[0].get_slice(filters=[tf[1].type], + tallies = map(lambda tf: tf[0].get_slice(filters=[tf[1].type], filter_bins=[tf[1].get_bin(0)]), cell_filter_prod) # Slice the tallies by energy filter bins @@ -133,11 +133,11 @@ class TallySliceMergeTestHarness(PyAPITestHarness): # Extract the distribcell tally distribcell_tally = sp.get_tally(name='distribcell tally') - # Sum up a few subdomains from the distribcell tally - sum1 = distribcell_tally.summation(filter_type='distribcell', + # Sum up a few subdomains from the distribcell tally + sum1 = distribcell_tally.summation(filter_type='distribcell', filter_bins=[0,100,2000,30000]) # Sum up a few subdomains from the distribcell tally - sum2 = distribcell_tally.summation(filter_type='distribcell', + sum2 = distribcell_tally.summation(filter_type='distribcell', filter_bins=[500,5000,50000]) # Merge the distribcell tally slices