Skip to content

Preserve collision count when splitting particles#3958

Open
EdenRochmanSharabi wants to merge 3 commits into
openmc-dev:developfrom
EdenRochmanSharabi:fix/collision-filter-weight-windows
Open

Preserve collision count when splitting particles#3958
EdenRochmanSharabi wants to merge 3 commits into
openmc-dev:developfrom
EdenRochmanSharabi:fix/collision-filter-weight-windows

Conversation

@EdenRochmanSharabi
Copy link
Copy Markdown
Contributor

Summary

  • When weight windows split a particle via Particle::split(), the SourceSite bank now copies the parent's n_collision value
  • Particle::from_source() restores n_collision from the source site instead of resetting to zero
  • This fixes CollisionFilter producing biased (inflated) tallies when weight windows are active, because split children were incorrectly tagged as uncollided

Changes

  • include/openmc/particle_data.h: Added int n_collision {0} field to SourceSite struct
  • src/particle.cpp: Copy n_collision() in split(), restore from src->n_collision in from_source()
  • tests/unit_tests/test_collision_filter_ww.py: Regression test comparing uncollided flux fraction between analog and weight-windowed runs

Test plan

  • C++ compiles without errors
  • Regression test passes locally (analog vs WW uncollided fraction consistent)
  • CI

Closes #3916

When weight windows split a particle, the child particles now inherit
the parent's collision count. Previously, children were created with
n_collision=0 via from_source(), which caused CollisionFilter to
incorrectly classify scattered children as uncollided, producing
biased tallies.

Closes openmc-dev#3916
The ctypes _SourceSite struct must match the C++ SourceSite layout.
The missing field caused test_source_bank to abort.
The MPI datatype must include all fields in the struct so that
collision count is transferred correctly between MPI ranks.
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.

CollisionFilter produces biased results when weight windows are active

1 participant