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

Fix Lost Particle w/ Runtime Attr #795

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Jan 10, 2025

For some processes and/or diagnostics, we add extra runtime attributes to our beam (particle container). The logic that collected "lost" particles in the beamline, i.e., as marked as lost in apertures, did not account for extra runtime attributes and thus got lost in bookkeeping.

This fixes the collection logic to be more robust and also copy any extra runtime attributes over to the "lost" particle recording.

This was first seen with an input that used the nonlinear lens (NLL), NLL-invariant diagnostics and an aperture at the same time. Fix #762

  • add a test to the NLL / IOTA examples (i.e., make sure we have an aperture that removes particles active?)

For some processes and/or diagnostics, we add extra runtime
attributes to our beam (particle container). The logic that
collected "lost" particles in the beamline, i.e., as marked as
lost in apertures, did not account for extra runtime attributes
and thus got lost in bookkeeping.

This fixes the collection logic to be more robust and also copy
any extra runtime attributes over to the "lost" particle recording.

This was first seen with an input that used the nonlinear lens (NLL),
NLL-invariant diagnostics and an aperture at the same time.
@ax3l ax3l added bug Something isn't working bug: affects latest release Bug also exists in latest release version component: diagnostics all types of outputs labels Jan 10, 2025
@ax3l ax3l requested a review from cemitch99 January 10, 2025 23:53
@ax3l ax3l requested a review from atmyers January 10, 2025 23:54
Comment on lines 60 to 65
// Check destination has the same attributes as source + "s_lost"
for (auto & name : source.GetRealSoANames())
{
if (!dest.HasRealComp(name)) {
dest.AddRealComp(name);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@atmyers question for you: we use amrex::filterAndTransformParticles below.
I am a bit afraid that when the order of attributes added in dest is not 100% the same as in source that this gets confused.

In particular, the attributes in source are something like:

  • x,y,t,px,py,pt,I,H
    and in dest
  • x,y,t,px,py,pt,s,I,H

s, I and H are runtime components, all are Real.

Will that lead to broken/mismatched or partial copies from source to dest?

Copy link
Member Author

@ax3l ax3l Jan 12, 2025

Choose a reason for hiding this comment

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

I tried to add a few asserts, but maybe we need to generalize with new helper methods/functions for copies that help with the matching a bit, to simplify complex bookkeeping.

@ax3l ax3l changed the title Fix Lost Particle w/ Runtime Attr [WIP] Fix Lost Particle w/ Runtime Attr Jan 11, 2025
@ax3l ax3l changed the title [WIP] Fix Lost Particle w/ Runtime Attr Fix Lost Particle w/ Runtime Attr Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: affects latest release Bug also exists in latest release version bug Something isn't working component: diagnostics all types of outputs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monitor+Nonlinear invariants+Aperture yields SegFault
2 participants