Skip to content

Commit

Permalink
Merge pull request #605 from bmad-sim/devel/44
Browse files Browse the repository at this point in the history
Added polarity parameter to em_field.
  • Loading branch information
DavidSagan authored Oct 30, 2023
2 parents 7d8c13e + 7b5e18c commit 86933da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bmad/code/valid_tracking_method.f90
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ function valid_tracking_method (ele, species, tracking_method) result (is_valid)
select case (method)
case (symp_lie_ptc$, taylor$, runge_kutta$, time_runge_kutta$, custom$)
is_valid = .true.
case (symp_lie_bmad$)
if (associated(ele%cartesian_map) .and. ele%field_calc == fieldmap$) is_valid = .true.
end select

case (floor_shift$, fiducial$)
Expand Down
7 changes: 7 additions & 0 deletions bmad/doc/elements.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,13 @@ \section{EM_Field}
Attributes specific to an \vn{em_field} element are:
\begin{example}
constant_ref_energy = <Logical> ! Is the reference energy constant? Default = True.
polarity = <Real> ! For scaling the field.
\end{example}

The \vn{polarity} value is used to scale the magnetic field. By
default, \vn{polarity} has a value of 1.0. Example:
\begin{example}
wig1: wiggler, l = 1.6, polarity = -1, cartesian_map = \{...\}
\end{example}

If the \vn{constant_ref_energy} logical is set to \vn{True} (the default), the reference energy
Expand Down
2 changes: 2 additions & 0 deletions bmad/modules/attribute_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,8 @@ subroutine init_attribute_name_array ()
call init_attribute_name1 (em_field$, phi0$, 'PHI0')
call init_attribute_name1 (em_field$, phi0_err$, 'PHI0_ERR')
call init_attribute_name1 (em_field$, constant_ref_energy$, 'CONSTANT_REF_ENERGY')
call init_attribute_name1 (em_field$, polarity$, 'POLARITY')


call init_attribute_name1 (girder$, l$, 'L', dependent$)
call init_attribute_name1 (girder$, x_offset$, 'X_OFFSET')
Expand Down
1 change: 1 addition & 0 deletions bmad/parsing/set_ele_defaults.f90
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ subroutine set_ele_defaults (ele, do_allocate)
ele%value(fringe_type$) = full$
ele%value(field_autoscale$) = 1
ele%value(constant_ref_energy$) = true$
ele%value(polarity$) = 1.0

case (fiducial$)
ele%value(origin_ele_ref_pt$) = center_pt$
Expand Down

0 comments on commit 86933da

Please sign in to comment.