Guard multigroup tally scoring against void regions - #4126
Open
GuySten wants to merge 1 commit into
Open
Conversation
GuySten
force-pushed
the
claude/practical-edison-lslk91-mg-void-tally
branch
from
September 11, 2026 22:42
eb6ee26 to
172ee07
Compare
score_general_mg bound references into data::mg.macro_xs_ using the particle's material index without checking for MATERIAL_VOID, so a tally covering a void cell indexed the table with -1. Scores that read the particle's cached cross sections (flux, total, absorption) happened to survive this, but inverse-velocity reads the material's multigroup data directly and aborted the run. Return early for particles in void and score the three quantities that remain defined there: - flux, which depends only on the track length; - inverse velocity, which depends only on the particle's speed. OpenMC already defines that speed for a multigroup particle in a void: Particle::speed falls back to the approximate group-average default_inverse_velocity_, and the same data is used here; - events, which counts scoring events and reads no material data. Every remaining score the function handles is a reaction rate, which vanishes without a material. This matches continuous-energy mode, where inverse velocity is flux / speed and events is a bare count, both scored in a void like anywhere else. Only a tracklength estimator can reach a void, since the analog and collision estimators score at collisions, which require a material and whose expressions divide by the total cross section. Add unit tests covering all four cases; the inverse-velocity case aborts without this change. The test library supplies no inverse-velocity data, so the material falls back to the same default as the void, and the inverse velocity per unit flux must therefore agree between the two cells to round-off. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ci4aodNXq5BPbv3PXZNcp
GuySten
force-pushed
the
claude/practical-edison-lslk91-mg-void-tally
branch
from
September 11, 2026 22:50
172ee07 to
6ed3776
Compare
GuySten
marked this pull request as ready for review
September 12, 2026 00:27
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.
score_general_mg bound references into data::mg.macro_xs_ using the particle's material index without checking for MATERIAL_VOID, so a tally covering a void cell indexed the table with -1. Scores that read the particle's cached cross sections (flux, total, absorption) happened to survive this.
Return early for particles in void, scoring the flux for tracklength tallies and leaving every material-dependent score at zero. This matches how the continuous-energy scoring functions already treat MATERIAL_VOID.
Add a unit test covering both cases; the inverse-velocity case aborts without this change.
Please include a summary of the change and which issue is fixed if applicable. Please also include relevant motivation and context.
Fixes #2403
Checklist
I have made corresponding changes to the documentation (if applicable)