Skip to content

Resolve conflict with weight windows and global russian roulette#3751

Open
GuySten wants to merge 32 commits intoopenmc-dev:developfrom
GuySten:ww-survival-biasing
Open

Resolve conflict with weight windows and global russian roulette#3751
GuySten wants to merge 32 commits intoopenmc-dev:developfrom
GuySten:ww-survival-biasing

Conversation

@GuySten
Copy link
Contributor

@GuySten GuySten commented Jan 26, 2026

Description

Currently the global neutron russian roulette (which is used when survival biasing is turned on) conflicts with the application of weight windows.
As suggested in #2773 (comment), this PR makes global neutron russian roulette apply only when neutrons are outside of the weight windows mesh boundaries.

Fixes #2773

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) on any C++ source files (if applicable)
  • 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)

@GuySten GuySten requested a review from nelsonag as a code owner January 26, 2026 22:04
@GuySten GuySten added the Bugs label Jan 26, 2026
@GuySten GuySten changed the title Resolve conflicts with weight windows and global russian roulette Resolve conflict with weight windows and global russian roulette Jan 26, 2026
@GuySten GuySten marked this pull request as draft January 27, 2026 07:45
@GuySten GuySten marked this pull request as ready for review January 27, 2026 08:30
Copy link
Contributor

@pshriwise pshriwise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @GuySten! You are a machine. Some thoughts to consider here in the comments.

@GuySten GuySten requested a review from pshriwise January 27, 2026 23:32
@GuySten
Copy link
Contributor Author

GuySten commented Jan 27, 2026

I've restructured the code to be more backwards compatible.

@GuySten
Copy link
Contributor Author

GuySten commented Jan 28, 2026

I've further improved the code structure according to your suggestion.
I will have to dig into why the tests fail.

@GuySten GuySten requested a review from pshriwise January 29, 2026 00:03
@GuySten
Copy link
Contributor Author

GuySten commented Jan 29, 2026

This PR is now ready for another review iteration.

Copy link
Contributor

@pshriwise pshriwise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're getting closer here. I made a suggestion for simplified logic in the collision functions.

There are also some checks on particle state inside get_mesh_bin that feel a little out of place. Not incorrect really, but the don't seem to fit into the purpose of that function. There might be some further refactoring we can to to make that a little cleaner.

@GuySten
Copy link
Contributor Author

GuySten commented Feb 2, 2026

@pshriwise, I've incorporated your suggestions and this PR is ready to review.

@GuySten GuySten requested a review from pshriwise February 2, 2026 16:16
@pshriwise
Copy link
Contributor

After some testing, there's more work to be done here to clarify the difference between a weight window that is not found and the case where a weight window is found but unset. I'll add a post here with a solution later today.

@pshriwise pshriwise requested a review from jtramm as a code owner February 5, 2026 13:36
@pshriwise
Copy link
Contributor

I tried applying this to a similar problem to the one presented in #2773. It's a block of Tungsten with an incident planar source of neutrons. All boundaries are reflective except the positive X plane, which is a vacuum boundary condition. These are short runs with 10k particles, 10 batches.

When I tried it as of 57b5d27, the survival biasing was still limiting the effectiveness of the weight windows because unset weight windows (different from the search for a weight window failing) were also resulting in WeightWindow::is_valid returning false and pushing us into the all to apply_russian_roulette. I'm glad I was using the MAGIC method for weight window generation in this case or I likely wouldn't have noticed this!

At any rate, what we need to separate here is the cases where a weight window is unset in the WeightWindows object vs. not being able to find one due to energy limits, a particle being outside the mesh, etc. The latest commit I pushed here takes care of that with an extra flag emitted from search_weight_window and get_weight_window. Happy to discuss the design of that further, but from the images below we can see we're now getting the effect we desire.

Weight windows, no survival biasing (same in 57b5d27 and a53c066)

image

Weight windows w/ survival biasing on 57b5d27

ww-survival

Weight windows w/ survival biasing on, a53c066

image

@GuySten
Copy link
Contributor Author

GuySten commented Feb 5, 2026

@pshriwise, can you add the last test (weight windows w/ survival biasing) as a regression test?

@pshriwise
Copy link
Contributor

@pshriwise, can you add the last test (weight windows w/ survival biasing) as a regression test?

Yeah that's good call. I'm hesitant to make it a regression test as it's going to be pretty sensitive to the prn stream. I'm thinking at least a coarse check that turning on survival biasing at least doesn't reduce the number of mesh bins with tallied results. I can't think of a reason that it would.

I'll also look into the now-failing regression test. Something must be different with the control flow without survival biasing on now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weight windows while using survival biasing

2 participants