! Subroutine dx_dvcros7_CALC (LAT, VC7_DIFF) ! ! Subroutine to calculate the dependence of orbit at detectors 0E and 0W ! on vcrosing 7. The group element raw_vcrosing_7 must be defined ! ! ! Input: ! LAT -- lat_struct: Lat ! ! Output: !- vc7_diff(0:lat%n_ele_track) -- Coord_struct ! Difference between closed orbits with vcrosing7 ! +- dk subroutine dx_dvcros7_calc ( lat, vc7_diff) use bmadz_mod use bmadz_interface, dummy => dx_dvcros7_calc use bmad_interface implicit none type (lat_struct) lat type (coord_struct), allocatable :: vc7_diff(:) type (coord_struct), allocatable, save :: coplus(:) type (coord_struct), allocatable, save :: cominus(:) real(rp) :: vc7_command, dk, vec0(6) = 0 integer ix_vc7/0/ integer i, n_track n_track = lat%n_ele_track call reallocate_coord(coplus, lat) call reallocate_coord(cominus, lat) ! ! find raw_vcrosing_7 i=0 do while(ix_vc7 == 0) if(lat%ele(i)%name == 'RAW_VCROSING_7')ix_vc7=i i=i+1 if(i > n_track) then print *,' DX_DVCROS7_CALC: cannot find RAW_VCROSING_7' stop endif enddo vc7_command = lat%ele(ix_vc7)%control%var(1)%value dk = 0.1 lat%ele(ix_vc7)%control%var(1)%value = vc7_command*(1+dk) call lat_make_mat6(lat, ix_vc7) call closed_orbit_calc( lat, coplus, 4, +1 ) lat%ele(ix_vc7)%control%var(1)%value = vc7_command*(1-dk) call lat_make_mat6(lat, ix_vc7) call init_coord (cominus(n_track), vec0, lat%ele(n_track), downstream_end$, antiparticle(lat%param%particle), -1) call closed_orbit_calc( lat, cominus, 4, -1 ) lat%ele(ix_vc7)%control%var(1)%value = vc7_command call lat_make_mat6(lat, ix_vc7) do i = 1,n_track vc7_diff(i)%vec(:) = (coplus(i)%vec(:) - cominus(i)%vec(:))/(2*dk) end do return end