From b56c528bdb0ce3efaefe66af4da77cedfef69d8f Mon Sep 17 00:00:00 2001 From: Sam Shaner Date: Thu, 7 Jul 2016 16:46:24 -0400 Subject: [PATCH] used condensed methods to generate mesh domain bins --- .../pythonapi/examples/mgxs-part-i.ipynb | 900 +++++++++++++++--- openmc/mgxs/mgxs.py | 87 +- 2 files changed, 765 insertions(+), 222 deletions(-) diff --git a/docs/source/pythonapi/examples/mgxs-part-i.ipynb b/docs/source/pythonapi/examples/mgxs-part-i.ipynb index ff242885e..7c5838b2d 100644 --- a/docs/source/pythonapi/examples/mgxs-part-i.ipynb +++ b/docs/source/pythonapi/examples/mgxs-part-i.ipynb @@ -91,7 +91,7 @@ "\n", "$$\\sigma_{n,x,k,g} = \\frac{\\int_{E_{g}}^{E_{g-1}}\\mathrm{d}E'\\int_{\\mathbf{r} \\in V_{k}}\\mathrm{d}\\mathbf{r}\\sigma_{n,x}(\\mathbf{r},E')\\Phi(\\mathbf{r},E')}{\\int_{E_{g}}^{E_{g-1}}\\mathrm{d}E'\\int_{\\mathbf{r} \\in V_{k}}\\mathrm{d}\\mathbf{r}\\Phi(\\mathbf{r},E')}$$\n", "\n", - "This scalar flux-weighted average microscopic cross section is computed by `openmc.mgxs` for most multi-group cross sections, including total, absorption, and fission reaction types. These double integrals are stochastically computed with OpenMC's tally system - in particular, [filters](https://mit-crpg.github.io/openmc/pythonapi/filter.html) on the energy range and spatial zone (material, cell or universe) define the bounds of integration for both numerator and denominator." + "This scalar flux-weighted average microscopic cross section is computed by `openmc.mgxs` for most multi-group cross sections, including total, absorption, and fission reaction types. These double integrals are stochastically computed with OpenMC's tally system - in particular, [filters](https://mit-crpg.github.io/openmc/pythonapi/filter.html) on the energy range and spatial zone (material, cell, universe, or mesh) define the bounds of integration for both numerator and denominator." ] }, { @@ -326,7 +326,7 @@ "# OpenMC simulation parameters\n", "batches = 50\n", "inactive = 10\n", - "particles = 1000\n", + "particles = 2500\n", "\n", "# Instantiate a Settings object\n", "settings_file = openmc.Settings()\n", @@ -433,7 +433,7 @@ " \tName =\t\n", " \tFilters =\t\n", " \t\tmesh\t[10000]\n", - " \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n", + " \t\tenergy\t[0.000000E+00 6.250000E-07 2.000000E+01]\n", " \tNuclides =\ttotal \n", " \tScores =\t['flux']\n", " \tEstimator =\ttracklength), ('absorption', Tally\n", @@ -441,7 +441,7 @@ " \tName =\t\n", " \tFilters =\t\n", " \t\tmesh\t[10000]\n", - " \t\tenergy\t[ 0.00000000e+00 6.25000000e-07 2.00000000e+01]\n", + " \t\tenergy\t[0.000000E+00 6.250000E-07 2.000000E+01]\n", " \tNuclides =\ttotal \n", " \tScores =\t['absorption']\n", " \tEstimator =\ttracklength)])" @@ -521,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: 736d7aa5ba3bcd1a8a1614ce4b6769babcb1d8ca\n", - " Date/Time: 2016-07-05 16:23:08\n", - " MPI Processes: 4\n", + " Git SHA1: 6a66fb9af7372435dc7da987c8fc3d6acff6549a\n", + " Date/Time: 2016-07-07 16:43:21\n", + " MPI Processes: 1\n", "\n", " ===========================================================================\n", " ========================> INITIALIZATION <=========================\n", @@ -549,56 +549,56 @@ "\n", " Bat./Gen. k Average k \n", " ========= ======== ==================== \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", + " 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", " Creating state point statepoint.50.h5...\n", "\n", " ===========================================================================\n", @@ -608,27 +608,27 @@ "\n", " =======================> TIMING STATISTICS <=======================\n", "\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", + " Total time for initialization = 7.1900E-01 seconds\n", + " Reading cross sections = 2.0400E-01 seconds\n", + " Total time in simulation = 2.4932E+01 seconds\n", + " Time in transport only = 2.4916E+01 seconds\n", + " Time in inactive batches = 2.1830E+00 seconds\n", + " Time in active batches = 2.2749E+01 seconds\n", + " Time synchronizing fission bank = 4.0000E-03 seconds\n", + " Sampling source sites = 4.0000E-03 seconds\n", " SEND/RECV source sites = 0.0000E+00 seconds\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", + " Time accumulating tallies = 1.0000E-03 seconds\n", + " Total time for finalization = 2.0000E-03 seconds\n", + " Total time elapsed = 2.5667E+01 seconds\n", + " Calculation Rate (inactive) = 11452.1 neutrons/second\n", + " Calculation Rate (active) = 4395.80 neutrons/second\n", "\n", " ============================> RESULTS <============================\n", "\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", + " 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", " Leakage Fraction = 0.00000 +/- 0.00000\n", "\n" ] @@ -646,7 +646,7 @@ ], "source": [ "# Run OpenMC\n", - "openmc.run(mpi_procs=4)" + "openmc.run()" ] }, { @@ -740,23 +740,23 @@ "\tDomain Type =\tmesh\n", "\tDomain ID =\t10000\n", "\tCross Sections [cm^-1]:\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", + " Group 1 [6.25e-07 - 20.0 MeV]:\t6.81e-01 +/- 3.06e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 6.94e-01%\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", + " Group 1 [6.25e-07 - 20.0 MeV]:\t6.81e-01 +/- 3.19e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 7.34e-01%\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", + " Group 1 [6.25e-07 - 20.0 MeV]:\t6.82e-01 +/- 3.01e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 7.23e-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", + " Group 1 [6.25e-07 - 20.0 MeV]:\t6.80e-01 +/- 3.34e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.40e+00 +/- 5.92e-01%\n", "\n", "\n", "\n" @@ -814,8 +814,8 @@ " 1\n", " 1\n", " total\n", - " 0.669016\n", - " 0.003015\n", + " 0.667691\n", + " 0.002046\n", " \n", " \n", " 0\n", @@ -824,8 +824,8 @@ " 1\n", " 2\n", " total\n", - " 1.293138\n", - " 0.014971\n", + " 1.291709\n", + " 0.008941\n", " \n", " \n", " 3\n", @@ -834,8 +834,8 @@ " 1\n", " 1\n", " total\n", - " 0.667930\n", - " 0.002132\n", + " 0.667474\n", + " 0.002119\n", " \n", " \n", " 2\n", @@ -844,8 +844,8 @@ " 1\n", " 2\n", " total\n", - " 1.292741\n", - " 0.016747\n", + " 1.292677\n", + " 0.009479\n", " \n", " \n", " 5\n", @@ -854,8 +854,8 @@ " 1\n", " 1\n", " total\n", - " 0.669513\n", - " 0.002584\n", + " 0.668766\n", + " 0.002021\n", " \n", " \n", " 4\n", @@ -864,8 +864,8 @@ " 1\n", " 2\n", " total\n", - " 1.294423\n", - " 0.012750\n", + " 1.292504\n", + " 0.009323\n", " \n", " \n", " 7\n", @@ -874,8 +874,8 @@ " 1\n", " 1\n", " total\n", - " 0.668773\n", - " 0.003314\n", + " 0.667218\n", + " 0.002220\n", " \n", " \n", " 6\n", @@ -884,8 +884,8 @@ " 1\n", " 2\n", " total\n", - " 1.292515\n", - " 0.015479\n", + " 1.291160\n", + " 0.007613\n", " \n", " \n", "\n", @@ -894,14 +894,14 @@ "text/plain": [ " 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" + "1 1 1 1 1 total 0.667691 0.002046\n", + "0 1 1 1 2 total 1.291709 0.008941\n", + "3 1 2 1 1 total 0.667474 0.002119\n", + "2 1 2 1 2 total 1.292677 0.009479\n", + "5 2 1 1 1 total 0.668766 0.002021\n", + "4 2 1 1 2 total 1.292504 0.009323\n", + "7 2 2 1 1 total 0.667218 0.002220\n", + "6 2 2 1 2 total 1.291160 0.007613" ] }, "execution_count": 19, @@ -914,38 +914,6 @@ "df.head(10)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Each multi-group cross section object can be easily exported to a variety of file formats, including CSV, Excel, and LaTeX for storage or data processing." - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "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')" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -955,7 +923,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "collapsed": false }, @@ -982,11 +950,170 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": { "collapsed": false }, - "outputs": [], + "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", + " \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", + "
mesh 10000energy low [MeV]energy high [MeV]nuclidescoremeanstd. dev.
xyz
01110.000000e+006.250000e-07total(((total / flux) - (absorption / flux)) - (sca...-1.332268e-150.013214
11116.250000e-072.000000e+01total(((total / flux) - (absorption / flux)) - (sca...-2.220446e-160.002922
21210.000000e+006.250000e-07total(((total / flux) - (absorption / flux)) - (sca...4.440892e-160.014000
31216.250000e-072.000000e+01total(((total / flux) - (absorption / flux)) - (sca...2.331468e-150.003034
42110.000000e+006.250000e-07total(((total / flux) - (absorption / flux)) - (sca...-6.661338e-160.013782
52116.250000e-072.000000e+01total(((total / flux) - (absorption / flux)) - (sca...-9.992007e-160.002880
62210.000000e+006.250000e-07total(((total / flux) - (absorption / flux)) - (sca...4.440892e-160.011257
72216.250000e-072.000000e+01total(((total / flux) - (absorption / flux)) - (sca...7.771561e-160.003177
\n", + "
" + ], + "text/plain": [ + " mesh 10000 energy low [MeV] energy high [MeV] nuclide \\\n", + " x y z \n", + "0 1 1 1 0.00e+00 6.25e-07 total \n", + "1 1 1 1 6.25e-07 2.00e+01 total \n", + "2 1 2 1 0.00e+00 6.25e-07 total \n", + "3 1 2 1 6.25e-07 2.00e+01 total \n", + "4 2 1 1 0.00e+00 6.25e-07 total \n", + "5 2 1 1 6.25e-07 2.00e+01 total \n", + "6 2 2 1 0.00e+00 6.25e-07 total \n", + "7 2 2 1 6.25e-07 2.00e+01 total \n", + "\n", + " score mean std. dev. \n", + " \n", + "0 (((total / flux) - (absorption / flux)) - (sca... -1.33e-15 1.32e-02 \n", + "1 (((total / flux) - (absorption / flux)) - (sca... -2.22e-16 2.92e-03 \n", + "2 (((total / flux) - (absorption / flux)) - (sca... 4.44e-16 1.40e-02 \n", + "3 (((total / flux) - (absorption / flux)) - (sca... 2.33e-15 3.03e-03 \n", + "4 (((total / flux) - (absorption / flux)) - (sca... -6.66e-16 1.38e-02 \n", + "5 (((total / flux) - (absorption / flux)) - (sca... -9.99e-16 2.88e-03 \n", + "6 (((total / flux) - (absorption / flux)) - (sca... 4.44e-16 1.13e-02 \n", + "7 (((total / flux) - (absorption / flux)) - (sca... 7.77e-16 3.18e-03 " + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Use tally arithmetic to compute the difference between the total, absorption and scattering\n", "difference = total.xs_tally - absorption.xs_tally - scattering.xs_tally\n", @@ -1004,11 +1131,170 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": { "collapsed": false }, - "outputs": [], + "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", + " \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", + "
mesh 10000energy low [MeV]energy high [MeV]nuclidescoremeanstd. dev.
xyz
01110.000000e+006.250000e-07total((absorption / flux) / (total / flux))0.0760770.000762
11116.250000e-072.000000e+01total((absorption / flux) / (total / flux))0.0192420.000160
21210.000000e+006.250000e-07total((absorption / flux) / (total / flux))0.0761730.000800
31216.250000e-072.000000e+01total((absorption / flux) / (total / flux))0.0193720.000136
42110.000000e+006.250000e-07total((absorption / flux) / (total / flux))0.0761830.000796
52116.250000e-072.000000e+01total((absorption / flux) / (total / flux))0.0193640.000154
62210.000000e+006.250000e-07total((absorption / flux) / (total / flux))0.0760270.000654
72216.250000e-072.000000e+01total((absorption / flux) / (total / flux))0.0190740.000153
\n", + "
" + ], + "text/plain": [ + " mesh 10000 energy low [MeV] energy high [MeV] nuclide \\\n", + " x y z \n", + "0 1 1 1 0.00e+00 6.25e-07 total \n", + "1 1 1 1 6.25e-07 2.00e+01 total \n", + "2 1 2 1 0.00e+00 6.25e-07 total \n", + "3 1 2 1 6.25e-07 2.00e+01 total \n", + "4 2 1 1 0.00e+00 6.25e-07 total \n", + "5 2 1 1 6.25e-07 2.00e+01 total \n", + "6 2 2 1 0.00e+00 6.25e-07 total \n", + "7 2 2 1 6.25e-07 2.00e+01 total \n", + "\n", + " score mean std. dev. \n", + " \n", + "0 ((absorption / flux) / (total / flux)) 7.61e-02 7.62e-04 \n", + "1 ((absorption / flux) / (total / flux)) 1.92e-02 1.60e-04 \n", + "2 ((absorption / flux) / (total / flux)) 7.62e-02 8.00e-04 \n", + "3 ((absorption / flux) / (total / flux)) 1.94e-02 1.36e-04 \n", + "4 ((absorption / flux) / (total / flux)) 7.62e-02 7.96e-04 \n", + "5 ((absorption / flux) / (total / flux)) 1.94e-02 1.54e-04 \n", + "6 ((absorption / flux) / (total / flux)) 7.60e-02 6.54e-04 \n", + "7 ((absorption / flux) / (total / flux)) 1.91e-02 1.53e-04 " + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Use tally arithmetic to compute the absorption-to-total MGXS ratio\n", "absorption_to_total = absorption.xs_tally / total.xs_tally\n", @@ -1019,11 +1305,170 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": { "collapsed": false }, - "outputs": [], + "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", + " \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", + "
mesh 10000energy low [MeV]energy high [MeV]nuclidescoremeanstd. dev.
xyz
01110.000000e+006.250000e-07total((scatter / flux) / (total / flux))0.9239230.009054
11116.250000e-072.000000e+01total((scatter / flux) / (total / flux))0.9807580.004247
21210.000000e+006.250000e-07total((scatter / flux) / (total / flux))0.9238270.009586
31216.250000e-072.000000e+01total((scatter / flux) / (total / flux))0.9806280.004411
42110.000000e+006.250000e-07total((scatter / flux) / (total / flux))0.9238170.009436
52116.250000e-072.000000e+01total((scatter / flux) / (total / flux))0.9806360.004180
62210.000000e+006.250000e-07total((scatter / flux) / (total / flux))0.9239730.007717
72216.250000e-072.000000e+01total((scatter / flux) / (total / flux))0.9809260.004623
\n", + "
" + ], + "text/plain": [ + " mesh 10000 energy low [MeV] energy high [MeV] nuclide \\\n", + " x y z \n", + "0 1 1 1 0.00e+00 6.25e-07 total \n", + "1 1 1 1 6.25e-07 2.00e+01 total \n", + "2 1 2 1 0.00e+00 6.25e-07 total \n", + "3 1 2 1 6.25e-07 2.00e+01 total \n", + "4 2 1 1 0.00e+00 6.25e-07 total \n", + "5 2 1 1 6.25e-07 2.00e+01 total \n", + "6 2 2 1 0.00e+00 6.25e-07 total \n", + "7 2 2 1 6.25e-07 2.00e+01 total \n", + "\n", + " score mean std. dev. \n", + " \n", + "0 ((scatter / flux) / (total / flux)) 9.24e-01 9.05e-03 \n", + "1 ((scatter / flux) / (total / flux)) 9.81e-01 4.25e-03 \n", + "2 ((scatter / flux) / (total / flux)) 9.24e-01 9.59e-03 \n", + "3 ((scatter / flux) / (total / flux)) 9.81e-01 4.41e-03 \n", + "4 ((scatter / flux) / (total / flux)) 9.24e-01 9.44e-03 \n", + "5 ((scatter / flux) / (total / flux)) 9.81e-01 4.18e-03 \n", + "6 ((scatter / flux) / (total / flux)) 9.24e-01 7.72e-03 \n", + "7 ((scatter / flux) / (total / flux)) 9.81e-01 4.62e-03 " + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Use tally arithmetic to compute the scattering-to-total MGXS ratio\n", "scattering_to_total = scattering.xs_tally / total.xs_tally\n", @@ -1041,11 +1486,170 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": { "collapsed": false }, - "outputs": [], + "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", + " \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", + "
mesh 10000energy low [MeV]energy high [MeV]nuclidescoremeanstd. dev.
xyz
01110.000000e+006.250000e-07total(((absorption / flux) / (total / flux)) + ((sc...10.009086
11116.250000e-072.000000e+01total(((absorption / flux) / (total / flux)) + ((sc...10.004250
21210.000000e+006.250000e-07total(((absorption / flux) / (total / flux)) + ((sc...10.009619
31216.250000e-072.000000e+01total(((absorption / flux) / (total / flux)) + ((sc...10.004413
42110.000000e+006.250000e-07total(((absorption / flux) / (total / flux)) + ((sc...10.009470
52116.250000e-072.000000e+01total(((absorption / flux) / (total / flux)) + ((sc...10.004183
62210.000000e+006.250000e-07total(((absorption / flux) / (total / flux)) + ((sc...10.007745
72216.250000e-072.000000e+01total(((absorption / flux) / (total / flux)) + ((sc...10.004626
\n", + "
" + ], + "text/plain": [ + " mesh 10000 energy low [MeV] energy high [MeV] nuclide \\\n", + " x y z \n", + "0 1 1 1 0.00e+00 6.25e-07 total \n", + "1 1 1 1 6.25e-07 2.00e+01 total \n", + "2 1 2 1 0.00e+00 6.25e-07 total \n", + "3 1 2 1 6.25e-07 2.00e+01 total \n", + "4 2 1 1 0.00e+00 6.25e-07 total \n", + "5 2 1 1 6.25e-07 2.00e+01 total \n", + "6 2 2 1 0.00e+00 6.25e-07 total \n", + "7 2 2 1 6.25e-07 2.00e+01 total \n", + "\n", + " score mean std. dev. \n", + " \n", + "0 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 9.09e-03 \n", + "1 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 4.25e-03 \n", + "2 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 9.62e-03 \n", + "3 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 4.41e-03 \n", + "4 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 9.47e-03 \n", + "5 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 4.18e-03 \n", + "6 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 7.74e-03 \n", + "7 (((absorption / flux) / (total / flux)) + ((sc... 1.00e+00 4.63e-03 " + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "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", diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index ab65f7a5a..1d2536678 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -7,6 +7,7 @@ import os import sys import copy import abc +import itertools import numpy as np @@ -701,20 +702,8 @@ class MGXS(object): # NOTE: This is important if tally merging was used 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)] + xyz = map(lambda x: np.arange(1, x+1), self.domain.dimension) + filter_bins = [tuple(itertools.product(*xyz))] elif self.domain_type != 'distribcell': filters = [self.domain_type] filter_bins = [(self.domain.id,)] @@ -1169,18 +1158,8 @@ class MGXS(object): 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)) + xyz = map(lambda x: np.arange(1, x+1), self.domain.dimension) + subdomains = list(itertools.product(*xyz)) else: subdomains = [self.domain.id] @@ -1318,18 +1297,8 @@ class MGXS(object): 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)) + xyz = map(lambda x: np.arange(1, x+1), self.domain.dimension) + subdomains = list(itertools.product(*xyz)) else: subdomains = [self.domain.id] @@ -1934,18 +1903,8 @@ class MatrixMGXS(MGXS): 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)) + xyz = map(lambda x: np.arange(1, x+1), self.domain.dimension) + subdomains = list(itertools.product(*xyz)) else: subdomains = [self.domain.id] @@ -3787,18 +3746,8 @@ class ScatterMatrixXS(MatrixMGXS): 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)) + xyz = map(lambda x: np.arange(1, x+1), self.domain.dimension) + subdomains = list(itertools.product(*xyz)) else: subdomains = [self.domain.id] @@ -5020,18 +4969,8 @@ class Velocity(MGXS): 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)) + xyz = map(lambda x: np.arange(1, x+1), self.domain.dimension) + subdomains = list(itertools.product(*xyz)) else: subdomains = [self.domain.id]