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 aperture element #398

Merged
merged 24 commits into from
Nov 24, 2023
Merged

Add aperture element #398

merged 24 commits into from
Nov 24, 2023

Conversation

cemitch99
Copy link
Member

@cemitch99 cemitch99 commented Jul 12, 2023

Added a first draft of collimator/aperture element. For now, this element simply compares each particle against an aperture boundary (rectangular or elliptical), and records whether the particle has been lost.

For this initial draft, coordinates of lost particles are updated to x = y = 0 (so that all particles lie within the aperture). This will be changed to modify the sign of the particle index.

  • Add new element type (inputs, etc.)
  • Update documentation
  • Modify particle index handling
  • Add benchmark example
  • Verify correct index handling
  • move particles to a separate particle container and enable output for them Apertures & Lost Particle Book Keeping #394
    • finalize move (see todos)
    • add s of reference particle at point of particle loss to "lost" particle container/species
    • output

*To be followed-up with additional bookkeeping of lost particles.
Metadata to add:

  • s
  • turn number

@cemitch99 cemitch99 requested review from ax3l and RemiLehe July 12, 2023 19:52
src/particles/elements/Aperture.H Fixed Show resolved Hide resolved
@ax3l ax3l self-assigned this Jul 18, 2023
@ax3l ax3l added the component: elements Elements/external fields label Jul 18, 2023
Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

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

Thank you for the draft of the aperture element, this is great!

Why do you set the id negative and the position to zero?
If we only set the id to negative, we can keep the transversal position where the particle was lost as information.

Generally, particles with negative ids will be removed on the next communication call. I would propose we add a filter step, that moves all negative-ly id's particles to a new species, so we can keep track and add the step and s where the particle was lost?

src/python/elements.cpp Outdated Show resolved Hide resolved
docs/source/usage/python.rst Outdated Show resolved Hide resolved
examples/aperture/README.rst Outdated Show resolved Hide resolved
examples/aperture/run_aperture.py Outdated Show resolved Hide resolved
src/initialization/InitElement.cpp Outdated Show resolved Hide resolved
src/particles/elements/All.H Outdated Show resolved Hide resolved
src/particles/elements/All.H Outdated Show resolved Hide resolved
src/particles/elements/Aperture.H Outdated Show resolved Hide resolved

switch(m_shape) {

// rectangular aperture (default)
Copy link
Member

Choose a reason for hiding this comment

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

Not super important yet, but since only one option can be true at the same time, we potentially want to move this switch decision out of kernel code, where it increases register pressure, and into a host-side decision.

For this, we could write a general aperture base class and derive it into special rectangular and elliptical classes.

Anyway, I think the part here is too small to warrant this just yet and this will be fine.

@cemitch99
Copy link
Member Author

I set the transverse position to zero in the initial draft so that the test passes (all particles in the output lie inside the aperture). This should be removed once we add the step of moving the particles with negative index.

src/particles/CollectLost.cpp Outdated Show resolved Hide resolved
src/particles/CollectLost.cpp Outdated Show resolved Hide resolved
src/particles/CollectLost.cpp Fixed Show resolved Hide resolved
@ax3l ax3l force-pushed the add_aperture branch 5 times, most recently from b9ee9a3 to 4f2efe5 Compare August 30, 2023 00:29
@ax3l ax3l force-pushed the add_aperture branch 2 times, most recently from 50de186 to 2d1f96d Compare November 22, 2023 19:26
cemitch99 and others added 12 commits November 22, 2023 15:38
Place arguments with defaults last (Python equivalent).
Add missing ,
Update the C++ API to use an enum for the aperture shape and
the Python API & inputs file syntax to accept a string. That
makes the parameters at the call sites self-describing.
to do:
- remove in beam species
- output
Update changed input API
This way, we can test if "s" was set to the right value.
Copy link
Member Author

@cemitch99 cemitch99 left a comment

Choose a reason for hiding this comment

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

The bookkeeping changes look good to me.

@ax3l ax3l force-pushed the add_aperture branch 8 times, most recently from 2b089c4 to 934807c Compare November 23, 2023 01:02
docs/source/usage/parameters.rst Outdated Show resolved Hide resolved
examples/CMakeLists.txt Outdated Show resolved Hide resolved
examples/aperture/run_aperture.py Outdated Show resolved Hide resolved
Do not generate empty files with half-ready meta data.
Outdated line from an earlier design created an empty
species in output.
@ax3l ax3l merged commit 79fab7c into ECP-WarpX:development Nov 24, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: elements Elements/external fields
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants