Skip to content

Commit 6ed4624

Browse files
author
Guido Sterbini
committed
To adapt to the new xsuite interface
1 parent 18dcc48 commit 6ed4624

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

python_examples/hl_lhc_collisions_python/checks_and_doc/t005_check_crabs.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,43 +142,47 @@ def prepare_line(path, input_type):
142142
z_slices = s_rel * 2.0
143143
partco = xp.build_particles(particle_on_co=partco, mode='shift', zeta=z_slices)
144144

145+
tracker=xt.Tracker(line=ltest)
146+
tracker.track(partco, turn_by_turn_monitor='ONE_TURN_EBE')
147+
first_turn = tracker.record_last_track
145148

146-
list_co = ltest.slow_track_elem_by_elem(partco)
147-
list_co2 = ltest.slow_track_elem_by_elem(partco)
149+
tracker.track(partco, turn_by_turn_monitor='ONE_TURN_EBE')
150+
second_turn = tracker.record_last_track
148151

149152
plt.figure(2)
150153
axcox = plt.subplot(2,1,1)
151154
axcoy = plt.subplot(2,1,2, sharex=axcox)
152155
plt.suptitle('Check closed orbit 2 turns')
153-
axcox.plot([pp.s[iho] for pp in list_co], [pp.x[iho] for pp in list_co])
154-
axcox.plot([pp.s[iho] for pp in list_co], [pp.x[iho] for pp in list_co2])
156+
axcox.plot(first_turn.s[iho,:] , first_turn.x[iho,:])
157+
axcox.plot(second_turn.s[iho,:] , second_turn.x[iho,:])
155158

156-
axcoy.plot([pp.s[iho] for pp in list_co], [pp.y[iho] for pp in list_co])
157-
axcoy.plot([pp.s[iho] for pp in list_co], [pp.y[iho] for pp in list_co2])
159+
axcoy.plot(first_turn.s[iho,:] , first_turn.y[iho,:])
160+
axcoy.plot(second_turn.s[iho,:] , second_turn.y[iho,:])
158161

159162
plt.figure(20)
160163
axcopx = plt.subplot(2,1,1, sharex=axcox)
161164
axcopy = plt.subplot(2,1,2, sharex=axcox)
162165
plt.suptitle('Check closed orbit 2 turns')
163-
axcopx.plot([pp.s[iho] for pp in list_co], [pp.px[iho] for pp in list_co])
164-
axcopx.plot([pp.s[iho] for pp in list_co], [pp.px[iho] for pp in list_co2])
166+
axcopx.plot(first_turn.s[iho,:] , first_turn.px[iho,:])
167+
axcopx.plot(second_turn.s[iho,:] , second_turn.px[iho,:])
165168

166-
axcopy.plot([pp.s[iho] for pp in list_co], [pp.py[iho] for pp in list_co])
167-
axcopy.plot([pp.s[iho] for pp in list_co], [pp.py[iho] for pp in list_co2])
169+
axcopy.plot(first_turn.s[iho,:] , first_turn.py[iho,:])
170+
axcopy.plot(second_turn.s[iho,:] , second_turn.py[iho,:])
168171

169172
plt.figure(3)
170173
axcox = plt.subplot(2,1,1)
171174
axcoy = plt.subplot(2,1,2, sharex=axcox)
172175
plt.suptitle('Check crab')
173176
for iz, zz in enumerate(z_slices):
174-
axcox.plot([pp.s[iz] for pp in list_co], [pp.x[iz] for pp in list_co])
175-
axcoy.plot([pp.s[iz] for pp in list_co], [pp.y[iz] for pp in list_co])
177+
axcox.plot(first_turn.s[iz,:] , first_turn.x[iz,:])
178+
axcoy.plot(first_turn.s[iz,:] , first_turn.y[iz,:])
176179

177180
# For each s_lens, we find the transverse position of the weak beam slice
178181
# that collides with the sycnhronous particle of the strong
179182
r_lenses = []
180183
for ibb, bb in enumerate(bb_elems):
181-
r_lenses.append(getattr(list_co[bb_index[ibb]], plane)[ibb])
184+
#r_lenses.append(getattr(list_co[bb_index[ibb]], plane)[ibb])
185+
r_lenses.append(getattr(first_turn, plane)[ibb, bb_index[ibb]])
182186

183187
axcrab.plot(s_rel, r_lenses, 'o', color='b', alpha=.5, label= 'weak xsuite')
184188
Rw_crab = phi_c_weak * L_lhc / (2*np.pi*h_cc) *np.sin(2*np.pi*h_cc/L_lhc*2*s_rel)
@@ -229,9 +233,10 @@ def prepare_line(path, input_type):
229233
px = 0*z_test + np.array([0, px_twiss[0]]),
230234
py = 0*z_test + np.array([0, py_twiss[0]]),
231235
delta = 0*z_test)
232-
list_track = ltest.slow_track_elem_by_elem(part)
236+
tracker.track(part, turn_by_turn_monitor='ONE_TURN_EBE')
237+
mon = tracker.record_last_track
233238

234-
axcbx.plot([pp.s[0] for pp in list_track], [pp.x[1] - pp.x[0] for pp in list_track])
235-
axcby.plot([pp.s[0] for pp in list_track], [pp.y[1] - pp.y[0] for pp in list_track])
239+
axcbx.plot(mon.s[0, :], mon.x[1, :] - mon.x[0, :])
240+
axcby.plot(mon.s[0, :], mon.y[1, :] - mon.y[0, :])
236241

237242
plt.show()

0 commit comments

Comments
 (0)