Skip to content

Commit

Permalink
Merge pull request #990 from tpersson/trackClosedOrbitFix
Browse files Browse the repository at this point in the history
The closed orbit search for track
  • Loading branch information
tpersson committed Feb 19, 2021
2 parents 80db043 + 2d36bee commit d19d317
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 400 deletions.
2 changes: 1 addition & 1 deletion src/trrun.f90
Expand Up @@ -3672,7 +3672,7 @@ subroutine trclor(switch,orbit0)
Z(:,k) = ORBIT0
enddo

DDD(1:6) = 1d-15
DDD(1:6) = 1d-10

! How does it work without the code right after? i.e. A will always be singular!
! do k = 1, 6
Expand Down
46 changes: 23 additions & 23 deletions src/twiss.f90
Expand Up @@ -6721,23 +6721,23 @@ SUBROUTINE tmxrot(ftrk,orbit,fmap,ek,re,te)
if (angle .eq. 0) return

angle = angle * node_value('other_bv ')
al_errors(4) = -angle
!al_errors(4) = -angle
!---- Kick.
!ca = cos(angle)
!sa = sin(angle)
!ta = tan(angle)
ca = cos(angle)
sa = sin(angle)
ta = tan(angle)

!ek(4) = sa
ek(4) = sa

call tmali1(orbit,al_errors,beta,gamma,orbit,re)
!call tmali1(orbit,al_errors,beta,gamma,orbit,re)
!---- Transfer matrix.
!re(3,3) = 1/ca
!re(4,4) = ca
!re(4,6) = sa/beta
!re(5,3) = -ta/beta
re(3,3) = 1/ca
re(4,4) = ca
re(4,6) = sa/beta
re(5,3) = -ta/beta

!---- Track orbit.
!if (ftrk) call tmtrak(ek,re,te,orbit,orbit)
if (ftrk) call tmtrak(ek,re,te,orbit,orbit)

end SUBROUTINE tmxrot

Expand Down Expand Up @@ -6770,26 +6770,26 @@ SUBROUTINE tmyrot(ftrk,orbit,fmap,ek,re,te)
!---- Initialize.
angle = node_value('angle ')
if (angle .eq. 0) return
al_errors = 0d0
!al_errors = 0d0
angle = angle * node_value('other_bv ')
al_errors(5) = - angle
call tmali1(orbit,al_errors,beta,gamma,orbit,re)
!al_errors(5) = - angle
!call tmali1(orbit,al_errors,beta,gamma,orbit,re)

!---- Kick.
!ca = cos(angle)
!sa = sin(angle)
!ta = tan(angle)
ca = cos(angle)
sa = sin(angle)
ta = tan(angle)

!ek(2) = sa
ek(2) = sa

!---- Transfer matrix.
!re(1,1) = 1/ca
!re(2,2) = ca
!re(2,6) = sa/beta
!re(5,1) = -ta/beta
re(1,1) = 1/ca
re(2,2) = ca
re(2,6) = sa/beta
re(5,1) = -ta/beta

!---- Track orbit.
!if (ftrk) call tmtrak(ek,re,te,orbit,orbit)
if (ftrk) call tmtrak(ek,re,te,orbit,orbit)

end SUBROUTINE tmyrot

Expand Down
4 changes: 2 additions & 2 deletions tests/test-crabcavity/fodo.ptc
Expand Up @@ -84,8 +84,8 @@
@ PTCOMAX %le 0.0004634515107
@ TITLE %08s "no-title"
@ ORIGIN %16s "5.06.01 Linux 64"
@ DATE %08s "16/02/21"
@ TIME %08s "16.26.31"
@ DATE %08s "19/02/21"
@ TIME %08s "09.37.28"
* NAME S X Y PT T RE11 RE12 RE15 RE25 RE56
$ %s %le %le %le %le %le %le %le %le %le %le
"SEQ$START" 0 0 0 0 -0 1 0 0 0 0
Expand Down
37 changes: 18 additions & 19 deletions tests/test-track-11/test-track-11.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 11:37:17 +
+ Release date: 2020.09.01 +
+ Execution date: 2021.02.18 16:14:49 +
++++++++++++++++++++++++++++++++++++++++++++
! S. Fartoukh March 2012

Expand Down Expand Up @@ -94,7 +94,7 @@ orbit: -5.931563E-09 9.482611E-10 0.000000E+00 0.000000E+00 0.000000E+00 0
26658.8832 -0 0.0003463097584 53.73628458

q1 dq1 betxmax dxmax
62.30999979 2.000072951 19393.4338 2.71665413
62.30999979 1.69243363 19393.4338 2.71665413

dxrms xcomax xcorms q2
1.451766744 1.162795312e-06 1.78592064e-07 60.32000043
Expand Down Expand Up @@ -123,7 +123,7 @@ orbit: -5.931563E-09 9.482611E-10 0.000000E+00 0.000000E+00 0.000000E+00 0
26658.8832 -0 0.0003463097584 53.73628458

q1 dq1 betxmax dxmax
62.30999979 2.000072951 19393.4338 2.71665413
62.30999979 1.69243363 19393.4338 2.71665413

dxrms xcomax xcorms q2
1.451766744 1.162795312e-06 1.78592064e-07 60.32000043
Expand Down Expand Up @@ -151,7 +151,7 @@ orbit: -5.931563E-09 9.482611E-10 0.000000E+00 0.000000E+00 0.000000E+00 0
26658.8832 -0 0.0003463097584 53.73628458

q1 dq1 betxmax dxmax
62.30999979 2.000072951 19393.4338 2.71665413
62.30999979 1.69243363 19393.4338 2.71665413

dxrms xcomax xcorms q2
1.451766744 1.162795312e-06 1.78592064e-07 60.32000043
Expand Down Expand Up @@ -490,25 +490,24 @@ VARIABLE "TAR" SET TO 0.00000000e+00
enter Twiss module

iteration: 1 error: 4.115632E-11 deltap: 0.000000E+00
orbit: 2.292565E-12 2.911529E-14 9.267977E-14 5.983349E-16 4.824161E-10 -4.466269E-12
++++++ warning: TWCPIN: One-turn map R symplectic deviation: 0.129294E-11 (symplectifying R)
orbit: 2.352913E-12 2.758769E-14 2.365867E-14 -6.018094E-16 4.833863E-10 -4.466282E-12

++++++ table: summ

length orbit5 alfa gammatr
26658.8832 -4.824161205e-10 0.0003463029846 53.73681013
26658.8832 -4.833862545e-10 0.0003463034654 53.73677283

q1 dq1 betxmax dxmax
62.30999994 2.000096878 19393.42999 2.716682711
62.31001397 1.691687552 19394.44173 2.716353443

dxrms xcomax xcorms q2
1.451766608 7.748466143e-09 6.5234722e-10 60.3200002
1.451762076 7.748060824e-09 6.523157109e-10 60.3200002

dq2 betymax dymax dyrms
2.000000346 19393.42412 1.139595355e-10 1.97165682e-11
2.000520799 19393.4245 0.01269990184 0.001739781313

ycomax ycorms deltap synch_1
1.4881674e-12 1.827726802e-13 0 0
1.610422082e-12 2.012835233e-13 0 0

synch_2 synch_3 synch_4 synch_5
0 0 0 0
Expand All @@ -518,20 +517,20 @@ orbit: 2.292565E-12 2.911529E-14 9.267977E-14 5.983349E-16 4.824161E-10 -4
enter TRACK module

iteration: 1 error: 4.115632E-11 deltap: 0.000000E+00
orbit: 2.292565E-12 2.911529E-14 9.267977E-14 5.983349E-16 4.824161E-10 -4.466269E-12
orbit: 2.352913E-12 2.758769E-14 2.365867E-14 -6.018094E-16 4.833863E-10 -4.466282E-12

Full 6D closed orbit search.
Initial value of 6-D closed orbit from Twiss:
orbit0 2.292565E-12 2.911529E-14 9.267977E-14 5.983349E-16 4.824161E-10 -4.466269E-12
orbit0 2.352913E-12 2.758769E-14 2.365867E-14 -6.018094E-16 4.833863E-10 -4.466282E-12

6D closed orbit found by subroutine trclor
iteration: 11 error: 5.544470E-13 deltap: 0.000000E+00
orbit: 2.279345E-12 2.913325E-14 2.684429E-19 3.307368E-21 -5.229164E-12 -4.464873E-12
iteration: 11 error: 5.783440E-12 deltap: 0.000000E+00
orbit: 2.384982E-12 3.048379E-14 2.684429E-19 3.307368E-21 -5.225983E-12 -4.671743E-12
exit TRACK module


Number of warnings: 4
0 in C and 4 in Fortran
Number of warnings: 3
0 in C and 3 in Fortran

++++++++++++++++++++++++++++++++++++++++++++
+ MAD-X finished normally +
Expand Down
46 changes: 23 additions & 23 deletions tests/test-track-11/track.obs0001.p0001.ref
@@ -1,29 +1,29 @@
@ NAME %19s "TRACK.OBS0001.P0001"
@ TYPE %08s "TRACKOBS"
@ TITLE %08s "no-title"
@ ORIGIN %16s "5.05.02 Linux 64"
@ DATE %08s "29/07/20"
@ TIME %08s "11.37.47"
@ ORIGIN %16s "5.06.01 Linux 64"
@ DATE %08s "18/02/21"
@ TIME %08s "16.14.59"
* NUMBER TURN X PX Y PY T PT S E
$ %d %d %le %le %le %le %le %le %le %le
1 0 0 0 0 0 0 0 0 7000
1 20 -1.101785281e-17 3.182611229e-19 1.105580085e-30 1.202051119e-32 1.341643882e-15 -5.191881897e-19 0 7000
1 40 -1.682461982e-18 2.622164619e-19 -8.209276388e-32 -5.370786669e-33 2.683611654e-15 -5.237404167e-19 0 7000
1 60 1.510545504e-17 -9.06869923e-20 5.015121575e-31 9.138387123e-33 4.025779603e-15 -1.264161389e-20 0 7000
1 80 1.614592117e-17 -2.527571479e-19 9.389871444e-31 5.069107799e-33 5.367747377e-15 1.013093145e-18 0 7000
1 100 1.24057826e-21 -2.70704814e-23 -7.320459719e-31 -7.508117518e-33 6.70939126e-15 2.554478915e-18 0 7000
1 120 -1.101758905e-17 3.182457213e-19 1.578251441e-30 1.769260057e-32 8.05103513e-15 4.611515714e-18 0 7000
1 140 -1.683499326e-18 2.622318126e-19 -6.754717797e-31 -1.357705379e-32 9.393002878e-15 7.183188463e-18 0 7000
1 160 1.510464597e-17 -9.066714625e-20 7.952646223e-31 1.297106294e-32 1.073517083e-14 1.027152729e-17 0 7000
1 180 1.614601723e-17 -2.527546108e-19 6.300198331e-31 1.108162034e-33 1.207713862e-14 1.387348702e-17 0 7000
1 200 1.81723745e-21 -3.855007996e-23 -5.466270665e-31 -4.667747008e-33 1.341878251e-14 1.799211282e-17 0 7000
1 220 -1.101794342e-17 3.182477978e-19 1.3347176e-30 1.271640385e-32 1.476042637e-14 2.262537458e-17 0 7000
1 240 -1.684119548e-18 2.622442322e-19 -7.338274571e-31 -1.12979113e-32 1.610239411e-14 2.777428736e-17 0 7000
1 260 1.510441294e-17 -9.065604049e-20 1.164898727e-30 1.666456023e-32 1.744456206e-14 3.343885116e-17 0 7000
1 280 1.614709082e-17 -2.527685832e-19 3.01552481e-31 -4.424372657e-33 1.878652987e-14 3.961805091e-17 0 7000
1 300 2.973785388e-21 -6.510725273e-23 -4.15230496e-31 -3.174775143e-34 2.012817377e-14 4.631188662e-17 0 7000
1 320 -1.101809879e-17 3.182404613e-19 1.850818677e-30 1.829332521e-32 2.146981761e-14 5.352137335e-17 0 7000
1 340 7.351241625e-16 9.679736953e-18 -1.156328339e-30 -1.840805345e-32 -8.940331301e-12 -1.388516098e-15 0 7000
1 360 3.132375562e-15 3.975249284e-17 1.550999532e-30 2.305624024e-32 -1.762197243e-11 -6.080835927e-15 0 7000
1 380 6.760789814e-15 8.595327075e-17 2.319301136e-31 -6.703138986e-33 -2.394704811e-11 -1.317093045e-14 0 7000
1 400 1.139221349e-14 1.456084619e-16 -4.100304852e-31 1.152924859e-33 -2.558024029e-11 -2.231915289e-14 0 7000
1 20 -2.155278106e-15 -2.732486059e-17 8.715844112e-30 1.288800721e-31 2.754930808e-11 4.176034302e-15 0 7000
1 40 -1.012714971e-14 -1.297739827e-16 4.406816602e-30 3.432819663e-32 5.812261709e-11 1.980040483e-14 0 7000
1 60 -2.144899218e-14 -2.75050249e-16 2.825387377e-30 6.04305659e-32 5.592619464e-11 4.204514811e-14 0 7000
1 80 -3.466610514e-14 -4.437768015e-16 9.573990347e-30 1.086397521e-31 7.808153489e-11 6.785660164e-14 0 7000
1 100 -5.197341479e-14 -6.64293735e-16 -1.850337194e-31 -7.37646215e-34 9.45260535e-11 1.018125831e-13 0 7000
1 120 -7.079192695e-14 -9.045982259e-16 8.520217777e-30 1.228777159e-31 9.459945676e-11 1.386211704e-13 0 7000
1 140 -8.936252126e-14 -1.142513991e-15 3.569614855e-30 2.553023267e-32 9.33447925e-11 1.750097043e-13 0 7000
1 160 -1.062954509e-13 -1.35950792e-15 2.641509215e-30 5.589372195e-32 7.517374987e-11 2.082195902e-13 0 7000
1 180 -1.209295047e-13 -1.546345008e-15 8.633606903e-30 9.612195982e-32 7.307155256e-11 2.368335672e-13 0 7000
1 200 -1.338726349e-13 -1.711081551e-15 -4.321305313e-31 -3.484729493e-33 6.48392037e-11 2.622038911e-13 0 7000
1 220 -1.433393337e-13 -1.831856623e-15 8.135176233e-30 1.155900271e-31 3.182491084e-11 2.807569904e-13 0 7000
1 240 -1.485906778e-13 -1.899533534e-15 3.00810998e-30 1.887862735e-32 2.249544096e-11 2.910401344e-13 0 7000
1 260 -1.510708038e-13 -1.931800198e-15 2.787735446e-30 5.776209969e-32 -5.838840084e-12 2.959867057e-13 0 7000
1 280 -1.482481369e-13 -1.895515756e-15 8.415880523e-30 9.209330558e-32 -2.256943684e-11 2.903383384e-13 0 7000
1 300 -1.427710272e-13 -1.824815602e-15 -3.62748905e-31 -1.408336272e-33 -4.306883111e-11 2.796591838e-13 0 7000
1 320 -1.329673223e-13 -1.699287645e-15 8.405961984e-30 1.178138743e-31 -5.839480368e-11 2.604200201e-13 0 7000
1 340 -1.194583616e-13 -1.527181298e-15 3.071713817e-30 1.943270837e-32 -7.884692427e-11 2.340389317e-13 0 7000
1 360 -1.019312716e-13 -1.303727503e-15 3.062324908e-30 6.142023811e-32 -9.999755643e-11 1.996658974e-13 0 7000
1 380 -8.108510699e-14 -1.037077333e-15 8.670969944e-30 9.606591225e-32 -1.039997475e-10 1.587742768e-13 0 7000
1 400 -6.109851648e-14 -7.80925505e-16 -7.949275845e-32 2.527030736e-33 -1.045253982e-10 1.196885073e-13 0 7000
18 changes: 9 additions & 9 deletions tests/test-track-7/test-track-7.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:23:29 +
+ Release date: 2020.09.01 +
+ Execution date: 2021.02.19 09:42:12 +
++++++++++++++++++++++++++++++++++++++++++++
!---|----1----|----2----|----3----|----4----|----5----|----6----|----7----|---;

Expand Down Expand Up @@ -133,17 +133,17 @@ orbit: 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0
1 0 0 0
2 0 0 0
3 0 0 0
1 320 3.781780568e-06 -4.14812231e-08
2 320 9.500959415e-06 1.275619779e-07
3 320 9.62741281e-06 1.250160678e-07
1 320 3.781780607e-06 -4.148122341e-08
2 320 9.500959422e-06 1.275619777e-07
3 320 9.627412807e-06 1.250160678e-07

y py t pt
0 0 0 0.0001
0 0 0 0.001002
0 0 0 0.001004
7.796518987e-23 -2.496980464e-25 -1.17510595 0.0009885395086
5.537209581e-22 1.509461394e-23 -3.189567287 0.001245397097
5.984002006e-22 4.193783518e-23 -3.194475798 0.001255311453
3.341702526e-23 2.011303518e-23 -1.175105945 0.0009885395136
1.497367757e-22 -7.468598628e-23 -3.189567288 0.001245397098
1.023512812e-21 1.012955956e-22 -3.194475798 0.001255311453

s e
0 0
Expand Down

0 comments on commit d19d317

Please sign in to comment.