!........................................................................ ! ! Subroutine :CUSTOM_closed_orbit(LAT, closed, idim) ! ! Description: If there are wigglers that use custom tracking it is sometimes ! difficult to find a closed orbit. In this subroutine ! 1.Identify custom wigglers that use integration for tracking ! 2.Set type use linear map for initial closed orbit ! 3.Set type to runge kutta for closed orbit determined ! with closed_orbit_at_start ! ! Arguments : Input: ! LAT -- lat_struct: Lat containing the lattice. ! ! Output: ! CLOSED -- Closed orbit coordinates !- subroutine custom_closed_orbit (lat, closed, idim) use bmad implicit none type (lat_struct) lat type (bmad_common_struct) com_saved type (coord_struct), allocatable :: closed(:) integer i, idim real(rp) eps_rel(4), eps_abs(4) character*12 type(lat%n_ele_max) ! com_saved = bmad_com do i=1,lat%n_ele_track if(lat%ele(i)%key == custom$)type(i) = lat%ele(i)%type if(lat%ele(i)%key == custom$)lat%ele(i)%type = 'LINEAR' end do call twiss_at_start (lat) closed(0)%vec(:) = 0. call closed_orbit_calc( lat, closed, 4 ) do i=1,lat%n_ele_track if(lat%ele(i)%key == custom$)lat%ele(i)%type = type(i) end do eps_rel(:) = 0.000001 eps_abs(:) = 0.000001 call closed_orbit_from_tracking( lat, closed, 4, eps_rel, eps_abs, closed(0) ) bmad_com%aperture_limit_on = .true. bmad_com = com_saved end subroutine