-
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
Add periodic masking option to Aperture. #739
Add periodic masking option to Aperture. #739
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.
Thanks, looks good to me. I'd let @SchroederSa and @n01r comment on the physics aspects of the PR.
Correct type in example README.
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 have little to no understanding of the underlaying code, so I added any thoughts and questions that I had when going through it line by line - I coudn't even find a single typo in the docs :).
Thanks again!
Sarah
particles_lost = series_lost.iterations[0].particles["beam"].to_df() | ||
|
||
# compare number of particles | ||
num_particles = 100000 |
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.
Do we need that line?
I see, this variable is being used in line 60.
I wonder why this number is hard-coded instead of directly defined as len(initial), as it doesn't matter at which initial number of particles this test is being done.
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.
This is only to check that the number of particles generated, and the number of particles remaining after the lattice (including those lost) both coincide with the number specified in the input file. We have this check in all of our CI tests.
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.
For the example that users are looking at, it would be nice to add another drift and monitor after the pepperpot to complement the setup of an actual emittance measurement and plot the outcome on the last monitor.
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.
Agreed. For automated testing, the existing test is good because it is simple and checks the functionality implemented. I propose that we keep it as-is for this PR, and we can add a follow-up example that includes a full pepperpot emittance reconstruction. We could rename the existing test aperture_periodic
to avoid confusion, and name the follow-up test pepperpot_measurement
or something similar.
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.
Same as above. Maybe it is worth adding another drift and monitor to represent an actual pepperpot emittance measurement setup.
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.
Absolutely! See the above suggestion.
@@ -59,6 +61,8 @@ namespace impactx | |||
Aperture ( | |||
amrex::ParticleReal xmax, | |||
amrex::ParticleReal ymax, | |||
amrex::ParticleReal repeat_x, |
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.
You don't define the default value to be 0. Is that on purpose? I see that this is being done in the .cpp file. I just want to double-check, as you need that definition later in line 116 and there is a default value defined for dx, dy and rotation_degree.
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.
Thanks for the careful check. The default value of 0 is set on lines 379-380 of InitElement.cpp
, which is where we read-in the nominal element parameters and include defaults. Only the error parameters dx
, dy
, and rotation_degree
are treated differently, because they are arguments of the Alignment
function.
src/particles/elements/Aperture.H
Outdated
amrex::ParticleReal dx = m_xmax; | ||
amrex::ParticleReal dy = m_ymax; | ||
// first case: a single aperture | ||
if (m_repeat_x == 0.0 || m_repeat_y == 0.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.
How does a periodic slit then work? Just by making the apertures touch each other in the direction of the slit? As a user, I would probably intuitively define only repeat_x and define an elongated rectangular aperture in y.
So maybe this could be an (m_repeat_x == 0.0 && m_repeat_y == 0.0) ?
And then the slit can be done via an option: (m_repeat_x == 0.0 || m_repeat_y == 0.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.
Yes, correct. To create an x-periodic array of vertical slits, you would now set repeat_x
to the period you want, and set ymax = repeat_y
. You make a good suggestion about a way to add more flexibility (for example, a rectangular aperture of finite size that is periodically repeated in only one direction). I just pushed a change to address this.
Generalize periodic aperture to allow periodicity in one direction only.
Rename example: analysis script.
Rename example: C++ input
Rename example: Python input
Rename example: CMakeLists
Rename example: README documentation
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.
Thank you!
Sarah
This PR adds the capability to allow periodic transverse masking of beam particles (as relevant for modeling, e.g. pepperpot diagnostics). This is implemented by adding two optional parameters to the existing Aperture element, representing a horizontal and vertical period with which the aperture is repeated. This addresses Issue #694.