Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Source Random Ray #2988

Merged
merged 232 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 223 commits
Commits
Show all changes
232 commits
Select commit Hold shift + click to select a range
d76033a
first commit. File layout, classes, source region init.
jtramm Jun 12, 2023
c2fa6aa
added source update function
jtramm Jun 12, 2023
dc30912
added high level control function
jtramm Jun 12, 2023
31609b0
added cell normalization routine
jtramm Jun 12, 2023
0e2dcec
added add source to flux function
jtramm Jun 12, 2023
7db4a7d
added k-eff update function
jtramm Jun 12, 2023
a782fa4
basic iteration code is in.
jtramm Jun 12, 2023
785c4d6
adding ray methods.
jtramm Jun 12, 2023
2ccc838
adding more ray methods.
jtramm Jun 12, 2023
168ca04
whitespace fixes
jtramm Jun 12, 2023
2c45008
working on debugging the compile. All basic pieces in place though, s…
jtramm Jun 12, 2023
003c646
continued debugging
jtramm Jun 13, 2023
f232980
Compile-time bug fixes and refactoring to use particle_data accessors.
jtramm Jun 13, 2023
04e7e12
assed basic printout. Results look decent.
jtramm Jun 13, 2023
d66cdbb
removed tallying (besides basic things like k-eff)
jtramm Jun 13, 2023
588f1ce
added clean timing/result output function.
jtramm Jun 13, 2023
442153c
added the basics of clean tally-based output
jtramm Jun 13, 2023
baf1f5a
fixed first tally init issue that was causing seg fault. Getting 0 va…
jtramm Jun 13, 2023
2c2770b
ensured that all active tallies are used, not just analog
jtramm Jun 13, 2023
e785b26
generic tally solution working. A little slow
jtramm Jun 14, 2023
9566890
added energy integrated version. About 2x fast, but still too slow. W…
jtramm Jun 14, 2023
7646594
added tally mapper, but now there is a problem where what if we did n…
jtramm Jun 14, 2023
7b46663
Added ability for tally conversion to run multiple times if not all F…
jtramm Jun 14, 2023
f28d655
minor cleanup of tally task conversion code
jtramm Jun 14, 2023
2b43008
moved tallying and tally conversion functions into separate file
jtramm Jun 14, 2023
5548628
added some comments
jtramm Jun 14, 2023
7503eb6
moved initialization of tally task array to where other cell-wise arr…
jtramm Jun 14, 2023
1eb5eec
parallelized flux/volume zeroing routines. Streamlined instability an…
jtramm Jun 14, 2023
958a73a
added more output metrics
jtramm Jun 14, 2023
ec78527
changed parallelization scheme for normalization routines. Removed ta…
jtramm Jun 14, 2023
eeda6ab
first commit. File layout, classes, source region init.
jtramm Jun 12, 2023
6a6d100
added source update function
jtramm Jun 12, 2023
34c35db
added high level control function
jtramm Jun 12, 2023
e19e3e3
added cell normalization routine
jtramm Jun 12, 2023
68af51e
added add source to flux function
jtramm Jun 12, 2023
7673afb
added k-eff update function
jtramm Jun 12, 2023
cfab02a
basic iteration code is in.
jtramm Jun 12, 2023
f40f807
adding ray methods.
jtramm Jun 12, 2023
c373560
adding more ray methods.
jtramm Jun 12, 2023
ebee0ef
whitespace fixes
jtramm Jun 12, 2023
25f1fcc
working on debugging the compile. All basic pieces in place though, s…
jtramm Jun 12, 2023
aa9b732
continued debugging
jtramm Jun 13, 2023
a3ed5dd
Compile-time bug fixes and refactoring to use particle_data accessors.
jtramm Jun 13, 2023
e9708d6
assed basic printout. Results look decent.
jtramm Jun 13, 2023
8d22e78
removed tallying (besides basic things like k-eff)
jtramm Jun 13, 2023
247e8df
added clean timing/result output function.
jtramm Jun 13, 2023
9610a2d
added the basics of clean tally-based output
jtramm Jun 13, 2023
84cfdaa
fixed first tally init issue that was causing seg fault. Getting 0 va…
jtramm Jun 13, 2023
d74781e
ensured that all active tallies are used, not just analog
jtramm Jun 13, 2023
68bee19
generic tally solution working. A little slow
jtramm Jun 14, 2023
a3c9804
added energy integrated version. About 2x fast, but still too slow. W…
jtramm Jun 14, 2023
0c5200b
added tally mapper, but now there is a problem where what if we did n…
jtramm Jun 14, 2023
4b60bd5
Added ability for tally conversion to run multiple times if not all F…
jtramm Jun 14, 2023
64a6d6e
minor cleanup of tally task conversion code
jtramm Jun 14, 2023
b1167d9
moved tallying and tally conversion functions into separate file
jtramm Jun 14, 2023
6566cdc
added some comments
jtramm Jun 14, 2023
738910a
moved initialization of tally task array to where other cell-wise arr…
jtramm Jun 14, 2023
1d9254e
parallelized flux/volume zeroing routines. Streamlined instability an…
jtramm Jun 14, 2023
d998d06
added more output metrics
jtramm Jun 14, 2023
58d516b
changed parallelization scheme for normalization routines. Removed ta…
jtramm Jun 14, 2023
7ffb30d
allowed for different cell instances to be given different material t…
jtramm Jun 16, 2023
5ff2be8
fixed fast forward issue
jtramm Oct 3, 2023
69abd98
updated to use zero temp and angle indices when accessing XS data. Ad…
jtramm Oct 3, 2023
2cb971c
used OpenMC init sim
jtramm Nov 21, 2023
504cb54
using init and finalize batch
jtramm Nov 21, 2023
a6a00b3
using generations now as well
jtramm Nov 21, 2023
ecc0087
using integrated keff tally
jtramm Nov 21, 2023
f363645
commented out unneeded init statements
jtramm Nov 21, 2023
c5fbb4c
set weight to 1.0
jtramm Nov 21, 2023
56e84f7
Switched random ray enum check to use a new solver type variable inst…
jtramm Nov 21, 2023
bbd325d
removed duplicate timer
jtramm Nov 21, 2023
2854d51
figured out bug -- was due to actual bug in openmc where it is revert…
jtramm Nov 22, 2023
8e91d50
input validation is well along -- maybe complete?
jtramm Nov 22, 2023
94705ef
added fixed source checking
jtramm Nov 22, 2023
54f39de
refactor from Ray to RandomRay
jtramm Nov 28, 2023
b3ea0f6
added source validation
jtramm Nov 29, 2023
2d90cd4
refactored to use settings/globals directly rather than passing as ar…
jtramm Nov 29, 2023
872ff56
adding comments, and switched to setting to previous source instead o…
jtramm Nov 29, 2023
39cdd66
moved validation code to end of file
jtramm Nov 29, 2023
43df38a
partial addition of docs and python interface
jtramm Dec 1, 2023
6cf75a6
finished up python interface?
jtramm Dec 1, 2023
dad86a0
fixed issue with int vs real in python interface, and added check for…
jtramm Dec 1, 2023
f7e0400
partial domain replication. Need to not print double, and need to red…
jtramm Dec 1, 2023
6eb99bd
fixed issue with tallies in mpi mode. Issue was solely with the cell …
jtramm Dec 4, 2023
b4fffb8
added more comments
jtramm Dec 4, 2023
ed34ab2
added reduction of intersection counts
jtramm Dec 4, 2023
fe4194d
added timer for source reductions, and added warning about slow reduc…
jtramm Dec 4, 2023
bec2b82
removed extra comment
jtramm Dec 4, 2023
1fbd373
added lots of comments
jtramm Dec 5, 2023
027653b
fixed comment issue
jtramm Dec 5, 2023
1789d41
removed assert statements and replaced with errors
jtramm Dec 5, 2023
fefe9aa
added vtk plotter
jtramm Dec 5, 2023
3bf3134
added FSR and material plots, but FSR plot is weird.
jtramm Dec 5, 2023
811c399
FSRs appear much better as floats rather than modulused ints, for som…
jtramm Dec 5, 2023
95ebeed
simplified plotting routine a bit
jtramm Dec 5, 2023
b3a38e0
parallelized plotter
jtramm Dec 5, 2023
00f0e4c
using plot.xml inputs for plots
jtramm Dec 5, 2023
4939ceb
plotter is using xml input fname
jtramm Dec 5, 2023
bce3b70
added nice output before plotting, and enforcement of acceptable plot…
jtramm Dec 5, 2023
8704ee7
only plot if there is a plotting xml file
jtramm Dec 5, 2023
98f0696
added storage of accumulated final flux and plotting at the end
jtramm Dec 5, 2023
3254e3b
added first try at tolerant testing harness
jtramm Dec 6, 2023
a7d90df
tweaks to tolerant testing. Report k-eff simulation for k-eff combine…
jtramm Dec 6, 2023
54d0a71
added random ray pincell example
jtramm Dec 6, 2023
8a49e5d
removed unneeded headers
jtramm Dec 6, 2023
1419f39
added endianness flipping function, ability to output multiple plots …
jtramm Dec 6, 2023
dd90d63
adjusted comment
jtramm Dec 6, 2023
1818989
fixed merge issue
jtramm Jan 8, 2024
cf0f69b
improved pincell example
jtramm Jan 8, 2024
2248ec4
ran git clang-format develop
jtramm Jan 8, 2024
8216a6c
Added a loop before plotting to change filenames first, so the plot s…
jtramm Jan 8, 2024
735fcfd
ran git clang-format develop
jtramm Jan 8, 2024
33c333b
updated test to use RectangularPrism instead of rectangular_prism`
jtramm Jan 10, 2024
0b0dc42
Revert "fixed fast forward issue"
jtramm Jan 10, 2024
12f24f0
ran clang-format on settings.h
jtramm Jan 10, 2024
69ae4f4
added back in comment
jtramm Jan 10, 2024
99a34cc
removed comments/debugging code
jtramm Jan 10, 2024
a07c534
ran git clang-format develop
jtramm Jan 10, 2024
e0b62a7
Update src/random_ray/iteration.cpp
jtramm Jan 10, 2024
63857aa
incorporation of @gridley review comments
jtramm Jan 11, 2024
57dad69
Merge branch 'random_ray_merge' of github.com:jtramm/openmc into rand…
jtramm Jan 11, 2024
d3cfd4b
Merge branch 'develop' of github.com:openmc-dev/openmc into random_ra…
jtramm Jan 17, 2024
ead8cfa
added random_ray.rst methods file and updated index
jtramm Jan 17, 2024
561d8fa
fixed over/underbars
jtramm Jan 25, 2024
bb24326
added random ray user guide
jtramm Jan 26, 2024
a060d4e
added lots more documentation to theory section
jtramm Jan 26, 2024
a42e0eb
added compressed image files to random ray documentation
jtramm Jan 26, 2024
53d3a5e
continued work on docs
jtramm Jan 28, 2024
74d7ac7
continued work on docs
jtramm Jan 28, 2024
2893ecf
continued updated to docs
jtramm Jan 28, 2024
872bcfe
continued work on docs
jtramm Jan 28, 2024
32c65d8
updating random ray docs
jtramm Jan 29, 2024
66387b4
More random ray docs. Fixed equation notation, added more references,…
jtramm Jan 29, 2024
2ec33be
Added random_ray_source option to IndependentSource to flag source as…
jtramm Feb 6, 2024
5c63a31
ran git clang-format HEAD~1
jtramm Feb 6, 2024
4a0500f
Refactored random ray source indicator to use particle type rather th…
jtramm Feb 6, 2024
4727569
ran git clang-format HEAD~1
jtramm Feb 6, 2024
f20bc1e
removed the rest of old random_ray_source source field.
jtramm Feb 6, 2024
98b65d1
removed unneeded lines throughout
jtramm Feb 6, 2024
916b2bd
updated docs to account for new random ray source specification inter…
jtramm Feb 6, 2024
524f2b4
added accessors for cell material/temperature fields to abstract logi…
jtramm Feb 7, 2024
f122ef0
ran git clang-format HEAD~1
jtramm Feb 7, 2024
4a92297
Merge branch 'develop' into random_ray_merge
jtramm Feb 12, 2024
3821eb2
fixed bug in Cell::sqrtkT accessor return type
jtramm Feb 12, 2024
00d07dc
incorporation of review comments
jtramm Feb 13, 2024
14faa19
refactor into classes mostly complete. Just some cleanup remaining.
jtramm Feb 13, 2024
5555dd9
refactor into classes complete and working (still needs cleanup)
jtramm Feb 14, 2024
28942b9
refactor of random ray filenames
jtramm Feb 14, 2024
383bd31
code cleanup, comments, formatting
jtramm Feb 14, 2024
e3bc76a
ran git clang-format develop
jtramm Feb 14, 2024
e5cdc3e
changed include guard names
jtramm Feb 14, 2024
eb66a04
ran git clang-format develop
jtramm Feb 14, 2024
2e4b12c
Basic source application functions
jtramm Feb 14, 2024
9f2ad9c
applied distrbcell instance bugfix
jtramm Feb 14, 2024
738e27e
fixed source mode calling. Working on kobayashi
jtramm Feb 14, 2024
0173b06
ran git clang-format develop
jtramm Feb 14, 2024
86a4a88
added fixed source regression tests
jtramm Feb 14, 2024
a92d35c
updated docs
jtramm Feb 15, 2024
b715f03
added comment for TolerantPyAPITestHarness class
jtramm Feb 15, 2024
b4ad777
enabled tracklength and collision tallies. Fixed vacuum BC bug where …
jtramm Feb 15, 2024
2d7eec3
updated documents and example to remove the requirement of analog tal…
jtramm Feb 15, 2024
ef0fdca
Remove docs for random_ray_source option that was removed from python…
jtramm Feb 16, 2024
30d0d1d
added TODO item on inheriting from GeometryState instead of Particle.
jtramm Feb 16, 2024
7de305b
Changed random ray interface on python side.
jtramm Feb 16, 2024
007a935
refactor C++ random ray interface to use random_ray object
jtramm Feb 16, 2024
15e6bec
updated docs, examples, and tests to use new interface. Also added va…
jtramm Feb 16, 2024
591d0e2
updated docs
jtramm Feb 16, 2024
1d8722f
ran git clang-format develop
jtramm Feb 16, 2024
a58be8c
removed random ray particle type from C++ and python
jtramm Feb 16, 2024
3d2eab9
ran git clang-format develop
jtramm Feb 16, 2024
982272c
fixed bug with outputting empty random ray dictionary
jtramm Feb 16, 2024
43b842d
simplified docs example slightly
jtramm Feb 16, 2024
ddb8e4f
merged with new UI changes
jtramm Feb 18, 2024
047ec26
merged with new UI changes
jtramm Feb 18, 2024
ace48f9
finished merging with UI update
jtramm Feb 18, 2024
97751be
updated docs for new UI
jtramm Feb 18, 2024
720040a
updated tests for new UI. Disabled default source generation in eigen…
jtramm Feb 18, 2024
bf0b84d
ran git clang-format develop
jtramm Feb 18, 2024
4819aaa
incorporation of @gridley docs review comments
jtramm Feb 18, 2024
208a982
fixed bug logic bug in applying sources to material filled cells.
jtramm Feb 19, 2024
04c0ed2
fixed bug in fixed source assignment due to universe storing index in…
jtramm Feb 19, 2024
c9c691d
Line spacing in random ray documentation
paulromano Mar 5, 2024
03333d2
Small changes in user's guide random ray section
paulromano Mar 5, 2024
e8ff8f5
Edits in random ray methods docs
paulromano Mar 5, 2024
0d94bbe
Small changes and updates
paulromano Mar 5, 2024
66b4a3d
Fix XML roundtrip of settings.random_ray
paulromano Mar 5, 2024
06d4343
incorporation of @promano review comments pt 1
jtramm Mar 6, 2024
3c13dd2
changed \vec to \mathbf in random ray docs
jtramm Mar 6, 2024
433b000
incorporation of @promano review comments pt 2
jtramm Mar 6, 2024
3f585ef
changed dV to d\mathbf{r}
jtramm Mar 6, 2024
cb813ce
incorporation of @promano review comments pt3
jtramm Mar 6, 2024
fa0b844
incorporation of @promano review comments pt 4
jtramm Mar 6, 2024
45e3bc9
ran git clang-format develop
jtramm Mar 6, 2024
de456e0
updated random ray test expected results due to bug fix with ray term…
jtramm Mar 6, 2024
936d703
removed unneeded vector header
jtramm Mar 6, 2024
d426075
Small fix in random_ray.rst
paulromano Mar 22, 2024
efe6353
marked random_ray_tally as const, and removed unneeded prototype
jtramm Mar 29, 2024
581229e
updated docs comment
jtramm Mar 29, 2024
d60c3c0
incorporation of @yardasol review comments
jtramm Apr 3, 2024
93bb5b2
Merge branch 'develop' into random_ray_merge
jtramm Apr 4, 2024
37acddd
merged with prime random ray branch
jtramm Apr 16, 2024
11c7c80
adjusting output formatting for fixed source random ray
jtramm Apr 16, 2024
3e0f623
added new tallytask stuff
jtramm Apr 16, 2024
82127dc
added more tally updates
jtramm Apr 16, 2024
c0a40a5
fixed const issue
jtramm Apr 16, 2024
d31a41b
progress on correct flux tally normalization
jtramm Apr 16, 2024
ec8347a
Flux tally normalization update complete - getting same answer on Kob…
jtramm Apr 16, 2024
38ebe59
removed unneeded source strength function
jtramm Apr 16, 2024
a8dfdd9
syncing of fixed source application routines with newest branch
jtramm Apr 16, 2024
6d0c6ab
corrected tally volume normalization
jtramm Apr 30, 2024
f71b818
simplified tally volume normalization
jtramm Apr 30, 2024
4b22d9d
merged fixed source with develop
jtramm Apr 30, 2024
c5f0297
updating docs
jtramm Apr 30, 2024
6df908b
reverted submodule changes
jtramm Apr 30, 2024
cbb0141
cleanup of comments in tally function
jtramm Apr 30, 2024
d81924f
improved documentation on hash_combine
jtramm Apr 30, 2024
5a3762b
comment cleanup
jtramm Apr 30, 2024
2d51ff1
updated python regression tests given new tally normalization procedure
jtramm Apr 30, 2024
5550a49
Merge branch 'develop' into random_ray_fixed_source6
jtramm May 31, 2024
feff168
merging with develop
jtramm Jun 3, 2024
b9cf141
ran git clang-format develop
jtramm Jun 3, 2024
a52c3fe
ran git clang-format develop with LLVM 15 instead of LLVM 19
jtramm Jun 3, 2024
44a6ee4
updated tests with new source domain format
jtramm Jun 4, 2024
7622790
Small changes from review
paulromano Jun 11, 2024
3184e5c
refactor of fixed source variable names to external source names
jtramm Jun 11, 2024
c7c6d3a
changed hash_combine to pass by value rather than reference
jtramm Jun 11, 2024
94d224f
using new constraints/domains API for openmc.IndependentSource
jtramm Jun 11, 2024
924aaca
ran git clang-format develop
jtramm Jun 11, 2024
373ca5d
ran older version of clang
jtramm Jun 11, 2024
2ce6736
removed comment
jtramm Jun 12, 2024
e1bc0cc
Consolidate random ray fixed source tests
paulromano Jun 12, 2024
53f5f32
Change e to E to follow style guidelines
jtramm Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions docs/source/methods/random_ray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Method of Characteristics
The Boltzmann neutron transport equation is a partial differential equation
(PDE) that describes the angular flux within a system. It is a balance equation,
with the streaming and absorption terms typically appearing on the left hand
side, which are balanced by the scattering source and fission source terms on
side, which are balanced by the scattering source, fission, and fixed source terms on
the right hand side.

.. math::
Expand Down Expand Up @@ -522,8 +522,8 @@ make their traversals, and summing these contributions up as in Equation
improve the estimate of the source and scalar flux over many iterations, given
that our initial starting source will just be a guess?

The source :math:`Q^{n}` for iteration :math:`n` can be inferred
from the scalar flux from the previous iteration :math:`n-1` as:
In an eigenvalue simulation, the source :math:`Q^{n}` for iteration :math:`n`
can be inferred from the scalar flux from the previous iteration :math:`n-1` as:

.. math::
:label: source_update
Expand All @@ -535,7 +535,7 @@ where :math:`Q^{n}(i, g)` is the total source (fission + scattering) in region
:math:`g` must be computed by summing over the contributions from all groups
:math:`g' \in G`.

In a similar manner, the eigenvalue for iteration :math:`n` can be computed as:
The eigenvalue for iteration :math:`n` can be computed as:

.. math::
:label: eigenvalue_update
Expand Down Expand Up @@ -576,6 +576,18 @@ and a similar substitution can be made to update Equation
estimate is used, such that the total fission source from the previous iteration
(:math:`n-1`) is also recomputed each iteration.

In a fixed source simulation, the fission source is replaced
by a user specified fixed source term :math:`Q_{fixed}(i,E)`, which is defined
for each FSR and energy group. This additional source term is applied at this
stage for generating the next iteration's source estimate as:

.. math::
:label: fixed_source_update

Q^{n}(i, g) = Q_{fixed}(i,g) + \sum\limits^{G}_{g'} \Sigma_{s}(i,g,g') \phi^{n-1}(g')

and no eigenvalue is computed.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ray Starting Conditions and Inactive Length
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -742,6 +754,32 @@ behavior if a single simulation cell is able to score to multiple filter mesh
cells. In the future, the capability to fully support mesh tallies may be added
to OpenMC, but for now this restriction needs to be respected.

.. _usersguide_fixed_source_methods:

------------
Fixed Source
------------

The random ray solver in OpenMC can be used for both eigenvalue and fixed source
problems. There are a few key differences between fixed source transport with
random ray and Monte Carlo, however.

- **Source definition:** In Monte Carlo, it is relatively easy to define various
source distributions, including point sources, surface sources, volume
sources, and even custom user sources -- all with varying angular and spatial
statistical distributions. In random ray, the natural way to include a fixed
source term is by adding a fixed (flat) contribution to specific flat source
regions. Thus, in the OpenMC implementation of random ray, particle sources
are restricted to being volumetric and isotropic, although different energy
spectrums are supported. Fixed sources can be applied to specific materials,
cells, or universes.

- **Inactive batches:** In Monte Carlo, use of a fixed source implies that all
batches are active batches, as there is no longer a need to develop a fission
source distribution. However, in random ray mode, there is still need to
develop the scattering source by way of inactive batches before beginning
active batches.

---------------------------
Fundamental Sources of Bias
---------------------------
Expand Down
154 changes: 150 additions & 4 deletions docs/source/usersguide/random_ray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ Carlo, **inactive batches are required for both eigenvalue and fixed source
solves in random ray mode** due to this additional need to converge the
scattering source.

.. warning::
Unlike Monte Carlo, the random ray solver still requires usage of inactive
batches when in fixed source mode so as to develop the scattering source.

The additional burden of converging the scattering source generally results in a
higher requirement for the number of inactive batches---often by an order of
magnitude or more. For instance, it may be reasonable to only use 50 inactive
batches for a light water reactor simulation with Monte Carlo, but random ray
might require 500 or more inactive batches. Similar to Monte Carlo,
:ref:`Shannon entropy <usersguide_entropy>` can be used to gauge whether the
combined scattering and fission source has fully developed.
might require 500 or more inactive batches.

Similar to Monte Carlo, active batches are used in the random ray solver mode to
accumulate and converge statistics on unknown quantities (i.e., the random ray
Expand Down Expand Up @@ -248,6 +250,8 @@ a larger value until the "low ray density" messages go away.
ray lengths are sufficiently long to allow for transport to occur between
source and target regions of interest.

.. _usersguide_ray_source:

----------
Ray Source
----------
Expand Down Expand Up @@ -411,12 +415,76 @@ in the `OpenMC Jupyter notebook collection
separate materials can be defined each with a separate multigroup dataset
corresponding to a given temperature.

---------------------------------
Fixed Source and Eigenvalue Modes
---------------------------------

Both fixed source and eigenvalue modes are supported with the random ray solver
in OpenMC. Modes can be selected as described in the :ref:`run modes section
<usersguide_run_modes>`. In both modes, a ray source must be provided to let
OpenMC know where to sample ray starting locations from, as discussed in the
:ref:`ray source section <usersguide_ray_source>`. In fixed source mode, at
least one regular source must be provided as well which represents the physical
particle fixed source. As discussed in the :ref:`fixed source methodology
section <usersguide_fixed_source_methods>`, the types of fixed sources supported
in the random ray solver mode are much more limited as compared to what is
possible with the Monte Carlo solver.

Currently, all of the following conditions must be met for the source to be
valid in random ray mode:

- One or more domain ids must be specified that indicate which cells, universes,
or materials the source applies to. This implicitly limits the source type to
being volumetric. This is specified via the ``domains`` field of the
:class:`openmc.IndependentSource` Python class.
jtramm marked this conversation as resolved.
Show resolved Hide resolved
- The source must be isotropic (default for a source)
- The source must use a discrete (i.e., multigroup) energy distribution. The
discrete energy distribution is input by defining a
:class:`openmc.stats.Discrete` Python class, and passed as the ``energy``
field of the :class:`openmc.IndependentSource` Python class.

Any other spatial distribution information contained in a particle source will
be ignored. Only the specified cell, material, or universe domains will be used
to define the spatial location of the source, as the source will be applied
during a pre-processing stage of OpenMC to all source regions that are contained
within the inputted domains for the source.

When defining a :class:`openmc.stats.Discrete` object, note that the ``x`` field
will correspond to the discrete energy points, and the ``p`` field will
correspond to the discrete probabilities. It is recommended to select energy
points that fall within energy groups rather than on boundaries between the
groups. I.e., if the problem contains two energy groups (with bin edges of
1.0e-5, 1.0e-1, 1.0e7), then a good selection for the ``x`` field might be
points of 1.0e-2 and 1.0e1.

::

# Define geometry, etc.
...
source_cell = openmc.Cell(fill=source_mat, name='cell where fixed source will be')
...
# Define physical neutron fixed source
energy_points = [1.0e-2, 1.0e1]
strengths = [0.25, 0.75]
energy_distribution = openmc.stats.Discrete(x=energy_points,p=strengths)
neutron_source = openmc.IndependentSource(energy=energy_distribution, domains=[source_cell], strength=1.0)

# Add fixed source and ray sampling source to settings file
settings.source = [neutron_source]

---------------------------------------
Putting it All Together: Example Inputs
---------------------------------------

An example of a settings definition for random ray is given below::
~~~~~~~~~~~~~~~~~~
Eigenvalue Example
~~~~~~~~~~~~~~~~~~

An example of a settings definition for an eigenvalue random ray simulation is
given below:

::

# Geometry and MGXS material definition of 2x2 lattice (not shown)
pitch = 1.26
group_edges = [1e-5, 0.0635, 10.0, 1.0e2, 1.0e3, 0.5e6, 1.0e6, 20.0e6]
Expand Down Expand Up @@ -478,3 +546,81 @@ Monte Carlo run (see the :ref:`geometry <usersguide_geometry>` and

There is also a complete example of a pincell available in the
``openmc/examples/pincell_random_ray`` folder.

~~~~~~~~~~~~~~~~~~~~
Fixed Source Example
~~~~~~~~~~~~~~~~~~~~

An example of a settings definition for a fixed source random ray simulation is
given below:

::

# Geometry and MGXS material definition of 2x2 lattice (not shown)
pitch = 1.26
source_cell = openmc.Cell(fill=source_mat, name='cell where fixed source will be')
ebins = [1e-5, 1e-1, 20.0e6]
...

# Instantiate a settings object for a random ray solve
settings = openmc.Settings()
settings.energy_mode = "multi-group"
settings.batches = 1200
settings.inactive = 600
settings.particles = 2000
settings.run_mode = 'fixed source'
settings.random_ray['distance_inactive'] = 40.0
settings.random_ray['distance_active'] = 400.0

# Create an initial uniform spatial source distribution for sampling rays
lower_left = (-pitch, -pitch, -pitch)
upper_right = ( pitch, pitch, pitch)
uniform_dist = openmc.stats.Box(lower_left, upper_right)
settings.random_ray['ray_source'] = openmc.IndependentSource(space=uniform_dist)

# Define physical neutron fixed source
energy_points = [1.0e-2, 1.0e1]
strengths = [0.25, 0.75]
energy_distribution = openmc.stats.Discrete(x=energy_points,p=strengths)
neutron_source = openmc.IndependentSource(energy=energy_distribution, domains=[source_cell], strength=1.0)

# Add fixed source and ray sampling source to settings file
settings.source = [neutron_source]

settings.export_to_xml()

# Define tallies

# Create a mesh filter
mesh = openmc.RegularMesh()
mesh.dimension = (2, 2)
mesh.lower_left = (-pitch/2, -pitch/2)
mesh.upper_right = (pitch/2, pitch/2)
mesh_filter = openmc.MeshFilter(mesh)

# Create a multigroup energy filter
energy_filter = openmc.EnergyFilter(ebins)

# Create tally using our two filters and add scores
tally = openmc.Tally()
tally.filters = [mesh_filter, energy_filter]
tally.scores = ['flux']

# Instantiate a Tallies collection and export to XML
tallies = openmc.Tallies([tally])
tallies.export_to_xml()

# Create voxel plot
plot = openmc.Plot()
plot.origin = [0, 0, 0]
plot.width = [2*pitch, 2*pitch, 1]
plot.pixels = [1000, 1000, 1]
plot.type = 'voxel'

# Instantiate a Plots collection and export to XML
plot_file = openmc.Plots([plot])
plot_file.export_to_xml()

All other inputs (e.g., geometry, material) will be unchanged from a typical
Monte Carlo run (see the :ref:`geometry <usersguide_geometry>` and
:ref:`multigroup materials <create_mgxs>` user guides for more information).
3 changes: 3 additions & 0 deletions include/openmc/mgxs_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class MgxsInterface {
// Get the kT values which are used in the OpenMC model
vector<vector<double>> get_mat_kTs();

// Get the group index corresponding to a continuous energy
int get_group_index(double e);
jtramm marked this conversation as resolved.
Show resolved Hide resolved

int num_energy_groups_;
int num_delayed_groups_;
vector<std::string> xs_names_; // available names in HDF5 file
Expand Down
Loading