Skip to content

Commit 41919e6

Browse files
author
jgray-19
committed
Add patch tests
1 parent 6361d3d commit 41919e6

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
-- ../mad test-misc-maps.mad
2+
-- assume ../madx64 to be present...
3+
4+
local object in MAD
5+
local tblcat in MAD.utility
6+
local run_test in require("trackvsptc")
7+
8+
-- The setup for the tests ----------------------------------------------------o
9+
10+
local ref_cfg = object "ref" {
11+
-- How to run the tests
12+
dorun = true, -- Default: true
13+
dosave = true, -- Default: false
14+
doprnt = true, -- Default: false
15+
dodbg = true, -- Default: false
16+
doplot = true, -- Default: false
17+
18+
-- list of variables in the tests
19+
alist = {"model", "energy", "method", "nslice", "x0i"}, --attributes list
20+
tol = 1000,
21+
22+
-- list of values that are used to run test but are not changed throughout
23+
order = 4, -- 2/4
24+
icase = 56, -- 56/6
25+
debug = 0, -- 0/6
26+
snm = -1,
27+
28+
x0i = 1..4, -- 0, 4D, 5D, 6D (see get_mad_str)
29+
}
30+
31+
local function testRotation()
32+
local cfg = ref_cfg "rot" {
33+
elm = "${dir}ROTATION, at=${at}, angle=pi/${_angle};",
34+
35+
model = {1},
36+
method = {2},
37+
nslice = {1},
38+
energy = {1, 6500}, -- {1, 450, 6500}
39+
40+
tol = 100,
41+
42+
at = {0.05, 0.25, 0.75, 1},
43+
_angle= {10, 50, 100, 330, 500, 1000},
44+
dir = {"X", "Y", "S"},
45+
alist = tblcat(ref_cfg.alist, {"dir", "at", "_angle"}),
46+
47+
plot_info = {
48+
series = {
49+
"'${dir}' == 'X'",
50+
"'${dir}' == 'Y'",
51+
"'${dir}' == 'S'",
52+
},
53+
legend = {
54+
y1 = "X Rotation",
55+
y2 = "Y Rotation",
56+
y3 = "S Rotation",
57+
},
58+
title = "Rotation NG vs PTC",
59+
filename = "rotation.png",
60+
}
61+
}
62+
run_test(cfg)
63+
end
64+
65+
local function testTranslate()
66+
local cfg = ref_cfg "translate" {
67+
elm = "translation, at=${at}, dx=${dx}, dy=${dy}, ds=${ds};",
68+
69+
model = {1},
70+
method = {2},
71+
nslice = {1},
72+
energy = {1, 6500}, -- {1, 450, 6500}
73+
74+
tol = 100,
75+
76+
at = {0.05, 0.25, 0.75, 1},
77+
dx = {0.01, 0.05, 0.1, 0.2},
78+
dy = {0.01, 0.05, 0.1, 0.2},
79+
ds = {0.01, 0.05, 0.1, 0.2},
80+
alist = tblcat(ref_cfg.alist, {"at", "dx", "dy", "ds"}),
81+
82+
plot_info = {
83+
title = "Translation NG vs PTC",
84+
filename = "translation.png",
85+
}
86+
}
87+
run_test(cfg)
88+
end
89+
90+
local function testChangeRef() -- FAILS -> ptc does rotation x, y, s not y, -x, s as ng
91+
local cfg = ref_cfg "changeref" {
92+
elm = "changeref, at=${at}, dx=${dx}, dy=${dy}, ds=${ds}, dtheta=${dtheta}, dphi=${dphi}, dpsi=${dpsi};",
93+
94+
model = {1},
95+
method = {2},
96+
nslice = {1},
97+
energy = {1, 6500}, -- {1, 450, 6500}
98+
99+
tol = 100,
100+
101+
at = {0.05, 0.25, 0.75, 1},
102+
dx = {0,-0.01, 0.4},
103+
dy = {0,-0.05, 0.3},
104+
ds = {0, 0.03,-0.2},
105+
dtheta= {0, 0.01, 0.05, 0.1, 0.2},
106+
dphi = {0, 0.03, 0.05, 0.2, 0.1},
107+
dpsi = {0, 0.02, 0.05, 0.3, 0.6},
108+
109+
alist = tblcat(ref_cfg.alist, {"at", "dx", "dy", "ds", "dtheta", "dphi", "dpsi"}),
110+
plot_info = {
111+
title = "ChangeRef NG vs PTC",
112+
filename = "changeref.png",
113+
}
114+
}
115+
116+
run_test(cfg)
117+
end
118+
119+
testRotation()
120+
testTranslate()
121+
-- testChangeRef()

0 commit comments

Comments
 (0)