Skip to content

Allow for Thin multipoles in RDT calculation#1088

Open
JonasKallestrup wants to merge 1 commit into
atcollab:masterfrom
JonasKallestrup:patch-1
Open

Allow for Thin multipoles in RDT calculation#1088
JonasKallestrup wants to merge 1 commit into
atcollab:masterfrom
JonasKallestrup:patch-1

Conversation

@JonasKallestrup

Copy link
Copy Markdown
Contributor

Previously, the integrated multipole strength of magnets were calculated as k*L, but for thin multipoles this would result in zero integrated strength. Now, to get the integrated strength calculation correct, the zero-length elements are treated to have length of 1.0.

Previously, the integrated multipole strength of magnets were calculated as k*L, but for thin multipoles this would result in zero integrated strength. 
Now, to get the integrated strength calculation correct, the zero-length elements are treated to have length of 1.0.
@oscarxblanco

oscarxblanco commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Dear @JonasKallestrup , just a warning.
In the current implementation of the geometric RDTs of second order wrt to sextupoles, each sextupole needs a different position along the 's' coordinate. This is always true for thick elements but could be a problem if one defines two thin sextupoles one after the other.

This comes from the summation term over pairs of sextupoles inherited from C, used in matlab and implemented as

at/pyat/at/physics/rdt.py

Lines 263 to 264 in 7414e40

bsign = np.array([np.sign(sm[i] - sm) * 1j * b3lm[i] * b3lm
for i in range(nelem)])
, which is basically a matrix with zeros in the diagonal, and plus 1 or minus 1 elsewhere, then multiplied by the sextupole strength. See the termsm[i]-sm .

During the implementation by @swhite2401 in python I did a review and ask to consider using indexes because I thought it was risky to substract two float values in order to get exactly zero to define the sign, but at that time @swhite2401 preferred to leave the equation exactly as in C for matlab.

Instead, for the chromatic second order RDTs I wrote the same sumation sign as

at/pyat/at/physics/rdt.py

Lines 362 to 365 in 7414e40

# The variable imag_and_sign multiplies by -1 the expression in
# ANL/APS/LS-330 March 10, 2012. Chun-xi Wang. Eq (46)
# in order to follow AT sign convention.
imag_and_sign = 1j * (np.tri(nelem, nelem, -1) - 1 + np.tri(nelem))

which produces the same matrix without the need of float comparison

>>> nelem = 3
>>> np.tri(nelem, nelem, -1) - 1 + np.tri(nelem)
array([[ 0., -1., -1.],
       [ 1.,  0., -1.],
       [ 1.,  1.,  0.]])

@oscarxblanco

oscarxblanco commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Here is the equation I refer to
(taken from https://www.aps.anl.gov/files/APS-sync/lsnotes/files/APS_1429490.pdf )
image
where $i,j$ refer to sextupole index $i$ and $j$, and in order to exclude the case of $i=j$ the C implementation checks for $sign(s_i - s_j)$.

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