Skip to content

Commit

Permalink
Better error messaging with read_beam. (#761)
Browse files Browse the repository at this point in the history
* Update Tao doc.

* Better error messaging with read_beam.
  • Loading branch information
DavidSagan committed Jan 31, 2024
1 parent b73a217 commit 4d687e6
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 114 deletions.
Binary file modified bmad-doc/other_manuals/long_term_tracking.pdf
Binary file not shown.
27 changes: 22 additions & 5 deletions bmad/code/type_ele.f90
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ subroutine type_ele (ele, type_zero_attrib, type_mat6, type_taylor, twiss_out, t
integer, optional, intent(out) :: n_lines
integer ia, im, i1, ig, i, j, n, is, ix, iw, ix2_attrib, iv, ic, nl2, l_status, a_type, default_val
integer nl, nt, n_term, n_att, attrib_type, n_char, iy, particle, ix_pole_max, lb(2), ub(2)
integer id1, id2, id3, ne, na
integer id1, id2, id3, ne, na, nn

real(rp) coef, val, L_mis(3), S_mis(3,3)
real(rp) a(0:n_pole_maxx), b(0:n_pole_maxx)
Expand Down Expand Up @@ -955,8 +955,25 @@ subroutine type_ele (ele, type_zero_attrib, type_mat6, type_taylor, twiss_out, t
enddo

if (has_it) then

nn = 10
na = 12
nt = 12

do im = 1, ele%n_lord
lord => pointer_to_lord (ele, im, ctl)
nn = max(nn, len_trim(lord%name)+2)
select case (lord%lord_status)
case (super_lord$, multipass_lord$, girder_lord$)
case default
na = max(na, len_trim(ctl%attribute)+2)
if (.not. lord%is_on) nt = 18
end select
enddo

str1 = ''
nl=nl+1; li(nl) = 'Controller Lord(s):'
nl=nl+1; li(nl) = ' Index Name Attribute Lord_Type Expression'
nl=nl+1; write (li(nl), '(9a)') ' Index Name', str1(:nn-4), 'Attribute', str1(:na-9), 'Lord_Type', str1(:nt-9), 'Expression'

do im = 1, ele%n_lord
lord => pointer_to_lord (ele, im, ctl)
Expand All @@ -975,13 +992,13 @@ subroutine type_ele (ele, type_zero_attrib, type_mat6, type_taylor, twiss_out, t
call split_expression_string (knots_to_string(lord%control%x_knot, ctl%y_knot), 70, 5, li2)
endif
a_name = ctl%attribute
if (lord%lord_status == overlay_lord$ .and. .not. lord%is_on) str1 = 'Overlay [IS_ON = F]'
if (.not. lord%is_on) str1 = trim(str1) // ' [Is off]'
end select

if (nl+size(li2)+100 > size(li)) call re_allocate (li, nl+size(li2)+100)
nl=nl+1; write (li(nl), '(i8, 3x, a32, a18, 2x, a21, a)') lord%ix_ele, lord%name, a_name, str1, trim(li2(1))
nl=nl+1; write (li(nl), '(i8, 3x, 4a)') lord%ix_ele, lord%name(:nn), a_name(:na), str1(:nt), trim(li2(1))
do j = 2, size(li2)
nl=nl+1; li(nl) = ''; li(nl)(84:) = trim(li2(j))
nl=nl+1; li(nl) = ''; li(nl)(17+nn+na+nt:) = trim(li2(j))
enddo
enddo
endif
Expand Down
34 changes: 33 additions & 1 deletion bmad/doc/charged-tracking.tex
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ \section{BeamBeam Tracking}
end of any tracking so that the longitudinal starting point and ending point are identical. The
longitudinal $s$--position of the \vn{BeamBeam} element is at the center of the strong bunch. For
example, with \vn{n_slice} = 2 and with a solenoid field, the calculation would proceed as follows:
\begin{enumerate}
\begin{enumerate}[topsep=-0.2ex,itemsep=-0.0ex]
\item
Start with the particle longitudinally at the \vn{beambeam} element (which is considered to have
zero longitudinal length) in laboratory coordinates (\sref{s:coords.3}).
Expand Down Expand Up @@ -367,6 +367,38 @@ \section{BeamBeam Tracking}
%
\end{enumerate}

There is an energy kick due to the motion of the strong beam. This is similar to the gravatational
slingshot in orbital mechanics. The energy kick is simply calculated using conservation of
4-momentum of the tracked particle and the strong beam where the mass of the strong beam is assumed
to be large compared to the mass of the tracked particle.\footnote
{
This assumption breaks down if a tracked particle is deflected due to a single scattering event with
a particle of the strong beam. But particle-particle scattering is outside of the assumption of a
strong beam that is unaffected by the weak beam.
}
After a little bit of algebra. The energy kick $dE_w$ to lowest order in the angle of the weak
particle with respect to the axis defined by the of motion of the strong beam is
\begin{equation}
dE_w = \frac{c \, P_w}{2 \, (1/\beta_w + 1/\beta_s)} \, \left( \theta_{w2}^2 - \theta_{w1}^2 \right)
\end{equation}
where $P_w$ is the momentum of the weak particle, $\beta_w$ and $\beta_s$ are the weak and strong
beam velocities, and $\theta_{w1}$ and $\theta_{w2}$ are angles of the weak particle trajectory with
respect to the strong beam motion before and after the interaction. Converting to phase space
coordinates, the momentum kick $dp_z$ is
\begin{equation}
dp_z = \frac{1}{2 \, \beta_w \, (1/\beta_w + 1/\beta_s) \, (1 + p_z)}
\left( dp_x \, (dp_x - 2p_{x1}) + dp_y \, (dp_y - 2p_{y1}) \right)
\end{equation}
where $dp_x$ and $dp_y$ are the transverse kicks and $p_{x1}$ and $p_{y1}$ are the initial phase
space momenta.

There is an added term to the energy kick when the strong beam's cross-section is changing due to
the hourglass effect.



\newpage

%---------------------------------------------------------------------------------
%---------------------------------------------------------------------------------
\section{Bend: Exact Body Tracking with k1 = 0}
Expand Down
Loading

0 comments on commit 4d687e6

Please sign in to comment.