Skip to content

Improve ng vs ng tests #308

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 2 commits into from
May 21, 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
97 changes: 57 additions & 40 deletions tests/tests/test-ng-maps/test-ng-maps.mad
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ local ref_cfg = object "ref" {
}


local default_plot_cfg = {
series = {
"'${test_type}' == 'edir'",
"'${test_type}' == 'chg'",
"'${test_type}' == 'backtrack'",
},
legend = {
y1 = "Reverse edir",
y2 = "Reverse charge",
y3 = "Backtrack",
},
}

-- The actual test functions --------------------------------------------------o
local function testQUAD() -- Test the body (~2 min)
local cfg = ref_cfg "quad" {
Expand All @@ -70,22 +83,10 @@ local function testQUAD() -- Test the body (~2 min)
alist = tblcat(ref_cfg.alist, {"k1", "k1s"}),

plot_info = {
title = "Quadrupole NG v NG Maps",
series = {
"'${test_type}' == 'edir'",
"'${test_type}' == 'chg'",
"'${test_type}' == 'backtrack'",
"'${test_type}' == 'rotate_1'",
"'${test_type}' == 'rotate_2'",
},
legend = {
y1 = "Reverse edir",
y2 = "Reverse charge",
y3 = "Backtrack",
y4 = "Rotate by pi/4",
y5 = "Rotate by -pi/4",
},
title = "Quadrupole NG v NG Maps",
filename = "quad-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
}
}
local equiv = object "quad" {
Expand Down Expand Up @@ -117,18 +118,10 @@ local function testSBEND() -- Test the body (~2 min)
alist = tblcat(ref_cfg.alist, {"angle_div"}),

plot_info = {
title = "SBend NG v NG Maps",
series = {
"'${test_type}' == 'edir'",
"'${test_type}' == 'chg'",
"'${test_type}' == 'backtrack'",
},
legend = {
y1 = "Reverse edir",
y2 = "Reverse charge",
y3 = "Backtrack",
},
title = "SBend NG v NG Maps",
filename = "sbend-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
}
}
run_test(cfg, {alist = {}})
Expand All @@ -138,7 +131,8 @@ local function testRBEND() -- Test the body (~2 min)
local cfg = ref_cfg "rbend" {
elm = [[rbend 'rbend' {
at=0.75, l=1.5, k0=${bdir}*math.pi/${angle_div}, angle=${tdir}*math.pi/${angle_div}*1.5, fringe=0,
e1 = ${edir}*${e1}*math.pi/${angle_div}*1.5, e2 = ${edir}*${e2}*math.pi/${angle_div}*1.5
e1 = ${tdir}*${e1}*math.pi/${angle_div}*1.5, e2 = ${tdir}*${e2}*math.pi/${angle_div}*1.5,
true_rbend = ${true_rbend},
}]],
model = {1, 2},
method = 2..6..2,
Expand All @@ -148,23 +142,45 @@ local function testRBEND() -- Test the body (~2 min)
tol = 2000,

angle_div = {50, 100, 200, 500, 1000},
true_rbend = {false, true},
e1 = {-0.15, 0, 0.2},
e2 = {-0.2, 0, 0.15},
alist = tblcat(ref_cfg.alist, {"angle_div", "e1", "e2"}),
alist = tblcat(ref_cfg.alist, {"true_rbend", "angle_div", "e1", "e2"}),

plot_info = {
title = "RBend NG v NG Maps",
series = {
"'${test_type}' == 'edir'",
"'${test_type}' == 'chg'",
"'${test_type}' == 'backtrack'",
},
legend = {
y1 = "Reverse edir",
y2 = "Reverse charge",
y3 = "Backtrack",
},
title = "RBend NG v NG Maps",
filename = "rbend-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
} }
run_test(cfg, {alist = {}})
end

local function testRBENDPARALLEL()
local cfg = ref_cfg "rbend_parallel" {
elm = [[rbend 'rbend' { true_rbend = true,
at=0.75, l=1.5, k0=${bdir}*math.pi/${angle_div}, angle=${tdir}*math.pi/${angle_div}*1.5, fringe=0,
e1 = ${e1} and ${tdir}*${e1}*math.pi/${angle_div}*1.5, e2 = ${e2} and ${tdir}*${e2}*math.pi/${angle_div}*1.5
}]],

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

tol = 2000,

angle_div = {50, 100, 200, 500, 1000},
patch_first = {false, true},
e1 = \s -> s.cur_cfg.patch_first and {false} or {-0.15, 0, 0.2},
e2 = \s -> s.cur_cfg.patch_first and {-0.2, 0, 0.15} or {false},
alist = tblcat(ref_cfg.alist, {"patch_first", "angle_div", "e1", "e2"}),

plot_info = {
title = "True Parallel RBend NG v NG Maps",
filename = "true-parallel-rbend-ngvng.png",
series = default_plot_cfg.series,
legend = default_plot_cfg.legend,
}
}
run_test(cfg, {alist = {}})
Expand Down Expand Up @@ -213,4 +229,5 @@ end
testQUAD()
testSBEND()
testRBEND()
-- testRFMULTIPOLE()
testRBENDPARALLEL()
-- testRFMULTIPOLE()