From 9686543fa0890dd2a923fdc7ffa546afc54e9b6b Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Tue, 5 Jul 2016 18:38:56 -0400 Subject: [PATCH] implemented mesh domain in mgxs --- .../pythonapi/examples/mgxs-part-i.ipynb | 586 +++++++----------- openmc/__init__.py | 2 +- openmc/mgxs/mgxs.py | 348 +++++++---- openmc/tallies.py | 2 +- 4 files changed, 468 insertions(+), 470 deletions(-) diff --git a/docs/source/pythonapi/examples/mgxs-part-i.ipynb b/docs/source/pythonapi/examples/mgxs-part-i.ipynb index ded04e479..ff242885e 100644 --- a/docs/source/pythonapi/examples/mgxs-part-i.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-i.ipynb @@ -326,7 +326,7 @@ "# OpenMC simulation parameters\n", "batches = 50\n", "inactive = 10\n", - "particles = 2500\n", + "particles = 1000\n", "\n", "# Instantiate a Settings object\n", "settings_file = openmc.Settings()\n", @@ -398,10 +398,17 @@ }, "outputs": [], "source": [ + "# Instantiate a tally Mesh\n", + "mesh = openmc.Mesh(name='mesh')\n", + "mesh.type = 'regular'\n", + "mesh.dimension = [2, 2]\n", + "mesh.lower_left = [-0.63, -0.63]\n", + "mesh.upper_right = [+0.63, +0.63]\n", + "\n", "# Instantiate a few different sections\n", - "total = mgxs.TotalXS(domain=cell, groups=groups)\n", - "absorption = mgxs.AbsorptionXS(domain=cell, groups=groups)\n", - "scattering = mgxs.ScatterXS(domain=cell, groups=groups)" + "total = mgxs.TotalXS(domain=mesh, groups=groups)\n", + "absorption = mgxs.AbsorptionXS(domain=mesh, groups=groups)\n", + "scattering = mgxs.ScatterXS(domain=mesh, groups=groups)" ] }, { @@ -422,24 +429,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\tmesh\t[10000]\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\tmesh\t[10000]\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, @@ -516,9 +521,9 @@ " Copyright: 2011-2016 Massachusetts Institute of Technology\n", " License: http://openmc.readthedocs.io/en/latest/license.html\n", " Version: 0.7.1\n", - " Git SHA1: 19feb55e6d5e8350398627f39fb55ee8e2e63011\n", - " Date/Time: 2016-05-13 10:19:16\n", - " MPI Processes: 1\n", + " Git SHA1: 736d7aa5ba3bcd1a8a1614ce4b6769babcb1d8ca\n", + " Date/Time: 2016-07-05 16:23:08\n", + " MPI Processes: 4\n", "\n", " ===========================================================================\n", " ========================> INITIALIZATION <=========================\n", @@ -544,56 +549,56 @@ "\n", " Bat./Gen. k Average k \n", " ========= ======== ==================== \n", - " 1/1 1.11184 \n", - " 2/1 1.15820 \n", - " 3/1 1.18468 \n", - " 4/1 1.17492 \n", - " 5/1 1.19645 \n", - " 6/1 1.18436 \n", - " 7/1 1.14070 \n", - " 8/1 1.15150 \n", - " 9/1 1.19202 \n", - " 10/1 1.17677 \n", - " 11/1 1.20272 \n", - " 12/1 1.21366 1.20819 +/- 0.00547\n", - " 13/1 1.15906 1.19181 +/- 0.01668\n", - " 14/1 1.14687 1.18058 +/- 0.01629\n", - " 15/1 1.14570 1.17360 +/- 0.01442\n", - " 16/1 1.13480 1.16713 +/- 0.01343\n", - " 17/1 1.17680 1.16852 +/- 0.01144\n", - " 18/1 1.16866 1.16853 +/- 0.00990\n", - " 19/1 1.19253 1.17120 +/- 0.00913\n", - " 20/1 1.18124 1.17220 +/- 0.00823\n", - " 21/1 1.19206 1.17401 +/- 0.00766\n", - " 22/1 1.17681 1.17424 +/- 0.00700\n", - " 23/1 1.17634 1.17440 +/- 0.00644\n", - " 24/1 1.13659 1.17170 +/- 0.00654\n", - " 25/1 1.17144 1.17169 +/- 0.00609\n", - " 26/1 1.20649 1.17386 +/- 0.00610\n", - " 27/1 1.11238 1.17024 +/- 0.00678\n", - " 28/1 1.18911 1.17129 +/- 0.00647\n", - " 29/1 1.14681 1.17000 +/- 0.00626\n", - " 30/1 1.12152 1.16758 +/- 0.00641\n", - " 31/1 1.12729 1.16566 +/- 0.00639\n", - " 32/1 1.15399 1.16513 +/- 0.00612\n", - " 33/1 1.13547 1.16384 +/- 0.00599\n", - " 34/1 1.17723 1.16440 +/- 0.00576\n", - " 35/1 1.09296 1.16154 +/- 0.00622\n", - " 36/1 1.19621 1.16287 +/- 0.00612\n", - " 37/1 1.12560 1.16149 +/- 0.00605\n", - " 38/1 1.17872 1.16211 +/- 0.00586\n", - " 39/1 1.17721 1.16263 +/- 0.00568\n", - " 40/1 1.13724 1.16178 +/- 0.00555\n", - " 41/1 1.18526 1.16254 +/- 0.00542\n", - " 42/1 1.13779 1.16177 +/- 0.00531\n", - " 43/1 1.15066 1.16143 +/- 0.00516\n", - " 44/1 1.12174 1.16026 +/- 0.00514\n", - " 45/1 1.17479 1.16068 +/- 0.00501\n", - " 46/1 1.14146 1.16014 +/- 0.00489\n", - " 47/1 1.20464 1.16135 +/- 0.00491\n", - " 48/1 1.15119 1.16108 +/- 0.00479\n", - " 49/1 1.17938 1.16155 +/- 0.00468\n", - " 50/1 1.15798 1.16146 +/- 0.00457\n", + " 1/1 1.07993 \n", + " 2/1 1.23691 \n", + " 3/1 1.17407 \n", + " 4/1 1.08258 \n", + " 5/1 1.21012 \n", + " 6/1 1.23825 \n", + " 7/1 1.18016 \n", + " 8/1 1.20989 \n", + " 9/1 1.15475 \n", + " 10/1 1.13462 \n", + " 11/1 1.12749 \n", + " 12/1 1.09502 1.11125 +/- 0.01623\n", + " 13/1 1.24722 1.15657 +/- 0.04628\n", + " 14/1 1.14700 1.15418 +/- 0.03281\n", + " 15/1 1.13889 1.15112 +/- 0.02560\n", + " 16/1 1.19008 1.15762 +/- 0.02189\n", + " 17/1 1.11320 1.15127 +/- 0.01956\n", + " 18/1 1.12093 1.14748 +/- 0.01736\n", + " 19/1 1.13809 1.14643 +/- 0.01534\n", + " 20/1 1.09886 1.14168 +/- 0.01452\n", + " 21/1 1.15457 1.14285 +/- 0.01319\n", + " 22/1 1.19951 1.14757 +/- 0.01293\n", + " 23/1 1.13296 1.14645 +/- 0.01195\n", + " 24/1 1.15322 1.14693 +/- 0.01107\n", + " 25/1 1.26213 1.15461 +/- 0.01286\n", + " 26/1 1.11758 1.15230 +/- 0.01225\n", + " 27/1 1.19061 1.15455 +/- 0.01172\n", + " 28/1 1.17562 1.15572 +/- 0.01111\n", + " 29/1 1.15989 1.15594 +/- 0.01051\n", + " 30/1 1.19989 1.15814 +/- 0.01021\n", + " 31/1 1.14498 1.15751 +/- 0.00974\n", + " 32/1 1.11494 1.15558 +/- 0.00948\n", + " 33/1 1.13251 1.15457 +/- 0.00912\n", + " 34/1 1.17943 1.15561 +/- 0.00879\n", + " 35/1 1.21182 1.15786 +/- 0.00872\n", + " 36/1 1.16118 1.15798 +/- 0.00838\n", + " 37/1 1.13679 1.15720 +/- 0.00811\n", + " 38/1 1.15684 1.15719 +/- 0.00781\n", + " 39/1 1.12450 1.15606 +/- 0.00762\n", + " 40/1 1.30157 1.16091 +/- 0.00882\n", + " 41/1 1.04558 1.15719 +/- 0.00930\n", + " 42/1 1.16538 1.15745 +/- 0.00901\n", + " 43/1 1.17710 1.15804 +/- 0.00875\n", + " 44/1 1.13273 1.15730 +/- 0.00853\n", + " 45/1 1.19156 1.15828 +/- 0.00834\n", + " 46/1 1.19404 1.15927 +/- 0.00816\n", + " 47/1 1.19058 1.16012 +/- 0.00798\n", + " 48/1 1.12943 1.15931 +/- 0.00781\n", + " 49/1 1.22428 1.16097 +/- 0.00779\n", + " 50/1 1.07496 1.15882 +/- 0.00789\n", " Creating state point statepoint.50.h5...\n", "\n", " ===========================================================================\n", @@ -603,27 +608,27 @@ "\n", " =======================> TIMING STATISTICS <=======================\n", "\n", - " Total time for initialization = 4.2300E-01 seconds\n", - " Reading cross sections = 9.3000E-02 seconds\n", - " Total time in simulation = 1.6549E+01 seconds\n", - " Time in transport only = 1.6535E+01 seconds\n", - " Time in inactive batches = 2.3650E+00 seconds\n", - " Time in active batches = 1.4184E+01 seconds\n", - " Time synchronizing fission bank = 5.0000E-03 seconds\n", - " Sampling source sites = 3.0000E-03 seconds\n", + " Total time for initialization = 8.6600E-01 seconds\n", + " Reading cross sections = 2.2400E-01 seconds\n", + " Total time in simulation = 3.0950E+00 seconds\n", + " Time in transport only = 2.9310E+00 seconds\n", + " Time in inactive batches = 2.8000E-01 seconds\n", + " Time in active batches = 2.8150E+00 seconds\n", + " Time synchronizing fission bank = 1.4200E-01 seconds\n", + " Sampling source sites = 1.0000E-03 seconds\n", " SEND/RECV source sites = 0.0000E+00 seconds\n", - " Time accumulating tallies = 0.0000E+00 seconds\n", - " Total time for finalization = 0.0000E+00 seconds\n", - " Total time elapsed = 1.6981E+01 seconds\n", - " Calculation Rate (inactive) = 10570.8 neutrons/second\n", - " Calculation Rate (active) = 7050.20 neutrons/second\n", + " Time accumulating tallies = 2.0000E-03 seconds\n", + " Total time for finalization = 3.0000E-03 seconds\n", + " Total time elapsed = 3.9660E+00 seconds\n", + " Calculation Rate (inactive) = 35714.3 neutrons/second\n", + " Calculation Rate (active) = 14209.6 neutrons/second\n", "\n", " ============================> RESULTS <============================\n", "\n", - " k-effective (Collision) = 1.15984 +/- 0.00411\n", - " k-effective (Track-length) = 1.16146 +/- 0.00457\n", - " k-effective (Absorption) = 1.16177 +/- 0.00380\n", - " Combined k-effective = 1.16105 +/- 0.00364\n", + " k-effective (Collision) = 1.15707 +/- 0.00744\n", + " k-effective (Track-length) = 1.15882 +/- 0.00789\n", + " k-effective (Absorption) = 1.16215 +/- 0.00476\n", + " Combined k-effective = 1.16131 +/- 0.00452\n", " Leakage Fraction = 0.00000 +/- 0.00000\n", "\n" ] @@ -641,7 +646,7 @@ ], "source": [ "# Run OpenMC\n", - "openmc.run()" + "openmc.run(mpi_procs=4)" ] }, { @@ -732,11 +737,26 @@ "text": [ "Multi-Group XS\n", "\tReaction Type =\ttotal\n", - "\tDomain Type =\tcell\n", - "\tDomain ID =\t1\n", + "\tDomain Type =\tmesh\n", + "\tDomain ID =\t10000\n", "\tCross Sections [cm^-1]:\n", - " Group 1 [6.25e-07 - 20.0 MeV]:\t6.81e-01 +/- 2.69e-01%\n", - " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 5.93e-01%\n", + " Group 1 [6.25e-07 - 20.0 MeV]:\t6.83e-01 +/- 4.53e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 1.16e+00%\n", + "\n", + "\n", + "\tCross Sections [cm^-1]:\n", + " Group 1 [6.25e-07 - 20.0 MeV]:\t6.81e-01 +/- 3.23e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 1.30e+00%\n", + "\n", + "\n", + "\tCross Sections [cm^-1]:\n", + " Group 1 [6.25e-07 - 20.0 MeV]:\t6.83e-01 +/- 3.88e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 9.89e-01%\n", + "\n", + "\n", + "\tCross Sections [cm^-1]:\n", + " Group 1 [6.25e-07 - 20.0 MeV]:\t6.82e-01 +/- 4.92e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 1.20e+00%\n", "\n", "\n", "\n" @@ -767,40 +787,121 @@ "
\n", "\n", " \n", - " \n", + " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", "
cellmesh 10000group innuclidemeanstd. dev.
xyz
11111total0.6677870.0018020.6690160.003015
01112total1.2920130.0076421.2931380.014971
31211total0.6679300.002132
21212total1.2927410.016747
52111total0.6695130.002584
42112total1.2944230.012750
72211total0.6687730.003314
62212total1.2925150.015479
\n", "
" ], "text/plain": [ - " cell group in nuclide mean std. dev.\n", - "1 1 1 total 0.667787 0.001802\n", - "0 1 2 total 1.292013 0.007642" + " mesh 10000 group in nuclide mean std. dev.\n", + " x y z \n", + "1 1 1 1 1 total 0.669016 0.003015\n", + "0 1 1 1 2 total 1.293138 0.014971\n", + "3 1 2 1 1 total 0.667930 0.002132\n", + "2 1 2 1 2 total 1.292741 0.016747\n", + "5 2 1 1 1 total 0.669513 0.002584\n", + "4 2 1 1 2 total 1.294423 0.012750\n", + "7 2 2 1 1 total 0.668773 0.003314\n", + "6 2 2 1 2 total 1.292515 0.015479" ] }, "execution_count": 19, @@ -824,9 +925,23 @@ "cell_type": "code", "execution_count": 20, "metadata": { - "collapsed": true + "collapsed": false }, - "outputs": [], + "outputs": [ + { + "ename": "TypeError", + "evalue": "Setting dtype to anything other than object is not supported", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mabsorption\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexport_xs_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'absorption-xs'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mformat\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'excel'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/Users/sam/.local/lib/python2.7/site-packages/openmc-0.7.1-py2.7.egg/openmc/mgxs/mgxs.pyc\u001b[0m in \u001b[0;36mexport_xs_data\u001b[0;34m(self, filename, directory, format, groups, xs_type)\u001b[0m\n\u001b[1;32m 1430\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1431\u001b[0m \u001b[0;31m# Capitalize column label strings\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1432\u001b[0;31m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mastype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1433\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtitle\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1434\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/core/index.pyc\u001b[0m in \u001b[0;36mastype\u001b[0;34m(self, dtype)\u001b[0m\n\u001b[1;32m 5922\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mis_object_dtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdtype\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 5923\u001b[0m raise TypeError('Setting %s dtype to anything other than object '\n\u001b[0;32m-> 5924\u001b[0;31m 'is not supported' % self.__class__)\n\u001b[0m\u001b[1;32m 5925\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_shallow_copy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5926\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: Setting dtype to anything other than object is not supported" + ] + } + ], "source": [ "absorption.export_xs_data(filename='absorption-xs', format='excel')" ] @@ -840,7 +955,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": { "collapsed": false }, @@ -867,68 +982,11 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": { "collapsed": false }, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
cellenergy low [MeV]energy high [MeV]nuclidescoremeanstd. dev.
010.000000e+006.250000e-07total(((total / flux) - (absorption / flux)) - (sca...-3.774758e-150.011292
116.250000e-072.000000e+01total(((total / flux) - (absorption / flux)) - (sca...1.443290e-150.002570
\n", - "
" - ], - "text/plain": [ - " cell energy low [MeV] energy high [MeV] nuclide \\\n", - "0 1 0.00e+00 6.25e-07 total \n", - "1 1 6.25e-07 2.00e+01 total \n", - "\n", - " score mean std. dev. \n", - "0 (((total / flux) - (absorption / flux)) - (sca... -3.77e-15 1.13e-02 \n", - "1 (((total / flux) - (absorption / flux)) - (sca... 1.44e-15 2.57e-03 " - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "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", @@ -946,68 +1004,11 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": { "collapsed": false }, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
cellenergy low [MeV]energy high [MeV]nuclidescoremeanstd. dev.
010.000000e+006.250000e-07total((absorption / flux) / (total / flux))0.0761150.000649
116.250000e-072.000000e+01total((absorption / flux) / (total / flux))0.0192630.000095
\n", - "
" - ], - "text/plain": [ - " cell energy low [MeV] energy high [MeV] nuclide \\\n", - "0 1 0.00e+00 6.25e-07 total \n", - "1 1 6.25e-07 2.00e+01 total \n", - "\n", - " score mean std. dev. \n", - "0 ((absorption / flux) / (total / flux)) 7.61e-02 6.49e-04 \n", - "1 ((absorption / flux) / (total / flux)) 1.93e-02 9.46e-05 " - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Use tally arithmetic to compute the absorption-to-total MGXS ratio\n", "absorption_to_total = absorption.xs_tally / total.xs_tally\n", @@ -1018,68 +1019,11 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "metadata": { "collapsed": false }, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
cellenergy low [MeV]energy high [MeV]nuclidescoremeanstd. dev.
010.000000e+006.250000e-07total((scatter / flux) / (total / flux))0.9238850.007736
116.250000e-072.000000e+01total((scatter / flux) / (total / flux))0.9807370.003737
\n", - "
" - ], - "text/plain": [ - " cell energy low [MeV] energy high [MeV] nuclide \\\n", - "0 1 0.00e+00 6.25e-07 total \n", - "1 1 6.25e-07 2.00e+01 total \n", - "\n", - " score mean std. dev. \n", - "0 ((scatter / flux) / (total / flux)) 9.24e-01 7.74e-03 \n", - "1 ((scatter / flux) / (total / flux)) 9.81e-01 3.74e-03 " - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Use tally arithmetic to compute the scattering-to-total MGXS ratio\n", "scattering_to_total = scattering.xs_tally / total.xs_tally\n", @@ -1097,68 +1041,11 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": { "collapsed": false }, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
cellenergy low [MeV]energy high [MeV]nuclidescoremeanstd. dev.
010.000000e+006.250000e-07total(((absorption / flux) / (total / flux)) + ((sc...1.00.007763
116.250000e-072.000000e+01total(((absorption / flux) / (total / flux)) + ((sc...1.00.003739
\n", - "
" - ], - "text/plain": [ - " cell energy low [MeV] energy high [MeV] nuclide \\\n", - "0 1 0.00e+00 6.25e-07 total \n", - "1 1 6.25e-07 2.00e+01 total \n", - "\n", - " score mean std. dev. \n", - "0 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 7.76e-03 \n", - "1 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 3.74e-03 " - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Use tally arithmetic to ensure that the absorption- and scattering-to-total MGXS ratios sum to unity\n", "sum_ratio = absorption_to_total + scattering_to_total\n", @@ -1166,6 +1053,15 @@ "# The scattering-to-total ratio is a derived tally which can generate Pandas DataFrames for inspection\n", "sum_ratio.get_pandas_dataframe()" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/openmc/__init__.py b/openmc/__init__.py index 0bde0f584..557e13039 100644 --- a/openmc/__init__.py +++ b/openmc/__init__.py @@ -9,8 +9,8 @@ from openmc.plots import * from openmc.settings import * from openmc.surface import * from openmc.universe import * -from openmc.mgxs_library import * from openmc.mesh import * +from openmc.mgxs_library import * from openmc.filter import * from openmc.trigger import * from openmc.tallies import * diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 748523608..cac5957fd 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -13,7 +13,7 @@ import numpy as np import openmc import openmc.checkvalue as cv from openmc.mgxs import EnergyGroups - +from openmc import Mesh if sys.version_info[0] >= 3: basestring = str @@ -45,13 +45,15 @@ MGXS_TYPES = ['total', DOMAIN_TYPES = ['cell', 'distribcell', 'universe', - 'material'] + 'material', + 'mesh'] # Supported domain classes # TODO: Implement Mesh domains _DOMAINS = (openmc.Cell, openmc.Universe, - openmc.Material) + openmc.Material, + openmc.Mesh) class MGXS(object): @@ -66,9 +68,9 @@ class MGXS(object): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -86,9 +88,9 @@ class MGXS(object): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -115,9 +117,10 @@ class MGXS(object): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading - tally data from a statepoint file). + tally data from a statepoint file) and the number of mesh cells for + 'mesh' domain types. num_nuclides : int The number of nuclides for which the multi-group cross section is being tracked. This is unity if the by_nuclide attribute is False. @@ -263,6 +266,10 @@ class MGXS(object): # Create a domain Filter object domain_filter = openmc.Filter(self.domain_type, self.domain.id) + # If a mesh domain, give the mesh to the domain filter + if self.domain_type == 'mesh': + domain_filter.mesh = self.domain + # Create each Tally needed to compute the multi group cross section tally_metadata = zip(self.scores, self.tally_keys, self.filters) for score, key, filters in tally_metadata: @@ -378,6 +385,8 @@ class MGXS(object): self._domain_type = 'cell' elif isinstance(domain, openmc.Universe): self._domain_type = 'universe' + elif isinstance(domain, openmc.Mesh): + self._domain_type = 'mesh' @domain_type.setter def domain_type(self, domain_type): @@ -432,9 +441,10 @@ class MGXS(object): ---------- mgxs_type : {'total', 'transport', 'nu-transport', 'absorption', 'capture', 'fission', 'nu-fission', 'kappa-fission', 'scatter', 'nu-scatter', 'scatter matrix', 'nu-scatter matrix', 'multiplicity matrix', 'nu-fission matrix', 'chi', 'chi-prompt', 'velocity', 'prompt-nu-fission'} The type of multi-group cross section object to return - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or + openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -675,6 +685,8 @@ class MGXS(object): self.domain = statepoint.summary.get_universe_by_id(self.domain.id) elif self.domain_type == 'material': self.domain = statepoint.summary.get_material_by_id(self.domain.id) + elif self.domain_type == 'mesh': + self.domain = statepoint.meshes[self.domain.id] else: msg = 'Unable to load data from a statepoint for domain type {0} ' \ 'which is not yet supported'.format(self.domain_type) @@ -682,7 +694,23 @@ class MGXS(object): # Use tally "slicing" to ensure that tallies correspond to our domain # NOTE: This is important if tally merging was used - if self.domain_type != 'distribcell': + if self.domain_type == 'mesh': + filters = [self.domain_type] + bins = [] + if (len(self.domain.dimension) == 3): + nx, ny, nz = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + for z in range(1,nz+1): + bins.append((x, y, z)) + else: + nx, ny = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + bins.append((x, y, 1)) + + filter_bins = [tuple(bins)] + elif self.domain_type != 'distribcell': filters = [self.domain_type] filter_bins = [(self.domain.id,)] # Distribcell filters only accept single cell - neglect it when slicing @@ -761,7 +789,7 @@ class MGXS(object): # Construct a collection of the domain filter bins if not isinstance(subdomains, basestring): - cv.check_iterable_type('subdomains', subdomains, Integral, max_depth=2) + cv.check_iterable_type('subdomains', subdomains, Integral, max_depth=3) for subdomain in subdomains: filters.append(self.domain_type) filter_bins.append((subdomain,)) @@ -981,16 +1009,16 @@ class MGXS(object): cv.check_iterable_type('energy_groups', groups, Integral) # Build lists of filters and filter bins to slice - if len(groups) == 0: - filters = [] - filter_bins = [] - else: - filter_bins = [] + filters = [] + filter_bins = [] + + if len(groups) != 0: + energy_bins = [] for group in groups: group_bounds = self.energy_groups.get_group_bounds(group) - filter_bins.append(group_bounds) - filter_bins = [tuple(filter_bins)] - filters = ['energy'] + energy_bins.append(group_bounds) + filter_bins.append(tuple(energy_bins)) + filters.append('energy') # Clone this MGXS to initialize the sliced version slice_xs = copy.deepcopy(self) @@ -1134,6 +1162,19 @@ class MGXS(object): cv.check_iterable_type('subdomains', subdomains, Integral) elif self.domain_type == 'distribcell': subdomains = np.arange(self.num_subdomains, dtype=np.int) + elif self.domain_type == 'mesh': + subdomains = [] + if (len(self.domain.dimension) == 3): + nx, ny, nz = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + for z in range(1,nz+1): + subdomains.append((x, y, z)) + else: + nx, ny = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + subdomains.append((x, y, 1)) else: subdomains = [self.domain.id] @@ -1270,6 +1311,19 @@ class MGXS(object): elif self.domain_type == 'avg(distribcell)': domain_filter = self.xs_tally.find_filter('avg(distribcell)') subdomains = domain_filter.bins + elif self.domain_type == 'mesh': + subdomains = [] + if (len(self.domain.dimension) == 3): + nx, ny, nz = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + for z in range(1,nz+1): + subdomains.append((x, y, z)) + else: + nx, ny = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + subdomains.append((x, y, 1)) else: subdomains = [self.domain.id] @@ -1375,8 +1429,8 @@ class MGXS(object): df = self.get_pandas_dataframe(groups=groups, xs_type=xs_type) # Capitalize column label strings - df.columns = df.columns.astype(str) - df.columns = map(str.title, df.columns) + #df.columns = df.columns.astype(str) + #df.columns = map(str.title, df.columns) # Export the data using Pandas IO API if format == 'csv': @@ -1477,7 +1531,10 @@ class MGXS(object): distribcell_paths=distribcell_paths) # Remove the score column since it is homogeneous and redundant - df = df.drop('score', axis=1) + if self.domain_type == 'mesh': + df = df.drop('score', axis=1, level=0) + else: + df = df.drop('score', axis=1) # Override energy groups bounds with indices all_groups = np.arange(self.num_groups, 0, -1, dtype=np.int) @@ -1533,7 +1590,12 @@ class MGXS(object): # Sort the dataframe by domain type id (e.g., distribcell id) and # energy groups such that data is from fast to thermal - df.sort_values(by=[self.domain_type] + columns, inplace=True) + if self.domain_type == 'mesh': + mesh_str = 'mesh {0}'.format(self.domain.id) + df.sort_values(by=[(mesh_str, 'x'), (mesh_str, 'y'), \ + (mesh_str, 'z')] + columns, inplace=True) + else: + df.sort_values(by=[self.domain_type] + columns, inplace=True) return df @@ -1552,9 +1614,9 @@ class MatrixMGXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -1572,9 +1634,9 @@ class MatrixMGXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -1601,9 +1663,10 @@ class MatrixMGXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading - tally data from a statepoint file). + tally data from a statepoint file) and the number of mesh cells for + 'mesh' domain types. num_nuclides : int The number of nuclides for which the multi-group cross section is being tracked. This is unity if the by_nuclide attribute is False. @@ -1700,7 +1763,7 @@ class MatrixMGXS(MGXS): # Construct a collection of the domain filter bins if not isinstance(subdomains, basestring): cv.check_iterable_type('subdomains', subdomains, Integral, - max_depth=2) + max_depth=3) for subdomain in subdomains: filters.append(self.domain_type) filter_bins.append((subdomain,)) @@ -1862,6 +1925,19 @@ class MatrixMGXS(MGXS): cv.check_iterable_type('subdomains', subdomains, Integral) elif self.domain_type == 'distribcell': subdomains = np.arange(self.num_subdomains, dtype=np.int) + elif self.domain_type == 'mesh': + subdomains = [] + if (len(self.domain.dimension) == 3): + nx, ny, nz = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + for z in range(1,nz+1): + subdomains.append((x, y, z)) + else: + nx, ny = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + subdomains.append((x, y, 1)) else: subdomains = [self.domain.id] @@ -1971,9 +2047,9 @@ class TotalXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -1991,9 +2067,9 @@ class TotalXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2022,7 +2098,7 @@ class TotalXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -2089,9 +2165,9 @@ class TransportXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -2109,9 +2185,9 @@ class TransportXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2140,7 +2216,7 @@ class TransportXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -2219,9 +2295,9 @@ class NuTransportXS(TransportXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -2239,9 +2315,9 @@ class NuTransportXS(TransportXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2270,7 +2346,7 @@ class NuTransportXS(TransportXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -2340,9 +2416,9 @@ class AbsorptionXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -2360,9 +2436,9 @@ class AbsorptionXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2391,7 +2467,7 @@ class AbsorptionXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -2456,9 +2532,9 @@ class CaptureXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -2476,9 +2552,9 @@ class CaptureXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2507,7 +2583,7 @@ class CaptureXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -2578,9 +2654,9 @@ class FissionXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -2598,9 +2674,9 @@ class FissionXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2629,7 +2705,7 @@ class FissionXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -2689,9 +2765,9 @@ class NuFissionXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -2709,9 +2785,9 @@ class NuFissionXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2740,7 +2816,7 @@ class NuFissionXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -2805,9 +2881,9 @@ class KappaFissionXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -2825,9 +2901,9 @@ class KappaFissionXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2856,7 +2932,7 @@ class KappaFissionXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -2918,9 +2994,9 @@ class ScatterXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -2938,9 +3014,9 @@ class ScatterXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -2969,7 +3045,7 @@ class ScatterXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -3033,9 +3109,9 @@ class NuScatterXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -3053,9 +3129,9 @@ class NuScatterXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -3084,7 +3160,7 @@ class NuScatterXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -3163,9 +3239,9 @@ class ScatterMatrixXS(MatrixMGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -3187,9 +3263,9 @@ class ScatterMatrixXS(MatrixMGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -3218,7 +3294,7 @@ class ScatterMatrixXS(MatrixMGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -3515,7 +3591,7 @@ class ScatterMatrixXS(MatrixMGXS): # Construct a collection of the domain filter bins if not isinstance(subdomains, basestring): - cv.check_iterable_type('subdomains', subdomains, Integral, max_depth=2) + cv.check_iterable_type('subdomains', subdomains, Integral, max_depth=3) for subdomain in subdomains: filters.append(self.domain_type) filter_bins.append((subdomain,)) @@ -3702,6 +3778,19 @@ class ScatterMatrixXS(MatrixMGXS): cv.check_iterable_type('subdomains', subdomains, Integral) elif self.domain_type == 'distribcell': subdomains = np.arange(self.num_subdomains, dtype=np.int) + elif self.domain_type == 'mesh': + subdomains = [] + if (len(self.domain.dimension) == 3): + nx, ny, nz = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + for z in range(1,nz+1): + subdomains.append((x, y, z)) + else: + nx, ny = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + subdomains.append((x, y, 1)) else: subdomains = [self.domain.id] @@ -3812,9 +3901,9 @@ class NuScatterMatrixXS(ScatterMatrixXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -3836,9 +3925,9 @@ class NuScatterMatrixXS(ScatterMatrixXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -3867,7 +3956,7 @@ class NuScatterMatrixXS(ScatterMatrixXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -3938,9 +4027,9 @@ class MultiplicityMatrixXS(MatrixMGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -3958,9 +4047,9 @@ class MultiplicityMatrixXS(MatrixMGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -3989,7 +4078,7 @@ class MultiplicityMatrixXS(MatrixMGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -4085,9 +4174,9 @@ class NuFissionMatrixXS(MatrixMGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -4105,9 +4194,9 @@ class NuFissionMatrixXS(MatrixMGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -4136,7 +4225,7 @@ class NuFissionMatrixXS(MatrixMGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -4200,9 +4289,9 @@ class Chi(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -4220,9 +4309,9 @@ class Chi(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -4251,7 +4340,7 @@ class Chi(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -4484,7 +4573,7 @@ class Chi(MGXS): # Construct a collection of the domain filter bins if not isinstance(subdomains, basestring): - cv.check_iterable_type('subdomains', subdomains, Integral, max_depth=2) + cv.check_iterable_type('subdomains', subdomains, Integral, max_depth=3) for subdomain in subdomains: filters.append(self.domain_type) filter_bins.append((subdomain,)) @@ -4659,9 +4748,9 @@ class ChiPrompt(Chi): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -4679,9 +4768,9 @@ class ChiPrompt(Chi): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -4710,7 +4799,7 @@ class ChiPrompt(Chi): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int @@ -4796,9 +4885,9 @@ class Velocity(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -4816,9 +4905,9 @@ class Velocity(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -4921,6 +5010,19 @@ class Velocity(MGXS): cv.check_iterable_type('subdomains', subdomains, Integral) elif self.domain_type == 'distribcell': subdomains = np.arange(self.num_subdomains, dtype=np.int) + elif self.domain_type == 'mesh': + subdomains = [] + if (len(self.domain.dimension) == 3): + nx, ny, nz = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + for z in range(1,nz+1): + subdomains.append((x, y, z)) + else: + nx, ny = self.domain.dimension + for x in range(1,nx+1): + for y in range(1,ny+1): + subdomains.append((x, y, 1)) else: subdomains = [self.domain.id] @@ -5011,9 +5113,9 @@ class PromptNuFissionXS(MGXS): Parameters ---------- - domain : openmc.Material or openmc.Cell or openmc.Universe + domain : openmc.Material or openmc.Cell or openmc.Universe or openmc.Mesh The domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} The domain type for spatial homogenization groups : openmc.mgxs.EnergyGroups The energy group structure for energy condensation @@ -5031,9 +5133,9 @@ class PromptNuFissionXS(MGXS): Reaction type (e.g., 'total', 'nu-fission', etc.) by_nuclide : bool If true, computes cross sections for each nuclide in domain - domain : Material or Cell or Universe + domain : Material or Cell or Universe or Mesh Domain for spatial homogenization - domain_type : {'material', 'cell', 'distribcell', 'universe'} + domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'} Domain type for spatial homogenization energy_groups : openmc.mgxs.EnergyGroups Energy group structure for energy condensation @@ -5062,7 +5164,7 @@ class PromptNuFissionXS(MGXS): is None unless the multi-group cross section has been computed. num_subdomains : int The number of subdomains is unity for 'material', 'cell' and 'universe' - domain types. When the This is equal to the number of cell instances + domain types. This is equal to the number of cell instances for 'distribcell' domain types (it is equal to unity prior to loading tally data from a statepoint file). num_nuclides : int diff --git a/openmc/tallies.py b/openmc/tallies.py index af19549a7..4fc19f1e5 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -2983,7 +2983,7 @@ class Tally(object): bin_indices.extend([bin_index]) bin_indices.extend([bin_index, bin_index+1]) num_bins += 1 - elif filter_type == 'distribcell': + elif filter_type in ['distribcell', 'mesh']: bin_indices = [0] num_bins = find_filter.num_bins else: