Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding icf detector examples #237

Merged
merged 5 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions tasks/task_01_cross_sections/3_material_xs_plot.ipynb

Large diffs are not rendered by default.

96 changes: 71 additions & 25 deletions tasks/task_03_making_CSG_geometry/1_simple_csg_geometry.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -22,6 +23,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -37,7 +39,6 @@
"outputs": [],
"source": [
"import openmc\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# example surfaces\n",
"inner_sphere_surface = openmc.Sphere(r=500)\n",
Expand All @@ -50,16 +51,23 @@
"blanket_cell = openmc.Cell(region=blanket_region)\n",
"\n",
"# makes a universe to cotain all the cells\n",
"universe = openmc.Universe(cells=[blanket_cell]) \n",
"geometry = openmc.Geometry([blanket_cell]) \n",
"\n",
"# shows the plots, as the geometry is symmetrical the plots look the same\n",
"color_assignment = {blanket_cell: 'blue'}\n",
"plt.show(universe.plot(basis='xz', color_by='material', colors=color_assignment))\n",
"plt.show(universe.plot(basis='xy', color_by='material', colors=color_assignment))\n",
"plt.show(universe.plot(basis='yz', color_by='material', colors=color_assignment))"
"\n",
"plot = geometry.plot(basis='xz', colors=color_assignment)\n",
"plot.figure.savefig('xz-cell.png')\n",
"\n",
"plot = geometry.plot(basis='xy', colors=color_assignment)\n",
"plot.figure.savefig('xy-cell.png')\n",
"\n",
"plot = geometry.plot(basis='yz', colors=color_assignment)\n",
"plot.figure.savefig('yz-cell.png')"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -73,7 +81,7 @@
"outputs": [],
"source": [
"# example surfaces\n",
"inner_sphere_surface = openmc.Sphere(r=480)\n",
"inner_sphere_surface = openmc.Sphere(r=400)\n",
"middle_sphere_surface = openmc.Sphere(r=500) # note the extra surface\n",
"outer_sphere_surface = openmc.Sphere(r=600)\n",
"\n",
Expand All @@ -87,16 +95,23 @@
"firstwall_cell = openmc.Cell(region=firstwall_region)\n",
"\n",
"# there are now two cells in the list\n",
"universe = openmc.Universe(cells=[blanket_cell, firstwall_cell]) \n",
"geometry = openmc.Geometry([blanket_cell, firstwall_cell]) \n",
"\n",
"# shows the plots, which still look the same for all directions\n",
"color_assignment = {blanket_cell: 'blue', firstwall_cell: 'red'}\n",
"plt.show(universe.plot(basis='xz', color_by='material', colors=color_assignment))\n",
"plt.show(universe.plot(basis='xy', color_by='material', colors=color_assignment))\n",
"plt.show(universe.plot(basis='yz', color_by='material', colors=color_assignment))"
"\n",
"plot = geometry.plot(basis='xz', colors=color_assignment)\n",
"plot.figure.savefig('xz-cell.png')\n",
"\n",
"plot = geometry.plot(basis='xy', colors=color_assignment)\n",
"plot.figure.savefig('xy-cell.png')\n",
"\n",
"plot = geometry.plot(basis='yz', colors=color_assignment)\n",
"plot.figure.savefig('yz-cell.png')"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -108,6 +123,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -121,9 +137,9 @@
"outputs": [],
"source": [
"# surfaces\n",
"inner_sphere_surface = openmc.Sphere(r=480)\n",
"inner_sphere_surface = openmc.Sphere(r=400)\n",
"middle_sphere_surface = openmc.Sphere(r=500)\n",
"outer_sphere_surface = openmc.Sphere(r=600, boundary_type='vacuum') # note the extra keyword\n",
"outer_sphere_surface = openmc.Sphere(r=600, boundary_type='vacuum') # note the extra keyword, last surface of the geometry\n",
"\n",
"# regions\n",
"blanket_region = +middle_sphere_surface & -outer_sphere_surface\n",
Expand All @@ -133,17 +149,24 @@
"# cells\n",
"blanket_cell = openmc.Cell(region=blanket_region)\n",
"firstwall_cell = openmc.Cell(region=firstwall_region)\n",
"inner_vessel_cell = openmc.Cell(region=inner_vessel_region) # here as the cell is th new void cell\n",
"inner_vessel_cell = openmc.Cell(region=inner_vessel_region) # here as the cell is th new void cell, the other cells will be assigned materials in the next step\n",
"\n",
"universe = openmc.Universe(cells=[blanket_cell, firstwall_cell, inner_vessel_cell]) \n",
"geometry = openmc.Geometry([blanket_cell, firstwall_cell, inner_vessel_cell])\n",
"\n",
"color_assignment = {blanket_cell: 'blue', firstwall_cell: 'red', inner_vessel_cell:'grey'}\n",
"plt.show(universe.plot(basis='xz', color_by='material', colors=color_assignment))\n",
"plt.show(universe.plot(basis='xy', color_by='material', colors=color_assignment))\n",
"plt.show(universe.plot(basis='yz', color_by='material', colors=color_assignment))"
"\n",
"plot = geometry.plot(basis='xz', colors=color_assignment)\n",
"plot.figure.savefig('xz-cell.png')\n",
"\n",
"plot = geometry.plot(basis='xy', colors=color_assignment)\n",
"plot.figure.savefig('xy-cell.png')\n",
"\n",
"plot = geometry.plot(basis='yz', colors=color_assignment)\n",
"plot.figure.savefig('yz-cell.png')"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -160,7 +183,7 @@
"metadata": {},
"outputs": [],
"source": [
"inner_sphere_surface = openmc.Sphere(r=480)\n",
"inner_sphere_surface = openmc.Sphere(r=400)\n",
"middle_sphere_surface = openmc.Sphere(r=500)\n",
"outer_sphere_surface = openmc.Sphere(r=600)\n",
"\n",
Expand All @@ -187,18 +210,25 @@
"inner_vessel_cell = openmc.Cell(region=inner_vessel_region)\n",
"# note there is no material assignment here as the cell a void cell\n",
"\n",
"universe = openmc.Universe(cells=[blanket_cell, firstwall_cell, inner_vessel_cell]) \n",
"geometry = openmc.Geometry([blanket_cell, firstwall_cell, inner_vessel_cell]) \n",
"\n",
"# note the new color scheme is based on materials not cells\n",
"# note the new color scheme is uses material objects as dictionary keys and not not cell objects\n",
"color_assignment = {lithium_mat: 'green', tungsten_mat: 'yellow'}\n",
"\n",
"# note the additional argument color_by, normally this defaults to 'cell'\n",
"plt.show(universe.plot(basis='xz', color_by='material', colors=color_assignment))\n",
"plt.show(universe.plot(basis='xy', color_by='material', colors=color_assignment))\n",
"plt.show(universe.plot(basis='yz', color_by='material', colors=color_assignment))"
"\n",
"plot = geometry.plot(basis='xz', color_by='material', colors=color_assignment)\n",
"plot.figure.savefig('xz-material.png')\n",
"\n",
"plot = geometry.plot(basis='xy', color_by='material', colors=color_assignment)\n",
"plot.figure.savefig('xy-material.png')\n",
"\n",
"plot = geometry.plot(basis='yz', color_by='material', colors=color_assignment)\n",
"plot.figure.savefig('yz-material.png')"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -209,8 +239,24 @@
"- Assigining materials to cells.\n",
"- Defining the complete geometry including void cells.\n",
"- Defining the edge of the model with the boundary keyword.\n",
"- Coloring models by cell or by material."
"- Coloring models by cell or by material.\n",
"\n",
"Additonal notes.\n",
"\n",
"The geometry.plot method has lots of useful arguments that can be passed in.\n",
"\n",
"Try adding ```outline=True``` to the geometry.plot() method and spot the difference.\n",
"\n",
"Take a look at the documentation for more information\n",
"\n",
"https://docs.openmc.org/en/latest/pythonapi/generated/openmc.Geometry.html#openmc.Geometry.plot"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
Expand All @@ -229,7 +275,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.8.13"
}
},
"nbformat": 4,
Expand Down
Loading
Loading