Skip to content

Commit

Permalink
Merge pull request #540 from bmad-sim/devel/step20
Browse files Browse the repository at this point in the history
bmad/elegnat gkicker/malign conversion implemented.
  • Loading branch information
DavidSagan committed Oct 3, 2023
2 parents ae9d927 + b227aa3 commit bcccadc
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 25 deletions.
5 changes: 5 additions & 0 deletions bmad/code/write_lattice_in_foreign_format.f90
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,11 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or
bmad_params(:1) = [character(40):: 'l']
elegant_params(:1) = [character(40):: 'l']

case (gkicker$)
write (line_out, '(2a)') trim(ele%name) // ': malign'
bmad_params(:6) = [character(40):: 'x_kick', 'y_kick', 'z_kick', 'px_kick', 'py_kick', 'pz_kick']
elegant_params(:6) = [character(40):: 'dx', 'dy', 'dz', 'dxp', 'dyp', 'dp']

case (hkicker$) ! Elegant
write (line_out, '(2a)') trim(ele%name) // ': ehkick'
bmad_params(:6) = [character(40):: 'l', 'kick', 'tilt', 'x_offset', 'y_offset', 'z_offset']
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: September 30, 2023 \\
Revision: October 3, 2023 \\
\end{flushright}

\pdfbookmark[0]{Preamble}{Preamble}
Expand Down
39 changes: 20 additions & 19 deletions bmad/doc/param-statements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ \section{Particle_Start Statements}
particle_start[spin_x] = <Real> ! Spin polarization x-coordinate
particle_start[spin_y] = <Real> ! Spin polarization y-coordinate
particle_start[spin_z] = <Real> ! Spin polarization z-coordinate
particle_start[spin_dn_dpz_x] = <Real> ! Spin dn/dpz x-coordinate
particle_start[spin_dn_dpz_y] = <Real> ! Spin dn/dpz y-coordinate
particle_start[spin_dn_dpz_z] = <Real> ! Spin dn/dpz z-coordinate
\end{example}
Normally the absolute time, set by \vn{particle_start[t]}, is a dependent
parameter set by solving \Eq{zbctt} for $t$. The exception is when the
Expand Down Expand Up @@ -281,22 +278,26 @@ \section{Beginning and Line Parameter Statements}
For non--circular lattices, the \vn{beginning} statement can be used to set the Twiss parameters and
beam energy at the beginning of the first lattice branch.
\begin{example}
beginning[alpha_a] = <Real> ! "a" mode alpha
beginning[alpha_b] = <Real> ! "b" mode alpha
beginning[beta_a] = <Real> ! "a" mode beta
beginning[beta_b] = <Real> ! "b" mode beta
beginning[cmat_ij] = <Real> ! C coupling matrix. i, j = \{``1'', or ``2''\}
beginning[mode_flip] = <logic> ! Set the mode flip status (\sref{s:coupling}). Default is False.
beginning[e_tot] = <Real> ! Reference total energy in eV.
beginning[eta_x] = <Real> ! x-axis dispersion
beginning[eta_y] = <Real> ! y-axis dispersion
beginning[etap_x] = <Real> ! x-axis dispersion derivative.
beginning[etap_y] = <Real> ! y-axis dispersion derivative.
beginning[p0c] = <Real> ! Reference momentum in eV.
beginning[phi_a] = <Real> ! "a" mode phase.
beginning[phi_b] = <Real> ! "b" mode phase.
beginning[ref_time] = <Real> ! Starting reference time.
beginning[s] = <Real> ! Longitudinal starting position.
beginning[alpha_a] = <Real> ! "a" mode alpha
beginning[alpha_b] = <Real> ! "b" mode alpha
beginning[beta_a] = <Real> ! "a" mode beta
beginning[beta_b] = <Real> ! "b" mode beta
beginning[cmat_ij] = <Real> ! C coupling matrix. i, j = \{``1'', or ``2''\}
beginning[mode_flip] = <logic> ! Set the mode flip status (\sref{s:coupling}). Default is False.
beginning[e_tot] = <Real> ! Reference total energy in eV.
beginning[eta_x] = <Real> ! x-axis dispersion
beginning[eta_y] = <Real> ! y-axis dispersion
beginning[etap_x] = <Real> ! x-axis dispersion derivative.
beginning[etap_y] = <Real> ! y-axis dispersion derivative.
beginning[p0c] = <Real> ! Reference momentum in eV.
beginning[phi_a] = <Real> ! "a" mode phase.
beginning[phi_b] = <Real> ! "b" mode phase.
beginning[ref_time] = <Real> ! Starting reference time.
beginning[s] = <Real> ! Longitudinal starting position.
beginning[spin_dn_dpz_x] = <Real> ! Spin dn/dpz x-coordinate
beginning[spin_dn_dpz_y] = <Real> ! Spin dn/dpz y-coordinate
beginning[spin_dn_dpz_z] = <Real> ! Spin dn/dpz z-coordinate

\end{example}
\index{e_tot}
The \vn{gamma_a}, \vn{gamma_b}, and \vn{gamma_c} (the coupling gamma factor) will be kept consistent
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/09/30 14:19:56"
character(*), parameter :: tao_version_date = "2023/10/02 02:28:01"
end module
32 changes: 28 additions & 4 deletions util_programs/elegant_to_bmad/elegant_to_bmad.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(self):
'koct': 'octupole',
'center': 'patch',
'energy': 'patch',
'malign': 'patch',
'malign': 'gkicker',
'rotate': 'marker', # [exclude_floor != 0, exclude_optics != 0]
# taylor [exclude_floor != 0, exclude_optics == 0]
# floor_shift [exclude_floor == 0, exclude_optics != 0]
Expand Down Expand Up @@ -600,9 +600,33 @@ def parse_element(dlist):

for eparam in ele.param:
## if eparam in ['dx', 'dy', 'dz'] and 'etilt' in params: continue # Handled later
bparam = bmad_param(eparam, ele.name)
if bparam == '?': continue
if ele.bmad_type == 'drift' and bparam != 'l': continue

# Malign -> Gkicker

if ele.bmad_type == 'malign':
if eparam == 'dx':
bparam = 'x_kick'
elif eparam == 'dy':
bparam = 'y_kick'
elif eparam == 'dz':
bparam = 'z_kick'
elif eparam == 'dxp':
bparam = 'px_kick'
elif eparam == 'dyp':
bparam = 'py_kick'
elif eparam == 'dp':
bparam = 'pz_kick'
else:
bparam = '?'

else:
bparam = bmad_param(eparam, ele.name)
if bparam == '?': continue
if ele.bmad_type == 'drift' and bparam != 'l': continue
endif

#

value = postfix_to_infix(params[eparam])

if bparam == 'phi0':
Expand Down

0 comments on commit bcccadc

Please sign in to comment.