def getData(): f1p = 0.16 fs = f1p * np.array([1, 2, 3, 4]) X = [] P = BladeModel.Blade(wsp=18) Yol = OLResponse.Response(18) # loop over each controller for i, mod_name in enumerate(Modules): X.append({}) # load linear closed loop system module = import_module('Controllers.' + mod_name) C = module.make() sys = ControlDesign.Turbine(P, C) X[i]['sm'] = sys.sm X[i]['linear'] = list(sys.performance(f1p)) # load HAWC2 closed loop system results dlc = PostProc.DLC('dlc11_1') Sim = dlc(wsp=18, controller=ControllerName[i])[0] Ycl = Spectrum(Sim) X[i]['HAWC2'] = [Ycl(f) / Yol(f) - 1 for f in fs] return X
def run(dlc, dlc_noipc, SAVE=False): dlc = PostProc.DLC('dlc13_1') shutdownseeds = [] for seed in dlc.seeds: if seed.data.shutdown: data = seed.loadFromSel(channels={'status': 91}) print(seed, '\tshutdown status:', data.status.values[-1]) shutdownseeds.append(seed) plotShutdown(shutdownseeds[8], SAVE)
def run(SAVE=False): # Load HAWC2 result data dlc_noipc = PostProc.DLC('dlc11_0') #WSP = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26] WSP = [6, 12, 18, 24] fig, axes = plt.subplots(2, 2, sharey=True, figsize=[8, 6]) plt.subplots_adjust(wspace=0.05, hspace=0.05) for wsp, ax in zip(WSP, axes.ravel()): f, Y = OLFreqResp(wsp, dlc_noipc) f_, Y_ = OLFreqResp(wsp, dlc_noipc, smooth=True) ax.plot(f, Y, label='Mean Fourier Transform') ax.plot(f_, Y_, label='Smoothed Fourier Transform') # axis ax.set_xscale('log') ax.set_xlim(0.05, 1.5) # ticks ax.set_xticks([F1p, 2 * F1p, 3 * F1p, 4 * F1p], minor=True) ax.grid(axis='x', which='minor') # annotate ax.annotate(f'$U={wsp}m/s$', xy=(0.5, 0.96), xycoords='axes fraction', size=10, ha='center', va='top', bbox=dict(boxstyle='round', fc='w', alpha=0.0)) # axis ax.set_yscale('log') ax.set_ylim(0.001, 1) # ticks axes[0, 0].set_xticklabels([]) axes[0, 1].set_xticklabels([]) axes[1, 0].set_xticklabels(['$f_{1p}$', '$f_{2p}$', '$f_{3p}$', '$f_{4p}$'], minor=True) axes[1, 1].set_xticklabels(['$f_{1p}$', '$f_{2p}$', '$f_{3p}$', '$f_{4p}$'], minor=True) # labels fig.text(0.05, 0.5, 'Magnitude [m]', va='center', rotation='vertical') fig.text(0.5, 0.07, 'Frequency [Hz]', ha='center', rotation='horizontal') axes[1, 1].legend(loc='lower left') if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print()
def run(dlc, dlc_noipc, SAVE=False): dlc2 = PostProc.DLC('dlc11_2') _run(dlc, dlc2, dlc_noipc, 'ipcpi', 'ipc_rbmpi', SAVE=SAVE) _run(dlc, dlc2, dlc_noipc, 'ipc04', 'ipc_rbm04', SAVE=SAVE) _run(dlc, dlc2, dlc_noipc, 'ipc07', 'ipc_rbm07', SAVE=SAVE) # Lifetime equivalent load table for ipc07 keys = ['RBMf', 'MBt', 'MBy'] tableRows = ['Blade (flap)', 'Main Bearing (tilt)', 'Main Bearing (yaw)'] f = open('../Figures/Tables/Ch2_RBM_Reqlt.txt', 'w') for i, row in enumerate(keys): leqref = lifetimeReq(dlc_noipc.Sims, row) leq1 = lifetimeReq(dlc(controller='ipc07'), row) leq2 = lifetimeReq(dlc2(controller='ipc_rbm07'), row) line = tableRows[i] line += '& {:2.0f} & {:+2.2f}'.format(leq1, (leq1 / leqref - 1) * 100) line += '& {:2.0f} & {:+2.2f} \\\\\n'.format(leq2, (leq2 / leqref - 1) * 100) f.write(line) f.close()
def run(dlcs, SAVE=None): wsp = 18 seed = dlcs['dlc15_0'](wsp=wsp)[0][0] data = seed.loadFromSel(channels={'t': 1, 'tcl': 111}) t = data.t tcl = data.tcl T, valleys = lowerPeaks(t, tcl) plt.figure(figsize=[8, 4]) plt.xlabel('Time [s]') plt.ylabel('Tower clearance [m]') start = 100 #340 plt.xlim(start, start + 50) plt.plot(t, tcl.values) plt.plot(T, valleys, 'xr', label='Minimum tower clearance') plt.legend(loc='upper center') if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print() return T, valleys if __name__ is '__main__': dlcs = {'dlc15_0': PostProc.DLC('dlc15_0')} T, valleys = run(dlcs, SAVE=False)
""" Analyses the correlation between root bending moment and tip deflection """ import numpy as np import matplotlib.pyplot as plt from JaimesThesisModule import Analysis, PostProc def run(dlc_noipc, SAVE=None): pass #return X, Y, coeffs, mean if __name__ is '__main__': dlc_noipc = PostProc.DLC('dlc11_0') #%% Load rbm and td data channels = { 'RBM1': 26, 'RBM2': 29, 'RBM3': 32, 'TD1': 49, 'TD2': 52, 'TD3': 55 } WSP = np.arange(4, 27, 2) X, Y, meanX, meanY = {}, {}, {}, {} for wsp in WSP: X[wsp], Y[wsp] = [], []
# -*- coding: utf-8 -*- """ Created on Wed Jun 13 16:32:01 2018 @author: J """ import os from JaimesThesisModule import PostProc basename = 'dlc11_3' pbsindir = 'C:/JL0004/pbs_in/' dlc = PostProc.DLC(basename) filenames = os.listdir(pbsindir + basename) print(len(filenames)) assert len(dlc.seeds) == len(filenames) for seed in dlc.seeds: if not seed.data.shutdown: #os.remove(pbsindir + basename + '/' + seed.filename + '.p') #print(seed.filename, '.p deleted.') pass
axes[0, 0].legend(loc='upper left', fontsize=7, numpoints=10) N = len(azim1[0]) cb = fig.colorbar(hexPlot, ax=axes.ravel().tolist(), pad=0.02) cb.set_ticks(np.linspace(0, 2000, 6)) #based on vmin and vmax ticklabels = [ '{:1.1f}%'.format(x * 100) for x in np.linspace(0 / N, 2000 / N, 6) ] ticklabels[-1] = '$>$' + ticklabels[-1] cb.set_ticklabels(ticklabels) cb.ax.tick_params(labelsize=8) cb.set_label('Probability of Occurences', labelpad=0) if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print() if __name__ is '__main__': dlcs = { 'dlc11_0': PostProc.DLC('dlc11_0'), 'dlc11_1': PostProc.DLC('dlc11_1'), 'dlc11_3': PostProc.DLC('dlc11_3'), 'dlc15_0': PostProc.DLC('dlc15_0'), 'dlc15_1': PostProc.DLC('dlc15_1'), 'dlc15_2': PostProc.DLC('dlc15_2') } run(dlcs, SAVE=False)
# labels fig.text(0.04, 0.5, 'Flapwise Tip Deflection (blade FOR) [m]', va='center', rotation='vertical') axes[-1].set_xlabel('Azimuth Angle [deg]') # color bar N = len(X[0]) cb = fig.colorbar(hexPlot, ax=axes.ravel().tolist()) cb.set_ticks(np.linspace(0, 1300, 6)) #based on vmin and vmax cb.set_ticklabels( ['{:1.2f}%'.format(x * 100) for x in np.linspace(0 / N, 1300 / N, 6)]) cb.set_label('Probability of Occurences') axes[0].legend(['Min/Max'], loc='upper right') if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print() if __name__ is '__main__': dlc = PostProc.DLC('dlc11_1') dlc2 = PostProc.DLC('dlc11_3') plt.rc('text', usetex=True) run(dlc, dlc2, SAVE='../Figures/TTT_azim.png') plt.rc('text', usetex=False)
#ax[i, 1].yaxis.tick_right() ax[i, 0].set_ylim(-6, 6) ax[i, 1].set_ylim(-6, 6) # Plotting for i in [0, 1, 2]: # for each blade ax[i, 0].hexbin(azim, td[:, i], cmap='Blues', **hexbinConfig) ax[i, 1].hexbin(azim1, td1[:, i], cmap='Blues', **hexbinConfig) ax[i, 0].autoscale(axis='x') ax[i, 1].autoscale(axis='x') # post set up ax[2, 0].set_xticks([0, 120, 240, 360]) ax[2, 1].set_xticks([120, 240, 360]) #ax[0,0].axvline(x=45, c='w', ls='--', lw=1) ax[0, 0].set_title('Without IPC') ax[0, 1].set_title('With IPC') if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print() return td, rbm if __name__ is '__main__': dlc_noipc = PostProc.DLC('dlc15_0') dlc = PostProc.DLC('dlc15_1') td, rbm = run(dlc, dlc_noipc, SAVE=False)
def run(dlc, dlc_noipc, SAVE=False): dlc_noipc = PostProc.DLC('dlc13_0') dlc = PostProc.DLC('dlc13_1') C = ['ipcpi', 'ipc04', 'ipc07'] keys = ['RBMf', 'MBt', 'MBy'] titles = ['Blade (flapwise)', 'Main bearing (tilt)', 'Main bearing (yaw)'] labels = ['$C_{pi}$', '$C_{f1p}$', '$C_{2}$'] #WSP = np.array([4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]) WSP = np.arange(4, 27, 4) fig, axes = plt.subplots(1, 3, sharex=True, sharey=True, figsize=[10, 3]) plt.subplots_adjust(wspace=0.05) # for eack key and title, make a new bar graph. for key, title, ax in zip(keys, titles, axes.ravel()): Req_ol, Req_cl = [0] * len(WSP), np.zeros([len(C), len(WSP)]) for i, wsp in enumerate(WSP): sim_ref = dlc_noipc(wsp=wsp, yaw=0)[0] Req_ol[i] = float(sim_ref.data[key]) for j, c in enumerate(C): sim = dlc(wsp=wsp, yaw=0, controller=c)[0] Req_cl[j, i] = float(sim.data[key]) # bar graph width = 3 / (len(C) + 1) ax.set_xticks(WSP + 1) ax.set_xticklabels(WSP) ax.grid(True, axis='y') ax.set_axisbelow(True) ax.bar(WSP, Req_ol, width, label='No IPC', hatch='\\\\', fc='0.8', ec='0') for j, c in enumerate(C): ax.bar(WSP + width * (j + 1), Req_cl[j], width, label=labels[j], ec='0') ax.annotate(title, xy=(0.5, 0.97), xycoords='axes fraction', size=10, ha='center', va='top', bbox=dict(ec='w', fc='w', alpha=0.7)) # labels fig.text(0.06, 0.5, 'Equivalent Bending Moment [kNm]', va='center', rotation='vertical') fig.text(0.5, 0.01, 'Wind Speed [m/s]', ha='center', rotation='horizontal') axes.ravel()[1].legend(ncol=4, bbox_to_anchor=(1.3, 1.2)) if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show() print() # lifetime equivalent load table tableRows = ['Blade (flap)', 'Main Bearing (tilt)', 'Main Bearing (yaw)'] f = open('../Figures/Tables/Ch2_extreme_Reqlt.txt', 'w') for i, row in enumerate(keys): leqref = lifetimeReq(dlc_noipc.Sims, row) leq0 = lifetimeReq(dlc(controller='ipcpi'), row) leq1 = lifetimeReq(dlc(controller='ipc04'), row) leq2 = lifetimeReq(dlc(controller='ipc07'), row) line = tableRows[i] line += '& {:2.0f} & {:+2.2f}'.format(leq0, (leq0 / leqref - 1) * 100) line += '& {:2.0f} & {:+2.2f}'.format(leq1, (leq1 / leqref - 1) * 100) line += '& {:2.0f} & {:+2.2f} \\\\\n'.format(leq2, (leq2 / leqref - 1) * 100) f.write(line) print(line) f.close()
plt.xlabel('Minimum Tower Clearance [m]') plt.ylabel('Probability [-]') for i, sims in enumerate(Sims): tcl = [] for sim in sims: data = sim.loadFromSel(channels) tcl += lowerPeaks(data.tcl) if labels: label = labels[i] else: label = '' plt.hist(tcl, label=label, **histProps, fc=colors[i]) plt.legend() if SAVE: plt.savefig(SAVE, dpi=200, bbox_inches='tight') plt.show(); print() if __name__ is '__main__': dlcs = { 'dlc15_0':PostProc.DLC('dlc15_0'), 'dlc15_1':PostProc.DLC('dlc15_1'), 'dlc15_2':PostProc.DLC('dlc15_2')} wsp = 18 c = 'ipc07' run(dlcs, SAVE=False)
plt.ylabel('Minimum Tower Clearance [m]') sns.violinplot(x=x, y=y, hue=hue, split=True, inner='quartile') plt.legend(loc='upper left') if SAVE: plt.savefig('../Figures/InverseShear/TowerClearance_inverse.png', dpi=200) plt.show(); print() return x, y, hue if __name__ is '__main__': dlc15_0 = PostProc.DLC('dlc15_0') dlc15_0.analysis() dlc15_1 = PostProc.DLC('dlc15_1') dlc15_1.analysis() dlc11_0 = PostProc.DLC('dlc11_0') dlc11_0.analysis() dlc11_1 = PostProc.DLC('dlc11_1') dlc11_1.analysis() x, y, hue = run(dlc15_0, dlc15_1(controller='ipc07'), labels=['no control', 'Tip Disturbance Rejection Control'], SAVE=False)