Add nonlinear thin dipole fringe field map - #1158
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Merge development into this PR branch.
for more information, see https://pre-commit.ci
Add some additional details to documentation.
for more information, see https://pre-commit.ci
Add additional documentation details.
for more information, see https://pre-commit.ci
|
The three failing tests are due to the Dashboard, and appear to be unrelated to this PR. |
Probably worth vectorizing now...
ax3l
left a comment
There was a problem hiding this comment.
This looks great!
I added formatting fixes (applying them now), small code suggestions (leaving for your review) and a final suggestion for he user-facing API that I can help with.
| int m_model; //! model specification | ||
| Location m_flag; //! +1 for entry, or -1 for exit |
There was a problem hiding this comment.
As a final update, I would like to make m_model and m_flag AMREX_ENUM as we do for SpaceChargeAlgo.
The reason is that I would like users to write in their input files / scripts a descriptive string or type instead of integers that one has to look up.
What would be good string values for each of those?
I assume:
- model: "linear", "order6" ?
- location: "entry", "exit"
Also would call m_flag simply m_location.
There was a problem hiding this comment.
I agree m_location works well, with entry and exit as string values. For m_model, I would just use linear and nonlinear. The question of "order" is subtle here, and unrelated to the values of K0-K6 above (which is where I assume the number 6 originated).
There was a problem hiding this comment.
Note that "flag" (which can be renamed "location") is already specified here by a user-provided string (not an integer) with values "entry" and "exit" using enum in lines 47-51 of DipEdge.H. Can you clarify the advantage of changing this to an implementation similar to SpaceChargeAlgo (e.g., lines 21-26 of Algorithms.H)?
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
for more information, see https://pre-commit.ci
|
@cemitch99 I'll push a PR with changes in a minute |
|
After this PR, need to update the |
| pp_element.queryAdd("model", model_str); | ||
| dipedge::Model const model = amrex::getEnum<dipedge::Model>(model_str); | ||
| pp_element.queryAdd("location", location_str); | ||
| dipedge::Location const location = amrex::getEnum<dipedge::Location>(location_str); |
There was a problem hiding this comment.
@WeiqunZhang just checked in that we can read directly into an enum in ParmParse, too! :)
There was a problem hiding this comment.
Not exactly right now. query works, but not queryAdd. We can certainly support that.
There was a problem hiding this comment.
auto model = Model::linear;
ParmParse pp;
pp.query("model", model);
amrex::Print() << " model is " << amrex::getEnumNameString(model) << "\n";
will give us
$ ./main3d.gnu.ex model="nonlinear"
model is nonlinear
There was a problem hiding this comment.
AMReX-Codes/amrex#4765 adds queryAdd for amrex_enum.
There was a problem hiding this comment.
Awesome, thnak you! Let me refactor this after the PR, so we can do a 25.11 release depending on AMReX 25.11
ee63fd2 to
06636ad
Compare
This PR modifies the existing linear DipEdge element to support the nonlinear map of:
K. Hwang and S. Y. Lee, "Dipole fringe field map for compact synchrotrons," Phys. Rev. Accel. Beams 18, 122401 (2015)
The map is expressed in the explicit, symplectic form provided in:
C. Mitchell and K. Hwang, "Explicit symplectic representations of nonlinear dipole fringe field maps," in Proc. NAPAC2025, TUP040, Sacramento, CA, 2025.