mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Merge remote-tracking branch 'upstream/develop' into mt_mgxs
This commit is contained in:
commit
5a94e66bf3
88 changed files with 616 additions and 1043 deletions
32
.github/workflows/dockerhub-publish-dev.yml
vendored
Normal file
32
.github/workflows/dockerhub-publish-dev.yml
vendored
Normal file
|
|
@ -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 }}
|
||||
35
.github/workflows/dockerhub-publish-release.yml
vendored
Normal file
35
.github/workflows/dockerhub-publish-release.yml
vendored
Normal file
|
|
@ -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 }}
|
||||
32
.github/workflows/dockerhub-publish.yml
vendored
Normal file
32
.github/workflows/dockerhub-publish.yml
vendored
Normal file
|
|
@ -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 }}
|
||||
|
|
@ -2,3 +2,4 @@ sphinx-numfig
|
|||
jupyter
|
||||
sphinxcontrib-katex
|
||||
sphinxcontrib-svg2pdfconverter
|
||||
nbsphinx
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
||||
|
|
|
|||
1
docs/source/examples/cad-based-geometry.ipynb
Symbolic link
1
docs/source/examples/cad-based-geometry.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/cad-based-geometry.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/candu.ipynb
Symbolic link
1
docs/source/examples/candu.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/candu.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/expansion-filters.ipynb
Symbolic link
1
docs/source/examples/expansion-filters.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/expansion-filters.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/hexagonal-lattice.ipynb
Symbolic link
1
docs/source/examples/hexagonal-lattice.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/hexagonal-lattice.ipynb
|
||||
|
|
@ -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.
|
||||
|
|
@ -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
|
||||
|
|
|
|||
1
docs/source/examples/mdgxs-part-i.ipynb
Symbolic link
1
docs/source/examples/mdgxs-part-i.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/mdgxs-part-i.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/mdgxs-part-ii.ipynb
Symbolic link
1
docs/source/examples/mdgxs-part-ii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/mdgxs-part-ii.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/mg-mode-part-i.ipynb
Symbolic link
1
docs/source/examples/mg-mode-part-i.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/mg-mode-part-i.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/mg-mode-part-ii.ipynb
Symbolic link
1
docs/source/examples/mg-mode-part-ii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/mg-mode-part-ii.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/mg-mode-part-iii.ipynb
Symbolic link
1
docs/source/examples/mg-mode-part-iii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/mg-mode-part-iii.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/mgxs-part-i.ipynb
Symbolic link
1
docs/source/examples/mgxs-part-i.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/mgxs-part-i.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/mgxs-part-ii.ipynb
Symbolic link
1
docs/source/examples/mgxs-part-ii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/mgxs-part-ii.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/mgxs-part-iii.ipynb
Symbolic link
1
docs/source/examples/mgxs-part-iii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/mgxs-part-iii.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/nuclear-data-resonance-covariance.ipynb
Symbolic link
1
docs/source/examples/nuclear-data-resonance-covariance.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/nuclear-data-resonance-covariance.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/nuclear-data.ipynb
Symbolic link
1
docs/source/examples/nuclear-data.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/nuclear-data.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/pandas-dataframes.ipynb
Symbolic link
1
docs/source/examples/pandas-dataframes.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/pandas-dataframes.ipynb
|
||||
|
|
@ -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.
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/pincell.ipynb
Symbolic link
1
docs/source/examples/pincell.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/pincell.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/pincell_depletion.ipynb
Symbolic link
1
docs/source/examples/pincell_depletion.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/pincell_depletion.ipynb
|
||||
1
docs/source/examples/post-processing.ipynb
Symbolic link
1
docs/source/examples/post-processing.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/post-processing.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/search.ipynb
Symbolic link
1
docs/source/examples/search.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/search.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/tally-arithmetic.ipynb
Symbolic link
1
docs/source/examples/tally-arithmetic.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/tally-arithmetic.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/triso.ipynb
Symbolic link
1
docs/source/examples/triso.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/triso.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/unstructured-mesh-part-i.ipynb
Symbolic link
1
docs/source/examples/unstructured-mesh-part-i.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/unstructured-mesh-part-i.ipynb
|
||||
|
|
@ -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.
|
||||
1
docs/source/examples/unstructured-mesh-part-ii.ipynb
Symbolic link
1
docs/source/examples/unstructured-mesh-part-ii.ipynb
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../examples/jupyter/unstructured-mesh-part-ii.ipynb
|
||||
|
|
@ -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.
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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/**
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
----------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <COPYRIGHT HOLDER> 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 <matthewturk@gmail.com>
|
||||
|
||||
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.
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -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('<head>', 1)[1].split('</head>',1)[0]
|
||||
body = output.split('<body>', 1)[1].split('</body>',1)[0]
|
||||
|
||||
# add HTML5 scoped attribute to header style tags
|
||||
header = header.replace('<style', '<style scoped="scoped"')
|
||||
header = header.replace('body {\n overflow: visible;\n padding: 8px;\n}\n',
|
||||
'')
|
||||
header = header.replace("code,pre{", "code{")
|
||||
|
||||
# Filter out styles that conflict with the sphinx theme.
|
||||
filter_strings = [
|
||||
'navbar',
|
||||
'body{',
|
||||
'alert{',
|
||||
'uneditable-input{',
|
||||
'collapse{',
|
||||
]
|
||||
|
||||
filter_strings.extend(['h%s{' % (i+1) for i in range(6)])
|
||||
|
||||
line_begin = [
|
||||
'pre{',
|
||||
'p{margin'
|
||||
]
|
||||
|
||||
filterfunc = lambda x: not any([s in x for s in filter_strings])
|
||||
header_lines = filter(filterfunc, header.split('\n'))
|
||||
|
||||
filterfunc = lambda x: not any([x.startswith(s) for s in line_begin])
|
||||
header_lines = filter(filterfunc, header_lines)
|
||||
|
||||
header = '\n'.join(header_lines)
|
||||
|
||||
# concatenate raw html lines
|
||||
lines = ['<div class="ipynotebook">']
|
||||
lines.append(header)
|
||||
lines.append(body)
|
||||
lines.append('</div>')
|
||||
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)
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<N>.h5`, where `<N>` 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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -105,24 +105,59 @@ public:
|
|||
StructuredMesh(pugi::xml_node node) : Mesh {node} {};
|
||||
virtual ~StructuredMesh() = default;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
|
||||
int n_bins() const override;
|
||||
|
||||
int n_surface_bins() const override;
|
||||
|
||||
void bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
||||
//! Get bin given mesh indices
|
||||
//
|
||||
//! \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
|
||||
//
|
||||
//! \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
|
||||
//
|
||||
//! \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
|
||||
//!
|
||||
//! \param[in] r Coordinate to get index for
|
||||
//! \param[in] i Direction index
|
||||
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 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;
|
||||
|
|
@ -130,6 +165,12 @@ public:
|
|||
// Data members
|
||||
xt::xtensor<double, 1> lower_left_; //!< Lower-left coordinates of mesh
|
||||
xt::xtensor<double, 1> upper_right_; //!< Upper-right coordinates of mesh
|
||||
xt::xtensor<int, 1> 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;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -145,23 +186,14 @@ public:
|
|||
|
||||
// Overriden methods
|
||||
|
||||
void bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
||||
void surface_bins_crossed(const Particle& p, std::vector<int>& bins)
|
||||
const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
int get_index_in_direction(double r, int i) const override;
|
||||
|
||||
int get_bin_from_indices(const int* ijk) const override;
|
||||
double positive_grid_boundary(int* ijk, int i) 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 n_bins() const override;
|
||||
|
||||
int n_surface_bins() const override;
|
||||
double negative_grid_boundary(int* ijk, int i) const override;
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
plot(Position plot_ll, Position plot_ur) const override;
|
||||
|
|
@ -170,14 +202,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
|
||||
|
|
@ -189,13 +213,7 @@ public:
|
|||
// Data members
|
||||
|
||||
double volume_frac_; //!< Volume fraction of each mesh element
|
||||
xt::xtensor<int, 1> shape_; //!< Number of mesh elements in each dimension
|
||||
xt::xtensor<double, 1> 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;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -207,42 +225,20 @@ public:
|
|||
|
||||
// Overriden methods
|
||||
|
||||
void bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const override;
|
||||
|
||||
void surface_bins_crossed(const Particle& p, std::vector<int>& bins)
|
||||
const override;
|
||||
|
||||
int get_bin(Position r) const override;
|
||||
int get_index_in_direction(double r, int i) const override;
|
||||
|
||||
int get_bin_from_indices(const int* ijk) const override;
|
||||
double positive_grid_boundary(int* ijk, int i) 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 n_bins() const override;
|
||||
|
||||
int n_surface_bins() const override;
|
||||
double negative_grid_boundary(int* ijk, int i) const override;
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
plot(Position plot_ll, Position plot_ur) const override;
|
||||
|
||||
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;
|
||||
|
||||
// Data members
|
||||
xt::xtensor<int, 1> shape_; //!< Number of mesh elements in each dimension
|
||||
|
||||
private:
|
||||
std::vector<std::vector<double>> grid_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,89 @@ 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', '<f8'), ('y', '<f8'), ('z', '<f8')])
|
||||
source_dtype = np.dtype([
|
||||
('r', pos_dtype),
|
||||
('u', pos_dtype),
|
||||
('E', '<f8'),
|
||||
('wgt', '<f8'),
|
||||
('delayed_group', '<i4'),
|
||||
('particle', '<i4'),
|
||||
])
|
||||
|
||||
# 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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
3
setup.py
3
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'],
|
||||
},
|
||||
|
|
|
|||
584
src/mesh.cpp
584
src/mesh.cpp
|
|
@ -102,104 +102,17 @@ StructuredMesh::bin_label(int bin) const {
|
|||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// RegularMesh implementation
|
||||
//==============================================================================
|
||||
|
||||
RegularMesh::RegularMesh(pugi::xml_node node)
|
||||
: StructuredMesh {node}
|
||||
void StructuredMesh::get_indices(Position r, int* ijk, bool* in_mesh) const
|
||||
{
|
||||
// Determine number of dimensions for mesh
|
||||
if (check_for_node(node, "dimension")) {
|
||||
shape_ = get_node_xarray<int>(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.");
|
||||
}
|
||||
*in_mesh = true;
|
||||
for (int i = 0; i < n_dimension_; ++i) {
|
||||
ijk[i] = get_index_in_direction(r[i], i);
|
||||
|
||||
// Check that dimensions are all greater than zero
|
||||
if (xt::any(shape_ <= 0)) {
|
||||
fatal_error("All entries on the <dimension> element for a tally "
|
||||
"mesh must be positive.");
|
||||
}
|
||||
} else {
|
||||
fatal_error("Must specify <dimension> on a mesh.");
|
||||
if (ijk[i] < 1 || ijk[i] > shape_[i]) *in_mesh = false;
|
||||
}
|
||||
|
||||
// Check for lower-left coordinates
|
||||
if (check_for_node(node, "lower_left")) {
|
||||
// Read mesh lower-left corner location
|
||||
lower_left_ = get_node_xarray<double>(node, "lower_left");
|
||||
|
||||
// Make sure lower_left and dimension match
|
||||
if (n_dimension_ != lower_left_.size()) {
|
||||
fatal_error("Number of entries on <lower_left> must be the same "
|
||||
"as the number of entries on <dimension>.");
|
||||
}
|
||||
} else {
|
||||
fatal_error("Must specify <lower_left> 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 <upper_right> and <width> on a mesh.");
|
||||
}
|
||||
|
||||
width_ = get_node_xarray<double>(node, "width");
|
||||
|
||||
// Check to ensure width has same dimensions
|
||||
if (n_dimension_ != width_.size()) {
|
||||
fatal_error("Number of entries on <width> must be the same as "
|
||||
"the number of entries on <lower_left>.");
|
||||
}
|
||||
|
||||
// Check for negative widths
|
||||
if (xt::any(width_ < 0.0)) {
|
||||
fatal_error("Cannot have a negative <width> 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<double>(node, "upper_right");
|
||||
|
||||
// Check to ensure upper right has same dimensions
|
||||
if (n_dimension_ != upper_right_.size()) {
|
||||
fatal_error("Number of entries on <upper_right> must be the "
|
||||
"same as the number of entries on <lower_left>.");
|
||||
}
|
||||
|
||||
// Check that upper-right is above lower-left
|
||||
if (xt::any(upper_right_ < lower_left_)) {
|
||||
fatal_error("The <upper_right> coordinates must be greater than "
|
||||
"the <lower_left> coordinates on a tally mesh.");
|
||||
}
|
||||
|
||||
// Set width
|
||||
width_ = xt::eval((upper_right_ - lower_left_) / shape_);
|
||||
} else {
|
||||
fatal_error("Must specify either <upper_right> and <width> on a mesh.");
|
||||
}
|
||||
|
||||
// Set volume fraction
|
||||
volume_frac_ = 1.0/xt::prod(shape_)();
|
||||
}
|
||||
|
||||
int RegularMesh::get_bin(Position r) const
|
||||
{
|
||||
// Determine indices
|
||||
std::vector<int> 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_bin_from_indices(const int* ijk) const
|
||||
int StructuredMesh::get_bin_from_indices(const int* ijk) const
|
||||
{
|
||||
switch (n_dimension_) {
|
||||
case 1:
|
||||
|
|
@ -213,19 +126,7 @@ int RegularMesh::get_bin_from_indices(const int* ijk) const
|
|||
}
|
||||
}
|
||||
|
||||
void RegularMesh::get_indices(Position r, int* ijk, bool* in_mesh) 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;
|
||||
}
|
||||
}
|
||||
|
||||
void RegularMesh::get_indices_from_bin(int bin, int* ijk) const
|
||||
void StructuredMesh::get_indices_from_bin(int bin, int* ijk) const
|
||||
{
|
||||
if (n_dimension_ == 1) {
|
||||
ijk[0] = bin + 1;
|
||||
|
|
@ -239,19 +140,29 @@ void RegularMesh::get_indices_from_bin(int bin, int* ijk) const
|
|||
}
|
||||
}
|
||||
|
||||
int RegularMesh::n_bins() const
|
||||
int StructuredMesh::get_bin(Position r) const
|
||||
{
|
||||
int n_bins = 1;
|
||||
for (auto dim : shape_) n_bins *= dim;
|
||||
return n_bins;
|
||||
// Determine indices
|
||||
std::vector<int> 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::n_surface_bins() const
|
||||
int StructuredMesh::n_bins() const
|
||||
{
|
||||
return xt::prod(shape_)();
|
||||
}
|
||||
|
||||
int StructuredMesh::n_surface_bins() const
|
||||
{
|
||||
return 4 * n_dimension_ * n_bins();
|
||||
}
|
||||
|
||||
bool RegularMesh::intersects(Position& r0, Position r1, int* ijk) const
|
||||
bool StructuredMesh::intersects(Position& r0, Position r1, int* ijk) const
|
||||
{
|
||||
switch(n_dimension_) {
|
||||
case 1:
|
||||
|
|
@ -265,7 +176,7 @@ bool RegularMesh::intersects(Position& r0, Position r1, int* ijk) const
|
|||
}
|
||||
}
|
||||
|
||||
bool RegularMesh::intersects_1d(Position& r0, Position r1, int* ijk) const
|
||||
bool StructuredMesh::intersects_1d(Position& r0, Position r1, int* ijk) const
|
||||
{
|
||||
// Copy coordinates of starting point
|
||||
double x0 = r0.x;
|
||||
|
|
@ -306,7 +217,7 @@ bool RegularMesh::intersects_1d(Position& r0, Position r1, int* ijk) const
|
|||
return min_dist < INFTY;
|
||||
}
|
||||
|
||||
bool RegularMesh::intersects_2d(Position& r0, Position r1, int* ijk) const
|
||||
bool StructuredMesh::intersects_2d(Position& r0, Position r1, int* ijk) const
|
||||
{
|
||||
// Copy coordinates of starting point
|
||||
double x0 = r0.x;
|
||||
|
|
@ -336,7 +247,7 @@ bool RegularMesh::intersects_2d(Position& r0, Position r1, int* ijk) const
|
|||
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]);
|
||||
ijk[1] = get_index_in_direction(yi, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -348,7 +259,7 @@ bool RegularMesh::intersects_2d(Position& r0, Position r1, int* ijk) const
|
|||
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[0] = get_index_in_direction(xi, 0);
|
||||
ijk[1] = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -362,7 +273,7 @@ bool RegularMesh::intersects_2d(Position& r0, Position r1, int* ijk) const
|
|||
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]);
|
||||
ijk[1] = get_index_in_direction(yi, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -374,7 +285,7 @@ bool RegularMesh::intersects_2d(Position& r0, Position r1, int* ijk) const
|
|||
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[0] = get_index_in_direction(xi, 0);
|
||||
ijk[1] = shape_[1];
|
||||
}
|
||||
}
|
||||
|
|
@ -383,7 +294,7 @@ bool RegularMesh::intersects_2d(Position& r0, Position r1, int* ijk) const
|
|||
return min_dist < INFTY;
|
||||
}
|
||||
|
||||
bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
||||
bool StructuredMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
||||
{
|
||||
// Copy coordinates of starting point
|
||||
double x0 = r0.x;
|
||||
|
|
@ -415,8 +326,8 @@ bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
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]);
|
||||
ijk[1] = get_index_in_direction(yi, 1);
|
||||
ijk[2] = get_index_in_direction(zi, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -428,9 +339,9 @@ bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
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[0] = get_index_in_direction(xi, 0);
|
||||
ijk[1] = 1;
|
||||
ijk[2] = std::ceil((zi - lower_left_[2]) / width_[2]);
|
||||
ijk[2] = get_index_in_direction(zi, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -442,8 +353,8 @@ bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
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[0] = get_index_in_direction(xi, 0);
|
||||
ijk[1] = get_index_in_direction(yi, 1);
|
||||
ijk[2] = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -457,8 +368,8 @@ bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
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]);
|
||||
ijk[1] = get_index_in_direction(yi, 1);
|
||||
ijk[2] = get_index_in_direction(zi, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -470,9 +381,9 @@ bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
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[0] = get_index_in_direction(xi, 0);
|
||||
ijk[1] = shape_[1];
|
||||
ijk[2] = std::ceil((zi - lower_left_[2]) / width_[2]);
|
||||
ijk[2] = get_index_in_direction(zi, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -484,8 +395,8 @@ bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
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[0] = get_index_in_direction(xi, 0);
|
||||
ijk[1] = get_index_in_direction(yi, 1);
|
||||
ijk[2] = shape_[2];
|
||||
}
|
||||
}
|
||||
|
|
@ -494,8 +405,8 @@ bool RegularMesh::intersects_3d(Position& r0, Position r1, int* ijk) const
|
|||
return min_dist < INFTY;
|
||||
}
|
||||
|
||||
void RegularMesh::bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
void StructuredMesh::bins_crossed(const Particle& p, std::vector<int>& bins,
|
||||
std::vector<double>& lengths) const
|
||||
{
|
||||
// ========================================================================
|
||||
// Determine where the track intersects the mesh and if it intersects at all.
|
||||
|
|
@ -514,13 +425,18 @@ void RegularMesh::bins_crossed(const Particle& p, std::vector<int>& 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<int> 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) {
|
||||
|
|
@ -530,7 +446,7 @@ void RegularMesh::bins_crossed(const Particle& p, std::vector<int>& 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;
|
||||
|
||||
|
|
@ -548,33 +464,33 @@ void RegularMesh::bins_crossed(const Particle& p, std::vector<int>& 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<double> 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 = lower_left_[k] + ijk0[k] * width_[k];
|
||||
double xyz_cross = positive_grid_boundary(ijk0, 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, 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.
|
||||
|
|
@ -600,6 +516,111 @@ void RegularMesh::bins_crossed(const Particle& p, std::vector<int>& 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<int>(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 <dimension> 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<double>(node, "lower_left");
|
||||
} else {
|
||||
fatal_error("Must specify <lower_left> 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 <upper_right> and <width> on a mesh.");
|
||||
}
|
||||
|
||||
width_ = get_node_xarray<double>(node, "width");
|
||||
|
||||
// Check to ensure width has same dimensions
|
||||
auto n = width_.size();
|
||||
if (n != lower_left_.size()) {
|
||||
fatal_error("Number of entries on <width> must be the same as "
|
||||
"the number of entries on <lower_left>.");
|
||||
}
|
||||
|
||||
// Check for negative widths
|
||||
if (xt::any(width_ < 0.0)) {
|
||||
fatal_error("Cannot have a negative <width> 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<double>(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 <upper_right> must be the "
|
||||
"same as the number of entries on <lower_left>.");
|
||||
}
|
||||
|
||||
// Check that upper-right is above lower-left
|
||||
if (xt::any(upper_right_ < lower_left_)) {
|
||||
fatal_error("The <upper_right> coordinates must be greater than "
|
||||
"the <lower_left> 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 <upper_right> and <width> 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 <lower_left> must be the same "
|
||||
"as the number of entries on <dimension>.");
|
||||
}
|
||||
|
||||
// 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<int>& bins) const
|
||||
{
|
||||
|
|
@ -638,9 +659,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -885,109 +906,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<int>& bins,
|
||||
std::vector<double>& 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,
|
||||
|
|
@ -1084,9 +1010,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1158,52 +1084,9 @@ void RectilinearMesh::surface_bins_crossed(const Particle& p,
|
|||
}
|
||||
}
|
||||
|
||||
int RectilinearMesh::get_bin(Position r) const
|
||||
int RectilinearMesh::get_index_in_direction(double r, int i) 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_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
|
||||
{
|
||||
*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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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_)();
|
||||
}
|
||||
|
||||
int RectilinearMesh::n_surface_bins() const
|
||||
{
|
||||
return 4 * n_dimension_ * n_bins();
|
||||
return lower_bound_index(grid_[i].begin(), grid_[i].end(), r) + 1;
|
||||
}
|
||||
|
||||
std::pair<std::vector<double>, std::vector<double>>
|
||||
|
|
@ -1248,117 +1131,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
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -506,6 +506,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);
|
||||
|
|
|
|||
45
tests/unit_tests/test_source_file.py
Normal file
45
tests/unit_tests/test_source_file.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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
|
||||
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:
|
||||
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))
|
||||
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)
|
||||
|
|
@ -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
|
||||
|
|
@ -30,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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue