From b3c0bf08a664d0869c813659f42494f979fe0664 Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Wed, 15 Jun 2022 15:52:17 -0400 Subject: [PATCH 1/9] Fix first order transfer map for a drift computed by TWISS when EXACT=true --- src/twiss.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/twiss.f90 b/src/twiss.f90 index c0a1fc66a..49761fa25 100644 --- a/src/twiss.f90 +++ b/src/twiss.f90 @@ -7180,12 +7180,12 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) re(1,2) = dl/sqrt(csq) + dl*px**2/c3sq re(1,4) = dl*px*py/c3sq re(1,6) = dl*px*(-pt - 1d0/beta)/c3sq - re(3,2) = dl*px*py/c3sq + re(3,2) = re(1,4) re(3,4) = dl/sqrt(csq) + dl*py**2/c3sq re(3,6) = dl*py*(-pt - 1d0/beta)/c3sq - re(5,2) = -dl*px*(beta + pt)/c3sq - re(5,4) = -dl*py*(beta + pt)/c3sq - re(5,6) = -dl/sqrt(csq) - dl*(beta + pt)*(-pt - 1d0/beta)/c3sq + re(5,2) = re(1,6) + re(5,4) = re(3,6) + re(5,6) = dl*((beta*gamma)**(-2)+px**2+py**2)/c3sq if (fsec) then te(1,2,2) = 3d0*dl*px/(2d0*c3sq) + 3d0*dl*px**3d0/(2d0*c52sq) From 4123357e12ccaf0872670e09d0ee984ad3e0e4c7 Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Fri, 17 Jun 2022 15:25:07 -0400 Subject: [PATCH 2/9] Define some intermediate values for the twiss exact drift case Simplifies the code and makes it easier to get things right --- src/twiss.f90 | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/twiss.f90 b/src/twiss.f90 index 49761fa25..c94142313 100644 --- a/src/twiss.f90 +++ b/src/twiss.f90 @@ -7160,6 +7160,7 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) double precision :: dl double precision :: orbit(6), ek(6), re(6,6), te(6,6,6) double precision :: px, py, pt, csq, l_pz, c3sq, c52sq + real(kind(1d0)) :: beti, dl3, dl5, pp2, ptb, ptot2, px2, py2, pz1i, pz3i, pz5i !---- Initialize. EK = zero @@ -7171,21 +7172,33 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) px = orbit(2) py = orbit(4) pt = orbit(6) + px2 = px*px + py2 = py*py + + beti = 1/beta + ptb = beti + pt + ptot2 = 1 + pt*(2*beti + pt) + pp2 = (beta*gamma)**(-2)+px2+py2 + csq = ptot2 - px2 - py2 + pz1i = 1.0 / sqrt(csq) + pz3i = pz1i / csq + pz5i = pz3i / csq + dl3 = dl*pz3i + dl5 = dl*pz5i - csq = 1 + 2*pt/beta + pt**2 - px**2 - py**2 l_pz = dl / sqrt(csq) c3sq = csq**(3d0/2d0) c52sq =csq**(5d0/2d0) - re(1,2) = dl/sqrt(csq) + dl*px**2/c3sq - re(1,4) = dl*px*py/c3sq - re(1,6) = dl*px*(-pt - 1d0/beta)/c3sq + re(1,2) = dl3*(ptot2 - py2) + re(1,4) = dl3*px*py + re(1,6) = -dl3*px*ptb re(3,2) = re(1,4) - re(3,4) = dl/sqrt(csq) + dl*py**2/c3sq - re(3,6) = dl*py*(-pt - 1d0/beta)/c3sq + re(3,4) = dl3*(ptot2 - px2) + re(3,6) = -dl3*py*ptb re(5,2) = re(1,6) re(5,4) = re(3,6) - re(5,6) = dl*((beta*gamma)**(-2)+px**2+py**2)/c3sq + re(5,6) = dl3*pp2 if (fsec) then te(1,2,2) = 3d0*dl*px/(2d0*c3sq) + 3d0*dl*px**3d0/(2d0*c52sq) From 6481e68955f15b2e0afbf1623f604c075640a378 Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Fri, 17 Jun 2022 15:56:23 -0400 Subject: [PATCH 3/9] Fix errors in third order for exact drift in twiss. Also simplified the code. --- src/twiss.f90 | 61 ++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/src/twiss.f90 b/src/twiss.f90 index c94142313..cf0516720 100644 --- a/src/twiss.f90 +++ b/src/twiss.f90 @@ -7159,7 +7159,7 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) logical :: fsec, ftrk, fmap double precision :: dl double precision :: orbit(6), ek(6), re(6,6), te(6,6,6) - double precision :: px, py, pt, csq, l_pz, c3sq, c52sq + double precision :: px, py, pt, csq, l_pz real(kind(1d0)) :: beti, dl3, dl5, pp2, ptb, ptot2, px2, py2, pz1i, pz3i, pz5i !---- Initialize. @@ -7184,11 +7184,8 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) pz3i = pz1i / csq pz5i = pz3i / csq dl3 = dl*pz3i - dl5 = dl*pz5i l_pz = dl / sqrt(csq) - c3sq = csq**(3d0/2d0) - c52sq =csq**(5d0/2d0) re(1,2) = dl3*(ptot2 - py2) re(1,4) = dl3*px*py @@ -7201,34 +7198,34 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) re(5,6) = dl3*pp2 if (fsec) then - te(1,2,2) = 3d0*dl*px/(2d0*c3sq) + 3d0*dl*px**3d0/(2d0*c52sq) - te(1,2,4) = dl*py/(2d0*c3sq) + 3d0*dl*px**2d0*py/(2d0*c52sq) - te(1,2,6) = dl*(-pt - 1d0/beta)/(2d0*c3sq) + dl*px**2d0*(-3d0*pt - 3d0/beta)/(2d0*c52sq) - te(1,4,2) = dl*py/(2d0*c3sq) + 3d0*dl*px**2d0*py/(2d0*c52sq) - te(1,4,4) = dl*px/(2d0*c3sq) + 3d0*dl*px*py**2d0/(2d0*c52sq) - te(1,4,6) = dl*px*py*(-3d0*pt - 3d0/beta)/(2d0*c52sq) - te(1,6,2) = dl*(-pt - 1d0/beta)/(2d0*c3sq) + 3d0*dl*px**2d0*(-pt - 1d0/beta)/(2d0*c52sq) - te(1,6,4) = 3d0*dl*px*py*(-pt - 1d0/beta)/(2d0*c52sq) - te(1,6,6) = -dl*px/(2d0*c3sq) + dl*px*(-3d0*pt - 3d0/beta)*(-pt - 1d0/beta)/(2d0*c52sq) - te(3,2,2) = dl*py/(2d0*c3sq) + 3d0*dl*px**2d0*py/(2d0*c52sq) - te(3,2,4) = dl*px/(2d0*c3sq) + 3d0*dl*px*py**2d0/(2d0*c52sq) - te(3,2,6) = dl*px*py*(-3d0*pt - 3d0/beta)/(2d0*c52sq) - te(3,4,2) = dl*px/(2d0*c3sq) + 3d0*dl*px*py**2d0/(2d0*c52sq) - te(3,4,4) = 3d0*dl*py/(2d0*c3sq) + 3d0*dl*py**3d0/(2d0*c52sq) - te(3,4,6) = dl*(-pt - 1d0/beta)/(2d0*c3sq) + dl*py**2d0*(-3d0*pt - 3d0/beta)/(2d0*c52sq) - te(3,6,2) = 3d0*dl*px*py*(-pt - 1d0/beta)/(2d0*c52sq) - te(3,6,4) = dl*(-pt - 1d0/beta)/(2d0*c3sq) + 3d0*dl*py**2d0*(-pt - 1d0/beta)/(2d0*c52sq) - te(3,6,6) = -dl*py/(2d0*c3sq) + dl*py*(-3d0*pt - 3d0/beta)*(-pt - 1d0/beta)/(2d0*c52sq) - te(5,2,2) = -dl*(beta + pt)/(2d0*c3sq) - 3d0*dl*px**2d0*(beta + pt)/(2d0*c52sq) - te(5,2,4) = -3d0*dl*px*py*(beta + pt)/(2d0*c52sq) - te(5,2,6) = -dl*px/(2d0*c3sq) - dl*px*(beta + pt)*(-3d0*pt - 3d0/beta)/(2d0*c52sq) - te(5,4,2) = -3d0*dl*px*py*(beta + pt)/(2d0*c52sq) - te(5,4,4) = -dl*(beta + pt)/(2d0*c3sq) - 3d0*dl*py**2d0*(beta + pt)/(2d0*c52sq) - te(5,4,6) = -dl*py/(2d0*c3sq) - dl*py*(beta + pt)*(-3d0*pt - 3d0/beta)/(2d0*c52sq) - te(5,6,2) = -dl*px/(2d0*c3sq) - 3d0*dl*px*(beta + pt)*(-pt - 1d0/beta)/(2d0*c52sq) - te(5,6,4) = -dl*py/(2d0*c3sq) - 3d0*dl*py*(beta + pt)*(-pt - 1d0/beta)/(2d0*c52sq) - te(5,6,6) = dl*(beta + pt)/(2d0*c3sq) - dl*(-pt - 1d0/beta)/c3sq - & - dl*(beta + pt)*(-3d0*pt - 3d0/beta)*(-pt - 1d0/beta)/(2d0*c52sq) + dl5 = 0.5d0*dl*pz5i + te(1,2,2) = 3*dl5*px*(ptot2 - py2) + te(1,2,4) = dl5*py*(ptot2 + 2*px2 - py2) + te(1,2,6) = -dl5*ptb*(ptot2 + 2*px2 - py2) + te(1,4,2) = te(1,2,4) + te(1,4,4) = dl5*px*(ptot2 - px2 + 2*py2) + te(1,4,6) = -3*dl5*px*py*ptb + te(1,6,2) = te(1,2,6) + te(1,6,4) = te(1,4,6) + te(1,6,6) = dl5*px*(2*ptb*ptb + pp2) + te(3,2,2) = te(1,2,4) + te(3,2,4) = te(1,4,4) + te(3,2,6) = te(1,4,6) + te(3,4,2) = te(3,2,4) + te(3,4,4) = 3*dl5*py*(ptot2 - px2) + te(3,4,6) = -dl5*ptb*(ptot2 - px2 + 2*py2) + te(3,6,2) = te(3,2,6) + te(3,6,4) = te(3,4,6) + te(3,6,6) = dl5*py*(2*ptb*ptb + pp2) + te(5,2,2) = te(1,2,6) + te(5,2,4) = te(1,4,6) + te(5,2,6) = te(1,6,6) + te(5,4,2) = te(5,2,4) + te(5,4,4) = te(3,4,6) + te(5,4,6) = te(3,6,6) + te(5,6,2) = te(5,2,6) + te(5,6,4) = te(5,4,6) + te(5,6,6) = -3*dl5*pp2*ptb endif orbit(1) = orbit(1) + px*l_pz From 5d38fa2a1bee8a9788bde37de276fadf8b37105d Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Fri, 17 Jun 2022 16:29:05 -0400 Subject: [PATCH 4/9] Simplification of the intermediate variables --- src/twiss.f90 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/twiss.f90 b/src/twiss.f90 index cf0516720..3713bdd24 100644 --- a/src/twiss.f90 +++ b/src/twiss.f90 @@ -7160,7 +7160,7 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) double precision :: dl double precision :: orbit(6), ek(6), re(6,6), te(6,6,6) double precision :: px, py, pt, csq, l_pz - real(kind(1d0)) :: beti, dl3, dl5, pp2, ptb, ptot2, px2, py2, pz1i, pz3i, pz5i + real(kind(1d0)) :: beti, dl3, dl5, pp2, ptb, ptot2, px2, py2, pz !---- Initialize. EK = zero @@ -7180,12 +7180,10 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) ptot2 = 1 + pt*(2*beti + pt) pp2 = (beta*gamma)**(-2)+px2+py2 csq = ptot2 - px2 - py2 - pz1i = 1.0 / sqrt(csq) - pz3i = pz1i / csq - pz5i = pz3i / csq - dl3 = dl*pz3i + pz = sqrt(csq) + l_pz = dl / pz + dl3 = l_pz / csq - l_pz = dl / sqrt(csq) re(1,2) = dl3*(ptot2 - py2) re(1,4) = dl3*px*py @@ -7198,7 +7196,7 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) re(5,6) = dl3*pp2 if (fsec) then - dl5 = 0.5d0*dl*pz5i + dl5 = 0.5d0*dl3/csq te(1,2,2) = 3*dl5*px*(ptot2 - py2) te(1,2,4) = dl5*py*(ptot2 + 2*px2 - py2) te(1,2,6) = -dl5*ptb*(ptot2 + 2*px2 - py2) From 3d10a8e78d29dd4c874a0f6ad43f58e94f81cf41 Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Fri, 17 Jun 2022 16:29:44 -0400 Subject: [PATCH 5/9] Rewrite formula for time in exact drift for better numerical precision --- src/twiss.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/twiss.f90 b/src/twiss.f90 index 3713bdd24..65841611d 100644 --- a/src/twiss.f90 +++ b/src/twiss.f90 @@ -7228,7 +7228,7 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) orbit(1) = orbit(1) + px*l_pz orbit(3) = orbit(3) + py*l_pz - orbit(5) = orbit(5) + (dl/beta - (1d0/beta + pt) * l_pz) + orbit(5) = orbit(5) + l_pz*(pt*(2*beti+pt)/(gamma*gamma) - px2 - py2)/(beta*beta*(ptb + beti*pz)) else re(1,2) = dl From 7d7fabdfc871c80a06e8463ac103ea344579f9e3 Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Tue, 21 Jun 2022 13:50:10 -0400 Subject: [PATCH 6/9] Add test case for an exact drift to second order --- Makefile_test | 4 +- .../test-twiss-16/test-twiss-16-mad3.tfs.cfg | 3 + .../test-twiss-16/test-twiss-16-mad3.tfs.ref | 11 ++ tests/test-twiss-16/test-twiss-16-ptc.tfs.cfg | 4 + tests/test-twiss-16/test-twiss-16-ptc.tfs.ref | 93 +++++++++ .../test-twiss-16/test-twiss-16-ptc3.tfs.cfg | 3 + .../test-twiss-16/test-twiss-16-ptc3.tfs.ref | 11 ++ .../test-twiss-16/test-twiss-16-twiss.tfs.cfg | 4 + .../test-twiss-16/test-twiss-16-twiss.tfs.ref | 55 ++++++ tests/test-twiss-16/test-twiss-16.cfg | 3 + tests/test-twiss-16/test-twiss-16.madx | 97 ++++++++++ tests/test-twiss-16/test-twiss-16.ref | 180 ++++++++++++++++++ 12 files changed, 467 insertions(+), 1 deletion(-) create mode 100644 tests/test-twiss-16/test-twiss-16-mad3.tfs.cfg create mode 100644 tests/test-twiss-16/test-twiss-16-mad3.tfs.ref create mode 100644 tests/test-twiss-16/test-twiss-16-ptc.tfs.cfg create mode 100644 tests/test-twiss-16/test-twiss-16-ptc.tfs.ref create mode 100644 tests/test-twiss-16/test-twiss-16-ptc3.tfs.cfg create mode 100644 tests/test-twiss-16/test-twiss-16-ptc3.tfs.ref create mode 100644 tests/test-twiss-16/test-twiss-16-twiss.tfs.cfg create mode 100644 tests/test-twiss-16/test-twiss-16-twiss.tfs.ref create mode 100644 tests/test-twiss-16/test-twiss-16.cfg create mode 100644 tests/test-twiss-16/test-twiss-16.madx create mode 100644 tests/test-twiss-16/test-twiss-16.ref diff --git a/Makefile_test b/Makefile_test index 686853a8c..8e7df7e07 100644 --- a/Makefile_test +++ b/Makefile_test @@ -30,6 +30,8 @@ # added test-twiss-12 for sigma matrix calculation # 2021-Sep-02 20:59:00 ghislain: # added test-taper +# 2022-Jun-21 jsberg-bnl: +# added test-twiss-16 for exact TWISS drift compared to PTC ################################################# # testsuite @@ -55,7 +57,7 @@ test-track-7 test-track-8 test-track-9 test-track-10 test-track-11 test-track-12 test-track-acd test-track-rotations test-beambeam-npart \ test-twiss test-twiss-2 test-twiss-3 test-twiss-4 test-twiss-5 \ test-twiss-6 test-twiss-8 test-twiss-9 test-twiss-10 test-twiss-11 \ -test-twiss-12 test-twiss-13 test-twiss-14 test-twiss-15 test-twiss-exact test-translation test-crabcavity \ +test-twiss-12 test-twiss-13 test-twiss-14 test-twiss-15 test-twiss-16 test-twiss-exact test-translation test-crabcavity \ test-xrotation test-yrotation test-rotations test-interpolate test-rf-fringe \ test-cororbit test-cororbit-2 test-cororbit-3 test-cororbit-4 \ test-emit test-emit-2 \ diff --git a/tests/test-twiss-16/test-twiss-16-mad3.tfs.cfg b/tests/test-twiss-16/test-twiss-16-mad3.tfs.cfg new file mode 100644 index 000000000..4cf7d1212 --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16-mad3.tfs.cfg @@ -0,0 +1,3 @@ +1-9 * skip +10 * rel=1e-14 +11-$ * skip diff --git a/tests/test-twiss-16/test-twiss-16-mad3.tfs.ref b/tests/test-twiss-16/test-twiss-16-mad3.tfs.ref new file mode 100644 index 000000000..b30b8db83 --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16-mad3.tfs.ref @@ -0,0 +1,11 @@ +@ NAME %04s "MAD3" +@ TYPE %09s "SECTORMAP" +@ TITLE %08s "no-title" +@ ORIGIN %16s "5.08.01 Linux 64" +@ DATE %08s "21/06/22" +@ TIME %08s "13.30.36" +* NAME T122 T124 T126 T144 T146 T166 T322 T324 T326 T344 T346 T366 T522 T524 T526 T544 T546 T566 +$ %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le + "L$START" 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 + "O" 7.95552195596275907e-02 3.44810984420141561e-02 -2.95832272960501763e+00 2.65296302746198774e-02 -1.19954398173697098e-03 7.63998146067667028e-02 3.44810984420141561e-02 2.65296302746198774e-02 -1.19954398173697098e-03 1.03429206342507532e-01 -2.95895941064147783e+00 9.93197589887966914e-02 -2.95832272960501763e+00 -1.19954398173697098e-03 7.63998146067667028e-02 -2.95895941064147783e+00 9.93197589887966914e-02 -2.60638736213083666e+00 + "L$END" 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 diff --git a/tests/test-twiss-16/test-twiss-16-ptc.tfs.cfg b/tests/test-twiss-16/test-twiss-16-ptc.tfs.cfg new file mode 100644 index 000000000..246fb3e1f --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16-ptc.tfs.cfg @@ -0,0 +1,4 @@ +1-91 * skip +92 2-8 rel=1e-14 +92 10-18 rel=1e-14 +93-$ * skip diff --git a/tests/test-twiss-16/test-twiss-16-ptc.tfs.ref b/tests/test-twiss-16/test-twiss-16-ptc.tfs.ref new file mode 100644 index 000000000..fd5603462 --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16-ptc.tfs.ref @@ -0,0 +1,93 @@ +@ NAME %09s "PTC_TWISS" +@ TYPE %05s "TWISS" +@ SEQUENCE %01s "L" +@ PARTICLE %06s "PROTON" +@ MASS %le 9.38272088159999962e-01 +@ CHARGE %le 1.00000000000000000e+00 +@ ENERGY %le 2.00000000000000000e+00 +@ PC %le 1.76625181912995433e+00 +@ GAMMA %le 2.13157784957890328e+00 +@ KBUNCH %le 1.00000000000000000e+00 +@ BCURRENT %le 7.49214795614770220e-12 +@ SIGE %le 1.00000000000000002e-03 +@ SIGT %le 1.00000000000000000e+00 +@ NPART %le 1.00000000000000000e+00 +@ EX %le 1.00000000000000000e+00 +@ EY %le 1.00000000000000000e+00 +@ ET %le 1.00000000000000002e-03 +@ DELTAP %le 0.00000000000000000e+00 +@ LENGTH %le 5.00000000000000000e+00 +@ ALPHA_C %le -1.00000000000000000e+06 +@ ALPHA_C_P %le -1.00000000000000000e+06 +@ ALPHA_C_P2 %le -1.00000000000000000e+06 +@ ALPHA_C_P3 %le -1.00000000000000000e+06 +@ ETA_C %le -1.00000000000000000e+06 +@ GAMMA_TR %le -1.00000000000000000e+06 +@ Q1 %le 2.18662318680467038e-01 +@ Q2 %le 2.18664509460172629e-01 +@ DQ1 %le -1.00000000000000000e+06 +@ DQ2 %le -1.00000000000000000e+06 +@ QS %le -1.00000000000000000e+06 +@ BETA_X_MIN %le 9.97668990890940632e-01 +@ BETA_X_MAX %le 2.60683049153817414e+01 +@ BETA_Y_MIN %le 9.97668990890940632e-01 +@ BETA_Y_MAX %le 2.60719028755598323e+01 +@ BETA11MIN %le 9.97668990890940632e-01 +@ BETA11MAX %le 2.60683048258232652e+01 +@ BETA12MIN %le 0.00000000000000000e+00 +@ BETA12MAX %le 4.58189068032043954e-07 +@ BETA13MIN %le 0.00000000000000000e+00 +@ BETA13MAX %le 3.49033090966918268e-03 +@ BETA21MIN %le 0.00000000000000000e+00 +@ BETA21MAX %le 4.58189068032043954e-07 +@ BETA22MIN %le 9.97668990890940632e-01 +@ BETA22MAX %le 2.60719027859889927e+01 +@ BETA23MIN %le 0.00000000000000000e+00 +@ BETA23MAX %le 5.89865923734092003e-03 +@ BETA31MIN %le 0.00000000000000000e+00 +@ BETA31MAX %le 3.37266836437332459e-03 +@ BETA32MIN %le 0.00000000000000000e+00 +@ BETA32MAX %le 5.69980953579091783e-03 +@ BETA33MIN %le 9.64036571539015785e-01 +@ BETA33MAX %le 3.20267140640042713e+00 +@ DISP1MIN %le -5.96572604168680853e-02 +@ DISP1MAX %le 0.00000000000000000e+00 +@ DISP2MIN %le 0.00000000000000000e+00 +@ DISP2MAX %le 0.00000000000000000e+00 +@ DISP3MIN %le -7.75544385419285193e-02 +@ DISP3MAX %le 0.00000000000000000e+00 +@ DISP4MIN %le 0.00000000000000000e+00 +@ DISP4MAX %le 0.00000000000000000e+00 +@ ORBIT_X %le 0.00000000000000000e+00 +@ ORBIT_PX %le 1.00000000000000002e-02 +@ ORBIT_Y %le 0.00000000000000000e+00 +@ ORBIT_PY %le 1.29999999999999994e-02 +@ ORBIT_PT %le -1.70000000000000012e-02 +@ ORBIT_T %le 0.00000000000000000e+00 +@ XCORMS %le 4.16337111554961822e-02 +@ PXCORMS %le 1.00000000000000002e-02 +@ YCORMS %le 5.41238245021450348e-02 +@ PYCORMS %le 1.29999999999999994e-02 +@ TCORMS %le 2.08157583830212087e-02 +@ PTCORMS %le 1.70000000000000012e-02 +@ XCOMIN %le 0.00000000000000000e+00 +@ XCOMAX %le 5.09906742146927355e-02 +@ PXCOMIN %le 1.00000000000000002e-02 +@ PXCOMAX %le 1.00000000000000002e-02 +@ YCOMIN %le 0.00000000000000000e+00 +@ YCOMAX %le 6.62878764791005604e-02 +@ PYCOMIN %le 1.29999999999999994e-02 +@ PYCOMAX %le 1.29999999999999994e-02 +@ TCOMIN %le -2.54939933237317007e-02 +@ TCOMAX %le -0.00000000000000000e+00 +@ PTCOMIN %le -1.70000000000000012e-02 +@ PTCOMAX %le -1.70000000000000012e-02 +@ TITLE %08s "no-title" +@ ORIGIN %16s "5.08.01 Linux 64" +@ DATE %08s "21/06/22" +@ TIME %08s "13.30.36" +* NAME KEYWORD S X PX Y PY T PT DISP1 DISP2 RE12 RE14 RE16 RE32 RE34 RE36 RE52 RE54 RE56 +$ %s %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le + "L$START" "MARKER" 0.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000002e-02 0.00000000000000000e+00 1.29999999999999994e-02 -0.00000000000000000e+00 -1.70000000000000012e-02 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 + "O" "DRIFT" 5.00000000000000000e+00 5.09906742146927355e-02 1.00000000000000002e-02 6.62878764791005604e-02 1.29999999999999994e-02 -2.54939933237317007e-02 -1.70000000000000012e-02 -5.96572604168680853e-02 0.00000000000000000e+00 5.09959773444608544e+00 6.89406869855017164e-04 -5.91480000693044086e-02 6.89406869855017164e-04 5.09996365040008470e+00 -7.68924000900957361e-02 -5.91480000693044086e-02 -7.68924000900957222e-02 1.49795370600283739e+00 + "L$END" "MARKER" 5.00000000000000000e+00 5.09906742146927355e-02 1.00000000000000002e-02 6.62878764791005604e-02 1.29999999999999994e-02 -2.54939933237317007e-02 -1.70000000000000012e-02 -5.96572604168680853e-02 0.00000000000000000e+00 5.09959773444608544e+00 6.89406869855017164e-04 -5.91480000693044086e-02 6.89406869855017164e-04 5.09996365040008470e+00 -7.68924000900957361e-02 -5.91480000693044086e-02 -7.68924000900957222e-02 1.49795370600283739e+00 diff --git a/tests/test-twiss-16/test-twiss-16-ptc3.tfs.cfg b/tests/test-twiss-16/test-twiss-16-ptc3.tfs.cfg new file mode 100644 index 000000000..4cf7d1212 --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16-ptc3.tfs.cfg @@ -0,0 +1,3 @@ +1-9 * skip +10 * rel=1e-14 +11-$ * skip diff --git a/tests/test-twiss-16/test-twiss-16-ptc3.tfs.ref b/tests/test-twiss-16/test-twiss-16-ptc3.tfs.ref new file mode 100644 index 000000000..11304188b --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16-ptc3.tfs.ref @@ -0,0 +1,11 @@ +@ NAME %04s "PTC3" +@ TYPE %04s "USER" +@ TITLE %08s "no-title" +@ ORIGIN %16s "5.08.01 Linux 64" +@ DATE %08s "21/06/22" +@ TIME %08s "13.30.36" +* NAME TXPP TXPQ TXPD TXQQ TXQD TXDD TYPP TYPQ TYPD TYQQ TYQD TYDD TTPP TTPQ TTPD TTQQ TTQD TTDD +$ %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le + "L$START" 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 -0.00000000000000000e+00 -0.00000000000000000e+00 -0.00000000000000000e+00 -0.00000000000000000e+00 -0.00000000000000000e+00 -0.00000000000000000e+00 + "O" 7.95552195596276046e-02 6.89621968840283123e-02 -5.91664545921003615e+00 2.65296302746198809e-02 -2.39908796347394282e-03 7.63998146067667305e-02 3.44810984420141631e-02 5.30592605492397548e-02 -2.39908796347394282e-03 1.03429206342507546e-01 -5.91791882128295654e+00 9.93197589887967469e-02 -2.95832272960501808e+00 -2.39908796347394282e-03 1.52799629213533406e-01 -2.95895941064147827e+00 1.98639517977593438e-01 -2.60638736213083977e+00 + "L$END" 7.95552195596276046e-02 6.89621968840283123e-02 -5.91664545921003615e+00 2.65296302746198809e-02 -2.39908796347394282e-03 7.63998146067667305e-02 3.44810984420141631e-02 5.30592605492397548e-02 -2.39908796347394282e-03 1.03429206342507546e-01 -5.91791882128295654e+00 9.93197589887967469e-02 -2.95832272960501808e+00 -2.39908796347394282e-03 1.52799629213533406e-01 -2.95895941064147827e+00 1.98639517977593438e-01 -2.60638736213083977e+00 diff --git a/tests/test-twiss-16/test-twiss-16-twiss.tfs.cfg b/tests/test-twiss-16/test-twiss-16-twiss.tfs.cfg new file mode 100644 index 000000000..7acb0f869 --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16-twiss.tfs.cfg @@ -0,0 +1,4 @@ +1-53 * skip +54 2-8 rel=1e-14 +54 10-18 rel=1e-14 +55-$ * skip diff --git a/tests/test-twiss-16/test-twiss-16-twiss.tfs.ref b/tests/test-twiss-16/test-twiss-16-twiss.tfs.ref new file mode 100644 index 000000000..bb3b92c96 --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16-twiss.tfs.ref @@ -0,0 +1,55 @@ +@ NAME %05s "TWISS" +@ TYPE %05s "TWISS" +@ SEQUENCE %01s "L" +@ PARTICLE %06s "PROTON" +@ MASS %le 9.38272088159999962e-01 +@ CHARGE %le 1.00000000000000000e+00 +@ ENERGY %le 2.00000000000000000e+00 +@ PC %le 1.76625181912995433e+00 +@ GAMMA %le 2.13157784957890328e+00 +@ KBUNCH %le 1.00000000000000000e+00 +@ BCURRENT %le 7.49214795614770220e-12 +@ SIGE %le 1.00000000000000002e-03 +@ SIGT %le 1.00000000000000000e+00 +@ NPART %le 1.00000000000000000e+00 +@ EX %le 1.00000000000000000e+00 +@ EY %le 1.00000000000000000e+00 +@ ET %le 1.00000000000000002e-03 +@ BV_FLAG %le 1.00000000000000000e+00 +@ LENGTH %le 5.00000000000000000e+00 +@ ALFA %le 0.00000000000000000e+00 +@ ORBIT5 %le -0.00000000000000000e+00 +@ GAMMATR %le 0.00000000000000000e+00 +@ Q1 %le 2.19181732237913984e-01 +@ Q2 %le 2.19183888556179401e-01 +@ DQ1 %le 0.00000000000000000e+00 +@ DQ2 %le 0.00000000000000000e+00 +@ DXMAX %le 5.91480000693044017e-02 +@ DYMAX %le 7.68924000900957222e-02 +@ XCOMAX %le 5.09906742146927355e-02 +@ YCOMAX %le 6.62878764791005465e-02 +@ BETXMAX %le 2.70058970531676366e+01 +@ BETYMAX %le 2.70096292354021585e+01 +@ XCORMS %le 4.16337111554961822e-02 +@ YCORMS %le 5.41238245021450279e-02 +@ DXRMS %le 4.82941398252999463e-02 +@ DYRMS %le 6.27823817728899308e-02 +@ DELTAP %le 0.00000000000000000e+00 +@ SYNCH_1 %le 0.00000000000000000e+00 +@ SYNCH_2 %le 0.00000000000000000e+00 +@ SYNCH_3 %le 0.00000000000000000e+00 +@ SYNCH_4 %le 0.00000000000000000e+00 +@ SYNCH_5 %le 0.00000000000000000e+00 +@ SYNCH_6 %le 0.00000000000000000e+00 +@ SYNCH_8 %le 0.00000000000000000e+00 +@ DQMIN %le 0.00000000000000000e+00 +@ DQMIN_PHASE %le 0.00000000000000000e+00 +@ TITLE %08s "no-title" +@ ORIGIN %16s "5.08.01 Linux 64" +@ DATE %08s "21/06/22" +@ TIME %08s "13.30.36" +* NAME KEYWORD S X PX Y PY T PT DX DPX RE12 RE14 RE16 RE32 RE34 RE36 RE52 RE54 RE56 +$ %s %s %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le %le + "L$START" "MARKER" 0.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000002e-02 0.00000000000000000e+00 1.29999999999999994e-02 0.00000000000000000e+00 -1.70000000000000012e-02 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 + "O" "DRIFT" 5.00000000000000000e+00 5.09906742146927355e-02 1.00000000000000002e-02 6.62878764791005465e-02 1.29999999999999994e-02 -2.54939933237324154e-02 -1.70000000000000012e-02 -5.91480000693044017e-02 0.00000000000000000e+00 5.09959773444608455e+00 6.89406869855017164e-04 -5.91480000693044017e-02 6.89406869855017164e-04 5.09996365040008470e+00 -7.68924000900957222e-02 -5.91480000693044017e-02 -7.68924000900957222e-02 1.49795370600283695e+00 + "L$END" "MARKER" 5.00000000000000000e+00 5.09906742146927355e-02 1.00000000000000002e-02 6.62878764791005465e-02 1.29999999999999994e-02 -2.54939933237324154e-02 -1.70000000000000012e-02 -5.91480000693044017e-02 0.00000000000000000e+00 5.09959773444608455e+00 6.89406869855017164e-04 -5.91480000693044017e-02 6.89406869855017164e-04 5.09996365040008470e+00 -7.68924000900957222e-02 -5.91480000693044017e-02 -7.68924000900957222e-02 1.49795370600283695e+00 diff --git a/tests/test-twiss-16/test-twiss-16.cfg b/tests/test-twiss-16/test-twiss-16.cfg new file mode 100644 index 000000000..cbb0bb2f2 --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16.cfg @@ -0,0 +1,3 @@ +1-90 * skip +91-129 * abs=1e-14 +130-$ * skip diff --git a/tests/test-twiss-16/test-twiss-16.madx b/tests/test-twiss-16/test-twiss-16.madx new file mode 100644 index 000000000..74c8cee3b --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16.madx @@ -0,0 +1,97 @@ +option, -echo; +set, format="10d", "25.17e", "-24s"; + +lo = 5; +o: drift, l=lo; +l: line=(o); + +px0=+0.01; +py0=+0.013; +pt0=-0.017; + +beam, energy=2, particle=proton; + +select, flag=twiss, column=name,keyword,s,x,px,y,py,t,pt,dx,dpx,re12,re14,re16,re32,re34,re36,re52,re54,re56; +select, flag=ptc_twiss, column=name,keyword,s,x,px,y,py,t,pt,disp1,disp2,re12,re14,re16,re32,re34,re36,re52,re54,re56; + +use, sequence=l; + +select, flag=mad3, column=name, + t122,t124,t126,t144,t146,t166, + t322,t324,t326,t344,t346,t366, + t522,t524,t526,t544,t546,t566; +twiss, exact, rmatrix, sectormap, sectortable=mad3, sectorfile='test-twiss-16-mad3.tfs', + betx=1, bety=1, px=px0, py=py0, pt=pt0, file='test-twiss-16-twiss.tfs'; + +create, table=ptc3, column=_name, + txpp,txpq,txpd,txqq,txqd,txdd, + typp,typq,typd,tyqq,tyqd,tydd, + ttpp,ttpq,ttpd,ttqq,ttqd,ttdd; +ptc_select, table=ptc3, column=txpp, polynomial=1, monomial='020000'; +ptc_select, table=ptc3, column=txpq, polynomial=1, monomial='010100'; +ptc_select, table=ptc3, column=txpd, polynomial=1, monomial='010001'; +ptc_select, table=ptc3, column=txqq, polynomial=1, monomial='000200'; +ptc_select, table=ptc3, column=txqd, polynomial=1, monomial='000101'; +ptc_select, table=ptc3, column=txdd, polynomial=1, monomial='000002'; +ptc_select, table=ptc3, column=typp, polynomial=3, monomial='020000'; +ptc_select, table=ptc3, column=typq, polynomial=3, monomial='010100'; +ptc_select, table=ptc3, column=typd, polynomial=3, monomial='010001'; +ptc_select, table=ptc3, column=tyqq, polynomial=3, monomial='000200'; +ptc_select, table=ptc3, column=tyqd, polynomial=3, monomial='000101'; +ptc_select, table=ptc3, column=tydd, polynomial=3, monomial='000002'; +ptc_select, table=ptc3, column=ttpp, polynomial=5, monomial='020000'; +ptc_select, table=ptc3, column=ttpq, polynomial=5, monomial='010100'; +ptc_select, table=ptc3, column=ttpd, polynomial=5, monomial='010001'; +ptc_select, table=ptc3, column=ttqq, polynomial=5, monomial='000200'; +ptc_select, table=ptc3, column=ttqd, polynomial=5, monomial='000101'; +ptc_select, table=ptc3, column=ttdd, polynomial=5, monomial='000002'; + + +ptc_create_universe; +ptc_create_layout, exact, model=2, method=6, nst=5; +ptc_twiss, rmatrix, no=2, betx=1, bety=1, betz=1, px=px0, py=py0, pt=pt0, icase=56, no=5, file='test-twiss-16-ptc.tfs'; +ptc_end; + +write, table=ptc3, file='test-twiss-16-ptc3.tfs'; + +value, table(twiss,o,x) - table(ptc_twiss,o,x); +value, table(twiss,o,y) - table(ptc_twiss,o,y); +value, table(twiss,o,t) - table(ptc_twiss,o,t); + +value, table(twiss,o,re12) - table(ptc_twiss,o,re12); +value, table(twiss,o,re14) - table(ptc_twiss,o,re14); +value, table(twiss,o,re16) - table(ptc_twiss,o,re16); +value, table(twiss,o,re32) - table(ptc_twiss,o,re32); +value, table(twiss,o,re34) - table(ptc_twiss,o,re34); +value, table(twiss,o,re36) - table(ptc_twiss,o,re36); +value, table(twiss,o,re52) - table(ptc_twiss,o,re52); +value, table(twiss,o,re54) - table(ptc_twiss,o,re54); +value, table(twiss,o,re56) - table(ptc_twiss,o,re56); + +value, table(ptc3,o,txpp) - table(mad3,o,t122); +value, 0.5*table(ptc3,o,txpq) - table(mad3,o,t124); +value, 0.5*table(ptc3,o,txpd) - table(mad3,o,t126); +value, 0.5*table(ptc3,o,txpq) - table(mad3,o,t142); +value, table(ptc3,o,txqq) - table(mad3,o,t144); +value, 0.5*table(ptc3,o,txqd) - table(mad3,o,t146); +value, 0.5*table(ptc3,o,txpd) - table(mad3,o,t162); +value, 0.5*table(ptc3,o,txqd) - table(mad3,o,t164); +value, table(ptc3,o,txdd) - table(mad3,o,t166); +value, table(ptc3,o,typp) - table(mad3,o,t322); +value, 0.5*table(ptc3,o,typq) - table(mad3,o,t324); +value, 0.5*table(ptc3,o,typd) - table(mad3,o,t326); +value, 0.5*table(ptc3,o,typq) - table(mad3,o,t342); +value, table(ptc3,o,tyqq) - table(mad3,o,t344); +value, 0.5*table(ptc3,o,tyqd) - table(mad3,o,t346); +value, 0.5*table(ptc3,o,typd) - table(mad3,o,t362); +value, 0.5*table(ptc3,o,tyqd) - table(mad3,o,t364); +value, table(ptc3,o,tydd) - table(mad3,o,t366); +value, table(ptc3,o,ttpp) - table(mad3,o,t522); +value, 0.5*table(ptc3,o,ttpq) - table(mad3,o,t524); +value, 0.5*table(ptc3,o,ttpd) - table(mad3,o,t526); +value, 0.5*table(ptc3,o,ttpq) - table(mad3,o,t542); +value, table(ptc3,o,ttqq) - table(mad3,o,t544); +value, 0.5*table(ptc3,o,ttqd) - table(mad3,o,t546); +value, 0.5*table(ptc3,o,ttpd) - table(mad3,o,t562); +value, 0.5*table(ptc3,o,ttqd) - table(mad3,o,t564); +value, table(ptc3,o,ttdd) - table(mad3,o,t566); diff --git a/tests/test-twiss-16/test-twiss-16.ref b/tests/test-twiss-16/test-twiss-16.ref new file mode 100644 index 000000000..285a41ba7 --- /dev/null +++ b/tests/test-twiss-16/test-twiss-16.ref @@ -0,0 +1,180 @@ + + ++++++++++++++++++++++++++++++++++++++++++++ + + MAD-X 5.08.01 (64 bit, Linux) + + + Support: mad@cern.ch, http://cern.ch/mad + + + Release date: 2022.02.25 + + + Execution date: 2022.06.21 13:30:36 + + ++++++++++++++++++++++++++++++++++++++++++++ +option, -echo; + +enter Twiss module + Found 3 initial orbit vector values from twiss command. + +++++++ table: summ + + length orbit5 alfa gammatr + 5.00000000000000000e+00 -0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 + + q1 dq1 betxmax dxmax + 2.19181732237913984e-01 0.00000000000000000e+00 2.70058970531676366e+01 5.91480000693044017e-02 + + dxrms xcomax xcorms q2 + 4.82941398252999463e-02 5.09906742146927355e-02 4.16337111554961822e-02 2.19183888556179401e-01 + + dq2 betymax dymax dyrms + 0.00000000000000000e+00 2.70096292354021585e+01 7.68924000900957222e-02 6.27823817728899308e-02 + + ycomax ycorms deltap synch_1 + 6.62878764791005465e-02 5.41238245021450279e-02 0.00000000000000000e+00 0.00000000000000000e+00 + + synch_2 synch_3 synch_4 synch_5 + 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 + + synch_6 synch_8 nflips dqmin + 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 + + dqmin_phase + 0.00000000000000000e+00 + +++++++ table: ptc_twiss_summary + + length alpha_c alpha_c_p alpha_c_p2 + 5.00000000000000000e+00 -1.00000000000000000e+06 -1.00000000000000000e+06 -1.00000000000000000e+06 + + alpha_c_p3 eta_c gamma_tr q1 + -1.00000000000000000e+06 -1.00000000000000000e+06 -1.00000000000000000e+06 2.18662318680467038e-01 + + q2 dq1 dq2 qs + 2.18664509460172629e-01 -1.00000000000000000e+06 -1.00000000000000000e+06 -1.00000000000000000e+06 + + beta_x_min beta_x_max beta_y_min beta_y_max + 9.97668990890940632e-01 2.60683049153817414e+01 9.97668990890940632e-01 2.60719028755598323e+01 + + beta11min beta11max beta12min beta12max + 9.97668990890940632e-01 2.60683048258232652e+01 0.00000000000000000e+00 4.58189068032043954e-07 + + beta13min beta13max beta21min beta21max + 0.00000000000000000e+00 3.49033090966918268e-03 0.00000000000000000e+00 4.58189068032043954e-07 + + beta22min beta22max beta23min beta23max + 9.97668990890940632e-01 2.60719027859889927e+01 0.00000000000000000e+00 5.89865923734092003e-03 + + beta31min beta31max beta32min beta32max + 0.00000000000000000e+00 3.37266836437332459e-03 0.00000000000000000e+00 5.69980953579091783e-03 + + beta33min beta33max disp1min disp1max + 9.64036571539015785e-01 3.20267140640042713e+00 -5.96572604168680853e-02 0.00000000000000000e+00 + + disp2min disp2max disp3min disp3max + 0.00000000000000000e+00 0.00000000000000000e+00 -7.75544385419285193e-02 0.00000000000000000e+00 + + disp4min disp4max deltap orbit_x + 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00 + + orbit_px orbit_y orbit_py orbit_pt + 1.00000000000000002e-02 0.00000000000000000e+00 1.29999999999999994e-02 -1.70000000000000012e-02 + + orbit_t xcorms ycorms pxcorms + 0.00000000000000000e+00 4.16337111554961822e-02 5.41238245021450348e-02 1.00000000000000002e-02 + + pycorms tcorms ptcorms xcomax + 1.29999999999999994e-02 2.08157583830212087e-02 1.70000000000000012e-02 5.09906742146927355e-02 + + ycomax pxcomax pycomax tcomax + 6.62878764791005604e-02 1.00000000000000002e-02 1.29999999999999994e-02 -0.00000000000000000e+00 + + ptcomax xcomin ycomin pxcomin + -1.70000000000000012e-02 0.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000002e-02 + + pycomin tcomin ptcomin + 1.29999999999999994e-02 -2.54939933237317007e-02 -1.70000000000000012e-02 +table( twiss o x )-table( ptc_twiss o x ) = 0.00000000000000000e+00 ; +table( twiss o y )-table( ptc_twiss o y ) = -1.38777878078144568e-17 ; +table( twiss o t )-table( ptc_twiss o t ) = -7.14706072102444523e-16 ; +table( twiss o re12 )-table( ptc_twiss o re12 ) = -8.88178419700125232e-16 ; +table( twiss o re14 )-table( ptc_twiss o re14 ) = 0.00000000000000000e+00 ; +table( twiss o re16 )-table( ptc_twiss o re16 ) = 6.93889390390722838e-18 ; +table( twiss o re32 )-table( ptc_twiss o re32 ) = 0.00000000000000000e+00 ; +table( twiss o re34 )-table( ptc_twiss o re34 ) = 0.00000000000000000e+00 ; +table( twiss o re36 )-table( ptc_twiss o re36 ) = 1.38777878078144568e-17 ; +table( twiss o re52 )-table( ptc_twiss o re52 ) = 6.93889390390722838e-18 ; +table( twiss o re54 )-table( ptc_twiss o re54 ) = 0.00000000000000000e+00 ; +table( twiss o re56 )-table( ptc_twiss o re56 ) = -4.44089209850062616e-16 ; +table( ptc3 o txpp )-table( mad3 o t122 ) = 1.38777878078144568e-17 ; +0.5*table( ptc3 o txpq )-table( mad3 o t124 ) = 0.00000000000000000e+00 ; +0.5*table( ptc3 o txpd )-table( mad3 o t126 ) = -4.44089209850062616e-16 ; +0.5*table( ptc3 o txpq )-table( mad3 o t142 ) = 0.00000000000000000e+00 ; +table( ptc3 o txqq )-table( mad3 o t144 ) = 3.46944695195361419e-18 ; +0.5*table( ptc3 o txqd )-table( mad3 o t146 ) = -4.33680868994201774e-19 ; +0.5*table( ptc3 o txpd )-table( mad3 o t162 ) = -4.44089209850062616e-16 ; +0.5*table( ptc3 o txqd )-table( mad3 o t164 ) = -4.33680868994201774e-19 ; +table( ptc3 o txdd )-table( mad3 o t166 ) = 2.77555756156289135e-17 ; +table( ptc3 o typp )-table( mad3 o t322 ) = 6.93889390390722838e-18 ; +0.5*table( ptc3 o typq )-table( mad3 o t324 ) = 0.00000000000000000e+00 ; +0.5*table( ptc3 o typd )-table( mad3 o t326 ) = -4.33680868994201774e-19 ; +0.5*table( ptc3 o typq )-table( mad3 o t342 ) = 0.00000000000000000e+00 ; +table( ptc3 o tyqq )-table( mad3 o t344 ) = 1.38777878078144568e-17 ; +0.5*table( ptc3 o tyqd )-table( mad3 o t346 ) = -4.44089209850062616e-16 ; +0.5*table( ptc3 o typd )-table( mad3 o t362 ) = -4.33680868994201774e-19 ; +0.5*table( ptc3 o tyqd )-table( mad3 o t364 ) = -4.44089209850062616e-16 ; +table( ptc3 o tydd )-table( mad3 o t366 ) = 5.55111512312578270e-17 ; +table( ptc3 o ttpp )-table( mad3 o t522 ) = -4.44089209850062616e-16 ; +0.5*table( ptc3 o ttpq )-table( mad3 o t524 ) = -4.33680868994201774e-19 ; +0.5*table( ptc3 o ttpd )-table( mad3 o t526 ) = 0.00000000000000000e+00 ; +0.5*table( ptc3 o ttpq )-table( mad3 o t542 ) = -4.33680868994201774e-19 ; +table( ptc3 o ttqq )-table( mad3 o t544 ) = -4.44089209850062616e-16 ; +0.5*table( ptc3 o ttqd )-table( mad3 o t546 ) = 2.77555756156289135e-17 ; +0.5*table( ptc3 o ttpd )-table( mad3 o t562 ) = 0.00000000000000000e+00 ; +0.5*table( ptc3 o ttqd )-table( mad3 o t564 ) = 2.77555756156289135e-17 ; +table( ptc3 o ttdd )-table( mad3 o t566 ) = -3.10862446895043831e-15 ; + + Number of warnings: 0 + + ++++++++++++++++++++++++++++++++++++++++++++ + + MAD-X finished normally + + ++++++++++++++++++++++++++++++++++++++++++++ + +open line - error with deltap: 0.000000E+00 +initial orbit vector: 0.000000E+00 1.000000E-02 0.000000E+00 1.300000E-02 0.000000E+00 -1.700000E-02 +final orbit vector: 5.099067E-02 1.000000E-02 6.628788E-02 1.300000E-02 -2.549399E-02 -1.700000E-02 +Determined SECTOR NMUL MAX : 0 + MAD-X Beam Parameters + Energy : 0.200000E+01 + Kinetic Energy : 0.106173E+01 + Particle Rest Mass : 0.938272E+00 + Momentum : 0.176625E+01 + Setting MADx with + energy 2.0000000000000000 + method 6 + Num. of steps 5 + charge 1.0000000000000000 + Length of machine: 5.0000000000000000 + The machine is a RING + ------------------------------------ PTC Survey ------------------------------------ + Before start: 0.0000000000000000 0.0000000000000000 0.0000000000000000 + Before end: 0.0000000000000000 0.0000000000000000 0.0000000000000000 + After start: 0.0000000000000000 0.0000000000000000 0.0000000000000000 + After end: 0.0000000000000000 0.0000000000000000 5.0000000000000000 + ************ State Summary **************** + MADTHICK=>KIND = 37 MATRIX-KICK-MATRIX + Rectangular Bend: input arc length (rho alpha) + Default integration method 6 + Default integration steps 5 + This is a proton + EXACT_MODEL = TRUE + TOTALPATH = 0 + RADIATION = FALSE + STOCHASTIC = FALSE + ENVELOPE = FALSE + NOCAVITY = TRUE + TIME = TRUE + FRINGE = FALSE + PARA_IN = FALSE + ONLY_2D = FALSE + ONLY_4D = FALSE + DELTA = FALSE + SPIN = FALSE + MODULATION = FALSE + RAMPING = FALSE + ACCELERATE = FALSE + Reduced SUMM Table (Inital parameters specified) From 693518f9b280e3963f95283bbcbc964fec29592a Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Wed, 22 Jun 2022 08:55:47 -0400 Subject: [PATCH 7/9] Fix reference for test-twiss-16 main output --- tests/test-twiss-16/test-twiss-16.cfg | 6 +- tests/test-twiss-16/test-twiss-16.ref | 92 +++++++++++++-------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/tests/test-twiss-16/test-twiss-16.cfg b/tests/test-twiss-16/test-twiss-16.cfg index cbb0bb2f2..168ceff67 100644 --- a/tests/test-twiss-16/test-twiss-16.cfg +++ b/tests/test-twiss-16/test-twiss-16.cfg @@ -1,3 +1,3 @@ -1-90 * skip -91-129 * abs=1e-14 -130-$ * skip +1-135 * skip +136-174 * abs=1e-14 +175-$ * skip diff --git a/tests/test-twiss-16/test-twiss-16.ref b/tests/test-twiss-16/test-twiss-16.ref index 285a41ba7..119bb76eb 100644 --- a/tests/test-twiss-16/test-twiss-16.ref +++ b/tests/test-twiss-16/test-twiss-16.ref @@ -3,12 +3,16 @@ + MAD-X 5.08.01 (64 bit, Linux) + + Support: mad@cern.ch, http://cern.ch/mad + + Release date: 2022.02.25 + - + Execution date: 2022.06.21 13:30:36 + + + Execution date: 2022.06.22 08:51:56 + ++++++++++++++++++++++++++++++++++++++++++++ option, -echo; enter Twiss module Found 3 initial orbit vector values from twiss command. + +open line - error with deltap: 0.000000E+00 +initial orbit vector: 0.000000E+00 1.000000E-02 0.000000E+00 1.300000E-02 0.000000E+00 -1.700000E-02 +final orbit vector: 5.099067E-02 1.000000E-02 6.628788E-02 1.300000E-02 -2.549399E-02 -1.700000E-02 ++++++ table: summ @@ -35,6 +39,47 @@ enter Twiss module dqmin_phase 0.00000000000000000e+00 +Determined SECTOR NMUL MAX : 0 + MAD-X Beam Parameters + Energy : 0.200000E+01 + Kinetic Energy : 0.106173E+01 + Particle Rest Mass : 0.938272E+00 + Momentum : 0.176625E+01 + Setting MADx with + energy 2.0000000000000000 + method 6 + Num. of steps 5 + charge 1.0000000000000000 + Length of machine: 5.0000000000000000 + The machine is a RING + ------------------------------------ PTC Survey ------------------------------------ + Before start: 0.0000000000000000 0.0000000000000000 0.0000000000000000 + Before end: 0.0000000000000000 0.0000000000000000 0.0000000000000000 + After start: 0.0000000000000000 0.0000000000000000 0.0000000000000000 + After end: 0.0000000000000000 0.0000000000000000 5.0000000000000000 + ************ State Summary **************** + MADTHICK=>KIND = 37 MATRIX-KICK-MATRIX + Rectangular Bend: input arc length (rho alpha) + Default integration method 6 + Default integration steps 5 + This is a proton + EXACT_MODEL = TRUE + TOTALPATH = 0 + RADIATION = FALSE + STOCHASTIC = FALSE + ENVELOPE = FALSE + NOCAVITY = TRUE + TIME = TRUE + FRINGE = FALSE + PARA_IN = FALSE + ONLY_2D = FALSE + ONLY_4D = FALSE + DELTA = FALSE + SPIN = FALSE + MODULATION = FALSE + RAMPING = FALSE + ACCELERATE = FALSE + Reduced SUMM Table (Inital parameters specified) ++++++ table: ptc_twiss_summary @@ -133,48 +178,3 @@ table( ptc3 o ttdd )-table( mad3 o t566 ) = -3.10862446895043831e-15 ; ++++++++++++++++++++++++++++++++++++++++++++ + MAD-X finished normally + ++++++++++++++++++++++++++++++++++++++++++++ - -open line - error with deltap: 0.000000E+00 -initial orbit vector: 0.000000E+00 1.000000E-02 0.000000E+00 1.300000E-02 0.000000E+00 -1.700000E-02 -final orbit vector: 5.099067E-02 1.000000E-02 6.628788E-02 1.300000E-02 -2.549399E-02 -1.700000E-02 -Determined SECTOR NMUL MAX : 0 - MAD-X Beam Parameters - Energy : 0.200000E+01 - Kinetic Energy : 0.106173E+01 - Particle Rest Mass : 0.938272E+00 - Momentum : 0.176625E+01 - Setting MADx with - energy 2.0000000000000000 - method 6 - Num. of steps 5 - charge 1.0000000000000000 - Length of machine: 5.0000000000000000 - The machine is a RING - ------------------------------------ PTC Survey ------------------------------------ - Before start: 0.0000000000000000 0.0000000000000000 0.0000000000000000 - Before end: 0.0000000000000000 0.0000000000000000 0.0000000000000000 - After start: 0.0000000000000000 0.0000000000000000 0.0000000000000000 - After end: 0.0000000000000000 0.0000000000000000 5.0000000000000000 - ************ State Summary **************** - MADTHICK=>KIND = 37 MATRIX-KICK-MATRIX - Rectangular Bend: input arc length (rho alpha) - Default integration method 6 - Default integration steps 5 - This is a proton - EXACT_MODEL = TRUE - TOTALPATH = 0 - RADIATION = FALSE - STOCHASTIC = FALSE - ENVELOPE = FALSE - NOCAVITY = TRUE - TIME = TRUE - FRINGE = FALSE - PARA_IN = FALSE - ONLY_2D = FALSE - ONLY_4D = FALSE - DELTA = FALSE - SPIN = FALSE - MODULATION = FALSE - RAMPING = FALSE - ACCELERATE = FALSE - Reduced SUMM Table (Inital parameters specified) From e4d7d90eff47d8f1ca50a7ab9e3a84dc5acd93d8 Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Wed, 22 Jun 2022 13:05:41 -0400 Subject: [PATCH 8/9] Add code to handle nonzero DELTAP for EXACT flag to TWISS --- src/twiss.f90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/twiss.f90 b/src/twiss.f90 index 65841611d..245d806ac 100644 --- a/src/twiss.f90 +++ b/src/twiss.f90 @@ -7226,9 +7226,12 @@ SUBROUTINE tmdrf(fsec,ftrk,orbit,fmap,dl,ek,re,te) te(5,6,6) = -3*dl5*pp2*ptb endif - orbit(1) = orbit(1) + px*l_pz - orbit(3) = orbit(3) + py*l_pz - orbit(5) = orbit(5) + l_pz*(pt*(2*beti+pt)/(gamma*gamma) - px2 - py2)/(beta*beta*(ptb + beti*pz)) + ek(1) = px*l_pz + ek(3) = py*l_pz + ek(5) = dl*dtbyds + l_pz*(pt*(2*beti+pt)/(gamma*gamma) - px2 - py2)/(beta*beta*(ptb + beti*pz)) + + if (ftrk) orbit(1:5:2) = orbit(1:5:2) + ek(1:5:2) + else re(1,2) = dl From ebace2d4d3433ebf4fce24b481ab70c2a83673fd Mon Sep 17 00:00:00 2001 From: "J. Scott Berg" Date: Wed, 22 Jun 2022 13:06:48 -0400 Subject: [PATCH 9/9] Add line to Changes.md for fix to EXACT flag to TWISS --- Changes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index 0076072a5..551eec1e9 100644 --- a/Changes.md +++ b/Changes.md @@ -1,5 +1,6 @@ MAD-X master -* [PR 1081](https://github.com/MethodicalAcceleratorDesign/MAD-X/pull/1108) Fix potential buffer overrun when node_name calls stoupper (S. Berg) +* (https://github.com/MethodicalAcceleratorDesign/MAD-X/pull/1123) Fix errors in the time variable with EXACT flag to TWISS (J. S. Berg) +* [PR 1081](https://github.com/MethodicalAcceleratorDesign/MAD-X/pull/1108) Fix potential buffer overrun when node_name calls stoupper (J. S. Berg) * [PR 1107](https://github.com/MethodicalAcceleratorDesign/MAD-X/pull/1107) Stabizes few tests due to compiler dependent numerical noise (R. De Maria) * [PR 1095](https://github.com/MethodicalAcceleratorDesign/MAD-X/pull/1095) Implement more robust, optional, PTC DA map output (L. Deniau) * [PR 1088](https://github.com/MethodicalAcceleratorDesign/MAD-X/pull/1088) Additional explanation bv flag (J. Dilly)