mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Removed OpenCG compatiblity module in place of new OpenMOC compatiblity module
This commit is contained in:
parent
647bf77a57
commit
fa7688e6b0
6 changed files with 898 additions and 1560 deletions
|
|
@ -49,10 +49,6 @@
|
|||
"\n",
|
||||
"import openmc\n",
|
||||
"import openmc.mgxs\n",
|
||||
"import openmoc\n",
|
||||
"import openmoc.process\n",
|
||||
"from openmoc.opencg_compatible import get_openmoc_geometry\n",
|
||||
"from openmoc.materialize import load_openmc_mgxs_lib\n",
|
||||
"\n",
|
||||
"%matplotlib inline"
|
||||
]
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
|
|
@ -486,7 +486,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
|
|
@ -524,9 +524,9 @@
|
|||
" 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 | 60a1f157dae88b62e1865a5fe3efd7ef0773a068\n",
|
||||
" Date/Time | 2017-02-25 14:26:54\n",
|
||||
" OpenMP Threads | 8\n",
|
||||
" Git SHA1 | 647bf77a57a3cc5cce24b39cb192e1b99f52e499\n",
|
||||
" Date/Time | 2017-02-27 13:25:16\n",
|
||||
" OpenMP Threads | 4\n",
|
||||
"\n",
|
||||
" ===========================================================================\n",
|
||||
" ========================> INITIALIZATION <=========================\n",
|
||||
|
|
@ -536,11 +536,16 @@
|
|||
" Reading geometry XML file...\n",
|
||||
" Reading materials XML file...\n",
|
||||
" Reading cross sections XML file...\n",
|
||||
" Reading H1 from /opt/xsdata/nndc/H1.h5\n",
|
||||
" Reading O16 from /opt/xsdata/nndc/O16.h5\n",
|
||||
" Reading U235 from /opt/xsdata/nndc/U235.h5\n",
|
||||
" Reading U238 from /opt/xsdata/nndc/U238.h5\n",
|
||||
" Reading Zr90 from /opt/xsdata/nndc/Zr90.h5\n",
|
||||
" Reading H1 from\n",
|
||||
" /home/wbinventor/Documents/NSE-CRPG-Codes/openmc/data/nndc_hdf5/H1.h5\n",
|
||||
" Reading O16 from\n",
|
||||
" /home/wbinventor/Documents/NSE-CRPG-Codes/openmc/data/nndc_hdf5/O16.h5\n",
|
||||
" Reading U235 from\n",
|
||||
" /home/wbinventor/Documents/NSE-CRPG-Codes/openmc/data/nndc_hdf5/U235.h5\n",
|
||||
" Reading U238 from\n",
|
||||
" /home/wbinventor/Documents/NSE-CRPG-Codes/openmc/data/nndc_hdf5/U238.h5\n",
|
||||
" Reading Zr90 from\n",
|
||||
" /home/wbinventor/Documents/NSE-CRPG-Codes/openmc/data/nndc_hdf5/Zr90.h5\n",
|
||||
" Maximum neutron transport energy: 2.00000E+07 eV for H1\n",
|
||||
" Reading tallies XML file...\n",
|
||||
" Building neighboring cells lists for each surface...\n",
|
||||
|
|
@ -570,81 +575,8 @@
|
|||
" 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.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.5070E-01 seconds\n",
|
||||
" Reading cross sections = 2.4151E-01 seconds\n",
|
||||
" Total time in simulation = 2.3276E+00 seconds\n",
|
||||
" Time in transport only = 2.2350E+00 seconds\n",
|
||||
" Time in inactive batches = 2.5677E-01 seconds\n",
|
||||
" Time in active batches = 2.0708E+00 seconds\n",
|
||||
" Time synchronizing fission bank = 2.7683E-03 seconds\n",
|
||||
" Sampling source sites = 2.0233E-03 seconds\n",
|
||||
" SEND/RECV source sites = 7.1007E-04 seconds\n",
|
||||
" Time accumulating tallies = 5.0753E-05 seconds\n",
|
||||
" Total time for finalization = 3.8695E-04 seconds\n",
|
||||
" Total time elapsed = 2.6857E+00 seconds\n",
|
||||
" Calculation Rate (inactive) = 97364.6 neutrons/second\n",
|
||||
" Calculation Rate (active) = 48290.8 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"
|
||||
" 19/1 1.19253 1.17120 +/- 0.00913\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"0"
|
||||
]
|
||||
},
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
|
|
@ -668,7 +600,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
|
|
@ -694,7 +626,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
|
|
@ -729,28 +661,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"total.print_xs()"
|
||||
]
|
||||
|
|
@ -764,58 +679,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df = scattering.get_pandas_dataframe()\n",
|
||||
"df.head(10)"
|
||||
|
|
@ -830,7 +698,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
|
|
@ -848,7 +716,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
|
|
@ -875,68 +743,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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>-5.551115e-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.110223e-16</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... -5.55e-15 1.13e-02 \n",
|
||||
"1 (((total / flux) - (absorption / flux)) - (sca... -1.11e-16 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",
|
||||
|
|
@ -954,68 +765,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Use tally arithmetic to compute the absorption-to-total MGXS ratio\n",
|
||||
"absorption_to_total = absorption.xs_tally / total.xs_tally\n",
|
||||
|
|
@ -1026,68 +780,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Use tally arithmetic to compute the scattering-to-total MGXS ratio\n",
|
||||
"scattering_to_total = scattering.xs_tally / total.xs_tally\n",
|
||||
|
|
@ -1105,68 +802,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"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",
|
||||
|
|
@ -1192,7 +832,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.6.0"
|
||||
"version": "3.5.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
747
openmc/openmoc_compatible.py
Normal file
747
openmc/openmoc_compatible.py
Normal file
|
|
@ -0,0 +1,747 @@
|
|||
import copy
|
||||
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 openmc
|
||||
import openmc.checkvalue as cv
|
||||
|
||||
|
||||
# A dictionary of all OpenMC Materials created
|
||||
# Keys - Material IDs
|
||||
# Values - Materials
|
||||
OPENMC_MATERIALS = {}
|
||||
|
||||
# A dictionary of all OpenMOC Materials created
|
||||
# Keys - Material IDs
|
||||
# Values - Materials
|
||||
OPENMOC_MATERIALS = {}
|
||||
|
||||
# A dictionary of all OpenMC Surfaces created
|
||||
# Keys - Surface IDs
|
||||
# Values - Surfaces
|
||||
OPENMC_SURFACES = {}
|
||||
|
||||
# A dictionary of all OpenMOC Surfaces created
|
||||
# Keys - Surface IDs
|
||||
# Values - Surfaces
|
||||
OPENMOC_SURFACES = {}
|
||||
|
||||
# A dictionary of all OpenMC Cells created
|
||||
# Keys - Cell IDs
|
||||
# Values - Cells
|
||||
OPENMC_CELLS = {}
|
||||
|
||||
# A dictionary of all OpenMOC Cells created
|
||||
# Keys - Cell IDs
|
||||
# Values - Cells
|
||||
OPENMOC_CELLS = {}
|
||||
|
||||
# A dictionary of all OpenMC Universes created
|
||||
# Keys - Universes IDs
|
||||
# Values - Universes
|
||||
OPENMC_UNIVERSES = {}
|
||||
|
||||
# A dictionary of all OpenMOC Universes created
|
||||
# Keys - Universes IDs
|
||||
# Values - Universes
|
||||
OPENMOC_UNIVERSES = {}
|
||||
|
||||
# A dictionary of all OpenMC Lattices created
|
||||
# Keys - Lattice IDs
|
||||
# Values - Lattices
|
||||
OPENMC_LATTICES = {}
|
||||
|
||||
# A dictionary of all OpenMOC Lattices created
|
||||
# Keys - Lattice IDs
|
||||
# Values - Lattices
|
||||
OPENMOC_LATTICES = {}
|
||||
|
||||
|
||||
def get_openmoc_material(openmc_material):
|
||||
"""Return an OpenMOC material corresponding to an OpenMC material.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmc_material : openmc.material.Material
|
||||
OpenMC material
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmoc_material : openmoc.Material
|
||||
Equivalent OpenMOC material
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmc_material', openmc_material, openmc.Material)
|
||||
|
||||
material_id = openmc_material.id
|
||||
|
||||
# If this Material was already created, use it
|
||||
if material_id in OPENMOC_MATERIALS:
|
||||
return OPENMOC_MATERIALS[material_id]
|
||||
|
||||
# Create an OpenMOC Material to represent this OpenMC Material
|
||||
name = str(openmc_material.name)
|
||||
openmoc_material = openmoc.Material(id=material_id, name=name)
|
||||
|
||||
# Add the OpenMC Material to the global collection of all OpenMC Materials
|
||||
OPENMC_MATERIALS[material_id] = openmc_material
|
||||
|
||||
# Add the OpenMOC Material to the global collection of all OpenMOC Materials
|
||||
OPENMOC_MATERIALS[material_id] = openmoc_material
|
||||
|
||||
return openmoc_material
|
||||
|
||||
|
||||
def get_openmc_material(openmoc_material):
|
||||
"""Return an OpenMC material corresponding to an OpenMOC material.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmoc_material : openmoc.Material
|
||||
OpenMOC material
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc_material : openmc.material.Material
|
||||
Equivalent OpenMC material
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmoc_material', openmoc_material, openmoc.Material)
|
||||
|
||||
material_id = openmoc_material.getId()
|
||||
|
||||
# If this Material was already created, use it
|
||||
if material_id in OPENMC_MATERIALS:
|
||||
return OPENMC_MATERIALS[material_id]
|
||||
|
||||
# Create an OpenMC Material to represent this OpenMOC Material
|
||||
name = openmoc_material.getName()
|
||||
openmc_material = openmc.Material(material_id=material_id, name=name)
|
||||
|
||||
# Add the OpenMOC Material to the global collection of all OpenMOC Materials
|
||||
OPENMOC_MATERIALS[material_id] = openmoc_material
|
||||
|
||||
# Add the OpenMC Material to the global collection of all OpenMC Materials
|
||||
OPENMC_MATERIALS[material_id] = openmc_material
|
||||
|
||||
return openmc_material
|
||||
|
||||
|
||||
def get_openmoc_surface(openmc_surface):
|
||||
"""Return an OpenMOC surface corresponding to an OpenMC surface.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmc_surface : openmc.surface.Surface
|
||||
OpenMC surface
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmoc_surface : openmoc.Surface
|
||||
Equivalent OpenMOC surface
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmc_surface', openmc_surface, openmc.Surface)
|
||||
|
||||
surface_id = openmc_surface.id
|
||||
|
||||
# If this Material was already created, use it
|
||||
if surface_id in OPENMOC_SURFACES:
|
||||
return OPENMOC_SURFACES[surface_id]
|
||||
|
||||
# Create an OpenMOC Surface to represent this OpenMC Surface
|
||||
name = openmc_surface.name
|
||||
|
||||
# Determine the type of boundary conditions applied to the Surface
|
||||
if openmc_surface.boundary_type == 'vacuum':
|
||||
boundary = openmoc.VACUUM
|
||||
elif openmc_surface.boundary_type == 'reflective':
|
||||
boundary = openmoc.REFLECTIVE
|
||||
elif openmc_surface.boundary_type == 'periodic':
|
||||
boundary = openmoc.PERIODIC
|
||||
else:
|
||||
boundary = openmoc.BOUNDARY_NONE
|
||||
|
||||
if openmc_surface.type == 'plane':
|
||||
A = openmc_surface.a
|
||||
B = openmc_surface.b
|
||||
C = openmc_surface.c
|
||||
D = openmc_surface.d
|
||||
openmoc_surface = openmoc.Plane(A, B, C, D, surface_id, name)
|
||||
|
||||
elif openmc_surface.type == 'x-plane':
|
||||
x0 = openmc_surface.x0
|
||||
openmoc_surface = openmoc.XPlane(x0, surface_id, name)
|
||||
|
||||
elif openmc_surface.type == 'y-plane':
|
||||
y0 = openmc_surface.y0
|
||||
openmoc_surface = openmoc.YPlane(y0, surface_id, name)
|
||||
|
||||
elif openmc_surface.type == 'z-plane':
|
||||
z0 = openmc_surface.z0
|
||||
openmoc_surface = openmoc.ZPlane(z0, surface_id, name)
|
||||
|
||||
elif openmc_surface.type == 'z-cylinder':
|
||||
x0 = openmc_surface.x0
|
||||
y0 = openmc_surface.y0
|
||||
R = openmc_surface.r
|
||||
openmoc_surface = openmoc.ZCylinder(x0, y0, R, surface_id, name)
|
||||
|
||||
else:
|
||||
msg = 'Unable to create an OpenMOC Surface from an OpenMC ' \
|
||||
'Surface of type "{0}" since it is not a compatible ' \
|
||||
'Surface type in OpenMOC'.format(type(openmc_surface))
|
||||
raise ValueError(msg)
|
||||
|
||||
# Set the boundary condition for this Surface
|
||||
openmoc_surface.setBoundaryType(boundary)
|
||||
|
||||
# Add the OpenMC Surface to the global collection of all OpenMC Surfaces
|
||||
OPENMC_SURFACES[surface_id] = openmc_surface
|
||||
|
||||
# Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces
|
||||
OPENMOC_SURFACES[surface_id] = openmoc_surface
|
||||
|
||||
return openmoc_surface
|
||||
|
||||
|
||||
def get_openmc_surface(openmoc_surface):
|
||||
"""Return an OpenMC surface corresponding to an OpenMOC surface.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmoc_surface : openmoc.Surface
|
||||
OpenMOC surface
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc_surface : openmc.surface.Surface
|
||||
Equivalent OpenMC surface
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmoc_surface', openmoc_surface, openmoc.Surface)
|
||||
|
||||
surface_id = openmoc_surface.id
|
||||
|
||||
# If this Surface was already created, use it
|
||||
if surface_id in OPENMC_SURFACES:
|
||||
return OPENMC_SURFACES[surface_id]
|
||||
|
||||
# Create an OpenMC Surface to represent this OpenCG Surface
|
||||
name = openmoc_surface.name
|
||||
|
||||
# Correct for OpenMC's syntax for Surfaces dividing Cells
|
||||
boundary = openmoc_surface.getBoundaryType()
|
||||
if boundary == openmoc.VACCUM:
|
||||
boundary = 'vacuum'
|
||||
elif boundary == openmoc.REFLECTIVE:
|
||||
boundary = 'reflective'
|
||||
elif boundary == openmoc.PERIODIC:
|
||||
boundary = 'periodic'
|
||||
else:
|
||||
boundary = 'transmission'
|
||||
|
||||
if openmoc_surface.getSurfaceType() == openmoc.PLANE:
|
||||
A = openmoc_surface.getA()
|
||||
B = openmoc_surface.getB()
|
||||
C = openmoc_surface.getC()
|
||||
D = openmoc_surface.getD()
|
||||
openmc_surface = openmc.Plane(surface_id, boundary, A, B, C, D, name)
|
||||
|
||||
elif openmoc_surface.getSurfaceType() == openmoc.XPLANE:
|
||||
x0 = openmoc_surface.getX()
|
||||
openmc_surface = openmc.XPlane(surface_id, boundary, x0, name)
|
||||
|
||||
elif openmoc_surface.type == openmoc.YPLANE:
|
||||
y0 = openmoc_surface.getY()
|
||||
openmc_surface = openmc.YPlane(surface_id, boundary, y0, name)
|
||||
|
||||
elif openmoc_surface.type == openmoc.ZPLANE:
|
||||
z0 = openmoc_surface.getZ()
|
||||
openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name)
|
||||
|
||||
elif openmoc_surface.getSurfaceType() == openmoc.ZCYLINDER:
|
||||
x0 = openmoc_surface.getX0()
|
||||
y0 = openmoc_surface.getY0()
|
||||
R = openmoc_surface.getR()
|
||||
openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R, name)
|
||||
|
||||
# Add the OpenMC Surface to the global collection of all OpenMC Surfaces
|
||||
OPENMC_SURFACES[surface_id] = openmc_surface
|
||||
|
||||
# Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces
|
||||
OPENMOC_SURFACES[surface_id] = openmoc_surface
|
||||
|
||||
return openmc_surface
|
||||
|
||||
|
||||
def get_openmoc_cell(openmc_cell):
|
||||
"""Return an OpenMOC cell corresponding to an OpenMC cell.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmc_cell : openmc.universe.Cell
|
||||
OpenMC cell
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmoc_cell : openmoc.Cell
|
||||
Equivalent OpenMOC cell
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmc_cell', openmc_cell, openmc.Cell)
|
||||
|
||||
cell_id = openmc_cell.id
|
||||
|
||||
# If this Cell was already created, use it
|
||||
if cell_id in OPENMOC_CELLS:
|
||||
return OPENMOC_CELLS[cell_id]
|
||||
|
||||
# Create an OpenMOC Cell to represent this OpenMC Cell
|
||||
name = openmc_cell.name
|
||||
openmoc_cell = openmoc.Cell(cell_id, name)
|
||||
|
||||
fill = openmc_cell.fill
|
||||
|
||||
if openmc_cell.fill_type == 'material':
|
||||
openmoc_cell.setFill(get_openmoc_material(fill))
|
||||
elif openmc_cell.fill_type == 'universe':
|
||||
openmoc_cell.setFill(get_openmoc_universe(fill))
|
||||
else:
|
||||
openmoc_cell.setFill(get_openmoc_lattice(fill))
|
||||
|
||||
if openmc_cell.rotation is not None:
|
||||
rotation = np.asarray(openmc_cell.rotation, dtype=np.float64)
|
||||
openmoc_cell.setRotation(rotation)
|
||||
if openmc_cell.translation is not None:
|
||||
translation = np.asarray(openmc_cell.translation, dtype=np.float64)
|
||||
openmoc_cell.setTranslation(translation)
|
||||
|
||||
# Add surfaces to OpenMOC cell from OpenMC cell region. Right now this only
|
||||
# works if the region is a single half-space or an intersection of
|
||||
# half-spaces, i.e., no complex cells.
|
||||
region = openmc_cell.region
|
||||
if region is not None:
|
||||
if isinstance(region, openmc.Halfspace):
|
||||
surface = region.surface
|
||||
halfspace = -1 if region.side == '-' else 1
|
||||
openmoc_cell.addSurface(halfspace, get_openmoc_surface(surface))
|
||||
elif isinstance(region, openmc.Intersection):
|
||||
for node in region.nodes:
|
||||
if not isinstance(node, openmc.Halfspace):
|
||||
raise NotImplementedError("Complex cells not yet "
|
||||
"supported in OpenMOC.")
|
||||
surface = node.surface
|
||||
halfspace = -1 if node.side == '-' else 1
|
||||
openmoc_cell.addSurface(halfspace, get_openmoc_surface(surface))
|
||||
else:
|
||||
raise NotImplementedError("Complex cells not yet supported "
|
||||
"in OpenMOC.")
|
||||
|
||||
# Add the OpenMC Cell to the global collection of all OpenMC Cells
|
||||
OPENMC_CELLS[cell_id] = openmc_cell
|
||||
|
||||
# Add the OpenMOC Cell to the global collection of all OpenMOC Cells
|
||||
OPENMOC_CELLS[cell_id] = openmoc_cell
|
||||
|
||||
return openmoc_cell
|
||||
|
||||
|
||||
def get_openmc_cell(openmoc_cell):
|
||||
"""Return an OpenMC cell corresponding to an OpenMOC cell.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmoc_cell : openmoc.Cell
|
||||
OpenCG cell
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc_cell : openmc.universe.Cell
|
||||
Equivalent OpenMC cell
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmoc_cell', openmoc_cell, openmoc.Cell)
|
||||
|
||||
cell_id = openmoc_cell.getId()
|
||||
|
||||
# If this Cell was already created, use it
|
||||
if cell_id in OPENMC_CELLS:
|
||||
return OPENMC_CELLS[cell_id]
|
||||
|
||||
# Create an OpenMOC Cell to represent this OpenMC Cell
|
||||
name = openmoc_cell.getName()
|
||||
openmc_cell = openmc.Cell(cell_id, name)
|
||||
|
||||
if (openmoc_cell.getType() == openmoc.MATERIAL):
|
||||
fill = openmoc_cell.getFillMaterial()
|
||||
openmc_cell.fill = get_openmc_material(fill)
|
||||
elif (openmoc_cell.getType() == openmoc.FILL):
|
||||
fill = openmoc_cell.getFillUniverse()
|
||||
if isinstance(fill, openmoc.Lattice):
|
||||
openmc_cell.fill = get_openmc_lattice(fill)
|
||||
else:
|
||||
openmc_cell.fill = get_openmc_universe(fill)
|
||||
|
||||
if openmoc_cell.isRotated():
|
||||
rotation = openmoc_cell.getRotation(3)
|
||||
openmc_cell.rotation = rotation
|
||||
if openmoc_cell.isTranslated():
|
||||
translation = openmoc_cell.getTranslation(3)
|
||||
openmc_cell.translation = translation
|
||||
|
||||
|
||||
surfaces = []
|
||||
operators = []
|
||||
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)])
|
||||
|
||||
# Add the OpenMC Cell to the global collection of all OpenMC Cells
|
||||
OPENMC_CELLS[cell_id] = openmc_cell
|
||||
|
||||
# Add the OpenMOC Cell to the global collection of all OpenMOC Cells
|
||||
OPENMOC_CELLS[cell_id] = openmoc_cell
|
||||
|
||||
return openmc_cell
|
||||
|
||||
|
||||
def get_openmoc_universe(openmc_universe):
|
||||
"""Return an OpenMOC universe corresponding to an OpenMC universe.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmc_universe : openmc.universe.Universe
|
||||
OpenMC universe
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmoc_universe : openmoc.Universe
|
||||
Equivalent OpenMOC universe
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmc_universe', openmc_universe, openmc.Universe)
|
||||
|
||||
universe_id = openmc_universe.id
|
||||
|
||||
# If this Universe was already created, use it
|
||||
if universe_id in OPENMOC_UNIVERSES:
|
||||
return OPENMOC_UNIVERSES[universe_id]
|
||||
|
||||
# Create an OpenMOC Universe to represent this OpenMC Universe
|
||||
name = openmc_universe.name
|
||||
openmoc_universe = openmoc.Universe(universe_id, name)
|
||||
|
||||
# Convert all OpenMC Cells in this Universe to OpenCG Cells
|
||||
openmc_cells = openmc_universe.cells
|
||||
|
||||
for openmc_cell in openmc_cells.values():
|
||||
openmoc_cell = get_openmoc_cell(openmc_cell)
|
||||
openmoc_universe.addCell(openmoc_cell)
|
||||
|
||||
# Add the OpenMC Universe to the global collection of all OpenMC Universes
|
||||
OPENMC_UNIVERSES[universe_id] = openmc_universe
|
||||
|
||||
# Add the OpenMOC Universe to the global collection of all OpenMOC Universes
|
||||
OPENMOC_UNIVERSES[universe_id] = openmoc_universe
|
||||
|
||||
return openmoc_universe
|
||||
|
||||
|
||||
def get_openmc_universe(openmoc_universe):
|
||||
"""Return an OpenMC universe corresponding to an OpenMOC universe.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmoc_universe : openmoc.Universe
|
||||
OpenMOC universe
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc_universe : openmc.universe.Universe
|
||||
Equivalent OpenMC universe
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmoc_universe', openmoc_universe, openmoc.Universe)
|
||||
|
||||
universe_id = openmoc_universe.getId()
|
||||
|
||||
# If this Universe was already created, use it
|
||||
if universe_id in OPENMC_UNIVERSES:
|
||||
return OPENMC_UNIVERSES[universe_id]
|
||||
|
||||
# Create an OpenMC Universe to represent this OpenMOC Universe
|
||||
name = openmoc_universe.getName()
|
||||
openmc_universe = openmc.Universe(universe_id, name)
|
||||
|
||||
# Convert all OpenMOC Cells in this Universe to OpenMC Cells
|
||||
for openmoc_cell in openmoc_universe.getCells():
|
||||
openmc_cell = get_openmc_cell(openmoc_cell)
|
||||
openmc_universe.add_cell(openmc_cell)
|
||||
|
||||
# Add the OpenMC Universe to the global collection of all OpenMC Universes
|
||||
OPENMC_UNIVERSES[universe_id] = openmc_universe
|
||||
|
||||
# Add the OpenMOC Universe to the global collection of all OpenMOC Universes
|
||||
OPENMOC_UNIVERSES[universe_id] = openmoc_universe
|
||||
|
||||
return openmc_universe
|
||||
|
||||
|
||||
def get_openmoc_lattice(openmc_lattice):
|
||||
"""Return an OpenMOC lattice corresponding to an OpenMOC lattice.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmc_lattice : openmc.universe.Lattice
|
||||
OpenMC lattice
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmoc_lattice : openmoc.Lattice
|
||||
Equivalent OpenMOC lattice
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmc_lattice', openmc_lattice, openmc.Lattice)
|
||||
|
||||
lattice_id = openmc_lattice.id
|
||||
|
||||
# If this Lattice was already created, use it
|
||||
if lattice_id in OPENMOC_LATTICES:
|
||||
return OPENMOC_LATTICES[lattice_id]
|
||||
|
||||
# Create an OpenMOC Lattice to represent this OpenMC Lattice
|
||||
name = openmc_lattice.name
|
||||
dimension = openmc_lattice.shape
|
||||
pitch = openmc_lattice.pitch
|
||||
lower_left = openmc_lattice.lower_left
|
||||
universes = openmc_lattice.universes
|
||||
|
||||
# Convert 2D dimension to 3D for OpenMOC
|
||||
if len(dimension) == 2:
|
||||
new_dimension = np.ones(3, dtype=np.int)
|
||||
new_dimension[:2] = dimension
|
||||
dimension = new_dimension
|
||||
|
||||
# Convert 2D pitch to 3D for OpenMOC
|
||||
if len(pitch) == 2:
|
||||
new_pitch = np.ones(3, dtype=np.float64) * np.finfo(np.float64).max
|
||||
new_pitch[:2] = pitch
|
||||
pitch = new_pitch
|
||||
|
||||
# Convert 2D lower left to 3D for OpenCG
|
||||
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
|
||||
if len(universes.shape) == 2:
|
||||
new_universes = universes.copy()
|
||||
new_universes.shape = (1,) + universes.shape
|
||||
universes = new_universes
|
||||
|
||||
# Initialize an empty array for the OpenMOC nested Universes in this Lattice
|
||||
universe_array = np.ndarray(tuple(dimension[::-1]), dtype=openmoc.Universe)
|
||||
|
||||
# Create OpenMOC Universes for each unique nested Universe in this Lattice
|
||||
unique_universes = openmc_lattice.get_unique_universes()
|
||||
|
||||
for universe_id, universe in unique_universes.items():
|
||||
unique_universes[universe_id] = get_openmoc_universe(universe)
|
||||
|
||||
# Build the nested Universe array
|
||||
for z in range(dimension[2]):
|
||||
for y in range(dimension[1]):
|
||||
for x in range(dimension[0]):
|
||||
universe_id = universes[z][y][x].id
|
||||
universe_array[z][dimension[1]-y-1][x] = unique_universes[universe_id]
|
||||
|
||||
openmoc_lattice = openmoc.Lattice(lattice_id, name)
|
||||
openmoc_lattice.setWidth(pitch[0], pitch[1], pitch[2])
|
||||
openmoc_lattice.setUniverses(universe_array.tolist())
|
||||
|
||||
offset = np.array(lower_left, dtype=np.float64) - \
|
||||
((np.array(pitch, dtype=np.float64) *
|
||||
np.array(dimension, dtype=np.float64))) / -2.0
|
||||
openmoc_lattice.setOffset(offset[0], offset[1], offset[2])
|
||||
|
||||
# Add the OpenMC Lattice to the global collection of all OpenMC Lattices
|
||||
OPENMC_LATTICES[lattice_id] = openmc_lattice
|
||||
|
||||
# Add the OpenMOC Lattice to the global collection of all OpenMOC Lattices
|
||||
OPENMOC_LATTICES[lattice_id] = openmoc_lattice
|
||||
|
||||
return openmoc_lattice
|
||||
|
||||
|
||||
def get_openmc_lattice(openmoc_lattice):
|
||||
"""Return an OpenMC lattice corresponding to an OpenMOC lattice.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmoc_lattice : openmoc.Lattice
|
||||
OpenMOC lattice
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc_lattice : openmc.universe.Lattice
|
||||
Equivalent OpenMC lattice
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmoc_lattice', openmoc_lattice, openmoc.Lattice)
|
||||
|
||||
lattice_id = openmoc_lattice.getId()
|
||||
|
||||
# If this Lattice was already created, use it
|
||||
if lattice_id in OPENMC_LATTICES:
|
||||
return OPENMC_LATTICES[lattice_id]
|
||||
|
||||
name = openmoc_lattice.getName()
|
||||
dimension = [1, openmoc_lattice.getNumY(), openmoc_lattice.getNumX()]
|
||||
width = [1, openmoc_lattice.getWidthY(), openmoc_lattice.getWidthX()]
|
||||
offset = openmoc_lattice.getOffset()
|
||||
lower_left = np.array(offset, dtype=np.float64) + \
|
||||
((np.array(width, dtype=np.float64) *
|
||||
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]), \
|
||||
dtype=openmoc.Universe)
|
||||
|
||||
# Create OpenMOC Universes for each unique nested Universe in this Lattice
|
||||
unique_universes = openmoc_lattice.getUniqueUniverses()
|
||||
|
||||
for universe_id, universe in unique_universes.items():
|
||||
unique_universes[universe_id] = get_openmc_universe(universe)
|
||||
|
||||
# Build the nested Universe array
|
||||
for z in range(dimension[2]):
|
||||
for y in range(dimension[1]):
|
||||
for x in range(dimension[0]):
|
||||
universe = openmoc_lattice.getUniverse(x, y)
|
||||
universe_id = universe.getId()
|
||||
universe_array[z][dimension[1]-y-1][x] = unique_universes[universe_id]
|
||||
|
||||
openmc_lattice = openmc.RectLattice(lattice_id=lattice_id, name=name)
|
||||
openmc_lattice.pitch = width
|
||||
openmc_lattice.lower_left = lower_left
|
||||
openmc_lattice.universes = universe_array
|
||||
|
||||
# Add the OpenMC Lattice to the global collection of all OpenMC Lattices
|
||||
OPENMC_LATTICES[lattice_id] = openmc_lattice
|
||||
|
||||
# Add the OpenMOC Lattice to the global collection of all OpenMOC Lattices
|
||||
OPENMOC_LATTICES[lattice_id] = openmoc_lattice
|
||||
|
||||
return openmc_lattice
|
||||
|
||||
|
||||
def get_openmoc_geometry(openmc_geometry):
|
||||
"""Return an OpenMC geometry corresponding to an OpenMOC geometry.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmc_geometry : openmc.universe.Geometry
|
||||
OpenMC geometry
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmoc_geometry : openmoc.Geometry
|
||||
Equivalent OpenMOC geometry
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmc_geometry', openmc_geometry, openmc.Geometry)
|
||||
|
||||
# Clear dictionaries and auto-generated IDs
|
||||
OPENMC_SURFACES.clear()
|
||||
OPENMOC_SURFACES.clear()
|
||||
OPENMC_CELLS.clear()
|
||||
OPENMOC_CELLS.clear()
|
||||
OPENMC_UNIVERSES.clear()
|
||||
OPENMOC_UNIVERSES.clear()
|
||||
OPENMC_LATTICES.clear()
|
||||
OPENMOC_LATTICES.clear()
|
||||
|
||||
openmc_root_universe = openmc_geometry.root_universe
|
||||
openmoc_root_universe = get_openmoc_universe(openmc_root_universe)
|
||||
|
||||
openmoc_geometry = openmoc.Geometry()
|
||||
openmoc_geometry.setRootUniverse(openmoc_root_universe)
|
||||
|
||||
# Update OpenMOC's auto-generated object IDs (e.g., Surface, Material)
|
||||
# with the maximum of those created from the OpenMC objects
|
||||
all_materials = openmoc_geometry.getAllMaterials()
|
||||
all_surfaces = openmoc_geometry.getAllSurfaces()
|
||||
all_cells = openmoc_geometry.getAllCells()
|
||||
all_universes = openmoc_geometry.getAllUniverses()
|
||||
|
||||
max_material_id = max(all_materials.keys())
|
||||
max_surface_id = max(all_surfaces.keys())
|
||||
max_cell_id = max(all_cells.keys())
|
||||
max_universe_id = max(all_universes.keys())
|
||||
|
||||
openmoc.maximize_material_id(max_material_id+1)
|
||||
openmoc.maximize_surface_id(max_surface_id+1)
|
||||
openmoc.maximize_cell_id(max_cell_id+1)
|
||||
openmoc.maximize_universe_id(max_universe_id+1)
|
||||
|
||||
return openmoc_geometry
|
||||
|
||||
|
||||
def get_openmc_geometry(openmoc_geometry):
|
||||
"""Return an OpenMC geometry corresponding to an OpenMOC geometry.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
openmoc_geometry : openmoc.Geometry
|
||||
OpenMOC geometry
|
||||
|
||||
Returns
|
||||
-------
|
||||
openmc_geometry : openmc.universe.Geometry
|
||||
Equivalent OpenMC geometry
|
||||
|
||||
"""
|
||||
|
||||
cv.check_type('openmoc_geometry', openmoc_geometry, openmoc.Geometry)
|
||||
|
||||
# Clear dictionaries and auto-generated ID
|
||||
OPENMC_SURFACES.clear()
|
||||
OPENMOC_SURFACES.clear()
|
||||
OPENMC_CELLS.clear()
|
||||
OPENMOC_CELLS.clear()
|
||||
OPENMC_UNIVERSES.clear()
|
||||
OPENMOC_UNIVERSES.clear()
|
||||
OPENMC_LATTICES.clear()
|
||||
OPENMOC_LATTICES.clear()
|
||||
|
||||
openmoc_root_universe = openmoc_geometry.getRootUniverse()
|
||||
openmc_root_universe = get_openmc_universe(openmoc_root_universe)
|
||||
|
||||
openmc_geometry = openmc.Geometry()
|
||||
openmc_geometry.root_universe = openmc_root_universe
|
||||
|
||||
return openmc_geometry
|
||||
Loading…
Add table
Add a link
Reference in a new issue