Skip to content

Avoid storing inconsistent sum/sum_sq on summed D1S tallies#3949

Merged
paulromano merged 2 commits into
openmc-dev:developfrom
shimwell:d1s-fix-summed-sum-sq
May 30, 2026
Merged

Avoid storing inconsistent sum/sum_sq on summed D1S tallies#3949
paulromano merged 2 commits into
openmc-dev:developfrom
shimwell:d1s-fix-summed-sum-sq

Conversation

@jon-proximafusion
Copy link
Copy Markdown
Contributor

@jon-proximafusion jon-proximafusion commented May 29, 2026

Description

I think we are doing some compute that we don't need to when working with D1S tallies.

For sum_nuclides=True, apply_time_correction returns a derived tally with the ParentNuclideFilter removed. The previous code left _sum/_sum_sq set to per-parent-nuclide arrays shaped for the pre-removal filter set. These are unreachable through the public Tally.sum/sum_sq accessors (which return None for any derived tally) and are inconsistent with the remaining filters, so converting such a tally with Tally.sparse raises a reshape error.

Set sum/sum_sq to None for the summed result (matching the observable develop behavior) and skip the two full-size array multiplies that are never read. mean/std_dev are unchanged bit-for-bit. This fixes Tally.sparse on summed D1S tallies and speeds up the summed path for large mesh tallies by not computing the discarded arrays.

Fixes # (issue)

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)

For sum_nuclides=True, apply_time_correction returns a derived tally with
the ParentNuclideFilter removed. The previous code left _sum/_sum_sq set to
per-parent-nuclide arrays shaped for the pre-removal filter set. These are
unreachable through the public Tally.sum/sum_sq accessors (which return None
for any derived tally) and are inconsistent with the tally's remaining
filters.

Set sum/sum_sq to None for the summed result (matching the observable
develop behavior, since the accessors already return None) and skip the two
full-size array multiplies that are never read. mean/std_dev are unchanged
bit-for-bit. This speeds up the summed path by up to ~2.8x for large mesh
tallies by not computing the discarded arrays.
Copy link
Copy Markdown
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @jon-proximafusion!

@paulromano paulromano enabled auto-merge (squash) May 30, 2026 02:28
@paulromano paulromano merged commit ddabe1c into openmc-dev:develop May 30, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants