Skip to content

Add corner checks for rectangular lattice crossings#3355

Closed
nuclearkevin wants to merge 2 commits intoopenmc-dev:developfrom
nuclearkevin:lattice_corner
Closed

Add corner checks for rectangular lattice crossings#3355
nuclearkevin wants to merge 2 commits intoopenmc-dev:developfrom
nuclearkevin:lattice_corner

Conversation

@nuclearkevin
Copy link
Contributor

@nuclearkevin nuclearkevin commented Mar 18, 2025

Description

There's a rare bug in rectangular lattice crossings where the incorrect cell would be calculated when a particle crosses a corner in a rectangular lattice. This normally doesn't result in any lost particles in actual transport unless a very large lattice is used with many particle histories. This does result in failures when plotting lattice geometries with ray traced plots though, as the camera often views the geometry from an orientation in which rays intersect lattice corners.

This PR fixes this bug by adding a corner check in RectLattice::distance(...) to ensure that particles are moved to the correct lattice cell. I've tested this against the minimal working example provided by @gridley in #2445, which is a 2x2 lattice made of iron (blue) and air (green).

Particles moving through the centre of the lattice from air -> air should not get attenuated, however the previous lattice offsets were calculated incorrectly and so those particles found their way into the iron cells erroneously (resulting in some attenuation):

Adding a corner check (this PR) to correctly move particles into adjacent cells fixes this issue:

I'm marking this as a draft for the moment until I have the time to add some tests for this fix.

Closes #2445

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) 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)

@nuclearkevin nuclearkevin changed the title Add corner check for rectangular lattice crossings Add corner checks for rectangular lattice crossings Mar 18, 2025
@gridley
Copy link
Contributor

gridley commented Mar 18, 2025

wow, awesome! Thanks for getting this man. Did this fix the issue in the plotter?

@nuclearkevin
Copy link
Contributor Author

nuclearkevin commented Mar 18, 2025

Unfortunately not ☹️. I still get a bunch of Particle (...) could not be located after crossing a boundary of lattice [...] errors, so something else must be going on here.

@nuclearkevin nuclearkevin marked this pull request as ready for review September 19, 2025 20:46
@nuclearkevin
Copy link
Contributor Author

I just remembered that I had this PR sitting around from a few months ago and completely forgot to add a test for the fix. The test I added here is @gridley's MWE with a reduced mesh tally resolution to ensure we catch those pesky corner crossings.

@nuclearkevin
Copy link
Contributor Author

@pshriwise thought I'd put this in your radar. For some reason, GH didn't automatically request any reviewers (guess I didn't hit any code owners on RectLattice).

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.

Lattice corner crossings leak particles

2 participants