From 68f7de13155231cf88213b19d9dd7e0aba8571ae Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 25 Apr 2016 10:44:20 -0500 Subject: [PATCH] Update Jupyter notebooks --- .../pythonapi/examples/mgxs-part-i.ipynb | 27 ++++++-------- .../pythonapi/examples/mgxs-part-ii.ipynb | 29 ++++++--------- .../pythonapi/examples/mgxs-part-iii.ipynb | 37 ++++++++----------- .../examples/pandas-dataframes.ipynb | 37 ++++++++----------- .../pythonapi/examples/post-processing.ipynb | 27 ++++++-------- .../pythonapi/examples/tally-arithmetic.ipynb | 29 ++++++--------- 6 files changed, 78 insertions(+), 108 deletions(-) diff --git a/docs/source/pythonapi/examples/mgxs-part-i.ipynb b/docs/source/pythonapi/examples/mgxs-part-i.ipynb index de66cbb83..c7a5b2ffa 100644 --- a/docs/source/pythonapi/examples/mgxs-part-i.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-i.ipynb @@ -201,7 +201,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "With our material, we can now create a `MaterialsFile` object that can be exported to an actual XML file." + "With our material, we can now create a `Materials` object that can be exported to an actual XML file." ] }, { @@ -212,8 +212,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, register all Materials, and export to XML\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, register all Materials, and export to XML\n", + "materials_file = openmc.Materials()\n", "materials_file.default_xs = '71c'\n", "materials_file.add_material(inf_medium)\n", "materials_file.export_to_xml()" @@ -290,7 +290,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML." + "We now must create a geometry that is assigned a root universe and export it to XML." ] }, { @@ -305,12 +305,8 @@ "openmc_geometry = openmc.Geometry()\n", "openmc_geometry.root_universe = root_universe\n", "\n", - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = openmc_geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "openmc_geometry.export_to_xml()" ] }, { @@ -333,8 +329,8 @@ "inactive = 10\n", "particles = 2500\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -455,7 +451,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The `Absorption` object includes tracklength tallies for the 'absorption' and 'flux' scores in the 2-group structure in cell 1. Now that each `MGXS` object contains the tallies that it needs, we must add these tallies to a `TalliesFile` object to generate the \"tallies.xml\" input file for OpenMC." + "The `Absorption` object includes tracklength tallies for the 'absorption' and 'flux' scores in the 2-group structure in cell 1. Now that each `MGXS` object contains the tallies that it needs, we must add these tallies to a `Tallies` object to generate the \"tallies.xml\" input file for OpenMC." ] }, { @@ -466,8 +462,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()\n", + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()\n", "\n", "# Add total tallies to the tallies file\n", "for tally in total.tallies.values():\n", @@ -644,8 +640,7 @@ ], "source": [ "# Run OpenMC\n", - "executor = openmc.Executor()\n", - "executor.run_simulation()" + "openmc.run()" ] }, { diff --git a/docs/source/pythonapi/examples/mgxs-part-ii.ipynb b/docs/source/pythonapi/examples/mgxs-part-ii.ipynb index 6ed5cd38d..49e301f5b 100644 --- a/docs/source/pythonapi/examples/mgxs-part-ii.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-ii.ipynb @@ -122,7 +122,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "With our materials, we can now create a `MaterialsFile` object that can be exported to an actual XML file." + "With our materials, we can now create a `Materials` object that can be exported to an actual XML file." ] }, { @@ -133,8 +133,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -238,7 +238,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML." + "We now must create a geometry that is assigned a root universe and export it to XML." ] }, { @@ -253,12 +253,8 @@ "openmc_geometry = openmc.Geometry()\n", "openmc_geometry.root_universe = root_universe\n", "\n", - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = openmc_geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "openmc_geometry.export_to_xml()" ] }, { @@ -281,8 +277,8 @@ "inactive = 10\n", "particles = 10000\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -396,8 +392,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()\n", + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()\n", "\n", "# Iterate over all cells and cross section types\n", "for cell in openmc_cells:\n", @@ -607,8 +603,7 @@ ], "source": [ "# Run OpenMC\n", - "executor = openmc.Executor()\n", - "executor.run_simulation(output=True)" + "openmc.run(output=True)" ] }, { @@ -1360,7 +1355,7 @@ ], "source": [ "# Generate tracks for OpenMOC\n", - "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, spacing=0.1)\n", + "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, azim_spacing=0.1)\n", "track_generator.generateTracks()\n", "\n", "# Run OpenMOC\n", @@ -1699,7 +1694,7 @@ ], "source": [ "# Generate tracks for OpenMOC\n", - "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, spacing=0.1)\n", + "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=128, azim_spacing=0.1)\n", "track_generator.generateTracks()\n", "\n", "# Run OpenMOC\n", diff --git a/docs/source/pythonapi/examples/mgxs-part-iii.ipynb b/docs/source/pythonapi/examples/mgxs-part-iii.ipynb index 5fccc4f03..3a3533ffe 100644 --- a/docs/source/pythonapi/examples/mgxs-part-iii.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-iii.ipynb @@ -122,7 +122,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "With our three materials, we can now create a `MaterialsFile` object that can be exported to an actual XML file." + "With our three materials, we can now create a `Materials` object that can be exported to an actual XML file." ] }, { @@ -133,8 +133,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -331,7 +331,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML." + "We now must create a geometry that is assigned a root universe and export it to XML." ] }, { @@ -355,12 +355,8 @@ }, "outputs": [], "source": [ - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "geometry.export_to_xml()" ] }, { @@ -383,8 +379,8 @@ "inactive = 10\n", "particles = 2500\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -403,7 +399,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let us also create a `PlotsFile` that we can use to verify that our fuel assembly geometry was created successfully." + "Let us also create a `Plots` file that we can use to verify that our fuel assembly geometry was created successfully." ] }, { @@ -422,8 +418,8 @@ "plot.width = [-10.71*2, -10.71*2]\n", "plot.color = 'mat'\n", "\n", - "# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n", - "plot_file = openmc.PlotsFile()\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots()\n", "plot_file.add_plot(plot)\n", "plot_file.export_to_xml()" ] @@ -455,8 +451,7 @@ ], "source": [ "# Run openmc in plotting mode\n", - "executor = openmc.Executor()\n", - "executor.plot_geometry(output=False)" + "openmc.plot_geometry(output=False)" ] }, { @@ -643,7 +638,7 @@ "source": [ "The tallies can now be export to a \"tallies.xml\" input file for OpenMC. \n", "\n", - "**NOTE**: At this point the `Library` has constructed nearly 100 distinct `Tally` objects. The overhead to tally in OpenMC scales as $O(N)$ for $N$ tallies, which can become a bottleneck for large tally datasets. To compensate for this, the Python API's `Tally`, `Filter` and `TalliesFile` classes allow for the smart *merging* of tallies when possible. The `Library` class supports this runtime optimization with the use of the optional `merge` paramter (`False` by default) for the `Library.add_to_tallies_file(...)` method, as shown below." + "**NOTE**: At this point the `Library` has constructed nearly 100 distinct `Tally` objects. The overhead to tally in OpenMC scales as $O(N)$ for $N$ tallies, which can become a bottleneck for large tally datasets. To compensate for this, the Python API's `Tally`, `Filter` and `Tallies` classes allow for the smart *merging* of tallies when possible. The `Library` class supports this runtime optimization with the use of the optional `merge` paramter (`False` by default) for the `Library.add_to_tallies_file(...)` method, as shown below." ] }, { @@ -655,7 +650,7 @@ "outputs": [], "source": [ "# Create a \"tallies.xml\" file for the MGXS Library\n", - "tallies_file = openmc.TalliesFile()\n", + "tallies_file = openmc.Tallies()\n", "mgxs_lib.add_to_tallies_file(tallies_file, merge=True)" ] }, @@ -690,7 +685,7 @@ "tally.filters = [mesh_filter]\n", "tally.scores = ['fission', 'nu-fission']\n", "\n", - "# Add mesh and Tally to TalliesFile\n", + "# Add mesh and tally to Tallies\n", "tallies_file.add_mesh(mesh)\n", "tallies_file.add_tally(tally)" ] @@ -860,7 +855,7 @@ ], "source": [ "# Run OpenMC\n", - "executor.run_simulation()" + "openmc.run()" ] }, { @@ -1449,7 +1444,7 @@ ], "source": [ "# Generate tracks for OpenMOC\n", - "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=32, spacing=0.1)\n", + "track_generator = openmoc.TrackGenerator(openmoc_geometry, num_azim=32, azim_spacing=0.1)\n", "track_generator.generateTracks()\n", "\n", "# Run OpenMOC\n", diff --git a/docs/source/pythonapi/examples/pandas-dataframes.ipynb b/docs/source/pythonapi/examples/pandas-dataframes.ipynb index 388e4aaa6..b0f2f6b13 100644 --- a/docs/source/pythonapi/examples/pandas-dataframes.ipynb +++ b/docs/source/pythonapi/examples/pandas-dataframes.ipynb @@ -108,8 +108,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -239,7 +239,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We now must create a geometry that is assigned a root universe, put the geometry into a `GeometryFile` object, and export it to XML." + "We now must create a geometry that is assigned a root universe and export it to XML." ] }, { @@ -263,12 +263,8 @@ }, "outputs": [], "source": [ - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "geometry.export_to_xml()" ] }, { @@ -292,8 +288,8 @@ "inactive = 5\n", "particles = 2500\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = min_batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -333,8 +329,8 @@ "plot.pixels = [250, 250]\n", "plot.color = 'mat'\n", "\n", - "# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n", - "plot_file = openmc.PlotsFile()\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots()\n", "plot_file.add_plot(plot)\n", "plot_file.export_to_xml()" ] @@ -366,8 +362,7 @@ ], "source": [ "# Run openmc in plotting mode\n", - "executor = openmc.Executor()\n", - "executor.plot_geometry(output=False)" + "openmc.plot_geometry(output=False)" ] }, { @@ -412,8 +407,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()\n", + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()\n", "tallies_file._tallies = []" ] }, @@ -453,7 +448,7 @@ "tally.filters = [mesh_filter, energy_filter]\n", "tally.scores = ['fission', 'nu-fission']\n", "\n", - "# Add mesh and Tally to TalliesFile\n", + "# Add mesh and Tally to Tallies\n", "tallies_file.add_mesh(mesh)\n", "tallies_file.add_tally(tally)" ] @@ -482,7 +477,7 @@ "tally.scores = ['scatter-y2']\n", "tally.nuclides = [u235, u238]\n", "\n", - "# Add mesh and tally to TalliesFile\n", + "# Add mesh and tally to Tallies\n", "tallies_file.add_tally(tally)" ] }, @@ -514,7 +509,7 @@ "tally.scores = ['absorption', 'scatter']\n", "tally.triggers = [trigger]\n", "\n", - "# Add mesh and tally to TalliesFile\n", + "# Add mesh and tally to Tallies\n", "tallies_file.add_tally(tally)" ] }, @@ -669,8 +664,8 @@ "# Remove old HDF5 (summary, statepoint) files\n", "!rm statepoint.*\n", "\n", - "# Run OpenMC with MPI!\n", - "executor.run_simulation()" + "# Run OpenMC!\n", + "openmc.run()" ] }, { diff --git a/docs/source/pythonapi/examples/post-processing.ipynb b/docs/source/pythonapi/examples/post-processing.ipynb index 0dc18d5a2..ce9209b03 100644 --- a/docs/source/pythonapi/examples/post-processing.ipynb +++ b/docs/source/pythonapi/examples/post-processing.ipynb @@ -104,8 +104,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -236,12 +236,8 @@ }, "outputs": [], "source": [ - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "geometry.export_to_xml()" ] }, { @@ -264,8 +260,8 @@ "inactive = 10\n", "particles = 5000\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -302,8 +298,8 @@ "plot.pixels = [250, 250]\n", "plot.color = 'mat'\n", "\n", - "# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n", - "plot_file = openmc.PlotsFile()\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots()\n", "plot_file.add_plot(plot)\n", "plot_file.export_to_xml()" ] @@ -335,8 +331,7 @@ ], "source": [ "# Run openmc in plotting mode\n", - "executor = openmc.Executor()\n", - "executor.plot_geometry(output=False)" + "openmc.plot_geometry(output=False)" ] }, { @@ -381,8 +376,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()" + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()" ] }, { @@ -634,7 +629,7 @@ ], "source": [ "# Run OpenMC!\n", - "executor.run_simulation()" + "openmc.run()" ] }, { diff --git a/docs/source/pythonapi/examples/tally-arithmetic.ipynb b/docs/source/pythonapi/examples/tally-arithmetic.ipynb index 094842895..81334efc2 100644 --- a/docs/source/pythonapi/examples/tally-arithmetic.ipynb +++ b/docs/source/pythonapi/examples/tally-arithmetic.ipynb @@ -126,8 +126,8 @@ }, "outputs": [], "source": [ - "# Instantiate a MaterialsFile, add Materials\n", - "materials_file = openmc.MaterialsFile()\n", + "# Instantiate a Materials object, add Materials\n", + "materials_file = openmc.Materials()\n", "materials_file.add_material(fuel)\n", "materials_file.add_material(water)\n", "materials_file.add_material(zircaloy)\n", @@ -258,12 +258,8 @@ }, "outputs": [], "source": [ - "# Instantiate a GeometryFile\n", - "geometry_file = openmc.GeometryFile()\n", - "geometry_file.geometry = geometry\n", - "\n", "# Export to \"geometry.xml\"\n", - "geometry_file.export_to_xml()" + "geometry.export_to_xml()" ] }, { @@ -286,8 +282,8 @@ "inactive = 5\n", "particles = 2500\n", "\n", - "# Instantiate a SettingsFile\n", - "settings_file = openmc.SettingsFile()\n", + "# Instantiate a Settings object\n", + "settings_file = openmc.Settings()\n", "settings_file.batches = batches\n", "settings_file.inactive = inactive\n", "settings_file.particles = particles\n", @@ -325,8 +321,8 @@ "plot.pixels = [250, 250]\n", "plot.color = 'mat'\n", "\n", - "# Instantiate a PlotsFile, add Plot, and export to \"plots.xml\"\n", - "plot_file = openmc.PlotsFile()\n", + "# Instantiate a Plots object, add Plot, and export to \"plots.xml\"\n", + "plot_file = openmc.Plots()\n", "plot_file.add_plot(plot)\n", "plot_file.export_to_xml()" ] @@ -358,8 +354,7 @@ ], "source": [ "# Run openmc in plotting mode\n", - "executor = openmc.Executor()\n", - "executor.plot_geometry(output=False)" + "openmc.plot_geometry(output=False)" ] }, { @@ -404,8 +399,8 @@ }, "outputs": [], "source": [ - "# Instantiate an empty TalliesFile\n", - "tallies_file = openmc.TalliesFile()" + "# Instantiate an empty Tallies object\n", + "tallies_file = openmc.Tallies()" ] }, { @@ -673,8 +668,8 @@ "# Remove old HDF5 (summary, statepoint) files\n", "!rm statepoint.*\n", "\n", - "# Run OpenMC with MPI!\n", - "executor.run_simulation()" + "# Run OpenMC!\n", + "openmc.run()" ] }, {