Skip to content

Commit

Permalink
Now match element will default to identity matrix if no betas are set. (
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan authored Aug 13, 2024
1 parent cf5b723 commit 0bd0d8d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
25 changes: 14 additions & 11 deletions bmad/code/lat_sanity_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -583,18 +583,21 @@ subroutine lat_sanity_check (lat, err_flag)
match_std = (is_true(ele%value(recalc$)) .and. nint(ele%value(matrix$)) == standard$)
match_orbit = (is_true(ele%value(recalc$)) .and. nint(ele%value(kick0$)) == match_orbit$)

if ((match_std .or. match_twiss) .and. (ele%value(beta_a1$) <= 0 .or. ele%value(beta_b1$) <= 0)) then
call out_io (s_fatal$, r_name, &
'ELEMENT: ' // ele_full_name(ele, '@N (&#)'), &
'WHICH IS A MATCH ELEMENT HAS A BETA_A1 OR BETA_B1 THAT IS NOT POSITIVE.')
err_flag = .true.
endif
if (.not. (match_std .and. ele%value(beta_a1$) == 0 .and. ele%value(beta_b1$) == 0 .and. &
ele%value(beta_a0$) == 0 .and. ele%value(beta_b0$) == 0)) then
if ((match_std .or. match_twiss) .and. (ele%value(beta_a1$) <= 0 .or. ele%value(beta_b1$) <= 0)) then
call out_io (s_fatal$, r_name, &
'ELEMENT: ' // ele_full_name(ele, '@N (&#)'), &
'WHICH IS A MATCH ELEMENT HAS A BETA_A1 OR BETA_B1 THAT IS NOT POSITIVE.')
err_flag = .true.
endif

if (match_std .and. (ele%value(beta_a0$) <= 0 .or. ele%value(beta_b0$) <= 0)) then
call out_io (s_fatal$, r_name, &
'ELEMENT: ' // ele_full_name(ele, '@N (&#)'), &
'WHICH IS A MATCH ELEMENT HAS A BETA_A0 OR BETA_B0 THAT IS NOT POSITIVE.')
err_flag = .true.
if (match_std .and. (ele%value(beta_a0$) <= 0 .or. ele%value(beta_b0$) <= 0)) then
call out_io (s_fatal$, r_name, &
'ELEMENT: ' // ele_full_name(ele, '@N (&#)'), &
'WHICH IS A MATCH ELEMENT HAS A BETA_A0 OR BETA_B0 THAT IS NOT POSITIVE.')
err_flag = .true.
endif
endif

if ((match_twiss .or. match_orbit) .and. ele%value(delta_time$) /= 0) then
Expand Down
2 changes: 1 addition & 1 deletion bmad/doc/cover-page.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

\begin{flushright}
\large
Revision: July 30, 2024 \\
Revision: August 13, 2024 \\
\end{flushright}

\pdfbookmark[0]{Preamble}{Preamble}
Expand Down
4 changes: 3 additions & 1 deletion bmad/doc/elements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3492,7 +3492,9 @@ \section{Match}
(and only if) the actual Twiss and coupling parameters at the entrance of the \vn{match} element
are equal to the element entrance Twiss and coupling parameters, then the computed Twiss and
coupling parameters at the exit end of the \vn{match} element will be the element end Twiss and coupling
parameters. Additionally, the phase advances (in radians) will be \vn{dphi_a} and \vn{dphi_b}.
parameters. Additionally, the phase advances (in radians) will be \vn{dphi_a} and \vn{dphi_b}. Exception:
If \vn{beta_a0}, \vn{beta_b0}, \vn{beta_a1}, and \vn{beta_b1} are all zero, the matrix will be set to the
identity.
%
\item[identity] \Newline
With \vn{matrix} set to \vn{identity} the transfer matrix will be set to the unit matrix independent
Expand Down
3 changes: 2 additions & 1 deletion bmad/low_level/match_ele_to_mat6.f90
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ subroutine match_ele_to_mat6 (ele, start_orb, mat6, vec0, err_flag, include_delt
v(pz0$) = start_orb%vec(6)
endif

if (m_val == identity$ .or. ((t_ele%a%beta == 0 .or. t_ele%b%beta == 0) .and. (do_twiss .or. do_trombone))) then
if (m_val == identity$ .or. ((t_ele%a%beta == 0 .or. t_ele%b%beta == 0) .and. (do_twiss .or. do_trombone)) .or. &
(m_val == standard$ .and. v(beta_a0$) == 0 .and. v(beta_b0$) == 0 .and. v(beta_a1$) == 0 .and. v(beta_b1$) == 0)) then
v(mode_flip0$) = int_logic(t_ele%mode_flip)
v(mode_flip1$) = int_logic(t_ele%mode_flip)
call mat_make_unit(mat6)
Expand Down
7 changes: 6 additions & 1 deletion bmad/parsing/bmad_parser_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6012,7 +6012,12 @@ subroutine compute_super_lord_s (ref_ele, super_ele, pele, ix_insert)
case default
s_ref_begin = ref_ele%s_start
s_ref_end = ref_ele%s
ix_ref = ref_ele%ix_ele
if (ref_ele%n_slave > 0) then
slave => pointer_to_slave(ref_ele, 1)
ix_ref = slave%ix_ele
else
ix_ref = ref_ele%ix_ele
endif
end select

! Now compute the s position at the end of the element and put it in ele%s.
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 = "2024/08/09 00:00:04"
character(*), parameter :: tao_version_date = "2024/08/10 16:53:27"
end module

0 comments on commit 0bd0d8d

Please sign in to comment.