Skip to content

Commit da10952

Browse files
authored
Merge pull request #283 from jgray-19/test_ptc
Quadrupole & Drift Test Changes
2 parents 2eda4d9 + f8a36f3 commit da10952

File tree

2 files changed

+451
-353
lines changed

2 files changed

+451
-353
lines changed

tests/tests/test-ptc-maps/test-ptc-maps.mad

Lines changed: 127 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,138 @@ local ref_cfg = object "ref" {
2323
icase = 56, -- 56/6
2424
debug = 0, -- 0/6
2525

26-
27-
-- list of values for each variables
28-
model = 1..2,
29-
method = 2..2..2, -- 2..6..2
30-
nslice = 1..3..1,
31-
energy = {1, 6500}, -- {1, 450, 6500}
32-
x0i = 1..4..4, -- 0, 4D, 5D, 6D (see get_mad_str)
26+
x0i = 1..4, -- 0, 4D, 5D, 6D (see get_mad_str)
3327
}
28+
3429
-------------------------------------------------------------------------------o
3530

3631
-- The actual test functions --------------------------------------------------o
37-
local function testQUAD()
38-
local cfg = ref_cfg "quadrupole" {
32+
local function testQUAD() -- Test the body (~2 min)
33+
local cfg = ref_cfg "quad" {
34+
elm = "QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s},",
35+
model = 1..2,
36+
method = 2..6..2, -- 2..6..2
37+
nslice = 1..3,
38+
energy = {1, 6500}, -- {1, 450, 6500}
39+
tol = 50,
40+
41+
alist = tblcat(ref_cfg.alist, {"k1", "k1s"}),
42+
k1 = {-0.15, 0, 0.2},
43+
k1s = {-0.15, 0, 0.2},
44+
}
45+
run_test(cfg)
46+
end
47+
48+
-- NOTE: FAILS for knl[2] ~= 0 or ksl[2] ~= 0
49+
local function testQUADm() -- Test the multipole (~2 min)
50+
local cfg = ref_cfg "quadm" {
51+
elm = [[
52+
QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s}, tilt=${tilt}*pi/8,
53+
knl=${knl}, ksl=${ksl}
54+
]],
55+
tol = 300,
56+
model = {1}, -- DKD slow as it does ~300 rotations producing ~4 MB of data (WEDGE)
57+
method = {2},
58+
nslice = {1},
59+
energy = {1}, -- {1, 450, 6500}
60+
61+
alist = tblcat(ref_cfg.alist, {"tilt", "k1s", "k1", "ksl", "knl"}),
62+
k1 = {0, 0.2}, -- Test just multipole first
63+
k1s = \s->s.k1, !{0, -0.15, 0.2}, -- Test just multipole first
64+
knl = {
65+
{ },
66+
{0.05, 0, 0, 0 },
67+
{0 , 0, 5, 0 },
68+
{0 , 0, 0, 50},
69+
{0.05, 0, 5, 50},
70+
},
71+
ksl = \s-> s.knl,
72+
tilt = 0..2,
73+
}
74+
run_test(cfg)
75+
end
76+
77+
local function testQUADf() -- Test the fringe (~1 min)
78+
local cfg = ref_cfg "quadf" {
3979
elm = [[
40-
QUADRUPOLE, at=0.75, l=1.5,
41-
k1=${k1}, k1s=${k1s}, tilt=${tilt}*pi/8, fringe=${fringe}
80+
QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s}, tilt=${tilt}*pi/8,
81+
fringe=${fringe}
4282
]],
83+
tol = 25,
84+
model = {2}, -- Use TKT as faster
85+
method = {2}, -- 2..6..2
86+
nslice = {1},
87+
energy = {1},
4388

4489
alist = tblcat(ref_cfg.alist, {"tilt", "fringe", "k1", "k1s"}),
45-
tilt = 0 ..4,
46-
fringe = 0 ..3 ..3,
47-
k1 = -0.2..0.2..0.2,
48-
k1s = -0.2..0.2..0.2,
90+
tilt = 0..4,
91+
fringe = 0..3..3,
92+
k1 = {0, 0.2},
93+
k1s = \s->s.k1,
94+
}
95+
run_test(cfg)
96+
end
97+
98+
local function testQUADh()
99+
local cfg = ref_cfg "quadh" {
100+
elm = [[
101+
QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s}, tilt=${tilt}*pi/8,
102+
k0=${k0}
103+
]],
104+
tol = 25,
105+
model = {1}, -- Use DKD as otherwise PTC broken
106+
method = {2}, -- 2..6..2
107+
nslice = {1},
108+
energy = {1},
109+
110+
alist = tblcat(ref_cfg.alist, {"tilt", "k1", "k1s", "k0"}),
111+
tilt = 0..4,
112+
k1 = {0, 0.2},
113+
k1s = \s->s.k1,
114+
k0 = {-0.05, 0, 0.05}
49115
}
50116
run_test(cfg)
51117
end
52118

119+
local function testQUADfh() -- MAD-NG does bend fringe for fringe=3
120+
local cfg = ref_cfg "quadfh" {
121+
elm = [[
122+
QUADRUPOLE, at=0.75, l=1.5, k1=${k1}, k1s=${k1s}, fringe=${fringe},
123+
k0=${k0}, bend_fringe=${bend_fringe}
124+
]],
125+
tol = 25,
126+
model = {1}, -- Use DKD as otherwise PTC broken
127+
method = {2},
128+
nslice = {1},
129+
energy = {1},
130+
131+
alist = tblcat(ref_cfg.alist, {"k1", "k1s", "k0", "fringe", "bend_fringe"}),
132+
fringe = 0..3..3,
133+
k1 = {0, 0.2},
134+
k1s = \s->s.k1,
135+
k0 = {0, 0.05},
136+
bend_fringe = \s-> {s.cur_cfg.fringe and s.cur_cfg.fringe > 0 and true or false},
137+
}
138+
run_test(cfg)
139+
end
140+
141+
local function testDRIFT()
142+
local cfg = ref_cfg "drift" {
143+
elm = "DRIFT, at=${at}, l=${l}",
144+
tol = 100,
145+
energy = {1},
146+
model = {1, 2},
147+
method = {2, 6},
148+
nslice = {1, 3},
149+
150+
alist = tblcat(ref_cfg.alist, {"l", "at"}),
151+
l = {0.1, 0.5, 1.5, 2},
152+
at = \s->{s.cur_cfg.l/2}
153+
-- tilt = 0..4, ! Illegal keyword in MAD-X
154+
}
155+
run_test(cfg)
156+
end
157+
--[=[
53158
local function testSEXT()
54159
local cfg = ref_cfg "sextupole" {
55160
elm = [[
@@ -119,14 +224,6 @@ local function testDODECA()
119224
run_test(cfg)
120225
end
121226

122-
local function testDRIFT()
123-
local cfg = ref_cfg "drift" {
124-
elm = "DRIFT, at=0.75, l=1.5",
125-
tol = 100,
126-
}
127-
run_test(cfg)
128-
end
129-
130227
local function testCAV()
131228
local cfg = ref_cfg "cavity" {
132229
elm = [[
@@ -297,14 +394,18 @@ local function testRFMULT()
297394
}
298395
cfg = cfg {harmon := {cfg.cur_cfg.freq == 0 and 2 or 0},}
299396
run_test(cfg)
300-
end
397+
end ]=]
301398
-------------------------------------------------------------------------------o
302399

303400
-- Running the tests-----------------------------------------------------------o
304-
-- testDRIFT()
401+
testDRIFT()
305402
-- testSBEND()
306403
-- testRBEND()
307-
testQUAD()
404+
-- testQUAD()
405+
-- testQUADm()
406+
-- testQUADf()
407+
-- testQUADh()
408+
-- testQUADfh()
308409
-- testSEXT()
309410
-- testOCT()
310411
-- testDECA () -- Only actually tests the multipole

0 commit comments

Comments
 (0)