From cf2656678470ad3c6dafb3f01b1894be9d56ff7d Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 29 Jan 2024 13:53:56 +0000 Subject: [PATCH 1/5] added half day ws folder --- .devcontainer/Dockerfile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 95f463b4..a14d55ee 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -21,6 +21,23 @@ FROM ghcr.io/fusion-energy/neutronics-workshop:base as base COPY tasks tasks/ COPY tests tests/ +RUN mkdir tasks/half-day-workshop +RUN cp tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb tasks/half-day-workshop/task_01_isotope_xs_plot.ipynb +RUN cp tasks/task_01_cross_sections/2_element_xs_plot.ipynb tasks/half-day-workshop/task_02_element_xs_plot.ipynb +RUN cp tasks/task_01_cross_sections/3_material_xs_plot.ipynb tasks/half-day-workshop/task_03_material_xs_plot.ipynb +RUN cp tasks/task_02_making_materials/1_example_materials_from_isotopes.ipynb tasks/half-day-workshop/task_04_example_materials_from_isotopes.ipynb +RUN cp tasks/task_02_making_materials/2_example_materials_from_elements.ipynb tasks/half-day-workshop/task_05_example_materials_from_elements.ipynb +RUN cp tasks/task_03_making_CSG_geometry/1_simple_csg_geometry.ipynb tasks/half-day-workshop/task_06_simple_csg_geometry.ipynb +RUN cp tasks/task_04_make_sources/1_point_source_plots.ipynb tasks/half-day-workshop/task_08_point_source_plots.ipynb +RUN cp tasks/task_04_make_sources/2_ring_source.ipynb tasks/half-day-workshop/task_09_ring_source.ipynb +RUN cp tasks/task_04_make_sources/3_plasma_source_plots.ipynb tasks/half-day-workshop/task_10_plasma_source_plots.ipynb +RUN cp tasks/task_05_CSG_cell_tally_TBR/1_example_tritium_production.ipynb tasks/half-day-workshop/task_11_example_tritium_production.ipynb +RUN cp tasks/task_06_CSG_cell_tally_DPA/1_find_dpa.ipynb tasks/half-day-workshop/task_12_find_dpa.ipynb +RUN cp tasks/task_07_CSG_cell_tally_spectra/2_example_neutron_spectra_on_cell.ipynb tasks/half-day-workshop/task_13_example_neutron_spectra_on_cell.ipynb +RUN cp tasks/task_07_CSG_cell_tally_spectra/4_example_photon_spectra.ipynb tasks/half-day-workshop/task_14_example_photon_spectra.ipynb +RUN cp tasks/task_08_CSG_mesh_tally/1_example_2d_regular_mesh_tallies.ipynb tasks/half-day-workshop/task_15_example_2d_regular_mesh_tallies.ipynb +RUN cp tasks/task_08_CSG_mesh_tally/2_example_3d_regular_mesh_tallies.ipynb tasks/half-day-workshop/task_16_example_3d_regular_mesh_tallies.ipynb + WORKDIR /tasks # this sets the port, gcr looks for this varible From 8298e4f72f0b9afc1a90154195230e87b5d144d8 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 29 Jan 2024 18:19:53 +0000 Subject: [PATCH 2/5] updated package version --- .devcontainer/Dockerfile | 2 ++ .../3_plasma_source_plots.ipynb | 27 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a14d55ee..1614d6c8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -21,6 +21,8 @@ FROM ghcr.io/fusion-energy/neutronics-workshop:base as base COPY tasks tasks/ COPY tests tests/ +RUN pip install openmc_source_plotter==0.6.6 + RUN mkdir tasks/half-day-workshop RUN cp tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb tasks/half-day-workshop/task_01_isotope_xs_plot.ipynb RUN cp tasks/task_01_cross_sections/2_element_xs_plot.ipynb tasks/half-day-workshop/task_02_element_xs_plot.ipynb diff --git a/tasks/task_04_make_sources/3_plasma_source_plots.ipynb b/tasks/task_04_make_sources/3_plasma_source_plots.ipynb index 484a904f..6614cee7 100644 --- a/tasks/task_04_make_sources/3_plasma_source_plots.ipynb +++ b/tasks/task_04_make_sources/3_plasma_source_plots.ipynb @@ -64,7 +64,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To plot the parametric plasma source we store the x y z birth locations, energies and directions of neutrons in the source in separate lists." + "Makes a simple model for the sources." ] }, { @@ -73,12 +73,15 @@ "metadata": {}, "outputs": [], "source": [ - "# plots multiple sources on one plot by iterating through\n", - "# the list of sources and building up the plot\n", - "plot = None\n", - "for source in my_sources:\n", - " plot = source.plot_source_energy(figure=plot)\n", - "plot.show()" + "settings = openmc.Settings()\n", + "settings.particles = 1\n", + "settings.batches = 1\n", + "settings.source = my_sources\n", + "materials = openmc.Materials()\n", + "sph = openmc.Sphere(r=1000000, boundary_type=\"vacuum\")\n", + "cell = openmc.Cell(region=-sph)\n", + "geometry = openmc.Geometry([cell])\n", + "model = openmc.Model(geometry, materials, settings)" ] }, { @@ -94,11 +97,7 @@ "metadata": {}, "outputs": [], "source": [ - "# plots multiple sources on one plot by iterating through\n", - "# the list of sources and building up the plot\n", - "plot = None\n", - "for source in my_sources:\n", - " plot = source.plot_source_position(figure=plot)\n", + "plot = source.plot_source_position()\n", "plot.show()" ] }, @@ -115,9 +114,7 @@ "metadata": {}, "outputs": [], "source": [ - "plot = None\n", - "for source in my_sources:\n", - " plot = source.plot_source_direction(figure=plot)\n", + "plot = source.plot_source_direction()\n", "plot.show()" ] }, From 5213bf4112d4f3b44dd34601866a5c8a5f00c77f Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 29 Jan 2024 18:24:29 +0000 Subject: [PATCH 3/5] added samples --- .devcontainer/Dockerfile | 3 ++- tasks/task_04_make_sources/3_plasma_source_plots.ipynb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 1614d6c8..fe103f50 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -17,11 +17,12 @@ FROM ghcr.io/fusion-energy/neutronics-workshop:base as base # local image # FROM neutronics-workshop:base as base +RUN pip install openmc_source_plotter==0.6.6 + # Copy over the local repository files COPY tasks tasks/ COPY tests tests/ -RUN pip install openmc_source_plotter==0.6.6 RUN mkdir tasks/half-day-workshop RUN cp tasks/task_01_cross_sections/1_isotope_xs_plot.ipynb tasks/half-day-workshop/task_01_isotope_xs_plot.ipynb diff --git a/tasks/task_04_make_sources/3_plasma_source_plots.ipynb b/tasks/task_04_make_sources/3_plasma_source_plots.ipynb index 6614cee7..7f837608 100644 --- a/tasks/task_04_make_sources/3_plasma_source_plots.ipynb +++ b/tasks/task_04_make_sources/3_plasma_source_plots.ipynb @@ -97,7 +97,7 @@ "metadata": {}, "outputs": [], "source": [ - "plot = source.plot_source_position()\n", + "plot = model.plot_source_position(n_samples=2000)\n", "plot.show()" ] }, @@ -114,7 +114,7 @@ "metadata": {}, "outputs": [], "source": [ - "plot = source.plot_source_direction()\n", + "plot = model.plot_source_direction(n_samples=500)\n", "plot.show()" ] }, From bd01846293ae7c6007f55ac6ffa3cef3e6511778 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 30 Jan 2024 17:40:48 +0000 Subject: [PATCH 4/5] converted depletion example to ipynb --- .../3_full_pulse_schedule.ipynb | 420 ++++++++++++++++++ .../3_full_pulse_schedule.py | 125 ------ 2 files changed, 420 insertions(+), 125 deletions(-) create mode 100644 tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.ipynb delete mode 100644 tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.py diff --git a/tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.ipynb b/tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.ipynb new file mode 100644 index 00000000..b7b413d0 --- /dev/null +++ b/tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.ipynb @@ -0,0 +1,420 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d608fad2-d0b4-4d9b-826e-23ef3a9b8f78", + "metadata": {}, + "source": [ + "This example performs a depletion/transmutation/activation simulation\n", + "\n", + "The simulation has been accelerated by making use of the IndependentOperator instead of the CoupledOperator.\n", + "\n", + "This is an approximation so is less accurate but it is much faster.\n", + "\n", + "This approach performs just a single transport simulation and obtains reactions rates once and assumes that they remain constant.\n", + "\n", + "If the materials don't change significantly during the irradiation this is a reasonable approximation.\n", + "\n", + "Fission fuel pins would perhaps require the full CoupledOperator while the majority of fusion simulations are suitable for the IndependentOperator\n", + "\n", + "More details on both Operators in the docs\n", + "https://docs.openmc.org/en/stable/usersguide/depletion.html#transport-independent-depletion" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6b2e7872-b0f2-407e-97cf-81d35ce1a799", + "metadata": {}, + "outputs": [], + "source": [ + "# remove any old files\n", + "!rm settings.xm model.xml materials.xml geometry.xml settings.xml\n", + "\n", + "import openmc\n", + "import openmc.deplete\n", + "import math\n", + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f42c7e11-f514-4859-855f-873fb8f4026e", + "metadata": {}, + "outputs": [], + "source": [ + "# chain and cross section paths have been set on the docker image but you may want to change them\n", + "#openmc.config['chain_file']=path to chain file\n", + "#openmc.config['cross_sections']=path to cross_sections.xml" + ] + }, + { + "cell_type": "markdown", + "id": "b4a8bf6d-2fb7-4334-8ee7-aaff2bbc47a1", + "metadata": {}, + "source": [ + "Creates a simple material which we will deplete" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cd47ca6f-eb2f-4eb9-a820-6daf3c8a744c", + "metadata": {}, + "outputs": [], + "source": [ + "my_material = openmc.Material(material_id=1) \n", + "my_material.add_element('Ag', 1, percent_type='ao')\n", + "my_material.set_density('g/cm3', 10.49)" + ] + }, + { + "cell_type": "markdown", + "id": "6a7f2c1e-7bfa-4989-b121-7f7adcb27539", + "metadata": {}, + "source": [ + "As we are doing a depletion simulation we must set the material volume and the .depletion to True" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "26358235-acce-4fcb-b218-fd91bf4999e5", + "metadata": {}, + "outputs": [], + "source": [ + "sphere_radius = 100\n", + "volume_of_sphere = (4/3) * math.pi * math.pow(sphere_radius, 3)\n", + "my_material.volume = volume_of_sphere # a volume is needed so openmc can find the number of atoms in the cell/material\n", + "my_material.depletable = True # depletable = True is needed to tell openmc to update the material with each time step\n", + "materials = openmc.Materials([my_material])" + ] + }, + { + "cell_type": "markdown", + "id": "6114bb03-95ea-4569-8e7c-6632770812a2", + "metadata": {}, + "source": [ + "makes a simple sphere surface and cell" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1646dc3b-5b85-44e3-9249-2a8dcc0a4ca1", + "metadata": {}, + "outputs": [], + "source": [ + "sph1 = openmc.Sphere(r=sphere_radius, boundary_type='vacuum')\n", + "shield_cell = openmc.Cell(region=-sph1)\n", + "shield_cell.fill = my_material\n", + "geometry = openmc.Geometry([shield_cell])" + ] + }, + { + "cell_type": "markdown", + "id": "86190213-ce93-4bf1-bc29-19382aea35a3", + "metadata": {}, + "source": [ + "creates a simple point source" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0bb7f11f-1fb3-4682-96a8-868abcf5aecf", + "metadata": {}, + "outputs": [], + "source": [ + "source = openmc.IndependentSource()\n", + "source.space = openmc.stats.Point((0, 0, 0))\n", + "source.angle = openmc.stats.Isotropic()\n", + "source.energy = openmc.stats.Discrete([14e6], [1])\n", + "source.particles = 'neutron'" + ] + }, + { + "cell_type": "markdown", + "id": "22070cea-8518-41e9-b860-8194f6884709", + "metadata": {}, + "source": [ + "defines the simulation settings" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "42ae0573-ba79-4e50-a592-56f8d38f7c20", + "metadata": {}, + "outputs": [], + "source": [ + "settings = openmc.Settings()\n", + "settings.batches = 10\n", + "settings.inactive = 0\n", + "settings.particles = 1000\n", + "settings.source = source\n", + "settings.run_mode = 'fixed source'" + ] + }, + { + "cell_type": "markdown", + "id": "92f4f6fc-3f05-4106-af1e-6e5a7bc2414d", + "metadata": {}, + "source": [ + "builds the model combining the materials, geometry and settings into one object" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7739f6b5-4117-4247-9e2e-9554f90d2ab8", + "metadata": {}, + "outputs": [], + "source": [ + "model = openmc.model.Model(geometry, materials, settings)" + ] + }, + { + "cell_type": "markdown", + "id": "9a32428a-51ab-454e-94e3-14f42b18a1b1", + "metadata": {}, + "source": [ + "this does perform particle transport but just to get the flux and micro xs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "289778c1-f4e2-47d0-a677-b2e528ac2ed9", + "metadata": {}, + "outputs": [], + "source": [ + "flux_in_each_group, micro_xs = openmc.deplete.get_microxs_and_flux(\n", + " model=model,\n", + " domains=[shield_cell],\n", + " energies=[0, 30e6], # one energy bin from 0 to 30MeV\n", + " chain_file=openmc.config['chain_file'],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "54eb1c03-d8ca-47a3-9f3e-45ddf54d1355", + "metadata": {}, + "source": [ + "constructing the operator, note we pass in the flux and micro xs calculated earlier" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "319d6a5e-ff05-4566-b246-82fc3b232652", + "metadata": {}, + "outputs": [], + "source": [ + "operator = openmc.deplete.IndependentOperator(\n", + " materials=materials,\n", + " fluxes=[i[0] for i in flux_in_each_group],\n", + " micros=micro_xs,\n", + " reduce_chain=True, # reduced to only the isotopes present in depletable materials and their possible progeny\n", + " reduce_chain_level=5,\n", + " normalization_mode=\"source-rate\"\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "b40792d3-7352-4ac9-b571-bd1849aafc31", + "metadata": {}, + "source": [ + "We define timesteps together with the source rate to make it clearer" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "baf58807-dd7f-47b5-96de-e0659721184d", + "metadata": {}, + "outputs": [], + "source": [ + "timesteps_and_source_rates = [\n", + " (24, 1e20),\n", + " (24, 1e20),\n", + " (24, 1e20),\n", + " (24, 1e20),\n", + " (24, 1e20), # should saturate Ag110 here as it has been irradiated for over 5 halflives\n", + " (24, 1e20),\n", + " (24, 1e20),\n", + " (24, 1e20),\n", + " (24, 1e20),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + " (24, 0),\n", + "]\n", + "\n", + "# Uses list Python comprehension to get the timesteps and source_rates separately\n", + "timesteps = [item[0] for item in timesteps_and_source_rates]\n", + "source_rates = [item[1] for item in timesteps_and_source_rates]" + ] + }, + { + "cell_type": "markdown", + "id": "5beeae66-00d1-4e40-9bc3-ffb5d9bfcd5c", + "metadata": {}, + "source": [ + "construct the integrator" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6ea92d13-c257-455e-93c4-a6827059f45a", + "metadata": {}, + "outputs": [], + "source": [ + "integrator = openmc.deplete.PredictorIntegrator(\n", + " operator=operator,\n", + " timesteps=timesteps,\n", + " source_rates=source_rates,\n", + " timestep_units='s'\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "559cfddd-0fcd-4d57-a5a0-395902487749", + "metadata": {}, + "source": [ + "this runs the depltion calculations for the timesteps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a2337659-f104-4c2b-ab29-900b45888e48", + "metadata": {}, + "outputs": [], + "source": [ + "integrator.integrate()" + ] + }, + { + "cell_type": "markdown", + "id": "5f900962-bdcf-4ac3-90eb-c1e692d1a118", + "metadata": {}, + "source": [ + "Loads up the results\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bbfea41e-06b9-4ad4-ba0f-4cceba36718b", + "metadata": {}, + "outputs": [], + "source": [ + "results = openmc.deplete.Results.from_hdf5(\"depletion_results.h5\")" + ] + }, + { + "cell_type": "markdown", + "id": "c06c548b-5b24-42a0-8311-305458ea8598", + "metadata": {}, + "source": [ + "Gets the material from the 2nd timestep and shows the composition" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e13480b9-ccd8-4f3d-9faf-b8131c1c3eab", + "metadata": {}, + "outputs": [], + "source": [ + "second_time_step = results[2]\n", + "second_time_step.get_material('1')" + ] + }, + { + "cell_type": "markdown", + "id": "fa3ec083-6bee-42f7-bb0b-299f66b2f92c", + "metadata": {}, + "source": [ + "prints the atoms of Ag110 in a table for reach time step" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6046e918-c587-4760-86ac-617a7d4f100b", + "metadata": {}, + "outputs": [], + "source": [ + "times, number_of_Ag110_atoms = results.get_atoms(my_material, 'Ag110')\n", + "for time, num in zip(times, number_of_Ag110_atoms):\n", + " print(f\" Time {time}s. Number of Ag110 atoms {num}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f0bed180-59c8-4bb4-bd03-8e85e5348b8c", + "metadata": {}, + "outputs": [], + "source": [ + "# plots the number of atoms as a function of time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ed601f11-deda-4ea3-b31a-1ae0b88b0f59", + "metadata": {}, + "outputs": [], + "source": [ + "plt.plot(times, number_of_Ag110_atoms)\n", + "plt.xlabel('Time [s]')\n", + "plt.ylabel('Number of Ag110 atoms')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "351f1bc3-f867-404a-ae0d-b7c0d09f256b", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.16" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.py b/tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.py deleted file mode 100644 index 530f1f05..00000000 --- a/tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.py +++ /dev/null @@ -1,125 +0,0 @@ -# This example performs a depletion simulation using the IndependentOperator -# instead of the CoupledOperator used in the first examples. - -# This is an approximation so is less accurate but it is much faster. -# This approach performs just a single transport simulation and obtains reactions rates once. -# If the materials don't change significantly during the irradiation this is a reasonable approximation. -# Fission fule pins would perhaps require the CoupledOperator while the majority of fusion simulations are suitable for the IndependentOperator - -# More details on both Operators in the docs -# https://docs.openmc.org/en/stable/usersguide/depletion.html#transport-independent-depletion - -import openmc -import openmc.deplete -import math -import matplotlib.pyplot as plt - -# chain and cross section paths have been set on the docker image but you may want to change them -#openmc.config['chain_file']=/home/j/openmc_data/chain-endf-b8.0.xml -#openmc.config['cross_sections']=/home/j/nndc-b8.0-hdf5/endfb-viii.0-hdf5/cross_sections.xml - -# Creates a simple material -my_material = openmc.Material() -my_material.add_element('Ag', 1, percent_type='ao') -my_material.set_density('g/cm3', 10.49) - -# As we are doing a depletion simulation we must set the material volume and the .depletion to True -sphere_radius = 100 -volume_of_sphere = (4/3) * math.pi * math.pow(sphere_radius, 3) -my_material.volume = volume_of_sphere # a volume is needed so openmc can find the number of atoms in the cell/material -my_material.depletable = True # depletable = True is needed to tell openmc to update the material with each time step - -materials = openmc.Materials([my_material]) - -# makes a simple sphere surface and cell -sph1 = openmc.Sphere(r=sphere_radius, boundary_type='vacuum') -shield_cell = openmc.Cell(region=-sph1) -shield_cell.fill = my_material -geometry = openmc.Geometry([shield_cell]) - -# creates a simple point source -source = openmc.IndependentSource() -source.space = openmc.stats.Point((0, 0, 0)) -source.angle = openmc.stats.Isotropic() -source.energy = openmc.stats.Discrete([14e6], [1]) -source.particles = 'neutron' - -settings = openmc.Settings() -settings.batches = 10 -settings.inactive = 0 -settings.particles = 1000 -settings.source = source -settings.run_mode = 'fixed source' - -model = openmc.model.Model(geometry, materials, settings) - -# this does perform transport but just to get the flux and micro xs -flux_in_each_group, micro_xs = openmc.deplete.get_microxs_and_flux( - model=model, - domains=[shield_cell], - energies=[0, 30e6], # one energy bin from 0 to 30MeV - chain_file=openmc.config['chain_file'], -) - -# constructing the operator, note we pass in the flux and micro xs -operator = openmc.deplete.IndependentOperator( - materials=materials, - fluxes=[i[0] for i in flux_in_each_group], - micros=micro_xs, - reduce_chain=True, # reduced to only the isotopes present in depletable materials and their possible progeny - reduce_chain_level=5, - normalization_mode="source-rate" -) - -# We define timesteps together with the source rate to make it clearer -timesteps_and_source_rates = [ - (24, 1e20), - (24, 1e20), - (24, 1e20), - (24, 1e20), - (24, 1e20), # should saturate Ag110 here as it has been irradiated for over 5 halflives - (24, 1e20), - (24, 1e20), - (24, 1e20), - (24, 1e20), - (24, 0), - (24, 0), - (24, 0), - (24, 0), - (24, 0), - (24, 0), - (24, 0), - (24, 0), - (24, 0), - (24, 0), - (24, 0), -] - -# Uses list Python comprehension to get the timesteps and source_rates separately -timesteps = [item[0] for item in timesteps_and_source_rates] -source_rates = [item[1] for item in timesteps_and_source_rates] - -# construct the integrator -integrator = openmc.deplete.PredictorIntegrator( - operator=operator, - timesteps=timesteps, - source_rates=source_rates, - timestep_units='s' -) - -# this runs the depltion calculations for the timesteps -integrator.integrate() - -# Loads up the results -results = openmc.deplete.ResultsList.from_hdf5("depletion_results.h5") -times, number_of_Ag110_atoms = results.get_atoms(my_material, 'Ag110') - -# prints the atoms in a table -for time, num in zip(times, number_of_Ag110_atoms): - print(f" Time {time}s. Number of Ag110 atoms {num}") - -# plots the number of atoms as a function of time -plt.plot(times, number_of_Ag110_atoms) -plt.xlabel('Time [s]') -plt.ylabel('Number of Ag110 atoms') -plt.show() From 006cb3bc567470409b032ab84fb6aaef2d6b43c0 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Tue, 30 Jan 2024 18:06:39 +0000 Subject: [PATCH 5/5] added new task --- .devcontainer/Dockerfile | 19 +++--- tasks/optimal_design.ipynb | 115 +++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 tasks/optimal_design.ipynb diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index fe103f50..5f307114 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -31,15 +31,16 @@ RUN cp tasks/task_01_cross_sections/3_material_xs_plot.ipynb tasks/half-day-work RUN cp tasks/task_02_making_materials/1_example_materials_from_isotopes.ipynb tasks/half-day-workshop/task_04_example_materials_from_isotopes.ipynb RUN cp tasks/task_02_making_materials/2_example_materials_from_elements.ipynb tasks/half-day-workshop/task_05_example_materials_from_elements.ipynb RUN cp tasks/task_03_making_CSG_geometry/1_simple_csg_geometry.ipynb tasks/half-day-workshop/task_06_simple_csg_geometry.ipynb -RUN cp tasks/task_04_make_sources/1_point_source_plots.ipynb tasks/half-day-workshop/task_08_point_source_plots.ipynb -RUN cp tasks/task_04_make_sources/2_ring_source.ipynb tasks/half-day-workshop/task_09_ring_source.ipynb -RUN cp tasks/task_04_make_sources/3_plasma_source_plots.ipynb tasks/half-day-workshop/task_10_plasma_source_plots.ipynb -RUN cp tasks/task_05_CSG_cell_tally_TBR/1_example_tritium_production.ipynb tasks/half-day-workshop/task_11_example_tritium_production.ipynb -RUN cp tasks/task_06_CSG_cell_tally_DPA/1_find_dpa.ipynb tasks/half-day-workshop/task_12_find_dpa.ipynb -RUN cp tasks/task_07_CSG_cell_tally_spectra/2_example_neutron_spectra_on_cell.ipynb tasks/half-day-workshop/task_13_example_neutron_spectra_on_cell.ipynb -RUN cp tasks/task_07_CSG_cell_tally_spectra/4_example_photon_spectra.ipynb tasks/half-day-workshop/task_14_example_photon_spectra.ipynb -RUN cp tasks/task_08_CSG_mesh_tally/1_example_2d_regular_mesh_tallies.ipynb tasks/half-day-workshop/task_15_example_2d_regular_mesh_tallies.ipynb -RUN cp tasks/task_08_CSG_mesh_tally/2_example_3d_regular_mesh_tallies.ipynb tasks/half-day-workshop/task_16_example_3d_regular_mesh_tallies.ipynb +RUN cp tasks/task_04_make_sources/1_point_source_plots.ipynb tasks/half-day-workshop/task_07_point_source_plots.ipynb +RUN cp tasks/task_04_make_sources/2_ring_source.ipynb tasks/half-day-workshop/task_08_ring_source.ipynb +RUN cp tasks/task_04_make_sources/3_plasma_source_plots.ipynb tasks/half-day-workshop/task_09_plasma_source_plots.ipynb +RUN cp tasks/task_05_CSG_cell_tally_TBR/1_example_tritium_production.ipynb tasks/half-day-workshop/task_10_example_tritium_production.ipynb +RUN cp tasks/task_06_CSG_cell_tally_DPA/1_find_dpa.ipynb tasks/half-day-workshop/task_11_find_dpa.ipynb +RUN cp tasks/task_07_CSG_cell_tally_spectra/2_example_neutron_spectra_on_cell.ipynb tasks/half-day-workshop/task_12_example_neutron_spectra_on_cell.ipynb +RUN cp tasks/task_07_CSG_cell_tally_spectra/4_example_photon_spectra.ipynb tasks/half-day-workshop/task_13_example_photon_spectra.ipynb +RUN cp tasks/task_08_CSG_mesh_tally/1_example_2d_regular_mesh_tallies.ipynb tasks/half-day-workshop/task_14_example_2d_regular_mesh_tallies.ipynb +RUN cp tasks/task_10_activation_transmutation_depletion/3_full_pulse_schedule.ipynb tasks/half-day-workshop/task_15_full_pulse_schedule.ipynb +RUN cp tasks/optimal_design.ipynb tasks/half-day-workshop/optimal_design.ipynb WORKDIR /tasks diff --git a/tasks/optimal_design.ipynb b/tasks/optimal_design.ipynb new file mode 100644 index 00000000..3469339d --- /dev/null +++ b/tasks/optimal_design.ipynb @@ -0,0 +1,115 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "72324188-e724-46bf-9a3c-f7f6501ccc73", + "metadata": {}, + "source": [ + "This activity allows you to put lots of simulation skills to the test.\n", + "\n", + "We are going to simulate a tokamak where you get to decide the materials.\n", + "\n", + "The goal is to:\n", + "\n", + "maximize the Tritium Breeding Ratio\n", + "minimize the heating on the center colum\n", + "maximize the heat in the blanket" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7114fda7-b184-46d4-bbce-0d88206c573e", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ef814191-35a3-44a9-b088-f27c1bb53457", + "metadata": {}, + "outputs": [], + "source": [ + "import openmc\n", + "\n", + "# surfaces\n", + "central_column_surface_outer = openmc.ZCylinder(r=100)\n", + "central_column_surface_mid = openmc.ZCylinder(r=90)\n", + "central_column_surface_inner = openmc.ZCylinder(r=80)\n", + "\n", + "inner_sphere_surface = openmc.Sphere(r=480)\n", + "middle_sphere_surface = openmc.Sphere(r=500) \n", + "outer_sphere_surface = openmc.Sphere(r=600)\n", + "outer_outer_sphere_surface = openmc.Sphere(r=650)\n", + "edge_of_simulation_surface = openmc.Sphere(r=650, boundary_type='vacuum')\n", + "\n", + "# regions\n", + "central_column_region = -central_column_surface_inner & -edge_of_simulation_surface\n", + "central_column_coolant_region = +central_column_surface_inner & -central_column_surface_mid & -edge_of_simulation_surface\n", + "central_column_fw_region = +central_column_surface_mid & -central_column_surface_outer & -edge_of_simulation_surface\n", + "\n", + "inner_vessel_region = +central_column_surface_outer & -inner_sphere_surface\n", + "\n", + "blanket_fw_region = -middle_sphere_surface & +inner_sphere_surface & +central_column_surface_outer\n", + "blanket_coolant_region = +middle_sphere_surface & -outer_sphere_surface & +central_column_surface_outer\n", + "blanket_breeder_region = +outer_sphere_surface & -outer_outer_sphere_surface & +central_column_surface_outer\n", + "blanket_reflector_region = +outer_outer_sphere_surface & -edge_of_simulation_surface & +central_column_surface_outer\n", + "\n", + "# cells\n", + "central_column_cell = openmc.Cell(region=central_column_region)\n", + "central_column_coolant_cell = openmc.Cell(region=central_column_coolant_region)\n", + "central_column_fw_cell = openmc.Cell(region=central_column_fw_region)\n", + "\n", + "inner_vessel_cell = openmc.Cell(region=inner_vessel_region)\n", + "\n", + "blanket_fw_cell = openmc.Cell(region=blanket_fw_region)\n", + "blanket_coolant_cell = openmc.Cell(region=blanket_coolant_region)\n", + "blanket_breeder_cell = openmc.Cell(region=blanket_breeder_region)\n", + "blanket_reflector_cell = openmc.Cell(region=blanket_reflector_region)\n", + "\n", + "geometry = openmc.Geometry([\n", + " central_column_cell,\n", + " central_column_coolant_cell,\n", + " central_column_fw_cell,\n", + " inner_vessel_cell,\n", + " blanket_fw_cell,\n", + " blanket_coolant_cell,\n", + " blanket_breeder_cell,\n", + " blanket_reflector_cell,\n", + "])\n", + "\n", + "# visualization\n", + "plot = geometry.plot(basis='xz')\n", + "plot.figure.savefig('xz-cell.png')\n", + "\n", + "plot = geometry.plot(basis='xy')\n", + "plot.figure.savefig('xy-cell.png')\n", + "\n", + "plot = geometry.plot(basis='yz')\n", + "plot.figure.savefig('yz-cell.png')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.16" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}