!+ ! Subroutine track1_preprocess (start_orb, ele, param, err_flag, finished, radiation_included, track) ! ! Dummy routine for pre-processing at the start of the track1 routine. ! ! Also see: ! track1_postprocess ! track1_custom ! ! The radiation_included argument should be set to True if this routine (or a modified version of track1_custom) ! takes into account radiation damping and/or excitation. This will prevent track1 from calling track1_radiation. ! Note: If symp_lie_bmad is being called by this routine, symp_lie_bmad does take into account radiation effects. ! ! General rule: Your code may NOT modify any argument that is not listed as an output agument below. ! ! Modules Needed: ! use bmad ! ! Input: ! start_orb -- coord_struct: Starting position. ! ele -- ele_struct: Element. ! param -- lat_param_struct: Lattice parameters. ! ! Output: ! start_orb -- coord_struct: End position. ! err_flag -- logical: Set true if there is an error. False otherwise. ! finished -- logical: When set True, track1 will halt processing and return to its calling routine. ! radiation_included ! -- logical: Should be set True if radiation damping/excitation is included in the tracking. ! track -- track_struct, optional: Structure holding the track information if the ! tracking method does tracking step-by-step. !- subroutine track1_preprocess (start_orb, ele, param, err_flag, finished, radiation_included, track) use bmad, except_dummy => track1_preprocess use ramp_parameters implicit none type (coord_struct) :: start_orb type (ele_struct) :: ele type (ele_struct), pointer, save :: ele_bump1, ele_bump2, ele_bump3 type (lat_param_struct) :: param type (track_struct), optional :: track type (all_pointer_struct), save :: a_ptr_bump1, a_ptr_bump2, a_ptr_bump3 logical err_flag, finished, radiation_included logical first_bump1/.true./ character(*), parameter :: r_name = 'track1_preprocess' real(rp) g, frac_ref, extract_qv, extract_qh, extract_s, extract_octk3, bump real(rp) b integer j,ix_lord ! ! print '(a,6es12.4)',ele%name,start_orb%vec if(param%ixx == 0)then !no ramp err_flag = .false. return else !print '(a)','call ramp function' call ramp_function(start_orb%t, frac_ref, extract_qv, extract_qh, extract_s,extract_octk3,bump) !ramp function returns a number between 0 and 1 that is the fraction of the reference if(ele%key == sbend$)then g=ele%value(g$) ele%value(g_err$) = -g*(1-frac_ref) ele%value(k1$) = ele%value(custom_attribute1$) * frac_ref ele%value(k2$) = ele%value(custom_attribute2$) * frac_ref !print '(5es12.4)',start_orb%t, frac_ref,ele%value(g_err$),ele%value(k1$),ele%value(k2$) if(trim(ele%name) == 'B012H')then b = bump*hbump(1) ele%value(g_err$) = ele%value(g_err$)*(1+b) +b*g ele%value(k1$) = ele%value(k1$)*(1+b) ele%value(k2$) = ele%value(k2$)*(1+b) endif if(trim(ele%name) == 'B001H')then b = bump*hbump(2) ele%value(g_err$) = ele%value(g_err$)*(1+b) +b*g ele%value(k1$) = ele%value(k1$) *(1+b) ele%value(k2$) = ele%value(k2$) *(1+b) endif if(trim(ele%name) == 'B190H')then b = bump*hbump(3) ele%value(g_err$) = ele%value(g_err$)*(1+b) +b*g ele%value(k1$) = ele%value(k1$) *(1+b) ele%value(k2$) = ele%value(k2$) *(1+b) endif endif if(ele%key == quadrupole$)then ele%value(k1$) = ele%value(custom_attribute1$) * frac_ref !print '(5es12.4)',start_orb%t, frac_ref,ele%value(g_err$),ele%value(k1$),ele%value(k2$) endif if(ele%key == multipole$)then ele%a_pole(0:n_pole_maxx) = ele%r(1,0:n_pole_maxx,1) * frac_ref ele%b_pole(0:n_pole_maxx) = ele%r(2,0:n_pole_maxx,1) * frac_ref endif if(ele%key == sextupole$) & ele%value(k2$) = ele%value(custom_attribute2$) * frac_ref !* (1. + extract_s) if(ele%key == sextupole$ .and.extract_s > 0)then ele%value(k2$) = (ele%value(custom_attribute2$) + extract_s) * frac_ref ! write(25, '(a12,1x,3es12.4)')ele%name,start_orb%t, extract_s,ele%value(k2$) endif if(trim(ele%name) == 'Q01V')then ele%value(k1$) = ele%value(k1$) * (1.+extract_qv) endif if(trim(ele%name) == 'Q02H')then ele%value(k1$) = ele%value(k1$) * (1.+extract_qh) endif ! if(trim(ele%name) == 'L4QUAD')then ! ele%value(k1$) = extact_qh * 0.4 ! endif if(index(ele%name,'Q01V_l0')/=0)then ele%value(k1$) = ele%value(k1$) endif if(index(ele%name,'Q02H_l0')/=0)then ele%value(k1$) = ele%value(k1$) endif if(ele%key == octupole$)then ele%value(k3$) = extract_octk3 * frac_ref endif !if(bump > 0)then !if(index(ele%name,'B012H') /=0)then ! if(first_bump1)then ! do j=1,ele%n_lord ! ele_bump1 => pointer_to_lord(ele,j) ! if(index(ele_bump1%name,'HBUMP1_B012H')/=0)then ! call pointer_to_attribute(ele_bump1, 'HKICK', .false., a_ptr_bump1, err_flag, .false.) ! exit ! endif ! end do ! first_bump1 = .false. ! endif ! a_ptr_bump1%r = hbump(1) * bump ! call control_bookkeeper(ele_bump1%branch%lat,ele_bump1) !endif !if(index(ele%name,'B001H') /=0)then ! do j=1,ele%n_lord ! ele_bump2 => pointer_to_lord(ele,j) ! if(index(ele_bump2%name,'HBUMP2_B001H') /=0)then ! call pointer_to_attribute(ele_bump2, 'HKICK', .false., a_ptr_bump2, err_flag, .false.) ! a_ptr_bump2%r = hbump(2) * bump ! call control_bookkeeper(ele_bump2%branch%lat,ele_bump2) ! endif ! end do !endif !if(index(ele%name,'B190H') /=0)then ! do j=1,ele%n_lord ! ele_bump3 => pointer_to_lord(ele,j) ! if(index(ele_bump3%name,'HBUMP3_B190H') /=0)then ! call pointer_to_attribute(ele_bump3, 'HKICK', .false., a_ptr_bump3, err_flag, .false.) ! a_ptr_bump3%r = hbump(3) * bump ! call control_bookkeeper(ele_bump3%branch%lat,ele_bump3) ! endif ! end do !endif !endif endif err_flag = .false. end subroutine