Skip to content

Commit

Permalink
Spin tracking will not respect element is_on = False setting. (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan authored Feb 26, 2024
1 parent 94628ef commit 131d2ec
Show file tree
Hide file tree
Showing 14 changed files with 2,381 additions and 2,350 deletions.
2 changes: 1 addition & 1 deletion bmad/code/make_mat6.f90
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ recursive subroutine make_mat6 (ele, param, start_orb, end_orb, err_flag)
endif

if (associated(ele%spin_taylor(0)%term)) then
ele%spin_q = spin_taylor_to_linear (ele%spin_taylor, .true., a_start_orb%vec-ele%spin_taylor_ref_orb_in)
ele%spin_q = spin_taylor_to_linear (ele%spin_taylor, .true., a_start_orb%vec-ele%spin_taylor_ref_orb_in, ele%is_on)
endif
endif

Expand Down
5 changes: 5 additions & 0 deletions bmad/low_level/track1_spin_taylor.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ subroutine track1_spin_taylor (start_orb, ele, param, end_orb)

!

if (.not. ele%is_on) then
end_orb%spin = start_orb%spin
return
endif

if (.not. associated(ele%spin_taylor(0)%term)) then
if (ele%spin_tracking_method == sprint$) then
call sprint_spin_taylor_map(ele)
Expand Down
4 changes: 2 additions & 2 deletions bmad/modules/bmad_routine_interface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2379,11 +2379,11 @@ subroutine spin_quat_resonance_strengths (orb_evec, spin_q, xi_sum, xi_diff)
complex(rp) orb_evec(6)
end subroutine

function spin_taylor_to_linear (spin_taylor, normalize, dref_orb) result (spin_map1)
function spin_taylor_to_linear (spin_taylor, normalize, dref_orb, is_on) result (spin_map1)
import
implicit none
type (taylor_struct), target :: spin_taylor(0:3)
logical normalize
logical normalize, is_on
real(rp) dref_orb(6), spin_map1(0:3,0:6)
end function

Expand Down
10 changes: 9 additions & 1 deletion bmad/ptc/ele_to_fibre.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ subroutine ele_to_fibre (ele, ptc_fibre, param, use_offsets, err_flag, integ_ord
type (gen_grad1_struct), pointer :: gg
type (em_taylor_struct), target :: em_taylor(3)
type (em_taylor_term_struct), pointer :: tm
type (taylor_struct) spin_taylor(0:3)
type (fibre), pointer :: ptc_fibre
type (keywords) ptc_key, key2
type (work) energy_work
Expand Down Expand Up @@ -1005,11 +1006,18 @@ subroutine ele_to_fibre (ele, ptc_fibre, param, use_offsets, err_flag, integ_ord
call taylor_to_real_8 (ele%taylor, beta0, beta1, ptc_re8, ref0, ref1)
ptc_c_damap = ptc_re8

if (associated(ele%spin_taylor(1)%term)) then
if (associated(ele%spin_taylor(1)%term) .and. ele%is_on) then
do j = 0, 3
ptc_taylor = ele%spin_taylor(j)
ptc_c_damap%q%x(j) = ptc_taylor
enddo
else
call taylor_make_quaternion_unit(spin_taylor)
do j = 0, 3
ptc_taylor = ele%spin_taylor(j)
ptc_c_damap%q%x(j) = ptc_taylor
enddo
call kill_taylor(spin_taylor)
endif

call kill (ptc_taylor)
Expand Down
Loading

0 comments on commit 131d2ec

Please sign in to comment.