Skip to content

Commit e4c9a76

Browse files
committed
Merge branch 'develop' into get_pdf
2 parents b067e7f + 0486e43 commit e4c9a76

Some content is hidden

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

74 files changed

+3267
-591
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: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,13 +844,18 @@ attributes/sub-elements:
844844
relative source strength of each mesh element or each point in the cloud.
845845

846846
:volume_normalized:
847-
For "mesh" spatial distrubtions, this optional boolean element specifies
847+
For "mesh" spatial distributions, this optional boolean element specifies
848848
whether the vector of relative strengths should be multiplied by the mesh
849849
element volume. This is most common if the strengths represent a source
850850
per unit volume.
851851

852852
*Default*: false
853853

854+
:bias:
855+
For "mesh" and "cloud" spatial distributions, this optional element
856+
specifies floating point values corresponding to alternative probabilities
857+
for each value/component to use for biased sampling.
858+
854859
:angle:
855860
An element specifying the angular distribution of source sites. This element
856861
has the following attributes:
@@ -883,6 +888,10 @@ attributes/sub-elements:
883888
are those of a univariate probability distribution (see the description in
884889
:ref:`univariate`).
885890

891+
:bias:
892+
For "isotropic" angular distributions, this optional element specifies a
893+
"mu-phi" angular distribution used for biased sampling.
894+
886895
:energy:
887896
An element specifying the energy distribution of source sites. The necessary
888897
sub-elements/attributes are those of a univariate probability distribution
@@ -906,6 +915,10 @@ attributes/sub-elements:
906915
mesh element and follows the format for :ref:`source_element`. The number of
907916
``<source>`` sub-elements should correspond to the number of mesh elements.
908917

918+
.. note:: Biased sampling can be applied to the spatial and energy distributions
919+
of a source by using the ``<bias>`` sub-element (see
920+
:ref:`univariate` for details on how to specify bias distributions).
921+
909922
:constraints:
910923
This sub-element indicates the presence of constraints on sampled source
911924
sites (see :ref:`usersguide_source_constraints` for details). It may have
@@ -998,13 +1011,26 @@ variable and whose sub-elements/attributes are as follows:
9981011
*Default*: histogram
9991012

10001013
:pair:
1001-
For a "mixture" distribution, this element provides a distribution and its corresponding probability.
1014+
For a "mixture" distribution, this element provides a distribution and its
1015+
corresponding probability.
10021016

10031017
:probability:
1004-
An attribute or ``pair`` that provides the probability of a univariate distribution within a "mixture" distribution.
1018+
An attribute or ``pair`` that provides the probability of a univariate
1019+
distribution within a "mixture" distribution.
10051020

10061021
:dist:
1007-
This sub-element of a ``pair`` element provides information on the corresponding univariate distribution.
1022+
This sub-element of a ``pair`` element provides information on the
1023+
corresponding univariate distribution.
1024+
1025+
:bias:
1026+
This optional element specifies a biased distribution for importance sampling.
1027+
For continuous distributions, the ``bias`` element should contain another
1028+
univariate distribution with the same support (interval) as the parent
1029+
distribution. For discrete distributions, the ``bias`` element should contain
1030+
floating point values corresponding to alternative probabilities for each
1031+
value/component to be used for biased sampling.
1032+
1033+
*Default*: None
10081034

10091035
---------------------------------------
10101036
``<source_rejection_fraction>`` Element

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)