Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description = "Accelerator Toolbox Interface for Pytac"
dependencies = [
"numpy",
"scipy",
"pytac>=0.6.1",
"pytac>=0.7.0",
"accelerator-toolbox (>=0.2.0,<0.7.1)",
"cothread",
"softioc",
Expand Down
Binary file removed src/atip/rings/DBA.mat
Binary file not shown.
Binary file modified src/atip/rings/DIAD.mat
Binary file not shown.
230 changes: 0 additions & 230 deletions src/atip/rings/DIAMOND2SP.lat

This file was deleted.

Binary file removed src/atip/rings/HMBA.mat
Binary file not shown.
Binary file modified src/atip/rings/I04.mat
Binary file not shown.
Binary file removed src/atip/rings/VMX.mat
Binary file not shown.
Binary file removed src/atip/rings/VMXSP.mat
Binary file not shown.
Binary file removed src/atip/rings/VMXSP_WIG.mat
Binary file not shown.
Binary file removed src/atip/rings/VMX_WIG.mat
Binary file not shown.
65 changes: 36 additions & 29 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def atlds():

@pytest.fixture()
def at_lattice():
return atip.utils.load_at_lattice("HMBA")
return atip.utils.load_at_lattice("I04")


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -125,50 +125,57 @@ def ba_atsim(at_lattice):
@pytest.fixture()
def initial_phys_data(at_lattice):
return {
"tune": numpy.array([0.38156245, 0.85437543]),
"chromaticity": numpy.array([0.17919002, 0.12242263]),
"tune": numpy.array([0.1823785, 0.2730096]),
"chromaticity": numpy.array([2.05528097, 2.90000203]),
"closed_orbit": numpy.zeros((6, len(at_lattice))),
"dispersion": numpy.array(
[1.72682010e-3, 4.04368254e-9, 5.88659608e-28, -8.95277691e-29]
[8.04285115e-02, 1.82229041e-03, -4.66599806e-16, 9.68514718e-17]
),
"s_pos": numpy.cumsum(
[0.0] + [getattr(elem, "Length", 0) for elem in at_lattice[:-1]]
),
"alpha": numpy.array([0.384261343, 1.00253822]),
"beta": numpy.array([7.91882634, 5.30280084]),
"alpha": numpy.array([0.41083373, 0.76826358]),
"beta": numpy.array([11.41465744, 9.38580055]),
"m66": numpy.array(
[
[-0.47537132, 6.62427828, 0.0, 0.0, 2.55038448e-03, -5.33885495e-07],
[-0.09816788, -0.73565385, 0.0, 0.0, 1.69015229e-04, -3.53808533e-08],
[0.0, 0.0, -0.18476435, -3.7128728, 0.0, 0.0],
[0.0, 0.0, 0.29967874, 0.60979916, 0.0, 0.0],
[
1.24684834e-06,
2.15443495e-05,
0.0,
0.0,
9.99980691e-01,
2.09331256e-04,
7.86384427e-01,
6.95380796e00,
0.00000000e00,
0.00000000e00,
-1.79313850e-03,
2.45580638e-05,
],
[
1.70098195e-04,
2.99580152e-03,
0.0,
0.0,
2.24325864e-03,
9.99999530e-01,
-9.32748192e-02,
4.46416511e-01,
0.00000000e00,
0.00000000e00,
9.24467098e-03,
-5.27165562e-05,
],
[0.0, 0.0, 0.61607674, 6.58807515, 0.0, 0.0],
[0.0, 0.0, -0.16763406, -0.1699704, 0.0, 0.0],
[
-1.51614014e-05,
-5.76481623e-05,
0.00000000e00,
0.00000000e00,
9.98875829e-01,
-8.01593240e-03,
],
[0.00710922, 0.06512084, 0.0, 0.0, 0.08704729, 0.99976966],
]
),
"mu": numpy.array([14.59693301, 4.58153046, 6.85248778e-04]),
"emitXY": numpy.array([1.32528e-10, 0.0]),
"mu": numpy.array([1.76647685e02, 8.27678865e01, 2.65364030e-02]),
"emitXY": numpy.array([2.70982566e-09, 0.00000000e00]),
"rad_int": numpy.array(
[
2.2435734416179783e-3,
4.3264360771244244e-3,
1.049245018317141e-4,
-2.3049140720439194e-3,
1.6505019559193616e-8,
8.75420386e-02,
8.65728946e-01,
1.20198368e-01,
-7.53876505e-03,
1.78670458e-04,
]
),
}
24 changes: 13 additions & 11 deletions tests/test_at_simulator_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ def test_gather_one_sample(atsim):
def test_recalculate_phys_data(atsim, initial_phys_data):
_check_initial_phys_data(atsim, initial_phys_data)
# Check that errors raised inside thread are converted to warnings.
atsim._at_lat[5].PolynomB[0] = 1.0e10
atsim._at_lat[4].PolynomB[0] = 1.0e10
atsim.queue_set(mock.Mock(), "f", 0)
with pytest.warns(at.AtWarning):
atsim.wait_for_calculations()
atsim._at_lat[5].PolynomB[0] = 0.0
atsim._at_lat[4].PolynomB[0] = 0.0
# Set corrector x_kick but on a sextupole as no correctors in test ring
atsim._at_lat[21].PolynomB[0] = -7.0e-5
atsim._at_lat[7].PolynomB[0] = -7.0e-5
# Set corrector y_kick but on a sextupole as no correctors in test ring
atsim._at_lat[21].PolynomA[0] = 7.0e-5
atsim._at_lat[7].PolynomA[0] = 7.0e-5
# Set quadrupole b1
atsim._at_lat[5].PolynomB[1] = 2.5
atsim._at_lat[4].PolynomB[1] = -0.8
# Set skew quadrupole a1
atsim._at_lat[7].PolynomA[1] = 2.25e-3
atsim._at_lat[10].PolynomA[1] = 2.25e-3
# Set sextupole b2
atsim._at_lat[21].PolynomB[2] = -75
atsim._at_lat[7].PolynomB[2] = 10
# Clear the flag and then wait for the calculations
atsim.queue_set(mock.Mock(), "f", 0)
atsim.wait_for_calculations()
Expand All @@ -164,8 +164,8 @@ def test_recalculate_phys_data(atsim, initial_phys_data):
numpy.testing.assert_almost_equal(
orbit, [5.18918914e-06, -8.92596857e-06], decimal=3
)
numpy.testing.assert_almost_equal(chrom, [0.11732846, 0.04300947], decimal=2)
numpy.testing.assert_almost_equal(tune, [0.37444833, 0.86048592], decimal=3)
numpy.testing.assert_almost_equal(chrom, [1.89, 4.64], decimal=2)
numpy.testing.assert_almost_equal(tune, [0.133, 0.307], decimal=3)
numpy.testing.assert_almost_equal(emit, [1.34308653e-10, 3.74339964e-13], decimal=3)


Expand Down Expand Up @@ -196,7 +196,8 @@ def test_toggle_calculations_and_wait_for_calculations(atsim, initial_phys_data)
assert not atsim._paused
# pause > make a change > check no calc > unpause > check calc
atsim.toggle_calculations()
atsim._at_lat[5].PolynomB[1] = 2.5
# Kick quadrupole
atsim._at_lat[4].PolynomB[1] = -0.8
atsim.queue_set(mock.Mock(), "f", 0)
assert atsim.wait_for_calculations(2) is False
_check_initial_phys_data(atsim, initial_phys_data)
Expand Down Expand Up @@ -335,7 +336,8 @@ def test_get_radiation_integrals(mocked_atsim):

def test_get_momentum_compaction(mocked_atsim, at_lattice):
numpy.testing.assert_almost_equal(
0.08196721311475409, mocked_atsim.get_momentum_compaction()
mocked_atsim.get_momentum_compaction(),
0.0045641,
)


Expand Down