From 2df1f0eb041a3d4e316c43cdeb9cd1c71284a149 Mon Sep 17 00:00:00 2001 From: shimwell Date: Thu, 17 Oct 2024 17:45:22 +0100 Subject: [PATCH] updated 14 --- .../3_sphere_iterative_per_run_ww.ipynb | 13 +++++++++---- .../4_sphere_iterative_per_batch_ww.ipynb | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/tasks/task_14_variance_reduction/3_sphere_iterative_per_run_ww.ipynb b/tasks/task_14_variance_reduction/3_sphere_iterative_per_run_ww.ipynb index 3f2d10d..55d33d3 100644 --- a/tasks/task_14_variance_reduction/3_sphere_iterative_per_run_ww.ipynb +++ b/tasks/task_14_variance_reduction/3_sphere_iterative_per_run_ww.ipynb @@ -39,11 +39,16 @@ "metadata": {}, "outputs": [], "source": [ + "\n", + "from matplotlib import pyplot as plt\n", + "from matplotlib.colors import LogNorm # used for plotting log scale graphs\n", + "\n", "import openmc\n", "import openmc.lib # this example makes use of openmc lib to run the simulations\n", "\n", - "from matplotlib import pyplot as plt\n", - "from matplotlib.colors import LogNorm # used for plotting log scale graphs" + "# 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'" ] }, { @@ -224,8 +229,8 @@ "model = openmc.Model(my_geometry, my_materials, my_settings, my_tallies)\n", "\n", "# deletes old input and output files\n", - "!rm *.xml\n", - "!rm *.h5\n", + "!rm *.xml || true\n", + "!rm *.h5 || true\n", "\n", "model.export_to_xml() # this is necessary as openmc.lib loads up the model.xml file" ] diff --git a/tasks/task_14_variance_reduction/4_sphere_iterative_per_batch_ww.ipynb b/tasks/task_14_variance_reduction/4_sphere_iterative_per_batch_ww.ipynb index b6c9f32..2a6e5b3 100644 --- a/tasks/task_14_variance_reduction/4_sphere_iterative_per_batch_ww.ipynb +++ b/tasks/task_14_variance_reduction/4_sphere_iterative_per_batch_ww.ipynb @@ -23,6 +23,14 @@ "spectra tally." ] }, + { + "cell_type": "markdown", + "id": "61ad590c", + "metadata": {}, + "source": [ + "First we import the packages needed to run the example, including OpenMC. We also configure the nuclear data path." + ] + }, { "cell_type": "code", "execution_count": null, @@ -30,6 +38,9 @@ "metadata": {}, "outputs": [], "source": [ + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "\n", "import openmc\n", "# Note this example makes use of OpenMC lib which provides python bindings to\n", "# the C/C++ methods in OpenMC and allows more direct control of the Monte Carlo\n", @@ -37,8 +48,10 @@ "# tally result each time.\n", "# Link to openmc.lib documentation https://docs.openmc.org/en/stable/pythonapi/capi.html\n", "import openmc.lib\n", - "import numpy as np\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'" ] }, {