!........................................................................ ! ! Subroutine : ! ! Description: ! ! Arguments : ! ! Mod/Commons: ! ! Calls : ! ! Author : ! ! Modified : ! !........................................................................ ! ! ! $Log$ ! Revision 1.6 2007/01/30 16:15:14 dcs ! merged with branch_bmad_1. ! ! Revision 1.2 2003/04/30 17:14:54 cesrulib ! dlr's changes since last import ! ! Revision 1.1.1.1 2002/12/13 19:23:30 cesrulib ! import bmadz ! ! !........................................................................ ! ! subroutine sex_kick_calc (ele, orb, dj) use bmad use nonlin_mod implicit none type (sextupole_res_struct) res type (ele_struct) ele type (coord_struct) orb, j_orb real(rp) dj(3), sqrt_j_vec(3), phi_vec(3), k2l, theta, factor, fac3(3) integer k ! dj = 0 call convert_coords ('LAB', orb, ele, 'ACTION', j_orb) sqrt_j_vec = sqrt(j_orb%vec(1:5:2)) phi_vec = j_orb%vec(2:6:2) call sextupole_resonance_calc (ele, res) k2l = ele%value(k2$) * ele%value(l$) do k = 1, res%n_res theta = sum(res%a(k)%iq * phi_vec) where (sqrt_j_vec /= 0 .or. res%a(k)%ij /= 0) fac3 = sqrt_j_vec**res%a(k)%ij elsewhere fac3 = 1 end where factor = k2l * product(fac3) dj(1) = dj(1) + factor * (res%a(k)%dj_cos * cos(theta) + & res%a(k)%dj_sin * sin(theta)) theta = sum(res%b(k)%iq * phi_vec) where (sqrt_j_vec /= 0 .or. res%b(k)%ij /= 0) fac3 = sqrt_j_vec**res%b(k)%ij elsewhere fac3 = 1 end where factor = k2l * product(fac3) dj(2) = dj(2) + factor * (res%b(k)%dj_cos * cos(theta) + & res%b(k)%dj_sin * sin(theta)) enddo end subroutine