Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add corner checks for rectangular lattice crossings #3355

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

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.

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