From bb24ae57998231ac89ae5bb0f3812b7f160bac30 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sat, 31 Jul 2021 02:06:48 +0100 Subject: [PATCH 1/2] moved source to avoid lost particles --- ...ronics_geometry_with_cell_tally_heat.ipynb | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/tasks/task_11_CAD_cell_tally_heat/1_simulate_CAD_neutronics_geometry_with_cell_tally_heat.ipynb b/tasks/task_11_CAD_cell_tally_heat/1_simulate_CAD_neutronics_geometry_with_cell_tally_heat.ipynb index b6e03690..6cb0142d 100644 --- a/tasks/task_11_CAD_cell_tally_heat/1_simulate_CAD_neutronics_geometry_with_cell_tally_heat.ipynb +++ b/tasks/task_11_CAD_cell_tally_heat/1_simulate_CAD_neutronics_geometry_with_cell_tally_heat.ipynb @@ -69,7 +69,6 @@ "# but the curved shape does slow down the simulation due to the large number of facets need\n", "# so it has been removed to speed up the example\n", "\n", - "my_reactor.rotation_angle=360 # this is a small \"feature\" which we will fix soon\n", "my_reactor.show()" ] }, @@ -91,7 +90,7 @@ "# initialises a new source object\n", "source = openmc.Source()\n", "# the distribution of radius is just a single value\n", - "radius = openmc.stats.Discrete([300], [1])\n", + "radius = openmc.stats.Discrete([400], [1])\n", "# the distribution of source z values is just a single value\n", "z_values = openmc.stats.Discrete([0], [1])\n", "# the distribution of source azimuthal angles values is a uniform distribution between 0 and 2 Pi\n", @@ -108,7 +107,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This section forms the neutronics model by combining the 3D model, the plasma source and some assigned materials. Additionally, the tallies to record the heating are specified. There are a few different methods of converting a CAD model into a neutronics model. The 'pymoab' method is the only open-source automated method that can also convert splines." + "This section forms the neutronics model by combining the 3D model, the plasma source and some assigned materials. Additionally, the tallies to record the heating are specified. There are a few different methods of converting a CAD model into a neutronics model." ] }, { @@ -130,8 +129,38 @@ " 'tf_coil_mat': 'copper',\n", " 'blanket_mat': 'Li4SiO4',\n", " }\n", - ")\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This next step might take a while to create so consider this an optional step.\n", "\n", + "The NeutronicsModel.export_html() method creates a 3D diagram of the mode and includes sample points for the source." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "neutronics_model.export_html()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The model can now be simulated in OpenMC" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "neutronics_model.simulate()" ] }, @@ -177,7 +206,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.9.5" } }, "nbformat": 4, From a08171f7f84670f3e081687dda2f5f53eba85af7 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sat, 31 Jul 2021 02:26:46 +0100 Subject: [PATCH 2/2] updated to use show() instead of .soild --- ...aking_shapes_into_a_neutronics_model.ipynb | 115 +++++++++-------- ...g_components_into_a_neutronics_model.ipynb | 121 +++++++++--------- ...ric_reactors_into_a_neutronics_model.ipynb | 89 +++++++------ 3 files changed, 161 insertions(+), 164 deletions(-) diff --git a/tasks/task_12_CAD_mesh_fast_flux/1_making_shapes_into_a_neutronics_model.ipynb b/tasks/task_12_CAD_mesh_fast_flux/1_making_shapes_into_a_neutronics_model.ipynb index cb2d2b89..8968eafb 100644 --- a/tasks/task_12_CAD_mesh_fast_flux/1_making_shapes_into_a_neutronics_model.ipynb +++ b/tasks/task_12_CAD_mesh_fast_flux/1_making_shapes_into_a_neutronics_model.ipynb @@ -2,7 +2,6 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, "source": [ "# Heating Mesh Tally on CAD geometry made from Shapes\n", "\n", @@ -11,20 +10,19 @@ "The Shapes made include a breeder blanket, PF coil and a central column shield.\n", "\n", "2D and 3D Meshes tally are then simulated to show nuclear heating, flux and tritium_production across the model." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This makes a 3D geometry and material for PF coil" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import paramak\n", "\n", @@ -39,21 +37,21 @@ " material_tag = 'pf_coil_material'\n", ")\n", "\n", - "pf_coil.solid" - ] + "pf_coil.show()" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This makes a 3D geometry and material for the centre column" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "center_column = paramak.RotateMixedShape(\n", " points=[\n", @@ -67,21 +65,21 @@ " material_tag = 'center_column_material'\n", ")\n", "\n", - "center_column.solid" - ] + "center_column.show()" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This makes a 3D geometry and material for breeder blanket. The azimuth_placement_angle argument is used to repeat the geometry around the Z axis at specified angles." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "blanket = paramak.RotateSplineShape(\n", " points=[\n", @@ -100,39 +98,39 @@ " material_tag = 'blanket_material'\n", ")\n", "\n", - "blanket.solid" - ] + "blanket.show()" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This makes a reactor object from the three components" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "my_reactor = paramak.Reactor([blanket, pf_coil,center_column])\n", "\n", "my_reactor.solid" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "At this stage we can export the reactor geometry as stp files and make them avaialbe from download and viewing in FreeCAD." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "my_reactor.export_stp()\n", "\n", @@ -141,45 +139,42 @@ "display(FileLink('pf_coil.stp'))\n", "display(FileLink('center_column.stp'))\n", "display(FileLink('Graveyard.stp'))" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The next section defines the materials. This can be done using openmc.Materials or in this case strings that look up materials from the neutronics material maker." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from neutronics_material_maker import Material\n", "\n", - "mat1 = Material(material_name='Li4SiO4',\n", - " material_tag='blanket_material')\n", + "mat1 = Material.from_library(name='Li4SiO4')\n", "\n", - "mat2 = Material(material_name='copper',\n", - " material_tag='pf_coil_material')\n", + "mat2 = Material.from_library(name='copper')\n", "\n", - "mat3 = Material(material_name='WC',\n", - " material_tag='center_column_material')" - ] + "mat3 = Material.from_library(name='WC')" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This next step makes a simple point source" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import openmc\n", "\n", @@ -194,22 +189,24 @@ "\n", "# sets the energy distribution to 100% 14MeV neutrons\n", "source.energy = openmc.stats.Discrete([14e6], [1])" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This next section combines the geometry with the materials and specifies a few mesh tallies" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ - "neutronics_model = paramak.NeutronicsModel(\n", + "import paramak_neutronics\n", + "\n", + "neutronics_model = paramak_neutronics.NeutronicsModel(\n", " geometry=my_reactor,\n", " mesh_tally_2d=['heating', 'flux', '(n,Xt)'],\n", " mesh_tally_3d=['heating', 'flux', '(n,Xt)'],\n", @@ -224,23 +221,23 @@ ")\n", "\n", "neutronics_model.simulate()" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The next section produces download links for:\n", "\n", "- vtk files that contain the 3D mesh results (open with Paraview)\n", "- png images that show the resuls of the 2D mesh tally" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from IPython.display import FileLink\n", "display(FileLink('heating_on_3D_mesh.vtk'))\n", @@ -255,7 +252,9 @@ "display(FileLink('tritium_production_on_2D_mesh_yz.png'))\n", "display(FileLink('tritium_production_on_2D_mesh_xz.png'))\n", "display(FileLink('tritium_production_on_2D_mesh_yz.png'))" - ] + ], + "outputs": [], + "metadata": {} } ], "metadata": { @@ -279,4 +278,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/tasks/task_12_CAD_mesh_fast_flux/2_making_components_into_a_neutronics_model.ipynb b/tasks/task_12_CAD_mesh_fast_flux/2_making_components_into_a_neutronics_model.ipynb index 3ba6539a..076b0aa5 100644 --- a/tasks/task_12_CAD_mesh_fast_flux/2_making_components_into_a_neutronics_model.ipynb +++ b/tasks/task_12_CAD_mesh_fast_flux/2_making_components_into_a_neutronics_model.ipynb @@ -2,7 +2,6 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, "source": [ "# Heating Mesh Tally on CAD geometry made from Components\n", "\n", @@ -11,20 +10,19 @@ "The Component made include a breeder blanket, PF coil and a central column shield.\n", "\n", "2D and 3D Meshes tally are then simulated to show nuclear heating, flux and tritium_production across the model." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This makes a 3D geometry and material for PF coil" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import paramak\n", "\n", @@ -37,21 +35,21 @@ " material_tag = 'pf_coil_material'\n", ")\n", "\n", - "pf_coil.solid" - ] + "pf_coil.show()" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This makes a 3D geometry and material for the centre column" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "center_column = paramak.CenterColumnShieldHyperbola(\n", " height=1200,\n", @@ -62,21 +60,21 @@ " material_tag = 'center_column_material'\n", ")\n", "\n", - "center_column.solid" - ] + "center_column.show()" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This makes a 3D geometry and material for breeder blanket. The azimuth_placement_angle argument is used to repeat the geometry around the Z axis at specified angles." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "blanket = paramak.BlanketConstantThicknessArcH(\n", " inner_mid_point=(500, 0),\n", @@ -89,39 +87,39 @@ " material_tag = 'blanket_material'\n", ")\n", "\n", - "blanket.solid" - ] + "blanket.show()" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This makes a reactor object from the three components" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "my_reactor = paramak.Reactor([blanket, pf_coil,center_column])\n", "\n", - "my_reactor.solid" - ] + "my_reactor.show()" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "At this stage we can export the reactor geometry as stp files and make them avaialbe from download and viewing in FreeCAD." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "my_reactor.export_stp()\n", "\n", @@ -130,45 +128,42 @@ "display(FileLink('pf_coil.stp'))\n", "display(FileLink('center_column.stp'))\n", "display(FileLink('Graveyard.stp'))" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The next section defines the materials. This can be done using openmc.Materials or in this case strings that look up materials from the neutronics material maker." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from neutronics_material_maker import Material\n", "\n", - "mat1 = Material(material_name='Li4SiO4',\n", - " material_tag='blanket_material')\n", + "mat1 = Material.from_library(name='Li4SiO4')\n", "\n", - "mat2 = Material(material_name='copper',\n", - " material_tag='pf_coil_material')\n", + "mat2 = Material.from_library(name='copper')\n", "\n", - "mat3 = Material(material_name='WC',\n", - " material_tag='center_column_material')" - ] + "mat3 = Material.from_library(name='WC')" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This next step makes a simple point source." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import openmc\n", "\n", @@ -183,22 +178,24 @@ "\n", "# sets the energy distribution to 100% 14MeV neutrons\n", "source.energy = openmc.stats.Discrete([14e6], [1])" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This next section combines the geometry with the materials and specifies a few mesh tallies" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ - "neutronics_model = paramak.NeutronicsModel(\n", + "import paramak_neutronics\n", + "\n", + "neutronics_model = paramak_neutronics.NeutronicsModel(\n", " geometry=my_reactor,\n", " cell_tallies=['heating', 'flux', 'TBR', 'spectra'],\n", " mesh_tally_2d=['heating', 'flux', '(n,Xt)'],\n", @@ -214,23 +211,23 @@ ")\n", "\n", "neutronics_model.simulate()" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The next section produces download links for:\n", "\n", "- vtk files that contain the 3D mesh results (open with Paraview)\n", "- png images that show the resuls of the 2D mesh tally" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from IPython.display import FileLink\n", "display(FileLink('heating_on_3D_mesh.vtk'))\n", @@ -245,14 +242,16 @@ "display(FileLink('tritium_production_on_2D_mesh_yz.png'))\n", "display(FileLink('tritium_production_on_2D_mesh_xz.png'))\n", "display(FileLink('tritium_production_on_2D_mesh_yz.png'))" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "source": [], "outputs": [], - "source": [] + "metadata": {} } ], "metadata": { @@ -276,4 +275,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/tasks/task_12_CAD_mesh_fast_flux/3_making_parametric_reactors_into_a_neutronics_model.ipynb b/tasks/task_12_CAD_mesh_fast_flux/3_making_parametric_reactors_into_a_neutronics_model.ipynb index da712f8d..cb12eda7 100644 --- a/tasks/task_12_CAD_mesh_fast_flux/3_making_parametric_reactors_into_a_neutronics_model.ipynb +++ b/tasks/task_12_CAD_mesh_fast_flux/3_making_parametric_reactors_into_a_neutronics_model.ipynb @@ -2,14 +2,13 @@ "cells": [ { "cell_type": "markdown", - "metadata": {}, "source": [ "# This task is not quite ready as we don't have an open source route for simulating geometry that requires imprinting and merging. However this simulation can be carried out using Trelis." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "# Heating Mesh Tally on CAD geometry made from Components\n", "\n", @@ -18,20 +17,19 @@ "The Component made include a breeder blanket, PF coil and a central column shield.\n", "\n", "2D and 3D Meshes tally are then simulated to show nuclear heating, flux and tritium_production across the model." - ] + ], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This section makes the 3d geometry for the entire reactor from a input parameters." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import paramak\n", "\n", @@ -56,21 +54,21 @@ "# see the documentation for more details \n", "# https://paramak.readthedocs.io/en/main/paramak.parametric_reactors.html\n", "\n", - "my_reactor.solid" - ] + "my_reactor.show()" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The next section defines the materials. This can be done using openmc.Materials or in this case strings that look up materials from the neutronics material maker." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "my_reactor.export_stp()\n", "\n", @@ -79,45 +77,42 @@ "display(FileLink('pf_coil.stp'))\n", "display(FileLink('center_column.stp'))\n", "display(FileLink('Graveyard.stp'))" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The next section defines the materials. This can be done using openmc.Materials or in this case strings that look up materials from the neutronics material maker." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from neutronics_material_maker import Material\n", "\n", - "mat1 = Material(material_name='Li4SiO4',\n", - " material_tag='blanket_material')\n", + "mat1 = Material.from_library(name='Li4SiO4')\n", "\n", - "mat2 = Material(material_name='copper',\n", - " material_tag='pf_coil_material')\n", + "mat2 = Material.from_library(name='copper')\n", "\n", - "mat3 = Material(material_name='WC',\n", - " material_tag='center_column_material')" - ] + "mat3 = Material.from_library(name='WC')" + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This next step makes a simple point source." - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "import openmc\n", "\n", @@ -132,22 +127,24 @@ "\n", "# sets the energy distribution to 100% 14MeV neutrons\n", "source.energy = openmc.stats.Discrete([14e6], [1])" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "This next section combines the geometry with the materials and specifies a few mesh tallies" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ - "neutronics_model = paramak.NeutronicsModel(\n", + "import paramak_neutronics\n", + "\n", + "neutronics_model = paramak_neutronics.NeutronicsModel(\n", " geometry=my_reactor,\n", " cell_tallies=['heating', 'flux', 'TBR', 'spectra'],\n", " mesh_tally_2d=['heating', 'flux', '(n,Xt)'],\n", @@ -165,23 +162,23 @@ "\n", "# You will need to have Trelis installed to run this command\n", "neutronics_model.simulate()" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "markdown", - "metadata": {}, "source": [ "The next section produces download links for:\n", "\n", "- vtk files that contain the 3D mesh results (open with Paraview)\n", "- png images that show the resuls of the 2D mesh tally" - ] + ], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], "source": [ "from IPython.display import FileLink\n", "display(FileLink('heating_on_3D_mesh.vtk'))\n", @@ -196,14 +193,16 @@ "display(FileLink('tritium_production_on_2D_mesh_yz.png'))\n", "display(FileLink('tritium_production_on_2D_mesh_xz.png'))\n", "display(FileLink('tritium_production_on_2D_mesh_yz.png'))" - ] + ], + "outputs": [], + "metadata": {} }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "source": [], "outputs": [], - "source": [] + "metadata": {} } ], "metadata": { @@ -227,4 +226,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file