diff --git a/pyproject.toml b/pyproject.toml index 673d0d0..8ddfdba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/src/atip/rings/DBA.mat b/src/atip/rings/DBA.mat deleted file mode 100755 index 77f0087..0000000 Binary files a/src/atip/rings/DBA.mat and /dev/null differ diff --git a/src/atip/rings/DIAD.mat b/src/atip/rings/DIAD.mat index 4ca2c65..a424136 100644 Binary files a/src/atip/rings/DIAD.mat and b/src/atip/rings/DIAD.mat differ diff --git a/src/atip/rings/DIAMOND2SP.lat b/src/atip/rings/DIAMOND2SP.lat deleted file mode 100644 index 9cb2286..0000000 --- a/src/atip/rings/DIAMOND2SP.lat +++ /dev/null @@ -1,230 +0,0 @@ -{c:\users\bs36\desktop\jb-04-30-05\m-h6ba-17e-79pm-01-01-02_sym_oct.opa} - -{opa to tracy-2 export} - -define lattice; -energy = 3.500000; -dp = 1.0d-10; codeps = 1.0d-6; dk = 1.0d-6; -meth = 4; nbend = 10; nquad = 10; -f = 499501358.3498094; -sp_f = 2.997008150098844e9; - -{----- variables ----------------------------------------------------} - -nsext = 2; -aban1 = 0.24303148; -aban3 = -0*0.33772927; -aban4 = 0.31853103; -rk1 = 5.26028347; -rk2 = -3.62182625; -rk3 = 6.12183082; -rk4 = 6.22723242; - -{----- table of elements ----------------------------------------------------} - -cav: Cavity, L = 0.0, Frequency = 2.997008150098844e9, Voltage = 2.2e6, - harnum=934, phi = 0.0; - -dmult : drift, l = 0.045000; -dmult1 : drift, l = 0.000000; -dcor : drift, l = 0.000000; -dcor1 : drift, l = 0.040000; -dr_01 : drift, l = 2.521350; -dr_02 : drift, l = 0.075000; -dr_03 : drift, l = 0.075000; -dr_04 : drift, l = 0.150000; -dr_05 : drift, l = 0.075000; -dr_06 : drift, l = 0.075000; -dr_07 : drift, l = 0.075000; -dr_08 : drift, l = 0.075000; -dr_09 : drift, l = 0.330500; -dr_091 : drift, l = 0.120000; -dr_092 : drift, l = 0.210500; -dr_10 : drift, l = 0.075000; -dr_11 : drift, l = 0.075000; -dr_12 : drift, l = 0.075000; -dr_13 : drift, l = 0.165500; -dr_14 : drift, l = 0.075000; -dr_15 : drift, l = 0.075000; -dr_16 : drift, l = 0.075000; -dr_17 : drift, l = 0.100000; -dr_18 : drift, l = 0.080000; -dr_19 : drift, l = 0.197000; -dr_20 : drift, l = 0.090000; -dr_21 : drift, l = 0.090000; -dr_22 : drift, l = 0.075000; -dr_23 : drift, l = 0.075000; -dr_24 : drift, l = 1.384200; -dl_27 : drift, l = 3.696350; -dl_26 : drift, l = 0.075000; -dl_25 : drift, l = 0.035000; -dl_24 : drift, l = 0.035000; -dl_23 : drift, l = 0.075000; -dl_22 : drift, l = 0.075000; -dl_21 : drift, l = 0.075000; -dl_20 : drift, l = 0.075000; -dl_19 : drift, l = 0.075000; -dl_18 : drift, l = 0.075000; -dl_17 : drift, l = 0.075000; -dl_161 : drift, l = 0.120000; -dl_162 : drift, l = 0.210500; -dl_15 : drift, l = 0.075000; -dl_14 : drift, l = 0.075000; -dl_13 : drift, l = 0.075000; -dl_12 : drift, l = 0.165500; -dl_11 : drift, l = 0.075000; -dl_10 : drift, l = 0.075000; -dl_09 : drift, l = 0.075000; -dl_08 : drift, l = 0.100000; -dl_07 : drift, l = 0.080000; -dl_06 : drift, l = 0.197000; -dl_05 : drift, l = 0.090000; -dl_04 : drift, l = 0.090000; -dl_03 : drift, l = 0.075000; -dl_02 : drift, l = 0.075000; -dl_01 : drift, l = 1.384200; - -b_t : marker; -ms : marker; -ss : marker; -ls : marker; - -dl1a_1: bending, l = 0.20000000, - t = 0.32969999, t1 = 0.00000000, t2 = 0.32969999, k = -0.12411107, - n = nbend, method = 4; -dl1a_2: bending, l = 0.20000000, - t = 0.37951415, t1 = -0.32969999, t2 = 0.70921414, k = -0.12411107, - n = nbend, method = 4; -dl1a_3: bending, l = 0.20000000, - t = 0.44430484, t1 = -0.37951415, t2 = 1.15351899, k = -0.12411107, - n = nbend, method = 4; -dl1a_4: bending, l = 0.20000000, - t = 0.54929318, t1 = -0.44430484, t2 = 1.70281217, k = -0.12411107, - n = nbend, method = 4; -dl1a_5: bending, l = 0.20000000, - t = 0.83989144, t1 = -0.54929318, t2 = 2.54270361, k = -0.12411107, - n = nbend, method = 4; -dl2a_1: bending, l = 0.16667000, - t = 0.37529392, t1 = 0.00000000, t2 = 0.37529392, k = -0.57541761, - n = nbend, method = 4; -dl2a_2: bending, l = 0.16667000, - t = 0.43199684, t1 = -0.37529392, t2 = 0.80729076, k = -0.57541761, - n = nbend, method = 4; -dl2a_3: bending, l = 0.33334000, - t = 0.50574738, t1 = -0.43199684, t2 = 1.31303814, k = -0.57541761, - n = nbend, method = 4; -dl2a_4: bending, l = 0.16667000, - t = 0.62525447, t1 = -0.50574738, t2 = 1.93829261, k = -0.57541761, - n = nbend, method = 4; -dl2a_5: bending, l = 0.16667000, - t = 0.95603931, t1 = -0.62525447, t2 = 2.89433192, k = -0.57541761, - n = nbend, method = 4; - -qf4: bending, l = 0.15000000, - t = -0.28922341, t1 = -0.14461171, t2 = -0.14461171, k = 4.58473041, - n = nbend, method = 4; -qf8: bending, l = 0.25000000, - t = -0.20559380, t1 = -0.10279690, t2 = -0.10279690, k = 6.65707774, - n = nbend, method = 4; -dq1: bending, l = 0.87000000, - t = 2.84700510, t1 = 1.42350255, t2 = 1.42350255, k = -2.80820067, - n = nbend, method = 4; - -qf1: quadrupole, l = 0.15000000, k = 10.24316352, n = nquad, method = 4; -qd2: quadrupole, l = 0.15000000, k = -6.81087771, n = nquad, method = 4; -qd3: quadrupole, l = 0.15000000, k = -2.33804938, n = nquad, method = 4; -qd5: quadrupole, l = 0.10500000, k = -3.17820036, n = nquad, method = 4; -qf6: quadrupole, l = 0.36000000, k = 7.44415301, n = nquad, method = 4; -qd3_c1: quadrupole, l = 0.15000000, k = -2.35079416, n = nquad, method = 4; -qf1_c1: quadrupole, l = 0.18500000, k = -4.54825797, n = nquad, method = 4; -qd2_c1: quadrupole, l = 0.10500000, k = -1.65796511, n = nquad, method = 4; -quad_add: quadrupole, l = 0.18500000, k = 7.03286724, n = nquad, method = 4; - -{ [+,-,-,-] } -sf1 : sextupole, l = 0.14000, k = 1.74437e+02, n = nsext, Method = Meth; -sd1 : sextupole, l = 0.14000, k = -2.18565e+02, n = nsext, Method = Meth; -sd2 : sextupole, l = 0.14000, k = -1.42631e+02, n = nsext, Method = Meth; -s : sextupole, l = 0.10000, k = 0.000000, n = 1, method=meth; -sh2 : sextupole, l = 0.10000, k = 0.000000, n = 1, method=meth; - -sh1a : sextupole, l = 0.10000, k = 0.000000, n = 1, method=meth; -sh1b : sextupole, l = 0.10000, k = 0.000000, n = 1, method=meth; - -of1 : multipole, l = 0.0;{, hom = (4, 0.0, 0);} - -bpm_01 : beam position monitor; -bpm_02 : beam position monitor; -bpm_03 : beam position monitor; -bpm_04 : beam position monitor; -bpm_05 : beam position monitor; -bpm_06 : beam position monitor; -bpm_07 : beam position monitor; -bpm_08 : beam position monitor; -bpm_09 : beam position monitor; -bpm_10 : beam position monitor; -bpm_11 : beam position monitor; - -ch_01 : corrector, horizontal; -ch_02 : corrector, horizontal; -ch_03 : corrector, horizontal; -ch_04 : corrector, horizontal; -ch_05 : corrector, horizontal; -ch_06 : corrector, horizontal; -ch_07 : corrector, horizontal; -ch_08 : corrector, horizontal; -ch_09 : corrector, horizontal; -ch_10 : corrector, horizontal; -ch_11 : corrector, horizontal; - -cv_01 : corrector, vertical; -cv_02 : corrector, vertical; -cv_03 : corrector, vertical; -cv_04 : corrector, vertical; -cv_05 : corrector, vertical; -cv_06 : corrector, vertical; -cv_07 : corrector, vertical; -cv_08 : corrector, vertical; -cv_09 : corrector, vertical; -cv_10 : corrector, vertical; -cv_11 : corrector, vertical; - -{----- table of segments ----------------------------------------------------} - -dl1a : dl1a_5, dl1a_4, dl1a_3, dl1a_2, dl1a_1; -dl2a : dl2a_5, dl2a_4, dl2a_3, dl2a_2, dl2a_1; -of1s : dmult, of1, dmult; -arca_c2r : dr_24, bpm_05, dr_23, ch_05, cv_05, sh2, dr_22, qf8, - dr_21, dq1, dr_20, qf6, dr_19, bpm_04, dr_18, dcor, s, ch_04, cv_04, - dcor, dr_17, dl2a, dr_16, qd5, dr_15, sd2, ch_03, cv_03, dr_14, - bpm_03, dr_13, of1s, dr_12, qf4, dr_11, sf1, dr_10, qf4, dr_091, - of1, dr_092, bpm_02, dr_08, ch_02, cv_02, sd1, dr_07, qd3, dr_06, - inv(dl1a), dr_05, qd2, dr_04, ch_01, cv_01, sh1b, dr_03, qf1, dr_02, - bpm_01, dr_01; -arca_c1r : dl_01, bpm_06, dl_02, ch_06, cv_06, sh2, dl_03, qf8, - dl_04, dq1, dl_05, qf6, dl_06, bpm_07, dl_07, dcor, s, ch_07, cv_07, - dcor, dl_08, dl2a, dl_09, qd5, dl_10, sd2, ch_08, cv_08, dl_11, - bpm_08, dl_12, of1s, dl_13, qf4, dl_14, sf1, dl_15, qf4, dl_161, - of1, dl_162, bpm_09, dl_17, ch_09, cv_09, sd1, dl_18, qd3_c1, dl_19, - inv(dl1a), dl_20, qd2_c1, dl_21, bpm_10, dl_22, ch_10, cv_10, sh1a, - dl_23, qf1_c1, dl_24, dcor1, ch_11, cv_11, dcor1, dl_25, quad_add, - dl_26, bpm_11, dl_27; -arca_c2 : ms, arca_c2r, ss, b_t, inv(arca_c2r); -arca_c1 : arca_c2r, ms, inv(arca_c1r); -sp_short : ls, inv(arca_c1r), 2*arca_c2, arca_c1r, ls; -sp : ls, b_t, inv(arca_c1r), 3*arca_c2, arca_c1r, b_t, ls; - -{line: ss, inv(arca_c2r), ms, arca_c2r, ss;} -{line: ms, arca_c1r, ls;} -{line: ms, arca_c1r, ls, inv(arca_c1r), ms;} -{line: ss, inv(arca_c1), arca_c1, ss;} -{line: sp_short;} -line: sp; -{line: 6*sp;} - -ring: 1*line, cav; - -cell: ring, symmetry=1; - -end; - -{c:\users\bs36\desktop\jb-04-30-05\m-h6ba-17e-79pm-01-01-02_sym_oct.opa} diff --git a/src/atip/rings/HMBA.mat b/src/atip/rings/HMBA.mat deleted file mode 100644 index 4854678..0000000 Binary files a/src/atip/rings/HMBA.mat and /dev/null differ diff --git a/src/atip/rings/I04.mat b/src/atip/rings/I04.mat index 3ffaddd..df9b1cc 100644 Binary files a/src/atip/rings/I04.mat and b/src/atip/rings/I04.mat differ diff --git a/src/atip/rings/VMX.mat b/src/atip/rings/VMX.mat deleted file mode 100644 index 8dd904f..0000000 Binary files a/src/atip/rings/VMX.mat and /dev/null differ diff --git a/src/atip/rings/VMXSP.mat b/src/atip/rings/VMXSP.mat deleted file mode 100644 index 8b07be2..0000000 Binary files a/src/atip/rings/VMXSP.mat and /dev/null differ diff --git a/src/atip/rings/VMXSP_WIG.mat b/src/atip/rings/VMXSP_WIG.mat deleted file mode 100644 index 9079473..0000000 Binary files a/src/atip/rings/VMXSP_WIG.mat and /dev/null differ diff --git a/src/atip/rings/VMX_WIG.mat b/src/atip/rings/VMX_WIG.mat deleted file mode 100644 index da18bf2..0000000 Binary files a/src/atip/rings/VMX_WIG.mat and /dev/null differ diff --git a/tests/conftest.py b/tests/conftest.py index af87d65..b898298 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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") @@ -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, ] ), } diff --git a/tests/test_at_simulator_object.py b/tests/test_at_simulator_object.py index 9861cc8..6f8dbe6 100644 --- a/tests/test_at_simulator_object.py +++ b/tests/test_at_simulator_object.py @@ -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() @@ -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) @@ -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) @@ -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, )