def turbine_opts(args): ph1, ph2, ps1, ps2, L1, L2, AR1, AR2, dh1, dh2 = [i for i in args] phi = [ph1, ph2] psi = [ps1, ps2] Lambda = [L1, L2] dho = [dh1, dh2] AR = [AR1, AR2] eff = turbine(Po1, To1, mdot, Omega, W, t, g, phi, psi, Lambda, AR, dho, n, ptc, ain, gas)[0] return -eff
def turb_calcs(var): To1, Po1, n, phi, psi, dho, AR, a1i = [i for i in var] eff = turbine(Po1, To1, mdot, Omega, phi, psi, Lambda, AR, W * n / (n + 1), dho, n, t, g, ptc, a1i, gas)[0] return [eff, n, phi, psi, Lambda, dho, AR, a1i]
n = 2 dho = [1.22, 1.0] phi_lim = (0.1, 1.5) psi_lim = (0.4, 3.0) Lam_lim = (0, 1) AR_lim = (0.1, 5) ptc_lim = (0.7, 1.5) dh_lim = (1, 1.5) calcs = '' plot = '' save = '' save_geom = False start_time = time.time() result = turbine(Po1, To1, mdot, Omega, W, t, g, phi, psi, Lambda, AR, dho, n, ptc, ain, gas) print('Time: {} s'.format(time.time() - start_time)) print('Work = {} W'.format(result[1])) print('Efficiency = {}'.format(result[0])) print('Mass = {} kg'.format(result[2])) print('Volume = {} m^3'.format(result[3])) print('Angles: {}'.format(result[10])) print('H1s: {}'.format([i[1] for i in result[5]])) print('No. Blades = {}'.format(int(result[6]))) print('Axial force on rotor = {} N'.format(result[13])) print('Average Re = {}'.format(result[14])) # print('Cold-stat, cold-rot, warm-rot, hot-rot:', result[15]) print(result[12]) print('') if 1 == 2:
# dho = [1.0, 1.21] # # Actual parameters # phi = [0.5, 0.55] # psi = [2.2, 1.8] # Lambda = [0.19, 0.10] # AR = [1.6, 1.6] # ptc = [1.1, 1.1] # n = 2 # ain = 0 dho = [1.22, 1.0] plot = 'opt' save = '' start_time = time.time() result = turbine(Po1, To1, mdot, Omega, W, t, g, phi, psi, Lambda, AR, dho, n, ptc, ain, gas) print('Time: {} s'.format(time.time() - start_time)) print('Work = {} W'.format(result[1])) print('Efficiency = {}'.format(result[0])) print('Mass = {} kg'.format(result[2])) print('Volume = {} m^3'.format(result[3])) print('No. Blades = {}'.format(int(result[6]))) print('Axial force on rotor = {} N'.format(result[13])) print('Average Re = {}'.format(result[14])) # print('Cold-stat, cold-rot, warm-rot, hot-rot:', result[15]) To3 = result[9] loss_norm = To3 * mdot / W if plot == 'transient': H_bar = [(i[1] + i[2] + i[3]) / 3 for i in result[5]]
def update(val): """Update the plots""" # Declare the turbine data to be global global new_turbine # Get data from inputs Po1 = float(Po1box.text)*10**5 To1 = float(To1box.text) mdot = float(mdotbox.text) Omega = float(Omegabox.text)*2*np.pi/60 W = float(Wbox.text)*10**6 t = float(tbox.text)/10**3 g = float(gbox.text)/10**3 n = int(float(nbox.text)) ain = float(a0box.text) Po1box.stop_typing() To1box.stop_typing() mdotbox.stop_typing() Omegabox.stop_typing() Wbox.stop_typing() tbox.stop_typing() gbox.stop_typing() nbox.stop_typing() a0box.stop_typing() phi = [sphi1.val, sphi2.val] psi = [spsi1.val, spsi2.val] Lambda = [sLambda1.val, sLambda2.val] dho = [sdho1.val, sdho2.val] AR = [sAR1.val, sAR2.val] ptc = [sptc1.val, sptc2.val] # Recalculate turbine performance new_turbine = turbine(Po1, To1, mdot, Omega, W, t, g, phi, psi, Lambda, AR, dho, n, ptc, ain, gas) # Get new profile data data = b2b_data(new_turbine) # Update plots for i in range(max_stages): for j in range(4): blades[4*i+j].set_xdata(data[0].T[:, 4*i+j]) blades[4*i+j].set_ydata(data[1].T[:, 4*i+j]) # Update the figure Cxst1 = new_turbine[5][0][4] Cxron = new_turbine[5][-1][5] Cxmax = np.amax([i[4] for i in new_turbine[5]]) ax.set_xbound(np.amin(data[0][:4*n])-scale*2*Cxst1, np.amax(data[0][:4*n])+scale*2*Cxron) ax.set_ybound(np.amin(data[1][:4*n])-scale*Cxmax, np.amax(data[1][:4*n])+scale*Cxmax) # Update the efficiency and angle boxes eff.set_val('Efficiency: {}%'.format(np.round(100*new_turbine[0], 2))) eff.stop_typing() angle_max.set_val( 'Maximum angle: {}º'.format(np.round(new_turbine[12][1], 2))) angle_max.stop_typing() fx.set_val( 'Rotor F$_x$: {} kN'.format(np.round(0.001*new_turbine[13], 2))) fx.stop_typing() mass.set_val('Mass: {} kg'.format(np.round(new_turbine[2], 2))) mass.stop_typing() nb.set_val('No. Blades: {}'.format(int(new_turbine[6]))) nb.stop_typing() a0box.set_val(np.round(new_turbine[11][-1], 1)) # Change the colour of the angle box if needed if new_turbine[12][0]: angle_max.color = 'r' angle_max.hovercolor = 'r' else: angle_max.color = 'g' angle_max.hovercolor = 'g'
Po1_ = 145*10**5 To1_ = 950 mdot_ = 16 Omega_ = 6782*2*np.pi/60 W_ = 17*10**6 t_ = 0.0003 g_ = 0.0003 phi_ = 0.4 psi_ = 1 Lambda_ = 0.5 AR_ = 1 dho_ = 1 n_ = 10 ptc_ = 1 ain_ = 0 init_turbine = turbine(Po1_, To1_, mdot_, Omega_, W_, t_, g_, phi_, psi_, Lambda_, AR_, dho_, n_, ptc_, ain_) new_turbine = init_turbine def b2b_data(turbine_data): """Return blade-to-blade profiles for the whole turbine""" # Extract values from the turbine function output angs = [[i[0], i[1], i[2], i[4]] for i in turbine_data[10]] chords = [[i[4], i[5]] for i in turbine_data[5]] ptcs = [[i[6], i[7]] for i in turbine_data[5]] tTE = turbine_data[11][5] n = turbine_data[11][12] # Number of points per blade plot point = 200 TE_point = 50