Skip to content

Commit

Permalink
Merge pull request #542 from bmad-sim/devel/step21
Browse files Browse the repository at this point in the history
Devel/step21
  • Loading branch information
DavidSagan committed Oct 5, 2023
2 parents bcccadc + 95a0eed commit 7f3a492
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion bmad/doc/attributes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,7 @@ \subsection{Cartesian_Map Field Map}
map types.
To use with PTC dependent tracking methods (\sref{s:integ}) there are a number of restrictions:
\begin{itemize}
\begin{itemize}
%
\item
There can be only one \vn{cartesian_map} field map and there cannot be any other field maps of any
Expand All @@ -2349,6 +2349,10 @@ \subsection{Cartesian_Map Field Map}
%
\item
The transverse terms in \vn{r0} must be zero.
%
\item
Since PTC evaluates the vector potential (\sref{s:wiggler.std}), and since \vn{k_z} appears in the
denominator of some terms, \vn{k_z} must be non-negative for all terms.
\end{itemize}
%-----------------------------------------------------------------
Expand Down
13 changes: 8 additions & 5 deletions bmad/ptc/ele_to_fibre.f90
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,7 @@ subroutine ele_to_fibre (ele, ptc_fibre, param, use_offsets, err_flag, integ_ord
is_planar_wiggler = ((key == wiggler$ .or. key == undulator$) .and. ele2%field_calc == planar_model$)

if (associated(ele2%grid_field)) then
call out_io (s_fatal$, r_name, 'PTC TRACKING IS NOT ABLE TO USE GRID_FIELDS. FOR ELEMENT: ' // ele%name)
if (global_com%exit_on_error) call err_exit
call out_io (s_error$, r_name, 'PTC TRACKING IS NOT ABLE TO USE GRID_FIELDS. FOR ELEMENT: ' // ele%name)
return
endif

Expand All @@ -914,18 +913,22 @@ subroutine ele_to_fibre (ele, ptc_fibre, param, use_offsets, err_flag, integ_ord
allocate(cm)
call create_wiggler_cartesian_map(ele2, cm)
else
call out_io (s_fatal$, r_name, 'NOT ABLE TO DO PTC TRACKING FOR NON-PLANAR WIGGLER WITHOUT A CARTESIAN (OR OTHER TYPE OF) MAP.', &
call out_io (s_error$, r_name, 'NOT ABLE TO DO PTC TRACKING FOR NON-PLANAR WIGGLER WITHOUT A CARTESIAN (OR OTHER TYPE OF) MAP.', &
'FOR ELEMENT: ' // ele%name)
if (global_com%exit_on_error) call err_exit
return
endif
else
cm => ele2%cartesian_map(1)
endif

if (any(abs(cm%ptr%term%kz) < 1e-100_rp)) then
call out_io (s_error$, r_name, 'CARTESIAN MAP KZ VALUES MUST BE NON-ZERO (MAKE > 1E-100).', &
'FOR ELEMENT: ' // ele%name)
return
endif

if (cm%field_type == electric$) then
call out_io (s_fatal$, r_name, 'PTC IS NOT ABLE TO HANDLE CARTESIAN_MAP WITH ELECTRIC FIELDS. FOR ELEMENT: ' // ele%name)
if (global_com%exit_on_error) call err_exit
return
endif

Expand Down
4 changes: 3 additions & 1 deletion tao/code/tao_spin_polarization_calc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ subroutine tao_spin_polarization_calc (branch, tao_branch, excite_zero, ignore_k
if (branch%param%geometry == closed$) then
tao_branch%spin%tune = 2.0_rp * atan2(norm2(q_1turn%spin_q(1:3,0)), q_1turn%spin_q(0,0))
n0 = 0
s_vec = [0.0_rp, 0.0_rp, 1.0_rp]
dn_dpz = 0
partial = 0
partial2 = 0

else
n0 = branch%lat%particle_start%spin
s_vec = [0.0_rp, 0.0_rp, 1.0_rp]
dn_dpz = branch%ele(0)%value(spin_dn_dpz_x$:spin_dn_dpz_z$)
partial = 0 ! Not sure this is computable.
partial2 = 0
Expand All @@ -110,6 +111,7 @@ subroutine tao_spin_polarization_calc (branch, tao_branch, excite_zero, ignore_k
old_n0 = n0
old_partial = partial
old_partial2 = partial2
old_s_vec = s_vec

ele => branch%ele(ie)

Expand Down

0 comments on commit 7f3a492

Please sign in to comment.