Skip to content

Extend transient CSR to all elements downstream of a bend - #18

Merged
qianglbl merged 3 commits into
impact-lbl:masterfrom
ChristopherMayes:drift_csr_extension
Jul 7, 2026
Merged

Extend transient CSR to all elements downstream of a bend#18
qianglbl merged 3 commits into
impact-lbl:masterfrom
ChristopherMayes:drift_csr_extension

Conversation

@ChristopherMayes

@ChristopherMayes ChristopherMayes commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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 in src/Contrl/AccSimulator.f90 only 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/zeuthen chicane demonstrates this: ZB.PIP03 is split into 0.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:

  • Retain the most recent bend's geometry across elements: flagbendcsr (is there an upstream bend requesting transient CSR), bendlencsr (its arc length). r0 already persists as the last bend's radius since it is only assigned in the bend branch.
  • Accumulate the distance from the bend entrance in sentr, incremented by each element length at the end of the beam-line-element loop and reset to 0 at each new bend.
  • Apply CSR to all downstream elements: flagcsr is set for the bend itself and for every element while flagbendcsr == 1.
  • Unify the geometry into a single downstream formula
    (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

  • Single most-recent-bend model (unchanged): each drift region uses the geometry of the nearest upstream bend. A new bend replaces the retained geometry.
  • Multi-bend superposition is intentionally out of scope. Summing contributions from several upstream bends is not compatible with the Saldin fixed-geometry case approach (the geometry changes between bends) and would require a fundamentally different algorithm. This PR does not attempt it.
  • On/off control is the bend's existing switch: input_switch (dparam(4)) > 500 enables transient CSR, which now propagates to all downstream elements; > 200 enables CSR inside the bend. No input-format change.

Validation

zeuthen chicane (attached as imactz_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:

final quantity before (split, truncated) after (split) after (single 5 m drift)
fort.26 z, col 4 1.4688 2.2074 2.2074
fort.26 z, col 6 9.5005 10.0662 10.0663
fort.24 x, col 6 +0.04082 −0.02246 −0.02246
  • After the change, the split and single-drift lattices agree to 6–7 significant figures → CSR is applied consistently regardless of segmentation.
  • The previous (truncated) result differs substantially (the transverse moment even changes sign), confirming the old behavior was dropping a physically significant CSR contribution over the long drift.

Files Changed

File Change
src/Contrl/AccSimulator.f90 Retain post-bend geometry (flagbendcsr, bendlencsr, sentr); apply transient CSR to all downstream elements; unify the wake-geometry computation

Notes

  • The validation lattice (zeuthen chicane) is attached to this PR as impactz_csr_zeuthen.zip, not committed to the repository. A proper in-repo example will be added in a follow-up.
  • The NaN values in the last three columns of fort.26 are 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.

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 ChristopherMayes changed the title Drift csr extension Extend transient CSR to all elements downstream of a bend Jul 5, 2026
@ChristopherMayes
ChristopherMayes marked this pull request as ready for review July 5, 2026 17:54
@qianglbl
qianglbl merged commit ae96cef into impact-lbl:master Jul 7, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants