def coefficient_LLT(AC, velocity, AOA): Au_P = [0.1828, 0.1179, 0.2079, 0.0850, 0.1874] Al_P = Au_P deltaz = 0 # Determine children shape coeffcients AC_u = list(data.values[i, 0:4]) Au_C, Al_C, c_C, spar_thicknesses = calculate_dependent_shape_coefficients( AC_u, psi_spars, Au_P, Al_P, deltaz, c_P, morphing=morphing_direction) # Calculate aerodynamics for that airfoil airfoil = 'optimal' x = create_x(1., distribution='linear') y = CST(x, 1., [deltaz / 2., deltaz / 2.], Al=Al_C, Au=Au_C) # Create file for Xfoil to read coordinates xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False) Data = xf.find_coefficients(airfoil, AOA, Reynolds=Reynolds(10000, velocity, c_C), iteration=100, NACA=False) deviation = 0.001 while Data['CL'] is None: Data_aft = xf.find_coefficients(airfoil, AOA * deviation, Reynolds=Reynolds( 10000, velocity, c_C), iteration=100, NACA=False) Data_fwd = xf.find_coefficients(airfoil, AOA * (1 - deviation), Reynolds=Reynolds( 10000, velocity, c_C), iteration=100, NACA=False) try: for key in Data: Data[key] = (Data_aft[key] + Data_fwd[key]) / 2. except: deviation += deviation alpha_L_0 = xf.find_alpha_L_0(airfoil, Reynolds=0, iteration=100, NACA=False) coefficients = LLT_calculator(alpha_L_0, Data['CD'], N=100, b=span, taper=1., chord_root=chord_root, alpha_root=AOA, V=velocity) lift = coefficients['C_L'] drag = coefficients['C_D'] return lift, drag
import numpy as np import matplotlib.pyplot as plt import aeropy.xfoil_module as xf from aeropy.CST.module_2D import * from aeropy.aero_module import Reynolds from aeropy.geometry.airfoil import CST, create_x # Au = [0.23993240191629417, 0.34468227138908186, 0.18125405377549103, # 0.35371349126072665, 0.2440815012119143, 0.25724974995738387] # Al = [0.18889012559339036, -0.24686758992053115, 0.077569769493868401, # -0.547827192265256, -0.0047342206759065641, -0.23994805474814629] Au = [0.172802, 0.167353, 0.130747, 0.172053, 0.112797, 0.168891] Al = Au # c_avian = 0.36 #m # deltaz = 0.0093943568219451313*c_avian c_avian = 1. deltaz = 0 airfoil = 'avian' x = create_x(1., distribution='linear') y = CST(x, 1., [deltaz / 2., deltaz / 2.], Au=Au, Al=Al) # Create file for Xfoil to read coordinates xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False) print('Reynolds: ', Reynolds(10000, 30, c_avian)) Data = xf.find_coefficients(airfoil, 0., Reynolds=Reynolds(10000, 30, c_avian), iteration=100, NACA=False) print(Data)
from aeropy.airfoil_module import CST, create_x Au = [0.23993240191629417, 0.34468227138908186, 0.18125405377549103, 0.35371349126072665, 0.2440815012119143, 0.25724974995738387] Al = [0.18889012559339036, -0.24686758992053115, 0.077569769493868401, -0.547827192265256, -0.0047342206759065641, -0.23994805474814629] c_avian = .36 #m deltaz = 0.0093943568219451313*c_avian airfoil = 'avian' x = create_x(c_avian, distribution = 'linear') y = CST(x, c_avian, [deltaz/2., deltaz/2.], Au = Au, Al= Al) # Create file for Xfoil to read coordinates xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower = False) Data = xf.find_coefficients(airfoil, 2., Reynolds=Reynolds(10000, 30, c_avian), iteration=100, NACA=False) print(Data) psi_u_inflection, psi_l_inflection = find_inflection_points(Au, Al) print('upper: ', psi_u_inflection) print('lower: ', psi_l_inflection) psi = np.linspace(0.001,0.999,100) xi = CST(psi, 1, [deltaz/2., deltaz/2.], Au, Al) plt.plot(psi, xi['u'], 'b', label = 'Upper outer mold line') plt.plot(psi, xi['l'],'b--', label = 'Lower outer mold line') xi_u_inflection = CST(psi_u_inflection, 1, [deltaz/2., deltaz/2.], Au, Al) plt.scatter(psi_u_inflection, xi_u_inflection['u']) xi_l_inflection = CST(psi_l_inflection, 1, [deltaz/2., deltaz/2.], Au, Al)
for j in range(1145, len(Au_database)): data['L/D'].append([]) print(j, airfoil_database['names'][j]) Au = Au_database[j, :] Al = Al_database[j, :] x = create_x(1., distribution = 'linear') y = CST(x, chord, deltasz=[du_database[j], dl_database[j]], Al=Al, Au=Au) xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower = False) for i in range(len(AOAs)): AOA = AOAs[i] V = velocities[i] try: Data = xf.find_coefficients(airfoil, AOA, Reynolds=Reynolds(10000, V, chord), iteration=100, NACA=False, delete=True) lift_drag_ratio = Data['CL']/Data['CD'] except: lift_drag_ratio = None increment = 0.1 conv_counter = 0 while lift_drag_ratio is None and conv_counter <3: print(increment) Data_f = xf.find_coefficients(airfoil, AOA*(1+increment), Reynolds=Reynolds(10000, V*(1+increment), chord), iteration=100, NACA=False, delete=True) Data_b = xf.find_coefficients(airfoil, AOA*(1-increment), Reynolds=Reynolds(10000, V*(1-increment), chord),
for j in range(len(Au_database)): print(j, airfoil_database['names'][j]) Au = Au_database[j, :] Al = Al_database[j, :] x = create_x(1., distribution='linear') y = CST(x, chord, deltasz=[du_database[j], dl_database[j]], Al=Al, Au=Au) xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False) for i in range(n): for k in range(n): AOA = AOAs[i][k] V = velocities[i][k] try: Data = xf.find_coefficients(airfoil, AOA, Reynolds=Reynolds(10000, V, chord), iteration=100, NACA=False, delete=True) lift_drag_ratio = Data['CL'] / Data['CD'] except: lift_drag_ratio = None increment = 0.01 conv_counter = 0 while lift_drag_ratio is None and conv_counter < 2: try: print(increment) Data_f = xf.find_coefficients(airfoil, AOA + increment, Reynolds=Reynolds( 10000, V, chord),
def aerodynamic_performance(AC, psi_spars, Au_P, Al_P, c_P, deltaz, alpha, H, V): morphing_direction = 'forwards' air_data = air_properties(H, unit='feet') density = air_data['Density'] dyn_pressure = .5 * density * V**2 # Generate dependent shape coefficients # try: Au_C, Al_C, c_C, spar_thicknesses = calculate_dependent_shape_coefficients( AC, psi_spars, Au_P, Al_P, deltaz, c_P, morphing=morphing_direction) # print 'Reynolds: ', Reynolds(H, V, c_C) # Generate aifoil file airfoil = 'test' x = create_x(1., distribution='linear', n=300) y = CST(x, 1., [deltaz / 2., deltaz / 2.], Au=Au_C, Al=Al_C) # Get strain data strains, av_strain = calculate_strains(Au_P, Al_P, c_P, Au_C, Al_C, c_C, deltaz, psi_spars, spar_thicknesses) intersections = intersect_curves(x, y['l'], x, y['u']) print(intersections, intersections[0][1:]) if len(intersections[0][1:]) == 0: # print y create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False) # Get aerodynamic data print(airfoil, alpha, Reynolds(H, V, c_C)) Data = find_coefficients(airfoil, alpha, Reynolds=Reynolds(H, V, c_C), iteration=200, NACA=False, delete=True, PANE=True, GDES=True) # plot_airfoil(AC, psi_spars, c_P, deltaz, Au_P, Al_P, image = 'save', iteration=counter, dir = airfoil+'_dir') # filtering data (for now I only care about negative strains str_output = { 'CL': Data['CL'], 'CD': Data['CD'], 'CM': Data['CM'], 'av_strain': av_strain, 'Au_C': Au_C, 'Al_C': Al_C, 'spars': psi_spars } if Data['CM'] == None: str_output['lift'] = None str_output['drag'] = None str_output['moment'] = None else: str_output['lift'] = Data['CL'] / dyn_pressure / c_C, str_output['drag'] = Data['CD'] / dyn_pressure / c_C, str_output['moment'] = Data['CM'] / dyn_pressure / c_C for i in range(len(strains)): str_output['strain_' + str(i)] = strains[i] # Writing to a text file # f_worker = open(str(airfoil) + '.txt', 'wb') # for i in range(len(key_list)): # if i != len(key_list)-1: # if key_list[i][:1] == 'Au': # f_worker.write('%f\t' % str_output[key_list[i][:1]+'_C'][int(key_list[i][-1])]) # else: # else: # if key_list[i][:1] == 'Au': # f_worker.write('%f\n' % str_output[key_list[i][:1]+'_C'][int(key_list[i][-1])]) else: str_output = { 'CL': 1000, 'CD': None, 'CM': None, 'av_strain': av_strain, 'spars': psi_spars, 'Au_C': Au_C, 'Al_C': Al_C, 'lift': None, 'drag': None, 'moment': None } for i in range(len(strains)): str_output['strain_' + str(i)] = strains[i] # except: # str_output = {'CL':None, 'CD':None, 'CM':None, 'av_strain':None, # 'Au_C':[None]*len(AC), 'Al_C': [None]*len(AC), # 'lift': None, 'drag': None, 'moment':None, # 'strains':[None]*(len(AC)-1), 'spars':psi_spars} return str_output
def aircraft_range_LLT(AC, velocity, AOA): def to_integrate(weight): # velocity = 0.514444*108 # m/s (113 KTAS) span = 10.9728 RPM = 1800 a = 0.3089 # (lb/hr)/BTU b = 0.008 * RPM + 19.607 # lb/hr lbhr_to_kgs = 0.000125998 BHP_to_watt = 745.7 eta = 0.85 thrust = weight / lift_to_drag power_SI = thrust * velocity / eta power_BHP = power_SI / BHP_to_watt mass_flow = (a * power_BHP + b) mass_flow_SI = mass_flow * lbhr_to_kgs SFC = mass_flow_SI / thrust dR = velocity / g / SFC * lift_to_drag / weight return dR * 0.001 #*0.0005399 Au_P = [0.1828, 0.1179, 0.2079, 0.0850, 0.1874] Al_P = Au_P deltaz = 0 # Determine children shape coeffcients AC_u = list(data.values[i, 0:4]) Au_C, Al_C, c_C, spar_thicknesses = calculate_dependent_shape_coefficients( AC_u, psi_spars, Au_P, Al_P, deltaz, c_P, morphing=morphing_direction) # Calculate aerodynamics for that airfoil airfoil = 'optimal' x = create_x(1., distribution='linear') y = CST(x, 1., [deltaz / 2., deltaz / 2.], Al=Al_C, Au=Au_C) # Create file for Xfoil to read coordinates xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False) Data = xf.find_coefficients(airfoil, AOA, Reynolds=Reynolds(10000, velocity, c_C), iteration=100, NACA=False) deviation = 0.001 while Data['CL'] is None: Data_aft = xf.find_coefficients(airfoil, AOA * deviation, Reynolds=Reynolds( 10000, velocity, c_C), iteration=100, NACA=False) Data_fwd = xf.find_coefficients(airfoil, AOA * (1 - deviation), Reynolds=Reynolds( 10000, velocity, c_C), iteration=100, NACA=False) try: for key in Data: Data[key] = (Data_aft[key] + Data_fwd[key]) / 2. except: deviation += deviation alpha_L_0 = xf.find_alpha_L_0(airfoil, Reynolds=0, iteration=100, NACA=False) coefficients = LLT_calculator(alpha_L_0, Data['CD'], N=100, b=span, taper=1., chord_root=chord_root, alpha_root=AOA, V=velocity) lift_to_drag = coefficients['C_L'] / coefficients['C_D'] g = 9.81 # kg/ms fuel = 56 * 6.01 * 0.4535 * g initial_weight = 1111 * g final_weight = initial_weight - fuel return scipy.integrate.quad(to_integrate, final_weight, initial_weight)[0]