Skip to content

Commit c2b9da6

Browse files
authored
Merge branch 'develop' into tdrr-clean-refactor
2 parents 80e4cff + 5bce5ad commit c2b9da6

File tree

93 files changed

+4096
-681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4096
-681
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
path: |
155155
~/nndc_hdf5
156156
~/endf-b-vii.1
157-
key: ${{ runner.os }}-build-xs-cache
157+
key: ${{ runner.os }}-build-xs-cache-${{ hashFiles(format('{0}/tools/ci/download-xs.sh', github.workspace)) }}
158158

159159
- name: before
160160
shell: bash
@@ -186,6 +186,7 @@ jobs:
186186
--gcov-ignore-errors source_not_found \
187187
--gcov-ignore-errors output_error \
188188
--gcov-ignore-parse-errors suspicious_hits.warn \
189+
--merge-mode-functions=separate \
189190
--print-summary \
190191
--lcov -o coverage-cpp.lcov || true
191192

docs/source/io_formats/geometry.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ the following attributes or sub-elements:
316316
*Default*: None
317317

318318
:orientation:
319-
The orientation of the hexagonal lattice. The string "x" indicates that two
320-
sides of the lattice are parallel to the x-axis, whereas the string "y"
321-
indicates that two sides are parallel to the y-axis.
319+
The orientation of the hexagonal lattice. The string "x" indicates that each
320+
lattice element has two faces that are perpendicular to the x-axis, whereas
321+
the string "y" indicates that each lattice element has two faces that are
322+
perpendicular to the y-axis.
322323

323324
*Default*: "y"
324325

docs/source/io_formats/settings.rst

Lines changed: 95 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,15 @@ ignored for all run modes other than "eigenvalue".
277277

278278
*Default*: 1
279279

280+
------------------------------
281+
``<ifp_n_generation>`` Element
282+
------------------------------
283+
284+
The ``<ifp_n_generation>`` element indicates the number of generations to
285+
consider for the Iterated Fission Probability method.
286+
287+
*Default*: 10
288+
280289
----------------------
281290
``<inactive>`` Element
282291
----------------------
@@ -414,7 +423,25 @@ then, OpenMC will only use up to the :math:`P_1` data.
414423
``<max_history_splits>`` Element
415424
--------------------------------
416425

417-
The ``<max_history_splits>`` element indicates the number of times a particle can split during a history.
426+
The ``<max_history_splits>`` element indicates the number of times a particle
427+
can split during a history.
428+
429+
*Default*: 1000
430+
431+
-----------------------------
432+
``<max_secondaries>`` Element
433+
-----------------------------
434+
435+
The ``<max_secondaries>`` element indicates the maximum secondary bank size.
436+
437+
*Default*: 10000
438+
439+
------------------------
440+
``<max_tracks>`` Element
441+
------------------------
442+
443+
The ``<max_tracks>`` element indicates the maximum number of tracks written to a
444+
track file (per MPI process).
418445

419446
*Default*: 1000
420447

@@ -875,13 +902,18 @@ attributes/sub-elements:
875902
relative source strength of each mesh element or each point in the cloud.
876903

877904
:volume_normalized:
878-
For "mesh" spatial distrubtions, this optional boolean element specifies
905+
For "mesh" spatial distributions, this optional boolean element specifies
879906
whether the vector of relative strengths should be multiplied by the mesh
880907
element volume. This is most common if the strengths represent a source
881908
per unit volume.
882909

883910
*Default*: false
884911

912+
:bias:
913+
For "mesh" and "cloud" spatial distributions, this optional element
914+
specifies floating point values corresponding to alternative probabilities
915+
for each value/component to use for biased sampling.
916+
885917
:angle:
886918
An element specifying the angular distribution of source sites. This element
887919
has the following attributes:
@@ -914,6 +946,10 @@ attributes/sub-elements:
914946
are those of a univariate probability distribution (see the description in
915947
:ref:`univariate`).
916948

949+
:bias:
950+
For "isotropic" angular distributions, this optional element specifies a
951+
"mu-phi" angular distribution used for biased sampling.
952+
917953
:energy:
918954
An element specifying the energy distribution of source sites. The necessary
919955
sub-elements/attributes are those of a univariate probability distribution
@@ -937,6 +973,10 @@ attributes/sub-elements:
937973
mesh element and follows the format for :ref:`source_element`. The number of
938974
``<source>`` sub-elements should correspond to the number of mesh elements.
939975

976+
.. note:: Biased sampling can be applied to the spatial and energy distributions
977+
of a source by using the ``<bias>`` sub-element (see
978+
:ref:`univariate` for details on how to specify bias distributions).
979+
940980
:constraints:
941981
This sub-element indicates the presence of constraints on sampled source
942982
sites (see :ref:`usersguide_source_constraints` for details). It may have
@@ -1029,13 +1069,26 @@ variable and whose sub-elements/attributes are as follows:
10291069
*Default*: histogram
10301070

10311071
:pair:
1032-
For a "mixture" distribution, this element provides a distribution and its corresponding probability.
1072+
For a "mixture" distribution, this element provides a distribution and its
1073+
corresponding probability.
10331074

10341075
:probability:
1035-
An attribute or ``pair`` that provides the probability of a univariate distribution within a "mixture" distribution.
1076+
An attribute or ``pair`` that provides the probability of a univariate
1077+
distribution within a "mixture" distribution.
10361078

10371079
:dist:
1038-
This sub-element of a ``pair`` element provides information on the corresponding univariate distribution.
1080+
This sub-element of a ``pair`` element provides information on the
1081+
corresponding univariate distribution.
1082+
1083+
:bias:
1084+
This optional element specifies a biased distribution for importance sampling.
1085+
For continuous distributions, the ``bias`` element should contain another
1086+
univariate distribution with the same support (interval) as the parent
1087+
distribution. For discrete distributions, the ``bias`` element should contain
1088+
floating point values corresponding to alternative probabilities for each
1089+
value/component to be used for biased sampling.
1090+
1091+
*Default*: None
10391092

10401093
---------------------------------------
10411094
``<source_rejection_fraction>`` Element
@@ -1409,6 +1462,15 @@ has the following attributes/sub-elements:
14091462
for fixed source and small criticality calculations, but is very
14101463
optimistic for highly coupled full-core reactor problems.
14111464

1465+
-------------------------------------
1466+
``<uniform_source_sampling>`` Element
1467+
-------------------------------------
1468+
1469+
The ``<uniform_source_sampling>`` element indicates whether to sample among
1470+
multiple sources uniformly, applying their strengths as weights to sampled
1471+
particles.
1472+
1473+
*Default*: False
14121474

14131475
------------------------
14141476
``<ufs_mesh>`` Element
@@ -1421,6 +1483,16 @@ Agency Monte Carlo Performance Benchmark Problem," Proceedings of *Physor 2012*,
14211483
Knoxville, TN (2012). The mesh should cover all possible fissionable materials
14221484
in the problem and is specified using a :ref:`mesh_element`.
14231485

1486+
-------------------------------
1487+
``<use_decay_photons>`` Element
1488+
-------------------------------
1489+
1490+
The ``<use_decay_photons>`` element indicates whether to produce decay photons
1491+
from neutron reactions instead of prompt photons. This is used in conjunction
1492+
with the direct 1-step method for shutdown dose rate calculations.
1493+
1494+
*Default*: False
1495+
14241496
.. _verbosity:
14251497

14261498
-----------------------
@@ -1651,3 +1723,21 @@ following sub-elements/attributes:
16511723

16521724
The ``weight_windows_file`` element has no attributes and contains the path to
16531725
a weight windows HDF5 file to load during simulation initialization.
1726+
1727+
-------------------------------
1728+
``<weight_windows_on>`` Element
1729+
-------------------------------
1730+
1731+
The ``weight_windows_on`` element indicates whether weight windows are
1732+
enabled.
1733+
1734+
*Default*: False
1735+
1736+
----------------------------------
1737+
``<write_initial_source>`` Element
1738+
----------------------------------
1739+
1740+
The ``write_initial_source`` element indicates whether to write the initial
1741+
source distribution to file.
1742+
1743+
*Default*: False

docs/source/methods/variance_reduction.rst

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ not experience a single scoring event, even after billions of analog histories.
2222
Variance reduction techniques aim to either flatten the global uncertainty
2323
distribution, such that all regions of phase space have a fairly similar
2424
uncertainty, or to reduce the uncertainty in specific locations (such as a
25-
detector). There are two strategies available in OpenMC for variance reduction:
26-
the Monte Carlo MAGIC method and the FW-CADIS method. Both strategies work by
27-
developing a weight window mesh that can be utilized by subsequent Monte Carlo
28-
solves to split particles heading towards areas of lower flux densities while
29-
terminating particles in higher flux regions---all while maintaining a fair
30-
game.
25+
detector). There are three strategies available in OpenMC for variance
26+
reduction: weight windows generated via the MAGIC method or the FW-CADIS method,
27+
and source biasing. Both weight windowing strategies work by developing a mesh
28+
that can be utilized by subsequent Monte Carlo solves to split particles heading
29+
towards areas of lower flux densities while terminating particles in higher flux
30+
regions. In contrast, source biasing modifies source site sampling behavior to
31+
preferentially track particles more likely to reach phase space regions of
32+
interest.
3133

3234
------------
3335
MAGIC Method
@@ -132,3 +134,71 @@ aware of this.
132134
:label: variance_fom
133135
134136
\text{FOM} = \frac{1}{\text{Time} \times \sigma^2}
137+
138+
.. _methods_source_biasing:
139+
140+
--------------
141+
Source Biasing
142+
--------------
143+
144+
In contrast to the previous two methods that introduce population controls
145+
during transport, source biasing modifies the sampling of the external source
146+
distribution. The basic premise of the technique is that for each spatial,
147+
angular, energy, or time distribution of a source, an additional distribution
148+
can be specified provided that the two share a common support (set of points
149+
where the distribution is nonzero). Samples are then drawn from this "bias"
150+
distribution, which can be chosen to preferentially direct particles towards
151+
phase space regions of interest. In order to avoid biasing the tally results,
152+
however, a weight adjustment is applied to each sampled site as described below.
153+
154+
Assume that the unbiased probability density function of a random variable
155+
:math:`X:x \rightarrow \mathbb{R}` is given by :math:`f(x)`, but that using the
156+
biased distribution :math:`g(x)` will result in a greater number of particle
157+
trajectories reaching some phase space region of interest. Then a sample
158+
:math:`x_0` may be drawn from :math:`g(x)` while maintaining a fair game,
159+
provided that its weight is adjusted as:
160+
161+
.. math::
162+
:label: source_bias
163+
164+
w = w_0 \times \frac{f(x_0)}{g(x_0)}
165+
166+
where :math:`w_0` is the weight of an unbiased sample from :math:`f(x)`,
167+
typically unity.
168+
169+
Returning now to Equation :eq:`source_bias`, the requirement for common support
170+
becomes evident. If :math:`\mathrm{supp} (g)` fully contains but is not
171+
identical to :math:`\mathrm{supp} (f)`, then some samples from :math:`g(x)` will
172+
correspond to points where :math:`f(x) = 0`. Thus these source sites would be
173+
assigned a starting weight of 0, meaning the particles would be killed
174+
immediately upon transport, effectively wasting computation time. Conversely, if
175+
:math:`\mathrm{supp} (g)` is fully contained by but not identical to
176+
:math:`\mathrm{supp} (f)`, the contributions of some regions outside
177+
:math:`\mathrm{supp} (g)` will not be counted towards the integral, potentially
178+
biasing the tally. The weight assigned to such points would be undefined since
179+
:math:`g(x) = \mathbf{0}` at these points.
180+
181+
When an independent source is sampled in OpenMC, the particle's coordinate in
182+
each variable of phase space :math:`(\mathbf{r},\mathbf{\Omega},E,t)` is
183+
successively drawn from an independent probability distribution. Multiple
184+
variables can be biased, in which case the resultant weight :math:`w` applied to
185+
the particle is the product of the weights assigned from all sampled
186+
distributions: space, angle, energy, and time, as shown in Equation
187+
:eq:`tot_wgt`.
188+
189+
.. math::
190+
:label: tot_wgt
191+
192+
w = w_r \times w_{\Omega} \times w_E \times w_t
193+
194+
Finally, source biasing and weight windows serve different purposes. Source
195+
biasing changes how particles are born, allowing the initial source sites to be
196+
sampled preferentially from important regions of phase space (space, angle,
197+
energy, and time) with an accompanying weight adjustment. Weight windows, by
198+
contrast, apply population control during transport (splitting and Russian
199+
roulette) to help particles reach and contribute in important regions as they
200+
move through the system. Because particle transport proceeds as usual after a
201+
biased source is sampled, particle attenuation in optically thick regions
202+
outside the source volume will not be affected by source biasing; in such
203+
scenarios, transport biasing techniques such as weight windows are often more
204+
effective.

docs/source/pythonapi/mgxs.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ Module Variables
1111
.. autodata:: openmc.mgxs.GROUP_STRUCTURES
1212
:annotation:
1313

14+
Functions
15+
+++++++++
16+
17+
.. autosummary::
18+
:toctree: generated
19+
:nosignatures:
20+
:template: myfunction.rst
21+
22+
openmc.mgxs.convert_flux_groups
23+
1424
Classes
1525
+++++++
1626

docs/source/usersguide/geometry.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,11 @@ to help figure out how to place universes::
415415

416416

417417
Note that by default, hexagonal lattices are positioned such that each lattice
418-
element has two faces that are parallel to the :math:`y` axis. As one example,
419-
to create a three-ring lattice centered at the origin with a pitch of 10 cm
420-
where all the lattice elements centered along the :math:`y` axis are filled with
421-
universe ``u`` and the remainder are filled with universe ``q``, the following
422-
code would work::
418+
element has two faces that are perpendicular to the :math:`y` axis. As one
419+
example, to create a three-ring lattice centered at the origin with a pitch of
420+
10 cm where all the lattice elements centered along the :math:`y` axis are
421+
filled with universe ``u`` and the remainder are filled with universe ``q``, the
422+
following code would work::
423423

424424
hexlat = openmc.HexLattice()
425425
hexlat.center = (0, 0)

docs/source/usersguide/settings.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ option::
272272
settings.source = [src1, src2]
273273
settings.uniform_source_sampling = True
274274

275+
Additionally, sampling from an :class:`openmc.IndependentSource` may be biased
276+
for local or global variance reduction by modifying the
277+
:attr:`~openmc.IndependentSource.bias` attribute of each of its four main
278+
distributions. Further discussion of source biasing can be found in
279+
:ref:`source_biasing`.
280+
275281
Finally, the :attr:`IndependentSource.particle` attribute can be used to
276282
indicate the source should be composed of particles other than neutrons. For
277283
example, the following would generate a photon source::

0 commit comments

Comments
 (0)