diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8a3715f7..8dcaa041 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -40,7 +40,8 @@ RUN cp tasks/task_07_CSG_cell_tally_spectra/2_example_neutron_spectra_on_cell.ip 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/task_16_optimal_design.ipynb +RUN cp tasks/task_17_design_tasks/1_optimal_design.ipynb tasks/half-day-workshop/task_16_optimal_design.ipynb +RUN cp tasks/task_17_design_tasks/1_optimal_design_with_hints.ipynb tasks/half-day-workshop/task_16_optimal_designs_with_hints.ipynb WORKDIR /tasks diff --git a/tasks/task_17_design_tasks/1_optimal_design.ipynb b/tasks/task_17_design_tasks/1_optimal_design.ipynb new file mode 100644 index 00000000..f097b73b --- /dev/null +++ b/tasks/task_17_design_tasks/1_optimal_design.ipynb @@ -0,0 +1,425 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "72324188-e724-46bf-9a3c-f7f6501ccc73", + "metadata": {}, + "source": [ + "This activity allows you to put you neutronics knowledge 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\n", + "\n", + "I recommend plotting the cross sections before you make your choices.\n", + "\n", + "The [example](https://github.com/fusion-energy/neutronics-workshop/blob/main/tasks/task_01_cross_sections/3_material_xs_plot.ipynb) for plotting cross sections might be useful." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7114fda7-b184-46d4-bbce-0d88206c573e", + "metadata": {}, + "outputs": [], + "source": [ + "import openmc" + ] + }, + { + "cell_type": "markdown", + "id": "6d951d32", + "metadata": {}, + "source": [ + "# Task 1 - enter the names of materials" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fbff5883", + "metadata": {}, + "outputs": [], + "source": [ + "# options for coolant\n", + "\n", + "water = openmc.Material(name='water')\n", + "water.add_element('H', 2)\n", + "water.add_element('O', 1)\n", + "water.set_density('g/cm3', 1)\n", + "\n", + "helium = openmc.Material(name='helium')\n", + "helium.add_element('He', 1)\n", + "helium.set_density('g/cm3', 0.0014)\n", + "\n", + "super_critical_co2 = openmc.Material(name='super critical co2')\n", + "super_critical_co2.add_element('C', 1)\n", + "super_critical_co2.add_element('O', 2)\n", + "super_critical_co2.set_density('g/cm3', 0.001)\n", + "\n", + "\n", + "# options for first wall\n", + "\n", + "tungsten = openmc.Material(name=# your code here)\n", + "tungsten.add_element('W', 1, percent_type='wo')\n", + "tungsten.set_density('g/cm3', 19.2)\n", + "\n", + "steel = openmc.Material(name=# your code here)\n", + "steel.add_element('Fe', 0.95, percent_type='wo')\n", + "steel.add_element('C', 0.95, percent_type='wo')\n", + "steel.set_density('g/cm3', 1)\n", + "\n", + "silicon_carbide = openmc.Material(name=# your code here)\n", + "silicon_carbide.add_element('Si', 1)\n", + "silicon_carbide.add_element('C', 1)\n", + "silicon_carbide.set_density('g/cm3', 3.21)\n", + "\n", + "zirconium = openmc.Material(name=# your code here)\n", + "zirconium.add_element('Zr', 1, percent_type='wo')\n", + "zirconium.set_density('g/cm3', 6.49)\n", + "\n", + "# options for reflector\n", + "\n", + "beryllium = openmc.Material(name='mat_reflector')\n", + "beryllium.add_element('Be', 1, percent_type='wo')\n", + "beryllium.set_density('g/cm3', 1.85)\n", + "\n", + "tungsten = openmc.Material(name='mat_reflector')\n", + "tungsten.add_element('W', 1, percent_type='wo')\n", + "tungsten.set_density('g/cm3', 19.2)\n", + "\n", + "graphite = openmc.Material(name='mat_reflector')\n", + "graphite.add_element('C', 1, percent_type='wo')\n", + "graphite.set_density('g/cm3', 2.2)\n", + "\n", + "# options for breeder\n", + "\n", + "# note you can change the enrichment\n", + "lithium_lead = openmc.Material(name=# your code here)\n", + "lithium_lead.add_element('Pb', 84.2, percent_type='ao')\n", + "lithium_lead.add_element('Li', 15.8, percent_type='ao', enrichment=90.0, enrichment_target='Li6', enrichment_type='ao')\n", + "lithium_lead.set_density('g/cm3', 9.5)\n", + "\n", + "# note you can change the enrichment\n", + "lithium_orthosilicate = openmc.Material(name=# your code here)\n", + "lithium_orthosilicate.add_element('Si', 4, percent_type='ao')\n", + "lithium_orthosilicate.add_element('O', 1, percent_type='ao')\n", + "lithium_orthosilicate.add_element('Li', 4, percent_type='ao', enrichment=50.0, enrichment_target='Li6', enrichment_type='ao')\n", + "lithium_orthosilicate.set_density('g/cm3', 2.2)\n", + "\n", + "# note you can change the enrichment\n", + "lithium_titanate = openmc.Material(name=# your code here)\n", + "lithium_titanate.add_element('O', 12, percent_type='ao')\n", + "lithium_titanate.add_element('Ti', 5, percent_type='ao')\n", + "lithium_titanate.add_element('Li', 4, percent_type='ao', enrichment=40.0, enrichment_target='Li6', enrichment_type='ao')\n", + "lithium_titanate.set_density('g/cm3', 2.4)\n", + "\n", + "# note you can change the enrichment\n", + "liquid_lithium = openmc.Material(name=# your code here)\n", + "liquid_lithium.add_element('Li', 1, percent_type='ao', enrichment=7.0, enrichment_target='Li6', enrichment_type='ao')\n", + "liquid_lithium.set_density('g/cm3', 0.5)\n", + "\n", + "# conductor material\n", + "\n", + "mat_conductor = openmc.Material(name='mat_conductor')\n", + "mat_conductor.add_element('Nb', 1, percent_type='ao')\n", + "mat_conductor.add_element('Sn', 3, percent_type='ao')\n", + "mat_conductor.set_density('g/cm3', 8.96)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "id": "09802e51", + "metadata": {}, + "source": [ + "# Task 2 - plot the tritium production cross sections of all the breeder options " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7f1a5eed", + "metadata": {}, + "outputs": [], + "source": [ + "# your code goes here" + ] + }, + { + "cell_type": "markdown", + "id": "72adc5fd", + "metadata": {}, + "source": [ + "# Task 3 - plot the absorption of all the coolants and first wall options" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2df73f5b", + "metadata": {}, + "outputs": [], + "source": [ + "# your code goes here" + ] + }, + { + "cell_type": "markdown", + "id": "d363f4ab", + "metadata": {}, + "source": [ + "# Task 4 - select your materials" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a2c3facd", + "metadata": {}, + "outputs": [], + "source": [ + "# put in your chosen material option\n", + "my_materials = openmc.Materials([mat_conductor, # your code here])" + ] + }, + { + "cell_type": "markdown", + "id": "a06692a5", + "metadata": {}, + "source": [ + "# Task 3 - Fill the cells with the materials" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ef814191-35a3-44a9-b088-f27c1bb53457", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "# surfaces\n", + "central_column_surface_outer = openmc.ZCylinder(r=100)\n", + "central_column_surface_mid = openmc.ZCylinder(r=95)\n", + "central_column_surface_inner = openmc.ZCylinder(r=90)\n", + "\n", + "inner_sphere_surface = openmc.Sphere(r=495)\n", + "middle_sphere_surface = openmc.Sphere(r=500) \n", + "outer_sphere_surface = openmc.Sphere(r=505)\n", + "outer_outer_sphere_surface = openmc.Sphere(r=600)\n", + "edge_of_simulation_surface = openmc.Sphere(r=700, 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, fill=mat_conductor)\n", + "central_column_coolant_cell = openmc.Cell(region=central_column_coolant_region, fill=# your code here)\n", + "central_column_fw_cell = openmc.Cell(region=central_column_fw_region, fill=# your code here)\n", + "inner_vessel_cell = openmc.Cell(region=inner_vessel_region)\n", + "blanket_fw_cell = openmc.Cell(region=blanket_fw_region, fill=# your code here)\n", + "blanket_coolant_cell = openmc.Cell(region=blanket_coolant_region, fill=# your code here)\n", + "blanket_breeder_cell = openmc.Cell(region=blanket_breeder_region, fill=# your code here)\n", + "blanket_reflector_cell = openmc.Cell(region=blanket_reflector_region, fill=# your code here)\n", + "\n", + "my_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" + ] + }, + { + "cell_type": "markdown", + "id": "f4b45781", + "metadata": {}, + "source": [ + "# task 4 - plot the geometry" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "25c8dcf1", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# your code here\n" + ] + }, + { + "cell_type": "markdown", + "id": "378674b3", + "metadata": {}, + "source": [ + "# Task 5 - plot the source location and energy" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ddd3c0a", + "metadata": {}, + "outputs": [], + "source": [ + "# initialises a new source object\n", + "my_source = openmc.IndependentSource()\n", + "# the distribution of radius is just a single value\n", + "radius = openmc.stats.Discrete([300], [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", + "angle = openmc.stats.Uniform(a=0., b=2* 3.14159265359)\n", + "# this makes the ring source using the three distributions and a radius\n", + "my_source.space = openmc.stats.CylindricalIndependent(r=radius, phi=angle, z=z_values, origin=(0.0, 0.0, 0.0))\n", + "# sets the direction to isotropic\n", + "my_source.angle = openmc.stats.Isotropic()\n", + "# sets the energy distribution to a Muir distribution neutrons\n", + "my_source.energy = openmc.stats.muir(e0=14080000.0, m_rat=5.0, kt=20000.0)\n", + "\n", + "my_settings = openmc.Settings()\n", + "my_settings.batches = 10\n", + "my_settings.inactive = 0\n", + "my_settings.particles = 500\n", + "my_settings.run_mode = 'fixed source'\n", + "my_settings.source = my_source\n", + "\n", + "# plot the source term\n", + "# your code goes here" + ] + }, + { + "cell_type": "markdown", + "id": "d539543f", + "metadata": {}, + "source": [ + "# Task 7 - complete the tally scores and filters" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0093ded0", + "metadata": {}, + "outputs": [], + "source": [ + "cell_filter_breeder = openmc.CellFilter(blanket_breeder_cell)\n", + "tbr_tally = openmc.Tally(name='TBR')\n", + "tbr_tally.filters = [cell_filter_breeder]\n", + "tbr_tally.scores = [# your code here]\n", + "\n", + "cell_filter_blanket_fw_coolant = openmc.CellFilter([\n", + " blanket_breeder_cell,\n", + " blanket_coolant_cell,\n", + " blanket_fw_cell,\n", + " central_column_coolant_cell,\n", + " central_column_fw_cell,\n", + "])\n", + "blanket_heating_tally = openmc.Tally(name='heating')\n", + "blanket_heating_tally.filters = [cell_filter_blanket_fw_coolant]\n", + "blanket_heating_tally.scores = ['heating']\n", + "\n", + "material_filter_conductor = openmc.MaterialFilter(# your code here)\n", + "conductor_damage_tally = openmc.Tally(name='conductor_damage')\n", + "conductor_damage_tally.filters = [material_filter_conductor]\n", + "conductor_damage_tally.scores = [# your code here]\n", + "\n", + "my_tallies = openmc.Tallies([tbr_tally, blanket_heating_tally, conductor_damage_tally])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "84caa13e", + "metadata": {}, + "outputs": [], + "source": [ + "model = openmc.model.Model(my_geometry, my_materials, my_settings, my_tallies)\n", + "\n", + "# removes the old output files\n", + "!rm *.h5 *.xml\n", + "\n", + "sp_filename = model.run()" + ] + }, + { + "cell_type": "markdown", + "id": "f58aa313", + "metadata": {}, + "source": [ + "# Task 8 - complete the code to get the correct tally names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "26ebca7b", + "metadata": {}, + "outputs": [], + "source": [ + "sp = openmc.StatePoint(sp_filename)\n", + "\n", + "tbr_tally = sp.get_tally(name=# Your code here)\n", + "\n", + "print(f'TBR={tbr_tally.mean.flatten()[0]} with standard deviation of {tbr_tally.std_dev.flatten()[0]}')\n", + "\n", + "heating_tally = sp.get_tally(name=# Your code here)\n", + "print(f'Heating={heating_tally.mean.flatten()[0]/1e6}MeV per source neutron with standard deviation of {heating_tally.std_dev.flatten()[0]}')\n", + "\n", + "damage_tally = sp.get_tally(name=# Your code here)\n", + "print(f'damage={damage_tally.mean.flatten()[0]} with standard deviation of {damage_tally.std_dev.flatten()[0]}')\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8a48c3af", + "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/optimal_design.ipynb b/tasks/task_17_design_tasks/1_optimal_design_with_hints.ipynb similarity index 86% rename from tasks/optimal_design.ipynb rename to tasks/task_17_design_tasks/1_optimal_design_with_hints.ipynb index c19f8799..49a189a5 100644 --- a/tasks/optimal_design.ipynb +++ b/tasks/task_17_design_tasks/1_optimal_design_with_hints.ipynb @@ -39,16 +39,16 @@ "source": [ "# options for coolant\n", "\n", - "water = openmc.Material(name='mat_coolant')\n", + "water = openmc.Material(name='water')\n", "water.add_element('H', 2)\n", "water.add_element('O', 1)\n", "water.set_density('g/cm3', 1)\n", "\n", - "helium = openmc.Material(name='mat_coolant')\n", + "helium = openmc.Material(name='helium')\n", "helium.add_element('He', 1)\n", "helium.set_density('g/cm3', 0.0014)\n", "\n", - "super_critical_co2 = openmc.Material(name='mat_coolant')\n", + "super_critical_co2 = openmc.Material(name='super critical co2')\n", "super_critical_co2.add_element('C', 1)\n", "super_critical_co2.add_element('O', 2)\n", "super_critical_co2.set_density('g/cm3', 0.001)\n", @@ -56,62 +56,62 @@ "\n", "# options for first wall\n", "\n", - "tungsten = openmc.Material(name='mat_reflector')\n", + "tungsten = openmc.Material(name='tungsten')\n", "tungsten.add_element('W', 1, percent_type='wo')\n", "tungsten.set_density('g/cm3', 19.2)\n", "\n", - "steel = openmc.Material(name='mat_firstwall')\n", + "steel = openmc.Material(name='steel')\n", "steel.add_element('Fe', 0.95, percent_type='wo')\n", "steel.add_element('C', 0.95, percent_type='wo')\n", "steel.set_density('g/cm3', 1)\n", "\n", - "silicon_carbide = openmc.Material(name='mat_firstwall')\n", + "silicon_carbide = openmc.Material(name='silicon_carbide')\n", "silicon_carbide.add_element('Si', 1)\n", "silicon_carbide.add_element('C', 1)\n", "silicon_carbide.set_density('g/cm3', 3.21)\n", "\n", - "zirconium = openmc.Material(name='mat_firstwall')\n", + "zirconium = openmc.Material(name='zirconium')\n", "zirconium.add_element('Zr', 1, percent_type='wo')\n", "zirconium.set_density('g/cm3', 6.49)\n", "\n", "# options for reflector\n", "\n", - "beryllium = openmc.Material(name='mat_reflector')\n", + "beryllium = openmc.Material(name='beryllium')\n", "beryllium.add_element('Be', 1, percent_type='wo')\n", "beryllium.set_density('g/cm3', 1.85)\n", "\n", - "tungsten = openmc.Material(name='mat_reflector')\n", + "tungsten = openmc.Material(name='tungsten')\n", "tungsten.add_element('W', 1, percent_type='wo')\n", "tungsten.set_density('g/cm3', 19.2)\n", "\n", - "graphite = openmc.Material(name='mat_reflector')\n", + "graphite = openmc.Material(name='graphite')\n", "graphite.add_element('C', 1, percent_type='wo')\n", "graphite.set_density('g/cm3', 2.2)\n", "\n", "# options for breeder\n", "\n", "# note you can change the enrichment\n", - "lithium_lead = openmc.Material(name='mat_breeder')\n", + "lithium_lead = openmc.Material(name='lithium_lead')\n", "lithium_lead.add_element('Pb', 84.2, percent_type='ao')\n", "lithium_lead.add_element('Li', 15.8, percent_type='ao', enrichment=90.0, enrichment_target='Li6', enrichment_type='ao')\n", "lithium_lead.set_density('g/cm3', 9.5)\n", "\n", "# note you can change the enrichment\n", - "lithium_orthosilicate = openmc.Material(name='mat_breeder')\n", + "lithium_orthosilicate = openmc.Material(name='lithium_orthosilicate')\n", "lithium_orthosilicate.add_element('Si', 4, percent_type='ao')\n", "lithium_orthosilicate.add_element('O', 1, percent_type='ao')\n", "lithium_orthosilicate.add_element('Li', 4, percent_type='ao', enrichment=50.0, enrichment_target='Li6', enrichment_type='ao')\n", "lithium_orthosilicate.set_density('g/cm3', 2.2)\n", "\n", "# note you can change the enrichment\n", - "lithium_titanate = openmc.Material(name='mat_breeder')\n", + "lithium_titanate = openmc.Material(name='lithium_titanate')\n", "lithium_titanate.add_element('O', 12, percent_type='ao')\n", "lithium_titanate.add_element('Ti', 5, percent_type='ao')\n", "lithium_titanate.add_element('Li', 4, percent_type='ao', enrichment=40.0, enrichment_target='Li6', enrichment_type='ao')\n", "lithium_titanate.set_density('g/cm3', 2.4)\n", "\n", "# note you can change the enrichment\n", - "liquid_lithium = openmc.Material(name='mat_breeder')\n", + "liquid_lithium = openmc.Material(name='liquid_lithium')\n", "liquid_lithium.add_element('Li', 1, percent_type='ao', enrichment=7.0, enrichment_target='Li6', enrichment_type='ao')\n", "liquid_lithium.set_density('g/cm3', 0.5)\n" ] @@ -131,7 +131,19 @@ "metadata": {}, "outputs": [], "source": [ - "# your code goes here" + "import matplotlib.pyplot as plt\n", + "\n", + "openmc.plotter.plot_xs(\n", + " reactions = {\n", + " lithium_lead: ['(n,Xt)'],\n", + " lithium_orthosilicate: ['(n,Xt)'],\n", + " lithium_orthosilicate: ['(n,Xt)'],\n", + " lithium_titanate: ['(n,Xt)'],\n", + " liquid_lithium: ['(n,Xt)'],\n", + " }\n", + ")\n", + "plt.title = '(n,XT) cross section'\n", + "plt.savefig('tritium_cross_section_pushers.png', dpi=400)" ] }, { @@ -149,7 +161,19 @@ "metadata": {}, "outputs": [], "source": [ - "# your code goes here" + "# your code goes hereimport matplotlib.pyplot as plt\n", + "\n", + "openmc.plotter.plot_xs(\n", + " reactions = {\n", + " lithium_lead: ['absorption'],\n", + " lithium_orthosilicate: ['absorption'],\n", + " lithium_orthosilicate: ['absorption'],\n", + " lithium_titanate: ['absorption'],\n", + " liquid_lithium: ['absorption'],\n", + " }\n", + ")\n", + "plt.title = 'absorption cross section'\n", + "plt.savefig('absorption_cross_section_pushers.png', dpi=400)" ] }, { @@ -159,10 +183,10 @@ "metadata": {}, "outputs": [], "source": [ - "mat_breeder = # your choice of material goes here\n", - "mat_coolant = # your choice of material goes here\n", - "mat_firstwall = # your choice of material goes here\n", - "mat_reflector = # your choice of material goes here" + "mat_breeder = liquid_lithium\n", + "mat_coolant = water\n", + "mat_firstwall = zirconium\n", + "mat_reflector = tungsten" ] }, {