@@ -23,33 +23,138 @@ local ref_cfg = object "ref" {
23
23
icase = 56, -- 56/6
24
24
debug = 0, -- 0/6
25
25
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)
33
27
}
28
+
34
29
-------------------------------------------------------------------------------o
35
30
36
31
-- 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" {
39
79
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}
42
82
]],
83
+ tol = 25,
84
+ model = {2}, -- Use TKT as faster
85
+ method = {2}, -- 2..6..2
86
+ nslice = {1},
87
+ energy = {1},
43
88
44
89
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}
49
115
}
50
116
run_test(cfg)
51
117
end
52
118
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
+ --[=[
53
158
local function testSEXT()
54
159
local cfg = ref_cfg "sextupole" {
55
160
elm = [[
@@ -119,14 +224,6 @@ local function testDODECA()
119
224
run_test(cfg)
120
225
end
121
226
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
-
130
227
local function testCAV()
131
228
local cfg = ref_cfg "cavity" {
132
229
elm = [[
@@ -297,14 +394,18 @@ local function testRFMULT()
297
394
}
298
395
cfg = cfg {harmon := {cfg.cur_cfg.freq == 0 and 2 or 0},}
299
396
run_test(cfg)
300
- end
397
+ end ]=]
301
398
-------------------------------------------------------------------------------o
302
399
303
400
-- Running the tests-----------------------------------------------------------o
304
- -- testDRIFT()
401
+ testDRIFT()
305
402
-- testSBEND()
306
403
-- testRBEND()
307
- testQUAD()
404
+ -- testQUAD()
405
+ -- testQUADm()
406
+ -- testQUADf()
407
+ -- testQUADh()
408
+ -- testQUADfh()
308
409
-- testSEXT()
309
410
-- testOCT()
310
411
-- testDECA () -- Only actually tests the multipole
0 commit comments