Merge pull request #642 from paulromano/small-improvements

A few small improvements based on PHYSOR workshop observations
This commit is contained in:
Will Boyd 2016-05-09 10:06:25 -04:00
commit 5eff2f81e0
21 changed files with 995 additions and 1118 deletions

View file

@ -417,24 +417,22 @@
"data": {
"text/plain": [
"OrderedDict([('flux', Tally\n",
"\tID =\t10000\n",
"\tName =\t\n",
"\tFilters =\t\n",
" \t\tcell\t[1]\n",
" \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n",
"\tNuclides =\ttotal \n",
"\tScores =\t['flux']\n",
"\tEstimator =\ttracklength\n",
"), ('absorption', Tally\n",
"\tID =\t10001\n",
"\tName =\t\n",
"\tFilters =\t\n",
" \t\tcell\t[1]\n",
" \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n",
"\tNuclides =\ttotal \n",
"\tScores =\t['absorption']\n",
"\tEstimator =\ttracklength\n",
")])"
" \tID =\t10000\n",
" \tName =\t\n",
" \tFilters =\t\n",
" \t\tcell\t[1]\n",
" \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n",
" \tNuclides =\ttotal \n",
" \tScores =\t['flux']\n",
" \tEstimator =\ttracklength), ('absorption', Tally\n",
" \tID =\t10001\n",
" \tName =\t\n",
" \tFilters =\t\n",
" \t\tcell\t[1]\n",
" \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n",
" \tNuclides =\ttotal \n",
" \tScores =\t['absorption']\n",
" \tEstimator =\ttracklength)])"
]
},
"execution_count": 13,
@ -508,12 +506,11 @@
" 888\n",
" 888\n",
"\n",
" Copyright: 2011-2015 Massachusetts Institute of Technology\n",
" License: http://mit-crpg.github.io/openmc/license.html\n",
" Copyright: 2011-2016 Massachusetts Institute of Technology\n",
" License: http://openmc.readthedocs.org/en/latest/license.html\n",
" Version: 0.7.1\n",
" Git SHA1: eeb5091ca3a34cc85df73a3318cae2b6c7097413\n",
" Date/Time: 2016-04-13 11:24:09\n",
" MPI Processes: 1\n",
" Git SHA1: df280b60eb1c6d7b7f842e05ede734a4883a0fc8\n",
" Date/Time: 2016-05-05 13:43:54\n",
"\n",
" ===========================================================================\n",
" ========================> INITIALIZATION <=========================\n",
@ -598,20 +595,20 @@
"\n",
" =======================> TIMING STATISTICS <=======================\n",
"\n",
" Total time for initialization = 4.6300E-01 seconds\n",
" Reading cross sections = 1.2100E-01 seconds\n",
" Total time in simulation = 1.6504E+01 seconds\n",
" Time in transport only = 1.6479E+01 seconds\n",
" Time in inactive batches = 1.9620E+00 seconds\n",
" Time in active batches = 1.4542E+01 seconds\n",
" Time synchronizing fission bank = 1.0000E-02 seconds\n",
" Sampling source sites = 4.0000E-03 seconds\n",
" SEND/RECV source sites = 3.0000E-03 seconds\n",
" Total time for initialization = 5.7300E-01 seconds\n",
" Reading cross sections = 1.7600E-01 seconds\n",
" Total time in simulation = 2.1188E+01 seconds\n",
" Time in transport only = 2.1173E+01 seconds\n",
" Time in inactive batches = 2.6880E+00 seconds\n",
" Time in active batches = 1.8500E+01 seconds\n",
" Time synchronizing fission bank = 3.0000E-03 seconds\n",
" Sampling source sites = 2.0000E-03 seconds\n",
" SEND/RECV source sites = 1.0000E-03 seconds\n",
" Time accumulating tallies = 0.0000E+00 seconds\n",
" Total time for finalization = 0.0000E+00 seconds\n",
" Total time elapsed = 1.6977E+01 seconds\n",
" Calculation Rate (inactive) = 12742.1 neutrons/second\n",
" Calculation Rate (active) = 6876.63 neutrons/second\n",
" Total time elapsed = 2.1776E+01 seconds\n",
" Calculation Rate (inactive) = 9300.60 neutrons/second\n",
" Calculation Rate (active) = 5405.41 neutrons/second\n",
"\n",
" ============================> RESULTS <============================\n",
"\n",
@ -669,20 +666,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition to the statepoint file, our simulation also created a summary file which encapsulates information about the materials and geometry. This is necessary for the `openmc.mgxs` module to properly process the tally data. We first create a `Summary` object and link it with the statepoint."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Load the summary file and link it with the statepoint\n",
"su = openmc.Summary('summary.h5')\n",
"sp.link_with_summary(su)"
"In addition to the statepoint file, our simulation also created a summary file which encapsulates information about the materials and geometry. By default, a `Summary` object is automatically linked when a `StatePoint` is loaded. This is necessary for the `openmc.mgxs` module to properly process the tally data."
]
},
{
@ -694,7 +678,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 17,
"metadata": {
"collapsed": false
},
@ -729,7 +713,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 18,
"metadata": {
"collapsed": false
},
@ -764,7 +748,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 19,
"metadata": {
"collapsed": false
},
@ -811,7 +795,7 @@
"0 1 2 total 1.292013 0.007642"
]
},
"execution_count": 20,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@ -830,7 +814,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 20,
"metadata": {
"collapsed": true
},
@ -848,7 +832,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 21,
"metadata": {
"collapsed": false
},
@ -875,7 +859,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 22,
"metadata": {
"collapsed": false
},
@ -932,7 +916,7 @@
"1 (((total / flux) - (absorption / flux)) - (sca... 1.44e-15 2.57e-03 "
]
},
"execution_count": 23,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@ -954,7 +938,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 23,
"metadata": {
"collapsed": false
},
@ -1011,7 +995,7 @@
"1 ((absorption / flux) / (total / flux)) 1.93e-02 9.46e-05 "
]
},
"execution_count": 24,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
@ -1026,7 +1010,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 24,
"metadata": {
"collapsed": false
},
@ -1083,7 +1067,7 @@
"1 ((scatter / flux) / (total / flux)) 9.81e-01 3.74e-03 "
]
},
"execution_count": 25,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
@ -1105,7 +1089,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 25,
"metadata": {
"collapsed": false
},
@ -1135,7 +1119,7 @@
" <td>6.250000e-07</td>\n",
" <td>total</td>\n",
" <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
" <td>1</td>\n",
" <td>1.0</td>\n",
" <td>0.007763</td>\n",
" </tr>\n",
" <tr>\n",
@ -1145,7 +1129,7 @@
" <td>2.000000e+01</td>\n",
" <td>total</td>\n",
" <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
" <td>1</td>\n",
" <td>1.0</td>\n",
" <td>0.003739</td>\n",
" </tr>\n",
" </tbody>\n",
@ -1162,7 +1146,7 @@
"1 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 3.74e-03 "
]
},
"execution_count": 26,
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
@ -1178,21 +1162,21 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
"pygments_lexer": "ipython3",
"version": "3.5.1"
}
},
"nbformat": 4,

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

File diff suppressed because one or more lines are too long

View file

@ -4,9 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook shows the how tallies can be combined (added, subtracted, multiplied, etc.) using the Python API in order to create derived tallies. Since no covariance information is obtained, it is assumed that tallies are completely independent of one another when propagating uncertainties. The target problem is a simple pin cell.\n",
"\n",
"**Note:** that this Notebook was created using the latest Pandas v0.16.1. Everything in the Notebook will wun with older versions of Pandas, but the multi-indexing option in >v0.15.0 makes the tables look prettier."
"This notebook shows the how tallies can be combined (added, subtracted, multiplied, etc.) using the Python API in order to create derived tallies. Since no covariance information is obtained, it is assumed that tallies are completely independent of one another when propagating uncertainties. The target problem is a simple pin cell."
]
},
{
@ -16,18 +14,6 @@
"collapsed": false
},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import glob\n",
"from IPython.display import Image\n",
@ -52,7 +38,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {
"collapsed": true
},
@ -76,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {
"collapsed": false
},
@ -111,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {
"collapsed": false
},
@ -134,7 +120,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {
"collapsed": false
},
@ -163,7 +149,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {
"collapsed": false
},
@ -200,7 +186,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {
"collapsed": false
},
@ -227,7 +213,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {
"collapsed": false
},
@ -240,7 +226,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {
"collapsed": false
},
@ -259,7 +245,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {
"collapsed": true
},
@ -295,7 +281,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"metadata": {
"collapsed": false
},
@ -323,7 +309,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"metadata": {
"collapsed": false
},
@ -334,7 +320,7 @@
"0"
]
},
"execution_count": 13,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@ -346,19 +332,19 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6AgMAAAD1grKuAAAABGdBTUEAALGPC/xhBQAAACBjSFJN\nAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX///9yEhLpgJFNv8Tq\nQYT7AAAAAWJLR0QAiAUdSAAAAAd0SU1FB+AEHgslKE7FoLIAAALKSURBVGje7dpLcqQwDAbgHHE2\nYeEj+D4cwQucBUfo+3CEXoSp8OhuhF70T4qpKXmdr21LogK2Pj7A8QmNP+HDhw8fPnz48Kf6VH9G\n+66vy+je8k19jnf8C5dXIPv86ms56lPdjvaYbyodx3ze+XLE76cXFiD4zPji99z0/AJ4n1lfvJ6f\nnl0A6x+578efMSg1wPr172/jPO5yFXM+Ef78gdblM+WPHyguP//t1/g6pA0wfln+ho/fwgYYn19C\n/xwDvwHGc9OvC+hs37DTrwuwfWanXxdQTC9Mvyygs3wjTL8uwPJpn/tNDbSGz7T0SBEWw4vLXzbQ\n6b6RoveIoO6TvPxlA63qs7z8ZQPF9F+SH22vbX8OQKf5Rtv+EgDNJ3X58wZaxWd1+fMGiuFvir8b\nvjp8J/tGy/6jAmRvhW8fwL3vVT+o3grfPoB7r/IpALI3tz8FoJN84/NV873hB8UnM3xzANtf8nb4\ndwmg3grfFEDJO8JPE0i9Ff4pAYL3pI8mkHor/HMCeO9JH00g9SafEsh7T/ppARBvp48UwJnelT5S\nACd7O31TAlnvKx9SQCd7B58KgPO+8iMFuPWe9E8F8BveWX7bAjzX9y4//Jve+fhsH6Ctv7n8PTzj\nvY/v9gEOHz58+PBX+6v/f/wPvnd54f3j6venE/yl769Xv7+j3x/o98/V32/o9+fl389Xnx+g5x/o\n+Qt6/oOeP6HnX+j5G3z+h54/ouefV5/foufP6Pk3ev4On/+j9w/o/Qd6/4Le/6D3T/D9V67Y/ZsV\nQBq+s+8f0ftP+P41axXguP9NWgDuu/Cdfv+N3r/D9/9TAID+A7T/Ae2/gPs/0P4TtP8F7r9J3AIO\n9P+g/Udw/9Oygbf7r9D+L7j/DO1/Q/vv4P4/tP8Q7n9E+y/h/k+0/xTuf4X7b+H+X7T/+BPuf3aM\n8OHDhw8fPnz4w/4vzcvgeY10sY0AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTYtMDQtMzBUMDY6Mzc6\nNDAtMDU6MDAMbOxZAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE2LTA0LTMwVDA2OjM3OjQwLTA1OjAw\nfTFU5QAAAABJRU5ErkJggg==\n",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6AgMAAAD1grKuAAAABGdBTUEAALGPC/xhBQAAACBjSFJN\nAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX///9yEhLpgJFNv8Tq\nQYT7AAAAAWJLR0QAiAUdSAAAAAd0SU1FB+AFBRQzLY81/IkAAALKSURBVGje7dpLcqQwDAbgHHE2\nYeEj+D4cwQucBUfo+3CEXoSp8OhuhF70T4qpKXmdr21LogK2Pj7A8QmNP+HDhw8fPnz48Kf6VH9G\n+66vy+je8k19jnf8C5dXIPv86ms56lPdjvaYbyodx3ze+XLE76cXFiD4zPji99z0/AJ4n1lfvJ6f\nnl0A6x+578efMSg1wPr172/jPO5yFXM+Ef78gdblM+WPHyguP//t1/g6pA0wfln+ho/fwgYYn19C\n/xwDvwHGc9OvC+hs37DTrwuwfWanXxdQTC9Mvyygs3wjTL8uwPJpn/tNDbSGz7T0SBEWw4vLXzbQ\n6b6RoveIoO6TvPxlA63qs7z8ZQPF9F+SH22vbX8OQKf5Rtv+EgDNJ3X58wZaxWd1+fMGiuFvir8b\nvjp8J/tGy/6jAmRvhW8fwL3vVT+o3grfPoB7r/IpALI3tz8FoJN84/NV873hB8UnM3xzANtf8nb4\ndwmg3grfFEDJO8JPE0i9Ff4pAYL3pI8mkHor/HMCeO9JH00g9SafEsh7T/ppARBvp48UwJnelT5S\nACd7O31TAlnvKx9SQCd7B58KgPO+8iMFuPWe9E8F8BveWX7bAjzX9y4//Jve+fhsH6Ctv7n8PTzj\nvY/v9gEOHz58+PBX+6v/f/wPvnd54f3j6venE/yl769Xv7+j3x/o98/V32/o9+fl389Xnx+g5x/o\n+Qt6/oOeP6HnX+j5G3z+h54/ouefV5/foufP6Pk3ev4On/+j9w/o/Qd6/4Le/6D3T/D9V67Y/ZsV\nQBq+s+8f0ftP+P41axXguP9NWgDuu/Cdfv+N3r/D9/9TAID+A7T/Ae2/gPs/0P4TtP8F7r9J3AIO\n9P+g/Udw/9Oygbf7r9D+L7j/DO1/Q/vv4P4/tP8Q7n9E+y/h/k+0/xTuf4X7b+H+X7T/+BPuf3aM\n8OHDhw8fPnz4w/4vzcvgeY10sY0AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTYtMDUtMDVUMTQ6NTE6\nNDUtMDY6MDCqOITjAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE2LTA1LTA1VDE0OjUxOjQ1LTA2OjAw\n22U8XwAAAABJRU5ErkJggg==\n",
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"execution_count": 14,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@ -380,7 +366,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 14,
"metadata": {
"collapsed": false
},
@ -392,7 +378,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 15,
"metadata": {
"collapsed": false
},
@ -429,7 +415,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 16,
"metadata": {
"collapsed": true
},
@ -445,7 +431,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 17,
"metadata": {
"collapsed": false
},
@ -460,7 +446,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 18,
"metadata": {
"collapsed": false
},
@ -476,7 +462,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 19,
"metadata": {
"collapsed": true
},
@ -491,7 +477,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 20,
"metadata": {
"collapsed": true
},
@ -511,7 +497,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 21,
"metadata": {
"collapsed": false
},
@ -530,7 +516,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 22,
"metadata": {
"collapsed": false,
"scrolled": true
@ -556,8 +542,8 @@
" Copyright: 2011-2016 Massachusetts Institute of Technology\n",
" License: http://openmc.readthedocs.org/en/latest/license.html\n",
" Version: 0.7.1\n",
" Git SHA1: ae083cf5d491e6a778d5b762dad19c8d5fe45238\n",
" Date/Time: 2016-04-30 06:37:41\n",
" Git SHA1: df280b60eb1c6d7b7f842e05ede734a4883a0fc8\n",
" Date/Time: 2016-05-05 14:51:45\n",
"\n",
" ===========================================================================\n",
" ========================> INITIALIZATION <=========================\n",
@ -613,20 +599,20 @@
"\n",
" =======================> TIMING STATISTICS <=======================\n",
"\n",
" Total time for initialization = 7.0900E-01 seconds\n",
" Reading cross sections = 4.0400E-01 seconds\n",
" Total time in simulation = 1.7108E+01 seconds\n",
" Time in transport only = 1.7093E+01 seconds\n",
" Time in inactive batches = 3.3970E+00 seconds\n",
" Time in active batches = 1.3711E+01 seconds\n",
" Total time for initialization = 7.2500E-01 seconds\n",
" Reading cross sections = 4.4400E-01 seconds\n",
" Total time in simulation = 1.5547E+01 seconds\n",
" Time in transport only = 1.5527E+01 seconds\n",
" Time in inactive batches = 2.2880E+00 seconds\n",
" Time in active batches = 1.3259E+01 seconds\n",
" Time synchronizing fission bank = 1.0000E-03 seconds\n",
" Sampling source sites = 1.0000E-03 seconds\n",
" Sampling source sites = 0.0000E+00 seconds\n",
" SEND/RECV source sites = 0.0000E+00 seconds\n",
" Time accumulating tallies = 0.0000E+00 seconds\n",
" Total time for finalization = 1.0000E-03 seconds\n",
" Total time elapsed = 1.7835E+01 seconds\n",
" Calculation Rate (inactive) = 3679.72 neutrons/second\n",
" Calculation Rate (active) = 2735.03 neutrons/second\n",
" Time accumulating tallies = 1.0000E-03 seconds\n",
" Total time for finalization = 2.0000E-03 seconds\n",
" Total time elapsed = 1.6291E+01 seconds\n",
" Calculation Rate (inactive) = 5463.29 neutrons/second\n",
" Calculation Rate (active) = 2828.27 neutrons/second\n",
"\n",
" ============================> RESULTS <============================\n",
"\n",
@ -644,7 +630,7 @@
"0"
]
},
"execution_count": 23,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@ -673,7 +659,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 23,
"metadata": {
"collapsed": false,
"scrolled": true
@ -684,27 +670,6 @@
"sp = openmc.StatePoint('statepoint.20.h5')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You may have also noticed we instructed OpenMC to create a summary file with lots of geometry information in it. This can help to produce more sensible output from the Python API, so we will use the summary file to link against."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [],
"source": [
"# Load the summary file and link with statepoint\n",
"su = openmc.Summary('summary.h5')\n",
"sp.link_with_summary(su)"
]
},
{
"cell_type": "markdown",
"metadata": {},
@ -716,7 +681,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 24,
"metadata": {
"collapsed": false
},
@ -752,7 +717,7 @@
"0 total (nu-fission / absorption) 1.04e+00 6.14e-03"
]
},
"execution_count": 26,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
@ -776,7 +741,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 25,
"metadata": {
"collapsed": false
},
@ -816,7 +781,7 @@
"0 0.00e+00 6.25e-07 total absorption 6.93e-01 4.11e-03"
]
},
"execution_count": 27,
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
@ -838,7 +803,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 26,
"metadata": {
"collapsed": false
},
@ -878,7 +843,7 @@
"0 0.00e+00 6.25e-07 total nu-fission 1.20e+00 7.60e-03"
]
},
"execution_count": 28,
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
@ -901,7 +866,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 27,
"metadata": {
"collapsed": false
},
@ -946,7 +911,7 @@
"0 4.72e-03 "
]
},
"execution_count": 29,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
@ -967,7 +932,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 28,
"metadata": {
"collapsed": false
},
@ -1012,7 +977,7 @@
"0 (nu-fission / absorption) 1.66e+00 1.13e-02 "
]
},
"execution_count": 30,
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
@ -1032,7 +997,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 29,
"metadata": {
"collapsed": false
},
@ -1077,7 +1042,7 @@
"0 (((absorption * nu-fission) * absorption) * (n... 1.04e+00 1.32e-02 "
]
},
"execution_count": 31,
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
@ -1098,7 +1063,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 30,
"metadata": {
"collapsed": false,
"scrolled": true
@ -1114,7 +1079,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 31,
"metadata": {
"collapsed": false
},
@ -1243,7 +1208,7 @@
"7 (scatter / flux) 3.37e-03 1.44e-05 "
]
},
"execution_count": 33,
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
@ -1262,7 +1227,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 32,
"metadata": {
"collapsed": false
},
@ -1294,7 +1259,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 33,
"metadata": {
"collapsed": false
},
@ -1318,7 +1283,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 34,
"metadata": {
"collapsed": false
},
@ -1349,7 +1314,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 35,
"metadata": {
"collapsed": false
},
@ -1430,7 +1395,7 @@
"3 7.32e-04 "
]
},
"execution_count": 37,
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
@ -1443,7 +1408,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 36,
"metadata": {
"collapsed": false
},
@ -1584,7 +1549,7 @@
"8 3.20e-03 "
]
},
"execution_count": 38,
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}

View file

@ -33,6 +33,10 @@ class Cell(object):
automatically be assigned.
name : str, optional
Name of the cell. If not specified, the name is the empty string.
fill : openmc.Material or openmc.Universe or openmc.Lattice or 'void' or iterable of openmc.Material, optional
Indicates what the region of space is filled with
region : openmc.Region, optional
Region of space that is assigned to the cell.
Attributes
----------
@ -58,7 +62,7 @@ class Cell(object):
"""
def __init__(self, cell_id=None, name=''):
def __init__(self, cell_id=None, name='', fill=None, region=None):
# Initialize Cell class attributes
self.id = cell_id
self.name = name
@ -70,6 +74,11 @@ class Cell(object):
self._offsets = None
self._distribcell_index = None
if fill is not None:
self.fill = fill
if region is not None:
self.region = region
def __eq__(self, other):
if not isinstance(other, Cell):
return False

View file

@ -32,11 +32,11 @@ class Lattice(object):
Name of the lattice
pitch : float
Pitch of the lattice in cm
outer : int
The unique identifier of a universe to fill all space outside the
lattice
universes : numpy.ndarray of openmc.Universe
An array of universes filling each element of the lattice
outer : openmc.Universe
A universe to fill all space outside the lattice
universes : Iterable of Iterable of openmc.Universe
A two- or three-dimensional list/array of universes filling each element
of the lattice
"""
@ -259,6 +259,13 @@ class RectLattice(Lattice):
lower_left : Iterable of float
The coordinates of the lower-left corner of the lattice. If the lattice
is two-dimensional, only the x- and y-coordinates are specified.
pitch : float
Pitch of the lattice in cm
outer : openmc.Universe
A universe to fill all space outside the lattice
universes : Iterable of Iterable of openmc.Universe
A two- or three-dimensional list/array of universes filling each element
of the lattice
"""
@ -505,6 +512,13 @@ class HexLattice(Lattice):
center : Iterable of float
Coordinates of the center of the lattice. If the lattice does not have
axial sections then only the x- and y-coordinates are specified
pitch : float
Pitch of the lattice in cm
outer : openmc.Universe
A universe to fill all space outside the lattice
universes : Iterable of Iterable of openmc.Universe
A two- or three-dimensional list/array of universes filling each element
of the lattice
"""
@ -635,7 +649,7 @@ class HexLattice(Lattice):
# Set the number of rings and make sure this number is consistent for
# all axial positions.
if n_dims == 3:
self.num_rings = len(self._universes)
self.num_rings = len(self._universes[0])
for rings in self._universes:
if len(rings) != self._num_rings:
msg = 'HexLattice ID={0:d} has an inconsistent number of ' \

View file

@ -1,5 +1,6 @@
import sys
import re
import os
import numpy as np
import openmc
@ -14,6 +15,14 @@ class StatePoint(object):
of a given batch). Statepoints can be used to analyze tally results as well
as restart a simulation.
Parameters
----------
filename : str
Path to file to load
autolink : bool, optional
Whether to automatically link in metadata from a summary.h5
file. Defaults to True.
Attributes
----------
cmfd_on : bool
@ -93,7 +102,7 @@ class StatePoint(object):
"""
def __init__(self, filename):
def __init__(self, filename, autolink=True):
import h5py
self._f = h5py.File(filename, 'r')
@ -116,10 +125,17 @@ class StatePoint(object):
# Set flags for what data has been read
self._meshes_read = False
self._tallies_read = False
self._summary = False
self._summary = None
self._global_tallies = None
self._sparse = False
# Automatically link in a summary file if one exists
if autolink:
path_summary = os.path.join(os.path.dirname(filename), 'summary.h5')
if os.path.exists(path_summary):
su = openmc.Summary(path_summary)
self.link_with_summary(su)
def close(self):
self._f.close()
@ -612,6 +628,11 @@ class StatePoint(object):
"""
if self.summary is not None:
warnings.warn('A Summary object has already been linked.',
RuntimeWarning)
return
if not isinstance(summary, openmc.summary.Summary):
msg = 'Unable to link statepoint with "{0}" which ' \
'is not a Summary object'.format(summary)

View file

@ -65,9 +65,10 @@ class Summary(object):
self.n_batches = self._f['n_batches'].value
self.n_particles = self._f['n_particles'].value
self.n_active = self._f['n_active'].value
self.n_inactive = self._f['n_inactive'].value
self.gen_per_batch = self._f['gen_per_batch'].value
if 'n_inactive' in self._f:
self.n_active = self._f['n_active'].value
self.n_inactive = self._f['n_inactive'].value
self.gen_per_batch = self._f['gen_per_batch'].value
self.n_procs = self._f['n_procs'].value
def _read_geometry(self):
@ -378,11 +379,11 @@ class Summary(object):
self.lattices[index] = lattice
if lattice_type == 'hexagonal':
n_rings = self._f['geometry/lattices'][key]['n_rings'][0]
n_axial = self._f['geometry/lattices'][key]['n_axial'][0]
n_rings = self._f['geometry/lattices'][key]['n_rings'].value
n_axial = self._f['geometry/lattices'][key]['n_axial'].value
center = self._f['geometry/lattices'][key]['center'][...]
pitch = self._f['geometry/lattices'][key]['pitch'][...]
outer = self._f['geometry/lattices'][key]['outer'][0]
outer = self._f['geometry/lattices'][key]['outer'].value
universe_ids = self._f[
'geometry/lattices'][key]['universes'][...]

View file

@ -36,6 +36,8 @@ class Universe(object):
automatically be assigned
name : str, optional
Name of the universe. If not specified, the name is the empty string.
cells : Iterable of openmc.Cell, optional
Cells to add to the universe. By default no cells are added.
Attributes
----------
@ -49,7 +51,7 @@ class Universe(object):
"""
def __init__(self, universe_id=None, name=''):
def __init__(self, universe_id=None, name='', cells=None):
# Initialize Cell class attributes
self.id = universe_id
self.name = name
@ -61,7 +63,9 @@ class Universe(object):
# Keys - Cell IDs
# Values - Offsets
self._cell_offsets = OrderedDict()
self._num_regions = 0
if cells is not None:
self.add_cells(cells)
def __eq__(self, other):
if not isinstance(other, Universe):
@ -87,8 +91,6 @@ class Universe(object):
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
string += '{0: <16}{1}{2}\n'.format('\tCells', '=\t',
list(self._cells.keys()))
string += '{0: <16}{1}{2}\n'.format('\t# Regions', '=\t',
self._num_regions)
return string
@property

View file

@ -54,7 +54,7 @@ contains
write(UNIT=OUTPUT_UNIT, FMT=*) &
' Copyright: 2011-2016 Massachusetts Institute of Technology'
write(UNIT=OUTPUT_UNIT, FMT=*) &
' License: http://openmc.readthedocs.org/en/latest/license.html'
' License: http://openmc.readthedocs.io/en/latest/license.html'
write(UNIT=OUTPUT_UNIT, FMT='(6X,"Version:",8X,I1,".",I1,".",I1)') &
VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE
#ifdef GIT_SHA1

View file

@ -82,11 +82,6 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Extract the tally of interest
tally = sp.get_tally(name='distribcell tally')
@ -96,8 +91,8 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
outstr += ', '.join(map(str, tally.std_dev.flatten())) + '\n'
# Extract fuel assembly lattices from the summary
core = su.get_cell_by_id(1)
fuel = su.get_cell_by_id(80)
core = sp.summary.get_cell_by_id(1)
fuel = sp.summary.get_cell_by_id(80)
fuel = fuel.fill
core = core.fill

View file

@ -43,11 +43,6 @@ class MGXSTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file.
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Load the MGXS library from the statepoint
self.mgxs_lib.load_from_statepoint(sp)

View file

@ -46,11 +46,6 @@ class MGXSTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file.
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Load the MGXS library from the statepoint
self.mgxs_lib.load_from_statepoint(sp)

View file

@ -44,11 +44,6 @@ class MGXSTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file.
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Load the MGXS library from the statepoint
self.mgxs_lib.load_from_statepoint(sp)

View file

@ -43,11 +43,6 @@ class MGXSTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file.
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Load the MGXS library from the statepoint
self.mgxs_lib.load_from_statepoint(sp)

View file

@ -43,11 +43,6 @@ class MGXSTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file.
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Load the MGXS library from the statepoint
self.mgxs_lib.load_from_statepoint(sp)

View file

@ -43,11 +43,6 @@ class TallyAggregationTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file.
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Extract the tally of interest
tally = sp.get_tally(name='distribcell tally')

View file

@ -62,11 +62,6 @@ class TallyArithmeticTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file.
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Load the tallies
tally_1 = sp.get_tally(name='tally 1')
tally_2 = sp.get_tally(name='tally 2')

View file

@ -83,11 +83,6 @@ class TallySliceMergeTestHarness(PyAPITestHarness):
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
sp = openmc.StatePoint(statepoint)
# Read the summary file.
summary = glob.glob(os.path.join(os.getcwd(), 'summary.h5'))[0]
su = openmc.Summary(summary)
sp.link_with_summary(su)
# Extract the cell tally
tallies = [sp.get_tally(name='cell tally')]