Skip to content

Commit

Permalink
Merge pull request #210 from fusion-energy/develop
Browse files Browse the repository at this point in the history
updates from develop
  • Loading branch information
shimwell authored May 31, 2023
2 parents 78a85c6 + 6358094 commit 7dbaa10
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 55 deletions.
4 changes: 2 additions & 2 deletions tasks/task_01_cross_sections/4_Doppler_broadening.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"\n",
"mt_number = REACTION_MT[\"(n,total)\"] # looks up the MT number for the total reaction\n",
"\n",
"h5_file = f\"/home/jshimwell/WMP_Library/WMP_Library/074186.h5\" # 074186 is W186\n",
"h5_file = f\"WMP_Library/074186.h5\" # 074186 is W186\n",
"\n",
"isotope_multipole = openmc.data.WindowedMultipole.from_hdf5(h5_file) # loads up the WMP cross section file\n",
"\n",
Expand Down Expand Up @@ -93,7 +93,7 @@
"\n",
"mt_number = REACTION_MT[\"(n,total)\"] # looks up the MT number for the total reaction\n",
"\n",
"h5_file = f\"/home/jshimwell/WMP_Library/WMP_Library/026056.h5\" # 026056 is Fe56\n",
"h5_file = f\"WMP_Library/026056.h5\" # 026056 is Fe56\n",
"\n",
"isotope_multipole = openmc.data.WindowedMultipole.from_hdf5(h5_file) # loads up the WMP cross section file\n",
"\n",
Expand Down
80 changes: 40 additions & 40 deletions tasks/task_08_CSG_mesh_tally/1_example_2d_mesh_tallies.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Part 1 - 2D mesh tallies\n",
"\n",
Expand All @@ -14,31 +15,32 @@
"This can form a 2D slice of the neutron interactions throughout the model.\n",
"\n",
"This notebook allows users to create a simple geometry from a few different materials and plot the results of a 2D regular mesh tally applied to the geometry."
],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import IFrame\n",
"IFrame(src=\"https://www.youtube.com/embed/KYIsDjip1nQ\", width=560, height=340)"
],
"outputs": [],
"metadata": {}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This code block defines the model geometry, materials, neutron source and regular mesh tally. Run the cell to see the model geometry.\n",
"\n",
"Observe how a 2D mesh is achieved by creating a 3D mesh with a thickness of one mesh cell in one dimension."
],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import openmc\n",
"import matplotlib.pyplot as plt\n",
Expand Down Expand Up @@ -112,20 +114,20 @@
"\n",
"# combines the geometry, materials, settings and tallies to create a neutronics model\n",
"model = openmc.model.Model(my_geometry, my_materials, my_settings, my_tallies)\n"
],
"outputs": [],
"metadata": {}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The next code block performs the simulation which tallies neutron flux on the mesh, and loads the results for inspection."
],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# deletes old files\n",
"!rm summary.h5\n",
Expand All @@ -136,20 +138,20 @@
"\n",
"# open the results file\n",
"results = openmc.StatePoint(output_filename)"
],
"outputs": [],
"metadata": {}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This code block filters the results to show the neutron flux recorded by the mesh tally."
],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# access the flux tally\n",
"my_tally = results.get_tally(scores=['flux'])\n",
Expand All @@ -161,24 +163,24 @@
"# when plotting the 2d data, added the extent is required.\n",
"# otherwise the plot uses the index of the 2d data arrays\n",
"# as the x y axis\n",
"plt.show(fig.imshow(my_slice.mean, extent=[-200,200,-200,200]))\n",
"plt.show(fig.imshow(my_slice.mean, extent=mesh.bounding_box.extent['xz']))\n",
"\n",
"# notice that neutrons are produced and emitted isotropically from a point source.\n",
"# There is a slight increase in flux within the neutron multiplier."
],
"outputs": [],
"metadata": {}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This code block filters the results to show the neutron absorption recorded by the mesh tally."
],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# access the absorption tally\n",
"my_tally = results.get_tally(scores=['absorption'])\n",
Expand All @@ -190,23 +192,23 @@
"# when plotting the 2d data, added the extent is required.\n",
"# otherwise the plot uses the index of the 2d data arrays\n",
"# as the x y axis\n",
"plt.show(fig.imshow(my_slice.mean, extent=[-200,200,-200,200]))\n",
"plt.show(fig.imshow(my_slice.mean, extent=mesh.bounding_box.extent['xz']))\n",
"\n",
"# notice that neutrons are being absorpted on the left hand side of the model"
],
"outputs": [],
"metadata": {}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This code block filters the results to show the neutron multiplication recorded by the mesh tally."
],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# access the neutron multiplication tally\n",
"my_tally = results.get_tally(scores=['(n,2n)'])\n",
Expand All @@ -218,16 +220,16 @@
"# when plotting the 2d data, added the extent is required.\n",
"# otherwise the plot uses the index of the 2d data arrays\n",
"# as the x y axis\n",
"plt.show(fig.imshow(my_slice.mean, extent=[-200,200,-200,200]))\n",
"plt.show(fig.imshow(my_slice.mean, extent=mesh.bounding_box.extent['xz']))\n",
"\n",
"# notice that neutrons are being muliplied on the right hand side of the model"
],
"outputs": [],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Bonus information\n",
"# The 2D mesh tally is currently recording all interactions in the 3rd dimention (z).\n",
Expand All @@ -240,18 +242,16 @@
"mesh.dimension = [100, 1, 100] # only one entry in the Y direction\n",
"mesh.lower_left = [-200, -0.5, -200] # Y thickness is now smaller\n",
"mesh.upper_right = [200, 0.5, 200] # Y thickness is now smaller"
],
"outputs": [],
"metadata": {}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Learning Outcomes for Part 1:**\n",
"\n",
"- Mesh tallies can be used to visualise neutron interactions spatially throughout geometry."
],
"metadata": {}
]
}
],
"metadata": {
Expand All @@ -273,9 +273,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.10.10"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
}
5 changes: 2 additions & 3 deletions tasks/task_09_CSG_dose_tallies/5_mesh_dose_from_neutrons.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@

data_slice = data_slice * neutrons_per_second * pico_to_milli


plot_1 = plt.imshow(
data_slice,
extent=mesh.get_mpl_plot_extent(view_direction="x"),
extent=mesh.bounding_box.extent['xy'],
interpolation=None,
norm=LogNorm(
vmin=1e-12, # trims out the lower section of the colors
Expand All @@ -134,7 +133,7 @@
linestyles="solid",
levels=levels,
linewidths=2.0,
extent=my_geometry.get_mpl_plot_extent(view_direction="x"),
extent=my_geometry.bounding_box.extent['xy'],
)
xlabel, ylabel = my_geometry.get_axis_labels(view_direction="x")
plt.xlabel(xlabel)
Expand Down
Loading

0 comments on commit 7dbaa10

Please sign in to comment.