Skip to content

Survey fixes for rbend #298

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

Merged
merged 2 commits into from
May 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions src/madl_esurv.mad
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ local fnil, bind3rd in MAD.gfunc
local errorf in MAD.utility
local minlen, minang in MAD.constant
local is_implicit in element.drift
local arc2cord in MAD.gmath

local abs in math
local abs, sin in math

-- integrator schemes ---------------------------------------------------------o

Expand Down Expand Up @@ -192,23 +193,23 @@ end
-- rbend special --------------------------------------------------------------o

local function fng_e1 (e, m, s)
local e1, e2, sdir in m
local e1, e2, elc, sdir in m
local d = s*sdir
if d == -1 then
local e_ = {name=e.name, dx=m.elc*sin((e2-e1)/2), dy=0, ds=0}
yrotation(e2, m, -1)
translate(e_, m, s)
local e_ = {name=e.name, dx=elc*sin((e2-e1)/2), dy=0, ds=0}
yrotation(e2, m, -1) -- translation independant of direction
translate(e_, m, -1)
elseif e1 ~= 0 then
yrotation(e1, m, -1)
end
end

local function fng_e2 (e, m, s)
local e1, e2, sdir in m
local e1, e2, elc, sdir in m
local d = s*sdir
if d == 1 then
local e_ = {name=e.name, dx=m.elc*sin((e2-e1)/2), dy=0, ds=0}
translate(e_, m, s)
local e_ = {name=e.name, dx=elc*sin((e2-e1)/2), dy=0, ds=0}
translate(e_, m, -1) -- translation independant of direction
yrotation(e1, m, -1)
elseif e2 ~= 0 then
yrotation(e2 , m, -1)
Expand All @@ -221,18 +222,23 @@ local function track_rbend (elm, m)
local fng = nil -- default: curved rbend aka sbend with parallel pole faces

if elm.true_rbend then -- true rbend
local e1, e2 in elm
-- compute correct E1 and E2 from the slides.
if e1 and e2 then
local e1, e2, angle, l in elm
if e1 and e2 then -- MAD-like Wedge rbend
fng = fng_e
elseif e1 then
fng = fng_e1
else
fng = fng_e2
else -- true parallel rbend
m.elc = arc2cord(l, angle)
if e1 then
m.e1, m.e2 = e1, angle - e1
fng = fng_e1
else
m.e1, m.e2 = angle - e2, e2
fng = fng_e2
end
end
end

track_thick(elm, m, fng)
m.e1, m.e2, m.elc = nil, nil, nil
end

-- load maps into elements ----------------------------------------------------o
Expand Down