Updated OpenMOC compatiblity module with changes suggested by @paulromano

This commit is contained in:
Will Boyd 2017-02-28 12:06:42 -05:00
parent 43b141e9ba
commit 3042e7d9c0
8 changed files with 427 additions and 75 deletions

View file

@ -25,7 +25,7 @@ except ImportError:
MOCK_MODULES = ['numpy', 'numpy.polynomial', 'numpy.polynomial.polynomial',
'h5py', 'pandas', 'uncertainties', 'opencg']
'h5py', 'pandas', 'uncertainties', 'openmoc']
sys.modules.update((mod_name, MagicMock()) for mod_name in MOCK_MODULES)
import numpy as np

View file

@ -455,7 +455,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {
"collapsed": false
},
@ -486,7 +486,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {
"collapsed": false
},
@ -524,8 +524,8 @@
" Copyright | 2011-2017 Massachusetts Institute of Technology\n",
" License | http://openmc.readthedocs.io/en/latest/license.html\n",
" Version | 0.8.0\n",
" Git SHA1 | 647bf77a57a3cc5cce24b39cb192e1b99f52e499\n",
" Date/Time | 2017-02-27 13:25:16\n",
" Git SHA1 | 43b141e9ba542da8b28c078cf2df8a6777cfb2ad\n",
" Date/Time | 2017-02-28 11:52:00\n",
" OpenMP Threads | 4\n",
"\n",
" ===========================================================================\n",
@ -575,8 +575,81 @@
" 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"
" 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.17478 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",
" ======================> SIMULATION FINISHED <======================\n",
" ===========================================================================\n",
"\n",
"\n",
" =======================> TIMING STATISTICS <=======================\n",
"\n",
" Total time for initialization = 3.0114E-01 seconds\n",
" Reading cross sections = 1.8743E-01 seconds\n",
" Total time in simulation = 9.7641E+00 seconds\n",
" Time in transport only = 9.5168E+00 seconds\n",
" Time in inactive batches = 1.2602E+00 seconds\n",
" Time in active batches = 8.5039E+00 seconds\n",
" Time synchronizing fission bank = 5.4293E-03 seconds\n",
" Sampling source sites = 4.3508E-03 seconds\n",
" SEND/RECV source sites = 9.9399E-04 seconds\n",
" Time accumulating tallies = 1.2758E-04 seconds\n",
" Total time for finalization = 3.6982E-04 seconds\n",
" Total time elapsed = 1.0075E+01 seconds\n",
" Calculation Rate (inactive) = 19838.7 neutrons/second\n",
" Calculation Rate (active) = 11759.3 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",
" Leakage Fraction = 0.00000 +/- 0.00000\n",
"\n"
]
},
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
@ -600,7 +673,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"metadata": {
"collapsed": false
},
@ -626,7 +699,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"metadata": {
"collapsed": false
},
@ -661,11 +734,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Multi-Group XS\n",
"\tReaction Type =\ttotal\n",
"\tDomain Type =\tcell\n",
"\tDomain ID =\t1\n",
"\tCross Sections [cm^-1]:\n",
" Group 1 [0.625 - 20000000.0eV]:\t6.81e-01 +/- 2.69e-01%\n",
" Group 2 [0.0 - 0.625 eV]:\t1.40e+00 +/- 5.93e-01%\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"total.print_xs()"
]
@ -679,11 +769,58 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cell</th>\n",
" <th>group in</th>\n",
" <th>nuclide</th>\n",
" <th>mean</th>\n",
" <th>std. dev.</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>total</td>\n",
" <td>0.667787</td>\n",
" <td>0.001802</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>total</td>\n",
" <td>1.292013</td>\n",
" <td>0.007642</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"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"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = scattering.get_pandas_dataframe()\n",
"df.head(10)"
@ -698,7 +835,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {
"collapsed": false
},
@ -716,7 +853,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"metadata": {
"collapsed": false
},
@ -743,11 +880,68 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cell</th>\n",
" <th>energy low [eV]</th>\n",
" <th>energy high [eV]</th>\n",
" <th>nuclide</th>\n",
" <th>score</th>\n",
" <th>mean</th>\n",
" <th>std. dev.</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.000</td>\n",
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
" <td>-1.110223e-15</td>\n",
" <td>0.011292</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.625</td>\n",
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>(((total / flux) - (absorption / flux)) - (sca...</td>\n",
" <td>1.776357e-15</td>\n",
" <td>0.002570</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cell energy low [eV] energy high [eV] nuclide \\\n",
"0 1 0.00e+00 6.25e-01 total \n",
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 (((total / flux) - (absorption / flux)) - (sca... -1.11e-15 1.13e-02 \n",
"1 (((total / flux) - (absorption / flux)) - (sca... 1.78e-15 2.57e-03 "
]
},
"execution_count": 22,
"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",
@ -765,11 +959,68 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cell</th>\n",
" <th>energy low [eV]</th>\n",
" <th>energy high [eV]</th>\n",
" <th>nuclide</th>\n",
" <th>score</th>\n",
" <th>mean</th>\n",
" <th>std. dev.</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.000</td>\n",
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>((absorption / flux) / (total / flux))</td>\n",
" <td>0.076115</td>\n",
" <td>0.000649</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.625</td>\n",
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>((absorption / flux) / (total / flux))</td>\n",
" <td>0.019263</td>\n",
" <td>0.000095</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cell energy low [eV] energy high [eV] nuclide \\\n",
"0 1 0.00e+00 6.25e-01 total \n",
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 ((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"
}
],
"source": [
"# Use tally arithmetic to compute the absorption-to-total MGXS ratio\n",
"absorption_to_total = absorption.xs_tally / total.xs_tally\n",
@ -780,11 +1031,68 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cell</th>\n",
" <th>energy low [eV]</th>\n",
" <th>energy high [eV]</th>\n",
" <th>nuclide</th>\n",
" <th>score</th>\n",
" <th>mean</th>\n",
" <th>std. dev.</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.000</td>\n",
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>((scatter / flux) / (total / flux))</td>\n",
" <td>0.923885</td>\n",
" <td>0.007736</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.625</td>\n",
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>((scatter / flux) / (total / flux))</td>\n",
" <td>0.980737</td>\n",
" <td>0.003737</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cell energy low [eV] energy high [eV] nuclide \\\n",
"0 1 0.00e+00 6.25e-01 total \n",
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 ((scatter / flux) / (total / flux)) 9.24e-01 7.74e-03 \n",
"1 ((scatter / flux) / (total / flux)) 9.81e-01 3.74e-03 "
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Use tally arithmetic to compute the scattering-to-total MGXS ratio\n",
"scattering_to_total = scattering.xs_tally / total.xs_tally\n",
@ -802,11 +1110,68 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>cell</th>\n",
" <th>energy low [eV]</th>\n",
" <th>energy high [eV]</th>\n",
" <th>nuclide</th>\n",
" <th>score</th>\n",
" <th>mean</th>\n",
" <th>std. dev.</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0.000</td>\n",
" <td>6.250000e-01</td>\n",
" <td>total</td>\n",
" <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
" <td>1.0</td>\n",
" <td>0.007763</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.625</td>\n",
" <td>2.000000e+07</td>\n",
" <td>total</td>\n",
" <td>(((absorption / flux) / (total / flux)) + ((sc...</td>\n",
" <td>1.0</td>\n",
" <td>0.003739</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cell energy low [eV] energy high [eV] nuclide \\\n",
"0 1 0.00e+00 6.25e-01 total \n",
"1 1 6.25e-01 2.00e+07 total \n",
"\n",
" score mean std. dev. \n",
"0 (((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"
}
],
"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",

View file

@ -1,8 +0,0 @@
.. _pythonapi_opencg_compatible:
====================
OpenCG Compatibility
====================
.. automodule:: openmc.opencg_compatible
:members:

View file

@ -0,0 +1,8 @@
.. _pythonapi_openmoc_compatible:
====================
OpenMOC Compatibility
====================
.. automodule:: openmc.openmoc_compatible
:members:

View file

@ -28,6 +28,6 @@ from openmc.mixin import *
from openmc.plotter import *
try:
from openmc.opencg_compatible import *
from openmc.openmoc_compatible import *
except ImportError:
pass

View file

@ -399,7 +399,6 @@ class CrossFilter(object):
distribcell tally filters (default is None). The geometric
information in the Summary object is embedded into a Multi-index
column with a geometric "path" to each distribcell instance.
NOTE: This option requires the OpenCG Python package.
Returns
-------

View file

@ -1301,8 +1301,7 @@ class DistribcellFilter(Filter):
filter_bins = np.tile(filter_bins, tile_factor)
df = pd.DataFrame({self.short_name.lower() : filter_bins})
# If OpenCG level info DataFrame was created, concatenate
# with DataFrame of distribcell instance IDs
# Concatenate with DataFrame of distribcell instance IDs
if level_df is not None:
level_df = level_df.dropna(axis=1, how='all')
level_df = level_df.astype(np.int)

View file

@ -3,12 +3,7 @@ import operator
import numpy as np
try:
import openmoc
except ImportError:
raise ImportError('Unable to import openmoc which is needed by '
'openmc.openmoc_compatible')
import openmoc
import openmc
import openmc.checkvalue as cv
@ -69,7 +64,7 @@ def get_openmoc_material(openmc_material):
Parameters
----------
openmc_material : openmc.material.Material
openmc_material : openmc.Material
OpenMC material
Returns
@ -110,7 +105,7 @@ def get_openmc_material(openmoc_material):
Returns
-------
openmc_material : openmc.material.Material
openmc_material : openmc.Material
Equivalent OpenMC material
"""
@ -141,7 +136,7 @@ def get_openmoc_surface(openmc_surface):
Parameters
----------
openmc_surface : openmc.surface.Surface
openmc_surface : openmc.Surface
OpenMC surface
Returns
@ -199,7 +194,7 @@ def get_openmoc_surface(openmc_surface):
else:
msg = 'Unable to create an OpenMOC Surface from an OpenMC ' \
'Surface of type "{0}" since it is not a compatible ' \
'Surface of type "{}" since it is not a compatible ' \
'Surface type in OpenMOC'.format(type(openmc_surface))
raise ValueError(msg)
@ -225,7 +220,7 @@ def get_openmc_surface(openmoc_surface):
Returns
-------
openmc_surface : openmc.surface.Surface
openmc_surface : openmc.Surface
Equivalent OpenMC surface
"""
@ -238,12 +233,12 @@ def get_openmc_surface(openmoc_surface):
if surface_id in OPENMC_SURFACES:
return OPENMC_SURFACES[surface_id]
# Create an OpenMC Surface to represent this OpenCG Surface
# Create an OpenMC Surface to represent this OpenMOC Surface
name = openmoc_surface.name
# Correct for OpenMC's syntax for Surfaces dividing Cells
boundary = openmoc_surface.getBoundaryType()
if boundary == openmoc.VACCUM:
if boundary == openmoc.VACUUM:
boundary = 'vacuum'
elif boundary == openmoc.REFLECTIVE:
boundary = 'reflective'
@ -263,11 +258,11 @@ def get_openmc_surface(openmoc_surface):
x0 = openmoc_surface.getX()
openmc_surface = openmc.XPlane(surface_id, boundary, x0, name)
elif openmoc_surface.type == openmoc.YPLANE:
elif openmoc_surface.getSurfaceType() == openmoc.YPLANE:
y0 = openmoc_surface.getY()
openmc_surface = openmc.YPlane(surface_id, boundary, y0, name)
elif openmoc_surface.type == openmoc.ZPLANE:
elif openmoc_surface.getSurfaceType() == openmoc.ZPLANE:
z0 = openmoc_surface.getZ()
openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name)
@ -291,7 +286,7 @@ def get_openmoc_cell(openmc_cell):
Parameters
----------
openmc_cell : openmc.universe.Cell
openmc_cell : openmc.Cell
OpenMC cell
Returns
@ -365,11 +360,11 @@ def get_openmc_cell(openmoc_cell):
Parameters
----------
openmoc_cell : openmoc.Cell
OpenCG cell
OpenMOC cell
Returns
-------
openmc_cell : openmc.universe.Cell
openmc_cell : openmc.Cell
Equivalent OpenMC cell
"""
@ -403,16 +398,10 @@ def get_openmc_cell(openmoc_cell):
translation = openmoc_cell.getTranslation(3)
openmc_cell.translation = translation
surfaces = []
operators = []
regions = []
for surf_id, surf_halfspace in openmoc_cell.getSurfaces().values():
halfspace = surf_halfspace._halfspace
surface = surf_halfspace._surface
surfaces.append(get_openmc_surface(surface))
operators.append(operator.neg if halfspace == -1 else operator.pos)
openmc_cell.region = openmc.Intersection(
*[op(s) for op, s in zip(operators, surfaces)])
regions.append(-surface if halfspace == -1 else +surface)
openmc_cell.region = openmc.Intersection(*regions)
# Add the OpenMC Cell to the global collection of all OpenMC Cells
OPENMC_CELLS[cell_id] = openmc_cell
@ -428,7 +417,7 @@ def get_openmoc_universe(openmc_universe):
Parameters
----------
openmc_universe : openmc.universe.Universe
openmc_universe : openmc.Universe
OpenMC universe
Returns
@ -450,7 +439,7 @@ def get_openmoc_universe(openmc_universe):
name = openmc_universe.name
openmoc_universe = openmoc.Universe(universe_id, name)
# Convert all OpenMC Cells in this Universe to OpenCG Cells
# Convert all OpenMC Cells in this Universe to OpenMOC Cells
openmc_cells = openmc_universe.cells
for openmc_cell in openmc_cells.values():
@ -476,7 +465,7 @@ def get_openmc_universe(openmoc_universe):
Returns
-------
openmc_universe : openmc.universe.Universe
openmc_universe : openmc.Universe
Equivalent OpenMC universe
"""
@ -512,7 +501,7 @@ def get_openmoc_lattice(openmc_lattice):
Parameters
----------
openmc_lattice : openmc.universe.Lattice
openmc_lattice : openmc.RectLattice
OpenMC lattice
Returns
@ -522,7 +511,7 @@ def get_openmoc_lattice(openmc_lattice):
"""
cv.check_type('openmc_lattice', openmc_lattice, openmc.Lattice)
cv.check_type('openmc_lattice', openmc_lattice, openmc.RectLattice)
lattice_id = openmc_lattice.id
@ -539,7 +528,7 @@ def get_openmoc_lattice(openmc_lattice):
# Convert 2D dimension to 3D for OpenMOC
if len(dimension) == 2:
new_dimension = np.ones(3, dtype=np.int)
new_dimension = np.ones(3, dtype=int)
new_dimension[:2] = dimension
dimension = new_dimension
@ -549,13 +538,13 @@ def get_openmoc_lattice(openmc_lattice):
new_pitch[:2] = pitch
pitch = new_pitch
# Convert 2D lower left to 3D for OpenCG
# Convert 2D lower left to 3D for OpenMOC
if len(lower_left) == 2:
new_lower_left = np.ones(3, dtype=np.float64) * np.finfo(np.float64).min
new_lower_left[:2] = lower_left
lower_left = new_lower_left
# Convert 2D universes array to 3D for OpenCG
# Convert 2D universes array to 3D for OpenMOC
if len(universes.shape) == 2:
new_universes = universes.copy()
new_universes.shape = (1,) + universes.shape
@ -605,7 +594,7 @@ def get_openmc_lattice(openmoc_lattice):
Returns
-------
openmc_lattice : openmc.universe.Lattice
openmc_lattice : openmc.RectLattice
Equivalent OpenMC lattice
"""
@ -627,7 +616,7 @@ def get_openmc_lattice(openmoc_lattice):
np.array(dimension, dtype=np.float64))) / -2.0
# Initialize an empty array for the OpenMOC nested Universes in this Lattice
universe_array = np.ndarray(tuple(np.array(dimension)[::-1]), \
universe_array = np.ndarray(tuple(np.array(dimension)[::-1]),
dtype=openmoc.Universe)
# Create OpenMOC Universes for each unique nested Universe in this Lattice
@ -663,7 +652,7 @@ def get_openmoc_geometry(openmc_geometry):
Parameters
----------
openmc_geometry : openmc.universe.Geometry
openmc_geometry : openmc.Geometry
OpenMC geometry
Returns
@ -721,7 +710,7 @@ def get_openmc_geometry(openmoc_geometry):
Returns
-------
openmc_geometry : openmc.universe.Geometry
openmc_geometry : openmc.Geometry
Equivalent OpenMC geometry
"""
@ -738,8 +727,8 @@ def get_openmc_geometry(openmoc_geometry):
OPENMC_LATTICES.clear()
OPENMOC_LATTICES.clear()
openmoc_root_universe = openmoc_geometry.getRootUniverse()
openmc_root_universe = get_openmc_universe(openmoc_root_universe)
openmoc_root_universe =
openmoc_geometry.getRootUniverse(openmoc_root_universe)
openmc_geometry = openmc.Geometry()
openmc_geometry.root_universe = openmc_root_universe