From 642afb5adbbf061f6c103bdfa1f694bdfe0c81a3 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 5 Oct 2020 13:51:44 +0100 Subject: [PATCH 01/23] added git actions workflow file --- github/workflows/dockerhub-publish-dev.yml | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 github/workflows/dockerhub-publish-dev.yml diff --git a/github/workflows/dockerhub-publish-dev.yml b/github/workflows/dockerhub-publish-dev.yml new file mode 100644 index 000000000..f025e2ab2 --- /dev/null +++ b/github/workflows/dockerhub-publish-dev.yml @@ -0,0 +1,32 @@ +name: dockerhub-publish + +on: + push: + branches: develop + +jobs: + main: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: openmc/openmc:dev + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} From 7228bba307a8a48810019f07270622d314de8fdc Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 14 Oct 2020 07:57:52 -0500 Subject: [PATCH 02/23] Use nbsphinx for rendering Jupyter notebooks in documentation --- docs/requirements-rtd.txt | 1 + docs/source/conf.py | 26 ++-- docs/source/examples/cad-geom.rst | 13 -- docs/source/examples/candu.rst | 13 -- docs/source/examples/expansion-filters.rst | 13 -- docs/source/examples/hexagonal.rst | 13 -- docs/source/examples/index.rst | 18 +-- docs/source/examples/mdgxs-part-i.rst | 13 -- docs/source/examples/mdgxs-part-ii.rst | 13 -- docs/source/examples/mg-mode-part-i.rst | 13 -- docs/source/examples/mg-mode-part-ii.rst | 13 -- docs/source/examples/mg-mode-part-iii.rst | 13 -- docs/source/examples/mgxs-part-i.rst | 13 -- docs/source/examples/mgxs-part-ii.rst | 13 -- docs/source/examples/mgxs-part-iii.rst | 13 -- .../nuclear-data-resonance-covariance.rst | 13 -- docs/source/examples/nuclear-data.rst | 13 -- docs/source/examples/pandas-dataframes.rst | 13 -- docs/source/examples/pincell-depletion.rst | 14 --- docs/source/examples/pincell.rst | 13 -- docs/source/examples/post-processing.rst | 13 -- docs/source/examples/search.rst | 13 -- docs/source/examples/tally-arithmetic.rst | 11 -- docs/source/examples/triso.rst | 13 -- .../examples/unstructured-mesh-part-i.rst | 13 -- .../examples/unstructured-mesh-part-ii.rst | 13 -- docs/sphinxext/LICENSE | 68 ---------- docs/sphinxext/notebook_sphinxext.py | 117 ------------------ examples/jupyter/cad-based-geometry.ipynb | 10 +- examples/jupyter/candu.ipynb | 3 +- examples/jupyter/expansion-filters.ipynb | 3 +- examples/jupyter/hexagonal-lattice.ipynb | 3 +- examples/jupyter/mdgxs-part-i.ipynb | 3 +- examples/jupyter/mdgxs-part-ii.ipynb | 5 +- examples/jupyter/mg-mode-part-i.ipynb | 9 +- examples/jupyter/mg-mode-part-ii.ipynb | 21 ++-- examples/jupyter/mg-mode-part-iii.ipynb | 19 +-- examples/jupyter/mgxs-part-i.ipynb | 3 +- examples/jupyter/mgxs-part-ii.ipynb | 3 +- examples/jupyter/mgxs-part-iii.ipynb | 3 +- .../nuclear-data-resonance-covariance.ipynb | 3 +- examples/jupyter/nuclear-data.ipynb | 3 +- examples/jupyter/pandas-dataframes.ipynb | 3 +- examples/jupyter/pincell.ipynb | 3 +- examples/jupyter/pincell_depletion.ipynb | 15 +-- examples/jupyter/post-processing.ipynb | 3 +- examples/jupyter/search.ipynb | 9 +- examples/jupyter/tally-arithmetic.ipynb | 3 +- examples/jupyter/triso.ipynb | 3 +- .../jupyter/unstructured-mesh-part-i.ipynb | 4 +- .../jupyter/unstructured-mesh-part-ii.ipynb | 4 +- setup.py | 3 +- 52 files changed, 101 insertions(+), 568 deletions(-) delete mode 100644 docs/source/examples/cad-geom.rst delete mode 100644 docs/source/examples/candu.rst delete mode 100644 docs/source/examples/expansion-filters.rst delete mode 100644 docs/source/examples/hexagonal.rst delete mode 100644 docs/source/examples/mdgxs-part-i.rst delete mode 100644 docs/source/examples/mdgxs-part-ii.rst delete mode 100644 docs/source/examples/mg-mode-part-i.rst delete mode 100644 docs/source/examples/mg-mode-part-ii.rst delete mode 100644 docs/source/examples/mg-mode-part-iii.rst delete mode 100644 docs/source/examples/mgxs-part-i.rst delete mode 100644 docs/source/examples/mgxs-part-ii.rst delete mode 100644 docs/source/examples/mgxs-part-iii.rst delete mode 100644 docs/source/examples/nuclear-data-resonance-covariance.rst delete mode 100644 docs/source/examples/nuclear-data.rst delete mode 100644 docs/source/examples/pandas-dataframes.rst delete mode 100644 docs/source/examples/pincell-depletion.rst delete mode 100644 docs/source/examples/pincell.rst delete mode 100644 docs/source/examples/post-processing.rst delete mode 100644 docs/source/examples/search.rst delete mode 100644 docs/source/examples/tally-arithmetic.rst delete mode 100644 docs/source/examples/triso.rst delete mode 100644 docs/source/examples/unstructured-mesh-part-i.rst delete mode 100644 docs/source/examples/unstructured-mesh-part-ii.rst delete mode 100644 docs/sphinxext/LICENSE delete mode 100644 docs/sphinxext/notebook_sphinxext.py diff --git a/docs/requirements-rtd.txt b/docs/requirements-rtd.txt index 7801c670f..776bbc24d 100644 --- a/docs/requirements-rtd.txt +++ b/docs/requirements-rtd.txt @@ -2,3 +2,4 @@ sphinx-numfig jupyter sphinxcontrib-katex sphinxcontrib-svg2pdfconverter +nbsphinx diff --git a/docs/source/conf.py b/docs/source/conf.py index 2410a887d..5ea2ec8ae 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -20,13 +20,12 @@ on_rtd = os.environ.get('READTHEDOCS', None) == 'True' # ImportErrors when building documentation from unittest.mock import MagicMock - MOCK_MODULES = [ 'numpy', 'numpy.polynomial', 'numpy.polynomial.polynomial', 'numpy.ctypeslib', 'scipy', 'scipy.sparse', 'scipy.sparse.linalg', - 'scipy.interpolate', 'scipy.integrate', 'scipy.optimize', 'scipy.special', - 'scipy.stats', 'scipy.spatial', 'h5py', 'pandas', 'uncertainties', - 'matplotlib', 'matplotlib.pyplot', 'openmoc', + 'scipy.interpolate', 'scipy.integrate', 'scipy.optimize', 'scipy.signal', + 'scipy.special', 'scipy.stats', 'scipy.spatial', 'h5py', 'pandas', + 'uncertainties', 'matplotlib', 'matplotlib.pyplot', 'openmoc', 'openmc.data.reconstruct', 'openmc.checkvalue' ] sys.modules.update((mod_name, MagicMock()) for mod_name in MOCK_MODULES) @@ -39,7 +38,6 @@ np.polynomial.Polynomial = MagicMock # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('../sphinxext')) sys.path.insert(0, os.path.abspath('../..')) @@ -47,14 +45,16 @@ sys.path.insert(0, os.path.abspath('../..')) # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', - 'sphinx.ext.napoleon', - 'sphinx.ext.autosummary', - 'sphinx.ext.intersphinx', - 'sphinx.ext.viewcode', - 'sphinxcontrib.katex', - 'sphinx_numfig', - 'notebook_sphinxext'] +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.napoleon', + 'sphinx.ext.autosummary', + 'sphinx.ext.intersphinx', + 'sphinx.ext.viewcode', + 'sphinxcontrib.katex', + 'sphinx_numfig', + 'nbsphinx' +] if not on_rtd: extensions.append('sphinxcontrib.rsvgconverter') diff --git a/docs/source/examples/cad-geom.rst b/docs/source/examples/cad-geom.rst deleted file mode 100644 index c5251c7ca..000000000 --- a/docs/source/examples/cad-geom.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_cad-geom: - -========================== -Using CAD-Based Geometries -========================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/cad-based-geometry.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/candu.rst b/docs/source/examples/candu.rst deleted file mode 100644 index 463a3c76e..000000000 --- a/docs/source/examples/candu.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_candu: - -======================= -Modeling a CANDU Bundle -======================= - -.. only:: html - - .. notebook:: ../../../examples/jupyter/candu.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/expansion-filters.rst b/docs/source/examples/expansion-filters.rst deleted file mode 100644 index f06d2bde6..000000000 --- a/docs/source/examples/expansion-filters.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_expansion: - -===================== -Functional Expansions -===================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/expansion-filters.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/hexagonal.rst b/docs/source/examples/hexagonal.rst deleted file mode 100644 index 8955fdb3f..000000000 --- a/docs/source/examples/hexagonal.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_hexagonal: - -=========================== -Modeling Hexagonal Lattices -=========================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/hexagonal-lattice.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/index.rst b/docs/source/examples/index.rst index 14565e64a..304137bcb 100644 --- a/docs/source/examples/index.rst +++ b/docs/source/examples/index.rst @@ -23,7 +23,7 @@ General Usage search nuclear-data nuclear-data-resonance-covariance - pincell-depletion + pincell_depletion -------- Geometry @@ -32,14 +32,14 @@ Geometry .. toctree:: :maxdepth: 1 - hexagonal + hexagonal-lattice triso candu - cad-geom + cad-based-geometry ------------------------------------- -Multi-Group Cross Section Generation ------------------------------------- +----------------------------------- +Multigroup Cross Section Generation +----------------------------------- .. toctree:: :maxdepth: 1 @@ -50,9 +50,9 @@ Multi-Group Cross Section Generation mdgxs-part-i mdgxs-part-ii ----------------- -Multi-Group Mode ----------------- +--------------- +Multigroup Mode +--------------- .. toctree:: :maxdepth: 1 diff --git a/docs/source/examples/mdgxs-part-i.rst b/docs/source/examples/mdgxs-part-i.rst deleted file mode 100644 index 2899f126b..000000000 --- a/docs/source/examples/mdgxs-part-i.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_mdgxs_part_i: - -=================================================================== -Multi-Group (Delayed) Cross Section Generation Part I: Introduction -=================================================================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/mdgxs-part-i.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/mdgxs-part-ii.rst b/docs/source/examples/mdgxs-part-ii.rst deleted file mode 100644 index c5d52df62..000000000 --- a/docs/source/examples/mdgxs-part-ii.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_mdgxs_part_ii: - -========================================================================= -Multi-Group (Delayed) Cross Section Generation Part II: Advanced Features -========================================================================= - -.. only:: html - - .. notebook:: ../../../examples/jupyter/mdgxs-part-ii.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/mg-mode-part-i.rst b/docs/source/examples/mg-mode-part-i.rst deleted file mode 100644 index e54c21c2f..000000000 --- a/docs/source/examples/mg-mode-part-i.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_mg_mode_part_i: - -===================================== -Multi-Group Mode Part I: Introduction -===================================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/mg-mode-part-i.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/mg-mode-part-ii.rst b/docs/source/examples/mg-mode-part-ii.rst deleted file mode 100644 index 9b4e574ae..000000000 --- a/docs/source/examples/mg-mode-part-ii.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_mg_mode_part_ii: - -============================================================= -Multi-Group Mode Part II: MGXS Library Generation With OpenMC -============================================================= - -.. only:: html - - .. notebook:: ../../../examples/jupyter/mg-mode-part-ii.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/mg-mode-part-iii.rst b/docs/source/examples/mg-mode-part-iii.rst deleted file mode 100644 index 86657c967..000000000 --- a/docs/source/examples/mg-mode-part-iii.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_mg_mode_part_iii: - -==================================================== -Multi-Group Mode Part III: Advanced Feature Showcase -==================================================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/mg-mode-part-iii.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/mgxs-part-i.rst b/docs/source/examples/mgxs-part-i.rst deleted file mode 100644 index d956e7261..000000000 --- a/docs/source/examples/mgxs-part-i.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_mgxs_part_i: - -========================= -MGXS Part I: Introduction -========================= - -.. only:: html - - .. notebook:: ../../../examples/jupyter/mgxs-part-i.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/mgxs-part-ii.rst b/docs/source/examples/mgxs-part-ii.rst deleted file mode 100644 index 64efc5752..000000000 --- a/docs/source/examples/mgxs-part-ii.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_mgxs_part_ii: - -=============================== -MGXS Part II: Advanced Features -=============================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/mgxs-part-ii.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/mgxs-part-iii.rst b/docs/source/examples/mgxs-part-iii.rst deleted file mode 100644 index 12f326529..000000000 --- a/docs/source/examples/mgxs-part-iii.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_mgxs_part_iii: - -======================== -MGXS Part III: Libraries -======================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/mgxs-part-iii.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/nuclear-data-resonance-covariance.rst b/docs/source/examples/nuclear-data-resonance-covariance.rst deleted file mode 100644 index 4b505c9a5..000000000 --- a/docs/source/examples/nuclear-data-resonance-covariance.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_nuclear_data_resonance_covariance: - -================================== -Nuclear Data: Resonance Covariance -================================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/nuclear-data-resonance-covariance.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/nuclear-data.rst b/docs/source/examples/nuclear-data.rst deleted file mode 100644 index 15dfbde18..000000000 --- a/docs/source/examples/nuclear-data.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_nuclear_data: - -============ -Nuclear Data -============ - -.. only:: html - - .. notebook:: ../../../examples/jupyter/nuclear-data.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/pandas-dataframes.rst b/docs/source/examples/pandas-dataframes.rst deleted file mode 100644 index 701f1630c..000000000 --- a/docs/source/examples/pandas-dataframes.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _examples_pandas: - -================= -Pandas Dataframes -================= - -.. only:: html - - .. notebook:: ../../../examples/jupyter/pandas-dataframes.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/pincell-depletion.rst b/docs/source/examples/pincell-depletion.rst deleted file mode 100644 index 348f3c6b9..000000000 --- a/docs/source/examples/pincell-depletion.rst +++ /dev/null @@ -1,14 +0,0 @@ -.. _notebook_depletion: - -================= -Pincell Depletion -================= - - -.. only:: html - - .. notebook:: ../../../examples/jupyter/pincell_depletion.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/pincell.rst b/docs/source/examples/pincell.rst deleted file mode 100644 index 0f149107c..000000000 --- a/docs/source/examples/pincell.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_pincell: - -=================== -Modeling a Pin-Cell -=================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/pincell.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/post-processing.rst b/docs/source/examples/post-processing.rst deleted file mode 100644 index 09c4454e7..000000000 --- a/docs/source/examples/post-processing.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_post_processing: - -=============== -Post Processing -=============== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/post-processing.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/search.rst b/docs/source/examples/search.rst deleted file mode 100644 index 1d56ff53a..000000000 --- a/docs/source/examples/search.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_search: - -================== -Criticality Search -================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/search.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/tally-arithmetic.rst b/docs/source/examples/tally-arithmetic.rst deleted file mode 100644 index 7e653e8ff..000000000 --- a/docs/source/examples/tally-arithmetic.rst +++ /dev/null @@ -1,11 +0,0 @@ -================ -Tally Arithmetic -================ - -.. only:: html - - .. notebook:: ../../../examples/jupyter/tally-arithmetic.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/triso.rst b/docs/source/examples/triso.rst deleted file mode 100644 index 98f2f1643..000000000 --- a/docs/source/examples/triso.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_triso: - -======================== -Modeling TRISO Particles -======================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/triso.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/unstructured-mesh-part-i.rst b/docs/source/examples/unstructured-mesh-part-i.rst deleted file mode 100644 index ed2c9c2fd..000000000 --- a/docs/source/examples/unstructured-mesh-part-i.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_unstructured_mesh_part_i: - -=============================== -Unstructured Mesh: Introduction -=============================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/unstructured-mesh-part-i.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/source/examples/unstructured-mesh-part-ii.rst b/docs/source/examples/unstructured-mesh-part-ii.rst deleted file mode 100644 index c30be8859..000000000 --- a/docs/source/examples/unstructured-mesh-part-ii.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _notebook_unstructured_mesh_part_ii: - -=================================================================================== -Unstructured Mesh: Unstructured Mesh Tallies with CAD and Point Cloud Visualization -=================================================================================== - -.. only:: html - - .. notebook:: ../../../examples/jupyter/unstructured-mesh-part-ii.ipynb - -.. only:: latex - - IPython notebooks must be viewed in the online HTML documentation. diff --git a/docs/sphinxext/LICENSE b/docs/sphinxext/LICENSE deleted file mode 100644 index 2d508d2be..000000000 --- a/docs/sphinxext/LICENSE +++ /dev/null @@ -1,68 +0,0 @@ -The file notebook_sphinxext.py was derived from code in PyNE and yt. - -PyNE has the following license: - -------------------------------------------------------------------------------- -Copyright 2011-2015, the PyNE Development Team. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other materials - provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE PYNE DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The views and conclusions contained in the software and documentation are those of the -authors and should not be interpreted as representing official policies, either expressed -or implied, of the stakeholders of the PyNE project or the employers of PyNE developers. -------------------------------------------------------------------------------- - -yt has the following license: - -------------------------------------------------------------------------------- -yt is licensed under the terms of the Modified BSD License (also known as New -or Revised BSD), as follows: - -Copyright (c) 2013-, yt Development Team -Copyright (c) 2006-2013, Matthew Turk - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of the yt Development Team nor the names of its -contributors may be used to endorse or promote products derived from this -software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- diff --git a/docs/sphinxext/notebook_sphinxext.py b/docs/sphinxext/notebook_sphinxext.py deleted file mode 100644 index eab93cc8a..000000000 --- a/docs/sphinxext/notebook_sphinxext.py +++ /dev/null @@ -1,117 +0,0 @@ -import sys -import os.path -import re -import time -from docutils import io, nodes, statemachine, utils -try: - from docutils.utils.error_reporting import ErrorString # the new way -except ImportError: - from docutils.error_reporting import ErrorString # the old way -from docutils.parsers.rst import Directive, convert_directive_function -from docutils.parsers.rst import directives, roles, states -from docutils.parsers.rst.roles import set_classes -from docutils.transforms import misc - -from nbconvert import html - - -class Notebook(Directive): - """Use nbconvert to insert a notebook into the environment. - This is based on the Raw directive in docutils - """ - required_arguments = 1 - optional_arguments = 0 - final_argument_whitespace = True - option_spec = {} - has_content = False - - def run(self): - # check if raw html is supported - if not self.state.document.settings.raw_enabled: - raise self.warning('"%s" directive disabled.' % self.name) - - # set up encoding - attributes = {'format': 'html'} - encoding = self.options.get( - 'encoding', self.state.document.settings.input_encoding) - e_handler = self.state.document.settings.input_encoding_error_handler - - # get path to notebook - source_dir = os.path.dirname( - os.path.abspath(self.state.document.current_source)) - nb_path = os.path.normpath(os.path.join(source_dir, - self.arguments[0])) - nb_path = utils.relative_path(None, nb_path) - - # convert notebook to html - exporter = html.HTMLExporter(template_file='full') - output, resources = exporter.from_filename(nb_path) - header = output.split('', 1)[1].split('',1)[0] - body = output.split('', 1)[1].split('',1)[0] - - # add HTML5 scoped attribute to header style tags - header = header.replace(''] - lines.append(header) - lines.append(body) - lines.append('') - text = '\n'.join(lines) - - # add dependency - self.state.document.settings.record_dependencies.add(nb_path) - attributes['source'] = nb_path - - # create notebook node - nb_node = notebook('', text, **attributes) - (nb_node.source, nb_node.line) = \ - self.state_machine.get_source_and_line(self.lineno) - - return [nb_node] - - -class notebook(nodes.raw): - pass - - -def visit_notebook_node(self, node): - self.visit_raw(node) - - -def depart_notebook_node(self, node): - self.depart_raw(node) - - -def setup(app): - app.add_node(notebook, - html=(visit_notebook_node, depart_notebook_node)) - - app.add_directive('notebook', Notebook) diff --git a/examples/jupyter/cad-based-geometry.ipynb b/examples/jupyter/cad-based-geometry.ipynb index b13c010cb..5f84ae5e5 100644 --- a/examples/jupyter/cad-based-geometry.ipynb +++ b/examples/jupyter/cad-based-geometry.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Using CAD-Based Geometries\n", "In this notebook we'll be exploring how to use CAD-based geometries in OpenMC via the [DagMC](https://svalinn.github.io/DAGMC/index.html) toolkit. The models we'll be using in this notebook have already been created using [Trelis](https://www.csimsoft.com/trelis) and faceted into a surface mesh represented as `.h5m` files in the [Mesh Oriented DatABase](https://press3.mcs.anl.gov/sigma/moab-library/) format. We'll be retrieving these files using the function below.\n", "\n" ] @@ -40,13 +41,6 @@ "This notebook is intended to demonstrate how DagMC problems are run in OpenMC. For more information on how DagMC models are created, please refer to the [DagMC User's Guide](https://svalinn.github.io/DAGMC/usersguide/index.html).\n" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# CAD-Based Geometry in OpenMC using [DagMC](https://svalinn.github.io/DAGMC/)" - ] - }, { "cell_type": "code", "execution_count": 2, @@ -756,7 +750,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/candu.ipynb b/examples/jupyter/candu.ipynb index b078d8ac6..eaf1e36d2 100644 --- a/examples/jupyter/candu.ipynb +++ b/examples/jupyter/candu.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Modeling a CANDU Bundle\n", "In this example, we will create a typical CANDU bundle with rings of fuel pins. At present, OpenMC does not have a specialized lattice for this type of fuel arrangement, so we must resort to manual creation of the array of fuel pins." ] }, @@ -1107,7 +1108,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/expansion-filters.ipynb b/examples/jupyter/expansion-filters.ipynb index 0975fca1b..3b0413a05 100644 --- a/examples/jupyter/expansion-filters.ipynb +++ b/examples/jupyter/expansion-filters.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Functional Expansions\n", "OpenMC's general tally system accommodates a wide range of tally *filters*. While most filters are meant to identify regions of phase space that contribute to a tally, there are a special set of functional expansion filters that will multiply the tally by a set of orthogonal functions, e.g. Legendre polynomials, so that continuous functions of space or angle can be reconstructed from the tallied moments.\n", "\n", "In this example, we will determine the spatial dependence of the flux along the $z$ axis by making a Legendre polynomial expansion. Let us represent the flux along the z axis, $\\phi(z)$, by the function\n", @@ -1539,7 +1540,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/hexagonal-lattice.ipynb b/examples/jupyter/hexagonal-lattice.ipynb index f47b3bc60..07c3ab834 100644 --- a/examples/jupyter/hexagonal-lattice.ipynb +++ b/examples/jupyter/hexagonal-lattice.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Modeling Hexagonal Lattices\n", "In this example, we will create a hexagonal lattice and show how the orientation can be changed via the cell rotation property. Let's first just set up some materials and universes that we will use to fill the lattice." ] }, @@ -402,7 +403,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/mdgxs-part-i.ipynb b/examples/jupyter/mdgxs-part-i.ipynb index 239b0f2df..cda79d30a 100644 --- a/examples/jupyter/mdgxs-part-i.ipynb +++ b/examples/jupyter/mdgxs-part-i.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Multigroup (Delayed) Cross Section Generation Part I: Introduction\n", "This IPython Notebook introduces the use of the `openmc.mgxs` module to calculate multi-energy-group and multi-delayed-group cross sections for an infinite homogeneous medium. In particular, this Notebook introduces the the following features:\n", "\n", "* Creation of multi-delayed-group cross sections for an **infinite homogeneous medium**\n", @@ -1486,7 +1487,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/mdgxs-part-ii.ipynb b/examples/jupyter/mdgxs-part-ii.ipynb index 77b5b5525..bb9538456 100644 --- a/examples/jupyter/mdgxs-part-ii.ipynb +++ b/examples/jupyter/mdgxs-part-ii.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Multigroup (Delayed) Cross Section Generation Part II: Advanced Features\n", "This IPython Notebook illustrates the use of the **`openmc.mgxs.Library`** class. The `Library` class is designed to automate the calculation of multi-group cross sections for use cases with one or more domains, cross section types, and/or nuclides. In particular, this Notebook illustrates the following features:\n", "\n", "* Calculation of multi-energy-group and multi-delayed-group cross sections for a **fuel assembly**\n", @@ -644,7 +645,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Using Tally Arithmetic to Compute the Delayed Neutron Precursor Concentrations" + "## Using Tally Arithmetic to Compute the Delayed Neutron Precursor Concentrations" ] }, { @@ -1170,7 +1171,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/mg-mode-part-i.ipynb b/examples/jupyter/mg-mode-part-i.ipynb index 23227b1ed..a4f3822f2 100644 --- a/examples/jupyter/mg-mode-part-i.ipynb +++ b/examples/jupyter/mg-mode-part-i.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Multigroup Mode Part I: Introduction\n", "This Notebook illustrates the usage of OpenMC's multi-group calculational mode with the Python API. This example notebook creates and executes the 2-D [C5G7](https://www.oecd-nea.org/science/docs/2003/nsc-doc2003-16.pdf) benchmark model using the `openmc.MGXSLibrary` class to create the supporting data library on the fly." ] }, @@ -11,7 +12,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Generate MGXS Library" + "## Generate MGXS Library" ] }, { @@ -137,7 +138,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Generate 2-D C5G7 Problem Input Files" + "## Generate 2-D C5G7 Problem Input Files" ] }, { @@ -622,7 +623,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Results Visualization\n", + "## Results Visualization\n", "\n", "Now that we have run the simulation, let's look at the fission rate and flux tallies that we tallied." ] @@ -693,7 +694,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.7" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/mg-mode-part-ii.ipynb b/examples/jupyter/mg-mode-part-ii.ipynb index 85a8d7367..ef9e00017 100644 --- a/examples/jupyter/mg-mode-part-ii.ipynb +++ b/examples/jupyter/mg-mode-part-ii.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Multigroup Mode Part II: MGXS Library Generation with OpenMC\n", "The previous Notebook in this series used multi-group mode to perform a calculation with previously defined cross sections. However, in many circumstances the multi-group data is not given and one must instead generate the cross sections for the specific application (or at least verify the use of cross sections from another application). \n", "\n", "This Notebook illustrates the use of the openmc.mgxs.Library class specifically for the calculation of MGXS to be used in OpenMC's multi-group mode. This example notebook is therefore very similar to the MGXS Part III notebook, except OpenMC is used as the multi-group solver instead of OpenMOC.\n", @@ -20,7 +21,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Generate Input Files" + "## Generate Input Files" ] }, { @@ -361,7 +362,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Create an MGXS Library\n", + "## Create an MGXS Library\n", "\n", "Now we are ready to generate multi-group cross sections! First, let's define a 2-group structure using the built-in EnergyGroups class." ] @@ -680,7 +681,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Tally Data Processing\n", + "## Tally Data Processing\n", "\n", "Our simulation ran successfully and created statepoint and summary output files. Let's begin by loading the StatePoint file." ] @@ -727,7 +728,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Multi-Group OpenMC Calculation" + "## Multi-Group OpenMC Calculation" ] }, { @@ -1005,7 +1006,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Results Comparison\n", + "## Results Comparison\n", "Now we can compare the multi-group and continuous-energy results.\n", "\n", "We will begin by loading the multi-group statepoint file we just finished writing and extracting the calculated keff." @@ -1092,7 +1093,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Pin Power Visualizations" + "## Pin Power Visualizations" ] }, { @@ -1208,7 +1209,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Scattering Anisotropy Treatments\n", + "## Scattering Anisotropy Treatments\n", "\n", "We will next show how we can work with the scattering angular distributions. OpenMC's MG solver has the capability to use group-to-group angular distributions which are represented as any of the following: a truncated Legendre series of up to the 10th order, a histogram distribution, and a tabular distribution. Any combination of these representations can be used by OpenMC during the transport process, so long as all constituents of a given material use the same representation. This means it is possible to have water represented by a tabular distribution and fuel represented by a Legendre if so desired.\n", "\n", @@ -1224,7 +1225,7 @@ "metadata": {}, "source": [ "\n", - "## Global P0 Scattering\n", + "### Global P0 Scattering\n", "First we begin by re-running with P0 scattering (i.e., isotropic) everywhere. If a global maximum order is requested, the most effective way to do this is to use the `max_order` attribute of our `openmc.Settings` object." ] }, @@ -1355,7 +1356,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Mixed Scattering Representations\n", + "### Mixed Scattering Representations\n", "OpenMC's Multi-Group mode also includes a feature where not every data in the library is required to have the same scattering treatment. For example, we could represent the water with P3 scattering, and the fuel and cladding with P0 scattering. This series will show how this can be done.\n", "\n", "First we will convert the data to P0 scattering, unless its water, then we will leave that as P3 data." @@ -1531,7 +1532,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.7" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/mg-mode-part-iii.ipynb b/examples/jupyter/mg-mode-part-iii.ipynb index e953d64d3..ea1e773f8 100644 --- a/examples/jupyter/mg-mode-part-iii.ipynb +++ b/examples/jupyter/mg-mode-part-iii.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Multigroup Mode Part III: Advanced Feature Showcase\n", "This Notebook illustrates the use of the the more advanced features of OpenMC's multi-group mode and the openmc.mgxs.Library class. During this process, this notebook will illustrate the following features:\n", "\n", " - Calculation of multi-group cross sections for a simplified BWR 8x8 assembly with isotropic and angle-dependent MGXS.\n", @@ -17,7 +18,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Generate Input Files" + "## Generate Input Files" ] }, { @@ -456,7 +457,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Create an MGXS Library\n", + "## Create an MGXS Library\n", "\n", "Now we are ready to generate multi-group cross sections! First, let's define a 2-group structure using the built-in EnergyGroups class." ] @@ -817,7 +818,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Tally Data Processing\n", + "## Tally Data Processing\n", "\n", "Our simulation ran successfully and created statepoint and summary output files. Let's begin by loading the StatePoint file, but not automatically linking the summary file." ] @@ -878,7 +879,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Isotropic Multi-Group OpenMC Calculation" + "## Isotropic Multi-Group OpenMC Calculation" ] }, { @@ -1100,7 +1101,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Angle-Dependent Multi-Group OpenMC Calculation\n", + "## Angle-Dependent Multi-Group OpenMC Calculation\n", "\n", "Let's now run the calculation with the angle-dependent multi-group cross sections. This process will be the exact same as above, except this time we will use the angle-dependent Library as our starting point.\n", "\n", @@ -1200,7 +1201,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Results Comparison\n", + "## Results Comparison\n", "In this section we will compare the eigenvalues and fission rate distributions of the continuous-energy, isotropic multi-group and angle-dependent multi-group cases.\n", "\n", "We will begin by loading the multi-group statepoint files, first the isotropic, then angle-dependent. The angle-dependent was not renamed, so we can autolink its summary." @@ -1225,7 +1226,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Eigenvalue Comparison\n", + "### Eigenvalue Comparison\n", "Next, we can load the eigenvalues for comparison and do that comparison" ] }, @@ -1280,7 +1281,7 @@ "\n", "It is important to note that both eigenvalues can be improved by the application of finer geometric or energetic discretizations, but this shows that the angle discretization may be a factor for consideration.\n", "\n", - "## Fission Rate Distribution Comparison\n", + "### Fission Rate Distribution Comparison\n", "Next we will visualize the mesh tally results obtained from our three cases.\n", "\n", "This will be performed by first obtaining the one-group fission rate tally information from our state point files. After we have this information we will re-shape the data to match the original mesh laydown. We will then normalize, and finally create side-by-side plots of all." @@ -1417,7 +1418,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/mgxs-part-i.ipynb b/examples/jupyter/mgxs-part-i.ipynb index 264f8967c..62a9b70b1 100644 --- a/examples/jupyter/mgxs-part-i.ipynb +++ b/examples/jupyter/mgxs-part-i.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Multigroup Cross Section Generation Part I: Introduction\n", "This IPython Notebook introduces the use of the `openmc.mgxs` module to calculate multi-group cross sections for an infinite homogeneous medium. In particular, this Notebook introduces the the following features:\n", "\n", "* **General equations** for scalar-flux averaged multi-group cross sections\n", @@ -1130,7 +1131,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/mgxs-part-ii.ipynb b/examples/jupyter/mgxs-part-ii.ipynb index 9e5cde42d..dd5b21a55 100644 --- a/examples/jupyter/mgxs-part-ii.ipynb +++ b/examples/jupyter/mgxs-part-ii.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Multigroup Cross Section Generation Part II: Advanced Features\n", "This IPython Notebook illustrates the use of the `openmc.mgxs` module to calculate multi-group cross sections for a heterogeneous fuel pin cell geometry. In particular, this Notebook illustrates the following features:\n", "\n", "* Creation of multi-group cross sections on a **heterogeneous geometry**\n", @@ -2736,7 +2737,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/mgxs-part-iii.ipynb b/examples/jupyter/mgxs-part-iii.ipynb index a4c440b3a..b05dbabd5 100644 --- a/examples/jupyter/mgxs-part-iii.ipynb +++ b/examples/jupyter/mgxs-part-iii.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Multigroup Cross Section Generation Part III: Libraries\n", "This IPython Notebook illustrates the use of the **`openmc.mgxs.Library`** class. The `Library` class is designed to automate the calculation of multi-group cross sections for use cases with one or more domains, cross section types, and/or nuclides. In particular, this Notebook illustrates the following features:\n", "\n", "* Calculation of multi-group cross sections for a **fuel assembly**\n", @@ -1659,7 +1660,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/nuclear-data-resonance-covariance.ipynb b/examples/jupyter/nuclear-data-resonance-covariance.ipynb index d8bca235d..8fe85161d 100644 --- a/examples/jupyter/nuclear-data-resonance-covariance.ipynb +++ b/examples/jupyter/nuclear-data-resonance-covariance.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Nuclear Data: Resonance Covariance\n", "In this notebook we will explore features of the Python API that allow us to import and manipulate resonance covariance data. A full description of the ENDF-VI and ENDF-VII formats can be found in the [ENDF102 manual](https://www.oecd-nea.org/dbdata/data/manual-endf/endf102.pdf)." ] }, @@ -954,7 +955,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/nuclear-data.ipynb b/examples/jupyter/nuclear-data.ipynb index e13b143e4..c63c24a17 100644 --- a/examples/jupyter/nuclear-data.ipynb +++ b/examples/jupyter/nuclear-data.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Nuclear Data\n", "In this notebook, we will go through the salient features of the `openmc.data` package in the Python API. This package enables inspection, analysis, and conversion of nuclear data from ACE files. Most importantly, the package provides a mean to generate HDF5 nuclear data libraries that are used by the transport solver." ] }, @@ -1495,7 +1496,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/pandas-dataframes.ipynb b/examples/jupyter/pandas-dataframes.ipynb index ddc8ee429..f5e5142b5 100644 --- a/examples/jupyter/pandas-dataframes.ipynb +++ b/examples/jupyter/pandas-dataframes.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Pandas Dataframes\n", "This notebook demonstrates how systematic analysis of tally scores is possible using Pandas dataframes. A dataframe can be automatically generated using the `Tally.get_pandas_dataframe(...)` method. Furthermore, by linking the tally data in a statepoint file with geometry and material information from a summary file, the dataframe can be shown with user-supplied labels." ] }, @@ -2687,7 +2688,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/pincell.ipynb b/examples/jupyter/pincell.ipynb index 0f11ca655..dd0cf1313 100644 --- a/examples/jupyter/pincell.ipynb +++ b/examples/jupyter/pincell.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Modeling a Pin-Cell\n", "This notebook is intended to demonstrate the basic features of the Python API for constructing input files and running OpenMC. In it, we will show how to create a basic reflective pin-cell model that is equivalent to modeling an infinite array of fuel pins. If you have never used OpenMC, this can serve as a good starting point to learn the Python API. We highly recommend having a copy of the [Python API reference documentation](https://docs.openmc.org/en/stable/pythonapi/index.html) open in another browser tab that you can refer to." ] }, @@ -1574,7 +1575,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/pincell_depletion.ipynb b/examples/jupyter/pincell_depletion.ipynb index 94ec479f6..3fa46c00b 100644 --- a/examples/jupyter/pincell_depletion.ipynb +++ b/examples/jupyter/pincell_depletion.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Pincell Depletion\n", "This notebook is intended to introduce the reader to the depletion interface contained in OpenMC. It is recommended that you are moderately familiar with building models using the OpenMC Python API. The earlier examples are excellent starting points, as this notebook will not focus heavily on model building.\n", "\n", "If you have a real power reactor, the fuel composition is constantly changing as fission events produce energy, remove some fissile isotopes, and produce fission products. Other reactions, like $(n, \\alpha)$ and $(n, \\gamma)$ will alter the composition as well. Furthermore, some nuclides undergo spontaneous decay with widely ranging frequencies. Depletion is the process of modeling this behavior.\n", @@ -26,7 +27,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Build the Geometry\n", + "## Build the Geometry\n", "\n", "Much of this section is borrowed from the \"Modeling a Pin-Cell\" example. If you find yourself not understanding some aspects of this section, feel free to refer to that example, as some details may be glossed over for brevity.\n", "\n", @@ -309,7 +310,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Setting up for depletion\n", + "## Setting up for depletion\n", "\n", "The OpenMC depletion interface can be accessed from the `openmc.deplete` module, and has a variety of classes that will help us." ] @@ -475,7 +476,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Processing the outputs\n", + "## Processing the outputs\n", "\n", "The depletion simulation produces a few output files. First, the statepoint files from each individual transport simulation are written to `openmc_simulation_n.h5`, where `` indicates the current depletion step. Any tallies that we defined in `tallies.xml` will be included in these files across our simulations. We have 7 such files, one for each our of 6 depletion steps and the initial state." ] @@ -708,7 +709,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Helpful tips\n", + "## Helpful tips\n", "\n", "Depletion is a tricky task to get correct. Use too short of time steps and you may never get your results due to running many transport simulations. Use long of time steps and you may get incorrect answers. Consider the xenon plot from above. Xenon-135 is a fission product with a thermal absorption cross section on the order of millions of barns, but has a half life of ~9 hours. Taking smaller time steps at the beginning of your simulation to build up some equilibrium in your fission products is highly recommended.\n", "\n", @@ -770,7 +771,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Register depletion chain\n", + "## Register depletion chain\n", "\n", "The depletion chain we created can be registered into the OpenMC `cross_sections.xml` file, so we don't have to always pass the `chain_file` argument to the `Operator`. To do this, we create a `DataLibrary` using `openmc.data`. Without any arguments, the `from_xml` method will look for the file located at `OPENMC_CROSS_SECTIONS`. For this example, we will just create a bare library." ] @@ -911,7 +912,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Choice of depletion step size\n", + "## Choice of depletion step size\n", "\n", "A general rule of thumb is to use depletion step sizes around 2 MWd/kgHM, where kgHM is really the initial heavy metal mass in kg. If your problem includes integral burnable absorbers, these typically require shorter time steps at or below 1 MWd/kgHM. These are typically valid for the predictor scheme, as the point of recent schemes is to extend this step size. A good convergence study, where the step size is decreased until some convergence metric is satisfied, is a beneficial exercise.\n", "\n", @@ -988,7 +989,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/post-processing.ipynb b/examples/jupyter/post-processing.ipynb index 44a2c2d4e..d31af5831 100644 --- a/examples/jupyter/post-processing.ipynb +++ b/examples/jupyter/post-processing.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Post Processing\n", "This notebook demonstrates some basic post-processing tasks that can be performed with the Python API, such as plotting a 2D mesh tally and plotting neutron source sites from an eigenvalue calculation. The problem we will use is a simple reflected pin-cell." ] }, @@ -971,7 +972,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/search.ipynb b/examples/jupyter/search.ipynb index 6c3e2169e..a71272641 100644 --- a/examples/jupyter/search.ipynb +++ b/examples/jupyter/search.ipynb @@ -4,7 +4,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This Notebook illustrates the usage of the OpenMC Python API's generic eigenvalue search capability. In this Notebook, we will do a critical boron concentration search of a typical PWR pin cell.\n", + "# Criticality Search\n", + "This notebook illustrates the usage of the OpenMC Python API's generic eigenvalue search capability. In this Notebook, we will do a critical boron concentration search of a typical PWR pin cell.\n", "\n", "To use the search functionality, we must create a function which creates our model according to the input parameter we wish to search for (in this case, the boron concentration). \n", "\n", @@ -31,7 +32,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Create Parametrized Model\n", + "## Create Parametrized Model\n", "\n", "To perform the search we will use the `openmc.search_for_keff` function. This function requires a different function be defined which creates an parametrized model to analyze. This model is required to be stored in an `openmc.model.Model` object. The first parameter of this function will be modified during the search process for our critical eigenvalue.\n", "\n", @@ -127,7 +128,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Search for the Critical Boron Concentration\n", + "## Search for the Critical Boron Concentration\n", "\n", "To perform the search we imply call the `openmc.search_for_keff` function and pass in the relvant arguments. For our purposes we will be passing in the model building function (`build_model` defined above), a bracketed range for the expected critical Boron concentration (1,000 to 2,500 ppm), the tolerance, and the method we wish to use. \n", "\n", @@ -225,7 +226,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/tally-arithmetic.ipynb b/examples/jupyter/tally-arithmetic.ipynb index 40eb2b05f..0e8b53ac7 100644 --- a/examples/jupyter/tally-arithmetic.ipynb +++ b/examples/jupyter/tally-arithmetic.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Tally Arithmetic\n", "This notebook shows the how tallies can be combined (added, subtracted, multiplied, etc.) using the Python API in order to create derived tallies. Since no covariance information is obtained, it is assumed that tallies are completely independent of one another when propagating uncertainties. The target problem is a simple pin cell." ] }, @@ -1745,7 +1746,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.0" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/triso.ipynb b/examples/jupyter/triso.ipynb index 882463efc..ae17ee344 100644 --- a/examples/jupyter/triso.ipynb +++ b/examples/jupyter/triso.ipynb @@ -4,6 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Modeling TRISO Particles\n", "OpenMC includes a few convenience functions for generationing TRISO particle locations and placing them in a lattice. To be clear, this capability is not a stochastic geometry capability like that included in MCNP. It's also important to note that OpenMC does not use delta tracking, which would normally speed up calculations in geometries with tons of surfaces and cells. However, the computational burden can be eased by placing TRISO particles in a lattice." ] }, @@ -357,7 +358,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/unstructured-mesh-part-i.ipynb b/examples/jupyter/unstructured-mesh-part-i.ipynb index 4e6d873cc..f307469de 100644 --- a/examples/jupyter/unstructured-mesh-part-i.ipynb +++ b/examples/jupyter/unstructured-mesh-part-i.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Unstructured Mesh Tallies in OpenMC\n", + "# Unstructured Mesh: Introduction\n", "\n", "In this example we'll look at how to setup and use unstructured mesh tallies in OpenMC. Unstructured meshes are able to provide results over spatial regions of a problem while conforming to a specific geometric features -- something that is often difficult to do using the regular and rectilinear meshes in OpenMC.\n", "\n", @@ -696,7 +696,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/examples/jupyter/unstructured-mesh-part-ii.ipynb b/examples/jupyter/unstructured-mesh-part-ii.ipynb index 8c04ace56..92089cabc 100644 --- a/examples/jupyter/unstructured-mesh-part-ii.ipynb +++ b/examples/jupyter/unstructured-mesh-part-ii.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Unstructured Mesh Tallies with CAD Geometry in OpenMC\n", + "# Unstructured Mesh: Tallies with CAD and Point Cloud Visualization\n", "\n", "In the first notebook on this topic, we looked at how to set up a tally using an unstructured mesh in OpenMC.\n", "In this notebook, we will explore using unstructured mesh in conjunction with CAD-based geometry to perform detailed geometry analysis on complex geomerty.\n", @@ -647,7 +647,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.8.3" } }, "nbformat": 4, diff --git a/setup.py b/setup.py index 6afac4df1..02f3c0842 100755 --- a/setup.py +++ b/setup.py @@ -72,7 +72,8 @@ kwargs = { 'extras_require': { 'depletion-mpi': ['mpi4py'], 'docs': ['sphinx', 'sphinxcontrib-katex', 'sphinx-numfig', 'jupyter', - 'sphinxcontrib-svg2pdfconverter', 'sphinx-rtd-theme'], + 'sphinxcontrib-svg2pdfconverter', 'sphinx-rtd-theme', + 'nbsphinx'], 'test': ['pytest', 'pytest-cov', 'colorama'], 'vtk': ['vtk'], }, From 4f7617e90cb6a905fdb93566d737d31c52e1853d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 14 Oct 2020 15:10:03 -0500 Subject: [PATCH 03/23] Fix documentation for source site attributes --- docs/source/io_formats/source.rst | 8 ++++---- docs/source/io_formats/statepoint.rst | 10 +++++----- openmc/statepoint.py | 7 ++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/source/io_formats/source.rst b/docs/source/io_formats/source.rst index 6058241e1..4cd023e12 100644 --- a/docs/source/io_formats/source.rst +++ b/docs/source/io_formats/source.rst @@ -15,7 +15,7 @@ is that documented here. :Datasets: - **source_bank** (Compound type) -- Source bank information for each - particle. The compound type has fields ``wgt``, ``xyz``, ``uvw``, - ``E``, ``delayed_group``, and ``particle``, which represent the - weight, position, direction, energy, energy group, delayed group, - and type of the source particle, respectively. + particle. The compound type has fields ``r``, ``u``, ``E``, + ``wgt``, ``delayed_group``, and ``particle``, which represent the + position, direction, energy, weight, delayed group, and particle + type (0=neutron, 1=photon, 2=electron, 3=positron), respectively. diff --git a/docs/source/io_formats/statepoint.rst b/docs/source/io_formats/statepoint.rst index f90d5b3af..3a2ad1600 100644 --- a/docs/source/io_formats/statepoint.rst +++ b/docs/source/io_formats/statepoint.rst @@ -51,11 +51,11 @@ The current version of the statepoint file format is 17.0. - **global_tallies** (*double[][2]*) -- Accumulated sum and sum-of-squares for each global tally. - **source_bank** (Compound type) -- Source bank information for each - particle. The compound type has fields ``wgt``, ``xyz``, ``uvw``, - ``E``, ``g``, and ``delayed_group``, which represent the weight, - position, direction, energy, energy group, and delayed_group of the - source particle, respectively. Only present when `run_mode` is - 'eigenvalue'. + particle. The compound type has fields ``r``, ``u``, ``E``, + ``wgt``, ``delayed_group``, and ``particle``, which represent the + position, direction, energy, weight, delayed group, and particle + type (0=neutron, 1=photon, 2=electron, 3=positron), respectively. + Only present when `run_mode` is 'eigenvalue'. **/tallies/** diff --git a/openmc/statepoint.py b/openmc/statepoint.py index 294f6c546..f6177fcc4 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -93,9 +93,10 @@ class StatePoint: seed : int Pseudorandom number generator seed source : numpy.ndarray of compound datatype - Array of source sites. The compound datatype has fields 'wgt', 'xyz', - 'uvw', and 'E' corresponding to the weight, position, direction, and - energy of the source site. + Array of source sites. The compound datatype has fields 'r', 'u', + 'E', 'wgt', 'delayed_group', and 'particle', corresponding to the + position, direction, energy, weight, delayed group, and particle type + of the source site, respectively. source_present : bool Indicate whether source sites are present sparse : bool From 441d081dd51dab4d7943abf906f4ea3f2112847e Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 14 Oct 2020 15:16:50 -0500 Subject: [PATCH 04/23] Implement write_source_file function --- docs/source/pythonapi/base.rst | 10 ++++ openmc/source.py | 88 ++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/docs/source/pythonapi/base.rst b/docs/source/pythonapi/base.rst index d621637bb..544e7009c 100644 --- a/docs/source/pythonapi/base.rst +++ b/docs/source/pythonapi/base.rst @@ -22,9 +22,19 @@ Simulation Settings :template: myclass.rst openmc.Source + openmc.SourceParticle openmc.VolumeCalculation openmc.Settings +The following function can be used for generating a source file: + +.. autosummary:: + :toctree: generated + :nosignatures: + :template: myfunction.rst + + openmc.write_source_file + Material Specification ---------------------- diff --git a/openmc/source.py b/openmc/source.py index 22952b4a5..3863bb826 100644 --- a/openmc/source.py +++ b/openmc/source.py @@ -1,6 +1,10 @@ +from enum import Enum from numbers import Real from xml.etree import ElementTree as ET +import numpy as np +import h5py + import openmc.checkvalue as cv from openmc.stats.multivariate import UnitSphere, Spatial from openmc.stats.univariate import Univariate @@ -226,3 +230,87 @@ class Source: source.energy = Univariate.from_xml_element(energy) return source + + +class ParticleType(Enum): + NEUTRON = 0 + PHOTON = 1 + ELECTRON = 2 + POSITRON = 3 + + +class SourceParticle: + """Source particle + + This class can be used to create source particles that can be written to a + file and used by OpenMC + + Parameters + ---------- + r : iterable of float + Position of particle in Cartesian coordinates + u : iterable of float + Directional cosines + E : float + Energy of particle in [eV] + wgt : float + Weight of the particle + delayed_group : int + Delayed group particle was created in (neutrons only) + particle : ParticleType + Type of the particle + + """ + def __init__(self, r=(0., 0., 0.), u=(0., 0., 1.), E=1.0e6, wgt=1.0, + delayed_group=0, particle=ParticleType.NEUTRON): + self.r = tuple(r) + self.u = tuple(u) + self.E = float(E) + self.wgt = float(wgt) + self.delayed_group = delayed_group + self.particle = particle + + def to_tuple(self): + """Return source particle attributes as a tuple + + Returns + ------- + tuple + Source particle attributes + + """ + return (self.r, self.u, self.E, self.wgt, + self.delayed_group, self.particle.value) + + +def write_source_file(source_particles, filename, **kwargs): + """Write a source file using a collection of source particles + + Parameters + ---------- + source_particles : iterable of SourceParticle + Source particles to write to file + filename : str or path-like + Path to source file to write + **kwargs + Keyword arguments to pass to :class:`h5py.File` + + """ + # Create compound datatype for source particles + pos_dtype = np.dtype([('x', ' Date: Wed, 14 Oct 2020 15:47:08 -0500 Subject: [PATCH 05/23] Add test for source file generation --- tests/unit_tests/test_source_file.py | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/unit_tests/test_source_file.py diff --git a/tests/unit_tests/test_source_file.py b/tests/unit_tests/test_source_file.py new file mode 100644 index 000000000..e9bcebc92 --- /dev/null +++ b/tests/unit_tests/test_source_file.py @@ -0,0 +1,38 @@ +from random import random + +import h5py +import numpy as np +import openmc + + +def test_source_file(run_in_tmpdir): + # Create source particles + source = [] + n = 1000 + for i in range(n): + source.append(openmc.SourceParticle( + r=(random(), i, 0), + u=(0., 0., 1.), + E=float(n - i), + )) + + # Create source file + openmc.write_source_file(source, 'test_source.h5') + + # Get array of source particles from file + with h5py.File('test_source.h5', 'r') as fh: + arr = fh['source_bank'][...] + + # Ensure data is consistent + r = arr['r'] + assert np.all((r['x'] > 0.0) & (r['x'] < 1.0)) + assert np.all(r['y'] == np.arange(1000)) + assert np.all(r['z'] == 0.0) + u = arr['u'] + assert np.all(u['x'] == 0.0) + assert np.all(u['y'] == 0.0) + assert np.all(u['z'] == 1.0) + assert np.all(arr['E'] == n - np.arange(n)) + assert np.all(arr['wgt'] == 1.0) + assert np.all(arr['delayed_group'] == 0) + assert np.all(arr['particle'] == 0) From 2d8c9aed8108d1c1e638fce599b9f66ed0f86395 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 14 Oct 2020 15:49:59 -0500 Subject: [PATCH 06/23] Add note in state_point.cpp about updating compoung datatype for source --- src/state_point.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/state_point.cpp b/src/state_point.cpp index 14260051c..e1ea52284 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -508,6 +508,12 @@ hid_t h5banktype() { H5Tinsert(postype, "z", HOFFSET(Position, z), H5T_NATIVE_DOUBLE); // Create bank datatype + // + // If you make changes to the compound datatype here, make sure you update: + // - openmc/source.py + // - openmc/statepoint.py + // - docs/source/io_formats/statepoint.rst + // - docs/source/io_formats/source.rst hid_t banktype = H5Tcreate(H5T_COMPOUND, sizeof(struct Particle::Bank)); H5Tinsert(banktype, "r", HOFFSET(Particle::Bank, r), postype); H5Tinsert(banktype, "u", HOFFSET(Particle::Bank, u), postype); From 43cb227e981a887b2f21eb97f44d8de8037e6310 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 19 Oct 2020 13:40:41 +0100 Subject: [PATCH 07/23] added latest build for master branch --- .github/workflows/dockerhub-publish-dev.yml | 32 +++++++++++++++++++++ .github/workflows/dockerhub-publish.yml | 32 +++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/dockerhub-publish-dev.yml create mode 100644 .github/workflows/dockerhub-publish.yml diff --git a/.github/workflows/dockerhub-publish-dev.yml b/.github/workflows/dockerhub-publish-dev.yml new file mode 100644 index 000000000..00fab4129 --- /dev/null +++ b/.github/workflows/dockerhub-publish-dev.yml @@ -0,0 +1,32 @@ +name: dockerhub-publish-develop + +on: + push: + branches: develop + +jobs: + main: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: openmc/openmc:develop + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/dockerhub-publish.yml b/.github/workflows/dockerhub-publish.yml new file mode 100644 index 000000000..0737849e9 --- /dev/null +++ b/.github/workflows/dockerhub-publish.yml @@ -0,0 +1,32 @@ +name: dockerhub-publish-latest + +on: + push: + branches: master + +jobs: + main: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: openmc/openmc:latest + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} From 27034923f92ec61d756fc0f533372d35b5b07c0b Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 19 Oct 2020 13:42:48 +0100 Subject: [PATCH 08/23] wrong dir, moved file --- github/workflows/dockerhub-publish-dev.yml | 32 ---------------------- 1 file changed, 32 deletions(-) delete mode 100644 github/workflows/dockerhub-publish-dev.yml diff --git a/github/workflows/dockerhub-publish-dev.yml b/github/workflows/dockerhub-publish-dev.yml deleted file mode 100644 index f025e2ab2..000000000 --- a/github/workflows/dockerhub-publish-dev.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: dockerhub-publish - -on: - push: - branches: develop - -jobs: - main: - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - push: true - tags: openmc/openmc:dev - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} From 986dc94aedd86aae727b0485798d3b5dc93d556a Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 19 Oct 2020 13:48:48 +0100 Subject: [PATCH 09/23] changed trigger to on PR to test if secrets work --- .github/workflows/dockerhub-publish-dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dockerhub-publish-dev.yml b/.github/workflows/dockerhub-publish-dev.yml index 00fab4129..0a08f848c 100644 --- a/.github/workflows/dockerhub-publish-dev.yml +++ b/.github/workflows/dockerhub-publish-dev.yml @@ -3,6 +3,8 @@ name: dockerhub-publish-develop on: push: branches: develop + pull_request: + branches: develop jobs: main: From 4068bb8ac51d0431f6c8aec8aa56998acafd12e1 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 19 Oct 2020 13:56:01 +0100 Subject: [PATCH 10/23] removed PR trigger --- .github/workflows/dockerhub-publish-dev.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/dockerhub-publish-dev.yml b/.github/workflows/dockerhub-publish-dev.yml index 0a08f848c..00fab4129 100644 --- a/.github/workflows/dockerhub-publish-dev.yml +++ b/.github/workflows/dockerhub-publish-dev.yml @@ -3,8 +3,6 @@ name: dockerhub-publish-develop on: push: branches: develop - pull_request: - branches: develop jobs: main: From 0b0d03541df161177a92a27c05eadd01aeba166b Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Thu, 15 Oct 2020 16:16:34 -0500 Subject: [PATCH 11/23] Put get_indices implementation into StructuredMesh base class. Refs #1695 --- include/openmc/mesh.h | 21 ++++++++++++--------- src/mesh.cpp | 35 +++++++++++++++-------------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index b7dcb017b..75cc22502 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -116,7 +116,7 @@ public: //! \param[in] r Position to get indices for //! \param[out] ijk Array of mesh indices //! \param[out] in_mesh Whether position is in mesh - virtual void get_indices(Position r, int* ijk, bool* in_mesh) const = 0; + virtual void get_indices(Position r, int* ijk, bool* in_mesh) const; //! Get mesh indices corresponding to a mesh bin // @@ -124,12 +124,19 @@ public: //! \param[out] ijk Mesh indices virtual void get_indices_from_bin(int bin, int* ijk) const = 0; + //! Get mesh index in a particular direction + //! + //! \param[in] r Position to get index for + //! \param[in] i Direction index + virtual int get_index_in_direction(Position r, int i) const = 0; + //! Get a label for the mesh bin std::string bin_label(int bin) const override; // Data members xt::xtensor lower_left_; //!< Lower-left coordinates of mesh xt::xtensor upper_right_; //!< Upper-right coordinates of mesh + xt::xtensor shape_; //!< Number of mesh elements in each dimension }; //============================================================================== @@ -155,10 +162,10 @@ public: int get_bin_from_indices(const int* ijk) const override; - void get_indices(Position r, int* ijk, bool* in_mesh) const override; - void get_indices_from_bin(int bin, int* ijk) const override; + int get_index_in_direction(Position r, int i) const override; + int n_bins() const override; int n_surface_bins() const override; @@ -189,7 +196,6 @@ public: // Data members double volume_frac_; //!< Volume fraction of each mesh element - xt::xtensor shape_; //!< Number of mesh elements in each dimension xt::xtensor width_; //!< Width of each mesh element private: @@ -217,10 +223,10 @@ public: int get_bin_from_indices(const int* ijk) const override; - void get_indices(Position r, int* ijk, bool* in_mesh) const override; - void get_indices_from_bin(int bin, int* ijk) const override; + int get_index_in_direction(Position r, int i) const override; + int n_bins() const override; int n_surface_bins() const override; @@ -240,9 +246,6 @@ public: //! \return Whether the line segment connecting r0 and r1 intersects mesh bool intersects(Position& r0, Position r1, int* ijk) const; - // Data members - xt::xtensor shape_; //!< Number of mesh elements in each dimension - private: std::vector> grid_; }; diff --git a/src/mesh.cpp b/src/mesh.cpp index 5122c2b61..5c4da6461 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -102,6 +102,17 @@ StructuredMesh::bin_label(int bin) const { } } +void +StructuredMesh::get_indices(Position r, int* ijk, bool* in_mesh) const +{ + *in_mesh = true; + for (int i = 0; i < n_dimension_; ++i) { + ijk[i] = get_index_in_direction(r, i); + + if (ijk[i] < 1 || ijk[i] > shape_[i]) *in_mesh = false; + } +} + //============================================================================== // RegularMesh implementation //============================================================================== @@ -213,16 +224,9 @@ int RegularMesh::get_bin_from_indices(const int* ijk) const } } -void RegularMesh::get_indices(Position r, int* ijk, bool* in_mesh) const +int RegularMesh::get_index_in_direction(Position r, int i) const { - // Find particle in mesh - *in_mesh = true; - for (int i = 0; i < n_dimension_; ++i) { - ijk[i] = std::ceil((r[i] - lower_left_[i]) / width_[i]); - - // Check if indices are within bounds - if (ijk[i] < 1 || ijk[i] > shape_[i]) *in_mesh = false; - } + return std::ceil((r[i] - lower_left_[i]) / width_[i]); } void RegularMesh::get_indices_from_bin(int bin, int* ijk) const @@ -1175,18 +1179,9 @@ int RectilinearMesh::get_bin_from_indices(const int* ijk) const return ((ijk[2] - 1)*shape_[1] + (ijk[1] - 1))*shape_[0] + ijk[0] - 1; } -void RectilinearMesh::get_indices(Position r, int* ijk, bool* in_mesh) const +int RectilinearMesh::get_index_in_direction(Position r, int i) const { - *in_mesh = true; - - for (int i = 0; i < 3; ++i) { - if (r[i] < grid_[i].front() || r[i] > grid_[i].back()) { - ijk[i] = -1; - *in_mesh = false; - } else { - ijk[i] = lower_bound_index(grid_[i].begin(), grid_[i].end(), r[i]) + 1; - } - } + return lower_bound_index(grid_[i].begin(), grid_[i].end(), r[i]) + 1; } void RectilinearMesh::get_indices_from_bin(int bin, int* ijk) const From 7d0838d27b11def6adc2c627387602e777b234c0 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Thu, 15 Oct 2020 16:22:27 -0500 Subject: [PATCH 12/23] Move get_bin_from_indices into StructuredMesh base class. Refs #1695 --- include/openmc/mesh.h | 6 +----- src/mesh.cpp | 36 +++++++++++++++--------------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 75cc22502..cfcc137e8 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -109,7 +109,7 @@ public: // //! \param[in] Array of mesh indices //! \return Mesh bin - virtual int get_bin_from_indices(const int* ijk) const = 0; + virtual int get_bin_from_indices(const int* ijk) const; //! Get mesh indices given a position // @@ -160,8 +160,6 @@ public: int get_bin(Position r) const override; - int get_bin_from_indices(const int* ijk) const override; - void get_indices_from_bin(int bin, int* ijk) const override; int get_index_in_direction(Position r, int i) const override; @@ -221,8 +219,6 @@ public: int get_bin(Position r) const override; - int get_bin_from_indices(const int* ijk) const override; - void get_indices_from_bin(int bin, int* ijk) const override; int get_index_in_direction(Position r, int i) const override; diff --git a/src/mesh.cpp b/src/mesh.cpp index 5c4da6461..fd5b30466 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -102,8 +102,7 @@ StructuredMesh::bin_label(int bin) const { } } -void -StructuredMesh::get_indices(Position r, int* ijk, bool* in_mesh) const +void StructuredMesh::get_indices(Position r, int* ijk, bool* in_mesh) const { *in_mesh = true; for (int i = 0; i < n_dimension_; ++i) { @@ -113,6 +112,20 @@ StructuredMesh::get_indices(Position r, int* ijk, bool* in_mesh) const } } +int StructuredMesh::get_bin_from_indices(const int* ijk) const +{ + switch (n_dimension_) { + case 1: + return ijk[0] - 1; + case 2: + return (ijk[1] - 1)*shape_[0] + ijk[0] - 1; + case 3: + return ((ijk[2] - 1)*shape_[1] + (ijk[1] - 1))*shape_[0] + ijk[0] - 1; + default: + throw std::runtime_error{"Invalid number of mesh dimensions"}; + } +} + //============================================================================== // RegularMesh implementation //============================================================================== @@ -210,20 +223,6 @@ int RegularMesh::get_bin(Position r) const return get_bin_from_indices(ijk.data()); } -int RegularMesh::get_bin_from_indices(const int* ijk) const -{ - switch (n_dimension_) { - case 1: - return ijk[0] - 1; - case 2: - return (ijk[1] - 1)*shape_[0] + ijk[0] - 1; - case 3: - return ((ijk[2] - 1)*shape_[1] + (ijk[1] - 1))*shape_[0] + ijk[0] - 1; - default: - throw std::runtime_error{"Invalid number of mesh dimensions"}; - } -} - int RegularMesh::get_index_in_direction(Position r, int i) const { return std::ceil((r[i] - lower_left_[i]) / width_[i]); @@ -1174,11 +1173,6 @@ int RectilinearMesh::get_bin(Position r) const return get_bin_from_indices(ijk); } -int RectilinearMesh::get_bin_from_indices(const int* ijk) const -{ - return ((ijk[2] - 1)*shape_[1] + (ijk[1] - 1))*shape_[0] + ijk[0] - 1; -} - int RectilinearMesh::get_index_in_direction(Position r, int i) const { return lower_bound_index(grid_[i].begin(), grid_[i].end(), r[i]) + 1; From 45b7dfb5a03b0e48620a7c1ac376e2dce57fca84 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Thu, 15 Oct 2020 16:26:36 -0500 Subject: [PATCH 13/23] Move implementation of get_indices_from_bin to StructuredMesh base class. Refs #1695 --- include/openmc/mesh.h | 6 +----- src/mesh.cpp | 35 ++++++++++++++--------------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index cfcc137e8..9f1b80c03 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -122,7 +122,7 @@ public: // //! \param[in] bin Mesh bin //! \param[out] ijk Mesh indices - virtual void get_indices_from_bin(int bin, int* ijk) const = 0; + virtual void get_indices_from_bin(int bin, int* ijk) const; //! Get mesh index in a particular direction //! @@ -160,8 +160,6 @@ public: int get_bin(Position r) const override; - void get_indices_from_bin(int bin, int* ijk) const override; - int get_index_in_direction(Position r, int i) const override; int n_bins() const override; @@ -219,8 +217,6 @@ public: int get_bin(Position r) const override; - void get_indices_from_bin(int bin, int* ijk) const override; - int get_index_in_direction(Position r, int i) const override; int n_bins() const override; diff --git a/src/mesh.cpp b/src/mesh.cpp index fd5b30466..17a87c47d 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -126,6 +126,20 @@ int StructuredMesh::get_bin_from_indices(const int* ijk) const } } +void StructuredMesh::get_indices_from_bin(int bin, int* ijk) const +{ + if (n_dimension_ == 1) { + ijk[0] = bin + 1; + } else if (n_dimension_ == 2) { + ijk[0] = bin % shape_[0] + 1; + ijk[1] = bin / shape_[0] + 1; + } else if (n_dimension_ == 3) { + ijk[0] = bin % shape_[0] + 1; + ijk[1] = (bin % (shape_[0] * shape_[1])) / shape_[0] + 1; + ijk[2] = bin / (shape_[0] * shape_[1]) + 1; + } +} + //============================================================================== // RegularMesh implementation //============================================================================== @@ -228,20 +242,6 @@ int RegularMesh::get_index_in_direction(Position r, int i) const return std::ceil((r[i] - lower_left_[i]) / width_[i]); } -void RegularMesh::get_indices_from_bin(int bin, int* ijk) const -{ - if (n_dimension_ == 1) { - ijk[0] = bin + 1; - } else if (n_dimension_ == 2) { - ijk[0] = bin % shape_[0] + 1; - ijk[1] = bin / shape_[0] + 1; - } else if (n_dimension_ == 3) { - ijk[0] = bin % shape_[0] + 1; - ijk[1] = (bin % (shape_[0] * shape_[1])) / shape_[0] + 1; - ijk[2] = bin / (shape_[0] * shape_[1]) + 1; - } -} - int RegularMesh::n_bins() const { int n_bins = 1; @@ -1178,13 +1178,6 @@ int RectilinearMesh::get_index_in_direction(Position r, int i) const return lower_bound_index(grid_[i].begin(), grid_[i].end(), r[i]) + 1; } -void RectilinearMesh::get_indices_from_bin(int bin, int* ijk) const -{ - ijk[0] = bin % shape_[0] + 1; - ijk[1] = (bin % (shape_[0] * shape_[1])) / shape_[0] + 1; - ijk[2] = bin / (shape_[0] * shape_[1]) + 1; -} - int RectilinearMesh::n_bins() const { return xt::prod(shape_)(); From bcc072e0a8774f2cda8e3708ec73cba6631615d4 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Thu, 15 Oct 2020 16:57:23 -0500 Subject: [PATCH 14/23] Move intersects method up to base class and combine the functionality using new get_index_in_direction function. Refs #1695 --- include/openmc/mesh.h | 40 ++- src/mesh.cpp | 608 +++++++++++++++++------------------------- 2 files changed, 264 insertions(+), 384 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 9f1b80c03..e619c4370 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -126,9 +126,17 @@ public: //! Get mesh index in a particular direction //! - //! \param[in] r Position to get index for + //! \param[in] r Coordinate to get index for //! \param[in] i Direction index - virtual int get_index_in_direction(Position r, int i) const = 0; + virtual int get_index_in_direction(double r, int i) const = 0; + + //! Check where a line segment intersects the mesh and if it intersects at all + // + //! \param[in,out] r0 In: starting position, out: intersection point + //! \param[in] r1 Ending position + //! \param[out] ijk Indices of the mesh bin containing the intersection point + //! \return Whether the line segment connecting r0 and r1 intersects mesh + virtual bool intersects(Position& r0, Position r1, int* ijk) const; //! Get a label for the mesh bin std::string bin_label(int bin) const override; @@ -137,6 +145,11 @@ public: xt::xtensor lower_left_; //!< Lower-left coordinates of mesh xt::xtensor upper_right_; //!< Upper-right coordinates of mesh xt::xtensor shape_; //!< Number of mesh elements in each dimension + +protected: + virtual bool intersects_1d(Position& r0, Position r1, int* ijk) const; + virtual bool intersects_2d(Position& r0, Position r1, int* ijk) const; + virtual bool intersects_3d(Position& r0, Position r1, int* ijk) const; }; //============================================================================== @@ -173,14 +186,6 @@ public: // New methods - //! Check where a line segment intersects the mesh and if it intersects at all - // - //! \param[in,out] r0 In: starting position, out: intersection point - //! \param[in] r1 Ending position - //! \param[out] ijk Indices of the mesh bin containing the intersection point - //! \return Whether the line segment connecting r0 and r1 intersects mesh - bool intersects(Position& r0, Position r1, int* ijk) const; - //! Count number of bank sites in each mesh bin / energy bin // //! \param[in] bank Array of bank sites @@ -193,11 +198,6 @@ public: double volume_frac_; //!< Volume fraction of each mesh element xt::xtensor width_; //!< Width of each mesh element - -private: - bool intersects_1d(Position& r0, Position r1, int* ijk) const; - bool intersects_2d(Position& r0, Position r1, int* ijk) const; - bool intersects_3d(Position& r0, Position r1, int* ijk) const; }; @@ -228,16 +228,6 @@ public: void to_hdf5(hid_t group) const override; - // New methods - - //! Check where a line segment intersects the mesh and if it intersects at all - // - //! \param[in,out] r0 In: starting position, out: intersection point - //! \param[in] r1 Ending position - //! \param[out] ijk Indices of the mesh bin containing the intersection point - //! \return Whether the line segment connecting r0 and r1 intersects mesh - bool intersects(Position& r0, Position r1, int* ijk) const; - private: std::vector> grid_; }; diff --git a/src/mesh.cpp b/src/mesh.cpp index 17a87c47d..c4158df23 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -106,7 +106,7 @@ void StructuredMesh::get_indices(Position r, int* ijk, bool* in_mesh) const { *in_mesh = true; for (int i = 0; i < n_dimension_; ++i) { - ijk[i] = get_index_in_direction(r, i); + ijk[i] = get_index_in_direction(r[i], i); if (ijk[i] < 1 || ijk[i] > shape_[i]) *in_mesh = false; } @@ -140,6 +140,250 @@ void StructuredMesh::get_indices_from_bin(int bin, int* ijk) const } } +bool StructuredMesh::intersects(Position& r0, Position r1, int* ijk) const +{ + switch(n_dimension_) { + case 1: + return intersects_1d(r0, r1, ijk); + case 2: + return intersects_2d(r0, r1, ijk); + case 3: + return intersects_3d(r0, r1, ijk); + default: + throw std::runtime_error{"Invalid number of mesh dimensions."}; + } +} + +bool StructuredMesh::intersects_1d(Position& r0, Position r1, int* ijk) const +{ + // Copy coordinates of starting point + double x0 = r0.x; + double y0 = r0.y; + double z0 = r0.z; + + // Copy coordinates of ending point + double x1 = r1.x; + double y1 = r1.y; + double z1 = r1.z; + + // Copy coordinates of mesh lower_left and upper_right + double xm0 = lower_left_[0]; + double xm1 = upper_right_[0]; + + double min_dist = INFTY; + + // Check if line intersects left surface -- calculate the intersection point + // (y,z) + if ((x0 < xm0 && x1 > xm0) || (x0 > xm0 && x1 < xm0)) { + double yi = y0 + (xm0 - x0) * (y1 - y0) / (x1 - x0); + double zi = z0 + (xm0 - x0) * (z1 - z0) / (x1 - x0); + if (check_intersection_point(xm0, x0, yi, yi, zi, zi, r0, min_dist)) { + ijk[0] = 1; + } + } + + // Check if line intersects right surface -- calculate the intersection point + // (y,z) + if ((x0 < xm1 && x1 > xm1) || (x0 > xm1 && x1 < xm1)) { + double yi = y0 + (xm1 - x0) * (y1 - y0) / (x1 - x0); + double zi = z0 + (xm1 - x0) * (z1 - z0) / (x1 - x0); + if (check_intersection_point(xm1, x0, yi, yi, zi, zi, r0, min_dist)) { + ijk[0] = shape_[0]; + } + } + + return min_dist < INFTY; +} + +bool StructuredMesh::intersects_2d(Position& r0, Position r1, int* ijk) const +{ + // Copy coordinates of starting point + double x0 = r0.x; + double y0 = r0.y; + double z0 = r0.z; + + // Copy coordinates of ending point + double x1 = r1.x; + double y1 = r1.y; + double z1 = r1.z; + + // Copy coordinates of mesh lower_left + double xm0 = lower_left_[0]; + double ym0 = lower_left_[1]; + + // Copy coordinates of mesh upper_right + double xm1 = upper_right_[0]; + double ym1 = upper_right_[1]; + + double min_dist = INFTY; + + // Check if line intersects left surface -- calculate the intersection point + // (y,z) + if ((x0 < xm0 && x1 > xm0) || (x0 > xm0 && x1 < xm0)) { + double yi = y0 + (xm0 - x0) * (y1 - y0) / (x1 - x0); + double zi = z0 + (xm0 - x0) * (z1 - z0) / (x1 - x0); + if (yi >= ym0 && yi < ym1) { + if (check_intersection_point(xm0, x0, yi, y0, zi, zi, r0, min_dist)) { + ijk[0] = 1; + ijk[1] = get_index_in_direction(yi, 1); + } + } + } + + // Check if line intersects back surface -- calculate the intersection point + // (x,z) + if ((y0 < ym0 && y1 > ym0) || (y0 > ym0 && y1 < ym0)) { + double xi = x0 + (ym0 - y0) * (x1 - x0) / (y1 - y0); + double zi = z0 + (ym0 - y0) * (z1 - z0) / (y1 - y0); + if (xi >= xm0 && xi < xm1) { + if (check_intersection_point(xi, x0, ym0, y0, zi, zi, r0, min_dist)) { + ijk[0] = get_index_in_direction(xi, 0); + ijk[1] = 1; + } + } + } + + // Check if line intersects right surface -- calculate the intersection point + // (y,z) + if ((x0 < xm1 && x1 > xm1) || (x0 > xm1 && x1 < xm1)) { + double yi = y0 + (xm1 - x0) * (y1 - y0) / (x1 - x0); + double zi = z0 + (xm1 - x0) * (z1 - z0) / (x1 - x0); + if (yi >= ym0 && yi < ym1) { + if (check_intersection_point(xm1, x0, yi, y0, zi, zi, r0, min_dist)) { + ijk[0] = shape_[0]; + ijk[1] = get_index_in_direction(yi, 1); + } + } + } + + // Check if line intersects front surface -- calculate the intersection point + // (x,z) + if ((y0 < ym1 && y1 > ym1) || (y0 > ym1 && y1 < ym1)) { + double xi = x0 + (ym1 - y0) * (x1 - x0) / (y1 - y0); + double zi = z0 + (ym1 - y0) * (z1 - z0) / (y1 - y0); + if (xi >= xm0 && xi < xm1) { + if (check_intersection_point(xi, x0, ym1, y0, zi, zi, r0, min_dist)) { + ijk[0] = get_index_in_direction(xi, 0); + ijk[1] = shape_[1]; + } + } + } + + return min_dist < INFTY; +} + +bool StructuredMesh::intersects_3d(Position& r0, Position r1, int* ijk) const +{ + // Copy coordinates of starting point + double x0 = r0.x; + double y0 = r0.y; + double z0 = r0.z; + + // Copy coordinates of ending point + double x1 = r1.x; + double y1 = r1.y; + double z1 = r1.z; + + // Copy coordinates of mesh lower_left + double xm0 = lower_left_[0]; + double ym0 = lower_left_[1]; + double zm0 = lower_left_[2]; + + // Copy coordinates of mesh upper_right + double xm1 = upper_right_[0]; + double ym1 = upper_right_[1]; + double zm1 = upper_right_[2]; + + double min_dist = INFTY; + + // Check if line intersects left surface -- calculate the intersection point + // (y,z) + if ((x0 < xm0 && x1 > xm0) || (x0 > xm0 && x1 < xm0)) { + double yi = y0 + (xm0 - x0) * (y1 - y0) / (x1 - x0); + double zi = z0 + (xm0 - x0) * (z1 - z0) / (x1 - x0); + if (yi >= ym0 && yi < ym1 && zi >= zm0 && zi < zm1) { + if (check_intersection_point(xm0, x0, yi, y0, zi, z0, r0, min_dist)) { + ijk[0] = 1; + ijk[1] = get_index_in_direction(yi, 1); + ijk[2] = get_index_in_direction(zi, 2); + } + } + } + + // Check if line intersects back surface -- calculate the intersection point + // (x,z) + if ((y0 < ym0 && y1 > ym0) || (y0 > ym0 && y1 < ym0)) { + double xi = x0 + (ym0 - y0) * (x1 - x0) / (y1 - y0); + double zi = z0 + (ym0 - y0) * (z1 - z0) / (y1 - y0); + if (xi >= xm0 && xi < xm1 && zi >= zm0 && zi < zm1) { + if (check_intersection_point(xi, x0, ym0, y0, zi, z0, r0, min_dist)) { + ijk[0] = get_index_in_direction(xi, 0); + ijk[1] = 1; + ijk[2] = get_index_in_direction(zi, 2); + } + } + } + + // Check if line intersects bottom surface -- calculate the intersection + // point (x,y) + if ((z0 < zm0 && z1 > zm0) || (z0 > zm0 && z1 < zm0)) { + double xi = x0 + (zm0 - z0) * (x1 - x0) / (z1 - z0); + double yi = y0 + (zm0 - z0) * (y1 - y0) / (z1 - z0); + if (xi >= xm0 && xi < xm1 && yi >= ym0 && yi < ym1) { + if (check_intersection_point(xi, x0, yi, y0, zm0, z0, r0, min_dist)) { + ijk[0] = get_index_in_direction(xi, 0); + ijk[1] = get_index_in_direction(yi, 1); + ijk[2] = 1; + } + } + } + + // Check if line intersects right surface -- calculate the intersection point + // (y,z) + if ((x0 < xm1 && x1 > xm1) || (x0 > xm1 && x1 < xm1)) { + double yi = y0 + (xm1 - x0) * (y1 - y0) / (x1 - x0); + double zi = z0 + (xm1 - x0) * (z1 - z0) / (x1 - x0); + if (yi >= ym0 && yi < ym1 && zi >= zm0 && zi < zm1) { + if (check_intersection_point(xm1, x0, yi, y0, zi, z0, r0, min_dist)) { + ijk[0] = shape_[0]; + ijk[1] = get_index_in_direction(yi, 1); + ijk[2] = get_index_in_direction(zi, 2); + } + } + } + + // Check if line intersects front surface -- calculate the intersection point + // (x,z) + if ((y0 < ym1 && y1 > ym1) || (y0 > ym1 && y1 < ym1)) { + double xi = x0 + (ym1 - y0) * (x1 - x0) / (y1 - y0); + double zi = z0 + (ym1 - y0) * (z1 - z0) / (y1 - y0); + if (xi >= xm0 && xi < xm1 && zi >= zm0 && zi < zm1) { + if (check_intersection_point(xi, x0, ym1, y0, zi, z0, r0, min_dist)) { + ijk[0] = get_index_in_direction(xi, 0); + ijk[1] = shape_[1]; + ijk[2] = get_index_in_direction(zi, 2); + } + } + } + + // Check if line intersects top surface -- calculate the intersection point + // (x,y) + if ((z0 < zm1 && z1 > zm1) || (z0 > zm1 && z1 < zm1)) { + double xi = x0 + (zm1 - z0) * (x1 - x0) / (z1 - z0); + double yi = y0 + (zm1 - z0) * (y1 - y0) / (z1 - z0); + if (xi >= xm0 && xi < xm1 && yi >= ym0 && yi < ym1) { + if (check_intersection_point(xi, x0, yi, y0, zm1, z0, r0, min_dist)) { + ijk[0] = get_index_in_direction(xi, 0); + ijk[1] = get_index_in_direction(yi, 1); + ijk[2] = shape_[2]; + } + } + } + + return min_dist < INFTY; +} + + //============================================================================== // RegularMesh implementation //============================================================================== @@ -237,9 +481,9 @@ int RegularMesh::get_bin(Position r) const return get_bin_from_indices(ijk.data()); } -int RegularMesh::get_index_in_direction(Position r, int i) const +int RegularMesh::get_index_in_direction(double r, int i) const { - return std::ceil((r[i] - lower_left_[i]) / width_[i]); + return std::ceil((r - lower_left_[i]) / width_[i]); } int RegularMesh::n_bins() const @@ -254,249 +498,6 @@ int RegularMesh::n_surface_bins() const return 4 * n_dimension_ * n_bins(); } -bool RegularMesh::intersects(Position& r0, Position r1, int* ijk) const -{ - switch(n_dimension_) { - case 1: - return intersects_1d(r0, r1, ijk); - case 2: - return intersects_2d(r0, r1, ijk); - case 3: - return intersects_3d(r0, r1, ijk); - default: - throw std::runtime_error{"Invalid number of mesh dimensions."}; - } -} - -bool RegularMesh::intersects_1d(Position& r0, Position r1, int* ijk) const -{ - // Copy coordinates of starting point - double x0 = r0.x; - double y0 = r0.y; - double z0 = r0.z; - - // Copy coordinates of ending point - double x1 = r1.x; - double y1 = r1.y; - double z1 = r1.z; - - // Copy coordinates of mesh lower_left and upper_right - double xm0 = lower_left_[0]; - double xm1 = upper_right_[0]; - - double min_dist = INFTY; - - // Check if line intersects left surface -- calculate the intersection point - // (y,z) - if ((x0 < xm0 && x1 > xm0) || (x0 > xm0 && x1 < xm0)) { - double yi = y0 + (xm0 - x0) * (y1 - y0) / (x1 - x0); - double zi = z0 + (xm0 - x0) * (z1 - z0) / (x1 - x0); - if (check_intersection_point(xm0, x0, yi, yi, zi, zi, r0, min_dist)) { - ijk[0] = 1; - } - } - - // Check if line intersects right surface -- calculate the intersection point - // (y,z) - if ((x0 < xm1 && x1 > xm1) || (x0 > xm1 && x1 < xm1)) { - double yi = y0 + (xm1 - x0) * (y1 - y0) / (x1 - x0); - double zi = z0 + (xm1 - x0) * (z1 - z0) / (x1 - x0); - if (check_intersection_point(xm1, x0, yi, yi, zi, zi, r0, min_dist)) { - ijk[0] = shape_[0]; - } - } - - return min_dist < INFTY; -} - -bool RegularMesh::intersects_2d(Position& r0, Position r1, int* ijk) const -{ - // Copy coordinates of starting point - double x0 = r0.x; - double y0 = r0.y; - double z0 = r0.z; - - // Copy coordinates of ending point - double x1 = r1.x; - double y1 = r1.y; - double z1 = r1.z; - - // Copy coordinates of mesh lower_left - double xm0 = lower_left_[0]; - double ym0 = lower_left_[1]; - - // Copy coordinates of mesh upper_right - double xm1 = upper_right_[0]; - double ym1 = upper_right_[1]; - - double min_dist = INFTY; - - // Check if line intersects left surface -- calculate the intersection point - // (y,z) - if ((x0 < xm0 && x1 > xm0) || (x0 > xm0 && x1 < xm0)) { - double yi = y0 + (xm0 - x0) * (y1 - y0) / (x1 - x0); - double zi = z0 + (xm0 - x0) * (z1 - z0) / (x1 - x0); - if (yi >= ym0 && yi < ym1) { - if (check_intersection_point(xm0, x0, yi, y0, zi, zi, r0, min_dist)) { - ijk[0] = 1; - ijk[1] = std::ceil((yi - lower_left_[1]) / width_[1]); - } - } - } - - // Check if line intersects back surface -- calculate the intersection point - // (x,z) - if ((y0 < ym0 && y1 > ym0) || (y0 > ym0 && y1 < ym0)) { - double xi = x0 + (ym0 - y0) * (x1 - x0) / (y1 - y0); - double zi = z0 + (ym0 - y0) * (z1 - z0) / (y1 - y0); - if (xi >= xm0 && xi < xm1) { - if (check_intersection_point(xi, x0, ym0, y0, zi, zi, r0, min_dist)) { - ijk[0] = std::ceil((xi - lower_left_[0]) / width_[0]); - ijk[1] = 1; - } - } - } - - // Check if line intersects right surface -- calculate the intersection point - // (y,z) - if ((x0 < xm1 && x1 > xm1) || (x0 > xm1 && x1 < xm1)) { - double yi = y0 + (xm1 - x0) * (y1 - y0) / (x1 - x0); - double zi = z0 + (xm1 - x0) * (z1 - z0) / (x1 - x0); - if (yi >= ym0 && yi < ym1) { - if (check_intersection_point(xm1, x0, yi, y0, zi, zi, r0, min_dist)) { - ijk[0] = shape_[0]; - ijk[1] = std::ceil((yi - lower_left_[1]) / width_[1]); - } - } - } - - // Check if line intersects front surface -- calculate the intersection point - // (x,z) - if ((y0 < ym1 && y1 > ym1) || (y0 > ym1 && y1 < ym1)) { - double xi = x0 + (ym1 - y0) * (x1 - x0) / (y1 - y0); - double zi = z0 + (ym1 - y0) * (z1 - z0) / (y1 - y0); - if (xi >= xm0 && xi < xm1) { - if (check_intersection_point(xi, x0, ym1, y0, zi, zi, r0, min_dist)) { - ijk[0] = std::ceil((xi - lower_left_[0]) / width_[0]); - ijk[1] = shape_[1]; - } - } - } - - return min_dist < INFTY; -} - -bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const -{ - // Copy coordinates of starting point - double x0 = r0.x; - double y0 = r0.y; - double z0 = r0.z; - - // Copy coordinates of ending point - double x1 = r1.x; - double y1 = r1.y; - double z1 = r1.z; - - // Copy coordinates of mesh lower_left - double xm0 = lower_left_[0]; - double ym0 = lower_left_[1]; - double zm0 = lower_left_[2]; - - // Copy coordinates of mesh upper_right - double xm1 = upper_right_[0]; - double ym1 = upper_right_[1]; - double zm1 = upper_right_[2]; - - double min_dist = INFTY; - - // Check if line intersects left surface -- calculate the intersection point - // (y,z) - if ((x0 < xm0 && x1 > xm0) || (x0 > xm0 && x1 < xm0)) { - double yi = y0 + (xm0 - x0) * (y1 - y0) / (x1 - x0); - double zi = z0 + (xm0 - x0) * (z1 - z0) / (x1 - x0); - if (yi >= ym0 && yi < ym1 && zi >= zm0 && zi < zm1) { - if (check_intersection_point(xm0, x0, yi, y0, zi, z0, r0, min_dist)) { - ijk[0] = 1; - ijk[1] = std::ceil((yi - lower_left_[1]) / width_[1]); - ijk[2] = std::ceil((zi - lower_left_[2]) / width_[2]); - } - } - } - - // Check if line intersects back surface -- calculate the intersection point - // (x,z) - if ((y0 < ym0 && y1 > ym0) || (y0 > ym0 && y1 < ym0)) { - double xi = x0 + (ym0 - y0) * (x1 - x0) / (y1 - y0); - double zi = z0 + (ym0 - y0) * (z1 - z0) / (y1 - y0); - if (xi >= xm0 && xi < xm1 && zi >= zm0 && zi < zm1) { - if (check_intersection_point(xi, x0, ym0, y0, zi, z0, r0, min_dist)) { - ijk[0] = std::ceil((xi - lower_left_[0]) / width_[0]); - ijk[1] = 1; - ijk[2] = std::ceil((zi - lower_left_[2]) / width_[2]); - } - } - } - - // Check if line intersects bottom surface -- calculate the intersection - // point (x,y) - if ((z0 < zm0 && z1 > zm0) || (z0 > zm0 && z1 < zm0)) { - double xi = x0 + (zm0 - z0) * (x1 - x0) / (z1 - z0); - double yi = y0 + (zm0 - z0) * (y1 - y0) / (z1 - z0); - if (xi >= xm0 && xi < xm1 && yi >= ym0 && yi < ym1) { - if (check_intersection_point(xi, x0, yi, y0, zm0, z0, r0, min_dist)) { - ijk[0] = std::ceil((xi - lower_left_[0]) / width_[0]); - ijk[1] = std::ceil((yi - lower_left_[1]) / width_[1]); - ijk[2] = 1; - } - } - } - - // Check if line intersects right surface -- calculate the intersection point - // (y,z) - if ((x0 < xm1 && x1 > xm1) || (x0 > xm1 && x1 < xm1)) { - double yi = y0 + (xm1 - x0) * (y1 - y0) / (x1 - x0); - double zi = z0 + (xm1 - x0) * (z1 - z0) / (x1 - x0); - if (yi >= ym0 && yi < ym1 && zi >= zm0 && zi < zm1) { - if (check_intersection_point(xm1, x0, yi, y0, zi, z0, r0, min_dist)) { - ijk[0] = shape_[0]; - ijk[1] = std::ceil((yi - lower_left_[1]) / width_[1]); - ijk[2] = std::ceil((zi - lower_left_[2]) / width_[2]); - } - } - } - - // Check if line intersects front surface -- calculate the intersection point - // (x,z) - if ((y0 < ym1 && y1 > ym1) || (y0 > ym1 && y1 < ym1)) { - double xi = x0 + (ym1 - y0) * (x1 - x0) / (y1 - y0); - double zi = z0 + (ym1 - y0) * (z1 - z0) / (y1 - y0); - if (xi >= xm0 && xi < xm1 && zi >= zm0 && zi < zm1) { - if (check_intersection_point(xi, x0, ym1, y0, zi, z0, r0, min_dist)) { - ijk[0] = std::ceil((xi - lower_left_[0]) / width_[0]); - ijk[1] = shape_[1]; - ijk[2] = std::ceil((zi - lower_left_[2]) / width_[2]); - } - } - } - - // Check if line intersects top surface -- calculate the intersection point - // (x,y) - if ((z0 < zm1 && z1 > zm1) || (z0 > zm1 && z1 < zm1)) { - double xi = x0 + (zm1 - z0) * (x1 - x0) / (z1 - z0); - double yi = y0 + (zm1 - z0) * (y1 - y0) / (z1 - z0); - if (xi >= xm0 && xi < xm1 && yi >= ym0 && yi < ym1) { - if (check_intersection_point(xi, x0, yi, y0, zm1, z0, r0, min_dist)) { - ijk[0] = std::ceil((xi - lower_left_[0]) / width_[0]); - ijk[1] = std::ceil((yi - lower_left_[1]) / width_[1]); - ijk[2] = shape_[2]; - } - } - } - - return min_dist < INFTY; -} - void RegularMesh::bins_crossed(const Particle& p, std::vector& bins, std::vector& lengths) const { @@ -1173,9 +1174,9 @@ int RectilinearMesh::get_bin(Position r) const return get_bin_from_indices(ijk); } -int RectilinearMesh::get_index_in_direction(Position r, int i) const +int RectilinearMesh::get_index_in_direction(double r, int i) const { - return lower_bound_index(grid_[i].begin(), grid_[i].end(), r[i]) + 1; + return lower_bound_index(grid_[i].begin(), grid_[i].end(), r) + 1; } int RectilinearMesh::n_bins() const @@ -1230,117 +1231,6 @@ void RectilinearMesh::to_hdf5(hid_t group) const close_group(mesh_group); } -bool RectilinearMesh::intersects(Position& r0, Position r1, int* ijk) const -{ - // Copy coordinates of starting point - double x0 = r0.x; - double y0 = r0.y; - double z0 = r0.z; - - // Copy coordinates of ending point - double x1 = r1.x; - double y1 = r1.y; - double z1 = r1.z; - - // Copy coordinates of mesh lower_left - double xm0 = grid_[0].front(); - double ym0 = grid_[1].front(); - double zm0 = grid_[2].front(); - - // Copy coordinates of mesh upper_right - double xm1 = grid_[0].back(); - double ym1 = grid_[1].back(); - double zm1 = grid_[2].back(); - - double min_dist = INFTY; - - // Check if line intersects left surface -- calculate the intersection point - // (y,z) - if ((x0 < xm0 && x1 > xm0) || (x0 > xm0 && x1 < xm0)) { - double yi = y0 + (xm0 - x0) * (y1 - y0) / (x1 - x0); - double zi = z0 + (xm0 - x0) * (z1 - z0) / (x1 - x0); - if (yi >= ym0 && yi < ym1 && zi >= zm0 && zi < zm1) { - if (check_intersection_point(xm0, x0, yi, y0, zi, z0, r0, min_dist)) { - ijk[0] = 1; - ijk[1] = lower_bound_index(grid_[1].begin(), grid_[1].end(), yi) + 1; - ijk[2] = lower_bound_index(grid_[2].begin(), grid_[2].end(), zi) + 1; - } - } - } - - // Check if line intersects back surface -- calculate the intersection point - // (x,z) - if ((y0 < ym0 && y1 > ym0) || (y0 > ym0 && y1 < ym0)) { - double xi = x0 + (ym0 - y0) * (x1 - x0) / (y1 - y0); - double zi = z0 + (ym0 - y0) * (z1 - z0) / (y1 - y0); - if (xi >= xm0 && xi < xm1 && zi >= zm0 && zi < zm1) { - if (check_intersection_point(xi, x0, ym0, y0, zi, z0, r0, min_dist)) { - ijk[0] = lower_bound_index(grid_[0].begin(), grid_[0].end(), xi) + 1; - ijk[1] = 1; - ijk[2] = lower_bound_index(grid_[2].begin(), grid_[2].end(), zi) + 1; - } - } - } - - // Check if line intersects bottom surface -- calculate the intersection - // point (x,y) - if ((z0 < zm0 && z1 > zm0) || (z0 > zm0 && z1 < zm0)) { - double xi = x0 + (zm0 - z0) * (x1 - x0) / (z1 - z0); - double yi = y0 + (zm0 - z0) * (y1 - y0) / (z1 - z0); - if (xi >= xm0 && xi < xm1 && yi >= ym0 && yi < ym1) { - if (check_intersection_point(xi, x0, yi, y0, zm0, z0, r0, min_dist)) { - ijk[0] = lower_bound_index(grid_[0].begin(), grid_[0].end(), xi) + 1; - ijk[1] = lower_bound_index(grid_[1].begin(), grid_[1].end(), yi) + 1; - ijk[2] = 1; - } - } - } - - // Check if line intersects right surface -- calculate the intersection point - // (y,z) - if ((x0 < xm1 && x1 > xm1) || (x0 > xm1 && x1 < xm1)) { - double yi = y0 + (xm1 - x0) * (y1 - y0) / (x1 - x0); - double zi = z0 + (xm1 - x0) * (z1 - z0) / (x1 - x0); - if (yi >= ym0 && yi < ym1 && zi >= zm0 && zi < zm1) { - if (check_intersection_point(xm1, x0, yi, y0, zi, z0, r0, min_dist)) { - ijk[0] = shape_[0]; - ijk[1] = lower_bound_index(grid_[1].begin(), grid_[1].end(), yi) + 1; - ijk[2] = lower_bound_index(grid_[2].begin(), grid_[2].end(), zi) + 1; - } - } - } - - // Check if line intersects front surface -- calculate the intersection point - // (x,z) - if ((y0 < ym1 && y1 > ym1) || (y0 > ym1 && y1 < ym1)) { - double xi = x0 + (ym1 - y0) * (x1 - x0) / (y1 - y0); - double zi = z0 + (ym1 - y0) * (z1 - z0) / (y1 - y0); - if (xi >= xm0 && xi < xm1 && zi >= zm0 && zi < zm1) { - if (check_intersection_point(xi, x0, ym1, y0, zi, z0, r0, min_dist)) { - ijk[0] = lower_bound_index(grid_[0].begin(), grid_[0].end(), xi) + 1; - ijk[1] = shape_[1]; - ijk[2] = lower_bound_index(grid_[2].begin(), grid_[2].end(), zi) + 1; - } - } - } - - // Check if line intersects top surface -- calculate the intersection point - // (x,y) - if ((z0 < zm1 && z1 > zm1) || (z0 > zm1 && z1 < zm1)) { - double xi = x0 + (zm1 - z0) * (x1 - x0) / (z1 - z0); - double yi = y0 + (zm1 - z0) * (y1 - y0) / (z1 - z0); - if (xi >= xm0 && xi < xm1 && yi >= ym0 && yi < ym1) { - if (check_intersection_point(xi, x0, yi, y0, zm1, z0, r0, min_dist)) { - ijk[0] = lower_bound_index(grid_[0].begin(), grid_[0].end(), xi) + 1; - ijk[1] = lower_bound_index(grid_[1].begin(), grid_[1].end(), yi) + 1; - ijk[2] = shape_[2]; - } - } - } - - return min_dist < INFTY; -} - //============================================================================== // Helper functions for the C API //============================================================================== From 9a36ea405aeeed940152882199219cdf6a35207c Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Thu, 15 Oct 2020 17:14:32 -0500 Subject: [PATCH 15/23] Move get_bin implementation up to StructuredMesh base class. Refs #1695 --- include/openmc/mesh.h | 10 ++++------ src/mesh.cpp | 36 ++++++++++++------------------------ 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index e619c4370..98f0e7a83 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -105,6 +105,8 @@ public: StructuredMesh(pugi::xml_node node) : Mesh {node} {}; virtual ~StructuredMesh() = default; + int get_bin(Position r) const override; + //! Get bin given mesh indices // //! \param[in] Array of mesh indices @@ -171,9 +173,7 @@ public: void surface_bins_crossed(const Particle& p, std::vector& bins) const override; - int get_bin(Position r) const override; - - int get_index_in_direction(Position r, int i) const override; + int get_index_in_direction(double r, int i) const override; int n_bins() const override; @@ -215,9 +215,7 @@ public: void surface_bins_crossed(const Particle& p, std::vector& bins) const override; - int get_bin(Position r) const override; - - int get_index_in_direction(Position r, int i) const override; + int get_index_in_direction(double r, int i) const override; int n_bins() const override; diff --git a/src/mesh.cpp b/src/mesh.cpp index c4158df23..68a116e3a 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -140,6 +140,18 @@ void StructuredMesh::get_indices_from_bin(int bin, int* ijk) const } } +int StructuredMesh::get_bin(Position r) const +{ + // Determine indices + std::vector ijk(n_dimension_); + bool in_mesh; + get_indices(r, ijk.data(), &in_mesh); + if (!in_mesh) return -1; + + // Convert indices to bin + return get_bin_from_indices(ijk.data()); +} + bool StructuredMesh::intersects(Position& r0, Position r1, int* ijk) const { switch(n_dimension_) { @@ -469,18 +481,6 @@ RegularMesh::RegularMesh(pugi::xml_node node) volume_frac_ = 1.0/xt::prod(shape_)(); } -int RegularMesh::get_bin(Position r) const -{ - // Determine indices - std::vector ijk(n_dimension_); - bool in_mesh; - get_indices(r, ijk.data(), &in_mesh); - if (!in_mesh) return -1; - - // Convert indices to bin - return get_bin_from_indices(ijk.data()); -} - int RegularMesh::get_index_in_direction(double r, int i) const { return std::ceil((r - lower_left_[i]) / width_[i]); @@ -1162,18 +1162,6 @@ void RectilinearMesh::surface_bins_crossed(const Particle& p, } } -int RectilinearMesh::get_bin(Position r) const -{ - // Determine indices - int ijk[3]; - bool in_mesh; - get_indices(r, ijk, &in_mesh); - if (!in_mesh) return -1; - - // Convert indices to bin - return get_bin_from_indices(ijk); -} - int RectilinearMesh::get_index_in_direction(double r, int i) const { return lower_bound_index(grid_[i].begin(), grid_[i].end(), r) + 1; From 008a73fa361308987e7141dcdb98be327bbc5b2d Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Thu, 15 Oct 2020 17:18:32 -0500 Subject: [PATCH 16/23] Move n_bins and n_surface_bins implementations to StructuredMesh base class. Refs #1695 --- include/openmc/mesh.h | 12 ++++-------- src/mesh.cpp | 32 ++++++++++---------------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 98f0e7a83..f3f84ac6b 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -107,6 +107,10 @@ public: int get_bin(Position r) const override; + int n_bins() const override; + + int n_surface_bins() const override; + //! Get bin given mesh indices // //! \param[in] Array of mesh indices @@ -175,10 +179,6 @@ public: int get_index_in_direction(double r, int i) const override; - int n_bins() const override; - - int n_surface_bins() const override; - std::pair, std::vector> plot(Position plot_ll, Position plot_ur) const override; @@ -217,10 +217,6 @@ public: int get_index_in_direction(double r, int i) const override; - int n_bins() const override; - - int n_surface_bins() const override; - std::pair, std::vector> plot(Position plot_ll, Position plot_ur) const override; diff --git a/src/mesh.cpp b/src/mesh.cpp index 68a116e3a..ca7eb53ab 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -152,6 +152,16 @@ int StructuredMesh::get_bin(Position r) const return get_bin_from_indices(ijk.data()); } +int StructuredMesh::n_bins() const +{ + return xt::prod(shape_)(); +} + +int StructuredMesh::n_surface_bins() const +{ + return 4 * n_dimension_ * n_bins(); +} + bool StructuredMesh::intersects(Position& r0, Position r1, int* ijk) const { switch(n_dimension_) { @@ -486,18 +496,6 @@ int RegularMesh::get_index_in_direction(double r, int i) const return std::ceil((r - lower_left_[i]) / width_[i]); } -int RegularMesh::n_bins() const -{ - int n_bins = 1; - for (auto dim : shape_) n_bins *= dim; - return n_bins; -} - -int RegularMesh::n_surface_bins() const -{ - return 4 * n_dimension_ * n_bins(); -} - void RegularMesh::bins_crossed(const Particle& p, std::vector& bins, std::vector& lengths) const { @@ -1167,16 +1165,6 @@ int RectilinearMesh::get_index_in_direction(double r, int i) const return lower_bound_index(grid_[i].begin(), grid_[i].end(), r) + 1; } -int RectilinearMesh::n_bins() const -{ - return xt::prod(shape_)(); -} - -int RectilinearMesh::n_surface_bins() const -{ - return 4 * n_dimension_ * n_bins(); -} - std::pair, std::vector> RectilinearMesh::plot(Position plot_ll, Position plot_ur) const { From 1207c901be203110b6bc6b0a5b8b791e10a0a1b9 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Thu, 15 Oct 2020 18:01:02 -0500 Subject: [PATCH 17/23] Move bins_crossed implementation into StructuredMesh base class. Refs #1695 --- include/openmc/mesh.h | 29 +++- src/mesh.cpp | 318 ++++++++++++++++-------------------------- 2 files changed, 141 insertions(+), 206 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index f3f84ac6b..5a8367b8b 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -111,6 +111,9 @@ public: int n_surface_bins() const override; + void bins_crossed(const Particle& p, std::vector& bins, + std::vector& lengths) const override; + //! Get bin given mesh indices // //! \param[in] Array of mesh indices @@ -144,6 +147,18 @@ public: //! \return Whether the line segment connecting r0 and r1 intersects mesh virtual bool intersects(Position& r0, Position r1, int* ijk) const; + //! Get the coordinate for the mesh grid boundary in the positive direction + //! + //! \param[in] ijk Array of mesh indices + //! \param[in] i Direction index + virtual double positive_grid_boundary(int* ijk, int i) const = 0; + + //! Get the coordinate for the mesh grid boundary in the negative direction + //! + //! \param[in] ijk Array of mesh indices + //! \param[in] i Direction index + virtual double negative_grid_boundary(int* ijk, int i) const = 0; + //! Get a label for the mesh bin std::string bin_label(int bin) const override; @@ -171,14 +186,15 @@ public: // Overriden methods - void bins_crossed(const Particle& p, std::vector& bins, - std::vector& lengths) const override; - void surface_bins_crossed(const Particle& p, std::vector& bins) const override; int get_index_in_direction(double r, int i) const override; + double positive_grid_boundary(int* ijk, int i) const override; + + double negative_grid_boundary(int* ijk, int i) const override; + std::pair, std::vector> plot(Position plot_ll, Position plot_ur) const override; @@ -209,14 +225,15 @@ public: // Overriden methods - void bins_crossed(const Particle& p, std::vector& bins, - std::vector& lengths) const override; - void surface_bins_crossed(const Particle& p, std::vector& bins) const override; int get_index_in_direction(double r, int i) const override; + double positive_grid_boundary(int* ijk, int i) const override; + + double negative_grid_boundary(int* ijk, int i) const override; + std::pair, std::vector> plot(Position plot_ll, Position plot_ur) const override; diff --git a/src/mesh.cpp b/src/mesh.cpp index ca7eb53ab..d3b671263 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -405,99 +405,7 @@ bool StructuredMesh::intersects_3d(Position& r0, Position r1, int* ijk) const return min_dist < INFTY; } - -//============================================================================== -// RegularMesh implementation -//============================================================================== - -RegularMesh::RegularMesh(pugi::xml_node node) - : StructuredMesh {node} -{ - // Determine number of dimensions for mesh - if (check_for_node(node, "dimension")) { - shape_ = get_node_xarray(node, "dimension"); - int n = n_dimension_ = shape_.size(); - if (n != 1 && n != 2 && n != 3) { - fatal_error("Mesh must be one, two, or three dimensions."); - } - - // Check that dimensions are all greater than zero - if (xt::any(shape_ <= 0)) { - fatal_error("All entries on the element for a tally " - "mesh must be positive."); - } - } else { - fatal_error("Must specify on a mesh."); - } - - // Check for lower-left coordinates - if (check_for_node(node, "lower_left")) { - // Read mesh lower-left corner location - lower_left_ = get_node_xarray(node, "lower_left"); - - // Make sure lower_left and dimension match - if (n_dimension_ != lower_left_.size()) { - fatal_error("Number of entries on must be the same " - "as the number of entries on ."); - } - } else { - fatal_error("Must specify on a mesh."); - } - - if (check_for_node(node, "width")) { - // Make sure both upper-right or width were specified - if (check_for_node(node, "upper_right")) { - fatal_error("Cannot specify both and on a mesh."); - } - - width_ = get_node_xarray(node, "width"); - - // Check to ensure width has same dimensions - if (n_dimension_ != width_.size()) { - fatal_error("Number of entries on must be the same as " - "the number of entries on ."); - } - - // Check for negative widths - if (xt::any(width_ < 0.0)) { - fatal_error("Cannot have a negative on a tally mesh."); - } - - // Set width and upper right coordinate - upper_right_ = xt::eval(lower_left_ + shape_ * width_); - - } else if (check_for_node(node, "upper_right")) { - upper_right_ = get_node_xarray(node, "upper_right"); - - // Check to ensure upper right has same dimensions - if (n_dimension_ != upper_right_.size()) { - fatal_error("Number of entries on must be the " - "same as the number of entries on ."); - } - - // Check that upper-right is above lower-left - if (xt::any(upper_right_ < lower_left_)) { - fatal_error("The coordinates must be greater than " - "the coordinates on a tally mesh."); - } - - // Set width - width_ = xt::eval((upper_right_ - lower_left_) / shape_); - } else { - fatal_error("Must specify either and on a mesh."); - } - - // Set volume fraction - volume_frac_ = 1.0/xt::prod(shape_)(); -} - -int RegularMesh::get_index_in_direction(double r, int i) const -{ - return std::ceil((r - lower_left_[i]) / width_[i]); -} - -void RegularMesh::bins_crossed(const Particle& p, std::vector& bins, - std::vector& lengths) const +void StructuredMesh::bins_crossed(const Particle& p, std::vector& bins, { // ======================================================================== // Determine where the track intersects the mesh and if it intersects at all. @@ -565,10 +473,10 @@ void RegularMesh::bins_crossed(const Particle& p, std::vector& bins, if (std::fabs(u[k]) < FP_PRECISION) { d[k] = INFTY; } else if (u[k] > 0) { - double xyz_cross = lower_left_[k] + ijk0[k] * width_[k]; + double xyz_cross = positive_grid_boundary(ijk0.data(), k); d[k] = (xyz_cross - r0[k]) / u[k]; } else { - double xyz_cross = lower_left_[k] + (ijk0[k] - 1) * width_[k]; + double xyz_cross = negative_grid_boundary(ijk0.data(), k); d[k] = (xyz_cross - r0[k]) / u[k]; } } @@ -602,6 +510,111 @@ void RegularMesh::bins_crossed(const Particle& p, std::vector& bins, } } + +//============================================================================== +// RegularMesh implementation +//============================================================================== + +RegularMesh::RegularMesh(pugi::xml_node node) + : StructuredMesh {node} +{ + // Determine number of dimensions for mesh + if (check_for_node(node, "dimension")) { + shape_ = get_node_xarray(node, "dimension"); + int n = n_dimension_ = shape_.size(); + if (n != 1 && n != 2 && n != 3) { + fatal_error("Mesh must be one, two, or three dimensions."); + } + + // Check that dimensions are all greater than zero + if (xt::any(shape_ <= 0)) { + fatal_error("All entries on the element for a tally " + "mesh must be positive."); + } + } + + // Check for lower-left coordinates + if (check_for_node(node, "lower_left")) { + // Read mesh lower-left corner location + lower_left_ = get_node_xarray(node, "lower_left"); + } else { + fatal_error("Must specify on a mesh."); + } + + if (check_for_node(node, "width")) { + // Make sure both upper-right or width were specified + if (check_for_node(node, "upper_right")) { + fatal_error("Cannot specify both and on a mesh."); + } + + width_ = get_node_xarray(node, "width"); + + // Check to ensure width has same dimensions + auto n = width_.size(); + if (n != lower_left_.size()) { + fatal_error("Number of entries on must be the same as " + "the number of entries on ."); + } + + // Check for negative widths + if (xt::any(width_ < 0.0)) { + fatal_error("Cannot have a negative on a tally mesh."); + } + + // Set width and upper right coordinate + upper_right_ = xt::eval(lower_left_ + shape_ * width_); + + } else if (check_for_node(node, "upper_right")) { + upper_right_ = get_node_xarray(node, "upper_right"); + + // Check to ensure width has same dimensions + auto n = upper_right_.size(); + if (n != lower_left_.size()) { + fatal_error("Number of entries on must be the " + "same as the number of entries on ."); + } + + // Check that upper-right is above lower-left + if (xt::any(upper_right_ < lower_left_)) { + fatal_error("The coordinates must be greater than " + "the coordinates on a tally mesh."); + } + + // Set width + if (shape_.size() > 0) { + width_ = xt::eval((upper_right_ - lower_left_) / shape_); + } + } else { + fatal_error("Must specify either and on a mesh."); + } + + // Make sure lower_left and dimension match + if (shape_.size() > 0) { + if (shape_.size() != lower_left_.size()) { + fatal_error("Number of entries on must be the same " + "as the number of entries on ."); + } + + // Set volume fraction + volume_frac_ = 1.0/xt::prod(shape_)(); + } +} + +int RegularMesh::get_index_in_direction(double r, int i) const +{ + return std::ceil((r - lower_left_[i]) / width_[i]); +} + +double RegularMesh::positive_grid_boundary(int* ijk, int i) const +{ + return lower_left_[i] + ijk[i] * width_[i]; +} + +double RegularMesh::negative_grid_boundary(int* ijk, int i) const +{ + return lower_left_[i] + (ijk[i] - 1) * width_[i]; +} + void RegularMesh::surface_bins_crossed(const Particle& p, std::vector& bins) const { @@ -640,9 +653,9 @@ void RegularMesh::surface_bins_crossed(const Particle& p, Position xyz_cross; for (int i = 0; i < n; ++i) { if (u[i] > 0.0) { - xyz_cross[i] = lower_left_[i] + ijk0[i] * width_[i]; + xyz_cross[i] = positive_grid_boundary(ijk0.data(), i); } else { - xyz_cross[i] = lower_left_[i] + (ijk0[i] - 1) * width_[i]; + xyz_cross[i] = negative_grid_boundary(ijk0.data(), i); } } @@ -887,109 +900,14 @@ RectilinearMesh::RectilinearMesh(pugi::xml_node node) upper_right_ = {grid_[0].back(), grid_[1].back(), grid_[2].back()}; } -void RectilinearMesh::bins_crossed(const Particle& p, std::vector& bins, - std::vector& lengths) const +double RectilinearMesh::positive_grid_boundary(int* ijk, int i) const { - // ======================================================================== - // Determine where the track intersects the mesh and if it intersects at all. + return grid_[i][ijk[i]]; +} - // Copy the starting and ending coordinates of the particle. - Position last_r {p.r_last_}; - Position r {p.r()}; - Direction u {p.u()}; - - // Compute the length of the entire track. - double total_distance = (r - last_r).norm(); - - // While determining if this track intersects the mesh, offset the starting - // and ending coords by a bit. This avoid finite-precision errors that can - // occur when the mesh surfaces coincide with lattice or geometric surfaces. - Position r0 = last_r + TINY_BIT*u; - Position r1 = r - TINY_BIT*u; - - // Determine the mesh indices for the starting and ending coords. - int ijk0[3], ijk1[3]; - bool start_in_mesh; - get_indices(r0, ijk0, &start_in_mesh); - bool end_in_mesh; - get_indices(r1, ijk1, &end_in_mesh); - - // Reset coordinates and check for a mesh intersection if necessary. - if (start_in_mesh) { - // The initial coords lie in the mesh, use those coords for tallying. - r0 = last_r; - } else { - // The initial coords do not lie in the mesh. Check to see if the particle - // eventually intersects the mesh and compute the relevant coords and - // indices. - if (!intersects(r0, r1, ijk0)) return; - } - r1 = r; - - // The TINY_BIT offsets above mean that the preceding logic cannot always find - // the correct ijk0 and ijk1 indices. For tracks shorter than 2*TINY_BIT, just - // assume the track lies in only one mesh bin. These tracks are very short so - // any error caused by this assumption will be small. It is important that - // ijk0 values are used rather than ijk1 because the previous logic guarantees - // ijk0 is a valid mesh bin. - if (total_distance < 2*TINY_BIT) { - for (int i = 0; i < 3; ++i) ijk1[i] = ijk0[i]; - } - - // ======================================================================== - // Find which mesh cells are traversed and the length of each traversal. - - while (true) { - if (std::equal(ijk0, ijk0+3, ijk1)) { - // The track ends in this cell. Use the particle end location rather - // than the mesh surface and stop iterating. - double distance = (r1 - r0).norm(); - bins.push_back(get_bin_from_indices(ijk0)); - lengths.push_back(distance / total_distance); - break; - } - - // The track exits this cell. Determine the distance to each mesh surface. - double d[3]; - for (int k = 0; k < 3; ++k) { - if (std::fabs(u[k]) < FP_PRECISION) { - d[k] = INFTY; - } else if (u[k] > 0) { - double xyz_cross = grid_[k][ijk0[k]]; - d[k] = (xyz_cross - r0[k]) / u[k]; - } else { - double xyz_cross = grid_[k][ijk0[k] - 1]; - d[k] = (xyz_cross - r0[k]) / u[k]; - } - } - - // Pick the closest mesh surface and append this traversal to the output. - auto j = std::min_element(d, d+3) - d; - double distance = d[j]; - bins.push_back(get_bin_from_indices(ijk0)); - lengths.push_back(distance / total_distance); - - // Translate to the oncoming mesh surface. - r0 += distance * u; - - // Increment the indices into the next mesh cell. - if (u[j] > 0.0) { - ++ijk0[j]; - } else { - --ijk0[j]; - } - - // If the next indices are invalid, then the track has left the mesh and - // we are done. - bool in_mesh = true; - for (int i = 0; i < 3; ++i) { - if (ijk0[i] < 1 || ijk0[i] > shape_[i]) { - in_mesh = false; - break; - } - } - if (!in_mesh) break; - } +double RectilinearMesh::negative_grid_boundary(int* ijk, int i) const +{ + return grid_[i][ijk[i] - 1]; } void RectilinearMesh::surface_bins_crossed(const Particle& p, @@ -1086,9 +1004,9 @@ void RectilinearMesh::surface_bins_crossed(const Particle& p, Position xyz_cross; for (int i = 0; i < 3; ++i) { if (u[i] > 0.0) { - xyz_cross[i] = grid_[i][ijk0[i]]; + xyz_cross[i] = positive_grid_boundary(ijk0, i); } else { - xyz_cross[i] = grid_[i][ijk0[i] - 1]; + xyz_cross[i] = negative_grid_boundary(ijk0, i); } } From 87c22dd4d498b6c28621c690b12d75da37fd1665 Mon Sep 17 00:00:00 2001 From: aprilnovak Date: Mon, 19 Oct 2020 16:19:28 -0500 Subject: [PATCH 18/23] Use arrays for ijk0, ijk1, and d in bins_crossed for slightly better performance. Refs #1695 --- src/mesh.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/mesh.cpp b/src/mesh.cpp index d3b671263..53279cc57 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -406,6 +406,7 @@ bool StructuredMesh::intersects_3d(Position& r0, Position r1, int* ijk) const } void StructuredMesh::bins_crossed(const Particle& p, std::vector& bins, + std::vector& lengths) const { // ======================================================================== // Determine where the track intersects the mesh and if it intersects at all. @@ -424,13 +425,18 @@ void StructuredMesh::bins_crossed(const Particle& p, std::vector& bins, Position r0 = last_r + TINY_BIT*u; Position r1 = r - TINY_BIT*u; - // Determine the mesh indices for the starting and ending coords. + // Determine the mesh indices for the starting and ending coords. Here, we + // use arrays for ijk0 and ijk1 instead of std::vector because we obtain a + // small performance improvement by forcing this data to live on the stack, + // rather than on the heap. We know the maximum length is 3, and by + // ensuring that all loops are only indexed up to n_dimension, we will not + // access any non-initialized values. The same concept is used throughout. int n = n_dimension_; - std::vector ijk0(n), ijk1(n); + int ijk0[3], ijk1[3]; bool start_in_mesh; - get_indices(r0, ijk0.data(), &start_in_mesh); + get_indices(r0, ijk0, &start_in_mesh); bool end_in_mesh; - get_indices(r1, ijk1.data(), &end_in_mesh); + get_indices(r1, ijk1, &end_in_mesh); // Reset coordinates and check for a mesh intersection if necessary. if (start_in_mesh) { @@ -440,7 +446,7 @@ void StructuredMesh::bins_crossed(const Particle& p, std::vector& bins, // The initial coords do not lie in the mesh. Check to see if the particle // eventually intersects the mesh and compute the relevant coords and // indices. - if (!intersects(r0, r1, ijk0.data())) return; + if (!intersects(r0, r1, ijk0)) return; } r1 = r; @@ -458,33 +464,33 @@ void StructuredMesh::bins_crossed(const Particle& p, std::vector& bins, // Find which mesh cells are traversed and the length of each traversal. while (true) { - if (ijk0 == ijk1) { + if (std::equal(ijk0, ijk0 + n, ijk1)) { // The track ends in this cell. Use the particle end location rather // than the mesh surface and stop iterating. double distance = (r1 - r0).norm(); - bins.push_back(get_bin_from_indices(ijk0.data())); + bins.push_back(get_bin_from_indices(ijk0)); lengths.push_back(distance / total_distance); break; } // The track exits this cell. Determine the distance to each mesh surface. - std::vector d(n); + double d[3]; for (int k = 0; k < n; ++k) { if (std::fabs(u[k]) < FP_PRECISION) { d[k] = INFTY; } else if (u[k] > 0) { - double xyz_cross = positive_grid_boundary(ijk0.data(), k); + double xyz_cross = positive_grid_boundary(ijk0, k); d[k] = (xyz_cross - r0[k]) / u[k]; } else { - double xyz_cross = negative_grid_boundary(ijk0.data(), k); + double xyz_cross = negative_grid_boundary(ijk0, k); d[k] = (xyz_cross - r0[k]) / u[k]; } } // Pick the closest mesh surface and append this traversal to the output. - auto j = std::min_element(d.begin(), d.end()) - d.begin(); + auto j = std::min_element(d, d + n) - d; double distance = d[j]; - bins.push_back(get_bin_from_indices(ijk0.data())); + bins.push_back(get_bin_from_indices(ijk0)); lengths.push_back(distance / total_distance); // Translate to the oncoming mesh surface. From 7a6b5fc62ea00fc72ae43b0cb8e9284abecb44d9 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Mon, 19 Oct 2020 22:56:55 +0100 Subject: [PATCH 19/23] added dockerhub action for release --- .../workflows/dockerhub-publish-release.yml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/dockerhub-publish-release.yml diff --git a/.github/workflows/dockerhub-publish-release.yml b/.github/workflows/dockerhub-publish-release.yml new file mode 100644 index 000000000..d8de72618 --- /dev/null +++ b/.github/workflows/dockerhub-publish-release.yml @@ -0,0 +1,35 @@ +name: dockerhub-publish-release + +on: + push: + tags: 'v*.*.*' + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: openmc/openmc:${{ env.RELEASE_VERSION }} + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} From a6bb97cf43df9d142e3479a49f75a175878d29bf Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 20 Oct 2020 07:25:35 -0500 Subject: [PATCH 20/23] Add missing symlinks in docs/source/examples directory --- docs/source/examples/cad-based-geometry.ipynb | 1 + docs/source/examples/candu.ipynb | 1 + docs/source/examples/expansion-filters.ipynb | 1 + docs/source/examples/hexagonal-lattice.ipynb | 1 + docs/source/examples/mdgxs-part-i.ipynb | 1 + docs/source/examples/mdgxs-part-ii.ipynb | 1 + docs/source/examples/mg-mode-part-i.ipynb | 1 + docs/source/examples/mg-mode-part-ii.ipynb | 1 + docs/source/examples/mg-mode-part-iii.ipynb | 1 + docs/source/examples/mgxs-part-i.ipynb | 1 + docs/source/examples/mgxs-part-ii.ipynb | 1 + docs/source/examples/mgxs-part-iii.ipynb | 1 + docs/source/examples/nuclear-data-resonance-covariance.ipynb | 1 + docs/source/examples/nuclear-data.ipynb | 1 + docs/source/examples/pandas-dataframes.ipynb | 1 + docs/source/examples/pincell.ipynb | 1 + docs/source/examples/pincell_depletion.ipynb | 1 + docs/source/examples/post-processing.ipynb | 1 + docs/source/examples/search.ipynb | 1 + docs/source/examples/tally-arithmetic.ipynb | 1 + docs/source/examples/triso.ipynb | 1 + docs/source/examples/unstructured-mesh-part-i.ipynb | 1 + docs/source/examples/unstructured-mesh-part-ii.ipynb | 1 + 23 files changed, 23 insertions(+) create mode 120000 docs/source/examples/cad-based-geometry.ipynb create mode 120000 docs/source/examples/candu.ipynb create mode 120000 docs/source/examples/expansion-filters.ipynb create mode 120000 docs/source/examples/hexagonal-lattice.ipynb create mode 120000 docs/source/examples/mdgxs-part-i.ipynb create mode 120000 docs/source/examples/mdgxs-part-ii.ipynb create mode 120000 docs/source/examples/mg-mode-part-i.ipynb create mode 120000 docs/source/examples/mg-mode-part-ii.ipynb create mode 120000 docs/source/examples/mg-mode-part-iii.ipynb create mode 120000 docs/source/examples/mgxs-part-i.ipynb create mode 120000 docs/source/examples/mgxs-part-ii.ipynb create mode 120000 docs/source/examples/mgxs-part-iii.ipynb create mode 120000 docs/source/examples/nuclear-data-resonance-covariance.ipynb create mode 120000 docs/source/examples/nuclear-data.ipynb create mode 120000 docs/source/examples/pandas-dataframes.ipynb create mode 120000 docs/source/examples/pincell.ipynb create mode 120000 docs/source/examples/pincell_depletion.ipynb create mode 120000 docs/source/examples/post-processing.ipynb create mode 120000 docs/source/examples/search.ipynb create mode 120000 docs/source/examples/tally-arithmetic.ipynb create mode 120000 docs/source/examples/triso.ipynb create mode 120000 docs/source/examples/unstructured-mesh-part-i.ipynb create mode 120000 docs/source/examples/unstructured-mesh-part-ii.ipynb diff --git a/docs/source/examples/cad-based-geometry.ipynb b/docs/source/examples/cad-based-geometry.ipynb new file mode 120000 index 000000000..ee3727e67 --- /dev/null +++ b/docs/source/examples/cad-based-geometry.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/cad-based-geometry.ipynb \ No newline at end of file diff --git a/docs/source/examples/candu.ipynb b/docs/source/examples/candu.ipynb new file mode 120000 index 000000000..480d99fb1 --- /dev/null +++ b/docs/source/examples/candu.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/candu.ipynb \ No newline at end of file diff --git a/docs/source/examples/expansion-filters.ipynb b/docs/source/examples/expansion-filters.ipynb new file mode 120000 index 000000000..e75734135 --- /dev/null +++ b/docs/source/examples/expansion-filters.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/expansion-filters.ipynb \ No newline at end of file diff --git a/docs/source/examples/hexagonal-lattice.ipynb b/docs/source/examples/hexagonal-lattice.ipynb new file mode 120000 index 000000000..e2b63d243 --- /dev/null +++ b/docs/source/examples/hexagonal-lattice.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/hexagonal-lattice.ipynb \ No newline at end of file diff --git a/docs/source/examples/mdgxs-part-i.ipynb b/docs/source/examples/mdgxs-part-i.ipynb new file mode 120000 index 000000000..01eb1172d --- /dev/null +++ b/docs/source/examples/mdgxs-part-i.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/mdgxs-part-i.ipynb \ No newline at end of file diff --git a/docs/source/examples/mdgxs-part-ii.ipynb b/docs/source/examples/mdgxs-part-ii.ipynb new file mode 120000 index 000000000..2d9d33907 --- /dev/null +++ b/docs/source/examples/mdgxs-part-ii.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/mdgxs-part-ii.ipynb \ No newline at end of file diff --git a/docs/source/examples/mg-mode-part-i.ipynb b/docs/source/examples/mg-mode-part-i.ipynb new file mode 120000 index 000000000..d1577f700 --- /dev/null +++ b/docs/source/examples/mg-mode-part-i.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/mg-mode-part-i.ipynb \ No newline at end of file diff --git a/docs/source/examples/mg-mode-part-ii.ipynb b/docs/source/examples/mg-mode-part-ii.ipynb new file mode 120000 index 000000000..a09306376 --- /dev/null +++ b/docs/source/examples/mg-mode-part-ii.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/mg-mode-part-ii.ipynb \ No newline at end of file diff --git a/docs/source/examples/mg-mode-part-iii.ipynb b/docs/source/examples/mg-mode-part-iii.ipynb new file mode 120000 index 000000000..6fa0d180e --- /dev/null +++ b/docs/source/examples/mg-mode-part-iii.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/mg-mode-part-iii.ipynb \ No newline at end of file diff --git a/docs/source/examples/mgxs-part-i.ipynb b/docs/source/examples/mgxs-part-i.ipynb new file mode 120000 index 000000000..a04b1da89 --- /dev/null +++ b/docs/source/examples/mgxs-part-i.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/mgxs-part-i.ipynb \ No newline at end of file diff --git a/docs/source/examples/mgxs-part-ii.ipynb b/docs/source/examples/mgxs-part-ii.ipynb new file mode 120000 index 000000000..dd8af3c43 --- /dev/null +++ b/docs/source/examples/mgxs-part-ii.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/mgxs-part-ii.ipynb \ No newline at end of file diff --git a/docs/source/examples/mgxs-part-iii.ipynb b/docs/source/examples/mgxs-part-iii.ipynb new file mode 120000 index 000000000..d6acc76ba --- /dev/null +++ b/docs/source/examples/mgxs-part-iii.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/mgxs-part-iii.ipynb \ No newline at end of file diff --git a/docs/source/examples/nuclear-data-resonance-covariance.ipynb b/docs/source/examples/nuclear-data-resonance-covariance.ipynb new file mode 120000 index 000000000..0ab0dd62b --- /dev/null +++ b/docs/source/examples/nuclear-data-resonance-covariance.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/nuclear-data-resonance-covariance.ipynb \ No newline at end of file diff --git a/docs/source/examples/nuclear-data.ipynb b/docs/source/examples/nuclear-data.ipynb new file mode 120000 index 000000000..59721abdc --- /dev/null +++ b/docs/source/examples/nuclear-data.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/nuclear-data.ipynb \ No newline at end of file diff --git a/docs/source/examples/pandas-dataframes.ipynb b/docs/source/examples/pandas-dataframes.ipynb new file mode 120000 index 000000000..f41f570be --- /dev/null +++ b/docs/source/examples/pandas-dataframes.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/pandas-dataframes.ipynb \ No newline at end of file diff --git a/docs/source/examples/pincell.ipynb b/docs/source/examples/pincell.ipynb new file mode 120000 index 000000000..edbbb8de2 --- /dev/null +++ b/docs/source/examples/pincell.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/pincell.ipynb \ No newline at end of file diff --git a/docs/source/examples/pincell_depletion.ipynb b/docs/source/examples/pincell_depletion.ipynb new file mode 120000 index 000000000..1f25930fc --- /dev/null +++ b/docs/source/examples/pincell_depletion.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/pincell_depletion.ipynb \ No newline at end of file diff --git a/docs/source/examples/post-processing.ipynb b/docs/source/examples/post-processing.ipynb new file mode 120000 index 000000000..1f3f4cd71 --- /dev/null +++ b/docs/source/examples/post-processing.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/post-processing.ipynb \ No newline at end of file diff --git a/docs/source/examples/search.ipynb b/docs/source/examples/search.ipynb new file mode 120000 index 000000000..fbfb67bc6 --- /dev/null +++ b/docs/source/examples/search.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/search.ipynb \ No newline at end of file diff --git a/docs/source/examples/tally-arithmetic.ipynb b/docs/source/examples/tally-arithmetic.ipynb new file mode 120000 index 000000000..7ffe19462 --- /dev/null +++ b/docs/source/examples/tally-arithmetic.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/tally-arithmetic.ipynb \ No newline at end of file diff --git a/docs/source/examples/triso.ipynb b/docs/source/examples/triso.ipynb new file mode 120000 index 000000000..0e51d8add --- /dev/null +++ b/docs/source/examples/triso.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/triso.ipynb \ No newline at end of file diff --git a/docs/source/examples/unstructured-mesh-part-i.ipynb b/docs/source/examples/unstructured-mesh-part-i.ipynb new file mode 120000 index 000000000..b1358788b --- /dev/null +++ b/docs/source/examples/unstructured-mesh-part-i.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/unstructured-mesh-part-i.ipynb \ No newline at end of file diff --git a/docs/source/examples/unstructured-mesh-part-ii.ipynb b/docs/source/examples/unstructured-mesh-part-ii.ipynb new file mode 120000 index 000000000..9074811b7 --- /dev/null +++ b/docs/source/examples/unstructured-mesh-part-ii.ipynb @@ -0,0 +1 @@ +../../../examples/jupyter/unstructured-mesh-part-ii.ipynb \ No newline at end of file From 490eadd86463d471e4453f938aaa0a102f0c3995 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 20 Oct 2020 14:07:45 -0500 Subject: [PATCH 21/23] Make sure write_source_file creates filetype attribute --- openmc/source.py | 2 ++ tests/unit_tests/test_source_file.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/openmc/source.py b/openmc/source.py index 3863bb826..b5b53167c 100644 --- a/openmc/source.py +++ b/openmc/source.py @@ -308,9 +308,11 @@ def write_source_file(source_particles, filename, **kwargs): ]) # Create array of source particles + cv.check_iterable_type("source particles", source_particles, SourceParticle) arr = np.array([s.to_tuple() for s in source_particles], dtype=source_dtype) # Write array to file kwargs.setdefault('mode', 'w') with h5py.File(filename, **kwargs) as fh: + fh.attrs['filetype'] = np.string_("source") fh.create_dataset('source_bank', data=arr, dtype=source_dtype) diff --git a/tests/unit_tests/test_source_file.py b/tests/unit_tests/test_source_file.py index e9bcebc92..ae6eff97f 100644 --- a/tests/unit_tests/test_source_file.py +++ b/tests/unit_tests/test_source_file.py @@ -3,9 +3,14 @@ from random import random import h5py import numpy as np import openmc +import pytest def test_source_file(run_in_tmpdir): + # write_source_file shouldn't accept non-SourceParticle items + with pytest.raises(TypeError): + openmc.write_source_file([1, 2, 3], 'test_source.h5') + # Create source particles source = [] n = 1000 @@ -21,9 +26,11 @@ def test_source_file(run_in_tmpdir): # Get array of source particles from file with h5py.File('test_source.h5', 'r') as fh: + filetype = fh.attrs['filetype'] arr = fh['source_bank'][...] # Ensure data is consistent + assert filetype == b'source' r = arr['r'] assert np.all((r['x'] > 0.0) & (r['x'] < 1.0)) assert np.all(r['y'] == np.arange(1000)) From 86a6e63236ac235d87aa928ea73a647a2d5e7f8b Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 27 Oct 2020 21:11:52 -0500 Subject: [PATCH 22/23] Removing static library build of MOAB. Not required any longery by DAGMC (thank goodness). --- tools/ci/travis-install-dagmc.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/ci/travis-install-dagmc.sh b/tools/ci/travis-install-dagmc.sh index 8c9cc61a4..cd2f07e6c 100755 --- a/tools/ci/travis-install-dagmc.sh +++ b/tools/ci/travis-install-dagmc.sh @@ -21,8 +21,6 @@ git clone -b $MOAB_BRANCH $MOAB_REPO mkdir build && cd build cmake ../moab -DENABLE_HDF5=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$MOAB_INSTALL_DIR -DENABLE_BLASLAPACK=OFF make -j && make -j install -cmake ../moab -DBUILD_SHARED_LIBS=OFF -make -j install rm -rf $HOME/MOAB/moab $HOME/MOAB/build # DAGMC Install From c9a95f0ac831e625b1ba8080507d398a918d5d4d Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 28 Oct 2020 12:29:26 -0500 Subject: [PATCH 23/23] Indicate no build of static libraries for DAGMC. --- tools/ci/travis-install-dagmc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/travis-install-dagmc.sh b/tools/ci/travis-install-dagmc.sh index cd2f07e6c..eabb9d382 100755 --- a/tools/ci/travis-install-dagmc.sh +++ b/tools/ci/travis-install-dagmc.sh @@ -28,7 +28,7 @@ cd $HOME mkdir DAGMC && cd DAGMC git clone -b $DAGMC_BRANCH $DAGMC_REPO mkdir build && cd build -cmake ../dagmc -DBUILD_TALLY=ON -DCMAKE_INSTALL_PREFIX=$DAGMC_INSTALL_DIR -DMOAB_DIR=$MOAB_INSTALL_DIR +cmake ../dagmc -DBUILD_TALLY=ON -DCMAKE_INSTALL_PREFIX=$DAGMC_INSTALL_DIR -DBUILD_STATIC_LIBS=OFF -DMOAB_DIR=$MOAB_INSTALL_DIR make -j install rm -rf $HOME/DAGMC/dagmc $HOME/DAGMC/build