diff --git a/tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb b/tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb index 70c8c40b..bacf4c23 100644 --- a/tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb +++ b/tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb @@ -29,6 +29,26 @@ "IFrame(src=\"https://www.youtube.com/embed/eBZ2lY_2v7IA\", width=560, height=340)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import OpenMC and configure the nuclear data path" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import openmc\n", + "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -50,7 +70,6 @@ "metadata": {}, "outputs": [], "source": [ - "import openmc\n", "import matplotlib.pyplot as plt\n", "\n", "fig = openmc.plotter.plot_xs(\n", diff --git a/tasks/task_01_cross_sections/2_element_xs_plot.ipynb b/tasks/task_01_cross_sections/2_element_xs_plot.ipynb index 739f6832..f0e8683a 100644 --- a/tasks/task_01_cross_sections/2_element_xs_plot.ipynb +++ b/tasks/task_01_cross_sections/2_element_xs_plot.ipynb @@ -23,6 +23,26 @@ "IFrame(src=\"https://www.youtube.com/embed/ELZNeIdSuMY\", width=560, height=340)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import OpenMC and configure the nuclear data path" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import openmc\n", + "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/tasks/task_01_cross_sections/3_material_xs_plot.ipynb b/tasks/task_01_cross_sections/3_material_xs_plot.ipynb index 4b510038..832ccdff 100644 --- a/tasks/task_01_cross_sections/3_material_xs_plot.ipynb +++ b/tasks/task_01_cross_sections/3_material_xs_plot.ipynb @@ -37,7 +37,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This code block imports a function and packages needed for the task." + "First import OpenMC and configure the nuclear data path" ] }, { @@ -46,7 +46,11 @@ "metadata": {}, "outputs": [], "source": [ - "import openmc" + "import openmc\n", + "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" ] }, { diff --git a/tasks/task_01_cross_sections/4_Doppler_broadening.ipynb b/tasks/task_01_cross_sections/4_Doppler_broadening.ipynb index ac7a9a2c..d4bd5d9a 100644 --- a/tasks/task_01_cross_sections/4_Doppler_broadening.ipynb +++ b/tasks/task_01_cross_sections/4_Doppler_broadening.ipynb @@ -22,6 +22,13 @@ "IFrame(src=\"https://www.youtube.com/embed/mkl1mVnTO6g\", width=560, height=340)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import packages needed for OpenMC and configure the nuclear data path" + ] + }, { "cell_type": "code", "execution_count": null, @@ -29,9 +36,14 @@ "outputs": [], "source": [ "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "\n", "import openmc\n", "from openmc.data import REACTION_MT\n", - "import matplotlib.pyplot as plt" + "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" ] }, { diff --git a/tasks/task_02_making_materials/1_example_materials_from_isotopes.ipynb b/tasks/task_02_making_materials/1_example_materials_from_isotopes.ipynb index 199725c9..d80250c1 100644 --- a/tasks/task_02_making_materials/1_example_materials_from_isotopes.ipynb +++ b/tasks/task_02_making_materials/1_example_materials_from_isotopes.ipynb @@ -23,6 +23,26 @@ "IFrame(src=\"https://www.youtube.com/embed/-NGnY-1TWCA\", width=560, height=340)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import OpenMC and configure the nuclear data path" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import openmc\n", + "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/tasks/task_02_making_materials/2_example_materials_from_elements.ipynb b/tasks/task_02_making_materials/2_example_materials_from_elements.ipynb index 9c318473..abb95c83 100644 --- a/tasks/task_02_making_materials/2_example_materials_from_elements.ipynb +++ b/tasks/task_02_making_materials/2_example_materials_from_elements.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The following code block is a simple example of creating a material (water H2O) from elements. (Note how Hydrogen and Oxygen elements have been specified rather than each specific isotope)." + "First import OpenMC and configure the nuclear data path" ] }, { @@ -26,6 +26,24 @@ "source": [ "import openmc\n", "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The following code block is a simple example of creating a material (water H2O) from elements. (Note how Hydrogen and Oxygen elements have been specified rather than each specific isotope)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# Making water from elements\n", "\n", "water_mat = openmc.Material()\n", diff --git a/tasks/task_02_making_materials/5_example_materials_mixed.ipynb b/tasks/task_02_making_materials/5_example_materials_mixed.ipynb index 9a3a0c04..add3af91 100644 --- a/tasks/task_02_making_materials/5_example_materials_mixed.ipynb +++ b/tasks/task_02_making_materials/5_example_materials_mixed.ipynb @@ -24,15 +24,25 @@ "This python notebook allows users to make mixed materials using OpenMC and the Neutronics Material Maker." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import packages needed and configure the OpenMC nuclear data path" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# import the packages needed for the task\n", + "import neutronics_material_maker as nmm\n", "import openmc\n", - "import neutronics_material_maker as nmm" + "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" ] }, { diff --git a/tasks/task_03_making_CSG_geometry/1_simple_csg_geometry.ipynb b/tasks/task_03_making_CSG_geometry/1_simple_csg_geometry.ipynb index bc7e31e9..29e9b97a 100644 --- a/tasks/task_03_making_CSG_geometry/1_simple_csg_geometry.ipynb +++ b/tasks/task_03_making_CSG_geometry/1_simple_csg_geometry.ipynb @@ -22,6 +22,26 @@ "IFrame(src=\"https://www.youtube.com/embed/Ovr7oYukYRw\", width=560, height=340)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import OpenMC and configure the nuclear data path" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import openmc\n", + "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -38,8 +58,6 @@ "metadata": {}, "outputs": [], "source": [ - "import openmc\n", - "\n", "# example surfaces\n", "inner_sphere_surface = openmc.Sphere(r=500)\n", "outer_sphere_surface = openmc.Sphere(r=600)\n", diff --git a/tasks/task_03_making_CSG_geometry/2_intermediate_csg_geometry.ipynb b/tasks/task_03_making_CSG_geometry/2_intermediate_csg_geometry.ipynb index a7dd5589..995c8c2f 100644 --- a/tasks/task_03_making_CSG_geometry/2_intermediate_csg_geometry.ipynb +++ b/tasks/task_03_making_CSG_geometry/2_intermediate_csg_geometry.ipynb @@ -9,8 +9,33 @@ "\n", "This python notebook allows users to build upon the geometry constructed in Part 1 by adding a center column to the model.\n", "\n", - "The center column requires a different surface type. OpenMC has several different surface types in addition to spheres. The documentation contains useful information on all surface types supported: https://openmc.readthedocs.io/en/stable/usersguide/geometry.html#surfaces-and-regions.\n", + "The center column requires a different surface type. OpenMC has several different surface types in addition to spheres. The documentation contains useful information on all surface types supported: https://openmc.readthedocs.io/en/stable/usersguide/geometry.html#surfaces-and-regions." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import OpenMC and configure the nuclear data path" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import openmc\n", "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "For the center column we will use a cylinder with Z axis orientation.\n", "\n", "The code block below shows how the center column can be defined." @@ -22,8 +47,6 @@ "metadata": {}, "outputs": [], "source": [ - "import openmc\n", - "\n", "# surfaces\n", "central_column_surface = openmc.ZCylinder(r=100) # note the new surface type\n", "inner_sphere_surface = openmc.Sphere(r=480)\n", diff --git a/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb b/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb index 644e1e0b..2af9dcf4 100644 --- a/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb +++ b/tasks/task_03_making_CSG_geometry/3_viewing_the_geometry_as_vtk.ipynb @@ -24,6 +24,13 @@ "This first code block recreates the simple reactor geometry seen in Part 2, but also assigns materials to each cell." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import OpenMC and configure the nuclear data path" + ] + }, { "cell_type": "code", "execution_count": null, @@ -32,6 +39,17 @@ "source": [ "import openmc\n", "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "copper = openmc.Material()\n", "copper.set_density('g/cm3', 8.5)\n", "copper.add_element('Cu', 1.0) # Note, percent_type does not have to be specified as material is 100% copper\n", diff --git a/tasks/task_04_make_sources/1_point_source_plots.ipynb b/tasks/task_04_make_sources/1_point_source_plots.ipynb index 72f91cfc..70a6173b 100644 --- a/tasks/task_04_make_sources/1_point_source_plots.ipynb +++ b/tasks/task_04_make_sources/1_point_source_plots.ipynb @@ -22,6 +22,13 @@ "IFrame(src=\"https://www.youtube.com/embed/j9dT1Viqcu4\", width=560, height=340)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import packages needed" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/tasks/task_04_make_sources/2_ring_source.ipynb b/tasks/task_04_make_sources/2_ring_source.ipynb index bd9cf3aa..726e4f7d 100644 --- a/tasks/task_04_make_sources/2_ring_source.ipynb +++ b/tasks/task_04_make_sources/2_ring_source.ipynb @@ -38,6 +38,13 @@ "In this example we are going to make use of the Uniform disitrbution by feel free to tinker with the differnt distributions an make your own source." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import packages needed" + ] + }, { "cell_type": "code", "execution_count": null, @@ -46,11 +53,11 @@ "source": [ "import openmc\n", "\n", - "# provides simple source plotting functions\n", + "\n", + "# This package provides simple source plotting functions\n", "# for more details here is a link to the package repository\n", "# https://github.com/fusion-energy/openmc_source_plotter\n", - "from openmc_source_plotter import plot_source_position\n", - "\n" + "from openmc_source_plotter import plot_source_position" ] }, { @@ -148,7 +155,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.12.2" } }, "nbformat": 4, diff --git a/tasks/task_04_make_sources/5_gamma_source_example.ipynb b/tasks/task_04_make_sources/5_gamma_source_example.ipynb index d2b6ff7f..f20071e7 100644 --- a/tasks/task_04_make_sources/5_gamma_source_example.ipynb +++ b/tasks/task_04_make_sources/5_gamma_source_example.ipynb @@ -96,7 +96,7 @@ "outputs": [], "source": [ "# remove any other xml files so that openmc reads the correct xml files\n", - "!rm *.xml\n", + "!rm *.xml || true\n", "\n", "# number_of_particles can be increased to sample more particles and the histogram resoluton can be changed\n", "plot_source_energy(\n", diff --git a/tasks/task_04_make_sources/7_strucutured_mesh_source.py b/tasks/task_04_make_sources/7_strucutured_mesh_source.py index aa4828df..79c6dda5 100644 --- a/tasks/task_04_make_sources/7_strucutured_mesh_source.py +++ b/tasks/task_04_make_sources/7_strucutured_mesh_source.py @@ -6,7 +6,8 @@ import openmc import numpy as np -# setting the nuclear data path to the correct location in the docker image +# Setting the nuclear data path to the correct location in the docker image. +# If you are running this outside the docker image you will have to change this path. openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml' # making a minimal geometry diff --git a/tasks/task_05_CSG_cell_tally_TBR/1_example_tritium_production.ipynb b/tasks/task_05_CSG_cell_tally_TBR/1_example_tritium_production.ipynb index 8dd85253..a9b089a9 100644 --- a/tasks/task_05_CSG_cell_tally_TBR/1_example_tritium_production.ipynb +++ b/tasks/task_05_CSG_cell_tally_TBR/1_example_tritium_production.ipynb @@ -23,9 +23,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This example uses a simple sphere model with a breeder material and a tritium production tally.\n", - "\n", - "This first code block makes the geometry, materials and settings for the neutronics model." + "This example uses a simple sphere model with a breeder material and a tritium production tally." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import OpenMC and configure the nuclear data path" ] }, { @@ -36,6 +41,24 @@ "source": [ "import openmc\n", "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This first code block makes the geometry, materials and settings for the neutronics model." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# MATERIALS\n", "\n", "breeder_material = openmc.Material() # lithium lead chemical equation is Pb84.2Li15.8\n", diff --git a/tasks/task_05_CSG_cell_tally_TBR/2_example_tritium_production_study.ipynb b/tasks/task_05_CSG_cell_tally_TBR/2_example_tritium_production_study.ipynb index e0a46b93..af3c2d59 100644 --- a/tasks/task_05_CSG_cell_tally_TBR/2_example_tritium_production_study.ipynb +++ b/tasks/task_05_CSG_cell_tally_TBR/2_example_tritium_production_study.ipynb @@ -15,7 +15,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This first code block a neutronics model for the provided enrichment value, runs the simulation and returns the TBR value obtained." + "First import OpenMC and configure the nuclear data path" ] }, { @@ -26,7 +26,24 @@ "source": [ "import openmc\n", "\n", - "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This first code block a neutronics model for the provided enrichment value, runs the simulation and returns the TBR value obtained." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "def make_materials_geometry_tallies(enrichment):\n", " \"\"\"Makes a neutronics model of a blanket and simulates the TBR value.\n", "\n", diff --git a/tasks/task_05_CSG_cell_tally_TBR/3_example_tritium_production_study_with_openmc_lib.py b/tasks/task_05_CSG_cell_tally_TBR/3_example_tritium_production_study_with_openmc_lib.py index c8cd8ecd..fca79b09 100644 --- a/tasks/task_05_CSG_cell_tally_TBR/3_example_tritium_production_study_with_openmc_lib.py +++ b/tasks/task_05_CSG_cell_tally_TBR/3_example_tritium_production_study_with_openmc_lib.py @@ -14,6 +14,9 @@ import openmc +# Setting the cross section path to the correct location in the docker image. +# If you are running this outside the docker image you will have to change this path to your local cross section path. +openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml' # make some python materials breeder_material = openmc.Material(material_id = 12) # Pb84.2Li15.8 diff --git a/tasks/task_06_CSG_cell_tally_DPA/1_find_dpa.ipynb b/tasks/task_06_CSG_cell_tally_DPA/1_find_dpa.ipynb index f3d0c963..4c52fd7d 100644 --- a/tasks/task_06_CSG_cell_tally_DPA/1_find_dpa.ipynb +++ b/tasks/task_06_CSG_cell_tally_DPA/1_find_dpa.ipynb @@ -27,7 +27,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This first stage sets up the geometry and materials for the simulation." + "First import OpenMC and configure the nuclear data path" ] }, { @@ -38,7 +38,24 @@ "source": [ "import openmc\n", "\n", - "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This first stage sets up the geometry and materials for the simulation." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# MATERIALS\n", "\n", "density_of_iron_in_g_per_cm3 = 7.75\n", diff --git a/tasks/task_07_CSG_cell_tally_spectra/1_example_neutron_flux_and_units.ipynb b/tasks/task_07_CSG_cell_tally_spectra/1_example_neutron_flux_and_units.ipynb index 897a4280..e5ae6ddc 100644 --- a/tasks/task_07_CSG_cell_tally_spectra/1_example_neutron_flux_and_units.ipynb +++ b/tasks/task_07_CSG_cell_tally_spectra/1_example_neutron_flux_and_units.ipynb @@ -13,7 +13,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This section creates a simple material, geometry and settings. This model is used in both the neutron current tally and the neutron flux tally." + "First import OpenMC and configure the nuclear data path" ] }, { @@ -24,6 +24,24 @@ "source": [ "import openmc\n", "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This section creates a simple material, geometry and settings. This model is used in both the neutron current tally and the neutron flux tally." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# MATERIALS\n", "\n", "# Due to the hydrogen content water is a very good neutron moderator\n", @@ -115,7 +133,7 @@ "model = openmc.model.Model(my_geometry, my_materials, my_settings, my_tallies)\n", "\n", "# remove old files and runs OpenMC\n", - "!rm *.h5\n", + "!rm *.h5 || true\n", "results_filename = model.run()" ] }, diff --git a/tasks/task_07_CSG_cell_tally_spectra/2_example_neutron_spectra_on_cell.ipynb b/tasks/task_07_CSG_cell_tally_spectra/2_example_neutron_spectra_on_cell.ipynb index 92268920..4401f117 100644 --- a/tasks/task_07_CSG_cell_tally_spectra/2_example_neutron_spectra_on_cell.ipynb +++ b/tasks/task_07_CSG_cell_tally_spectra/2_example_neutron_spectra_on_cell.ipynb @@ -25,7 +25,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This section creates a simple material, geometry and settings. This model is used in both the neutron current tally and the neutron flux tally." + "\n", + "\n", + "First import OpenMC and configure the nuclear data path\n" ] }, { @@ -34,10 +36,28 @@ "metadata": {}, "outputs": [], "source": [ - "import openmc\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "import openmc\n", "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This section creates a simple material, geometry and settings. This model is used in both the neutron current tally and the neutron flux tally." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# MATERIALS\n", "\n", "# Due to the hydrogen content water is a very good neutron moderator\n", @@ -125,7 +145,7 @@ "model = openmc.model.Model(my_geometry, my_materials, my_settings, my_tallies)\n", "\n", "# remove old files and runs OpenMC\n", - "!rm *.h5\n", + "!rm *.h5 || true\n", "results_filename = model.run()" ] }, diff --git a/tasks/task_07_CSG_cell_tally_spectra/3_example_neutron_spectra_on_surface.ipynb b/tasks/task_07_CSG_cell_tally_spectra/3_example_neutron_spectra_on_surface.ipynb index 71b98653..5cb18dc2 100644 --- a/tasks/task_07_CSG_cell_tally_spectra/3_example_neutron_spectra_on_surface.ipynb +++ b/tasks/task_07_CSG_cell_tally_spectra/3_example_neutron_spectra_on_surface.ipynb @@ -29,7 +29,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This section creates a simple material, geometry and settings. This model is used in both the neutron current tally and the neutron flux tally." + "First import OpenMC and configure the nuclear data path" ] }, { @@ -40,6 +40,24 @@ "source": [ "import openmc\n", "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This section creates a simple material, geometry and settings. This model is used in both the neutron current tally and the neutron flux tally." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# MATERIALS\n", "\n", "# Due to the hydrogen content water is a very good neutron moderator\n", @@ -158,7 +176,7 @@ "model = openmc.model.Model(my_geometry, my_materials, my_settings, my_tallies)\n", "\n", "# remove old files and runs OpenMC\n", - "!rm *.h5\n", + "!rm *.h5 || true\n", "results_filename = model.run()" ] }, diff --git a/tasks/task_07_CSG_cell_tally_spectra/4_example_photon_spectra.ipynb b/tasks/task_07_CSG_cell_tally_spectra/4_example_photon_spectra.ipynb index 9c9c1313..7315ec5a 100644 --- a/tasks/task_07_CSG_cell_tally_spectra/4_example_photon_spectra.ipynb +++ b/tasks/task_07_CSG_cell_tally_spectra/4_example_photon_spectra.ipynb @@ -19,7 +19,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This section creates a simple material, geometry and settings. This model is used in both the photon current tally and photon flux tally." + "First import OpenMC and configure the nuclear data path" ] }, { @@ -28,9 +28,27 @@ "metadata": {}, "outputs": [], "source": [ - "import openmc\n", "import matplotlib.pyplot as plt\n", + "import openmc\n", "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This section creates a simple material, geometry and settings. This model is used in both the photon current tally and photon flux tally." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# MATERIALS\n", "\n", "# Tungsten is a very good photon shield, partly due to its high Z number and electrons\n", @@ -122,7 +140,7 @@ "model = openmc.model.Model(my_geometry, my_materials, my_settings, my_tallies)\n", "\n", "# remove old files and runs OpenMC\n", - "!rm *.h5\n", + "!rm *.h5 || true\n", "results_filename = model.run()" ] }, diff --git a/tasks/task_07_CSG_cell_tally_spectra/5_neutron_energy_loss_plot.ipynb b/tasks/task_07_CSG_cell_tally_spectra/5_neutron_energy_loss_plot.ipynb index 58a7cf01..7693c2f4 100644 --- a/tasks/task_07_CSG_cell_tally_spectra/5_neutron_energy_loss_plot.ipynb +++ b/tasks/task_07_CSG_cell_tally_spectra/5_neutron_energy_loss_plot.ipynb @@ -19,7 +19,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Imports required packages" + "First import OpenMC and configure the nuclear data path" ] }, { @@ -28,9 +28,14 @@ "metadata": {}, "outputs": [], "source": [ - "import openmc\n", "import matplotlib.pyplot as plt\n", - "from shutil import move" + "from shutil import move\n", + "\n", + "import openmc\n", + "\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" ] }, { @@ -112,7 +117,7 @@ "outputs": [], "source": [ "# remove old summary and statepoint files\n", - "!rm *.h5\n", + "!rm *.h5 || true\n", "\n", "for element, color in zip([liquid_hydrogen, tungsten], [\"red\", \"blue\"]):\n", " plt.plot([0], label=element, color=color)\n", diff --git a/tasks/task_08_CSG_mesh_tally/1_example_2d_regular_mesh_tallies.ipynb b/tasks/task_08_CSG_mesh_tally/1_example_2d_regular_mesh_tallies.ipynb index 82006429..8d156757 100644 --- a/tasks/task_08_CSG_mesh_tally/1_example_2d_regular_mesh_tallies.ipynb +++ b/tasks/task_08_CSG_mesh_tally/1_example_2d_regular_mesh_tallies.ipynb @@ -27,6 +27,26 @@ "IFrame(src=\"https://www.youtube.com/embed/KYIsDjip1nQ\", width=560, height=340)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import packages needed and configure the OpenMC nuclear data path" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "import openmc\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -42,9 +62,6 @@ "metadata": {}, "outputs": [], "source": [ - "import openmc\n", - "import matplotlib.pyplot as plt\n", - "\n", "# MATERIALS\n", "\n", "# creates two materials, one is a neutron multiplier (lead) and the other a tritium breeder (lithium)\n", diff --git a/tasks/task_08_CSG_mesh_tally/2_example_3d_regular_mesh_tallies.ipynb b/tasks/task_08_CSG_mesh_tally/2_example_3d_regular_mesh_tallies.ipynb index f47175cd..c3c25fa5 100644 --- a/tasks/task_08_CSG_mesh_tally/2_example_3d_regular_mesh_tallies.ipynb +++ b/tasks/task_08_CSG_mesh_tally/2_example_3d_regular_mesh_tallies.ipynb @@ -20,16 +20,33 @@ "This first code block defines the model geometry, materials and neutron source." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First import OpenMC and configure the nuclear data path" + ] + }, { "cell_type": "code", "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import openmc\n", + "# Setting the cross section path to the correct location in the docker image.\n", + "# If you are running this outside the docker image you will have to change this path to your local cross section path.\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'" + ] + }, + { + "cell_type": "code", + "execution_count": 1, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "import openmc\n", - "\n", "# MATERIALS\n", "\n", "breeder_material = openmc.Material() # Pb84.2Li15.8\n", @@ -110,7 +127,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -131,7 +148,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -162,15 +179,100 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "rm: cannot remove 's*.h5': No such file or directory\n", + " %%%%%%%%%%%%%%%\n", + " %%%%%%%%%%%%%%%%%%%%%%%%\n", + " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", + " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", + " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", + " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", + " %%%%%%%%%%%%%%%%%%%%%%%%\n", + " %%%%%%%%%%%%%%%%%%%%%%%%\n", + " ############### %%%%%%%%%%%%%%%%%%%%%%%%\n", + " ################## %%%%%%%%%%%%%%%%%%%%%%%\n", + " ################### %%%%%%%%%%%%%%%%%%%%%%%\n", + " #################### %%%%%%%%%%%%%%%%%%%%%%\n", + " ##################### %%%%%%%%%%%%%%%%%%%%%\n", + " ###################### %%%%%%%%%%%%%%%%%%%%\n", + " ####################### %%%%%%%%%%%%%%%%%%\n", + " ####################### %%%%%%%%%%%%%%%%%\n", + " ###################### %%%%%%%%%%%%%%%%%\n", + " #################### %%%%%%%%%%%%%%%%%\n", + " ################# %%%%%%%%%%%%%%%%%\n", + " ############### %%%%%%%%%%%%%%%%\n", + " ############ %%%%%%%%%%%%%%%\n", + " ######## %%%%%%%%%%%%%%\n", + " %%%%%%%%%%%\n", + "\n", + " | The OpenMC Monte Carlo Code\n", + " Copyright | 2011-2024 MIT, UChicago Argonne LLC, and contributors\n", + " License | https://docs.openmc.org/en/latest/license.html\n", + " Version | 0.15.1-dev\n", + " Git SHA1 | 86fc40a6456e789676eec3410afff38e340ea8f8\n", + " Date/Time | 2024-08-30 11:57:21\n", + " OpenMP Threads | 16\n", + "\n", + " Reading model XML file 'model.xml' ...\n", + " Reading cross sections XML file...\n", + " Reading Pb204 from /nuclear_data/endfb-viii.0-hdf5/neutron/Pb204.h5\n", + " Reading Pb206 from /nuclear_data/endfb-viii.0-hdf5/neutron/Pb206.h5\n", + " Reading Pb207 from /nuclear_data/endfb-viii.0-hdf5/neutron/Pb207.h5\n", + " Reading Pb208 from /nuclear_data/endfb-viii.0-hdf5/neutron/Pb208.h5\n", + " Reading Li6 from /nuclear_data/endfb-viii.0-hdf5/neutron/Li6.h5\n", + " Reading Li7 from /nuclear_data/endfb-viii.0-hdf5/neutron/Li7.h5\n", + " Reading Cu63 from /nuclear_data/endfb-viii.0-hdf5/neutron/Cu63.h5\n", + " Reading Cu65 from /nuclear_data/endfb-viii.0-hdf5/neutron/Cu65.h5\n", + " Reading Fe54 from /nuclear_data/endfb-viii.0-hdf5/neutron/Fe54.h5\n", + " Reading Fe56 from /nuclear_data/endfb-viii.0-hdf5/neutron/Fe56.h5\n", + " Reading Fe57 from /nuclear_data/endfb-viii.0-hdf5/neutron/Fe57.h5\n", + " Reading Fe58 from /nuclear_data/endfb-viii.0-hdf5/neutron/Fe58.h5\n", + " Minimum neutron data temperature: 294 K\n", + " Maximum neutron data temperature: 294 K\n", + " Preparing distributed cell instances...\n", + " Writing summary.h5 file...\n", + " Maximum neutron transport energy: 20000000 eV for Li6\n", + "\n", + " ===============> FIXED SOURCE TRANSPORT SIMULATION <===============\n", + "\n", + " Simulating batch 1\n", + " Simulating batch 2\n", + " Creating state point statepoint.2.h5...\n", + "\n", + " =======================> TIMING STATISTICS <=======================\n", + "\n", + " Total time for initialization = 1.1259e+00 seconds\n", + " Reading cross sections = 1.1053e+00 seconds\n", + " Total time in simulation = 4.0207e-01 seconds\n", + " Time in transport only = 3.9833e-01 seconds\n", + " Time in active batches = 4.0207e-01 seconds\n", + " Time accumulating tallies = 3.6221e-04 seconds\n", + " Time writing statepoints = 3.2080e-03 seconds\n", + " Total time for finalization = 1.3965e-02 seconds\n", + " Total time elapsed = 1.5450e+00 seconds\n", + " Calculation Rate (active) = 24871.5 particles/second\n", + "\n", + " ============================> RESULTS <============================\n", + "\n", + " Leakage Fraction = 0.14289 +/- 0.00061\n", + "\n" + ] + } + ], "source": [ "# deletes old statepoint and summary files\n", "!rm s*.h5\n", "\n", "# Run OpenMC!\n", "model = openmc.Model(my_geometry, mats, sett, tallies)\n", + "openmc.config['cross_sections'] = '/nuclear_data/cross_sections.xml'\n", + "\n", "sp_filename = model.run()" ] }, @@ -184,9 +286,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\n", "# loads up the output file from the simulation\n", @@ -225,6 +338,37 @@ "Visit can be downloaded here: https://wci.llnl.gov/simulation/computer-codes/visit/downloads." ] }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6de27a09e3594a6bbb7cb8846e9781ae", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Widget(value='