Extend transient CSR to all elements downstream of a bend - #18
Merged
Conversation
Previously CSR in a post-bend drift was applied only to the 1st/2nd element after a bend; further elements (and split drift fragments) silently dropped it. Retain the most recent bend's geometry (flagbendcsr, bendlencsr) and accumulate the distance from the bend entrance (sentr) across every element, so the transient (drift) CSR wake is applied consistently to all downstream elements using the existing Saldin Case C/D kernel. Unifies the 1st/2nd-after special cases into one formula. Validated split-invariance on examples/CSR/zeuthen.
ChristopherMayes
marked this pull request as ready for review
July 5, 2026 17:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the long-standing restriction that transient (drift) CSR is applied only to the first and second beam-line elements after a bend. With this change the transient CSR wake is applied to every element downstream of a bend, so the CSR effect is no longer truncated and is independent of how the drift region is segmented.
Builds on PR #17 (
fix-out-of-bound-access).Motivation
The 1D CSR wake kernel
csrwakeTrIGF_FieldQuant(src/Appl/Field.f90) already implements the full Saldin et al. model, including the post-bend drift transient (Cases C and D), which is valid for arbitrary distance past a bend. However, the driver insrc/Contrl/AccSimulator.f90only tracked two elements of history (bitypeold,bitypeold2) and had three hard-coded geometry cases (in-bend, 1st-after, 2nd-after). Any element beyond the second after a bend silently received no CSR.Consequently, breaking a post-bend drift into several shorter drifts (a common way to increase resolution) truncates the CSR effect after the second fragment. The
examples/CSR/zeuthenchicane demonstrates this:ZB.PIP03is split into0.1 / 0.1 / 4.8 m, and the 4.8 m fragment previously got no CSR.Change
The fix is bookkeeping only — no changes to the physics kernel:
flagbendcsr(is there an upstream bend requesting transient CSR),bendlencsr(its arc length).r0already persists as the last bend's radius since it is only assigned in the bend branch.sentr, incremented by each element length at the end of the beam-line-element loop and reset to 0 at each new bend.flagcsris set for the bend itself and for every element whileflagbendcsr == 1.(
zwkmin = range(5)/gamma + (z - zbleng + sentr),bendlen = bendlencsr),replacing the 1st/2nd-after special cases and the dead
"Not available for csr!"branch.Scope / model
input_switch (dparam(4)) > 500enables transient CSR, which now propagates to all downstream elements;> 200enables CSR inside the bend. No input-format change.Validation
zeuthenchicane (attached asimactz_csr_zeuthen.zip— see Notes), 100k particles,mpirun -n 8. Split-invariance test — CSR must not depend on how the post-bend drift is segmented:Files Changed
src/Contrl/AccSimulator.f90flagbendcsr,bendlencsr,sentr); apply transient CSR to all downstream elements; unify the wake-geometry computationNotes
zeuthenchicane) is attached to this PR asimpactz_csr_zeuthen.zip, not committed to the repository. A proper in-repo example will be added in a follow-up.NaNvalues in the last three columns offort.26are a pre-existing extended-diagnostic artifact, unrelated to this change (identical before and after).Attachments
impactz_csr_zeuthen.zip
Acknowledgment
The investigation, implementation, and validation for this change were carried out with the assistance of Claude (Anthropic), used via GitHub Copilot.