Allow for Thin multipoles in RDT calculation - #1088
Conversation
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.
|
Dear @JonasKallestrup , just a warning. This comes from the summation term over pairs of sextupoles inherited from C, used in matlab and implemented as Lines 263 to 264 in 7414e40 sm[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 Lines 362 to 365 in 7414e40 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.]]) |
|
Here is the equation I refer to |
|
@JonasKallestrup to get the integrated strength you may simply use the newly added attributes @oscarxblanco , we may reconsider in view of this failure scenario where we have successive thin lens elements, at the time I preferred to have a conservative approach and remain as close as possible to the matlab implementation. Now that we have more experience we could move away from this... up to you! |
|
@JonasKallestrup , the sign implementation is solved in the master branch. You could continue with this PR. |

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.