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

This commit is contained in:
Sterling Harper 2020-12-18 23:30:37 -07:00
commit 8879414824
160 changed files with 4720 additions and 3186 deletions

122
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,122 @@
name: CI
on:
# allows us to run workflows manually
workflow_dispatch:
pull_request:
branches:
- develop
- master
push:
branches:
- develop
- master
env:
MPI_DIR: /usr
HDF5_ROOT: /usr
OMP_NUM_THREADS: 2
COVERALLS_PARALLEL: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
main:
runs-on: ubuntu-16.04
strategy:
matrix:
python-version: [3.8]
mpi: [n, y]
omp: [n, y]
dagmc: [n]
event: [n]
vectfit: [n]
include:
- python-version: 3.6
omp: n
mpi: n
- python-version: 3.7
omp: n
mpi: n
- dagmc: y
python-version: 3.8
mpi: y
omp: y
- event: y
python-version: 3.8
omp: y
mpi: n
- vectfit: y
python-version: 3.8
omp: n
mpi: y
env:
MPI: ${{ matrix.mpi }}
PHDF5: ${{ matrix.mpi }}
OMP: ${{ matrix.omp }}
DAGMC: ${{ matrix.dagmc }}
EVENT: ${{ matrix.event }}
VECTFIT: ${{ matrix.vectfit }}
steps:
-
uses: actions/checkout@v2
-
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
-
name: Environment Variables
run: |
echo "DAGMC_ROOT=$HOME/DAGMC"
echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV
echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV
-
name: Apt dependencies
shell: bash
run: |
sudo apt -y update
sudo apt install -y mpich \
libmpich-dev \
libhdf5-serial-dev \
libhdf5-mpich-dev \
libeigen3-dev
-
name: install
shell: bash
run: |
echo "$HOME/NJOY2016/build" >> $GITHUB_PATH
$GITHUB_WORKSPACE/tools/ci/gha-install.sh
-
name: before
shell: bash
run: $GITHUB_WORKSPACE/tools/ci/gha-before-script.sh
-
name: test
shell: bash
run: $GITHUB_WORKSPACE/tools/ci/gha-script.sh
-
name: after_success
shell: bash
run: |
cpp-coveralls -i src -i include --exclude-pattern "/usr/*" --dump cpp_cov.json
coveralls --merge=cpp_cov.json
finish:
needs: main
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

View 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 }}

View 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
View 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 }}

View file

@ -1,60 +0,0 @@
sudo: required
dist: xenial
language: python
addons:
apt:
packages:
- mpich
- libmpich-dev
- libhdf5-serial-dev
- libhdf5-mpich-dev
- libeigen3-dev
config:
retries: true
services:
- xvfb
cache:
directories:
- $HOME/nndc_hdf5
- $HOME/endf-b-vii.1
env:
global:
- MPI_DIR=/usr
- DAGMC_ROOT=$HOME/DAGMC
- HDF5_ROOT=/usr
- OMP_NUM_THREADS=2
- OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml
- OPENMC_ENDF_DATA=$HOME/endf-b-vii.1
- PATH=$PATH:$HOME/NJOY2016/build
- COVERALLS_PARALLEL=true
- NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=0
matrix:
include:
- python: "3.6"
env: OMP=n MPI=n PHDF5=n
- python: "3.7"
env: OMP=n MPI=n PHDF5=n
- python: "3.8"
env: OMP=n MPI=n PHDF5=n
- python: "3.8"
env: OMP=y MPI=n PHDF5=n
- python: "3.8"
env: OMP=n MPI=y PHDF5=n VECTFIT=y
- python: "3.8"
env: OMP=n MPI=y PHDF5=y
- python: "3.8"
env: OMP=y MPI=y PHDF5=y DAGMC=y
- python: "3.8"
env: OMP=y MPI=n PHDF5=n EVENT=y
notifications:
webhooks: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN
install:
- ./tools/ci/travis-install.sh
before_script:
- ./tools/ci/travis-before-script.sh
script:
- ./tools/ci/travis-script.sh
after_success:
- cpp-coveralls -i src -i include --exclude-pattern "/usr/*" --dump cpp_cov.json
- coveralls --merge=cpp_cov.json

View file

@ -1,7 +1,7 @@
# OpenMC Monte Carlo Particle Transport Code
[![License](https://img.shields.io/github/license/openmc-dev/openmc.svg)](http://openmc.readthedocs.io/en/latest/license.html)
[![Travis CI build status (Linux)](https://travis-ci.org/openmc-dev/openmc.svg?branch=develop)](https://travis-ci.org/openmc-dev/openmc)
[![GitHub Actions build status (Linux)](https://github.com/openmc-dev/openmc/workflows/CI/badge.svg?branch=develop)](https://github.com/openmc-dev/openmc/actions)
[![Code Coverage](https://coveralls.io/repos/github/openmc-dev/openmc/badge.svg?branch=develop)](https://coveralls.io/github/openmc-dev/openmc?branch=develop)
The OpenMC project aims to provide a fully-featured Monte Carlo particle

View file

@ -2,3 +2,10 @@ sphinx-numfig
jupyter
sphinxcontrib-katex
sphinxcontrib-svg2pdfconverter
nbsphinx
numpy
scipy
h5py
pandas
uncertainties
matplotlib

View file

@ -20,26 +20,15 @@ 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',
'openmc.data.reconstruct', 'openmc.checkvalue'
'openmoc', 'openmc.data.reconstruct',
]
sys.modules.update((mod_name, MagicMock()) for mod_name in MOCK_MODULES)
import numpy as np
np.ndarray = MagicMock
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 +36,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')

View file

@ -0,0 +1 @@
../../../examples/jupyter/cad-based-geometry.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/candu.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/expansion-filters.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/hexagonal-lattice.ipynb

View file

@ -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.

View file

@ -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

View file

@ -0,0 +1 @@
../../../examples/jupyter/mdgxs-part-i.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/mdgxs-part-ii.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/mg-mode-part-i.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/mg-mode-part-ii.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/mg-mode-part-iii.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/mgxs-part-i.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/mgxs-part-ii.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/mgxs-part-iii.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/nuclear-data-resonance-covariance.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/nuclear-data.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/pandas-dataframes.ipynb

View file

@ -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.

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/pincell.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/pincell_depletion.ipynb

View file

@ -0,0 +1 @@
../../../examples/jupyter/post-processing.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/search.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/tally-arithmetic.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/triso.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/unstructured-mesh-part-i.ipynb

View file

@ -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.

View file

@ -0,0 +1 @@
../../../examples/jupyter/unstructured-mesh-part-ii.ipynb

View file

@ -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.

View file

@ -465,7 +465,7 @@ attributes/sub-elements:
as complex as is required to define the source for your problem. The library
has a few basic requirements:
* It must contain a class that inherits from ``openmc::CustomSource``;
* It must contain a class that inherits from ``openmc::Source``;
* The class must implement a function called ``sample()``;
* There must be an ``openmc_create_source()`` function that creates the source
as a unique pointer. This function can be used to pass parameters through to

View file

@ -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.

View file

@ -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/**

View file

@ -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
----------------------

View file

@ -30,6 +30,7 @@ Multi-group Cross Sections
:template: myclassinherit.rst
openmc.mgxs.MGXS
openmc.mgxs.MatrixMGXS
openmc.mgxs.AbsorptionXS
openmc.mgxs.CaptureXS
openmc.mgxs.Chi
@ -45,6 +46,9 @@ Multi-group Cross Sections
openmc.mgxs.ScatterProbabilityMatrix
openmc.mgxs.TotalXS
openmc.mgxs.TransportXS
openmc.mgxs.ArbitraryXS
openmc.mgxs.ArbitraryMatrixXS
openmc.mgxs.MeshSurfaceMGXS
Multi-delayed-group Cross Sections
----------------------------------
@ -55,6 +59,7 @@ Multi-delayed-group Cross Sections
:template: myclassinherit.rst
openmc.mgxs.MDGXS
openmc.mgxs.MatrixMDGXS
openmc.mgxs.ChiDelayed
openmc.mgxs.DelayedNuFissionXS
openmc.mgxs.DelayedNuFissionMatrixXS

View file

@ -194,9 +194,9 @@ below.
#include "openmc/source.h"
#include "openmc/particle.h"
class Source : public openmc::CustomSource
class CustomSource : public openmc::Source
{
openmc::Particle::Bank sample(uint64_t* seed)
openmc::Particle::Bank sample(uint64_t* seed) const
{
openmc::Particle::Bank particle;
// weight
@ -216,16 +216,16 @@ below.
}
};
extern "C" std::unique_ptr<Source> openmc_create_source(std::string parameters)
extern "C" std::unique_ptr<CustomSource> openmc_create_source(std::string parameters)
{
return std::make_unique<Source>();
return std::make_unique<CustomSource>();
}
The above source creates monodirectional 14.08 MeV neutrons that are distributed
in a ring with a 3 cm radius. This routine is not particularly complex, but
should serve as an example upon which to build more complicated sources.
.. note:: The source class must inherit from ``openmc::CustomSource`` and
.. note:: The source class must inherit from ``openmc::Source`` and
implement a ``sample()`` function.
.. note:: The ``openmc_create_source()`` function signature must be declared
@ -266,12 +266,12 @@ the source class when it is created:
#include "openmc/source.h"
#include "openmc/particle.h"
class Source : public openmc::CustomSource {
class CustomSource : public openmc::Source {
public:
Source(double energy) : energy_{energy} { }
CustomSource(double energy) : energy_{energy} { }
// Samples from an instance of this class.
openmc::Particle::Bank sample(uint64_t* seed)
openmc::Particle::Bank sample(uint64_t* seed) const
{
openmc::Particle::Bank particle;
// weight
@ -293,9 +293,9 @@ the source class when it is created:
double energy_;
};
extern "C" std::unique_ptr<Source> openmc_create_source(std::string parameter) {
extern "C" std::unique_ptr<CustomSource> openmc_create_source(std::string parameter) {
double energy = std::stod(parameter);
return std::make_unique<Source>(energy);
return std::make_unique<CustomSource>(energy);
}
As with the basic custom source functionality, the custom source library

View file

@ -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.
-------------------------------------------------------------------------------

View file

@ -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)

View file

@ -5,9 +5,9 @@
#include "openmc/source.h"
#include "openmc/particle.h"
class Source : public openmc::CustomSource
class RingSource : public openmc::Source
{
openmc::Particle::Bank sample(uint64_t* seed)
openmc::Particle::Bank sample(uint64_t* seed) const
{
openmc::Particle::Bank particle;
// wgt
@ -30,7 +30,7 @@ class Source : public openmc::CustomSource
// A function to create a unique pointer to an instance of this class when generated
// via a plugin call using dlopen/dlsym.
// You must have external C linkage here otherwise dlopen will not find the file
extern "C" std::unique_ptr<Source> openmc_create_source(std::string parameters)
extern "C" std::unique_ptr<RingSource> openmc_create_source(std::string parameters)
{
return std::make_unique<Source>();
return std::make_unique<RingSource>();
}

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -6,14 +6,13 @@
#include "openmc/source.h"
#include "openmc/particle.h"
class Source : public openmc::CustomSource
{
class RingSource : public openmc::Source {
public:
Source(double radius, double energy) : radius_(radius), energy_(energy) { }
RingSource(double radius, double energy) : radius_(radius), energy_(energy) { }
// Defines a function that can create a unique pointer to a new instance of this class
// by extracting the parameters from the provided string.
static std::unique_ptr<Source> from_string(std::string parameters)
static std::unique_ptr<RingSource> from_string(std::string parameters)
{
std::unordered_map<std::string, std::string> parameter_mapping;
@ -28,11 +27,11 @@ class Source : public openmc::CustomSource
double radius = std::stod(parameter_mapping["radius"]);
double energy = std::stod(parameter_mapping["energy"]);
return std::make_unique<Source>(radius, energy);
return std::make_unique<RingSource>(radius, energy);
}
// Samples from an instance of this class.
openmc::Particle::Bank sample(uint64_t* seed)
openmc::Particle::Bank sample(uint64_t* seed) const
{
openmc::Particle::Bank particle;
// wgt
@ -60,7 +59,7 @@ class Source : public openmc::CustomSource
// A function to create a unique pointer to an instance of this class when generated
// via a plugin call using dlopen/dlsym.
// You must have external C linkage here otherwise dlopen will not find the file
extern "C" std::unique_ptr<Source> openmc_create_source(std::string parameters)
extern "C" std::unique_ptr<RingSource> openmc_create_source(std::string parameters)
{
return Source::from_string(parameters);
return RingSource::from_string(parameters);
}

View file

@ -131,27 +131,38 @@ extern "C" {
int openmc_zernike_filter_set_params(int32_t index, const double* x,
const double* y, const double* r);
//! Sets the mesh and energy grid for CMFD reweight
//! \param[in] meshtyally_id id of CMFD Mesh Tally
//! \param[in] cmfd_indices indices storing spatial and energy dimensions of CMFD problem
//! \param[in] norm CMFD normalization factor
extern "C" void openmc_initialize_mesh_egrid(const int meshtally_id, const int* cmfd_indices,
const double norm);
//! Sets the mesh and energy grid for CMFD reweight
//! \param[in] feedback whether or not to run CMFD feedback
//! \param[in] cmfd_src computed CMFD source
extern "C" void openmc_cmfd_reweight(const bool feedback, const double* cmfd_src);
//! Sets the fixed variables that are used for CMFD linear solver
//! \param[in] CSR format index pointer array of loss matrix
//! \param[in] length of indptr
//! \param[in] CSR format index array of loss matrix
//! \param[in] number of non-zero elements in CMFD loss matrix
//! \param[in] dimension n of nxn CMFD loss matrix
//! \param[in] spectral radius of CMFD matrices and tolerances
//! \param[in] indices storing spatial and energy dimensions of CMFD problem
//! \param[in] coremap for problem, storing accelerated regions
//! \param[in] indptr CSR format index pointer array of loss matrix
//! \param[in] len_indptr length of indptr
//! \param[in] indices CSR format index array of loss matrix
//! \param[in] n_elements number of non-zero elements in CMFD loss matrix
//! \param[in] dim dimension n of nxn CMFD loss matrix
//! \param[in] spectral spectral radius of CMFD matrices and tolerances
//! \param[in] map coremap for problem, storing accelerated regions
//! \param[in] use_all_threads whether to use all threads when running CMFD solver
extern "C" void openmc_initialize_linsolver(const int* indptr, int len_indptr,
const int* indices, int n_elements,
int dim, double spectral,
const int* cmfd_indices,
const int* map, bool use_all_threads);
//! Runs a Gauss Seidel linear solver to solve CMFD matrix equations
//! linear solver
//! \param[in] CSR format data array of coefficient matrix
//! \param[in] right hand side vector
//! \param[out] unknown vector
//! \param[in] tolerance on final error
//! \param[in] A_data CSR format data array of coefficient matrix
//! \param[in] b right hand side vector
//! \param[out] x unknown vector
//! \param[in] tol tolerance on final error
//! \return number of inner iterations required to reach convergence
extern "C" int openmc_run_linsolver(const double* A_data, const double* b,
double* x, double tol);

View file

@ -199,7 +199,7 @@ enum ReactionType {
N_3N3HE = 177,
N_4N3HE = 178,
N_3N2P = 179,
N_3N3A = 180,
N_3N2A = 180,
N_3NPA = 181,
N_DT = 182,
N_NPD = 183,
@ -289,9 +289,9 @@ enum class MgxsType {
ABSORPTION,
INVERSE_VELOCITY,
DECAY_RATE,
NU_SCATTER,
SCATTER,
SCATTER_MULT,
SCATTER_FMU_MULT,
NU_SCATTER_FMU,
SCATTER_FMU,
FISSION,
KAPPA_FISSION,

View file

@ -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_;
};

View file

@ -117,7 +117,7 @@ class Mgxs {
int num_group, int num_delay);
//! \brief Constructor that initializes and populates all data to build a
//! macroscopic cross section from microscopic cross section.
//! macroscopic cross section from microscopic cross sections.
//!
//! @param in_name Name of the object.
//! @param mat_kTs temperatures (in units of eV) that data is needed.

View file

@ -33,7 +33,8 @@ class ScattData {
//! \brief Combines microscopic ScattDatas into a macroscopic one.
void
base_combine(size_t max_order, const std::vector<ScattData*>& those_scatts,
base_combine(size_t max_order, size_t order_dim,
const std::vector<ScattData*>& those_scatts,
const std::vector<double>& scalars, xt::xtensor<int, 1>& in_gmin,
xt::xtensor<int, 1>& in_gmax, double_2dvec& sparse_mult,
double_3dvec& sparse_scatter);

View file

@ -59,8 +59,6 @@ extern std::string path_cross_sections; //!< path to cross_sections.xml
extern std::string path_input; //!< directory where main .xml files resides
extern std::string path_output; //!< directory where output files are written
extern std::string path_particle_restart; //!< path to a particle restart file
extern std::string path_source;
extern std::string path_source_library; //!< path to the source shared object
extern std::string path_sourcepoint; //!< path to a source file
extern "C" std::string path_statepoint; //!< path to a statepoint file

View file

@ -19,32 +19,47 @@ namespace openmc {
// Global variables
//==============================================================================
class SourceDistribution;
class Source;
namespace model {
extern std::vector<SourceDistribution> external_sources;
extern std::vector<std::unique_ptr<Source>> external_sources;
} // namespace model
//==============================================================================
//! External source distribution
//! Abstract source interface
//==============================================================================
class SourceDistribution {
class Source {
public:
virtual ~Source() = default;
// Methods that must be implemented
virtual Particle::Bank sample(uint64_t* seed) const = 0;
// Methods that can be overridden
virtual double strength() const { return 1.0; }
};
//==============================================================================
//! Source composed of independent spatial, angle, and energy distributions
//==============================================================================
class IndependentSource : public Source {
public:
// Constructors
SourceDistribution(UPtrSpace space, UPtrAngle angle, UPtrDist energy);
explicit SourceDistribution(pugi::xml_node node);
IndependentSource(UPtrSpace space, UPtrAngle angle, UPtrDist energy);
explicit IndependentSource(pugi::xml_node node);
//! Sample from the external source distribution
//! \param[inout] seed Pseudorandom seed pointer
//! \return Sampled site
Particle::Bank sample(uint64_t* seed) const;
Particle::Bank sample(uint64_t* seed) const override;
// Properties
Particle::Type particle_type() const { return particle_; }
double strength() const { return strength_; }
double strength() const override { return strength_; }
// Make observing pointers available
SpatialDistribution* space() const { return space_.get(); }
@ -59,14 +74,45 @@ private:
UPtrDist energy_; //!< Energy distribution
};
class CustomSource {
public:
virtual ~CustomSource() {}
//==============================================================================
//! Source composed of particles read from a file
//==============================================================================
virtual Particle::Bank sample(uint64_t* seed) = 0;
class FileSource : public Source {
public:
// Constructors
explicit FileSource(std::string path);
// Methods
Particle::Bank sample(uint64_t* seed) const override;
private:
std::vector<Particle::Bank> sites_; //!< Source sites from a file
};
typedef std::unique_ptr<CustomSource> create_custom_source_t(std::string parameters);
//==============================================================================
//! Wrapper for custom sources that manages opening/closing shared library
//==============================================================================
class CustomSourceWrapper : public Source {
public:
// Constructors, destructors
CustomSourceWrapper(std::string path, std::string parameters);
~CustomSourceWrapper();
// Defer implementation to custom source library
Particle::Bank sample(uint64_t* seed) const override
{
return custom_source_->sample(seed);
}
double strength() const override { return custom_source_->strength(); }
private:
void* shared_library_; //!< library from dlopen
std::unique_ptr<Source> custom_source_;
};
typedef std::unique_ptr<Source> create_custom_source_t(std::string parameters);
//==============================================================================
// Functions
@ -81,18 +127,6 @@ extern "C" void initialize_source();
//! \return Sampled source site
Particle::Bank sample_external_source(uint64_t* seed);
//! Sample a site from custom source library
Particle::Bank sample_custom_source_library(uint64_t* seed);
//! Load custom source library
void load_custom_source_library();
//! Release custom source library
void close_custom_source_library();
//! Fill source bank at the end of a generation for dlopen based source simulation
void fill_source_bank_custom_source();
void free_memory_source();
} // namespace openmc

View file

@ -2,17 +2,19 @@
#define OPENMC_STATE_POINT_H
#include <cstdint>
#include <vector>
#include "hdf5.h"
#include "openmc/capi.h"
#include "openmc/particle.h"
namespace openmc {
void load_state_point();
void write_source_point(const char* filename);
void write_source_bank(hid_t group_id);
void read_source_bank(hid_t group_id);
void read_source_bank(hid_t group_id, std::vector<Particle::Bank>& sites, bool distribute);
void write_tally_results_nr(hid_t file_id);
void restart_set_keff();

View file

@ -21,7 +21,6 @@ extern Timer time_finalize;
extern Timer time_inactive;
extern Timer time_initialize;
extern Timer time_read_xs;
extern Timer time_sample_source;
extern Timer time_statepoint;
extern Timer time_tallies;
extern Timer time_total;

View file

@ -366,8 +366,6 @@ class CMFDRun:
self._current = None
self._cmfd_src = None
self._openmc_src = None
self._sourcecounts = None
self._weightfactors = None
self._entropy = []
self._balance = []
self._src_cmp = []
@ -914,7 +912,7 @@ class CMFDRun:
args = temp_loss.indptr, len(temp_loss.indptr), \
temp_loss.indices, len(temp_loss.indices), n, \
self._spectral, self._indices, coremap, self._use_all_threads
self._spectral, coremap, self._use_all_threads
return openmc.lib._dll.openmc_initialize_linsolver(*args)
def _write_cmfd_output(self):
@ -1171,8 +1169,12 @@ class CMFDRun:
# Calculate fission source
self._calc_fission_source()
# Calculate weight factors
self._cmfd_reweight()
# Calculate weight factors through C++ and manipulate CMFD
# source into a 1-D vector that matches C++ array ordering
src_flipped = np.flip(self._cmfd_src, axis=3)
src_swapped = np.swapaxes(src_flipped, 0, 2)
args = self._feedback, src_swapped.flatten()
openmc.lib._dll.openmc_cmfd_reweight(*args)
# Stop CMFD timer
if openmc.lib.master():
@ -1390,151 +1392,6 @@ class CMFDRun:
self._src_cmp.append(np.sqrt(1.0 / self._norm
* np.sum((self._cmfd_src - self._openmc_src)**2)))
def _cmfd_reweight(self):
"""Performs weighting of particles in source bank"""
# Get spatial dimensions and energy groups
nx, ny, nz, ng = self._indices
# Count bank site in mesh and reverse due to egrid structured
outside = self._count_bank_sites()
# Check and raise error if source sites exist outside of CMFD mesh
if openmc.lib.master() and outside:
raise OpenMCError('Source sites outside of the CMFD mesh')
# Have master compute weight factors, ignore any zeros in
# sourcecounts or cmfd_src
if openmc.lib.master():
# Compute normalization factor
norm = np.sum(self._sourcecounts) / np.sum(self._cmfd_src)
# Define target reshape dimensions for sourcecounts. This
# defines how self._sourcecounts is ordered by dimension
target_shape = [nz, ny, nx, ng]
# Reshape sourcecounts to target shape. Swap x and z axes so
# that the shape is now [nx, ny, nz, ng]
sourcecounts = np.swapaxes(
self._sourcecounts.reshape(target_shape), 0, 2)
# Flip index of energy dimension
sourcecounts = np.flip(sourcecounts, axis=3)
# Compute weight factors
div_condition = np.logical_and(sourcecounts > 0,
self._cmfd_src > 0)
self._weightfactors = (np.divide(self._cmfd_src * norm,
sourcecounts, where=div_condition,
out=np.ones_like(self._cmfd_src),
dtype=np.float32))
if not self._feedback:
return
# Broadcast weight factors to all procs
if have_mpi:
self._weightfactors = self._intracomm.bcast(
self._weightfactors)
m = openmc.lib.meshes[self._mesh_id]
energy = self._egrid
ng = self._indices[3]
# Get locations and energies of all particles in source bank
source_xyz = openmc.lib.source_bank()['r']
source_energies = openmc.lib.source_bank()['E']
# Convert xyz location to the CMFD mesh index
mesh_ijk = np.floor((source_xyz - m.lower_left)/m.width).astype(int)
# Determine which energy bin each particle's energy belongs to
# Separate into cases bases on where source energies lies on egrid
energy_bins = np.zeros(len(source_energies), dtype=int)
idx = np.where(source_energies < energy[0])
energy_bins[idx] = ng - 1
idx = np.where(source_energies > energy[-1])
energy_bins[idx] = 0
idx = np.where((source_energies >= energy[0]) &
(source_energies <= energy[-1]))
energy_bins[idx] = ng - np.digitize(source_energies[idx], energy)
# Determine weight factor of each particle based on its mesh index
# and energy bin and updates its weight
openmc.lib.source_bank()['wgt'] *= self._weightfactors[
mesh_ijk[:,0], mesh_ijk[:,1], mesh_ijk[:,2], energy_bins]
if openmc.lib.master() and np.any(source_energies < energy[0]):
print(' WARNING: Source point below energy grid')
sys.stdout.flush()
if openmc.lib.master() and np.any(source_energies > energy[-1]):
print(' WARNING: Source point above energy grid')
sys.stdout.flush()
def _count_bank_sites(self):
"""Determines the number of fission bank sites in each cell of a given
mesh and energy group structure.
Returns
-------
bool
Wheter any source sites outside of CMFD mesh were found
"""
# Initialize variables
m = openmc.lib.meshes[self._mesh_id]
bank = openmc.lib.source_bank()
energy = self._egrid
sites_outside = np.zeros(1, dtype=bool)
nxnynz = np.prod(self._indices[0:3])
ng = self._indices[3]
outside = np.zeros(1, dtype=bool)
self._sourcecounts = np.zeros((nxnynz, ng))
count = np.zeros(self._sourcecounts.shape)
# Get location and energy of each particle in source bank
source_xyz = openmc.lib.source_bank()['r']
source_energies = openmc.lib.source_bank()['E']
# Convert xyz location to mesh index and ravel index to scalar
mesh_locations = np.floor((source_xyz - m.lower_left) / m.width)
mesh_bins = mesh_locations[:,2] * m.dimension[1] * m.dimension[0] + \
mesh_locations[:,1] * m.dimension[0] + mesh_locations[:,0]
# Check if any source locations lie outside of defined CMFD mesh
if np.any(mesh_bins < 0) or np.any(mesh_bins >= np.prod(m.dimension)):
outside[0] = True
# Determine which energy bin each particle's energy belongs to
# Separate into cases bases on where source energies lies on egrid
energy_bins = np.zeros(len(source_energies), dtype=int)
idx = np.where(source_energies < energy[0])
energy_bins[idx] = 0
idx = np.where(source_energies > energy[-1])
energy_bins[idx] = ng - 1
idx = np.where((source_energies >= energy[0]) &
(source_energies <= energy[-1]))
energy_bins[idx] = np.digitize(source_energies[idx], energy) - 1
# Determine all unique combinations of mesh bin and energy bin, and
# count number of particles that belong to these combinations
idx, counts = np.unique(np.array([mesh_bins, energy_bins]), axis=1,
return_counts=True)
# Store counts to appropriate mesh-energy combination
count[idx[0].astype(int), idx[1].astype(int)] = counts
if have_mpi:
# Collect values of count from all processors
self._intracomm.Reduce(count, self._sourcecounts, MPI.SUM)
# Check if there were sites outside the mesh for any processor
self._intracomm.Reduce(outside, sites_outside, MPI.LOR)
# Deal with case if MPI not defined (only one proc)
else:
sites_outside = outside
self._sourcecounts = count
return sites_outside[0]
def _build_loss_matrix(self, adjoint):
# Extract spatial and energy indices and define matrix dimension
ng = self._indices[3]
@ -3045,3 +2902,7 @@ class CMFDRun:
# Set all tallies to be active from beginning
cmfd_tally.active = True
# Initialize CMFD mesh and energy grid in C++ for CMFD reweight
args = self._tally_ids[0], self._indices, self._norm
openmc.lib._dll.openmc_initialize_mesh_egrid(*args)

View file

@ -56,7 +56,7 @@ REACTION_NAME = {1: '(n,total)', 2: '(n,elastic)', 4: '(n,level)',
301: 'heating', 444: 'damage-energy',
649: '(n,pc)', 699: '(n,dc)', 749: '(n,tc)', 799: '(n,3Hec)',
849: '(n,ac)', 891: '(n,2nc)', 901: 'heating-local'}
REACTION_NAME.update({i: '(n,n{})'.format(i - 50) for i in range(50, 91)})
REACTION_NAME.update({i: '(n,n{})'.format(i - 50) for i in range(51, 91)})
REACTION_NAME.update({i: '(n,p{})'.format(i - 600) for i in range(600, 649)})
REACTION_NAME.update({i: '(n,d{})'.format(i - 650) for i in range(650, 699)})
REACTION_NAME.update({i: '(n,t{})'.format(i - 700) for i in range(700, 749)})
@ -64,6 +64,9 @@ REACTION_NAME.update({i: '(n,3He{})'.format(i - 750) for i in range(750, 799)})
REACTION_NAME.update({i: '(n,a{})'.format(i - 800) for i in range(800, 849)})
REACTION_NAME.update({i: '(n,2n{})'.format(i - 875) for i in range(875, 891)})
REACTION_MT = {name: mt for mt, name in REACTION_NAME.items()}
REACTION_MT['fission'] = 18
FISSION_MTS = (18, 19, 20, 21, 38)

View file

@ -1,17 +1,18 @@
"""
Class for normalizing fission energy deposition
"""
import bisect
from collections import defaultdict
from copy import deepcopy
from itertools import product
from numbers import Real
import bisect
from collections import defaultdict
import sys
from numpy import dot, zeros, newaxis, asarray
from . import comm
from openmc.checkvalue import check_type, check_greater_than
from openmc.data import JOULE_PER_EV, REACTION_NAME
from openmc.data import JOULE_PER_EV, REACTION_MT
from openmc.lib import (
Tally, MaterialFilter, EnergyFilter, EnergyFunctionFilter)
import openmc.lib
@ -168,10 +169,8 @@ class FluxCollapseHelper(ReactionRateHelper):
"""
self._materials = materials
# Convert reactions to MT values (needed when collapsing)
mt_values = {v: k for k, v in REACTION_NAME.items()}
mt_values['fission'] = 18
self._mts = [mt_values[x] for x in scores]
# adds an entry for fisson to the dictionary of reactions
self._mts = [REACTION_MT[x] for x in scores]
self._scores = scores
# Create flux tally with material and energy filters

Some files were not shown because too many files have changed in this diff Show more