Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #54 from fusion-energy/develop
Browse files Browse the repository at this point in the history
normalising spectra
  • Loading branch information
shimwell authored Sep 18, 2021
2 parents 689a242 + 6ff9e1a commit b02e1d2
Show file tree
Hide file tree
Showing 20 changed files with 405 additions and 397 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,4 @@ dmypy.json
*.stp
*.trelis
*.out
*.tar.gz
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ ENV OPENMC_CROSS_SECTIONS=/nuclear_data/cross_sections.xml
ENV PATH="/MOAB/build/bin:${PATH}"
ENV PATH="/DAGMC/bin:${PATH}"

COPY requirements-test.txt requirements-test.txt
RUN pip install -r requirements-test.txt

FROM dependencies as final

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ Standard simulations tallies are facilitated:
Neutronics responses can be obtained:
- Tritium Breeding Ratio (TBR)
- Heating (photon and neutron)
- Dose (on road map)
- Any supported reaction from the standard OpenMC reactions
- Effective dose (photon and neutron)
- Any supported reaction from the [standard OpenMC reactions](https://docs.openmc.org/en/latest/usersguide/tallies.html#scores)

A standard collection of materials are available by making use of the
[neutronics_material_maker](https://github.com/fusion-energy/neutronics_material_maker) package.

OpenMC sources definitions are used for the particle sources.

Post processing of results are also carried out to automatically provide images,
JSON output files and VTK files for convenient access to the results.
Post processing of the OpenMC output files are also carried out to automatically
provide: JSON text files, PNG images, VTK files for convenient access to the
results.

:point_right: [Documentation](https://openmc-dagmc-wrapper.readthedocs.io)

Expand Down
21 changes: 14 additions & 7 deletions examples/ball_reactor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"source": [
"import neutronics_material_maker as nmm\n",
"import openmc\n",
"import openmc_dagmc_wrapper\n",
"import openmc_dagmc_wrapper as odw\n",
"\n",
"# makes a homogenised material for the blanket from lithium lead and\n",
"# eurofer\n",
Expand All @@ -31,15 +31,15 @@
"\n",
"source = openmc.Source()\n",
"# sets the location of the source to x=0 y=0 z=0\n",
"source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0))\n",
"source.space = openmc.stats.Point((450, 0, 0))\n",
"# sets the direction to isotropic\n",
"source.angle = openmc.stats.Isotropic()\n",
"# sets the energy distribution to 100% 14MeV neutrons\n",
"source.energy = openmc.stats.Discrete([14e6], [1])\n",
"\n",
"# makes the neutronics material\n",
"neutronics_model = paramak_neutronics.NeutronicsModel(\n",
" h5m_filename=my_reactor.export_h5m(),\n",
"neutronics_model = odw.NeutronicsModel(\n",
" h5m_filename='dagmc.h5m,\n",
" source=source,\n",
" materials={\n",
" 'inboard_tf_coils_mat': 'copper',\n",
Expand All @@ -52,17 +52,24 @@
")\n",
"\n",
"# starts the neutronics simulation\n",
"neutronics_model.simulate(\n",
"h5m_filename = neutronics_model.simulate(\n",
" simulation_batches=2,\n",
" simulation_particles_per_batch=10, # this will need increasing to obtain accurate results\n",
")\n",
"\n",
"# extracts and processes the results from the statepoint file\n",
"neutronics_model.process_results()\n",
"odw.process_results(statepoint_filename=h5m_filename)\n",
"\n",
"# prints the results to screen\n",
"print('TBR', neutronics_model.results['TBR'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -84,7 +91,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.11"
}
},
"nbformat": 4,
Expand Down
30 changes: 22 additions & 8 deletions examples/ball_reactor_minimal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,37 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "FileNotFoundError",
"evalue": "h5m_filename provided (dagmc.h5m) does not exist",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/tmp/ipykernel_11288/4029085043.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;31m# makes the neutronics model from the geometry and material allocations\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 13\u001b[0;31m neutronics_model = odw.NeutronicsModel(\n\u001b[0m\u001b[1;32m 14\u001b[0m \u001b[0mh5m_filename\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"dagmc.h5m\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0msource\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msource\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/openmc-dagmc-wrapper/openmc_dagmc_wrapper/neutronics_model.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, h5m_filename, source, materials, cell_tallies, tet_mesh_filename, mesh_tally_2d, mesh_tally_3d, mesh_tally_tet, mesh_2d_resolution, mesh_3d_resolution, mesh_2d_corners, mesh_3d_corners, photon_transport, bounding_box)\u001b[0m\n\u001b[1;32m 91\u001b[0m ):\n\u001b[1;32m 92\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmaterials\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmaterials\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 93\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mh5m_filename\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mh5m_filename\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 94\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtet_mesh_filename\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtet_mesh_filename\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 95\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msource\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msource\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/openmc-dagmc-wrapper/openmc_dagmc_wrapper/neutronics_model.py\u001b[0m in \u001b[0;36mh5m_filename\u001b[0;34m(self, value)\u001b[0m\n\u001b[1;32m 123\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mPath\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_file\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 124\u001b[0m \u001b[0mmsg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34mf\"h5m_filename provided ({value}) does not exist\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 125\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mFileNotFoundError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 126\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_h5m_filename\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 127\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: h5m_filename provided (dagmc.h5m) does not exist"
]
}
],
"source": [
"import openmc\n",
"import openmc_dagmc_wrapper\n",
"import openmc_dagmc_wrapper as odw\n",
"\n",
"source = openmc.Source()\n",
"# sets the location of the source to x=0 y=0 z=0\n",
"source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0))\n",
"source.space = openmc.stats.Point((450, 0, 0))\n",
"# sets the direction to isotropic\n",
"source.angle = openmc.stats.Isotropic()\n",
"# sets the energy distribution to 100% 14MeV neutrons\n",
"source.energy = openmc.stats.Discrete([14e6], [1])\n",
"\n",
"# makes the neutronics model from the geometry and material allocations\n",
"neutronics_model = openmc_dagmc_wrapper.NeutronicsModel(\n",
"neutronics_model = odw.NeutronicsModel(\n",
" h5m_filename=\"dagmc.h5m\",\n",
" source=source,\n",
" materials={\n",
Expand All @@ -39,14 +53,14 @@
")\n",
"\n",
"# simulate the neutronics model\n",
"neutronics_model.simulate(\n",
"h5m_filename = neutronics_model.simulate(\n",
" simulation_batches=2,\n",
" simulation_particles_per_batch=10, # this will need increasing to obtain accurate results\n",
"\n",
")\n",
"\n",
"# extracts and processes the results from the statepoint file\n",
"neutronics_model.process_results()\n",
"odw.process_results(statepoint_filename=h5m_filename)\n",
"\n",
"print(neutronics_model.results)\n"
]
Expand Down Expand Up @@ -78,7 +92,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.11"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions examples/ball_reactor_source_plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"metadata": {},
"outputs": [],
"source": [
"import paramak_neutronics\n",
"import openmc_dagmc_wrapper as odw\n",
"\n",
"# makes the neutronics material\n",
"neutronics_model = paramak_neutronics.NeutronicsModel(\n",
"neutronics_model = odw.NeutronicsModel(\n",
" h5m_filename=\"dagmc.h5m\",\n",
" source=source,\n",
" materials={\n",
Expand Down Expand Up @@ -115,7 +115,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.11"
}
},
"nbformat": 4,
Expand Down
12 changes: 6 additions & 6 deletions examples/center_column_study_reactor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"\n",
"import matplotlib.pyplot as plt\n",
"import openmc\n",
"import openmc_dagmc_wrapper\n",
"import openmc_dagmc_wrapper as odw\n",
"\n",
"\n",
"source = openmc.Source()\n",
Expand All @@ -27,7 +27,7 @@
"\n",
"# makes the neutronics model and assigns basic materials to each\n",
"# component\n",
"neutronics_model = openmc_dagmc_wrapper.NeutronicsModel(\n",
"neutronics_model = odw.NeutronicsModel(\n",
" h5m_filename=my_reactor.export_h5m(),\n",
" source=source,\n",
" materials={\n",
Expand All @@ -41,16 +41,16 @@
")\n",
"\n",
"# starts the neutronics simulation\n",
"neutronics_model.simulate(\n",
"h5m_filename = neutronics_model.simulate(\n",
" simulation_batches=2,\n",
" simulation_particles_per_batch=10, # this would need increasing to get a accurate result\n",
")\n",
"\n",
"# extracts and processes the results from the statepoint file\n",
"neutronics_model.process_results()\n",
"results = neutronics_model.process_results(statepoint_filename=h5m_filename)\n",
"\n",
"# converts the results to mega watts\n",
"total_heat_in_MW = neutronics_model.results['firstwall_mat_heating']['Watts']['result'] / 1e6\n",
"total_heat_in_MW = results['firstwall_mat_heating']['Watts']['result'] / 1e6\n",
"\n"
]
}
Expand All @@ -74,7 +74,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.11"
}
},
"nbformat": 4,
Expand Down
14 changes: 7 additions & 7 deletions examples/center_column_study_reactor_minimal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
"parametric reactor.\"\"\"\n",
"\n",
"import openmc\n",
"import openmc_dagmc_wrapper\n",
"import openmc_dagmc_wrapper as odw\n",
"\n",
"source = openmc.Source()\n",
"# sets the location of the source to x=0 y=0 z=0\n",
"source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0))\n",
"source.space = openmc.stats.Point((450, 0, 0))\n",
"# sets the direction to isotropic\n",
"source.angle = openmc.stats.Isotropic()\n",
"# sets the energy distribution to 100% 14MeV neutrons\n",
"source.energy = openmc.stats.Discrete([14e6], [1])\n",
"\n",
"# creates a neutronics model from the geometry and assigned materials\n",
"neutronics_model = paramak_neutronics.NeutronicsModel(\n",
"neutronics_model = odw.NeutronicsModel(\n",
" h5m_filename=my_reactor.export_h5m(),\n",
" source=source,\n",
" materials={\n",
Expand All @@ -34,16 +34,16 @@
")\n",
"\n",
"# starts the neutronics simulation\n",
"neutronics_model.simulate(\n",
"h5m_filename = neutronics_model.simulate(\n",
" simulation_batches=2,\n",
" simulation_particles_per_batch=10, # this will need increasing to obtain accurate results\n",
")\n",
"\n",
"# extracts and processes the results from the statepoint file\n",
"neutronics_model.process_results()\n",
"results = odw.process_results(statepoint_filename=h5m_filename)\n",
"\n",
"# prints the results\n",
"print(neutronics_model.results)\n"
"print(results)\n"
]
},
{
Expand Down Expand Up @@ -73,7 +73,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.11"
}
},
"nbformat": 4,
Expand Down
12 changes: 6 additions & 6 deletions examples/component_based_parameter_study.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"outputs": [],
"source": [
"import openmc\n",
"import openmc_dagmc_wrapper\n",
"import openmc_dagmc_wrapper as odw\n",
"\n",
"# makes the openmc neutron source at x,y,z 0, 0, 0 with isotropic\n",
"# diections\n",
Expand All @@ -25,7 +25,7 @@
"source.angle = openmc.stats.Isotropic()\n",
"\n",
"# converts the geometry into a neutronics geometry\n",
"my_model = paramak_neutronics.NeutronicsModel(\n",
"my_model = odw.NeutronicsModel(\n",
" h5m_filename=\"dagmc.h5m\",\n",
" source=source,\n",
" materials={\n",
Expand All @@ -35,16 +35,16 @@
")\n",
"\n",
"# performs an openmc simulation on the model\n",
"my_model.simulate(\n",
"h5m_filename = my_model.simulate(\n",
" simulation_batches=10, # should be increased for more accurate result\n",
" simulation_particles_per_batch=10, # settings are low to reduce time required\n",
")\n",
"\n",
"# extracts and processes the results from the statepoint file\n",
"my_model.process_results()\n",
"results = my_model.process_results(statepoint_filename=h5m_filename)\n",
"\n",
"# extracts the heat from the results dictionary\n",
"heat = my_model.results['center_column_shield_mat_heating']['Watts']['result']\n",
"heat = results['center_column_shield_mat_heating']['Watts']['result']\n",
"\n",
"print(heat)"
]
Expand Down Expand Up @@ -76,7 +76,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.11"
}
},
"nbformat": 4,
Expand Down
12 changes: 6 additions & 6 deletions examples/openmc_logo_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"outputs": [],
"source": [
"import openmc\n",
"import openmc_dagmc_wrapper"
"import openmc_dagmc_wrapper as odw"
]
},
{
Expand Down Expand Up @@ -45,7 +45,7 @@
"metadata": {},
"outputs": [],
"source": [
"my_model = paramak_neutronics.NeutronicsModel(\n",
"my_model = odw.NeutronicsModel(\n",
" h5m_filename=\"dagmc.h5m\",\n",
" source=source,\n",
" materials = {'red_part_material':'P91', 'grey_part_material':'Li4SiO4'},\n",
Expand All @@ -54,14 +54,14 @@
" cell_tallies=['(n,Xt)','heating', 'spectra'],\n",
")\n",
"\n",
"my_model.simulate(\n",
"h5m_filename = my_model.simulate(\n",
" simulation_batches=2, # this should be increased to get a better mesh tally result\n",
" simulation_particles_per_batch=10, # this should be increased to get a better mesh tally result\n",
")\n",
"\n",
"\n",
"# extracts and processes the results from the statepoint file\n",
"my_model.process_results()"
"results = my_model.process_results(statepoint_filename=h5m_filename)"
]
},
{
Expand All @@ -77,7 +77,7 @@
"metadata": {},
"outputs": [],
"source": [
"my_model.results"
"print(results)"
]
}
],
Expand All @@ -97,7 +97,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.11"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit b02e1d2

Please sign in to comment.