diff --git a/bmad/doc/charged-tracking.tex b/bmad/doc/charged-tracking.tex index 097b7bed9..c613c7d22 100644 --- a/bmad/doc/charged-tracking.tex +++ b/bmad/doc/charged-tracking.tex @@ -388,7 +388,7 @@ \section{BeamBeam Tracking} coordinates, the momentum kick $dp_z$ is \begin{equation} dp_{z,s} = \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) + \left( dp_x \, (dp_x + 2p_{x1}) + dp_y \, (dp_y + 2p_{y1}) \right) \label{dpz12} \end{equation} where $dp_x$ and $dp_y$ are the transverse kicks and $p_{x1}$ and $p_{y1}$ are the initial phase @@ -928,18 +928,18 @@ \section{Drift Tracking} \bmad uses the exact map for a drift This gives the map \begin{align} - x_2 &= x_1 + \frac{L \, p_{x1}}{(1 + p_{z1}) \, p_l} \CRNO + x_2 &= x_1 + \frac{L \, p_{x1}}{p_l} \CRNO p_{x2} &= p_{x1} \CRNO - y_2 &= y_1 + \frac{L \, p_{y1}}{(1 + p_{z1}) \, p_l} \CRNO + y_2 &= y_1 + \frac{L \, p_{y1}}{p_l} \CRNO p_{y2} &= p_{y1} \\ - z_2 &= z_1 + \left( \frac{\beta}{\beta_\REF} - \frac{1}{p_l} \right) \, L \CRNO + z_2 &= z_1 + \left( \frac{\beta}{\beta_\REF} - \frac{1 + p_{z1}}{p_l} \right) \, L \CRNO p_{z2} &= p_{z1} \nonumber \end{align} -where $\beta$ is the normalized particle velocity, $\beta_\REF$ is -the reference particle's normalized velocity, and $p_l$ is the -longitudinal momentum +where $\beta$ is the normalized particle velocity, $\beta_\REF$ is the reference particle's +normalized velocity, and $p_l$ is the normalized longitudinal momentum $P_l/P_0$ with $P_l$ being +the longitudinal momentum \begin{equation} - p_l = \sqrt{1 - \frac{p_x^2 + p_y^2}{(1 + p_z)^2}} + p_l = \sqrt{(1 + p_z)^2 - p_x^2 + p_y^2} \end{equation} %--------------------------------------------------------------------------------- diff --git a/bmad/doc/cover-page.tex b/bmad/doc/cover-page.tex index d56792147..4b08ccca3 100644 --- a/bmad/doc/cover-page.tex +++ b/bmad/doc/cover-page.tex @@ -3,7 +3,7 @@ \begin{flushright} \large - Revision: November 14, 2024 \\ + Revision: December 5, 2024 \\ \end{flushright} \pdfbookmark[0]{Preamble}{Preamble} diff --git a/bmad/low_level/track_a_drift.f90 b/bmad/low_level/track_a_drift.f90 index 01807aa1b..f4417eb3e 100644 --- a/bmad/low_level/track_a_drift.f90 +++ b/bmad/low_level/track_a_drift.f90 @@ -34,58 +34,58 @@ subroutine track_a_drift (orb, length, mat6, make_matrix, ele_orientation, inclu real(rp), optional :: mat6(6,6), time real(rp) matd(6,6), e_tot_ref, e_particle, rel_len, dt -real(rp) length, rel_pc, dz, px, py, ps, delta, pxy2, mc2, beta_ref +real(rp) length, rel_pc, dz, px_rel, py_rel, ps_rel, delta, pxy2, mc2, beta_ref integer, optional :: ele_orientation integer rel_z_vel logical, optional :: make_matrix, include_ref_motion -! If the element orientation is opposite the particle direction, px and py are reversed. +! If the element orientation is opposite the particle direction, px_rel and py_rel are reversed. if (length == 0) return delta = orb%vec(6) rel_pc = 1 + delta rel_z_vel = integer_option(orb%direction, ele_orientation) * orb%direction -px = rel_z_vel * orb%vec(2) / rel_pc -py = rel_z_vel * orb%vec(4) / rel_pc -pxy2 = px**2 + py**2 +px_rel = rel_z_vel * orb%vec(2) / rel_pc ! Relative to the actual momentum, not the reference momentum. +py_rel = rel_z_vel * orb%vec(4) / rel_pc +pxy2 = px_rel**2 + py_rel**2 if (pxy2 >= 1) then orb%state = lost_pz$ return endif -ps = sqrt(1 - pxy2) +ps_rel = sqrt(1 - pxy2) -orb%vec(1) = orb%vec(1) + length * px / ps -orb%vec(3) = orb%vec(3) + length * py / ps +orb%vec(1) = orb%vec(1) + length * px_rel / ps_rel +orb%vec(3) = orb%vec(3) + length * py_rel / ps_rel ! Length is the length in body coordinates if (orb%beta > 0) then if (logic_option(.true., include_ref_motion)) then mc2 = mass_of(orb%species) - ! dz = length * ([beta/beta_ref - 1] - [1/ps - 1]) + ! dz = length * ([beta/beta_ref - 1] - [1/ps_rel - 1]) if (orb%direction == 1) then - dz = length * (sqrt_one((mc2**2 * (2*delta+delta**2))/((orb%p0c*rel_pc)**2 + mc2**2)) + sqrt_one(-pxy2)/ps) + dz = length * (sqrt_one((mc2**2 * (2*delta+delta**2))/((orb%p0c*rel_pc)**2 + mc2**2)) + sqrt_one(-pxy2)/ps_rel) else beta_ref = orb%p0c / sqrt(orb%p0c**2 + mc2**2) - dz = length * ((-orb%beta/beta_ref - 1.0_rp) - (1.0_rp / ps - 1.0_rp)) + dz = length * ((-orb%beta/beta_ref - 1.0_rp) - (1.0_rp / ps_rel - 1.0_rp)) endif orb%s = orb%s + orb%direction * length else - dz = -length /ps + dz = -length /ps_rel endif - dt = rel_z_vel * length / (orb%beta * ps * c_light) + dt = rel_z_vel * length / (orb%beta * ps_rel * c_light) orb%t = orb%t + dt if (present(time)) time = time + dt else if (logic_option(.true., include_ref_motion)) then - dz = length * (1 - 1/ps) + dz = length * (1 - 1/ps_rel) orb%s = orb%s + orb%direction * length else - dz = -length /ps + dz = -length /ps_rel endif endif @@ -93,21 +93,21 @@ subroutine track_a_drift (orb, length, mat6, make_matrix, ele_orientation, inclu if (logic_option(.false., make_matrix)) then call mat_make_unit(matd) - rel_len = length / (rel_pc * ps) - matd(1,2) = rel_len * (px**2 / ps**2 + 1) - matd(3,4) = rel_len * (py**2 / ps**2 + 1) - matd(1,4) = rel_len * px*py / ps**2 - matd(3,2) = rel_len * px*py / ps**2 - matd(1,6) = -rel_len * px / ps**2 - matd(3,6) = -rel_len * py / ps**2 - matd(5,2) = -rel_len * px / ps**2 - matd(5,4) = -rel_len * py / ps**2 + rel_len = length / (rel_pc * ps_rel) + matd(1,2) = rel_len * (px_rel**2 / ps_rel**2 + 1) + matd(3,4) = rel_len * (py_rel**2 / ps_rel**2 + 1) + matd(1,4) = rel_len * px_rel*py_rel / ps_rel**2 + matd(3,2) = rel_len * px_rel*py_rel / ps_rel**2 + matd(1,6) = -rel_len * px_rel / ps_rel**2 + matd(3,6) = -rel_len * py_rel / ps_rel**2 + matd(5,2) = -rel_len * px_rel / ps_rel**2 + matd(5,4) = -rel_len * py_rel / ps_rel**2 if (logic_option(.true., include_ref_motion)) then e_tot_ref = sqrt(orb%p0c**2 + mass_of(orb%species)**2) e_particle = orb%p0c * (1 + orb%vec(6)) / orb%beta - matd(5,6) = rel_len * (px**2 + py**2) / ps**2 + length * mass_of(orb%species)**2 * e_tot_ref / e_particle**3 + matd(5,6) = rel_len * (px_rel**2 + py_rel**2) / ps_rel**2 + length * mass_of(orb%species)**2 * e_tot_ref / e_particle**3 else - matd(5,6) = rel_len * (px**2 + py**2) / ps**2 + matd(5,6) = rel_len * (px_rel**2 + py_rel**2) / ps_rel**2 endif mat6 = matmul(matd, mat6) diff --git a/bsim/code/set_tune_3d.f90 b/bsim/code/set_tune_3d.f90 index 5969e4274..e37028a8f 100644 --- a/bsim/code/set_tune_3d.f90 +++ b/bsim/code/set_tune_3d.f90 @@ -62,7 +62,7 @@ function set_tune_3d (branch, target_tunes, quad_mask, use_phase_trombone, z_tun ele => branch%ele(1) n = branch%n_ele_track do i = 1, 20 - call twiss_and_track(branch%lat, co, status, branch%ix_branch) + call twiss_and_track(branch%lat, co, status, branch%ix_branch, print_err = print_err) if (status == ok$) then dQ_a = target_tunes(1) - branch%ele(n)%a%phi/twopi dQ_b = target_tunes(2) - branch%ele(n)%b%phi/twopi diff --git a/tao/version/tao_version_mod.f90 b/tao/version/tao_version_mod.f90 index 0147b521d..2d67f757c 100644 --- a/tao/version/tao_version_mod.f90 +++ b/tao/version/tao_version_mod.f90 @@ -6,5 +6,5 @@ !- module tao_version_mod -character(*), parameter :: tao_version_date = "2024/12/02 15:05:24" +character(*), parameter :: tao_version_date = "2024/12/04 22:29:10" end module