From 32f67d3d0abfb5e6d0f626251c0d64536791e44b Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Fri, 9 Oct 2015 00:15:09 -0400 Subject: [PATCH] Implemented new openmc.mgxs.Library class --- .../examples/multi-group-cross-sections.ipynb | 415 ++++++++++++++++-- openmc/mgxs/__init__.py | 3 +- openmc/mgxs/groups.py | 2 +- openmc/mgxs/library.py | 286 ++++++++++++ openmc/mgxs/mgxs.py | 39 +- 5 files changed, 692 insertions(+), 53 deletions(-) create mode 100644 openmc/mgxs/library.py diff --git a/docs/source/pythonapi/examples/multi-group-cross-sections.ipynb b/docs/source/pythonapi/examples/multi-group-cross-sections.ipynb index 652c21a11..3996543e1 100644 --- a/docs/source/pythonapi/examples/multi-group-cross-sections.ipynb +++ b/docs/source/pythonapi/examples/multi-group-cross-sections.ipynb @@ -1480,7 +1480,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": { "collapsed": false }, @@ -1520,11 +1520,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Delete old HDF5 files\n", "!rm *.h5\n", @@ -1550,7 +1561,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "metadata": { "collapsed": false }, @@ -1571,7 +1582,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "metadata": { "collapsed": false }, @@ -1607,11 +1618,46 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Multi-Group XS\n", + "\tReaction Type =\tnu-fission\n", + "\tDomain Type =\tcell\n", + "\tDomain ID =\t10000\n", + "\tNuclide =\tU-235\n", + "\tCross Sections [barns]:\n", + " Group 1 [0.821 - 20.0 MeV]:\t3.30e+00 +/- 5.91e-01%\n", + " Group 2 [0.00553 - 0.821 MeV]:\t3.97e+00 +/- 4.03e-01%\n", + " Group 3 [4e-06 - 0.00553 MeV]:\t5.48e+01 +/- 5.56e-01%\n", + " Group 4 [6.25e-07 - 4e-06 MeV]:\t8.84e+01 +/- 8.48e-01%\n", + " Group 5 [2.8e-07 - 6.25e-07 MeV]:\t2.89e+02 +/- 1.25e+00%\n", + " Group 6 [1.4e-07 - 2.8e-07 MeV]:\t4.49e+02 +/- 1.09e+00%\n", + " Group 7 [5.8e-08 - 1.4e-07 MeV]:\t6.87e+02 +/- 7.98e-01%\n", + " Group 8 [0.0 - 5.8e-08 MeV]:\t1.44e+03 +/- 5.73e-01%\n", + "\n", + "\tNuclide =\tU-238\n", + "\tCross Sections [barns]:\n", + " Group 1 [0.821 - 20.0 MeV]:\t1.06e+00 +/- 6.74e-01%\n", + " Group 2 [0.00553 - 0.821 MeV]:\t1.22e-03 +/- 8.28e-01%\n", + " Group 3 [4e-06 - 0.00553 MeV]:\t4.75e-04 +/- 7.97e+00%\n", + " Group 4 [6.25e-07 - 4e-06 MeV]:\t6.53e-06 +/- 7.56e-01%\n", + " Group 5 [2.8e-07 - 6.25e-07 MeV]:\t1.07e-05 +/- 1.22e+00%\n", + " Group 6 [1.4e-07 - 2.8e-07 MeV]:\t1.55e-05 +/- 1.09e+00%\n", + " Group 7 [5.8e-08 - 1.4e-07 MeV]:\t2.30e-05 +/- 7.97e-01%\n", + " Group 8 [0.0 - 5.8e-08 MeV]:\t4.25e-05 +/- 5.72e-01%\n", + "\n", + "\n", + "\n" + ] + } + ], "source": [ "nufission = xs_library[fuel_cell.id]['nu-fission']\n", "nufission.print_xs(xs_type='micro', nuclides=['U-235', 'U-238'])" @@ -1626,11 +1672,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Multi-Group XS\n", + "\tReaction Type =\tnu-fission\n", + "\tDomain Type =\tcell\n", + "\tDomain ID =\t10000\n", + "\tCross Sections [cm^-1]:\n", + " Group 1 [0.821 - 20.0 MeV]:\t2.52e-02 +/- 6.42e-01%\n", + " Group 2 [0.00553 - 0.821 MeV]:\t1.52e-03 +/- 3.96e-01%\n", + " Group 3 [4e-06 - 0.00553 MeV]:\t2.06e-02 +/- 5.56e-01%\n", + " Group 4 [6.25e-07 - 4e-06 MeV]:\t3.32e-02 +/- 8.48e-01%\n", + " Group 5 [2.8e-07 - 6.25e-07 MeV]:\t1.09e-01 +/- 1.25e+00%\n", + " Group 6 [1.4e-07 - 2.8e-07 MeV]:\t1.69e-01 +/- 1.09e+00%\n", + " Group 7 [5.8e-08 - 1.4e-07 MeV]:\t2.58e-01 +/- 7.98e-01%\n", + " Group 8 [0.0 - 5.8e-08 MeV]:\t5.41e-01 +/- 5.73e-01%\n", + "\n", + "\n", + "\n" + ] + } + ], "source": [ "nufission = xs_library[fuel_cell.id]['nu-fission']\n", "nufission.print_xs(xs_type='macro', nuclides='sum')" @@ -1645,11 +1714,141 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 41, "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", + "
cellgroup ingroup outnuclidemeanstd. dev.
1261000211O-161.5600980.017801
1271000211H-10.2348770.010096
1241000212O-160.2882360.004397
1251000212H-11.5878150.007847
1221000213O-160.0000000.000000
1231000213H-10.0101220.000513
1201000214O-160.0000000.000000
1211000214H-10.0000000.000000
1181000215O-160.0000000.000000
1191000215H-10.0000000.000000
\n", + "
" + ], + "text/plain": [ + " cell group in group out nuclide mean std. dev.\n", + "126 10002 1 1 O-16 1.560098 0.017801\n", + "127 10002 1 1 H-1 0.234877 0.010096\n", + "124 10002 1 2 O-16 0.288236 0.004397\n", + "125 10002 1 2 H-1 1.587815 0.007847\n", + "122 10002 1 3 O-16 0.000000 0.000000\n", + "123 10002 1 3 H-1 0.010122 0.000513\n", + "120 10002 1 4 O-16 0.000000 0.000000\n", + "121 10002 1 4 H-1 0.000000 0.000000\n", + "118 10002 1 5 O-16 0.000000 0.000000\n", + "119 10002 1 5 H-1 0.000000 0.000000" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "nuscatter = xs_library[moderator_cell.id]['nu-scatter']\n", "df = nuscatter.get_pandas_dataframe(xs_type='micro')\n", @@ -1665,7 +1864,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": { "collapsed": false }, @@ -1693,11 +1892,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWYAAADDCAYAAACxgLv/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFxZJREFUeJzt3XmYVNWZx/FvAyIKCijGBRiaxA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X8jc7tB5XYvCnKrBa1SjBza+dDrW\nw6jUCmwXsh+wF5Wdn3gQ8CE2PhWqt7w7tnLuD5yC9Q4q0QUYClzn/n4OnFdl29Kzh9xdZZx6UF6X\nJ3Rud+i8rkVhfp+24yz9sd5FDNYA7sEmE7gvUMylwEPAjhU8dzfgYGz87C7ge8CtVbZnnvv7ETYL\n9LAK48x1l5fc9fFYIlejxOwhUVNelyd0biuvq9QFG2tpxLYk1RwkwcUJcZCkAUuMywPE6oMd2QVY\nC3gK2LvKmMOp/sj12sA67v/uwN+A/aqI9xSwufu/Gbi0ilhg47LHVhmjXpTXlas2t5XXgeyPHR1+\nG/hFFXHuAj4A/oGN742sItYe2G7adDKnt4yoMNZgbHxqOnYKz9lVtCttONUfuR6ItWk6dupUNe89\n2JRlL2E/njWB6o5edwcWklnB2iPldWWqzW3ltYiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiHRs/w9e\ned7lsJ91IAAAAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "# Create plot of the H-1 scattering matrix\n", "fig = plt.subplot(121)\n", @@ -1722,7 +1932,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 44, "metadata": { "collapsed": true }, @@ -1744,22 +1954,133 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 45, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Multi-Group XS\n", + "\tReaction Type =\ttransport\n", + "\tDomain Type =\tcell\n", + "\tDomain ID =\t10000\n", + "\tNuclide =\tU-238\n", + "\tCross Sections [cm^-1]:\n", + " Group 1 [6.25e-07 - 20.0 MeV]:\t2.17e-01 +/- 4.04e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t2.53e-01 +/- 5.85e-01%\n", + "\n", + "\tNuclide =\tO-16\n", + "\tCross Sections [cm^-1]:\n", + " Group 1 [6.25e-07 - 20.0 MeV]:\t1.45e-01 +/- 4.10e-01%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.75e-01 +/- 6.46e-01%\n", + "\n", + "\tNuclide =\tU-235\n", + "\tCross Sections [cm^-1]:\n", + " Group 1 [6.25e-07 - 20.0 MeV]:\t7.91e-03 +/- 1.22e+00%\n", + " Group 2 [0.0 - 6.25e-07 MeV]:\t1.82e-01 +/- 4.98e-01%\n", + "\n", + "\n", + "\n" + ] + } + ], "source": [ "condense_xs.print_xs()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "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", + "
cellgroup innuclidemeanstd. dev.
3100001U-2389.5893230.038756
4100001O-163.1591010.012939
5100001U-23521.0952560.257787
0100002U-23811.1788440.065428
1100002O-163.8000270.024538
2100002U-235485.5135302.418761
\n", + "
" + ], + "text/plain": [ + " cell group in nuclide mean std. dev.\n", + "3 10000 1 U-238 9.589323 0.038756\n", + "4 10000 1 O-16 3.159101 0.012939\n", + "5 10000 1 U-235 21.095256 0.257787\n", + "0 10000 2 U-238 11.178844 0.065428\n", + "1 10000 2 O-16 3.800027 0.024538\n", + "2 10000 2 U-235 485.513530 2.418761" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "df = condense_xs.get_pandas_dataframe(xs_type='micro')\n", "df" @@ -1781,7 +2102,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": { "collapsed": true }, @@ -1803,7 +2124,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 48, "metadata": { "collapsed": false }, @@ -1851,7 +2172,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": { "collapsed": false }, @@ -1879,11 +2200,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "openmc keff = 1.227616\n", + "openmoc keff = 1.225325\n", + "bias [pcm]: -229.1\n" + ] + } + ], "source": [ "# Print report of keff and bias with OpenMC\n", "openmoc_keff = solver.getKeff()\n", @@ -1904,11 +2235,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 51, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n", + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n", + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n", + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n", + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n", + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n", + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n", + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n", + "/usr/local/lib/python2.7/dist-packages/openmc-0.7.0-py2.7.egg/openmc/mgxs/mgxs.py:711: DeprecationWarning: elementwise comparison failed; this will raise the error in the future.\n" + ] + } + ], "source": [ "su.make_opencg_geometry()\n", "openmoc_geometry = get_openmoc_geometry(su.opencg_geometry)\n", @@ -1945,7 +2292,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 52, "metadata": { "collapsed": false }, @@ -1963,11 +2310,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 53, "metadata": { "collapsed": false }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "openmc keff = 1.227616\n", + "openmoc keff = 1.227096\n", + "bias [pcm]: -52.0\n" + ] + } + ], "source": [ "# Print report of keff and bias with OpenMC\n", "openmoc_keff = solver.getKeff()\n", diff --git a/openmc/mgxs/__init__.py b/openmc/mgxs/__init__.py index b6f928b09..91eb811f4 100644 --- a/openmc/mgxs/__init__.py +++ b/openmc/mgxs/__init__.py @@ -1,2 +1,3 @@ from groups import EnergyGroups -from mgxs import * \ No newline at end of file +from library import Library +from mgxs import * diff --git a/openmc/mgxs/groups.py b/openmc/mgxs/groups.py index dfaca9be9..53f032f51 100644 --- a/openmc/mgxs/groups.py +++ b/openmc/mgxs/groups.py @@ -1,5 +1,5 @@ from collections import Iterable -from numbers import Real, Integral +from numbers import Real import copy import sys diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py new file mode 100644 index 000000000..6f9d40a55 --- /dev/null +++ b/openmc/mgxs/library.py @@ -0,0 +1,286 @@ +import sys +import copy +from numbers import Integral + +import openmc +import openmc.mgxs +import openmc.checkvalue as cv + + +if sys.version_info[0] >= 3: + basestring = str + + +class Library(object): + + def __init__(self, openmc_geometry, by_nuclide=False, + mgxs_types=None, name=''): + + self._name = '' + self._openmc_geometry = None + self._by_nuclide = None + self._mgxs_types = [] + self._domain_type = None + self._energy_groups = None + self._all_mgxs = {} + + self.name = name + self.openmc_geometry = openmc_geometry + self.by_nuclide = by_nuclide + + if mgxs_types is not None: + self.mgxs_types = mgxs_types + + def __deepcopy__(self, memo): + existing = memo.get(id(self)) + + # If this is the first time we have tried to copy this object, copy it + if existing is None: + clone = type(self).__new__(type(self)) + clone._name = self.name + clone._openmc_geometry = self.openmc_geometry + clone._by_nuclide = self.by_nuclide + clone._mgxs_types = self.mgxs_types + clone._domain_type = self.domain_type + clone._energy_groups = copy.deepcopy(self.energy_groups, memo) + clone._all_mgxs = self.all_mgxs + + clone._all_mgxs = {} + for domain in self.domains: + clone.all_mgxs[domain.id] = {} + for mgxs_type in self.mgxs_types: + mgxs = copy.deepcopy(self.all_mgxs[domain.id][mgxs_type]) + clone.all_mgxs[domain.id][mgxs_type] = mgxs + + memo[id(self)] = clone + + return clone + + # If this object has been copied before, return the first copy made + else: + return existing + + @property + def openmc_geometry(self): + return self._openmc_geometry + + @property + def name(self): + return self._name + + @property + def mgxs_types(self): + return self._mgxs_types + + @property + def by_nuclide(self): + return self._by_nuclide + + @property + def domains(self): + if self.domain_type is None: + raise ValueError('Unable to get all domains without a domain type') + + if self.domain_type == 'material': + return self.openmc_geometry.get_all_materials() + elif self.domain_type == 'cell' or self.domain_type == 'distribcell': + return self.openmc_geometry.get_all_material_cells() + elif self.domain_type == 'universe': + return self.openmc_geometry.get_all_universes() + + @property + def domain_type(self): + return self._domain_type + + @property + def energy_groups(self): + return self._energy_groups + + @property + def num_groups(self): + return self.energy_groups.num_groups + + @property + def all_mgxs(self): + return self._all_mgxs + + @openmc_geometry.setter + def openmc_geometry(self, openmc_geometry): + cv.check_type('openmc_geometry', openmc_geometry, openmc.Geometry) + self._openmc_geometry = openmc_geometry + + @name.setter + def name(self, name): + cv.check_type('name', name, basestring) + self._name = name + + @mgxs_types.setter + def mgxs_types(self, mgxs_types): + if mgxs_types == 'all': + self._mgxs_types = openmc.mgxs.MGXS_TYPES + else: + cv.check_iterable_type('mgxs_types', mgxs_types, basestring) + for mgxs_type in mgxs_types: + cv.check_value('mgxs_type', mgxs_type, openmc.mgxs.MGXS_TYPES) + self._mgxs_types = mgxs_types + + @by_nuclide.setter + def by_nuclide(self, by_nuclide): + cv.check_type('by_nuclide', by_nuclide, bool) + self._by_nuclide = by_nuclide + + @domain_type.setter + def domain_type(self, domain_type): + cv.check_value('domain type', domain_type, tuple(openmc.mgxs.DOMAIN_TYPES)) + self._domain_type = domain_type + + @energy_groups.setter + def energy_groups(self, energy_groups): + cv.check_type('energy groups', energy_groups, openmc.mgxs.EnergyGroups) + self._energy_groups = energy_groups + + def build_library(self): + """ + """ + + # Initialize MGXS for each domain and mgxs type and store in dictionary + for domain in self.domains: + self.all_mgxs[domain.id] = {} + for mgxs_type in self.mgxs_types: + mgxs = openmc.mgxs.MGXS.get_mgxs(mgxs_type, name=self.name) + mgxs.domain = domain + mgxs.domain_type = self.domain_type + mgxs.energy_groups = self.energy_groups + mgxs.by_nuclide = self.by_nuclide + mgxs.create_tallies() + self.all_mgxs[domain.id][mgxs_type] = mgxs + + def add_to_tallies_file(self, tallies_file): + """ + + NOTE: This assumes that build_library() has been called + + :param tallies_file: + :return: + """ + + cv.check_type('tallies_file', tallies_file, openmc.TalliesFile) + + # Add tallies from each MGXS for each domain and mgxs type + for domain in self.domains: + for mgxs_type in self.mgxs_types: + mgxs = self.get_mgxs(domain, mgxs_type) + for tally_id, tally in mgxs.tallies.items(): + tallies_file.add_tally(tally, merge=True) + + def load_from_statepoint(self, statepoint): + """ + + :param statepoint: + :return: + """ + + cv.check_type('statepoint', statepoint, openmc.StatePoint) + + # Load tallies for each MGXS for each domain and mgxs type + for domain in self.domains: + for mgxs_type in self.mgxs_types: + mgxs = self.get_mgxs(domain, mgxs_type) + mgxs.load_from_statepoint(statepoint) + mgxs.compute_xs() + + def get_mgxs(self, domain, mgxs_type): + """ + + :param domain: + :param mgxs_type: + :return: + """ + + if self.domain_type == 'material': + cv.check_type('domain', domain, (openmc.Material, Integral)) + elif self.domain_type == 'cell' or self.domain_type == 'distribcell': + cv.check_type('domain', domain, (openmc.Cell, Integral)) + elif self.domain_type == 'universe': + cv.check_type('domain', domain, (openmc.Universe, Integral)) + + # Check that requested domain is included in library + if cv._isinstance(domain, Integral): + domain_id = domain + for domain in self.domains: + if domain_id == domain.id: + break + else: + msg = 'Unable to find MGXS for {0} "{1}" in ' \ + 'library'.format(self.domain_type, domain) + raise ValueError(msg) + else: + domain_id = domain.id + + # Check that requested domain is included in library + if mgxs_type not in self.mgxs_types: + msg = 'Unable to find MGXS type "{0}"'.format(mgxs_type) + raise ValueError(msg) + + return self.all_mgxs[domain_id][mgxs_type] + + def get_condensed_library(self, coarse_groups): + """ + + :param coarse_groups: + :return: + """ + + if self.energy_groups is None: + msg = 'Unable to get a condensed coarse group cross section ' \ + 'library since the fine energy groups have not yet been set' + raise ValueError(msg) + + cv.check_type('coarse_groups', coarse_groups, openmc.mgxs.EnergyGroups) + cv.check_less_than('coarse groups', coarse_groups.num_groups, + self.num_groups, equality=True) + cv.check_value('upper coarse energy', coarse_groups.group_edges[-1], + [self.energy_groups.group_edges[-1]]) + cv.check_value('lower coarse energy', coarse_groups.group_edges[0], + [self.energy_groups.group_edges[0]]) + + # Clone this Library to initialize the condensed version + condensed_library = copy.deepcopy(self) + condensed_library.energy_groups = coarse_groups + + # Condense the MGXS for each domain and mgxs type + for domain in self.domains: + for mgxs_type in self.mgxs_types: + mgxs = condensed_library.get_mgxs(domain, mgxs_type) + condensed_mgxs = mgxs.get_condensed_xs(coarse_groups) + condensed_library.all_mgxs[domain.id][mgxs_type] = condensed_mgxs + + return condensed_library + + def build_hdf5_store(self, filename='mgxs', directory='mgxs', xs_type='macro'): + """Export the multi-group cross section library to an HDF5 binary file. + + This method constructs an HDF5 file which stores the multi-group + cross section data. The data is stored in a hierarchy of HDF5 groups + from the domain type, domain id, subdomain id (for distribcell domains), + nuclides and cross section types. Two datasets for the mean and standard + deviation are stored for each subdomain entry in the HDF5 file. + + NOTE: This requires the h5py Python package. + + Parameters + ---------- + filename : str + Filename for the HDF5 file (default is 'mgxs') + directory : str + Directory for the HDF5 file (default is 'mgxs') + xs_type: {'macro', 'micro'} + Store the macro or micro cross section in units of cm^-1 or barns + + """ + + # Load tallies for each MGXS for each domain and mgxs type + for domain in self.domains: + for mgxs_type in self.mgxs_types: + mgxs = self.all_mgxs[domain.id][mgxs_type] + mgxs.build_hdf5_store(filename, directory, xs_type) \ No newline at end of file diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 5659ec4d3..07d0e10ab 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -32,7 +32,7 @@ MGXS_TYPES = ['total', # Supported domain types # TODO: Implement Mesh domains -_DOMAIN_TYPES = ['cell', +DOMAIN_TYPES = ['cell', 'distribcell', 'universe', 'material'] @@ -80,8 +80,6 @@ class MGXS(object): Domain type for spatial homogenization energy_groups : EnergyGroups Energy group structure for energy condensation - num_groups : Integral - Number of energy groups tallies : dict OpenMC tallies needed to compute the multi-group cross section xs_tally : Tally @@ -102,8 +100,7 @@ class MGXS(object): self._domain = None self._domain_type = None self._energy_groups = None - self._num_groups = None - self._tallies = dict() + self._tallies = {} self._xs_tally = None self.name = name @@ -128,10 +125,9 @@ class MGXS(object): clone._domain = self.domain clone._domain_type = self.domain_type clone._energy_groups = copy.deepcopy(self.energy_groups, memo) - clone._num_groups = self.num_groups clone._xs_tally = copy.deepcopy(self.xs_tally, memo) - clone._tallies = dict() + clone._tallies = {} for tally_type, tally in self.tallies.items(): clone.tallies[tally_type] = copy.deepcopy(tally, memo) @@ -169,7 +165,7 @@ class MGXS(object): @property def num_groups(self): - return self._num_groups + return self.energy_groups.num_groups @property def tallies(self): @@ -185,16 +181,6 @@ class MGXS(object): domain_filter = tally.find_filter(self.domain_type) return domain_filter.num_bins - @name.setter - def name(self, name): - cv.check_type('name', name, basestring) - self._name = name - - @by_nuclide.setter - def by_nuclide(self, by_nuclide): - cv.check_type('by_nuclide', by_nuclide, bool) - self._by_nuclide = by_nuclide - @property def num_nuclides(self): if self.by_nuclide: @@ -209,6 +195,16 @@ class MGXS(object): else: return 'sum' + @name.setter + def name(self, name): + cv.check_type('name', name, basestring) + self._name = name + + @by_nuclide.setter + def by_nuclide(self, by_nuclide): + cv.check_type('by_nuclide', by_nuclide, bool) + self._by_nuclide = by_nuclide + @domain.setter def domain(self, domain): cv.check_type('domain', domain, tuple(_DOMAINS)) @@ -216,14 +212,13 @@ class MGXS(object): @domain_type.setter def domain_type(self, domain_type): - cv.check_value('domain type', domain_type, tuple(_DOMAIN_TYPES)) + cv.check_value('domain type', domain_type, tuple(DOMAIN_TYPES)) self._domain_type = domain_type @energy_groups.setter def energy_groups(self, energy_groups): cv.check_type('energy groups', energy_groups, openmc.mgxs.EnergyGroups) self._energy_groups = energy_groups - self._num_groups = energy_groups.num_groups @staticmethod def get_mgxs(mgxs_type, domain=None, domain_type=None, @@ -295,7 +290,7 @@ class MGXS(object): Returns ------- list of str - A list of the string names for each nuclide in the problem domain + A list of the string names for each nuclide in the spatial domain (e.g., ['U-235', 'U-238', 'O-16']) Raises @@ -362,7 +357,7 @@ class MGXS(object): ------- ndarray of Real An array of the atomic number densities (atom/b-cm) for each of the - nuclides in the problem domain + nuclides in the spatial domain Raises ------