Skip to content

Quadrupole & Drift Test Changes #283

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 6 commits into from
Mar 1, 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
153 changes: 127 additions & 26 deletions tests/tests/test-ptc-maps/test-ptc-maps.mad
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,138 @@ local ref_cfg = object "ref" {
icase = 56, -- 56/6
debug = 0, -- 0/6


-- list of values for each variables
model = 1..2,
method = 2..2..2, -- 2..6..2
nslice = 1..3..1,
energy = {1, 6500}, -- {1, 450, 6500}
x0i = 1..4..4, -- 0, 4D, 5D, 6D (see get_mad_str)
x0i = 1..4, -- 0, 4D, 5D, 6D (see get_mad_str)
}

-------------------------------------------------------------------------------o

-- The actual test functions --------------------------------------------------o
local function testQUAD()
local cfg = ref_cfg "quadrupole" {
local function testQUAD() -- Test the body (~2 min)
local cfg = ref_cfg "quad" {
elm = "QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s},",
model = 1..2,
method = 2..6..2, -- 2..6..2
nslice = 1..3,
energy = {1, 6500}, -- {1, 450, 6500}
tol = 50,

alist = tblcat(ref_cfg.alist, {"k1", "k1s"}),
k1 = {-0.15, 0, 0.2},
k1s = {-0.15, 0, 0.2},
}
run_test(cfg)
end

-- NOTE: FAILS for knl[2] ~= 0 or ksl[2] ~= 0
local function testQUADm() -- Test the multipole (~2 min)
local cfg = ref_cfg "quadm" {
elm = [[
QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s}, tilt=${tilt}*pi/8,
knl=${knl}, ksl=${ksl}
]],
tol = 300,
model = {1}, -- DKD slow as it does ~300 rotations producing ~4 MB of data (WEDGE)
method = {2},
nslice = {1},
energy = {1}, -- {1, 450, 6500}

alist = tblcat(ref_cfg.alist, {"tilt", "k1s", "k1", "ksl", "knl"}),
k1 = {0, 0.2}, -- Test just multipole first
k1s = \s->s.k1, !{0, -0.15, 0.2}, -- Test just multipole first
knl = {
{ },
{0.05, 0, 0, 0 },
{0 , 0, 5, 0 },
{0 , 0, 0, 50},
{0.05, 0, 5, 50},
},
ksl = \s-> s.knl,
tilt = 0..2,
}
run_test(cfg)
end

local function testQUADf() -- Test the fringe (~1 min)
local cfg = ref_cfg "quadf" {
elm = [[
QUADRUPOLE, at=0.75, l=1.5,
k1=${k1}, k1s=${k1s}, tilt=${tilt}*pi/8, fringe=${fringe}
QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s}, tilt=${tilt}*pi/8,
fringe=${fringe}
]],
tol = 25,
model = {2}, -- Use TKT as faster
method = {2}, -- 2..6..2
nslice = {1},
energy = {1},

alist = tblcat(ref_cfg.alist, {"tilt", "fringe", "k1", "k1s"}),
tilt = 0 ..4,
fringe = 0 ..3 ..3,
k1 = -0.2..0.2..0.2,
k1s = -0.2..0.2..0.2,
tilt = 0..4,
fringe = 0..3..3,
k1 = {0, 0.2},
k1s = \s->s.k1,
}
run_test(cfg)
end

local function testQUADh()
local cfg = ref_cfg "quadh" {
elm = [[
QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s}, tilt=${tilt}*pi/8,
k0=${k0}
]],
tol = 25,
model = {1}, -- Use DKD as otherwise PTC broken
method = {2}, -- 2..6..2
nslice = {1},
energy = {1},

alist = tblcat(ref_cfg.alist, {"tilt", "k1", "k1s", "k0"}),
tilt = 0..4,
k1 = {0, 0.2},
k1s = \s->s.k1,
k0 = {-0.05, 0, 0.05}
}
run_test(cfg)
end

local function testQUADfh() -- MAD-NG does bend fringe for fringe=3
local cfg = ref_cfg "quadfh" {
elm = [[
QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s}, fringe=${fringe},
k0=${k0}, bend_fringe=${bend_fringe}
]],
tol = 25,
model = {1}, -- Use DKD as otherwise PTC broken
method = {2},
nslice = {1},
energy = {1},

alist = tblcat(ref_cfg.alist, {"k1", "k1s", "k0", "fringe", "bend_fringe"}),
fringe = 0..3..3,
k1 = {0, 0.2},
k1s = \s->s.k1,
k0 = {0, 0.05},
bend_fringe = \s-> {s.cur_cfg.fringe and s.cur_cfg.fringe > 0 and true or false},
}
run_test(cfg)
end

local function testDRIFT()
local cfg = ref_cfg "drift" {
elm = "DRIFT, at=${at}, l=${l}",
tol = 100,
energy = {1},
model = {1, 2},
method = {2, 6},
nslice = {1, 3},

alist = tblcat(ref_cfg.alist, {"l", "at"}),
l = {0.1, 0.5, 1.5, 2},
at = \s->{s.cur_cfg.l/2}
-- tilt = 0..4, ! Illegal keyword in MAD-X
}
run_test(cfg)
end
--[=[
local function testSEXT()
local cfg = ref_cfg "sextupole" {
elm = [[
Expand Down Expand Up @@ -119,14 +224,6 @@ local function testDODECA()
run_test(cfg)
end

local function testDRIFT()
local cfg = ref_cfg "drift" {
elm = "DRIFT, at=0.75, l=1.5",
tol = 100,
}
run_test(cfg)
end

local function testCAV()
local cfg = ref_cfg "cavity" {
elm = [[
Expand Down Expand Up @@ -297,14 +394,18 @@ local function testRFMULT()
}
cfg = cfg {harmon := {cfg.cur_cfg.freq == 0 and 2 or 0},}
run_test(cfg)
end
end ]=]
-------------------------------------------------------------------------------o

-- Running the tests-----------------------------------------------------------o
-- testDRIFT()
testDRIFT()
-- testSBEND()
-- testRBEND()
testQUAD()
-- testQUAD()
-- testQUADm()
-- testQUADf()
-- testQUADh()
-- testQUADfh()
-- testSEXT()
-- testOCT()
-- testDECA () -- Only actually tests the multipole
Expand Down
Loading