Skip to content

Commit

Permalink
Merge pull request #598 from bmad-sim/devel/step39
Browse files Browse the repository at this point in the history
Now  will show a map of order N.
  • Loading branch information
DavidSagan authored Oct 28, 2023
2 parents 620d2f6 + b71e0b5 commit 594afcf
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dcs16_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
EXTERNAL_DEPS_VERSION: main

# secrets.DCS_PUSH works allows the ci.yml workflow to be triggered by this workflow. Documentation at:
# secrets.DCS_PUSH allows the ci.yml workflow to be triggered by this workflow. Documentation at:
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs

jobs:
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ source util/dist_source_me
util/dist_build_production
```





## Contributing to Bmad: Pull Requests

What is a Pull Request? A Pull Request (PR) is a mechanism for requesting that changes that you have made
Expand Down
96 changes: 57 additions & 39 deletions tao/code/tao_show_this.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4843,7 +4843,9 @@ subroutine tao_show_this (what, result_id, lines, nl)
nl=1; lines(1) = 'CANNOT READ ORDER NUMBER!'
return
endif

call string_trim (what2(ix+1:), what2, ix)

if (n_order > ptc_private%taylor_order_ptc) then
nl=1; write(lines(nl), '(a, i0)') &
'TAYLOR ORDER CANNOT BE ABOVE ORDER USED IN CALCULATIONS WHICH IS ', ptc_private%taylor_order_ptc
Expand All @@ -4860,6 +4862,7 @@ subroutine tao_show_this (what, result_id, lines, nl)
disp_fmt = 'ELEMENTS'
ele_name = what2(1:ix)
call string_trim(what2(ix+1:), what2, ix)
if (n_order == -1) n_order = 1

case ('-s')
by_s = .true.
Expand Down Expand Up @@ -4931,9 +4934,9 @@ subroutine tao_show_this (what, result_id, lines, nl)
ref_vec = orb%vec
endif

! By element
!

else
elseif (disp_fmt /= 'ELEMENTS') then

if (ele1_name == '') then
ix2 = lat%n_ele_track
Expand Down Expand Up @@ -5026,32 +5029,33 @@ subroutine tao_show_this (what, result_id, lines, nl)

!---------------------------------------

if (disp_fmt /= 'ELEMENTS' .and. ele2_name == '') then
nl=nl+1; lines(nl) = 'From: ' // trim(branch%ele(ix1)%name)
nl=nl+1; lines(nl) = 'To: ' // trim(branch%ele(ix2)%name)
endif

if (n_order > 1 .or. print_ptc) then
call transfer_map_calc (lat, taylor, err, ix1, ix2, u%model%tao_branch(ix_branch)%orbit(ix1), &
one_turn = .true., concat_if_possible = s%global%concatenate_maps)
if (err) then
nl = 1; lines(1) = 'TAYLOR MAP TERM OVERFLOW.'
return
if (disp_fmt /= 'ELEMENTS') then
if (ele2_name == '') then
nl=nl+1; lines(nl) = 'From: ' // trim(branch%ele(ix1)%name)
nl=nl+1; lines(nl) = 'To: ' // trim(branch%ele(ix2)%name)
endif

call taylor_to_mat6(taylor, u%model%tao_branch(ix_branch)%orbit(ix1)%vec, vec0, mat6)
ref_vec = u%model%tao_branch(ix_branch)%orbit(ix1)%vec
if (n_order > 1 .or. print_ptc) then
call transfer_map_calc (lat, taylor, err, ix1, ix2, u%model%tao_branch(ix_branch)%orbit(ix1), ix_branch, &
one_turn = .true., concat_if_possible = s%global%concatenate_maps)
if (err) then
nl = 1; lines(1) = 'TAYLOR MAP TERM OVERFLOW.'
return
endif

else
call transfer_matrix_calc (lat, mat6, vec0, ix1, ix2, ix_branch, one_turn = .true.)
ref_vec = u%model%tao_branch(ix_branch)%orbit(ix1)%vec
call taylor_to_mat6(taylor, u%model%tao_branch(ix_branch)%orbit(ix1)%vec, vec0, mat6)
ref_vec = u%model%tao_branch(ix_branch)%orbit(ix1)%vec

else
call transfer_matrix_calc (lat, mat6, vec0, ix1, ix2, ix_branch, one_turn = .true.)
ref_vec = u%model%tao_branch(ix_branch)%orbit(ix1)%vec
endif
endif

endif

! Print results

!
if (disp_fmt == 'ELEMENTS') THEN
call tao_locate_elements (ele_name, u%ix_uni, eles, err)
if (err .or. size(eles) == 0) return
Expand All @@ -5061,31 +5065,45 @@ subroutine tao_show_this (what, result_id, lines, nl)
select case (ele%key)
case (group$, overlay$, girder$, ramper$); cycle
end select
if (i > 1) then
nl=nl+1; lines(nl) = ''
endif
nl=nl+1; write (lines(nl), '(4a)') 'Element: ', trim(ele%name), ' ', ele_loc_name(ele, .false., '()')
if (size(lines) < nl+400) call re_allocate(lines, 2*size(lines))

mat6 = ele%mat6
vec0 = ele%vec0
if (n_order == 1) then
mat6 = ele%mat6
vec0 = ele%vec0

if (angle_units) then
call mat6_to_taylor (vec0, mat6, taylor, ref_vec)
call map_to_angle_coords (taylor, taylor)
call taylor_to_mat6 (taylor, ref_vec, vec0, mat6)
endif
if (angle_units) then
call mat6_to_taylor (vec0, mat6, taylor, ref_vec)
call map_to_angle_coords (taylor, taylor)
call taylor_to_mat6 (taylor, ref_vec, vec0, mat6)
endif

if (nl+10 > size(lines)) call re_allocate (lines, 2*nl, .false.)
if (nl+10 > size(lines)) call re_allocate (lines, 2*nl, .false.)

if (fmt /= '') then
fmt2 = '(6' // trim(fmt) // ', a, ' // trim(fmt) // ')'
elseif (any(abs(mat6(1:n_order,1:n_order)) >= 1000)) then
fmt2 = '(6es15.7, a, es15.7)'
else
fmt2 = '(6f15.8, a, es15.7)'
endif
if (fmt /= '') then
fmt2 = '(6' // trim(fmt) // ', a, ' // trim(fmt) // ')'
elseif (any(abs(mat6(1:n_order,1:n_order)) >= 1000)) then
fmt2 = '(6es15.7, a, es15.7)'
else
fmt2 = '(6f15.8, a, es15.7)'
endif

nl=nl+1; lines(nl) = ''
nl=nl+1; write (lines(nl), '(a, f18.9)') ele_full_name(ele), ele%s
do j = 1, 6
nl=nl+1; write(lines(nl), fmt2, iostat = ios) mat6(j,:), ' : ', vec0(j)
enddo
do j = 1, 6
nl=nl+1; write(lines(nl), fmt2, iostat = ios) mat6(j,:), ' : ', vec0(j)
enddo

else ! n_order /= 1
i0 = ele%ix_ele-1
call transfer_map_calc (lat, taylor, err, i0, ele%ix_ele, u%model%tao_branch(ix_branch)%orbit(i0), ele%ix_branch)
call truncate_taylor_to_order (taylor, n_order, taylor)
call type_taylors (taylor, lines = alloc_lines, n_lines = n, out_style = disp_fmt, clean = .true.)
do j = 1, n
nl=nl+1; lines(nl) = alloc_lines(j)
enddo
endif
enddo

else
Expand Down

0 comments on commit 594afcf

Please sign in to comment.