-
Notifications
You must be signed in to change notification settings - Fork 21
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
Apply transverse aperture to thick elements. #788
base: development
Are you sure you want to change the base?
Conversation
Add namespace amrex::literals
Add Python class for aperture mixin.
for more information, see https://pre-commit.ci
src/particles/elements/Drift.H
Outdated
@@ -121,6 +128,11 @@ namespace impactx | |||
py = pyout; | |||
pt = ptout; | |||
|
|||
// apply transverse aperture | |||
if (m_xmax > 0 && m_ymax > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the if
into mixin/aperture.H
.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Note: Windows test fail now, but all tests were previously passing. |
src/particles/elements/Drift.H
Outdated
amrex::ParticleReal xmax = 0, | ||
amrex::ParticleReal ymax = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if for all potential elements, xmax
and ymax
are general enough argument names.
They do make sense for the Aperture
element, but for all other thick elements we might need something more specific, e.g., x_open
or x_aperture
?
Another small change I thought we could do is use std::optional<amrex::ParticleReal> ... = std::nullopt
. That way, we do not redefine 0
with a jump, which technically is a fully blocking aperture. The equivalent in Python is then x_aperture = None
, which is clearly no aperture.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like x_aperture
, and I'll make that change. Will look into using std::optional
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get the value out of std::optional, call operator* or .value().
We will need to write the real value into m_x_aperture
because we cannot (should not) use std::optional
on GPU. For no value, I would maybe write a negative value into the member variable and only apply the aperture for >=0. That way, 0 is well-defined (blocking).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify the last comment: We're avoiding std::optional
altogether? If so, I actually prefer the existing approach, to apply the aperture when x_aperture > 0 and y_aperture >0. Why? 1) Allowing for blocking with x_aperture = 0 requires changing the logic/math in the mixin class, 2) A thick element with zero aperture has no use case (eg, its action is the same as a thin screen for blocking), 3) Allowing this case means setting the default values of x_aperture, y_aperture to an arbitrarily-chosen negative number.
src/python/elements.cpp
Outdated
.def_property_readonly("xmax", | ||
&elements::Aperture::xmax, | ||
"horizontal aperture in m" | ||
) | ||
.def_property_readonly("ymax", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming: please see above.
Small changes (excluding naming and std::optional). Co-authored-by: Axel Huebl <[email protected]>
Remove "maybe unused".
Adds the comparison of particles against the transverse aperture within thick elements, at the end of each space charge slice. This will close #763 .
Note: Need to verify that using the same name
Aperture
for the thin aperture element and for the mixin class will not cause conflicts. Otherwise, one of these should be renamed.