def run(dlc=None, dlc_noipc=None, SAVE=None): wsp = 18 # Load transfer functions C = make() P = BladeModel.Blade(wsp) Kps, Tis = np.meshgrid([0.01, 0.015, 0.02], [0.5, 1, 2]) fig, axes = plt.subplots(3, 3, sharex=False, sharey=False, figsize=(7, 7)) plt.subplots_adjust(wspace=0.05, hspace=0.05) for i in range(3): for j in range(3): C = make(Kp=Kps[i, j], Ti=Tis[i, j]) sys = ControlDesign.Turbine(P, C) plot_nyquist(sys.L, axes=axes[i, j], zoom=1, margin=True) perf = sys.performance(0.16)[0] axes[i, j].text(0, 0, '$f_{1p}$: ' + '{:2.2f}\%'.format(perf * 100), transform=axes[i, j].transAxes, va='bottom') fig.text(0.1, 0.5, 'Real', va='center', rotation='vertical') fig.text(0.5, 0.1, 'Imaginary', ha='center', rotation='horizontal') for i in range(3): axes[0, i].set_title(f'$K_p=${Kps[0, i]}') axes[i, 2].yaxis.set_label_position('right') axes[i, 2].set_ylabel(f'$T_i=${Tis[i, 0]}') if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print()
def run(dlc=None, dlc_noipc=None, SAVE=None): f = np.linspace(0, 1.5, 1000)[1:] Yol = OLResponse.Response(18) Ycl = Spectrum(dlc(wsp=18, controller='ipcpi')[0]) C = make() P = BladeModel.Blade(18) sys = ControlDesign.Turbine(P, C) mag = signal.bode(sys.S, w=f * (2 * np.pi))[1] actualMag = 20 * np.log10(Ycl(f) / Yol(f)) fig, ax = ControllerEvaluation.magplotSetup(F1p=0.16) ax.set_xlim(0.05, 1.5) ax.axhline(0, lw=1, c='0.8', ls='-') ax.plot(f, mag, label='$S(C_{PI})$, linear model') ax.plot(f, actualMag, '--', label='$S(C_{PI})$, HAWC2 model') ax.set_ylim(-10, 10) ax.legend(loc='upper left') if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print()
def run(dlc=None, dlc_noipc=None, SAVE=None): wsp = 18 C = make() P = BladeModel.Blade(wsp) sys = ControlDesign.Turbine(P, C) plot_nyquist(sys.L, zoom=1.5, rightticks=True, save=SAVE)
def run(dlc=None, dlc_noipc=None, SAVE=None): f = np.linspace(0, 1.5, 1000)[1:] Yol = OLResponse.Response(18) Ycl = Spectrum(dlc(wsp=18, controller='ipcpi')[0]) C = make() P = BladeModel.Blade(18) sys = ControlDesign.Turbine(P, C) mag = signal.bode(sys.S, w=f * (2 * np.pi))[1] #actualMag = 20*np.log10(Ycl(f)/Yol(f)) w, H = signal.freqresp(sys.S, n=100000) f = w / (2 * np.pi) Ycl_pred = abs(H) * Yol(f) fig, ax = ControllerEvaluation.magplotSetup(F1p=0.16) ax.set_xlim(0.05, 1.5) ax.axhline(0, lw=1, c='0.8', ls='-') ax.plot(f, Yol(f), label='Open loop') ax.plot(f, Ycl_pred, '--k', label='Closed loop (linear)') ax.plot(f, Ycl(f), 'r', label='Closed loop (HAWC2)') #ax.plot(f, mag, label='$S(C_{PI})$, linear model') #ax.plot(f, actualMag, '--', label='$S(C_{PI})$, HAWC2 model') ax.set_ylabel('Magnitude [m]') ax.set_xlim(0.05, 1.5) ax.set_ylim(0.01, 0.4) ax.set_yscale('log') ax.legend(loc='upper right') if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print()
ax.plot(f, Yol(f), label='$Y_{OL}$') ax.plot(f, Ycl_pred, '--k', label='$Y_{CL}$ (predicted)') ax.plot(f, Ycl(f), 'r', label='$Y_{CL}$ (actual)') ax.set_xlim(f.min(), 1.5) ax.set_title('wsp = {}m/s'.format(wsp)) ax.legend() if SAVE: plt.savefig( '../Figures/{}/{}_TipDeflection_Spectrum_{}.png'.format( c, c, wsp), dpi=200) plt.show() print() for f in fnp: pred = abs(signal.freqresp(system.S, f * 2 * np.pi)[1][0]) * 100 - 100 act = Ycl(f) / Yol(f) * 100 - 100 print('{:2.2f}%, {:2.2f}%'.format(pred, act)) if __name__ is '__main__': dlc_noipc = PostProc.DLC('dlc11_0') dlc = PostProc.DLC('dlc11_1') from Controllers.IPC_PI import make c = 'ipcpi' run(dlc, dlc_noipc, c, make(), SAVE=False)
def discretise(C, Fs=100, method='bilinear', save=None): # discretizes the controller transfer function and saves it to file. if method == 'bilinear': coefz = signal.bilinear(C.num, C.den, fs=Fs) elif method.lower() == 'matchedzeropole': coefz = MatchedZeroPole(C.num, C.den, 1 / Fs) Cd = signal.TransferFunction(coefz[0], coefz[1], dt=1 / Fs) return Cd if __name__ == '__main__': C = make() Cd = discretise(C, Fs=Fs) saveHTC(Cd.num, Cd.den, filename) # Calculate continuous frequency response wa, maga, phasea = signal.bode(C, n=1000) phasea = (phasea + 180) % 360 - 180 fa = wa / (2 * np.pi) # calculate discrete frequency response wd, Hd = signal.freqz(Cd.num, Cd.den, worN=1024 * 4) fd = wd / np.pi * (Fs / 2) magd, phased = 20 * np.log10(abs(Hd)), np.angle(Hd, deg=True) # plot