From 21fdf644429de22fda52b31954a7c7f6b50694c4 Mon Sep 17 00:00:00 2001 From: shimwell Date: Mon, 30 Sep 2024 08:44:45 +0100 Subject: [PATCH 01/17] added nuc path to examples --- .../1_isotope_xs_plot.ipynb | 21 ++- .../2_element_xs_plot.ipynb | 20 +++ .../3_material_xs_plot.ipynb | 8 +- .../4_Doppler_broadening.ipynb | 14 +- .../1_example_materials_from_isotopes.ipynb | 20 +++ .../7_strucutured_mesh_source.py | 3 +- .../2_example_3d_regular_mesh_tallies.ipynb | 146 ++++++++++++++++-- 7 files changed, 218 insertions(+), 14 deletions(-) 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_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_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..b67857fc 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 @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "scrolled": true }, @@ -110,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -162,15 +162,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/endfb-viii.0-hdf5/cross_sections.xml'\n", + "\n", "sp_filename = model.run()" ] }, @@ -184,14 +269,26 @@ }, { "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", "statepoint = openmc.StatePoint(sp_filename)\n", - "\n", + "import pyvista as pv\n", + "mesh = pv.read('my_strange_vtk_file.vtk')\n", "# extracts the mesh tally by name\n", "my_tbr_tally = statepoint.get_tally(name='tbr_on_mesh')\n", "\n", @@ -225,6 +322,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='