Set all tally estimators to collision in RR simulations - #4042
Open
nuclearkevin wants to merge 2 commits into
Open
Set all tally estimators to collision in RR simulations#4042nuclearkevin wants to merge 2 commits into
nuclearkevin wants to merge 2 commits into
Conversation
GuySten
reviewed
Aug 3, 2026
GuySten
left a comment
Contributor
There was a problem hiding this comment.
This feels a bit hacky.
Maybe it will be better to do something special in another place if we are in random ray mode.
Regardless, IMO you should add a test that now passes and used to fail without this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Obtaining results from a random ray simulation through the use of tallies in OpenMC relies of mapping each source region to a corresponding tally object. To facilitate this, source regions save the midpoint of the first ray that passes through them, which is then used to query tallies and find every tally object that maps spatially to the source region. In the vast majority of cases this works perfectly, however we run into issues when a tally is set to use a tracklength estimator. The filter matches run
bins_crossed()using a position (r()) and previous position (r_last()) that are the same, which results in zero-lengths being returned. In most filters this still counts as a bin being hit, but in some cases (MOAB/XDG unstructured mesh tallies, and very rarely tallies with no filters applied) this will not be registered which leads to source regions missing tally objects.This PR fixes this bug by silently setting all tallies to collision estimators before running a random ray simulation to ensure filter matches are obtained with
r(). This has no impact on results as the random ray solver does not require the concept of estimators.Checklist
I have followed the style guidelines 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)