Skip to content

Commit ddf5f83

Browse files
committed
Reformat example and changes to see effect of octupoles and damper on ~short timescale
1 parent 0014135 commit ddf5f83

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

examples/pyheadtail_interface/002_headtailInstability.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
context = xo.ContextCpu(omp_num_threads=1)
2323

24-
nTurn = 3000 # int(1E4)
24+
nTurn = 5000 # int(1E4)
2525
bunch_intensity = 1.8e11
26-
n_macroparticles = int(1e5) # int(1E4)
26+
n_macroparticles = int(1e4)
2727
energy = 7e3 # [GeV]
2828
gamma = energy * 1e9 / protonMass
2929
betar = np.sqrt(1 - 1 / gamma ** 2)
@@ -56,9 +56,9 @@
5656
)
5757
wake_field = WakeField(slicer_for_wakefields, waketable)
5858

59-
damping_time = 100000000 # 33.
59+
damping_time = 7000 # 33.
6060
damper = TransverseDamper(dampingrate_x=damping_time, dampingrate_y=damping_time)
61-
i_oct = 0.0000001
61+
i_oct = 15.
6262
detx_x = 1.4e5 * i_oct / 550.0 # from PTC with ATS optics, telescopic factor 1.0
6363
detx_y = -1.0e5 * i_oct / 550.0
6464

@@ -168,6 +168,7 @@
168168
iMax = nTurn
169169
ampl = np.abs(hilbert(x))
170170
b, a, r, p, stderr = linregress(turns[iMin:iMax], np.log(ampl[iMin:iMax]))
171+
gr_pyht = b
171172
plt.plot(turns, np.exp(a + b * turns), "--k", label=f"{1/b:.3E} turns")
172173
print(f"Growth rate {b*1E4} [$10^{-4}$/turn]")
173174
plt.title("PyHEADTAIL")
@@ -287,11 +288,14 @@
287288
iMax = nTurn
288289
ampl = np.abs(hilbert(x))
289290
b, a, r, p, stderr = linregress(turns[iMin:iMax], np.log(ampl[iMin:iMax]))
291+
gr_xtpyht = b
290292
plt.plot(turns, np.exp(a + b * turns), "--k", label=f"{1/b:.3E} turns")
291293
print(f"Growth rate {b*1E4} [$10^{-4}$/turn]")
292294
plt.title("xsuite-PyHEADTAIL")
293295
plt.legend(loc="upper left")
294296
plt.xlabel("Turn")
295297
plt.ylabel("x [$\sigma_x$]")
296298

299+
assert np.isclose(gr_xtpyht, gr_pyht, rtol=1e-3, atol=1e-100)
300+
297301
plt.show()

0 commit comments

Comments
 (0)