Conversation
Particles banked on a surface, such as particles split by weight windows at a surface crossing, are only known to be on that one surface. If another surface coincides with it, roundoff in the banked position can place the particle on the wrong side of the other surface, beyond FP_COINCIDENT for large coordinates, so that no cell contains it and the particle is lost (GitHub issue openmc-dev#4140). When a particle with a surface set cannot be located at the start of its history, move it forward by TINY_BIT with the surface cleared and search again, as Particle::cross_surface already does after crossing a surface. Fixes openmc-dev#4140 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014RN7JroEkrbkLKVHbMDap9
This branch has not been deployed
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.
Description
Particles split by weight windows at a surface crossing can be lost when another surface coincides with the crossed surface. This was reported in #4140, where 9 of 10 particles were lost ("Could not find the cell containing particle") and the leakage fraction was 0.1 instead of 1.0.
Cause. In the reproducer, the particle crosses
x = 62125.05(surface 3) inside a universe, and the surface weight window checkpoint splits it there. The secondaries are banked withsurf_id= +3, so when they start, OpenMC knows only that they are on the positive side of surface 3. Surface 4 has exactly the same coefficients, and the root cell region is-1 | -2 | -3 | 4. After a track of about 1.5×10⁵ cm, roundoff places the banked position 2.9×10⁻¹¹ cm below the plane, more thanFP_COINCIDENT(10⁻¹² cm), so4evaluates to false. Together with-3being false from the surface flag, no root cell contains the particle and it is lost. The primary particle is not lost because it never re-searches the root level. Instead, the same inconsistency causes the zero-length "crossing surface 4" event visible in a trace.Fix. When a particle that has a surface set cannot be located at the start of its history, it is now moved forward by
TINY_BITalong its direction with the surface cleared, and the search is repeated. This is the same fallbackParticle::cross_surfacealready uses when a particle cannot be located after crossing a surface. Particles without a surface set, such as source particles from point sources, are unaffected, so a genuinely undefined region is still reported as lost.Test.
test_split_on_coincident_surfacesintests/unit_tests/test_lost_particles.pybuilds the model from #4140 with the Python API and checks that all of the weight leaks. It fails ondevelop(leakage 0.1) and passes with this change.Note. This fixes the symptom at the point where particles are banked on a surface. The underlying issue is that the "on surface" flag covers only one surface while other coincident surfaces are evaluated from the position with an absolute tolerance, which becomes smaller than the floating-point resolution of coordinates beyond about 10⁴ cm. Treating geometrically identical surfaces as one when deciding which side a particle is on would also remove the spurious zero-length crossing. That could be a follow-up.
Fixes #4140
Checklist
I have made corresponding changes to the documentation (if applicable)