Skip to content

Guard multigroup tally scoring against void regions - #4126

Open
GuySten wants to merge 1 commit into
openmc-dev:developfrom
GuySten:claude/practical-edison-lslk91-mg-void-tally
Open

Guard multigroup tally scoring against void regions#4126
GuySten wants to merge 1 commit into
openmc-dev:developfrom
GuySten:claude/practical-edison-lslk91-mg-void-tally

Conversation

@GuySten

@GuySten GuySten commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

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 performed a self-review of my own code
  • I have run clang-format (version 18) 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 force-pushed the claude/practical-edison-lslk91-mg-void-tally branch from eb6ee26 to 172ee07 Compare September 11, 2026 22:42
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
GuySten force-pushed the claude/practical-edison-lslk91-mg-void-tally branch from 172ee07 to 6ed3776 Compare September 11, 2026 22:50
@GuySten
GuySten marked this pull request as ready for review September 12, 2026 00:27
@GuySten
GuySten requested a review from paulromano September 12, 2026 00:27
@GuySten GuySten added the Bugs label Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-group mode doesn't support tallies in void regions

2 participants