-
Notifications
You must be signed in to change notification settings - Fork 29
ChrPlasmaLens element: Support k<0, and fix uninitialized-variable bug in tracking of reference particle #1030
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
Conversation
|
Hm, as soon as I made the PR I realized I forgot to fix tabs / spaces. However the bot seems to have messed up the number of spaces needed. I'll fix (and probably force push to override its broken fixes). Looks like the CI is running the tests for me, that's nice :) |
…ith Quad when k=0
|
Thank you for your first PR to ImpactX, @kyrsjo! Those changes look great, let us structure & test them to make them best documented/portable/covered by CI. I also started CI and sent you an invite to our GitHub org, please accept to auto-run CI even before your first PR got merged on updates. Please make sure to provide a detailed description on the change and try to do one change at a time. e.g., if you fix a bug do it in one PR, adding a feature in another. Ideally, if it affects multiple elements as in your case, with unrelated bugs, then please make a PR per element (plasma lens, quad and ConstF here could be each a PR.) Please feel free to add your name to the author list of the respective files you changed. If a specific bug is fixed (or feature added), then I usually structure my PR (branch) like this:
Welcome again, looking forward to merging those! Please let us know if you have any questions ✨ |
|
Hi @ax3l , thanks for the invite and for looking over it! Most fixes are easy, will do. For the "use ternary operator" thing, please see my comments. I guess I should add tests for negative-k cases of these elements also. Is it OK that we keep the elements in 1 PR? I'll separate out the I see that the General comment: I appreciate that you are insisting on small and readable PRs! Having been involved in a few codes myself, especially being the former release manager and git-repo-czar of sixtrack, it's a very good thing. |
|
Thanks a lot @kyrsjo !
I would really prefer to do one PR for each, because that way we can merge the quad right away and then decide for ConstF and plasma lens if and how much testing we add, too. Also makes the release notes that we auto-generate readable. I already moved the Quad fix into #1038. Please merge in Please do the same for ConstF 🙏 |
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 made some small comments, and will try to help pin down why the CI tests are currently failing.
for more information, see https://pre-commit.ci
|
I think this is ready for review/merging now, @ax3l & @cemitch99 ? There are two questions I wonder about (datatype and tolerance) + 1 question I've answered (why negative). Note that I've made the tests so that I can fit the ConstF tests into the same framework :) |
|
|
||
| # Forward-propagate that through the focusing/defocusing lens | ||
| # from the beginning, ignoring energy spread | ||
| # [Doesn't give same result as ChrPlasmaLens and ChrQuad for some reason, even when sigpt_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.
Does this comment still apply? If so, this needs to be addressed.
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.
Hi, this was fixed here:
bb670a1#diff-a95909e2ce0d4e807a3fa1dc18e09c9c822ec1dbb1275b60b056c775609e216eL125
and then I started using the analytical estimate here:
7f06ab2
I will cleanup when I do constF, PR #1041 - the tests should share quite a bit of code.
| beta_y = sigy2 / emittance_y | ||
| alpha_y = -epstrms["position_y"]["momentum_y"] / emittance_y | ||
|
|
||
| return (beta_x, beta_y, alpha_x, alpha_y) |
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.
Note: This works, but the values defined here are computed internally and stored as reduced_diagnostics. See this example for an alternative approach: https://impactx.readthedocs.io/en/latest/usage/examples/fodo_space_charge/README.html
It's fine to keep this for now.
examples/active_plasma_lens/plot_APL_ChrPlasmaLens_analytical.py
Outdated
Show resolved
Hide resolved
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.
Looks great, thank you for this! 🚀 ✨
|
Thank you @ax3l and @cemitch99 for merging! I will now proceed to ConstF. Also, PhD student @aellings will now be able to simulate diverging APLs in ImpactX :) Maybe see you at Elba? |
|
@kyrsjo Awesome, thanks for the contribution!! Yes, I am at EAAC until Thursday noon, let's catch up! |
This patch adds support for negative strength (defocusing) for
ChrPlasmaLensandConstFelements. It also fixes a bug (use of uninitialized variable) in reference particle tracking forChrPlasmaLens.