Skip to content

Improve ng vs ng Tests #338

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 5 commits into from
Jun 29, 2023
Merged
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
219 changes: 219 additions & 0 deletions tests/tests/test-ng-maps/test-ng-maps.mad
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,30 @@ local default_plot_cfg = {
}

-- The actual test functions --------------------------------------------------o
local function testDRIFT()
local cfg = ref_cfg "drift" {
elm = "drift 'drift' {at=0.75, l=1.5, tilt=${tdir}*${tilt}*math.pi/8}",
model = {1, 2},
method = 2..8..2,
nslice = 1..3,
energy = {1, 6500},

tol = 10,

tilt = 0..2,
alist = tblcat(ref_cfg.alist, {"tilt"}),

plot_info = {
title = "Drift NG v NG Maps",
filename = "drift-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
},
}

run_test(cfg, {alist={}})
end

local function testQUAD() -- Test the body (~2 min)
local cfg = ref_cfg "quad" {
elm = "quadrupole 'quad' {at=0.75, l=1.5, k1=${bdir}*${k1}, k1s=${bdir}*${k1s},tilt=${tilt}, fringe=0}",
Expand Down Expand Up @@ -364,7 +388,196 @@ local function testKICKER()
run_test(cfg, {alist={}})
end

local function testELSEPARATOR()
local cfg = ref_cfg "elseparator" {
elm = "elseparator 'elsep' {at=0.75, l=1.5,\z
ex=${bdir}*${ex}, ey=${bdir}*${ey}, exl=${bdir}*${exl}, eyl=${bdir}*${eyl}, tilt=${tdir}*${tilt}*math.pi/16}",

model = {1, 2},
method = {2, 8},
nslice = 1..3,
energy = {1, 6500},

tol = 50,

ex = {-4, 4, 0},
ey = {-4, 4, 0},
exl = {0, -6, 6}, ! Madx is ex_l and the madng is exl
eyl = {0, -6, 6}, ! Madx is ex_l and the madng is exl
tilt = 0..2,
alist = tblcat(ref_cfg.alist, {"ex", "ey", "exl", "eyl", "tilt"}),

plot_info = {
title = "Elseparator NG v NG Maps",
filename = "elseparator-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
},
}

run_test(cfg, {alist={}})
end

local function testCCAVITY()
local cfg = ref_cfg "ccav" {
elm = "crabcavity 'ccav' {at=0.75, l=1.5, volt=${bdir}*${volt}, freq=${freq}, lag=${lag}, fringe=0}",
model = {1, 2},
method = 2..8..2,
nslice = 1..3,
energy = {1, 6500},

tol = 100,

volt = {-8, 0, 8},
freq = {75, 150, 225},
lag = {0, 0.8},
alist = tblcat(ref_cfg.alist, {"volt", "freq", "lag"}),

plot_info = {
title = "CrabCavity NG v NG Maps",
filename = "crabcav-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
},
}

run_test(cfg, {alist={}})
end

local function testMULTIPOLE()
local cfg = ref_cfg "mult" {
elm = [[
multipole 'mult' {
at=0.75, lrad=${lrad}, knl={
${bdir}*${k0},
${bdir}*${k1},
${bdir}*${k2},
${bdir}*${k3},
}, ksl={
${bdir}*${k0s},
${bdir}*${k1s},
${bdir}*${k2s},
${bdir}*${k3s},
}, ksi=${bdir}*${ksi}, fringe=0
}
]],
model = {1},
method = {2},
nslice = {1},
energy = {1, 6500},

order = 6,

tol = 60,

lrad = { 0, 0.5, 1.5},
k0 = {-0.15, 0, 0.2},
k1 = {-0.15, 0, 0.2},
k2 = \s -> s.cur_cfg.k0,
k3 = \s -> s.cur_cfg.k1s,
k0s = {-0.15, 0, 0.2},
k1s = {-0.15, 0, 0.2},
k2s = \s -> s.cur_cfg.k0s,
k3s = \s -> s.cur_cfg.k1,
ksi = {0, -0.15, 0.2},
alist = tblcat(ref_cfg.alist, {"lrad", "k0", "k1", "k0s", "k1s", "ksi"}),

plot_info = {
title = "Multipole NG v NG Maps",
filename = "mult-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
},
}

run_test(cfg, {alist={}})
end

local function testROTATION()
local cfg = ref_cfg "rot" {
elm = "${dir}rotation 'rot' {at=${at}, angle=${tdir}*math.pi/${_angle}}",
model = {1},
method = {2},
nslice = {1},
energy = {1, 6500},

tol = 10,

at = {0.05, 0.25, 0.75, 1},
_angle= {10, 50, 100, 330, 500, 1000},
dir = {"x", "y", "s"},
alist = tblcat(ref_cfg.alist, {"dir", "at", "_angle"}),

plot_info = {
title = "Rotation NG v NG Maps",
filename = "rot-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
},
}

run_test(cfg, {alist={}})
end

local function testTRANSLATE() -- Needs verification about tdir and sdir
local cfg = ref_cfg "translate" {
elm = "translate {at=${at}, dx=${tdir}*${dx}, dy=${tdir}*${dy}, ds=${sdir}*${ds}}",

model = {1},
method = {2},
nslice = {1},
energy = {1, 6500}, -- {1, 450, 6500}

tol = 10,

at = {0.05, 0.25, 0.75, 1},
dx = {0.01, 0.05, 0.1, 0.2},
dy = {0.01, 0.05, 0.1, 0.2},
ds = {0.01, 0.05, 0.1, 0.2},
alist = tblcat(ref_cfg.alist, {"at", "dx", "dy", "ds"}),

plot_info = {
title = "Translation NG v NG Maps",
filename = "translate-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
},
}

run_test(cfg, {alist={}})
end

local function testCHANGEREF()
local cfg = ref_cfg "changeref" {
elm = "changeref{at=${at}, dx=${tdir}*${dx}, dy=${tdir}*${dy}, ds=${sdir}*${ds}, dtheta=${tdir}*${dtheta}, dphi=${tdir}*${dphi}, dpsi=${tdir}*${dpsi}}",
model = {1},
method = {2},
nslice = {1},
energy = {1, 6500},
tol = 100,

at = {0.05, 0.25, 0.75, 1},
dx = {0,-0.01, 0.4},
dy = {0,-0.05, 0.3},
ds = {0, 0.03,-0.2},
dtheta= {0, 0.01, 0.2},
dphi = {0, 0.03, 0.1},
dpsi = {0, 0.02, 0.6},

alist = tblcat(ref_cfg.alist, {"at", "dx", "dy", "ds", "dtheta", "dphi", "dpsi"}),

plot_info = {
title = "ChangeRef NG v NG Maps",
filename = "changeref-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
},
}

run_test(cfg, {alist={}})
end

testDRIFT()
testQUAD()
testSEXT()
testOCT()
Expand All @@ -375,3 +588,9 @@ testRFMULTIPOLE()
testSOL()
testRFCAVITY()
testKICKER()
testELSEPARATOR()
testCCAVITY()
testMULTIPOLE()
testROTATION()
testTRANSLATE()
testCHANGEREF()