1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| vc2 = np.zeros(simN, dtype = complex) vaff = np.zeros(simN, dtype = complex)
for pul_id in range(10): print('Simulate pulse {}'.format(pul_id))
state_rf = np.matrix(np.zeros(Brfd.shape), dtype = complex) state_bm = np.matrix(np.zeros(Bbmd.shape), dtype = complex)
for i in range(simN): status, vc2[i], _, state_rf, state_bm = sim_ncav_step(Arfd, Brfd, Crfd, Drfd, vaff[i], state_rf, Abmd = Abmd, Bbmd = Bbmd, Cbmd = Cbmd, Dbmd = Dbmd,
vb_step = vb[i], state_bm0 = state_bm) vff_cor = AFF_ilc(vc_sp[:M] - vc2[:M], L) vaff[:M] = vaff[:M] + vff_cor
plt.figure(); plt.subplot(2,1,1) plt.plot(T, np.abs(vc_sp), label = 'Setpoint') plt.plot(T, np.abs(vc1), '--', label = 'Feedforward response') plt.plot(T, np.abs(vc2), '-.', label = 'AFF response') plt.plot(T, np.abs(vaff), ':', label = 'AFF drive') plt.legend() plt.grid() plt.xlabel('Time (s)') plt.ylabel('Amplitude') plt.subplot(2,1,2) plt.plot(T, np.angle(vc_sp,deg = True), label = 'Setpoint') plt.plot(T, np.angle(vc1, deg = True), '--', label = 'Feedforward response') plt.plot(T, np.angle(vc2, deg = True), '-.', label = 'AFF response') plt.plot(T, np.angle(vaff, deg = True), ':', label = 'AFF drive') plt.legend() plt.grid() plt.xlabel('Time (s)') plt.ylabel('Phase (deg)') plt.show(block = False)
|