@@ -909,8 +909,6 @@ function M.quad_kick (elm, m, lw, ii) -- [KICKTKT7] --
909
909
if ii <= 0 then drift_adj(elm, m, ii == 0 and l/2 or l) end
910
910
end
911
911
912
- M.quad_kick_ysh = \elm, m, lw -> M.quad_kick(elm, m, lw, 0)
913
-
914
912
-- skew (tilted by k1s)
915
913
916
914
function M.quad_thicks (elm, m, lw) -- [PUSHTKT7] -- checked
@@ -983,8 +981,6 @@ function M.quad_kicks (elm, m, lw, ii) -- [KICKTKT7] --
983
981
if ii <= 0 then drift_adj(elm, m, ii == 0 and l/2 or l) end
984
982
end
985
983
986
- M.quad_kicks_ysh = \elm, m, lw -> M.quad_kicks(elm, m, lw, 0)
987
-
988
984
-- curved (eh ~= 0)
989
985
990
986
function M.quad_thickh_new (elm, m, lw) -- [PUSHTKT7] -- unchecked
@@ -1207,8 +1203,6 @@ function M.quad_kickh (elm, m, lw, ii) -- [KICKTKT7] --
1207
1203
if ii <= 0 then drift_adj(elm, m, ii == 0 and l/2 or l) end
1208
1204
end
1209
1205
1210
- M.quad_kickh_ysh = \elm, m, lw -> M.quad_kickh(elm, m, lw, 0)
1211
-
1212
1206
-- DKD, TKT [INTER_SOL5] ------------------------------------------------------o
1213
1207
1214
1208
function M.solen_thick (elm, m, lw) -- [KICK_SOL] -- checked
@@ -1556,7 +1550,7 @@ FRINGE_TEAPOT:
1556
1550
FACE, FRINGE_DIPOLE, MULTIPOLE_FRINGE, FRINGE2QUAD
1557
1551
1558
1552
FRINGE_DIPOLE[BEND_FRINGE=TRUE]
1559
- FRINGE2QUAD[PERMFRINGE=2.or.3 ]
1553
+ FRINGE2QUAD[PERMFRINGE=2]
1560
1554
MULTIPOLE_FRINGE[PERMFRINGE=1.or.3]
1561
1555
1562
1556
NEWFACE[EXACT] / FACE[.not.EXACT]
@@ -1649,7 +1643,7 @@ function M.curex_fringe (elm, m, lw_) -- [FRINGE_TEAPOT] --
1649
1643
if sdir*lw == 1 then
1650
1644
-- print(lw == 1 and 'forward entry' or 'backward exit')
1651
1645
yrotation (-e, m, 1)
1652
- bend_face ( h, m )
1646
+ bend_face ( h, m, 1 )
1653
1647
if m.frng ~= 0 then
1654
1648
if ftst(m.frng, fringe.bend) then bend_fringe(elm, m, 1) end
1655
1649
if ftst(m.frng, fringe.mult) then mult_fringe(elm, m, 1) end
@@ -1666,7 +1660,7 @@ function M.curex_fringe (elm, m, lw_) -- [FRINGE_TEAPOT] --
1666
1660
if ftst(m.frng, fringe.mult) then mult_fringe(elm, m, -1) end
1667
1661
if ftst(m.frng, fringe.bend) then bend_fringe(elm, m, -1) end
1668
1662
end
1669
- bend_face ( h, m )
1663
+ bend_face ( h, m, -1 )
1670
1664
yrotation ( e, m, -1)
1671
1665
end
1672
1666
@@ -1735,40 +1729,42 @@ end
1735
1729
1736
1730
-- fringes helpers ------------------------------------------------------------o
1737
1731
1738
- function bend_face (h, m) -- [NEWFACE] -- checked
1732
+ function bend_face (h, m, lw ) -- [NEWFACE] -- checked
1739
1733
if h == 0 then return end
1740
1734
local el, eld, knl in m
1741
1735
if abs(el) < minlen or abs(knl[1]) < minstr then return end
1742
1736
1743
- m.atdebug(h, m, 'bend_face:0')
1737
+ m.atdebug(h, m, lw, 'bend_face:0')
1744
1738
1745
- local edir, tdir, beam in m
1746
- local k0h = 0.5*h * knl[1]/(eld or el)*edir
1739
+ local edir, sdir, tdir, beam in m
1740
+ ! h is weighted by tdir, el is weighted by sdir, so to get tdir back, we need to multiply by sdir
1741
+ local k0h = 0.5*h * knl[1]/(eld or el) * sdir
1747
1742
local chg = beam.charge
1748
1743
local _beta = 1/beam.beta
1749
1744
1750
1745
for i=1,m.npar do
1751
1746
local x, px, y, py, t, pt, beam in m[i]
1752
1747
local _beta = beam and 1/beam.beta or _beta
1753
1748
local chg = beam and beam.charge or chg
1749
+ local k0hq = k0h*chg -- k0hq must be weighted by bdir
1754
1750
1755
- if tdir == 1 then -- to insure reversal symmetry ; horizontal wedge (only dir )
1756
- px = px + chg*k0h *x^2
1751
+ if sdir == 1 then -- to insure reversal symmetry ; horizontal wedge (only sdir )
1752
+ px = px + k0hq *x^2
1757
1753
end
1758
1754
1759
1755
local dpp = 1 + 2*pt*_beta + pt^2
1760
1756
local _pt2 = 1/(dpp - px^2)
1761
- local xi = 2*k0h*tdir *sqrt(dpp)*_pt2
1762
- local dxi_px = 2*px*xi *_pt2
1763
- local dxi_ddel = -2 *xi*(1+pt) *_pt2
1757
+ local xi = 2*k0hq *sqrt(dpp)*_pt2
1758
+ local dxi_px = 2*px*xi *_pt2
1759
+ local dxi_ddel = -2 *xi*(1+pt) *_pt2
1764
1760
1765
1761
x = x / (1-dxi_px*y^2)
1766
1762
px = px - xi*y^2
1767
1763
py = py - 2*xi*x*y
1768
1764
t = t - dxi_ddel*x*y^2
1769
1765
1770
- if tdir == -1 then -- to insure reversal symmetry; horizontal wedge (only dir )
1771
- px = px - chg*k0h *x^2
1766
+ if sdir == -1 then -- to insure reversal symmetry; horizontal wedge (only sdir )
1767
+ px = px + k0hq *x^2
1772
1768
end
1773
1769
1774
1770
m[i].x = x
@@ -1777,7 +1773,7 @@ function bend_face (h, m) -- [NEWFACE] -- chec
1777
1773
m[i].t = t
1778
1774
end
1779
1775
1780
- m.atdebug(h, m, 'bend_face:1')
1776
+ m.atdebug(h, m, lw, 'bend_face:1')
1781
1777
end
1782
1778
1783
1779
function mad8_wedge (e, m, lw_, wc) -- [FRINGE_TEAPOT:MAD8_WEDGE] -- checked
0 commit comments