MAD-X icon indicating copy to clipboard operation
MAD-X copied to clipboard

dipole issue in twiss with k0!=h and/or deltap!=0

Open rdemaria opened this issue 1 year ago • 1 comments

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 image

  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.

rdemaria avatar Aug 09 '23 13:08 rdemaria