Updates to notebooks to use models and correct for API changes

This commit is contained in:
Patrick Shriwise 2022-05-11 23:52:22 -05:00
parent 3762fbb756
commit c8b6a1efad
6 changed files with 3338 additions and 3053 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -144,6 +144,16 @@
"import openmc.mgxs as mgxs"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# create a model object to tie geometry, materials, settings, and tallies together\n",
"model = openmc.Model()"
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -153,7 +163,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@ -176,13 +186,12 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# Instantiate a Materials collection and export to XML\n",
"materials_file = openmc.Materials([inf_medium])\n",
"materials_file.export_to_xml()"
"model.materials = openmc.Materials([inf_medium])"
]
},
{
@ -194,7 +203,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@ -214,7 +223,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@ -237,7 +246,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@ -254,15 +263,12 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# Create Geometry and set root Universe\n",
"openmc_geometry = openmc.Geometry(root_universe)\n",
"\n",
"# Export to \"geometry.xml\"\n",
"openmc_geometry.export_to_xml()"
"model.geometry = openmc.Geometry(root_universe)"
]
},
{
@ -274,7 +280,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@ -284,19 +290,18 @@
"particles = 2500\n",
"\n",
"# Instantiate a Settings object\n",
"settings_file = openmc.Settings()\n",
"settings_file.batches = batches\n",
"settings_file.inactive = inactive\n",
"settings_file.particles = particles\n",
"settings_file.output = {'tallies': True}\n",
"settings = openmc.Settings()\n",
"settings.batches = batches\n",
"settings.inactive = inactive\n",
"settings.particles = particles\n",
"settings.output = {'tallies': True}\n",
"\n",
"# Create an initial uniform spatial source distribution over fissionable zones\n",
"bounds = [-0.63, -0.63, -0.63, 0.63, 0.63, 0.63]\n",
"uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)\n",
"settings_file.source = openmc.Source(space=uniform_dist)\n",
"settings.source = openmc.Source(space=uniform_dist)\n",
"\n",
"# Export to \"settings.xml\"\n",
"settings_file.export_to_xml()"
"model.settings = settings"
]
},
{
@ -308,7 +313,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@ -345,7 +350,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@ -368,7 +373,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@ -392,7 +397,7 @@
" \tEstimator =\ttracklength)])"
]
},
"execution_count": 12,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@ -410,35 +415,23 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/shriwise/opt/openmc/openmc/openmc/mixin.py:68: IDWarning: Another Filter instance already exists with id=3.\n",
" warn(msg, IDWarning)\n",
"/home/shriwise/opt/openmc/openmc/openmc/mixin.py:68: IDWarning: Another Filter instance already exists with id=4.\n",
" warn(msg, IDWarning)\n"
]
}
],
"outputs": [],
"source": [
"# Instantiate an empty Tallies object\n",
"tallies_file = openmc.Tallies()\n",
"tallies = openmc.Tallies()\n",
"\n",
"# Add total tallies to the tallies file\n",
"tallies_file += total.tallies.values()\n",
"tallies += total.tallies.values()\n",
"\n",
"# Add absorption tallies to the tallies file\n",
"tallies_file += absorption.tallies.values()\n",
"tallies += absorption.tallies.values()\n",
"\n",
"# Add scattering tallies to the tallies file\n",
"tallies_file += scattering.tallies.values()\n",
"tallies += scattering.tallies.values()\n",
"\n",
"# Export to \"tallies.xml\"\n",
"tallies_file.export_to_xml()"
"model.tallies = tallies"
]
},
{
@ -450,9 +443,19 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/pshriwise/.pyenv/versions/3.9.1/lib/python3.9/site-packages/openmc/mixin.py:67: IDWarning: Another Filter instance already exists with id=3.\n",
" warn(msg, IDWarning)\n",
"/home/pshriwise/.pyenv/versions/3.9.1/lib/python3.9/site-packages/openmc/mixin.py:67: IDWarning: Another Filter instance already exists with id=4.\n",
" warn(msg, IDWarning)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
@ -481,111 +484,112 @@
" ######## %%%%%%%%%%%%%%\n",
" %%%%%%%%%%%\n",
"\n",
" | The OpenMC Monte Carlo Code\n",
" Copyright | 2011-2021 MIT and OpenMC contributors\n",
" License | https://docs.openmc.org/en/latest/license.html\n",
" Version | 0.13.0-dev\n",
" Git SHA1 | 3dd81a1316ac3b5a0633e4b7a290f3bc97a066d9\n",
" Date/Time | 2021-06-28 08:44:52\n",
" OpenMP Threads | 2\n",
" | The OpenMC Monte Carlo Code\n",
" Copyright | 2011-2022 MIT, UChicago Argonne LLC, and contributors\n",
" License | https://docs.openmc.org/en/latest/license.html\n",
" Version | 0.13.1-dev\n",
" Git SHA1 | 1be02f90bd0e9adb5a3311ee77c904a52ca7ebaa\n",
" Date/Time | 2022-05-11 23:29:23\n",
" OpenMP Threads | 2\n",
"\n",
" Reading settings XML file...\n",
" Reading cross sections XML file...\n",
" Reading materials XML file...\n",
" Reading geometry XML file...\n",
" Reading H1 from /opt/data/xs/nndc_hdf5/H1.h5\n",
" Reading O16 from /opt/data/xs/nndc_hdf5/O16.h5\n",
" Reading U235 from /opt/data/xs/nndc_hdf5/U235.h5\n",
" Reading U238 from /opt/data/xs/nndc_hdf5/U238.h5\n",
" Reading Zr90 from /opt/data/xs/nndc_hdf5/Zr90.h5\n",
" Minimum neutron data temperature: 294.0 K\n",
" Maximum neutron data temperature: 294.0 K\n",
" Reading H1 from /home/pshriwise/data/xs/openmc/endfb71_hdf5/H1.h5\n",
" Reading O16 from /home/pshriwise/data/xs/openmc/endfb71_hdf5/O16.h5\n",
" Reading U235 from /home/pshriwise/data/xs/openmc/endfb71_hdf5/U235.h5\n",
" Reading U238 from /home/pshriwise/data/xs/openmc/endfb71_hdf5/U238.h5\n",
" Reading Zr90 from /home/pshriwise/data/xs/openmc/endfb71_hdf5/Zr90.h5\n",
" Minimum neutron data temperature: 294 K\n",
" Maximum neutron data temperature: 294 K\n",
" Reading tallies XML file...\n",
" Preparing distributed cell instances...\n",
" Reading plot XML file...\n",
" Writing summary.h5 file...\n",
" Maximum neutron transport energy: 20000000.0 eV for H1\n",
" Maximum neutron transport energy: 20000000 eV for H1\n",
" Initializing source particles...\n",
"\n",
" ====================> K EIGENVALUE SIMULATION <====================\n",
"\n",
" Bat./Gen. k Average k\n",
" ========= ======== ====================\n",
" 1/1 1.18505\n",
" 2/1 1.17297\n",
" 3/1 1.16184\n",
" 4/1 1.14929\n",
" 5/1 1.09928\n",
" 6/1 1.18675\n",
" 7/1 1.19772\n",
" 8/1 1.17470\n",
" 9/1 1.17208\n",
" 10/1 1.09993\n",
" 11/1 1.14342\n",
" 12/1 1.10127 1.12234 +/- 0.02107\n",
" 13/1 1.19914 1.14794 +/- 0.02834\n",
" 14/1 1.18411 1.15698 +/- 0.02199\n",
" 15/1 1.14556 1.15470 +/- 0.01718\n",
" 16/1 1.20337 1.16281 +/- 0.01621\n",
" 17/1 1.13853 1.15934 +/- 0.01413\n",
" 18/1 1.18208 1.16218 +/- 0.01256\n",
" 19/1 1.11842 1.15732 +/- 0.01210\n",
" 20/1 1.15248 1.15684 +/- 0.01083\n",
" 21/1 1.14903 1.15613 +/- 0.00982\n",
" 22/1 1.23456 1.16266 +/- 0.01110\n",
" 23/1 1.18876 1.16467 +/- 0.01040\n",
" 24/1 1.13591 1.16262 +/- 0.00985\n",
" 25/1 1.19559 1.16481 +/- 0.00943\n",
" 26/1 1.16947 1.16511 +/- 0.00882\n",
" 27/1 1.13198 1.16316 +/- 0.00851\n",
" 28/1 1.15329 1.16261 +/- 0.00805\n",
" 29/1 1.16538 1.16275 +/- 0.00761\n",
" 30/1 1.18229 1.16373 +/- 0.00729\n",
" 31/1 1.15060 1.16311 +/- 0.00696\n",
" 32/1 1.15460 1.16272 +/- 0.00665\n",
" 33/1 1.13875 1.16168 +/- 0.00644\n",
" 34/1 1.13479 1.16056 +/- 0.00626\n",
" 35/1 1.21125 1.16258 +/- 0.00634\n",
" 36/1 1.15914 1.16245 +/- 0.00609\n",
" 37/1 1.10457 1.16031 +/- 0.00624\n",
" 38/1 1.17215 1.16073 +/- 0.00603\n",
" 39/1 1.18462 1.16155 +/- 0.00588\n",
" 40/1 1.15361 1.16129 +/- 0.00568\n",
" 41/1 1.14983 1.16092 +/- 0.00551\n",
" 42/1 1.14087 1.16029 +/- 0.00537\n",
" 43/1 1.18725 1.16111 +/- 0.00527\n",
" 44/1 1.19094 1.16199 +/- 0.00519\n",
" 45/1 1.17371 1.16232 +/- 0.00505\n",
" 46/1 1.18552 1.16297 +/- 0.00495\n",
" 47/1 1.14194 1.16240 +/- 0.00485\n",
" 48/1 1.12045 1.16130 +/- 0.00484\n",
" 49/1 1.18476 1.16190 +/- 0.00476\n",
" 50/1 1.17063 1.16212 +/- 0.00464\n",
" 1/1 1.15552\n",
" 2/1 1.16733\n",
" 3/1 1.17357\n",
" 4/1 1.12104\n",
" 5/1 1.15371\n",
" 6/1 1.12495\n",
" 7/1 1.19449\n",
" 8/1 1.20011\n",
" 9/1 1.16787\n",
" 10/1 1.14804\n",
" 11/1 1.10848\n",
" 12/1 1.13356 1.12102 +/- 0.01254\n",
" 13/1 1.15809 1.13337 +/- 0.01432\n",
" 14/1 1.15677 1.13922 +/- 0.01170\n",
" 15/1 1.17172 1.14572 +/- 0.01115\n",
" 16/1 1.24178 1.16173 +/- 0.01842\n",
" 17/1 1.12127 1.15595 +/- 0.01660\n",
" 18/1 1.14862 1.15503 +/- 0.01441\n",
" 19/1 1.19389 1.15935 +/- 0.01342\n",
" 20/1 1.13333 1.15675 +/- 0.01228\n",
" 21/1 1.11797 1.15322 +/- 0.01166\n",
" 22/1 1.15630 1.15348 +/- 0.01064\n",
" 23/1 1.19152 1.15641 +/- 0.01022\n",
" 24/1 1.15088 1.15601 +/- 0.00947\n",
" 25/1 1.18286 1.15780 +/- 0.00899\n",
" 26/1 1.13381 1.15630 +/- 0.00855\n",
" 27/1 1.15178 1.15604 +/- 0.00803\n",
" 28/1 1.15118 1.15577 +/- 0.00758\n",
" 29/1 1.12090 1.15393 +/- 0.00740\n",
" 30/1 1.18609 1.15554 +/- 0.00720\n",
" 31/1 1.20145 1.15773 +/- 0.00719\n",
" 32/1 1.12612 1.15629 +/- 0.00700\n",
" 33/1 1.17661 1.15717 +/- 0.00675\n",
" 34/1 1.17043 1.15773 +/- 0.00649\n",
" 35/1 1.16430 1.15799 +/- 0.00623\n",
" 36/1 1.13257 1.15701 +/- 0.00606\n",
" 37/1 1.11728 1.15554 +/- 0.00602\n",
" 38/1 1.18588 1.15662 +/- 0.00590\n",
" 39/1 1.19931 1.15809 +/- 0.00588\n",
" 40/1 1.13642 1.15737 +/- 0.00572\n",
" 41/1 1.17784 1.15803 +/- 0.00558\n",
" 42/1 1.15119 1.15782 +/- 0.00540\n",
" 43/1 1.16841 1.15814 +/- 0.00525\n",
" 44/1 1.18698 1.15899 +/- 0.00516\n",
" 45/1 1.10199 1.15736 +/- 0.00527\n",
" 46/1 1.13452 1.15672 +/- 0.00516\n",
" 47/1 1.11975 1.15573 +/- 0.00512\n",
" 48/1 1.15899 1.15581 +/- 0.00498\n",
" 49/1 1.12582 1.15504 +/- 0.00491\n",
" 50/1 1.12809 1.15437 +/- 0.00483\n",
" Creating state point statepoint.50.h5...\n",
"\n",
" =======================> TIMING STATISTICS <=======================\n",
"\n",
" Total time for initialization = 2.9038e-01 seconds\n",
" Reading cross sections = 2.7861e-01 seconds\n",
" Total time in simulation = 3.9987e+00 seconds\n",
" Time in transport only = 3.9829e+00 seconds\n",
" Time in inactive batches = 4.9461e-01 seconds\n",
" Time in active batches = 3.5041e+00 seconds\n",
" Time synchronizing fission bank = 5.2042e-03 seconds\n",
" Sampling source sites = 4.4431e-03 seconds\n",
" SEND/RECV source sites = 7.3804e-04 seconds\n",
" Time accumulating tallies = 3.6977e-04 seconds\n",
" Time writing statepoints = 6.6301e-03 seconds\n",
" Total time for finalization = 1.9945e-04 seconds\n",
" Total time elapsed = 4.2948e+00 seconds\n",
" Calculation Rate (inactive) = 50544.8 particles/second\n",
" Calculation Rate (active) = 28537.8 particles/second\n",
" Total time for initialization = 1.2841e-01 seconds\n",
" Reading cross sections = 1.2456e-01 seconds\n",
" Total time in simulation = 2.7131e+00 seconds\n",
" Time in transport only = 2.7038e+00 seconds\n",
" Time in inactive batches = 2.9116e-01 seconds\n",
" Time in active batches = 2.4219e+00 seconds\n",
" Time synchronizing fission bank = 5.1996e-03 seconds\n",
" Sampling source sites = 4.3432e-03 seconds\n",
" SEND/RECV source sites = 8.4443e-04 seconds\n",
" Time accumulating tallies = 2.4355e-04 seconds\n",
" Time writing statepoints = 2.3963e-03 seconds\n",
" Total time for finalization = 6.0680e-05 seconds\n",
" Total time elapsed = 2.8438e+00 seconds\n",
" Calculation Rate (inactive) = 85862.4 particles/second\n",
" Calculation Rate (active) = 41289.8 particles/second\n",
"\n",
" ============================> RESULTS <============================\n",
"\n",
" k-effective (Collision) = 1.16239 +/- 0.00461\n",
" k-effective (Track-length) = 1.16212 +/- 0.00464\n",
" k-effective (Absorption) = 1.15435 +/- 0.00325\n",
" Combined k-effective = 1.15666 +/- 0.00304\n",
" k-effective (Collision) = 1.15560 +/- 0.00487\n",
" k-effective (Track-length) = 1.15437 +/- 0.00483\n",
" k-effective (Absorption) = 1.15879 +/- 0.00318\n",
" Combined k-effective = 1.15743 +/- 0.00304\n",
" Leakage Fraction = 0.00000 +/- 0.00000\n",
"\n"
]
@ -593,7 +597,7 @@
],
"source": [
"# Run OpenMC\n",
"openmc.run()"
"statepoint_filename = model.run()"
]
},
{
@ -612,12 +616,12 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"# Load the last statepoint file\n",
"sp = openmc.StatePoint('statepoint.50.h5')"
"sp = openmc.StatePoint(statepoint_filename)"
]
},
{
@ -636,7 +640,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
@ -671,7 +675,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@ -683,8 +687,8 @@
"\tDomain Type =\tcell\n",
"\tDomain ID =\t1\n",
"\tCross Sections [cm^-1]:\n",
" Group 1 [0.625 - 20000000.0eV]:\t6.81e-01 +/- 2.69e-01%\n",
" Group 2 [0.0 - 0.625 eV]:\t1.40e+00 +/- 6.00e-01%\n",
" Group 1 [0.625 - 20000000.0eV]:\t6.82e-01 +/- 2.16e-01%\n",
" Group 2 [0.0 - 0.625 eV]:\t1.40e+00 +/- 6.49e-01%\n",
"\n",
"\n",
"\n"
@ -704,7 +708,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 19,
"metadata": {},
"outputs": [
{
@ -741,16 +745,16 @@
" <td>1</td>\n",
" <td>1</td>\n",
" <td>total</td>\n",
" <td>0.668083</td>\n",
" <td>0.001798</td>\n",
" <td>0.668519</td>\n",
" <td>0.001449</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>total</td>\n",
" <td>1.292060</td>\n",
" <td>0.007737</td>\n",
" <td>1.292665</td>\n",
" <td>0.008362</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -758,11 +762,11 @@
],
"text/plain": [
" cell group in nuclide mean std. dev.\n",
"1 1 1 total 0.668083 0.001798\n",
"0 1 2 total 1.292060 0.007737"
"1 1 1 total 0.668519 0.001449\n",
"0 1 2 total 1.292665 0.008362"
]
},
"execution_count": 18,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@ -781,9 +785,18 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 20,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/pshriwise/.pyenv/versions/3.9.1/lib/python3.9/site-packages/openmc/mgxs/mgxs.py:1994: FutureWarning: As the xlwt package is no longer maintained, the xlwt engine will be removed in a future version of pandas. This is the only engine in pandas that supports writing in the xls format. Install openpyxl and write to an xlsx file instead. You can set the option io.excel.xls.writer to 'xlwt' to silence this warning. While this option is deprecated and will also raise a warning, it can be globally set and the warning suppressed.\n",
" df.to_excel(filename + '.xls', index=False)\n"
]
}
],
"source": [
"absorption.export_xs_data(filename='absorption-xs', format='excel')"
]
@ -797,7 +810,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
@ -820,96 +833,6 @@
"Finally, we illustrate how one can leverage OpenMC's [tally arithmetic](../examples/tally-arithmetic.rst) data processing feature with `MGXS` objects. The `openmc.mgxs` module uses tally arithmetic to compute multi-group cross sections with automated uncertainty propagation. Each `MGXS` object includes an `xs_tally` attribute which is a \"derived\" `Tally` based on the tallies needed to compute the cross section type of interest. These derived tallies can be used in subsequent tally arithmetic operations. For example, we can use tally artithmetic to confirm that the `TotalXS` is equal to the sum of the `AbsorptionXS` and `ScatterXS` objects."
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cell</th>\n",
" <th>energy low [eV]</th>\n",
" <th>energy high [eV]</th>\n",
" <th>nuclide</th>\n",
" <th>score</th>\n",
" <th>mean</th>\n",
" <th>std. dev.</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.000</td>\n",
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
" <td>4.440892e-16</td>\n",
" <td>0.011435</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.625</td>\n",
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
" <td>-2.553513e-15</td>\n",
" <td>0.002567</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cell energy low [eV] energy high [eV] nuclide \\\n",
"0 1 0.00e+00 6.25e-01 total \n",
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 (((total / flux) - (absorption / flux)) - (sca... 4.44e-16 1.14e-02 \n",
"1 (((total / flux) - (absorption / flux)) - (sca... -2.55e-15 2.57e-03 "
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Use tally arithmetic to compute the difference between the total, absorption and scattering\n",
"difference = total.xs_tally - absorption.xs_tally - scattering.xs_tally\n",
"\n",
"# The difference is a derived tally which can generate Pandas DataFrames for inspection\n",
"difference.get_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Similarly, we can use tally arithmetic to compute the ratio of `AbsorptionXS` and `ScatterXS` to the `TotalXS`."
]
},
{
"cell_type": "code",
"execution_count": 22,
@ -952,9 +875,9 @@
" <td>0.000</td>\n",
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>((absorption / flux) / (total / flux))</td>\n",
" <td>0.076103</td>\n",
" <td>0.000658</td>\n",
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
" <td>-2.442491e-15</td>\n",
" <td>0.012361</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
@ -962,9 +885,9 @@
" <td>0.625</td>\n",
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>((absorption / flux) / (total / flux))</td>\n",
" <td>0.019441</td>\n",
" <td>0.000093</td>\n",
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
" <td>3.996803e-15</td>\n",
" <td>0.002069</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -975,9 +898,9 @@
"0 1 0.00e+00 6.25e-01 total \n",
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 ((absorption / flux) / (total / flux)) 7.61e-02 6.58e-04 \n",
"1 ((absorption / flux) / (total / flux)) 1.94e-02 9.26e-05 "
" score mean std. dev. \n",
"0 (((total / flux) - (absorption / flux)) - (sca... -2.44e-15 1.24e-02 \n",
"1 (((total / flux) - (absorption / flux)) - (sca... 4.00e-15 2.07e-03 "
]
},
"execution_count": 22,
@ -986,11 +909,18 @@
}
],
"source": [
"# Use tally arithmetic to compute the absorption-to-total MGXS ratio\n",
"absorption_to_total = absorption.xs_tally / total.xs_tally\n",
"# Use tally arithmetic to compute the difference between the total, absorption and scattering\n",
"difference = total.xs_tally - absorption.xs_tally - scattering.xs_tally\n",
"\n",
"# The absorption-to-total ratio is a derived tally which can generate Pandas DataFrames for inspection\n",
"absorption_to_total.get_pandas_dataframe()"
"# The difference is a derived tally which can generate Pandas DataFrames for inspection\n",
"difference.get_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Similarly, we can use tally arithmetic to compute the ratio of `AbsorptionXS` and `ScatterXS` to the `TotalXS`."
]
},
{
@ -1035,9 +965,9 @@
" <td>0.000</td>\n",
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>((scatter / flux) / (total / flux))</td>\n",
" <td>0.923897</td>\n",
" <td>0.007833</td>\n",
" <td>((absorption / flux) / (total / flux))</td>\n",
" <td>0.076155</td>\n",
" <td>0.000712</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
@ -1045,9 +975,9 @@
" <td>0.625</td>\n",
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>((scatter / flux) / (total / flux))</td>\n",
" <td>0.980559</td>\n",
" <td>0.003729</td>\n",
" <td>((absorption / flux) / (total / flux))</td>\n",
" <td>0.019411</td>\n",
" <td>0.000091</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -1058,9 +988,9 @@
"0 1 0.00e+00 6.25e-01 total \n",
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 ((scatter / flux) / (total / flux)) 9.24e-01 7.83e-03 \n",
"1 ((scatter / flux) / (total / flux)) 9.81e-01 3.73e-03 "
" score mean std. dev. \n",
"0 ((absorption / flux) / (total / flux)) 7.62e-02 7.12e-04 \n",
"1 ((absorption / flux) / (total / flux)) 1.94e-02 9.08e-05 "
]
},
"execution_count": 23,
@ -1069,24 +999,107 @@
}
],
"source": [
"# Use tally arithmetic to compute the scattering-to-total MGXS ratio\n",
"scattering_to_total = scattering.xs_tally / total.xs_tally\n",
"# Use tally arithmetic to compute the absorption-to-total MGXS ratio\n",
"absorption_to_total = absorption.xs_tally / total.xs_tally\n",
"\n",
"# The scattering-to-total ratio is a derived tally which can generate Pandas DataFrames for inspection\n",
"scattering_to_total.get_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lastly, we sum the derived scatter-to-total and absorption-to-total ratios to confirm that they sum to unity."
"# The absorption-to-total ratio is a derived tally which can generate Pandas DataFrames for inspection\n",
"absorption_to_total.get_pandas_dataframe()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cell</th>\n",
" <th>energy low [eV]</th>\n",
" <th>energy high [eV]</th>\n",
" <th>nuclide</th>\n",
" <th>score</th>\n",
" <th>mean</th>\n",
" <th>std. dev.</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.000</td>\n",
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>((scatter / flux) / (total / flux))</td>\n",
" <td>0.923845</td>\n",
" <td>0.008463</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.625</td>\n",
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>((scatter / flux) / (total / flux))</td>\n",
" <td>0.980589</td>\n",
" <td>0.003003</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cell energy low [eV] energy high [eV] nuclide \\\n",
"0 1 0.00e+00 6.25e-01 total \n",
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 ((scatter / flux) / (total / flux)) 9.24e-01 8.46e-03 \n",
"1 ((scatter / flux) / (total / flux)) 9.81e-01 3.00e-03 "
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Use tally arithmetic to compute the scattering-to-total MGXS ratio\n",
"scattering_to_total = scattering.xs_tally / total.xs_tally\n",
"\n",
"# The scattering-to-total ratio is a derived tally which can generate Pandas DataFrames for inspection\n",
"scattering_to_total.get_pandas_dataframe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lastly, we sum the derived scatter-to-total and absorption-to-total ratios to confirm that they sum to unity."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
@ -1127,7 +1140,7 @@
" <td>total</td>\n",
" <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
" <td>1.0</td>\n",
" <td>0.007861</td>\n",
" <td>0.008492</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
@ -1137,7 +1150,7 @@
" <td>total</td>\n",
" <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
" <td>1.0</td>\n",
" <td>0.003731</td>\n",
" <td>0.003005</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -1149,11 +1162,11 @@
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 7.86e-03 \n",
"1 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 3.73e-03 "
"0 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 8.49e-03 \n",
"1 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 3.00e-03 "
]
},
"execution_count": 24,
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
@ -1169,7 +1182,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@ -1183,9 +1196,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long