Skip to content

Commit

Permalink
Fix last version of track_a_bend.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan committed Oct 30, 2023
1 parent 3bc02fe commit 466bbd2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
Binary file modified bmad-doc/other_manuals/long_term_tracking.pdf
Binary file not shown.
8 changes: 4 additions & 4 deletions bmad/low_level/symp_lie_bmad.f90
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ subroutine symp_lie_bmad (ele, param, orbit, track, mat6, make_matrix, offset_el
! select the element

key = ele%key
if (associated(ele%cartesian_map)) key = wiggler$
if (associated(ele%cartesian_map) .and. ele%field_calc == fieldmap$) key = wiggler$

select case (ele%key)
select case (key)

!------------------------------------------------------------------
! Wiggler
Expand Down Expand Up @@ -365,8 +365,8 @@ subroutine symp_lie_bmad (ele, param, orbit, track, mat6, make_matrix, offset_el

case default

call out_io (s_fatal$, r_name, 'TRACKING NOT YET IMPLEMENTED FOR: ' // key_name(ele%key), &
'FOR ELEMENT: ', ele%name)
call out_io (s_fatal$, r_name, 'TRACKING NOT YET IMPLEMENTED FOR ELEMENT OF TYPE: ' // key_name(ele%key), &
'FOR ELEMENT: ' // ele%name)

end select

Expand Down
11 changes: 8 additions & 3 deletions bmad/low_level/track_a_bend.f90
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,20 @@ subroutine apply_multipole_kicks (coef, step_len, r_step, ix_mag_max, an, bn, ix
real(rp) an(0:n_pole_maxx), bn(0:n_pole_maxx), an_elec(0:n_pole_maxx), bn_elec(0:n_pole_maxx)

integer i, charge, ix_mag_max, ix_elec_max
logical exact

! Calculate field

charge = charge_of(orbit%species)

if (nint(ele%value(exact_multipoles$)) /= off$ .and. ele%value(g$) /= 0) then
exact = .true.
call bend_exact_multipole_field (ele, param, orbit, .true., field, make_matrix)

else
exact = .false.
field = em_field_struct()
f_p0c = r_step * ele%value(p0c$) / (step_len * c_light * charge_of(param%particle))
f_p0c = r_step * ele%value(p0c$) / (c_light * charge_of(param%particle))

do i = 0, ix_mag_max
if (an(i) == 0 .and. bn(i) == 0) cycle
Expand Down Expand Up @@ -389,12 +392,14 @@ subroutine apply_multipole_kicks (coef, step_len, r_step, ix_mag_max, an, bn, ix

if (ix_mag_max > -1) then
orb0 = orbit
f_coef = step_len * coef * c_dir * (1 + ele%value(g$) * orbit%vec(1)) * c_light / orb0%p0c
f_coef = coef * c_dir * (1 + ele%value(g$) * orbit%vec(1)) * c_light / orb0%p0c
if (exact) f_coef = f_coef * step_len
orbit%vec(2) = orbit%vec(2) - f_coef * field%B(2)
orbit%vec(4) = orbit%vec(4) + f_coef * field%B(1)

if (logic_option(.false., make_matrix)) then
df_coef_dx = step_len * coef * c_dir * ele%value(g$) * c_light / orb0%p0c
df_coef_dx = coef * c_dir * ele%value(g$) * c_light / orb0%p0c
if (exact) df_coef_dx = f_coef * step_len

mat6(2,:) = mat6(2,:) - (f_coef * field%dB(2,1) + df_coef_dx * field%B(2)) * mat6(1,:) - &
(f_coef * field%dB(2,2)) * mat6(3,:)
Expand Down
4 changes: 2 additions & 2 deletions bsim/long_term_tracking/doc/long_term_tracking.tex
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

\title{Long Term Tracking Program}
\author{}
\date{David Sagan \\ July 10, 2023}
\date{David Sagan \\ October 30, 2023}

\begin{document}
\pdfbookmark[1]{Contents}{contents}
Expand Down Expand Up @@ -433,7 +433,7 @@
To simulate noise, use the \vn{ran()} or \vn{ran_gauss()} functions in a slave expression. Example:
\begin{code}
quake: ramper = \{*[y_offset]: 1e-5*ran_gauss()\}, var = \{\}
\end
\end{code}
In this case no ramper variable is needed.
When a bunch passes through an element, the slave expression \vn{1e-5*ran_gauss()} is evaluated just
once. That is, it is assumed that the frequency spectrum of the noise falls below 1/\vn{dt_bunch}
Expand Down
2 changes: 1 addition & 1 deletion tao/version/tao_version_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
!-

module tao_version_mod
character(*), parameter :: tao_version_date = "2023/10/29 01:05:04"
character(*), parameter :: tao_version_date = "2023/10/29 18:44:34"
end module

0 comments on commit 466bbd2

Please sign in to comment.