Skip to content

Curved Multipole #287

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 4 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
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
48 changes: 39 additions & 9 deletions src/madl_dynmap.mad
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,38 @@ local function bxby (nmul, knl, ksl, x, y)
return bx, by
end

local function bxbyh (nmul, knl, ksl, x, y, h) -- [GETMAGNETIC] TODO: useful?
error("NYI")
local getanbnr in require("madl_dynmaph")

local function bxbyh (nmul, bf_X, bf_Y, x, y, eh) -- [GETMAGNETIC]
nmul = nmul + 2
local bx, by, k, b1, b2 = 0, 0, 0
for a = nmul, 1, -1 do
local btx, bty = 0, 0
for j = nmul-a, 1, -1 do
k = k + 1
btx = (btx + bf_X[k]) * y ! x1
bty = (bty + bf_Y[k]) * y
end

k = k + 1
btx = (btx + bf_X[k])
bty = (bty + bf_Y[k])

bx = (bx + btx) * x
by = (by + bty) * x
end

local btx, bty = 0, 0
for j = nmul, 1, -1 do
k = k + 1
btx = (btx + bf_X[k]) * y
bty = (bty + bf_Y[k]) * y
end

k = k + 1
b1 = (by + bty + bf_Y[k]) * (1 + eh*x)
b2 = (bx + btx + bf_X[k]) * (1 + eh*x)
return b2, b1
end

-- call make_coef(S_B_from_V,I,0)
Expand Down Expand Up @@ -593,19 +623,19 @@ end
function M.curex_kick (elm, m, lw, no_k0l) -- [SKICK] -- checked
m.atdebug(elm, m, lw, 'curex_kick:0', no_k0l)

local el, eh, tdir, nmul, knl, ksl, beam in m
local el, eh, tdir, nmul, knl, bf_X, bf_Y, beam in m
local bdir = tdir*beam.charge
local dby = no_k0l == true and knl[1] or eh*el*bdir-knl[1]

for i=1,m.npar do
local x, px, y, py, beam in m[i]
local bdir = beam and tdir*beam.charge or bdir
local dby = beam and not no_k0l and eh*el*bdir-knl[1] or dby
local bx,by = bxby(nmul, knl, ksl, x, y) -- bxbyh
local r = 1+eh*x
local bx, by = bxbyh(nmul, bf_X, bf_Y, x, y, eh) !m.bf_X, m.bf_Y instead of knl, ksl

m[i].px = px - (lw*bdir)*(by-dby)*r
m[i].py = py + (lw*bdir)* bx *r
m[i].px = px - (lw*bdir)*by
m[i].py = py + (lw*bdir)*bx
if no_k0l == true then
m[i].px = m[i].px + (lw*bdir*knl[1])*(1 + eh*x)
end
end

m.atdebug(elm, m, lw, 'curex_kick:1', no_k0l)
Expand Down
Loading