@@ -1773,33 +1773,35 @@ function bend_face (h, m, lw) -- [NEWFACE] --
1773
1773
1774
1774
m.atdebug(h, m, lw, 'bend_face:0')
1775
1775
1776
- local edir, beam in m
1777
- local k0h = 0.5*h * knl[1]/(eld or el)*edir
1776
+ local edir, sdir, tdir, beam in m
1777
+ ! h is weighted by tdir, el is weighted by sdir, so to get tdir back, we need to multiply by sdir
1778
+ local k0h = 0.5*h * knl[1]/(eld or el) * sdir
1778
1779
local chg = beam.charge
1779
1780
local _beta = 1/beam.beta
1780
1781
1781
1782
for i=1,m.npar do
1782
1783
local x, px, y, py, t, pt, beam in m[i]
1783
1784
local _beta = beam and 1/beam.beta or _beta
1784
1785
local chg = beam and beam.charge or chg
1786
+ local k0hq = k0h*chg -- k0hq must be weighted by bdir
1785
1787
1786
- if lw == 1 then -- to insure reversal symmetry ; horizontal wedge (only dir )
1787
- px = px + chg*k0h *x^2
1788
+ if tdir == 1 then -- to insure reversal symmetry ; horizontal wedge (only tdir )
1789
+ px = px + k0hq *x^2
1788
1790
end
1789
1791
1790
1792
local dpp = 1 + 2*pt*_beta + pt^2
1791
1793
local _pt2 = 1/(dpp - px^2)
1792
- local xi = 2*k0h*lw *sqrt(dpp)*_pt2
1793
- local dxi_px = 2*px*xi *_pt2
1794
- local dxi_ddel = -2 *xi*(1+pt) *_pt2
1794
+ local xi = 2*k0hq *sqrt(dpp)*_pt2
1795
+ local dxi_px = 2*px*xi *_pt2
1796
+ local dxi_ddel = -2 *xi*(1+pt) *_pt2
1795
1797
1796
1798
x = x / (1-dxi_px*y^2)
1797
1799
px = px - xi*y^2
1798
1800
py = py - 2*xi*x*y
1799
- t = t - dxi_ddel*x*y^2
1801
+ t = t + dxi_ddel*x*y^2
1800
1802
1801
- if lw == -1 then -- to insure reversal symmetry; horizontal wedge (only dir )
1802
- px = px - chg*k0h *x^2
1803
+ if tdir == -1 then -- to insure reversal symmetry; horizontal wedge (only tdir )
1804
+ px = px + k0hq *x^2
1803
1805
end
1804
1806
1805
1807
m[i].x = x
0 commit comments