Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for lost particle in PTC #972

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/manylinux.yml
Expand Up @@ -88,7 +88,7 @@ jobs:

- name: Install runtime dependencies
run: |
sudo apt-get update \
sudo apt-get update
sudo apt-get install -qy gnuplot

- name: Run tests
Expand Down
41 changes: 34 additions & 7 deletions src/madx_ptc_track_run.f90
Expand Up @@ -1913,13 +1913,18 @@ SUBROUTINE track_beam_elementwise_with_PTC ! int.subroutine


! save coordinates for the current particle ---!

if (getdebug() > 3) then
print*, "Saving X for j_th_partic = ", j_th_partic
endif

do k_th_coord=1,6
if (ISNAN(current_x_coord_incl_co(k_th_coord))) then
! BUG !? Aperture does not work, if lattice with spread multipoles XXXX + ! !
NaN_coord_after_track_VK=.TRUE.
x_coord_incl_co(k_th_coord,j_th_partic)=999
else
x_coord_incl_co(k_th_coord,j_th_partic)= &
x_coord_incl_co(k_th_coord,j_th_partic)= &
current_x_coord_incl_co(k_th_coord)
endif
end do
Expand Down Expand Up @@ -2242,7 +2247,12 @@ SUBROUTINE Final_Coord_to_tables ! Complete all tables by one subroutine:
last_turn_of_lost_particle(particle_ID(j_part_tmp))= turn_final !
last_position_of_lost_particle(particle_ID(j_part_tmp))= sum_length
! remember last turn and position of particles

last_orbit_of_lost_particle(:, particle_ID(j_part_tmp))= x_coord_incl_co(:, j_part_tmp)

if (ptc_track_debug) then
print*, "j_part_tmp ", j_part_tmp, " id ", particle_ID(j_part_tmp), " coord ", x_coord_incl_co(:, j_part_tmp)
endif
! !
enddo

Expand Down Expand Up @@ -2343,9 +2353,17 @@ SUBROUTINE Final_Coord_to_tables ! Complete all tables by one subroutine:
ENDDO !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>! !
! !
CALL Coord_PTC_to_MAD(X_PTC,X_MAD) !
! !
!
if (ptc_track_debug) then
print*, "putting in tracksumm part no ", j_part_tmp
endif !
DO i_coord = 1, 6 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>! !
doublenum = X_MAD(i_coord) ! !
doublenum = X_MAD(i_coord)
! !
if (ptc_track_debug) then
print*, " coord ", i_coord, " = ", doublenum
endif

call double_to_table_curr('tracksumm ', vec_names(i_coord), doublenum) ! !
!call double_to_table_curr('tracksumm ', vec_names(j), tmp_d) ! !
! ! !
Expand Down Expand Up @@ -3727,14 +3745,16 @@ SUBROUTINE kill_ptc_track (n_particle, &

last_position_of(np)=sum_accum_length
! Save Position of n_particle

last_orbit_of(:,np) = x_coord_incl_co(:,np)
if(getdebug() > 3) then
print*,"kill_ptc_track, n_particle=",n_particle," np=",np, " x = ", x_coord_incl_co(:,n_particle)
endif
last_orbit_of(:,np) = x_coord_incl_co(:,n_particle)

if (recloss) then
namelen = LEN_TRIM(el_name)
if (namelen > name_len) namelen = name_len
madx_name = el_name(1:namelen)
call tp_ploss(np,i_th_turn, sum_accum_length, x_coord_incl_co(:,np), madx_name, en)
call tp_ploss(np,i_th_turn, sum_accum_length, x_coord_incl_co(:,n_particle), madx_name, en)
endif

! Renumbering arrays
Expand All @@ -3748,7 +3768,14 @@ SUBROUTINE kill_ptc_track (n_particle, &
END IF

enddo



if(getdebug() > 3) then
do j_th=1,j_max
print*,"kill_ptc_track, part_ID(",j_th,")",part_ID(j_th)
enddo
endif

j_max = j_max - 1

END SUBROUTINE kill_ptc_track
Expand Down
14 changes: 7 additions & 7 deletions tests/test-ptc-track-2/test-ptc-track-2.ref
@@ -1,9 +1,9 @@

++++++++++++++++++++++++++++++++++++++++++++
+ MAD-X 5.05.02 (64 bit, Linux) +
+ MAD-X 5.06.01 (64 bit, Linux) +
+ Support: mad@cern.ch, http://cern.ch/mad +
+ Release date: 2019.07.25 +
+ Execution date: 2020.07.29 16:35:20 +
+ Release date: 2020.09.01 +
+ Execution date: 2021.01.08 17:21:07 +
++++++++++++++++++++++++++++++++++++++++++++
!TITLE,' Example 1 for for MAD-X with PTC_TRACK_RUN';

Expand Down Expand Up @@ -144,8 +144,8 @@ ptc_track,icase=56,element_by_element, turns=10, file="tfv9", recloss ;
1 10 0.0002252020254 -1.111922841e-05
2 10 3.234489974e-05 -2.017208596e-06
3 1 0.0001 0
4 1 0.001229979172 6.360301388e-05
5 1 0.001178855988 6.095440089e-05
4 1 0.01000609926 0.0005239391492
5 1 0.01009694549 0.0001422990216
6 10 0.009370093381 0.0001176678106

y py t pt
Expand All @@ -158,8 +158,8 @@ ptc_track,icase=56,element_by_element, turns=10, file="tfv9", recloss ;
-0.00311135335 3.238436512e-05 -1.897391847e-05 0
-0.001097781795 1.132710343e-05 1.047619194e-06 0
0 0 2 0.02
0 0 8.054090825e-06 0.0024
0 0 7.720682552e-06 0.0023
0 0 0.05006345122 0.02
0 0 -0.0001838485114 0.0024
0.0004919324094 1.388568373e-05 -0.004391133034 0.0023

s e
Expand Down
10 changes: 5 additions & 5 deletions tests/test-ptc-track-2/tfv9recloss.tfs.ref
@@ -1,11 +1,11 @@
@ NAME %09s "TRACKLOSS"
@ TYPE %09s "TRACKLOSS"
@ TITLE %08s "no-title"
@ ORIGIN %16s "5.05.02 Linux 64"
@ DATE %08s "29/07/20"
@ TIME %08s "16.35.20"
@ ORIGIN %16s "5.06.01 Linux 64"
@ DATE %08s "08/01/21"
@ TIME %08s "17.19.54"
* NUMBER TURN X PX Y PY T PT S E ELEMENT
$ %d %d %le %le %le %le %le %le %le %le %s
3 1 0.0001 0 0 0 -2 0.02 0 100 "FIVECELL$START"
4 1 0.001229979172 6.360301388e-05 0 0 -8.054090825e-06 0.0024 73.18000769 100 "MB"
5 1 0.001178855988 6.095440089e-05 0 0 -7.720682552e-06 0.0023 211.4200077 100 "MB"
4 1 0.01000609926 0.0005239391492 0 0 -0.05006345122 0.02 73.18000769 100 "MB"
5 1 0.01009694549 0.0001422990216 0 0 0.0001838485114 0.0024 211.4200077 100 "MB"