Files
OpenMC_NEA_Training_nov25/course/student_notebooks/plotter/Plotter.ipynb
Stafie Alex PSI 850de66b07 first files
2025-12-02 11:57:33 +01:00

113 lines
3.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "d1ae14aa-9a26-455c-9424-f4d2b37e3475",
"metadata": {},
"source": [
"# OpenMC Plotter demonstration\n",
"\n",
"Below is the definition of a PWR assembly model with three tallies for use in the live demonstration of the openmc-plotter GUI application. The boundary conditions on the PWR assembly are changed to vacuum boundaries so that the flux profile is not flat."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "e75ac8c6-3cc8-476d-9440-2df428ab032a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"PosixPath('/home/ubuntu/openmc-nea-course/notebooks/plotter/statepoint.100.h5')"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import openmc\n",
"import numpy as np\n",
"\n",
"model = openmc.examples.pwr_assembly()\n",
"\n",
"# change the boundries, to make it looks cosine, not flat\n",
"for surf in model.geometry.get_all_surfaces().values():\n",
" if surf.boundary_type == 'reflective':\n",
" surf.boundary_type = 'vacuum'\n",
"\n",
"\n",
"model.settings.particles = 10_000\n",
"model.settings.batches = 100\n",
"model.settings.inactive = 10\n",
"\n",
"# added a tally to see\n",
"mesh = openmc.RegularMesh()\n",
"mesh.lower_left = (-10.71, -10.71)\n",
"mesh.upper_right = (10.71, 10.71)\n",
"mesh.dimension = (100, 100)\n",
"\n",
"reg_mesh_tally = openmc.Tally()\n",
"reg_mesh_tally.scores = ['flux', 'fission']\n",
"reg_mesh_tally.filters = [openmc.MeshFilter(mesh)]\n",
"\n",
"cyl_mesh = openmc.CylindricalMesh(\n",
" [0., 3., 5., 7.],\n",
" [-100., 100.],\n",
" np.linspace(0, 2*np.pi, 30), # azimutal\n",
" origin=(3., 3., 0.) # offset to see how it looks\n",
")\n",
"\n",
"cyl_mesh_tally = openmc.Tally()\n",
"cyl_mesh_tally.scores = ['flux', 'fission']\n",
"cyl_mesh_tally.filters = [openmc.MeshFilter(cyl_mesh)]\n",
"\n",
"fuel_cell = model.geometry.get_all_material_cells()[1]\n",
"\n",
"distribcell_tally = openmc.Tally()\n",
"distribcell_tally.scores = ['flux']\n",
"distribcell_tally.filters = [openmc.DistribcellFilter(fuel_cell)]\n",
"\n",
"model.tallies = [reg_mesh_tally, cyl_mesh_tally, distribcell_tally]\n",
"\n",
"model.run(output=False)"
]
},
{
"cell_type": "markdown",
"id": "36e9d5a0-63c3-4149-b195-e511c7244076",
"metadata": {},
"source": [
"### Notes\n",
"\n",
"Need to download the openmc-plotter separate, pip install as well, need x11\n",
"\n",
"overlap can be run with openmc -g to see overlap of materials"
]
}
],
"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.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}