Skip to content

Commit a506ed8

Browse files
authored
Merge branch 'openmc-dev:develop' into njoy-photonuclear
2 parents 8be7267 + db426b6 commit a506ed8

File tree

147 files changed

+6035
-1222
lines changed

Some content is hidden

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

147 files changed

+6035
-1222
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Tests and Coverage
22

33
on:
44
# allows us to run workflows manually
@@ -21,7 +21,25 @@ env:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2222

2323
jobs:
24+
filter-changes:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
source_changed: ${{ steps.filter.outputs.source_changed }}
28+
steps:
29+
- name: Check out the repository
30+
uses: actions/checkout@v4
31+
- name: Examine changed files
32+
id: filter
33+
uses: dorny/paths-filter@668c092af3649c4b664c54e4b704aa46782f6f7c # latest master commit, not released yet
34+
with:
35+
filters: |
36+
source_changed:
37+
- '!docs/**'
38+
- '!**/*.md'
39+
predicate-quantifier: 'every'
2440
main:
41+
needs: filter-changes
42+
if: ${{ needs.filter-changes.outputs.source_changed == 'true' }}
2543
runs-on: ubuntu-22.04
2644
strategy:
2745
matrix:
@@ -154,7 +172,7 @@ jobs:
154172
path: |
155173
~/nndc_hdf5
156174
~/endf-b-vii.1
157-
key: ${{ runner.os }}-build-xs-cache
175+
key: ${{ runner.os }}-build-xs-cache-${{ hashFiles(format('{0}/tools/ci/download-xs.sh', github.workspace)) }}
158176

159177
- name: before
160178
shell: bash
@@ -186,6 +204,7 @@ jobs:
186204
--gcov-ignore-errors source_not_found \
187205
--gcov-ignore-errors output_error \
188206
--gcov-ignore-parse-errors suspicious_hits.warn \
207+
--merge-mode-functions=separate \
189208
--print-summary \
190209
--lcov -o coverage-cpp.lcov || true
191210
@@ -204,12 +223,33 @@ jobs:
204223
flag-name: C++ and Python
205224
path-to-lcov: coverage.lcov
206225

207-
finish:
208-
needs: main
226+
coverage:
227+
needs: [filter-changes, main]
228+
if: ${{ always() }}
209229
runs-on: ubuntu-latest
210230
steps:
211231
- name: Coveralls Finished
232+
if: ${{ needs.filter-changes.outputs.source_changed == 'true' }}
212233
uses: coverallsapp/github-action@v2
213234
with:
214235
github-token: ${{ secrets.GITHUB_TOKEN }}
215236
parallel-finished: true
237+
238+
ci-pass:
239+
needs: [filter-changes, main, coverage]
240+
name: Check CI status
241+
if: ${{ always() }}
242+
runs-on: ubuntu-latest
243+
steps:
244+
- name: Check CI status
245+
run: |
246+
if [[ "${{ needs.filter-changes.outputs.source_changed }}" == "false" ]]; then
247+
echo "Documentation-only change - CI skipped successfully"
248+
exit 0
249+
fi
250+
if [[ "${{ needs.main.result }}" == "success" && "${{ needs.coverage.result }}" == "success" ]]; then
251+
echo "CI passed"
252+
exit 0
253+
fi
254+
echo "CI failed"
255+
exit 1

AGENTS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ C++17/Python codebase where:
3131
- **Depletion**: `openmc.deplete` implements burnup via operator-splitting with various integrators (Predictor, CECM, etc.)
3232
- **Nuclear Data**: `openmc.data` provides programmatic access to nuclear data files (ENDF, ACE, HDF5)
3333

34+
## Git Branching Workflow
35+
36+
OpenMC uses a git flow branching model with two primary branches:
37+
38+
- **`develop` branch**: The main development branch where all ongoing development takes place. This is the **primary branch against which pull requests are submitted and merged**. This branch is not guaranteed to be stable and may contain work-in-progress features.
39+
- **`master` branch**: The stable release branch containing the latest stable release of OpenMC. This branch only receives merges from `develop` when the development team decides a release should occur.
40+
41+
### Instructions for Code Review
42+
43+
When analyzing code changes on a feature or bugfix branch (e.g., when a user asks "what do you think of these changes?"), **compare the branch changes against `develop`, not `master`**. Pull requests are submitted to merge into `develop`, so differences relative to `develop` represent the actual proposed changes. Comparing against `master` will include unrelated changes from other features that have already been merged to `develop`.
44+
45+
### Workflow for contributors
46+
47+
1. Create a feature/bugfix branch off `develop`
48+
2. Make changes and commit to the feature branch
49+
3. Open a pull request to merge the feature branch into `develop`
50+
4. A committer reviews and merges the PR into `develop`
51+
3452
## Critical Build & Test Workflows
3553

3654
### Build Dependencies

docs/source/io_formats/depletion_results.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The current version of the depletion results file format is 1.2.
3434

3535
:Attributes: - **index** (*int*) -- Index used in results for this material
3636
- **volume** (*double*) -- Volume of this material in [cm^3]
37+
- **name** (*char[]*) -- Name of this material
3738

3839
**/nuclides/<name>/**
3940

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
----------------------
@@ -402,7 +411,25 @@ then, OpenMC will only use up to the :math:`P_1` data.
402411
``<max_history_splits>`` Element
403412
--------------------------------
404413

405-
The ``<max_history_splits>`` element indicates the number of times a particle can split during a history.
414+
The ``<max_history_splits>`` element indicates the number of times a particle
415+
can split during a history.
416+
417+
*Default*: 1000
418+
419+
-----------------------------
420+
``<max_secondaries>`` Element
421+
-----------------------------
422+
423+
The ``<max_secondaries>`` element indicates the maximum secondary bank size.
424+
425+
*Default*: 10000
426+
427+
------------------------
428+
``<max_tracks>`` Element
429+
------------------------
430+
431+
The ``<max_tracks>`` element indicates the maximum number of tracks written to a
432+
track file (per MPI process).
406433

407434
*Default*: 1000
408435

@@ -844,13 +871,18 @@ attributes/sub-elements:
844871
relative source strength of each mesh element or each point in the cloud.
845872

846873
:volume_normalized:
847-
For "mesh" spatial distrubtions, this optional boolean element specifies
874+
For "mesh" spatial distributions, this optional boolean element specifies
848875
whether the vector of relative strengths should be multiplied by the mesh
849876
element volume. This is most common if the strengths represent a source
850877
per unit volume.
851878

852879
*Default*: false
853880

881+
:bias:
882+
For "mesh" and "cloud" spatial distributions, this optional element
883+
specifies floating point values corresponding to alternative probabilities
884+
for each value/component to use for biased sampling.
885+
854886
:angle:
855887
An element specifying the angular distribution of source sites. This element
856888
has the following attributes:
@@ -883,6 +915,10 @@ attributes/sub-elements:
883915
are those of a univariate probability distribution (see the description in
884916
:ref:`univariate`).
885917

918+
:bias:
919+
For "isotropic" angular distributions, this optional element specifies a
920+
"mu-phi" angular distribution used for biased sampling.
921+
886922
:energy:
887923
An element specifying the energy distribution of source sites. The necessary
888924
sub-elements/attributes are those of a univariate probability distribution
@@ -906,6 +942,10 @@ attributes/sub-elements:
906942
mesh element and follows the format for :ref:`source_element`. The number of
907943
``<source>`` sub-elements should correspond to the number of mesh elements.
908944

945+
.. note:: Biased sampling can be applied to the spatial and energy distributions
946+
of a source by using the ``<bias>`` sub-element (see
947+
:ref:`univariate` for details on how to specify bias distributions).
948+
909949
:constraints:
910950
This sub-element indicates the presence of constraints on sampled source
911951
sites (see :ref:`usersguide_source_constraints` for details). It may have
@@ -998,13 +1038,26 @@ variable and whose sub-elements/attributes are as follows:
9981038
*Default*: histogram
9991039

10001040
:pair:
1001-
For a "mixture" distribution, this element provides a distribution and its corresponding probability.
1041+
For a "mixture" distribution, this element provides a distribution and its
1042+
corresponding probability.
10021043

10031044
:probability:
1004-
An attribute or ``pair`` that provides the probability of a univariate distribution within a "mixture" distribution.
1045+
An attribute or ``pair`` that provides the probability of a univariate
1046+
distribution within a "mixture" distribution.
10051047

10061048
:dist:
1007-
This sub-element of a ``pair`` element provides information on the corresponding univariate distribution.
1049+
This sub-element of a ``pair`` element provides information on the
1050+
corresponding univariate distribution.
1051+
1052+
:bias:
1053+
This optional element specifies a biased distribution for importance sampling.
1054+
For continuous distributions, the ``bias`` element should contain another
1055+
univariate distribution with the same support (interval) as the parent
1056+
distribution. For discrete distributions, the ``bias`` element should contain
1057+
floating point values corresponding to alternative probabilities for each
1058+
value/component to be used for biased sampling.
1059+
1060+
*Default*: None
10081061

10091062
---------------------------------------
10101063
``<source_rejection_fraction>`` Element
@@ -1352,6 +1405,15 @@ has the following attributes/sub-elements:
13521405
for fixed source and small criticality calculations, but is very
13531406
optimistic for highly coupled full-core reactor problems.
13541407

1408+
-------------------------------------
1409+
``<uniform_source_sampling>`` Element
1410+
-------------------------------------
1411+
1412+
The ``<uniform_source_sampling>`` element indicates whether to sample among
1413+
multiple sources uniformly, applying their strengths as weights to sampled
1414+
particles.
1415+
1416+
*Default*: False
13551417

13561418
------------------------
13571419
``<ufs_mesh>`` Element
@@ -1364,6 +1426,16 @@ Agency Monte Carlo Performance Benchmark Problem," Proceedings of *Physor 2012*,
13641426
Knoxville, TN (2012). The mesh should cover all possible fissionable materials
13651427
in the problem and is specified using a :ref:`mesh_element`.
13661428

1429+
-------------------------------
1430+
``<use_decay_photons>`` Element
1431+
-------------------------------
1432+
1433+
The ``<use_decay_photons>`` element indicates whether to produce decay photons
1434+
from neutron reactions instead of prompt photons. This is used in conjunction
1435+
with the direct 1-step method for shutdown dose rate calculations.
1436+
1437+
*Default*: False
1438+
13671439
.. _verbosity:
13681440

13691441
-----------------------
@@ -1594,3 +1666,21 @@ following sub-elements/attributes:
15941666

15951667
The ``weight_windows_file`` element has no attributes and contains the path to
15961668
a weight windows HDF5 file to load during simulation initialization.
1669+
1670+
-------------------------------
1671+
``<weight_windows_on>`` Element
1672+
-------------------------------
1673+
1674+
The ``weight_windows_on`` element indicates whether weight windows are
1675+
enabled.
1676+
1677+
*Default*: False
1678+
1679+
----------------------------------
1680+
``<write_initial_source>`` Element
1681+
----------------------------------
1682+
1683+
The ``write_initial_source`` element indicates whether to write the initial
1684+
source distribution to file.
1685+
1686+
*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.

0 commit comments

Comments
 (0)