fuel = 56*6.01*0.4535*g initial_weight = 1111*g final_weight = initial_weight-fuel x = np.linspace(final_weight, initial_weight, 100) y = [] for x_i in x: y.append(to_integrate(x_i)[0]) range = scipy.integrate.simps(y, x) return range # ============================================================================== # Inputs # ============================================================================== altitude = 10000 # ft air_props = air_properties(altitude, unit='feet') density = air_props['Density'] # data = pandas.read_csv('performance_grid.csv') # psi_spars = [0.1, 0.3, 0.6, 0.8] # c_P = 1.0 # ranges = [] # for i in range(len(data.values)): # AC = data.values[i,0:4] # velocity = data.values[i,-4] # AOA = data.values[i,-5] # cl= data.values[i,-3] # cd = data.values[i,-2] # CL, CD = coefficient_LLT(AC, velocity, AOA)
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