Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into no_XS_in_volume
Browse files Browse the repository at this point in the history
  • Loading branch information
bam241 committed Nov 2, 2023
2 parents b938be2 + 847e9b5 commit d077a2c
Show file tree
Hide file tree
Showing 93 changed files with 1,035 additions and 542 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Fixes # (issue)
# Checklist

- [ ] I have performed a self-review of my own code
- [ ] I have run [clang-format](https://docs.openmc.org/en/latest/devguide/styleguide.html#automatic-formatting) on any C++ source files (if applicable)
- [ ] I have run [clang-format](https://docs.openmc.org/en/latest/devguide/styleguide.html#automatic-formatting) (version 15) on any C++ source files (if applicable)
- [ ] I have followed the [style guidelines](https://docs.openmc.org/en/latest/devguide/styleguide.html#python) for Python source files (if applicable)
- [ ] I have made corresponding changes to the documentation (if applicable)
- [ ] I have added tests that prove my fix is effective or that my feature works (if applicable)
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ project(openmc C CXX)

# Set version numbers
set(OPENMC_VERSION_MAJOR 0)
set(OPENMC_VERSION_MINOR 13)
set(OPENMC_VERSION_RELEASE 4)
set(OPENMC_VERSION_MINOR 14)
set(OPENMC_VERSION_RELEASE 0)
set(OPENMC_VERSION ${OPENMC_VERSION_MAJOR}.${OPENMC_VERSION_MINOR}.${OPENMC_VERSION_RELEASE})
configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY)

Expand Down Expand Up @@ -120,6 +120,7 @@ if(OPENMC_USE_DAGMC)
message(FATAL_ERROR "Discovered DAGMC Version: ${DAGMC_VERSION}. \
Please update DAGMC to version 3.2.0 or greater.")
endif()
message(STATUS "Found DAGMC: ${DAGMC_DIR} (version ${DAGMC_VERSION})")
endif()

#===============================================================================
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
# built documents.
#
# The short X.Y version.
version = "0.13"
version = "0.14"
# The full version, including alpha/beta/rc tags.
release = "0.13.4"
release = "0.14.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 4 additions & 0 deletions docs/source/devguide/styleguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ whenever a file is saved. For example, `Visual Studio Code
<https://code.visualstudio.com/docs/cpp/cpp-ide#_code-formatting>`_ includes
support for running clang-format.

.. note::
OpenMC's CI uses `clang-format` version 15. A different version of `clang-format`
may produce different line changes and as a result fail the CI test.

Miscellaneous
-------------

Expand Down
25 changes: 25 additions & 0 deletions docs/source/devguide/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ If you want to view testing output on failure run::

ctest --output-on-failure

Possible Reasons for Test Failures
----------------------------------

You may find that when you run the test suite, not everything passes. First,
make sure you have satisfied all the prerequisites above. After you have done
that, consider the following:

- When building OpenMC, make sure you run CMake with
``-DCMAKE_BUILD_TYPE=Debug``. Building with a release build will result in
some test failures due to differences in which compiler optimizations are
used.
- Because tallies involve the sum of many floating point numbers, the
non-associativity of floating point numbers can result in different answers
especially when the number of threads is high (different order of operations).
Thus, if you are running on a CPU with many cores, you may need to limit the
number of OpenMP threads used. It is recommended to set the
:envvar:`OMP_NUM_THREADS` environment variable to 2.
- Recent versions of NumPy use instruction dispatch that may generate different
results depending the particular ISA that you are running on. To avoid issues,
you may need to disable AVX512 instructions. This can be done by setting the
:envvar:`NPY_DISABLE_CPU_FEATURES` environment variable to "AVX512F
AVX512_SKX". When NumPy/SciPy are built against OpenBLAS, you may also need to
limit the number of threads that OpenBLAS uses internally; this can be done by
setting the :envvar:`OPENBLAS_NUM_THREADS` environment variable to 1.

Generating XML Inputs
---------------------

Expand Down
8 changes: 5 additions & 3 deletions docs/source/io_formats/summary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ The current version of the summary file format is 6.0.
- **coefficients** (*double[]*) -- Array of coefficients that define
the surface. See :ref:`surface_element` for what coefficients are
defined for each surface type.
- **boundary_condition** (*char[]*) -- Boundary condition applied to
the surface. Can be 'transmission', 'vacuum', 'reflective', or
'periodic'.
- **boundary_type** (*char[]*) -- Boundary condition applied to
the surface. Can be 'transmission', 'vacuum', 'reflective',
'periodic', or 'white'.
- **albedo** (*double*) -- Boundary albedo as a positive multiplier
of particle weight. If absent, it is assumed to be 1.0.
- **geom_type** (*char[]*) -- Type of geometry used to create the cell.
Either 'csg' or 'dagmc'.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/pythonapi/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Convenience Functions
:template: myfunction.rst

openmc.model.borated_water
openmc.model.hexagonal_prism
openmc.model.rectangular_prism
openmc.model.subdivide
openmc.model.pin

Expand All @@ -26,9 +24,11 @@ Composite Surfaces

openmc.model.CruciformPrism
openmc.model.CylinderSector
openmc.model.HexagonalPrism
openmc.model.IsogonalOctagon
openmc.model.Polygon
openmc.model.RectangularParallelepiped
openmc.model.RectangularPrism
openmc.model.RightCircularCylinder
openmc.model.XConeOneSided
openmc.model.YConeOneSided
Expand Down
45 changes: 32 additions & 13 deletions docs/source/usersguide/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ For many regions, a bounding-box can be determined automatically::
While a bounding box can be determined for regions involving half-spaces of
spheres, cylinders, and axis-aligned planes, it generally cannot be determined
if the region involves cones, non-axis-aligned planes, or other exotic
second-order surfaces. For example, the :func:`openmc.model.hexagonal_prism`
function returns the interior region of a hexagonal prism; because it is bounded
by a :class:`openmc.Plane`, trying to get its bounding box won't work::
second-order surfaces. For example, the :class:`openmc.model.HexagonalPrism`
class returns a hexagonal prism surface; because it utilizes a
:class:`openmc.Plane`, trying to get the bounding box of its interior won't
work::

>>> hex = openmc.model.hexagonal_prism()
>>> hex.bounding_box
>>> hex = openmc.model.HexagonalPrism()
>>> (-hex).bounding_box
(array([-0.8660254, -inf, -inf]),
array([ 0.8660254, inf, inf]))

Expand All @@ -172,13 +173,17 @@ surface. To specify a vacuum boundary condition, simply change the
outer_surface = openmc.Sphere(r=100.0)
outer_surface.boundary_type = 'vacuum'

Reflective and periodic boundary conditions can be set with the strings
'reflective' and 'periodic'. Vacuum and reflective boundary conditions can be
applied to any type of surface. Periodic boundary conditions can be applied to
pairs of planar surfaces. If there are only two periodic surfaces they will be
matched automatically. Otherwise it is necessary to specify pairs explicitly
using the :attr:`Surface.periodic_surface` attribute as in the following
example::
Reflective, periodic, and white boundary conditions can be set with the
strings 'reflective', 'periodic', and 'white' respectively.
Vacuum, reflective and white boundary conditions can be applied to any
type of surface. The 'white' boundary condition supports diffuse particle
reflection in contrast to specular reflection provided by the 'reflective'
boundary condition.

Periodic boundary conditions can be applied to pairs of planar surfaces.
If there are only two periodic surfaces they will be matched automatically.
Otherwise it is necessary to specify pairs explicitly using the
:attr:`Surface.periodic_surface` attribute as in the following example::

p1 = openmc.Plane(a=0.3, b=5.0, d=1.0, boundary_type='periodic')
p2 = openmc.Plane(a=0.3, b=5.0, d=-1.0, boundary_type='periodic')
Expand All @@ -196,6 +201,20 @@ lies in the first quadrant of the Cartesian grid. If the geometry instead lies
in the fourth quadrant, the :class:`YPlane` must be replaced by a
:class:`Plane` with the normal vector pointing in the :math:`-y` direction.

Additionally, 'reflective', 'periodic', and 'white' boundary conditions have
an albedo parameter that can be used to modify the importance of particles
that encounter the boundary. The albedo value specifies the ratio between
the particle's importance after interaction with the boundary to its initial
importance. The following example creates a reflective planar surface which
reduces the reflected particles' importance by 33.3%::

x1 = openmc.XPlane(1.0, boundary_type='reflective', albedo=0.667)

# This is equivalent
x1 = openmc.XPlane(1.0)
x1.boundary_type = 'reflective'
x1.albedo = 0.667

.. _usersguide_cells:

-----
Expand Down Expand Up @@ -410,7 +429,7 @@ code would work::
hexlat.universes = [outer_ring, middle_ring, inner_ring]

If you need to create a hexagonal boundary (composed of six planar surfaces) for
a hexagonal lattice, :func:`openmc.model.hexagonal_prism` can be used.
a hexagonal lattice, :class:`openmc.model.HexagonalPrism` can be used.

.. _usersguide_geom_export:

Expand Down
4 changes: 2 additions & 2 deletions examples/assembly/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def assembly_model():
assembly.universes[gt_pos[:, 0], gt_pos[:, 1]] = guide_tube_pin()

# Create outer boundary of the geometry to surround the lattice
outer_boundary = openmc.model.rectangular_prism(
outer_boundary = openmc.model.RectangularPrism(
pitch, pitch, boundary_type='reflective')

# Create a cell filled with the lattice
main_cell = openmc.Cell(fill=assembly, region=outer_boundary)
main_cell = openmc.Cell(fill=assembly, region=-outer_boundary)

# Finally, create geometry by providing a list of cells that fill the root
# universe
Expand Down
4 changes: 2 additions & 2 deletions examples/custom_source/build_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
mats.export_to_xml()

# Create a 5 cm x 5 cm box filled with iron
box = openmc.model.rectangular_prism(10.0, 10.0, boundary_type='vacuum')
cell = openmc.Cell(fill=iron, region=box)
box = openmc.model.RectangularPrism(10.0, 10.0, boundary_type='vacuum')
cell = openmc.Cell(fill=iron, region=-box)
geometry = openmc.Geometry([cell])
geometry.export_to_xml()

Expand Down
4 changes: 2 additions & 2 deletions examples/parameterized_custom_source/build_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
mats.export_to_xml()

# Create a 5 cm x 5 cm box filled with iron
box = openmc.model.rectangular_prism(10.0, 10.0, boundary_type='vacuum')
cell = openmc.Cell(fill=iron, region=box)
box = openmc.model.RectangularPrism(10.0, 10.0, boundary_type='vacuum')
cell = openmc.Cell(fill=iron, region=-box)
geometry = openmc.Geometry([cell])
geometry.export_to_xml()

Expand Down
4 changes: 2 additions & 2 deletions examples/pincell/build_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@

# Create a region represented as the inside of a rectangular prism
pitch = 1.25984
box = openmc.rectangular_prism(pitch, pitch, boundary_type='reflective')
box = openmc.model.RectangularPrism(pitch, pitch, boundary_type='reflective')

# Create cells, mapping materials to regions
fuel = openmc.Cell(fill=uo2, region=-fuel_or)
gap = openmc.Cell(fill=helium, region=+fuel_or & -clad_ir)
clad = openmc.Cell(fill=zircaloy, region=+clad_ir & -clad_or)
water = openmc.Cell(fill=borated_water, region=+clad_or & box)
water = openmc.Cell(fill=borated_water, region=+clad_or & -box)

# Create a geometry and export to XML
geometry = openmc.Geometry([fuel, gap, clad, water])
Expand Down
4 changes: 2 additions & 2 deletions examples/pincell_depletion/run_depletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
fuel_or = openmc.ZCylinder(r=0.39218, name='Fuel OR')
clad_ir = openmc.ZCylinder(r=0.40005, name='Clad IR')
clad_or = openmc.ZCylinder(r=0.45720, name='Clad OR')
box = openmc.model.rectangular_prism(pitch, pitch, boundary_type='reflective')
box = openmc.model.RectangularPrism(pitch, pitch, boundary_type='reflective')

# Define cells
fuel = openmc.Cell(fill=uo2, region=-fuel_or)
gap = openmc.Cell(fill=helium, region=+fuel_or & -clad_ir)
clad = openmc.Cell(fill=zircaloy, region=+clad_ir & -clad_or)
water = openmc.Cell(fill=borated_water, region=+clad_or & box)
water = openmc.Cell(fill=borated_water, region=+clad_or & -box)

# Define overall geometry
geometry = openmc.Geometry([fuel, gap, clad, water])
Expand Down
4 changes: 2 additions & 2 deletions examples/pincell_multigroup/build_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@

# Create a region represented as the inside of a rectangular prism
pitch = 1.26
box = openmc.rectangular_prism(pitch, pitch, boundary_type='reflective')
box = openmc.model.RectangularPrism(pitch, pitch, boundary_type='reflective')

# Instantiate Cells
fuel = openmc.Cell(fill=uo2, region=-fuel_or, name='fuel')
moderator = openmc.Cell(fill=water, region=+fuel_or & box, name='moderator')
moderator = openmc.Cell(fill=water, region=+fuel_or & -box, name='moderator')

# Create a geometry with the two cells and export to XML
geometry = openmc.Geometry([fuel, moderator])
Expand Down
39 changes: 39 additions & 0 deletions include/openmc/boundary_condition.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#ifndef OPENMC_BOUNDARY_CONDITION_H
#define OPENMC_BOUNDARY_CONDITION_H

#include "openmc/hdf5_interface.h"
#include "openmc/particle.h"
#include "openmc/position.h"
#include <fmt/core.h>

namespace openmc {

Expand All @@ -22,8 +25,44 @@ class BoundaryCondition {
//! \param surf The specific surface on the boundary the particle struck.
virtual void handle_particle(Particle& p, const Surface& surf) const = 0;

//! Modify the incident particle's weight according to the boundary's albedo.
//! \param p The particle that struck the boundary. This function calculates
//! the reduction in the incident particle's weight as it interacts
//! with a boundary. The lost weight is tallied before the remaining weight
//! is reassigned to the incident particle. Implementations of the
//! handle_particle function typically call this method in its body.
//! \param surf The specific surface on the boundary the particle struck.
void handle_albedo(Particle& p, const Surface& surf) const
{
if (!has_albedo())
return;
double initial_wgt = p.wgt();
// Treat the lost weight fraction as leakage, similar to VacuumBC.
// This ensures the lost weight is tallied properly.
p.wgt() *= (1.0 - albedo_);
p.cross_vacuum_bc(surf);
p.wgt() = initial_wgt * albedo_;
};

//! Return a string classification of this BC.
virtual std::string type() const = 0;

//! Write albedo data of this BC to hdf5.
void to_hdf5(hid_t surf_group) const
{
if (has_albedo()) {
write_string(surf_group, "albedo", fmt::format("{}", albedo_), false);
}
};

//! Set albedo of this BC.
void set_albedo(double albedo) { albedo_ = albedo; }

//! Return if this BC has an albedo.
bool has_albedo() const { return (albedo_ > 0.0); }

private:
double albedo_ = -1.0;
};

//==============================================================================
Expand Down
8 changes: 4 additions & 4 deletions include/openmc/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ struct BoundingBox {

class Surface {
public:
int id_; //!< Unique ID
std::string name_; //!< User-defined name
std::shared_ptr<BoundaryCondition> bc_ {nullptr}; //!< Boundary condition
GeometryType geom_type_; //!< Geometry type indicator (CSG or DAGMC)
int id_; //!< Unique ID
std::string name_; //!< User-defined name
unique_ptr<BoundaryCondition> bc_; //!< Boundary condition
GeometryType geom_type_; //!< Geometry type indicator (CSG or DAGMC)
bool surf_source_ {false}; //!< Activate source banking for the surface?

explicit Surface(pugi::xml_node surf_node);
Expand Down
4 changes: 2 additions & 2 deletions openmc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from .config import *

# Import a few names from the model module
from openmc.model import rectangular_prism, hexagonal_prism, Model
from openmc.model import Model


__version__ = '0.13.4-dev'
__version__ = '0.14.0-dev'
2 changes: 1 addition & 1 deletion openmc/bounding_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class BoundingBox:
"""Axis-aligned bounding box.
.. versionadded:: 0.13.4
.. versionadded:: 0.14.0
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion openmc/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def clone(self, clone_materials=True, clone_regions=True, memo=None):
def plot(self, *args, **kwargs):
"""Display a slice plot of the cell.
.. versionadded:: 0.13.4
.. versionadded:: 0.14.0
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion openmc/data/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DataLibrary(list):
cross section data from a single file. The dictionary has keys 'path',
'type', and 'materials'.
.. versionchanged:: 0.13.4
.. versionchanged:: 0.14.0
This class now behaves like a list rather than requiring you to access
the list of libraries through a special attribute.
Expand Down
2 changes: 1 addition & 1 deletion openmc/deplete/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ class Integrator(ABC):
transfer_rates : openmc.deplete.TransferRates
Instance of TransferRates class to perform continuous transfer during depletion
.. versionadded:: 0.13.4
.. versionadded:: 0.14.0
"""

Expand Down
Loading

0 comments on commit d077a2c

Please sign in to comment.