Merge remote-tracking branch 'upstream/develop' into dagmc_universe

This commit is contained in:
Patrick Shriwise 2021-06-30 09:12:35 -05:00
commit 1e3a38a96d
30 changed files with 3377 additions and 2627 deletions

View file

@ -0,0 +1,57 @@
====================
What's New in 0.12.2
====================
.. currentmodule:: openmc
-------
Summary
-------
This release of OpenMC is primarily a hotfix release with numerous important bug
fixes. Several tally-related enhancements have also been added.
------------
New Features
------------
Three tally-related enhancements were added to the code in this release:
- A new :class:`~openmc.CollisionFilter` class that allows tallies to be filtered
by the number of collisions a particle has undergone.
- A `translation` attribute has been added to :class:`~openmc.MeshFilter` that
allows a mesh to be translated from its original position before location
checks are performed.
- The :class:`~openmc.UnstructuredMesh` class now supports libMesh unstructured
meshes to enable better ingration with MOOSE-based applications.
---------
Bug Fixes
---------
- `Reset particle coordinates during find cell operation <https://github.com/openmc-dev/openmc/pull/1809>`_
- `Cover quadric edge case <https://github.com/openmc-dev/openmc/pull/1812>`_
- `Prevent divide-by-zero in bins_crossed methods for meshes <https://github.com/openmc-dev/openmc/pull/1816>`_
- `Fix for translational periodic boundary conditions <https://github.com/openmc-dev/openmc/pull/1820>`_
- `Fix angle sampling in CorrelatedAngleEnergy <https://github.com/openmc-dev/openmc/pull/1821>`_
- `Fix typo in fmt string for a lattice error <https://github.com/openmc-dev/openmc/pull/1824>`_
- `Nu-fission tally and stochastic volume bug fixes <https://github.com/openmc-dev/openmc/pull/1828>`_
- `Make sure failed neighbor list triggers exhaustic search <https://github.com/openmc-dev/openmc/pull/1830>`_
- `Change element to element.title to catch lowercase entries <https://github.com/openmc-dev/openmc/pull/1839>`_
- `Disallow non-current scores with a surface filter <https://github.com/openmc-dev/openmc/pull/1844>`_
- `Depletion operator obeys Materials.cross_sections <https://github.com/openmc-dev/openmc/pull/1846>`_
- `Fix for surface_bins_crossed override <https://github.com/openmc-dev/openmc/pull/1847>`_
------------
Contributors
------------
This release contains new contributions from the following people:
- `Hunter Belanger <https://github.com/HunterBelanger>`_
- `Isaac Griswold-Steiner <https://github.com/isaac-gs>`_
- `Andrew Johnson <https://github.com/drewejohnson>`_
- `Gavin Ridley <https://github.com/gridley>`_
- `Paul Romano <https://github.com/paulromano>`_
- `Patrick Shriwise <https://github.com/pshriwise>`_
- `Jonathan Shimwell <https://github.com/Shimwell>`_

View file

@ -7,6 +7,7 @@ Release Notes
.. toctree::
:maxdepth: 1
0.12.2
0.12.1
0.12.0
0.11.0

View file

@ -45,6 +45,23 @@ with the :envvar:`OPENMC_CROSS_SECTIONS` environment variable. It is recommended
to add a line in your ``.profile`` or ``.bash_profile`` setting the
:envvar:`OPENMC_CROSS_SECTIONS` environment variable.
RuntimeError: Failed to open HDF5 file with mode 'w': summary.h5
****************************************************************
This often occurs when working with the Python API and executing multiple OpenMC
runs in a script. If an :class:`openmc.StatePoint` is open in the Python interpreter,
the file handle of the statepoint file as well as the linked `summary.h5` file will
be unavailable for writing, causing this error to appear. To avoid this situation,
it is recommended that data be extracted from statepoint files in a context manager:
.. code-block:: python
with openmc.StatePoint('statepoint.10.h5') as sp:
k_eff = sp.k_combined
or that the :meth:`StatePoint.close` method is called before executing a subsequent
OpenMC run.
Geometry Debugging
******************

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 one or more lines are too long

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 one or more lines are too long

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 one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -243,7 +243,7 @@
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6AgMAAAD1grKuAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEVyEhLpgJFNv8T///98iBL0AAAAAWJLR0QDEQxM8gAAAAd0SU1FB+MHEhEzAhO1TdMAAAKlSURBVGje7ZrBscIwDETxwSWkn5TAgXCgBPqhBA6kyj/fDhCIJa2zZAwz0pmHpZWdSazd7Tw8PDw8PDw8vinCMBzW03HIsRLvhnv0HL7qD+IwjzXKzaNaxeEt9kz21RWEBV5XQbfka3pQWL4qgdLyNQkUcbwFT/FP4zjWt+D+++OY4laZQJgtnqNOwe5l9XkGmIIL/PEHUAGTeuc5P15wBbu34ucSIAXkX77h4xUtIBSXnxIAOhCLy98TANNfLj8lYBYQCuLPWmAWEBe9f90DUPdKy08JWB0U1HsoaAgQxPSnAgwBopz+VABQvoDnAnqTP0r8zealzfPcQqqAQSs/C6AKGLX0pwKs8uX0cwGaAHr6uYC9wSt46qDCB4RXBDTkMwWMhnxZQF3+s8pf1AZY5VsCWuVnAUQ+YPxB43X5koAiH035soCa/AaeBOw34m359AaQPCK/1oAAyJ8aIPBI+7QGRkD+3IBt+A6QPzeg34SH2pcauN+Kt9uXGljkse0jb6BP8AD+vwGKPLZ95A0UofbnDbAFj20/eQN+gD8h/LgRD25/8QCA2088AD/Oo8dPOoDo8ZMOoPPNeej4pwdAgUcfX9IDzHnnf5lnz88XnH/nSf4M8cIL7I+/P3yCP0G88P7W+v2z9ft36+8P9vuJ/X5r/f3Jfj83//5vff/R+v6Hvb9i78/Y+7vW94/N71/Z+2P2/pq9P2fv7+n5ATu/YOcn7PyGnR+x8yt6ftYN3PzOENCcH7LzS3Z+Ss9vO62DV5uPmgAXSz5+fs7O72n/QBQLwPwLrH+C9W/Q/hHWv8L6Z2j/ThZgvX+I9S/R/inWv8X6x2j/Guufo/17rH+Q9S/S/knWv0n7R2n/Kuufpf27tH+Y9i/vWP+0h4eHh4eHh8cW8QcxLJDBvLKoigAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOS0wNy0xOFQyMjo1MTowMi0wNTowMAMmdtQAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTktMDctMThUMjI6NTE6MDItMDU6MDBye85oAAAAAElFTkSuQmCC\n",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6AgMAAAD1grKuAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEV3C9wCswC1wFT///+Se5pWAAAAAWJLR0QDEQxM8gAAAAd0SU1FB+UGGhQuFt5F1RsAAAKlSURBVGje7ZrBscIwDETxwSWkn5TAgXCgBPqhBA6kyj/fDhCIJa2zZAwz0pmHpZWdSazd7Tw8PDw8PDw8vinCMBzW03HIsRLvhnv0HL7qD+IwjzXKzaNaxeEt9kz21RWEBV5XQbfka3pQWL4qgdLyNQkUcbwFT/FP4zjWt+D+++OY4laZQJgtnqNOwe5l9XkGmIIL/PEHUAGTeuc5P15wBbu34ucSIAXkX77h4xUtIBSXnxIAOhCLy98TANNfLj8lYBYQCuLPWmAWEBe9f90DUPdKy08JWB0U1HsoaAgQxPSnAgwBopz+VABQvoDnAnqTP0r8zealzfPcQqqAQSs/C6AKGLX0pwKs8uX0cwGaAHr6uYC9wSt46qDCB4RXBDTkMwWMhnxZQF3+s8pf1AZY5VsCWuVnAUQ+YPxB43X5koAiH035soCa/AaeBOw34m359AaQPCK/1oAAyJ8aIPBI+7QGRkD+3IBt+A6QPzeg34SH2pcauN+Kt9uXGljkse0jb6BP8AD+vwGKPLZ95A0UofbnDbAFj20/eQN+gD8h/LgRD25/8QCA2088AD/Oo8dPOoDo8ZMOoPPNeej4pwdAgUcfX9IDzHnnf5lnz88XnH/nSf4M8cIL7I+/P3yCP0G88P7W+v2z9ft36+8P9vuJ/X5r/f3Jfj83//5vff/R+v6Hvb9i78/Y+7vW94/N71/Z+2P2/pq9P2fv7+n5ATu/YOcn7PyGnR+x8yt6ftYN3PzOENCcH7LzS3Z+Ss9vO62DV5uPmgAXSz5+fs7O72n/QBQLwPwLrH+C9W/Q/hHWv8L6Z2j/ThZgvX+I9S/R/inWv8X6x2j/Guufo/17rH+Q9S/S/knWv0n7R2n/Kuufpf27tH+Y9i/vWP+0h4eHh4eHh8cW8QcxLJDBvLKoigAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wNi0yNlQyMDo0NjoyMiswMDowMIjWIT4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDYtMjZUMjA6NDY6MjIrMDA6MDD5i5mCAAAAAElFTkSuQmCC\n",
"text/plain": [
"<IPython.core.display.Image object>"
]
@ -421,11 +421,11 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/home/romano/openmc/openmc/mixin.py:71: IDWarning: Another Filter instance already exists with id=6.\n",
"/home/shriwise/opt/openmc/openmc/openmc/mixin.py:68: IDWarning: Another Filter instance already exists with id=6.\n",
" warn(msg, IDWarning)\n",
"/home/romano/openmc/openmc/mixin.py:71: IDWarning: Another Filter instance already exists with id=3.\n",
"/home/shriwise/opt/openmc/openmc/openmc/mixin.py:68: IDWarning: Another Filter instance already exists with id=3.\n",
" warn(msg, IDWarning)\n",
"/home/romano/openmc/openmc/mixin.py:71: IDWarning: Another Filter instance already exists with id=2.\n",
"/home/shriwise/opt/openmc/openmc/openmc/mixin.py:68: IDWarning: Another Filter instance already exists with id=2.\n",
" warn(msg, IDWarning)\n"
]
}
@ -478,78 +478,82 @@
" %%%%%%%%%%%\n",
"\n",
" | The OpenMC Monte Carlo Code\n",
" Copyright | 2011-2019 MIT and OpenMC contributors\n",
" License | http://openmc.readthedocs.io/en/latest/license.html\n",
" Version | 0.11.0-dev\n",
" Git SHA1 | 61c911cffdae2406f9f4bc667a9a6954748bb70c\n",
" Date/Time | 2019-07-18 22:51:02\n",
" OpenMP Threads | 4\n",
" Copyright | 2011-2021 MIT and OpenMC contributors\n",
" License | https://docs.openmc.org/en/latest/license.html\n",
" Version | 0.13.0-dev\n",
" Git SHA1 | 3dd81a1316ac3b5a0633e4b7a290f3bc97a066d9\n",
" Date/Time | 2021-06-26 15:46:22\n",
" OpenMP Threads | 2\n",
"\n",
" Reading settings XML file...\n",
" Reading cross sections XML file...\n",
" Reading materials XML file...\n",
" Reading geometry XML file...\n",
" Reading U235 from /opt/data/hdf5/nndc_hdf5_v15/U235.h5\n",
" Reading U238 from /opt/data/hdf5/nndc_hdf5_v15/U238.h5\n",
" Reading O16 from /opt/data/hdf5/nndc_hdf5_v15/O16.h5\n",
" Reading H1 from /opt/data/hdf5/nndc_hdf5_v15/H1.h5\n",
" Reading B10 from /opt/data/hdf5/nndc_hdf5_v15/B10.h5\n",
" Reading Zr90 from /opt/data/hdf5/nndc_hdf5_v15/Zr90.h5\n",
" Maximum neutron transport energy: 20000000.000000 eV for U235\n",
" Reading U235 from /home/shriwise/opt/openmc/xs/nndc_hdf5/U235.h5\n",
" Reading U238 from /home/shriwise/opt/openmc/xs/nndc_hdf5/U238.h5\n",
" Reading O16 from /home/shriwise/opt/openmc/xs/nndc_hdf5/O16.h5\n",
" Reading H1 from /home/shriwise/opt/openmc/xs/nndc_hdf5/H1.h5\n",
" Reading B10 from /home/shriwise/opt/openmc/xs/nndc_hdf5/B10.h5\n",
" Reading Zr90 from /home/shriwise/opt/openmc/xs/nndc_hdf5/Zr90.h5\n",
" Minimum neutron data temperature: 294.0 K\n",
" Maximum neutron data temperature: 294.0 K\n",
" Reading tallies XML file...\n",
" Preparing distributed cell instances...\n",
" Writing summary.h5 file...\n",
" Maximum neutron transport energy: 20000000.0 eV for U235\n",
" Initializing source particles...\n",
"\n",
" ====================> K EIGENVALUE SIMULATION <====================\n",
"\n",
" Bat./Gen. k Average k\n",
" ========= ======== ====================\n",
" 1/1 0.96168\n",
" 2/1 0.96651\n",
" 3/1 1.00678\n",
" 4/1 0.98773\n",
" 5/1 1.01883\n",
" 6/1 1.02959\n",
" 7/1 0.99859 1.01409 +/- 0.01550\n",
" 8/1 1.03441 1.02086 +/- 0.01123\n",
" 9/1 1.06097 1.03089 +/- 0.01279\n",
" 10/1 1.06132 1.03698 +/- 0.01163\n",
" 11/1 1.04687 1.03863 +/- 0.00964\n",
" 12/1 1.02982 1.03737 +/- 0.00824\n",
" 13/1 1.03520 1.03710 +/- 0.00714\n",
" 14/1 0.99508 1.03243 +/- 0.00784\n",
" 15/1 1.03987 1.03317 +/- 0.00705\n",
" 16/1 1.02743 1.03265 +/- 0.00640\n",
" 17/1 1.02975 1.03241 +/- 0.00585\n",
" 18/1 0.99671 1.02966 +/- 0.00604\n",
" 19/1 1.02040 1.02900 +/- 0.00563\n",
" 20/1 1.02024 1.02842 +/- 0.00527\n",
" 1/1 0.99327\n",
" 2/1 1.05535\n",
" 3/1 1.02165\n",
" 4/1 1.02898\n",
" 5/1 1.02521\n",
" 6/1 1.04782\n",
" 7/1 1.07014 1.05898 +/- 0.01116\n",
" 8/1 1.07724 1.06507 +/- 0.00886\n",
" 9/1 1.06268 1.06447 +/- 0.00630\n",
" 10/1 0.99628 1.05083 +/- 0.01448\n",
" 11/1 1.07257 1.05446 +/- 0.01237\n",
" 12/1 1.01603 1.04897 +/- 0.01181\n",
" 13/1 1.01047 1.04415 +/- 0.01130\n",
" 14/1 1.03639 1.04329 +/- 0.01000\n",
" 15/1 1.00699 1.03966 +/- 0.00966\n",
" 16/1 0.99098 1.03524 +/- 0.00979\n",
" 17/1 1.03990 1.03562 +/- 0.00895\n",
" 18/1 1.02076 1.03448 +/- 0.00831\n",
" 19/1 0.99685 1.03179 +/- 0.00815\n",
" 20/1 1.04833 1.03290 +/- 0.00767\n",
" Creating state point statepoint.20.h5...\n",
"\n",
" =======================> TIMING STATISTICS <=======================\n",
"\n",
" Total time for initialization = 3.4427e-01 seconds\n",
" Reading cross sections = 3.1628e-01 seconds\n",
" Total time in simulation = 3.7319e+00 seconds\n",
" Time in transport only = 3.6302e+00 seconds\n",
" Time in inactive batches = 4.9601e-01 seconds\n",
" Time in active batches = 3.2359e+00 seconds\n",
" Time synchronizing fission bank = 2.8100e-03 seconds\n",
" Sampling source sites = 2.4682e-03 seconds\n",
" SEND/RECV source sites = 3.2484e-04 seconds\n",
" Time accumulating tallies = 4.4538e-05 seconds\n",
" Total time for finalization = 9.3656e-04 seconds\n",
" Total time elapsed = 4.0859e+00 seconds\n",
" Calculation Rate (inactive) = 25201.2 particles/second\n",
" Calculation Rate (active) = 11588.7 particles/second\n",
" Total time for initialization = 2.5195e-01 seconds\n",
" Reading cross sections = 2.3830e-01 seconds\n",
" Total time in simulation = 3.6172e+00 seconds\n",
" Time in transport only = 3.6041e+00 seconds\n",
" Time in inactive batches = 4.5282e-01 seconds\n",
" Time in active batches = 3.1644e+00 seconds\n",
" Time synchronizing fission bank = 2.4821e-03 seconds\n",
" Sampling source sites = 2.0826e-03 seconds\n",
" SEND/RECV source sites = 3.8781e-04 seconds\n",
" Time accumulating tallies = 2.8497e-04 seconds\n",
" Time writing statepoints = 8.5742e-03 seconds\n",
" Total time for finalization = 3.1545e-04 seconds\n",
" Total time elapsed = 3.8763e+00 seconds\n",
" Calculation Rate (inactive) = 27604.9 particles/second\n",
" Calculation Rate (active) = 11850.8 particles/second\n",
"\n",
" ============================> RESULTS <============================\n",
"\n",
" k-effective (Collision) = 1.02889 +/- 0.00492\n",
" k-effective (Track-length) = 1.02842 +/- 0.00527\n",
" k-effective (Absorption) = 1.02637 +/- 0.00349\n",
" Combined k-effective = 1.02700 +/- 0.00291\n",
" Leakage Fraction = 0.01717 +/- 0.00107\n",
" k-effective (Collision) = 1.03497 +/- 0.00681\n",
" k-effective (Track-length) = 1.03290 +/- 0.00767\n",
" k-effective (Absorption) = 1.02663 +/- 0.00590\n",
" Combined k-effective = 1.03085 +/- 0.00535\n",
" Leakage Fraction = 0.01728 +/- 0.00077\n",
"\n"
]
}
@ -631,8 +635,8 @@
" <th>0</th>\n",
" <td>total</td>\n",
" <td>(nu-fission / (absorption + current))</td>\n",
" <td>1.023002</td>\n",
" <td>0.006647</td>\n",
" <td>1.025847</td>\n",
" <td>0.009998</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -640,7 +644,7 @@
],
"text/plain": [
" nuclide score mean std. dev.\n",
"0 total (nu-fission / (absorption + current)) 1.02e+00 6.65e-03"
"0 total (nu-fission / (absorption + current)) 1.03e+00 1.00e-02"
]
},
"execution_count": 21,
@ -712,8 +716,8 @@
" <td>0.625</td>\n",
" <td>total</td>\n",
" <td>((absorption + current) / (absorption + current))</td>\n",
" <td>0.694368</td>\n",
" <td>0.004606</td>\n",
" <td>0.695924</td>\n",
" <td>0.007275</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -724,7 +728,7 @@
"0 0.00e+00 6.25e-01 total \n",
"\n",
" score mean std. dev. \n",
"0 ((absorption + current) / (absorption + current)) 6.94e-01 4.61e-03 "
"0 ((absorption + current) / (absorption + current)) 6.96e-01 7.27e-03 "
]
},
"execution_count": 22,
@ -790,8 +794,8 @@
" <td>0.625</td>\n",
" <td>total</td>\n",
" <td>(nu-fission / nu-fission)</td>\n",
" <td>1.203099</td>\n",
" <td>0.009615</td>\n",
" <td>1.203449</td>\n",
" <td>0.01381</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -802,7 +806,7 @@
"0 0.00e+00 6.25e-01 total (nu-fission / nu-fission) \n",
"\n",
" mean std. dev. \n",
"0 1.20e+00 9.61e-03 "
"0 1.20e+00 1.38e-02 "
]
},
"execution_count": 23,
@ -869,8 +873,8 @@
" <td>1</td>\n",
" <td>total</td>\n",
" <td>(absorption / absorption)</td>\n",
" <td>0.749423</td>\n",
" <td>0.006089</td>\n",
" <td>0.74975</td>\n",
" <td>0.009032</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -881,7 +885,7 @@
"0 0.00e+00 6.25e-01 1 total (absorption / absorption) \n",
"\n",
" mean std. dev. \n",
"0 7.49e-01 6.09e-03 "
"0 7.50e-01 9.03e-03 "
]
},
"execution_count": 24,
@ -946,8 +950,8 @@
" <td>1</td>\n",
" <td>total</td>\n",
" <td>(nu-fission / absorption)</td>\n",
" <td>1.663727</td>\n",
" <td>0.014403</td>\n",
" <td>1.663575</td>\n",
" <td>0.020557</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -958,7 +962,7 @@
"0 0.00e+00 6.25e-01 1 total (nu-fission / absorption) \n",
"\n",
" mean std. dev. \n",
"0 1.66e+00 1.44e-02 "
"0 1.66e+00 2.06e-02 "
]
},
"execution_count": 25,
@ -1020,8 +1024,8 @@
" <td>0.625</td>\n",
" <td>total</td>\n",
" <td>((absorption + current) / (absorption + current))</td>\n",
" <td>0.984668</td>\n",
" <td>0.005509</td>\n",
" <td>0.984639</td>\n",
" <td>0.00883</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -1032,7 +1036,7 @@
"0 0.00e+00 6.25e-01 total \n",
"\n",
" score mean std. dev. \n",
"0 ((absorption + current) / (absorption + current)) 9.85e-01 5.51e-03 "
"0 ((absorption + current) / (absorption + current)) 9.85e-01 8.83e-03 "
]
},
"execution_count": 26,
@ -1093,8 +1097,8 @@
" <td>0.625</td>\n",
" <td>total</td>\n",
" <td>(absorption / (absorption + current))</td>\n",
" <td>0.997439</td>\n",
" <td>0.007548</td>\n",
" <td>0.997372</td>\n",
" <td>0.011707</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -1105,7 +1109,7 @@
"0 0.00e+00 6.25e-01 total \n",
"\n",
" score mean std. dev. \n",
"0 (absorption / (absorption + current)) 9.97e-01 7.55e-03 "
"0 (absorption / (absorption + current)) 9.97e-01 1.17e-02 "
]
},
"execution_count": 27,
@ -1168,8 +1172,8 @@
" <td>1</td>\n",
" <td>total</td>\n",
" <td>(((((((absorption + current) / (absorption + c...</td>\n",
" <td>1.023002</td>\n",
" <td>0.018791</td>\n",
" <td>1.025847</td>\n",
" <td>0.028224</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -1180,7 +1184,7 @@
"0 0.00e+00 6.25e-01 1 total \n",
"\n",
" score mean std. dev. \n",
"0 (((((((absorption + current) / (absorption + c... 1.02e+00 1.88e-02 "
"0 (((((((absorption + current) / (absorption + c... 1.03e+00 2.82e-02 "
]
},
"execution_count": 28,
@ -1260,8 +1264,8 @@
" <td>6.250000e-01</td>\n",
" <td>(U238 / total)</td>\n",
" <td>(nu-fission / flux)</td>\n",
" <td>6.659486e-07</td>\n",
" <td>5.627975e-09</td>\n",
" <td>6.670761e-07</td>\n",
" <td>7.788171e-09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
@ -1270,8 +1274,8 @@
" <td>6.250000e-01</td>\n",
" <td>(U238 / total)</td>\n",
" <td>(scatter / flux)</td>\n",
" <td>2.099901e-01</td>\n",
" <td>1.748379e-03</td>\n",
" <td>2.099931e-01</td>\n",
" <td>2.336727e-03</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
@ -1280,8 +1284,8 @@
" <td>6.250000e-01</td>\n",
" <td>(U235 / total)</td>\n",
" <td>(nu-fission / flux)</td>\n",
" <td>3.566329e-01</td>\n",
" <td>3.030782e-03</td>\n",
" <td>3.571972e-01</td>\n",
" <td>4.203420e-03</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
@ -1290,8 +1294,8 @@
" <td>6.250000e-01</td>\n",
" <td>(U235 / total)</td>\n",
" <td>(scatter / flux)</td>\n",
" <td>5.555466e-03</td>\n",
" <td>4.635318e-05</td>\n",
" <td>5.555637e-03</td>\n",
" <td>6.200519e-05</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
@ -1300,8 +1304,8 @@
" <td>2.000000e+07</td>\n",
" <td>(U238 / total)</td>\n",
" <td>(nu-fission / flux)</td>\n",
" <td>7.251304e-03</td>\n",
" <td>5.161998e-05</td>\n",
" <td>7.269233e-03</td>\n",
" <td>6.814579e-05</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
@ -1310,8 +1314,8 @@
" <td>2.000000e+07</td>\n",
" <td>(U238 / total)</td>\n",
" <td>(scatter / flux)</td>\n",
" <td>2.272661e-01</td>\n",
" <td>9.576939e-04</td>\n",
" <td>2.276519e-01</td>\n",
" <td>7.674381e-04</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
@ -1320,8 +1324,8 @@
" <td>2.000000e+07</td>\n",
" <td>(U235 / total)</td>\n",
" <td>(nu-fission / flux)</td>\n",
" <td>7.920169e-03</td>\n",
" <td>5.751231e-05</td>\n",
" <td>8.069479e-03</td>\n",
" <td>5.324215e-05</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
@ -1330,8 +1334,8 @@
" <td>2.000000e+07</td>\n",
" <td>(U235 / total)</td>\n",
" <td>(scatter / flux)</td>\n",
" <td>3.358280e-03</td>\n",
" <td>1.341281e-05</td>\n",
" <td>3.363165e-03</td>\n",
" <td>1.147434e-05</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -1349,14 +1353,14 @@
"7 1 6.25e-01 2.00e+07 (U235 / total) \n",
"\n",
" score mean std. dev. \n",
"0 (nu-fission / flux) 6.66e-07 5.63e-09 \n",
"1 (scatter / flux) 2.10e-01 1.75e-03 \n",
"2 (nu-fission / flux) 3.57e-01 3.03e-03 \n",
"3 (scatter / flux) 5.56e-03 4.64e-05 \n",
"4 (nu-fission / flux) 7.25e-03 5.16e-05 \n",
"5 (scatter / flux) 2.27e-01 9.58e-04 \n",
"6 (nu-fission / flux) 7.92e-03 5.75e-05 \n",
"7 (scatter / flux) 3.36e-03 1.34e-05 "
"0 (nu-fission / flux) 6.67e-07 7.79e-09 \n",
"1 (scatter / flux) 2.10e-01 2.34e-03 \n",
"2 (nu-fission / flux) 3.57e-01 4.20e-03 \n",
"3 (scatter / flux) 5.56e-03 6.20e-05 \n",
"4 (nu-fission / flux) 7.27e-03 6.81e-05 \n",
"5 (scatter / flux) 2.28e-01 7.67e-04 \n",
"6 (nu-fission / flux) 8.07e-03 5.32e-05 \n",
"7 (scatter / flux) 3.36e-03 1.15e-05 "
]
},
"execution_count": 30,
@ -1385,11 +1389,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[[6.65948580e-07]\n",
" [3.56632881e-01]]\n",
"[[[6.67076123e-07]\n",
" [3.57197248e-01]]\n",
"\n",
" [[7.25130446e-03]\n",
" [7.92016892e-03]]]\n"
" [[7.26923324e-03]\n",
" [8.06947893e-03]]]\n"
]
}
],
@ -1415,9 +1419,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[[0.00555547]]\n",
"[[[0.00555564]]\n",
"\n",
" [[0.00335828]]]\n"
" [[0.00336316]]]\n"
]
}
],
@ -1437,8 +1441,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[[0.22726611]\n",
" [0.00335828]]]\n"
"[[[0.22765194]\n",
" [0.00336316]]]\n"
]
}
],
@ -1501,7 +1505,7 @@
" <td>U238</td>\n",
" <td>nu-fission</td>\n",
" <td>0.000002</td>\n",
" <td>9.679304e-09</td>\n",
" <td>1.382881e-08</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
@ -1510,8 +1514,8 @@
" <td>6.250000e-01</td>\n",
" <td>U235</td>\n",
" <td>nu-fission</td>\n",
" <td>0.854805</td>\n",
" <td>5.239673e-03</td>\n",
" <td>0.858278</td>\n",
" <td>7.512185e-03</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
@ -1520,8 +1524,8 @@
" <td>2.000000e+07</td>\n",
" <td>U238</td>\n",
" <td>nu-fission</td>\n",
" <td>0.082978</td>\n",
" <td>5.346135e-04</td>\n",
" <td>0.082753</td>\n",
" <td>7.469156e-04</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
@ -1530,8 +1534,8 @@
" <td>2.000000e+07</td>\n",
" <td>U235</td>\n",
" <td>nu-fission</td>\n",
" <td>0.090632</td>\n",
" <td>5.981942e-04</td>\n",
" <td>0.091863</td>\n",
" <td>5.596607e-04</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -1540,15 +1544,15 @@
"text/plain": [
" cell energy low [eV] energy high [eV] nuclide score mean \\\n",
"0 1 0.00e+00 6.25e-01 U238 nu-fission 1.60e-06 \n",
"1 1 0.00e+00 6.25e-01 U235 nu-fission 8.55e-01 \n",
"2 1 6.25e-01 2.00e+07 U238 nu-fission 8.30e-02 \n",
"3 1 6.25e-01 2.00e+07 U235 nu-fission 9.06e-02 \n",
"1 1 0.00e+00 6.25e-01 U235 nu-fission 8.58e-01 \n",
"2 1 6.25e-01 2.00e+07 U238 nu-fission 8.28e-02 \n",
"3 1 6.25e-01 2.00e+07 U235 nu-fission 9.19e-02 \n",
"\n",
" std. dev. \n",
"0 9.68e-09 \n",
"1 5.24e-03 \n",
"2 5.35e-04 \n",
"3 5.98e-04 "
"0 1.38e-08 \n",
"1 7.51e-03 \n",
"2 7.47e-04 \n",
"3 5.60e-04 "
]
},
"execution_count": 34,
@ -1605,8 +1609,8 @@
" <td>1.080060e-01</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>4.541188</td>\n",
" <td>0.025230</td>\n",
" <td>4.542677</td>\n",
" <td>0.037555</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
@ -1615,8 +1619,8 @@
" <td>1.166529e+00</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>2.001332</td>\n",
" <td>0.006754</td>\n",
" <td>2.019002</td>\n",
" <td>0.011992</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
@ -1625,8 +1629,8 @@
" <td>1.259921e+01</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>1.639292</td>\n",
" <td>0.011374</td>\n",
" <td>1.622688</td>\n",
" <td>0.011889</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
@ -1635,8 +1639,8 @@
" <td>1.360790e+02</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>1.821633</td>\n",
" <td>0.009590</td>\n",
" <td>1.834317</td>\n",
" <td>0.012322</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
@ -1645,8 +1649,8 @@
" <td>1.469734e+03</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>2.032395</td>\n",
" <td>0.009953</td>\n",
" <td>2.040064</td>\n",
" <td>0.012967</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
@ -1655,8 +1659,8 @@
" <td>1.587401e+04</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>2.120745</td>\n",
" <td>0.011090</td>\n",
" <td>2.107758</td>\n",
" <td>0.012781</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
@ -1665,8 +1669,8 @@
" <td>1.714488e+05</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>2.181709</td>\n",
" <td>0.013602</td>\n",
" <td>2.175480</td>\n",
" <td>0.014165</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
@ -1675,8 +1679,8 @@
" <td>1.851749e+06</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>2.013644</td>\n",
" <td>0.009219</td>\n",
" <td>1.983382</td>\n",
" <td>0.012931</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
@ -1685,8 +1689,8 @@
" <td>2.000000e+07</td>\n",
" <td>H1</td>\n",
" <td>scatter</td>\n",
" <td>0.372640</td>\n",
" <td>0.002903</td>\n",
" <td>0.372359</td>\n",
" <td>0.003689</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
@ -1695,25 +1699,25 @@
"text/plain": [
" cell energy low [eV] energy high [eV] nuclide score mean \\\n",
"0 3 1.00e-02 1.08e-01 H1 scatter 4.54e+00 \n",
"1 3 1.08e-01 1.17e+00 H1 scatter 2.00e+00 \n",
"2 3 1.17e+00 1.26e+01 H1 scatter 1.64e+00 \n",
"3 3 1.26e+01 1.36e+02 H1 scatter 1.82e+00 \n",
"4 3 1.36e+02 1.47e+03 H1 scatter 2.03e+00 \n",
"5 3 1.47e+03 1.59e+04 H1 scatter 2.12e+00 \n",
"1 3 1.08e-01 1.17e+00 H1 scatter 2.02e+00 \n",
"2 3 1.17e+00 1.26e+01 H1 scatter 1.62e+00 \n",
"3 3 1.26e+01 1.36e+02 H1 scatter 1.83e+00 \n",
"4 3 1.36e+02 1.47e+03 H1 scatter 2.04e+00 \n",
"5 3 1.47e+03 1.59e+04 H1 scatter 2.11e+00 \n",
"6 3 1.59e+04 1.71e+05 H1 scatter 2.18e+00 \n",
"7 3 1.71e+05 1.85e+06 H1 scatter 2.01e+00 \n",
"8 3 1.85e+06 2.00e+07 H1 scatter 3.73e-01 \n",
"7 3 1.71e+05 1.85e+06 H1 scatter 1.98e+00 \n",
"8 3 1.85e+06 2.00e+07 H1 scatter 3.72e-01 \n",
"\n",
" std. dev. \n",
"0 2.52e-02 \n",
"1 6.75e-03 \n",
"2 1.14e-02 \n",
"3 9.59e-03 \n",
"4 9.95e-03 \n",
"5 1.11e-02 \n",
"6 1.36e-02 \n",
"7 9.22e-03 \n",
"8 2.90e-03 "
"0 3.76e-02 \n",
"1 1.20e-02 \n",
"2 1.19e-02 \n",
"3 1.23e-02 \n",
"4 1.30e-02 \n",
"5 1.28e-02 \n",
"6 1.42e-02 \n",
"7 1.29e-02 \n",
"8 3.69e-03 "
]
},
"execution_count": 35,
@ -1728,6 +1732,16 @@
" filters=[openmc.CellFilter], filter_bins=[(moderator_cell.id,)])\n",
"slice_test.get_pandas_dataframe()"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
"# Close the statepoint file as a matter of best practice\n",
"sp.close()"
]
}
],
"metadata": {
@ -1746,7 +1760,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.7.3"
}
},
"nbformat": 4,

View file

@ -231,7 +231,7 @@ public:
RegularMesh() = default;
RegularMesh(pugi::xml_node node);
// Overriden methods
// Overridden methods
void
surface_bins_crossed(Position r0,
Position r1,
@ -272,7 +272,7 @@ public:
RectilinearMesh() = default;
RectilinearMesh(pugi::xml_node node);
// Overriden methods
// Overridden methods
void
surface_bins_crossed(Position r0,
Position r1,
@ -304,6 +304,17 @@ public:
UnstructuredMesh(pugi::xml_node node);
UnstructuredMesh(const std::string& filename);
// Overridden Methods
void
surface_bins_crossed(Position r0,
Position r1,
const Direction& u,
vector<int>& bins) const override;
void to_hdf5(hid_t group) const override;
std::string bin_label(int bin) const override;
// Methods
//! Add a variable to the mesh instance
@ -337,14 +348,6 @@ public:
//! Get the library used for this unstructured mesh
virtual std::string library() const = 0;
std::string bin_label(int bin) const override;
void surface_bins_crossed(Position r0,
Position r1,
vector<int>& bins) const;
void to_hdf5(hid_t group) const override;
// Data members
bool output_ {true}; //!< Write tallies onto the unstructured mesh at the end of a run
std::string filename_; //!< Path to unstructured mesh file
@ -363,39 +366,42 @@ public:
MOABMesh() = default;
MOABMesh(pugi::xml_node);
MOABMesh(const std::string& filename);
MOABMesh(std::shared_ptr<moab::Interface> external_mbi);
void bins_crossed(Position r0,
Position r1,
const Direction& u,
vector<int>& bins,
vector<double>& lengths) const override;
// Overridden Methods
void surface_bins_crossed(Position r0, Position r1, const Direction& u,
vector<int>& bins) const override;
void
bins_crossed(Position r0,
Position r1,
const Direction& u,
vector<int>& bins,
vector<double>& lengths) const override;
int get_bin(Position r) const;
int get_bin(Position r) const override;
int n_bins() const override;
int n_surface_bins() const override;
std::pair<vector<double>, vector<double>> plot(
Position plot_ll, Position plot_ur) const override;
std::pair<vector<double>, vector<double>>
plot(Position plot_ll,
Position plot_ur) const override;
std::string library() const override;
//! Add a score to the mesh instance
void add_score(const std::string& score) override;
//! Remove a score from the mesh instance
//! Remove all scores from the mesh instance
void remove_scores() override;
//! Set data for a score
void set_score_data(const std::string& score, const vector<double>& values,
const vector<double>& std_dev) override;
void set_score_data(const std::string& score,
const vector<double>& values,
const vector<double>& std_dev) override;
//! Write the mesh with any current tally data
void write(const std::string& base_filename) const;
void write(const std::string& base_filename) const override;
Position centroid(int bin) const override;
@ -405,6 +411,11 @@ private:
void initialize() override;
// Methods
//! Create the MOAB interface pointer
void create_interface();
//! Find all intersections with faces of the mesh.
//
//! \param[in] start Staring location
@ -496,7 +507,7 @@ private:
moab::Range ehs_; //!< Range of tetrahedra EntityHandle's in the mesh
moab::EntityHandle tetset_; //!< EntitySet containing all tetrahedra
moab::EntityHandle kdtree_root_; //!< Root of the MOAB KDTree
unique_ptr<moab::Interface> mbi_; //!< MOAB instance
std::shared_ptr<moab::Interface> mbi_; //!< MOAB instance
unique_ptr<moab::AdaptiveKDTree> kdtree_; //!< MOAB KDTree instance
vector<moab::Matrix3> baryc_data_; //!< Barycentric data for tetrahedra
vector<std::string> tag_names_; //!< Names of score tags added to the mesh
@ -512,31 +523,32 @@ public:
LibMesh(pugi::xml_node node);
LibMesh(const std::string& filename);
// Methods
// Overridden Methods
void bins_crossed(Position r0,
Position r1,
const Direction& u,
vector<int>& bins,
vector<double>& lengths) const override;
void surface_bins_crossed(Position r0, Position r1, const Direction& u,
vector<int>& bins) const override;
int get_bin(Position r) const override;
int n_bins() const override;
int n_surface_bins() const override;
std::pair<vector<double>, vector<double>> plot(
Position plot_ll, Position plot_ur) const override;
std::pair<vector<double>, vector<double>>
plot(Position plot_ll,
Position plot_ur) const override;
std::string library() const override;
void add_score(const std::string& var_name) override;
void remove_scores() override;
void set_score_data(const std::string& var_name, const vector<double>& values,
const vector<double>& std_dev) override;
void set_score_data(const std::string& var_name,
const vector<double>& values,
const vector<double>& std_dev) override;
void write(const std::string& base_filename) const override;
@ -544,12 +556,12 @@ public:
double volume(int bin) const override;
std::string library() const override;
private:
void initialize() override;
// Methods
//! Translate a bin value to an element reference
const libMesh::Elem& get_element_from_bin(int bin) const;
@ -567,6 +579,7 @@ private:
libMesh::BoundingBox bbox_; //!< bounding box of the mesh
libMesh::dof_id_type first_element_id_; //!< id of the first element in the mesh
};
#endif
//==============================================================================

View file

@ -53,6 +53,9 @@ public:
void set_filters(gsl::span<Filter*> filters);
//! Given already-set filters, set the stride lengths
void set_strides();
int32_t strides(int i) const {return strides_[i];}
int32_t n_filter_bins() const {return n_filter_bins_;}

View file

@ -12,6 +12,7 @@ from collections import OrderedDict
import os
import xml.etree.ElementTree as ET
from warnings import warn
from pathlib import Path
import numpy as np
from uncertainties import ufloat
@ -610,6 +611,14 @@ class Operator(TransportOperator):
for mat in materials:
mat._nuclides.sort(key=lambda x: nuclides.index(x[0]))
# Grab the cross sections tag from the existing file
mfile = Path("materials.xml")
if mfile.exists():
tree = ET.parse(str(mfile))
xs = tree.find('cross_sections')
if xs is not None:
materials.cross_sections = xs.text
materials.export_to_xml()
def _get_tally_nuclides(self):

View file

@ -993,6 +993,8 @@ class MeshSurfaceFilter(MeshFilter):
class CollisionFilter(Filter):
"""Bins tally events based on the number of collisions.
.. versionadded:: 0.12.2
Parameters
----------
bins : Iterable of int

View file

@ -521,6 +521,19 @@ class Material(IDManagerMixin):
if element is None:
msg = 'Element name "{}" not recognised'.format(el)
raise ValueError(msg)
else:
if element[0].islower():
msg = 'Element name "{}" should start with an uppercase ' \
'letter'.format(element)
raise ValueError(msg)
if len(element) == 2 and element[1].isupper():
msg = 'Element name "{}" should end with a lowercase ' \
'letter'.format(element)
raise ValueError(msg)
# skips the first entry of ATOMIC_SYMBOL which is n for neutron
if element not in list(openmc.data.ATOMIC_SYMBOL.values())[1:]:
msg = 'Element name "{}" not recognised'.format(element)
raise ValueError(msg)
if self._macroscopic is not None:
msg = 'Unable to add an Element to Material ID="{}" as a ' \

View file

@ -605,6 +605,9 @@ class UnstructuredMesh(MeshBase):
.. versionadded:: 0.12
.. versionchanged:: 0.12.2
Support for libMesh unstructured meshes was added.
Parameters
----------
filename : str

View file

@ -153,9 +153,7 @@ class StatePoint:
return self
def __exit__(self, *exc):
self._f.close()
if self._summary is not None:
self._summary._f.close()
self.close()
@property
def cmfd_on(self):
@ -490,6 +488,14 @@ class StatePoint:
for tally_id in self.tallies:
self.tallies[tally_id].sparse = self.sparse
def close(self):
"""Close the statepoint HDF5 file and the corresponding
summary HDF5 file if present.
"""
self._f.close()
if self._summary is not None:
self._summary._f.close()
def add_volume_information(self, volume_calc):
"""Add volume information to the geometry within the file

View file

@ -160,7 +160,6 @@ StructuredMesh::bin_label(int bin) const {
//==============================================================================
UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) {
n_dimension_ = 3;
// check the mesh type
if (check_for_node(node, "type")) {
@ -192,6 +191,7 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) {
void
UnstructuredMesh::surface_bins_crossed(Position r0,
Position r1,
const Direction& u,
vector<int>& bins) const {
fatal_error("Unstructured mesh surface tallies are not implemented.");
}
@ -1581,14 +1581,22 @@ MOABMesh::MOABMesh(const std::string& filename) {
initialize();
}
MOABMesh::MOABMesh(std::shared_ptr<moab::Interface> external_mbi) {
mbi_ = external_mbi;
filename_ = "unknown (external file)";
this->initialize();
}
void MOABMesh::initialize() {
// create MOAB instance
mbi_ = make_unique<moab::Core>();
// load unstructured mesh file
moab::ErrorCode rval = mbi_->load_file(filename_.c_str());
if (rval != moab::MB_SUCCESS) {
fatal_error("Failed to load the unstructured mesh file: " + filename_);
}
// Create the MOAB interface and load data from file
this->create_interface();
// Initialise MOAB error code
moab::ErrorCode rval = moab::MB_SUCCESS;
// Set the dimension
n_dimension_ = 3;
// set member range of tetrahedral entities
rval = mbi_->get_entities_by_dimension(0, n_dimension_, ehs_);
@ -1618,6 +1626,22 @@ void MOABMesh::initialize() {
build_kdtree(ehs_);
}
void
MOABMesh::create_interface()
{
// Do not create a MOAB instance if one is already in memory
if (mbi_) return;
// create MOAB instance
mbi_ = std::make_shared<moab::Core>();
// load unstructured mesh file
moab::ErrorCode rval = mbi_->load_file(filename_.c_str());
if (rval != moab::MB_SUCCESS) {
fatal_error("Failed to load the unstructured mesh file: " + filename_);
}
}
void
MOABMesh::build_kdtree(const moab::Range& all_tets)
{
@ -1813,14 +1837,6 @@ double MOABMesh::tet_volume(moab::EntityHandle tet) const
return 1.0 / 6.0 * (((p[1] - p[0]) * (p[2] - p[0])) % (p[3] - p[0]));
}
void MOABMesh::surface_bins_crossed(
Position r0, Position r1, const Direction& u, vector<int>& bins) const
{
// TODO: Implement triangle crossings here
throw std::runtime_error{"Unstructured mesh surface tallies are not implemented."};
}
int MOABMesh::get_bin(Position r) const
{
moab::EntityHandle tet = get_tet(r);
@ -2081,7 +2097,8 @@ void MOABMesh::remove_scores()
}
void MOABMesh::set_score_data(const std::string& score,
const vector<double>& values, const vector<double>& std_dev)
const vector<double>& values,
const vector<double>& std_dev)
{
auto score_tags = this->get_score_tags(score);
@ -2198,13 +2215,6 @@ int LibMesh::n_bins() const
return m_->n_elem();
}
void LibMesh::surface_bins_crossed(
Position r0, Position r1, const Direction& u, vector<int>& bins) const
{
// TODO: Implement triangle crossings here
throw std::runtime_error{"Unstructured mesh surface tallies are not implemented."};
}
int
LibMesh::n_surface_bins() const {
int n_bins = 0;

View file

@ -366,9 +366,18 @@ Tally::set_filters(gsl::span<Filter*> filters)
}
}
// Set the strides.
set_strides();
}
void
Tally::set_strides()
{
// Set the strides. Filters are traversed in reverse so that the last filter
// has the shortest stride in memory and the first filter has the longest
// stride.
auto n = filters_.size();
strides_.resize(n, 0);
int stride = 1;
for (int i = n-1; i >= 0; --i) {
@ -507,8 +516,11 @@ void Tally::set_scores(const vector<std::string>& scores)
if (type_ == TallyType::SURFACE || type_ == TallyType::MESH_SURFACE) {
if (scores_.size() != 1)
fatal_error("Cannot tally other scores in the same tally as surface "
"currents");
"currents.");
}
if ((surface_present || meshsurface_present) && scores_[0] != SCORE_CURRENT)
fatal_error("Cannot tally score other than 'current' when using a surface "
"or mesh-surface filter.");
}
void

View file

@ -0,0 +1,73 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="1" material="1" name="fuel" region="1 -2 3 -4 5 -6" universe="1" />
<cell id="2" material="2" name="clad" region="(-1 | 2 | -3 | 4 | -5 | 6) (7 -8 9 -10 11 -12)" universe="1" />
<cell id="3" material="3" name="water" region="(-7 | 8 | -9 | 10 | -11 | 12) (13 -14 15 -16 17 -18)" universe="1" />
<surface coeffs="-5.0" id="1" name="minimum x" type="x-plane" />
<surface coeffs="5.0" id="2" name="maximum x" type="x-plane" />
<surface coeffs="-5.0" id="3" name="minimum y" type="y-plane" />
<surface coeffs="5.0" id="4" name="maximum y" type="y-plane" />
<surface coeffs="-5.0" id="5" name="minimum z" type="z-plane" />
<surface coeffs="5.0" id="6" name="maximum z" type="z-plane" />
<surface coeffs="-6.0" id="7" name="minimum x" type="x-plane" />
<surface coeffs="6.0" id="8" name="maximum x" type="x-plane" />
<surface coeffs="-6.0" id="9" name="minimum y" type="y-plane" />
<surface coeffs="6.0" id="10" name="maximum y" type="y-plane" />
<surface coeffs="-6.0" id="11" name="minimum z" type="z-plane" />
<surface coeffs="6.0" id="12" name="maximum z" type="z-plane" />
<surface boundary="vacuum" coeffs="-10" id="13" name="minimum x" type="x-plane" />
<surface boundary="vacuum" coeffs="10" id="14" name="maximum x" type="x-plane" />
<surface boundary="vacuum" coeffs="-10" id="15" name="minimum y" type="y-plane" />
<surface boundary="vacuum" coeffs="10" id="16" name="maximum y" type="y-plane" />
<surface boundary="vacuum" coeffs="-10" id="17" name="minimum z" type="z-plane" />
<surface boundary="vacuum" coeffs="10" id="18" name="maximum z" type="z-plane" />
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material depletable="true" id="1" name="fuel">
<density units="g/cc" value="4.5" />
<nuclide ao="1.0" name="U235" />
</material>
<material id="2" name="zircaloy">
<density units="g/cc" value="5.77" />
<nuclide ao="0.5145" name="Zr90" />
<nuclide ao="0.1122" name="Zr91" />
<nuclide ao="0.1715" name="Zr92" />
<nuclide ao="0.1738" name="Zr94" />
<nuclide ao="0.028" name="Zr96" />
</material>
<material id="3" name="water">
<density units="atom/b-cm" value="0.07416" />
<nuclide ao="2.0" name="H1" />
<nuclide ao="1.0" name="O16" />
</material>
</materials>
<?xml version='1.0' encoding='utf-8'?>
<settings>
<run_mode>fixed source</run_mode>
<particles>100</particles>
<batches>10</batches>
<source strength="1.0">
<space type="point">
<parameters>0.0 0.0 0.0</parameters>
</space>
<angle reference_uvw="-1.0 0.0 0.0" type="monodirectional" />
<energy type="discrete">
<parameters>15000000.0 1.0</parameters>
</energy>
</source>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<tallies>
<mesh id="1" library="moab" type="unstructured">
<filename>test_mesh_tets.h5m</filename>
</mesh>
<filter id="1" type="mesh">
<bins>1</bins>
</filter>
<tally id="1" name="unstructured mesh tally">
<filters>1</filters>
<scores>flux</scores>
<estimator>tracklength</estimator>
</tally>
</tallies>

View file

@ -0,0 +1,98 @@
#include "moab/Core.hpp"
#include "openmc/capi.h"
#include "openmc/error.h"
#include "openmc/mesh.h"
#include "openmc/tallies/filter_mesh.h"
#include "openmc/tallies/tally.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace openmc;
int openmc_err;
// Initialise OpenMC
openmc_err = openmc_init(argc, argv, nullptr);
if (openmc_err == -1) {
// This happens for the -h and -v flags
return EXIT_SUCCESS;
} else if (openmc_err) {
fatal_error(openmc_err_msg);
}
// Create MOAB interface
std::shared_ptr<moab::Interface> moabPtrLocal =
std::make_shared<moab::Core>();
// Load unstructured mesh file
std::string filename = "test_mesh_tets.h5m";
moab::ErrorCode rval = moabPtrLocal->load_file(filename.c_str());
if (rval != moab::MB_SUCCESS) {
fatal_error("Failed to load the unstructured mesh file: " + filename);
} else {
std::cout << "Loaded external MOAB mesh from file " << filename
<< std::endl;
}
// Add a new unstructured mesh to openmc using new constructor
model::meshes.push_back(std::make_unique<MOABMesh>(moabPtrLocal));
// Check we now have 2 copies of the shared ptr
if (moabPtrLocal.use_count() != 2) {
fatal_error("Incorrect number of MOAB shared pointers");
}
// Auto-assign mesh ID
model::meshes.back()->set_id(C_NONE);
int mesh_id = model::meshes.back()->id_;
// Check we now have 2 meshes and id was correctly set
if (model::meshes.size() != 2)
fatal_error("Wrong number of meshes.");
else if (mesh_id != 2)
fatal_error("Mesh ID is incorrect");
// Add a new mesh filter with auto-assigned ID
Filter* filter_ptr = Filter::create("mesh", C_NONE);
// Upcast pointer type
MeshFilter* mesh_filter = dynamic_cast<MeshFilter*>(filter_ptr);
if (!mesh_filter) {
fatal_error("Failed to create mesh filter");
}
// Pass in the index of our mesh to the filter
int32_t mesh_idx = model::meshes.size() - 1;
mesh_filter->set_mesh(mesh_idx);
// Create a tally with auto-assigned ID
model::tallies.push_back(make_unique<Tally>(C_NONE));
// Set tally name - matches that in test.py
model::tallies.back()->name_ = "external mesh tally";
// Set tally filter to our mesh filter
std::vector<Filter*> filters(1, filter_ptr);
model::tallies.back()->set_filters(filters);
// Set tally estimator
model::tallies.back()->estimator_ = TallyEstimator::TRACKLENGTH;
// Set tally score
std::vector<std::string> score_names(1, "flux");
model::tallies.back()->set_scores(score_names);
// Run OpenMC
openmc_err = openmc_run();
if (openmc_err)
fatal_error(openmc_err_msg);
// Deallocate memory
openmc_err = openmc_finalize();
if (openmc_err)
fatal_error(openmc_err_msg);
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,275 @@
from pathlib import Path
import os
import shutil
import subprocess
from subprocess import CalledProcessError
import textwrap
import glob
from itertools import product
import openmc
import openmc.lib
import numpy as np
import pytest
from tests.regression_tests import config
from tests.testing_harness import PyAPITestHarness
pytestmark = pytest.mark.skipif(
not openmc.lib._dagmc_enabled(),
reason="DAGMC is not enabled.")
TETS_PER_VOXEL = 12
# Test that an external moab instance can be passed in through the C API
@pytest.fixture
def cpp_driver(request):
"""Compile the external source"""
# Get build directory and write CMakeLists.txt file
openmc_dir = Path(str(request.config.rootdir)) / 'build'
with open('CMakeLists.txt', 'w') as f:
f.write(textwrap.dedent("""
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(openmc_cpp_driver CXX)
add_executable(main main.cpp)
find_package(OpenMC REQUIRED HINTS {})
target_link_libraries(main OpenMC::libopenmc)
set_target_properties(main PROPERTIES CXX_STANDARD
14 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO)
set(CMAKE_CXX_FLAGS "-pedantic-errors")
add_compile_definitions(DAGMC=1)
""".format(openmc_dir)))
# Create temporary build directory and change to there
local_builddir = Path('build')
local_builddir.mkdir(exist_ok=True)
os.chdir(str(local_builddir))
if config['mpi']:
os.environ['CXX'] = 'mpicxx'
try:
print("Building driver")
# Run cmake/make to build the shared libary
subprocess.run(['cmake', os.path.pardir], check=True)
subprocess.run(['make'], check=True)
os.chdir(os.path.pardir)
yield "./build/main"
finally:
# Remove local build directory when test is complete
shutil.rmtree('build')
os.remove('CMakeLists.txt')
class ExternalMoabTest(PyAPITestHarness):
def __init__(self, executable, statepoint_name, model):
super().__init__(statepoint_name, model)
self.executable = executable
def _run_openmc(self):
if config['mpi']:
mpi_args = [config['mpiexec'], '-n', config['mpi_np']]
openmc.run(openmc_exec=self.executable,
mpi_args=mpi_args,
event_based=config['event'])
else:
openmc.run(openmc_exec=self.executable,
event_based=config['event'])
# Override some methods to do nothing
def _get_results(self):
pass
def _write_results(self, results_string):
pass
def _overwrite_results(self):
pass
def _test_output_created(self):
pass
# Directly compare results of unstructured mesh with internal and
# external moab
def _compare_results(self):
with openmc.StatePoint(self._sp_name) as sp:
# loop over the tallies and get data
ext_data = []
unstr_data = []
for tally in sp.tallies.values():
# Safety check that mesh filter is correct
if tally.contains_filter(openmc.MeshFilter):
flt = tally.find_filter(openmc.MeshFilter)
if isinstance(flt.mesh, openmc.UnstructuredMesh):
if tally.name == "external mesh tally":
ext_data = tally.get_reshaped_data(value='mean')
elif tally.name == "unstructured mesh tally":
unstr_data = tally.get_reshaped_data(value='mean')
# we expect these results to be the same to within at 8
# decimal places
decimals = 8
np.testing.assert_array_almost_equal(unstr_data,
ext_data, decimals)
@staticmethod
def get_mesh_tally_data(tally):
data = tally.get_reshaped_data(value='mean')
std_dev = tally.get_reshaped_data(value='std_dev')
data.shape = (data.size, 1)
std_dev.shape = (std_dev.size, 1)
return np.sum(data, axis=1), np.sum(std_dev, axis=1)
def _cleanup(self):
super()._cleanup()
output = glob.glob('tally*.vtk')
for f in output:
if os.path.exists(f):
os.remove(f)
def test_external_mesh(cpp_driver):
# Materials
materials = openmc.Materials()
fuel_mat = openmc.Material(name="fuel")
fuel_mat.add_nuclide("U235", 1.0)
fuel_mat.set_density('g/cc', 4.5)
materials.append(fuel_mat)
zirc_mat = openmc.Material(name="zircaloy")
zirc_mat.add_element("Zr", 1.0)
zirc_mat.set_density("g/cc", 5.77)
materials.append(zirc_mat)
water_mat = openmc.Material(name="water")
water_mat.add_nuclide("H1", 2.0)
water_mat.add_nuclide("O16", 1.0)
water_mat.set_density("atom/b-cm", 0.07416)
materials.append(water_mat)
materials.export_to_xml()
# Geometry
fuel_min_x = openmc.XPlane(-5.0, name="minimum x")
fuel_max_x = openmc.XPlane(5.0, name="maximum x")
fuel_min_y = openmc.YPlane(-5.0, name="minimum y")
fuel_max_y = openmc.YPlane(5.0, name="maximum y")
fuel_min_z = openmc.ZPlane(-5.0, name="minimum z")
fuel_max_z = openmc.ZPlane(5.0, name="maximum z")
fuel_cell = openmc.Cell(name="fuel")
fuel_cell.region = +fuel_min_x & -fuel_max_x & \
+fuel_min_y & -fuel_max_y & \
+fuel_min_z & -fuel_max_z
fuel_cell.fill = fuel_mat
clad_min_x = openmc.XPlane(-6.0, name="minimum x")
clad_max_x = openmc.XPlane(6.0, name="maximum x")
clad_min_y = openmc.YPlane(-6.0, name="minimum y")
clad_max_y = openmc.YPlane(6.0, name="maximum y")
clad_min_z = openmc.ZPlane(-6.0, name="minimum z")
clad_max_z = openmc.ZPlane(6.0, name="maximum z")
clad_cell = openmc.Cell(name="clad")
clad_cell.region = (-fuel_min_x | +fuel_max_x |
-fuel_min_y | +fuel_max_y |
-fuel_min_z | +fuel_max_z) & \
(+clad_min_x & -clad_max_x &
+clad_min_y & -clad_max_y &
+clad_min_z & -clad_max_z)
clad_cell.fill = zirc_mat
bounds = (10, 10, 10)
water_min_x = openmc.XPlane(x0=-bounds[0],
name="minimum x",
boundary_type='vacuum')
water_max_x = openmc.XPlane(x0=bounds[0],
name="maximum x",
boundary_type='vacuum')
water_min_y = openmc.YPlane(y0=-bounds[1],
name="minimum y",
boundary_type='vacuum')
water_max_y = openmc.YPlane(y0=bounds[1],
name="maximum y",
boundary_type='vacuum')
water_min_z = openmc.ZPlane(z0=-bounds[2],
name="minimum z",
boundary_type='vacuum')
water_max_z = openmc.ZPlane(z0=bounds[2],
name="maximum z",
boundary_type='vacuum')
water_cell = openmc.Cell(name="water")
water_cell.region = (-clad_min_x | +clad_max_x |
-clad_min_y | +clad_max_y |
-clad_min_z | +clad_max_z) & \
(+water_min_x & -water_max_x &
+water_min_y & -water_max_y &
+water_min_z & -water_max_z)
water_cell.fill = water_mat
# create a containing universe
geometry = openmc.Geometry([fuel_cell, clad_cell, water_cell])
# Meshes
mesh_filename = "test_mesh_tets.h5m"
# Create a normal unstructured mesh to compare to
uscd_mesh = openmc.UnstructuredMesh(mesh_filename, 'moab')
# Create filters
uscd_filter = openmc.MeshFilter(mesh=uscd_mesh)
# Tallies
tallies = openmc.Tallies()
uscd_tally = openmc.Tally(name="unstructured mesh tally")
uscd_tally.filters = [uscd_filter]
uscd_tally.scores = ['flux']
uscd_tally.estimator = 'tracklength'
tallies.append(uscd_tally)
# Settings
settings = openmc.Settings()
settings.run_mode = 'fixed source'
settings.particles = 100
settings.batches = 10
# Source setup
space = openmc.stats.Point()
angle = openmc.stats.Monodirectional((-1.0, 0.0, 0.0))
energy = openmc.stats.Discrete(x=[15.e+06], p=[1.0])
source = openmc.Source(space=space, energy=energy, angle=angle)
settings.source = source
model = openmc.model.Model(geometry=geometry,
materials=materials,
tallies=tallies,
settings=settings)
harness = ExternalMoabTest(cpp_driver,
'statepoint.10.h5',
model)
# Run open MC and check results
harness.main()

View file

@ -54,6 +54,15 @@ def test_elements():
m.add_element('U', 1.0, enrichment=70.0, enrichment_target='U235')
with pytest.raises(ValueError):
m.add_element('He', 1.0, enrichment=17.0, enrichment_target='He6')
with pytest.raises(ValueError):
m.add_element('li', 1.0) # should fail as 1st char is lowercase
with pytest.raises(ValueError):
m.add_element('LI', 1.0) # should fail as 2nd char is uppercase
with pytest.raises(ValueError):
m.add_element('Xx', 1.0) # should fail as Xx is not an element
with pytest.raises(ValueError):
m.add_element('n', 1.0) # check to avoid n for neutron being accepted
def test_elements_by_name():
"""Test adding elements by name"""