MAD-X
MAD-X copied to clipboard
dipole issue in twiss with k0!=h and/or deltap!=0
In twiss the dipole map is calculated by tmsect using h and dh as parameters defined by:
if (sk0 .ne. 0) then-
f_errors(0) = f_errors(0) + (sk0*el - angle)
h_k = sk0 * bvk
endif
! ugly kludge to mimic k0 integration in errors
if (ktap .ne. 0) then
f_errors(0) = f_errors(0) + ktap*angle-----
endif
dh = (- h * deltap + bvk * f_errors(0) / el) / (one + deltap) ! dipole term
However dh is not used consistently in tmsect, for instance xksq to compute the weak focusing is computed as:
xksq = h**2 + sk1
while it should be
xksq = h*k0 + sk1
The first expression does not take into account dh and therefore deltap, ktap and other dipole errors.
It is probably better to refactor the code and use h and k0 in tmsect.