import practised_ultimate as pu import Airfoil_inertia as ai print("------- Starting on shear calculation -------") boom_area = pu.boom_area_all[0] I_zz, I_yy, I_yz = pu.I_zz_sections, pu.I_yy_wing, pu.I_yz_wing #print("The boom area", boom_area) data_z_all_sec, data_y_upper_all_sec, data_y_lower_all_sec = ag.airfoil_geometry( pu.N, pu.b, pu.calc_chord, pu.X_root) airfoil_area, z_c_airfoil, y_c_airfoil = cw.get_skin_centroid( pu.N, pu.b, pu.calc_chord, pu.dx) z_centroid_all_sec, y_centroid_all_sec, y_loc_spar_up, y_loc_spar_low, y_loc_stiff_up, y_loc_stiff_low, y_vertical_spar, z_loc_stiff_up, spar_loc_sec, z_loc_stiff_low, spar_areas_verti = cw.wing_centroid( boom_area, cw.spar_areas_hori, cw.t_spar_v, z_c_airfoil, y_c_airfoil, cw.n_stiff_up, cw.n_stiff_low, pu.N, pu.b, pu.calc_chord, pu.X_root, pu.dx) s_all_sec, ds_all_sec = ai.s_airfoil(pu.N, pu.b, pu.calc_chord, pu.X_root) boom_loc_y = np.zeros((len(y_loc_spar_up), len(y_loc_stiff_up[0]) * 2 + 4)) boom_loc_z = np.zeros((len(y_loc_spar_up), len(y_loc_stiff_up[0]) * 2 + 4)) for i in range(len(y_loc_spar_up)): for j in range(len(y_loc_stiff_up[0])): boom_loc_y[i][j] = -(y_loc_stiff_up[i][j] - y_centroid_all_sec[i]) boom_loc_z[i][j] = z_loc_stiff_up[i][j] - z_centroid_all_sec[i] boom_loc_y[i][j + 1] = -(y_loc_spar_up[i][1] - y_centroid_all_sec[i]) boom_loc_z[i][j + 1] = 0.55 * data_z_all_sec[i][-1] - z_centroid_all_sec[i]
def wing_price_weight(A_req_P, A_req_B, density, cost, N, t_skin, b, qcsweep, dx): Max_area, strut_volume, strut_mass, cost_strut = strut_cost( A_req_P, A_req_B, density, cost) airfoil_area, z_c_airfoil, y_c_airfoil = cw.get_skin_centroid( N, b, prac.calc_chord, dx) boom_area = prac.boom_area_all print("boom area", boom_area) X_root = np.arange(0, (b / 2) + dx, dx) spar_areas_verti = cw.wing_centroid(boom_area, cw.spar_areas_hori, cw.t_spar_v, z_c_airfoil, y_c_airfoil, cw.n_stiff_up, cw.n_stiff_low, N, b, prac.calc_chord, X_root, dx)[10] spar_areas_hori = cw.spar_areas_hori nr_stiff = cw.n_stiff_low + cw.n_stiff_up Sweep_LE = m.atan( m.tan(qcsweep) - 4 / prac.AR * (-0.25 * (1 - prac.taper) / (1 + prac.taper))) # rad # print(spar_areas_verti[0]) # print(spar_areas_hori) # print(spar_areas_hori) # print(spar_areas_verti[0]) # print(spar_areas_verti[1]) # print(len(spar_areas_verti[0])) total_spar_volume = 0 for i in range(len(spar_areas_verti)): spar_volume = 0 for j in range(len(spar_areas_verti[0])): spar_volume += (spar_areas_verti[i][j] + spar_areas_hori[j] * 2) total_spar_volume += spar_volume * prac.dx total_boom_volume = np.zeros(len(prac.A_S_L)) for i in range(len(prac.A_S_L)): if boom_area > 0: total_boom_volume[i] = (boom_area * nr_stiff) * (b / 2) / np.cos(Sweep_LE) else: total_boom_volume[i] = 0 # print("boom_area", boom_area) boom_mass = total_boom_volume * density boom_cost = boom_mass * cost skin_volume = np.zeros(len(prac.X_root)) for i in range(len(prac.X_root) - 1): skin_volume[i] = ai.s_airfoil(N, b, prac.calc_chord, X_root)[0][i] * prac.dx * t_skin # print(skin_volume) skin_mass = sum(skin_volume) * density skin_price = skin_mass * cost spar_mass = total_spar_volume * density spar_price = spar_mass * cost total_price = np.zeros(len(prac.A_S_L)) total_mass = np.zeros(len(prac.A_S_L)) # print(spar_length, spar_volume, spar_mass, total_spar_area) # print(skin_price, spar_price) for i in range(len(prac.A_S_L)): total_price[i] = ( skin_price + spar_price) * 2 + cost_strut[i] * 2 + boom_cost[i] * 2 total_mass[i] = (skin_mass + spar_mass) * 2 + strut_mass[i] * 2 + boom_mass[i] * 2 return skin_mass, spar_mass, boom_mass, total_mass, total_price, boom_cost
def wing_stress(b, Mz, My, X_root): # l_spar_h, t_spar_v, t_spar_h = cw.l_spar_h, cw.t_spar_v, cw.t_spar_h N = prac.L_wing / prac.dx # I_zz_spar, I_yy_spar, I_yz_spar = ai.I_zz_spars(l_spar_h, t_spar_v, t_spar_h, N, b ,prac.calc_chord,prac.boom_area_all) # I_zz_req = pr.required_Izz(N, b, prac.calc_chord, Mz) # airfoil_area, z_c_airfoil, y_c_airfoil = cw.get_skin_centroid( N, b, prac.calc_chord, prac.dx, cw.t_skin) z_centroid_all_sec, y_centroid_all_sec, y_loc_spar_up, y_loc_spar_low, y_loc_stiff_up, y_loc_stiff_low, y_vertical_spar, z_loc_stiff_up, spar_loc_sec, z_loc_stiff_low, spar_areas_verti = cw.wing_centroid( prac.boom_area_new, cw.spar_areas_hori, cw.t_spar_v, z_c_airfoil, y_c_airfoil, cw.n_stiff_up, cw.n_stiff_low, N, b, prac.calc_chord, X_root, prac.dx) # print("the used boom area") # print(prac.boom_area_all[0]) # print(z_centroid_all_sec) # boom_area = ai.wing_geometry(I_zz_req, I_zz_spar, N, b, prac.calc_chord)[0][0] # I_zz_wing, I_yy_wing, I_yz_wing = ai.inertia_wing(I_zz_spar, I_yy_spar, I_yz_spar, boom_area, N, b, prac.calc_chord) I_yy_wing = prac.I_yy_wing I_zz_wing = prac.I_zz_sections I_yz_wing = prac.I_yz_wing # I_yy_wing = inertia_wing(I_zz_spar, I_yy_spar, I_yz_spar, boom_area, N, b, c) # I_zz_wing = inertia_wing(I_zz_spar, I_yy_spar, I_yz_spar, boom_area, N, b, c) # I_zy_wing = inertia_wing(I_zz_spar, I_yy_spar, I_yz_spar, boom_area, N, b, c) # # z_centroid = wing_centroid(boom_area, spar_areas_hori, t_spar_v, z_c_airfoil, y_c_airfoil, n_stiff_up, n_stiff_low, N, b, c) # y_centroid = wing_centroid(boom_area, spar_areas_hori, t_spar_v, z_c_airfoil, y_c_airfoil, n_stiff_up, n_stiff_low, N, b, c) # Mz_wing = Mz My_wing = My z_nodes = airfoil_geometry(N, b, prac.calc_chord, X_root)[0] #adapt to centroid y_up_nodes = airfoil_geometry(N, b, prac.calc_chord, X_root)[1] #adapt y_low_nodes = airfoil_geometry(N, b, prac.calc_chord, X_root)[2] local_stress_up = np.zeros((len(X_root), len(z_nodes[0]))) local_stress_low = np.zeros((len(X_root), len(z_nodes[0]))) z = np.zeros((len(X_root), len(z_nodes[0]))) y_up = np.zeros((len(X_root), len(y_up_nodes[0]))) y_low = np.zeros((len(X_root), len(y_low_nodes[0]))) # print(z_nodes) # print(y_up_nodes[0]) for i in range(len(X_root)): for j in range(len(z_nodes[0])): z[i][j] = z_nodes[i][j] - z_centroid_all_sec[i] y_up[i][j] = -(y_up_nodes[i][j] - y_centroid_all_sec[i]) y_low[i][j] = (y_centroid_all_sec[i] - y_low_nodes[i][j]) local_stress_up[i][j] = ( ((-1) * My_wing[i] * I_zz_wing[i] + (-1) * Mz_wing[i] * I_yz_wing[i]) * z[i][j] + (Mz_wing[i] * I_yy_wing[i] + My_wing[i] * I_yz_wing[i]) * y_up[i][j]) / (I_zz_wing[i] * I_yy_wing[i] - I_yz_wing[i]**2) local_stress_low[i][j] = ( ((-1) * My_wing[i] * I_zz_wing[i] + (-1) * Mz_wing[i] * I_yz_wing[i]) * z[i][j] + (Mz_wing[i] * I_yy_wing[i] + My_wing[i] * I_yz_wing[i]) * y_low[i][j]) / (I_zz_wing[i] * I_yy_wing[i] - I_yz_wing[i]**2) # print(I_zz_wing) return z, local_stress_up, local_stress_low
# print(abs(boom_area_new - boom_area_old) ) z = 0 while abs(boom_area_new[0] - boom_area_old[0]) > 1 / 100000 or z < 5: # print(abs(boom_area_new - boom_area_old) ) print("New iteration", z) boom_area_old = boom_area_new # boom_area_all = 0.0045 I_zz_spar, I_yy_spar, I_yz_spar = ai.I_zz_spars(l_spar_h, t_spar_v, t_spar_h, N, b ,calc_chord, boom_area_old, X_root, dx) I_zz_req = pr.required_Izz(N, b, calc_chord, Mz_dist[idx], boom_area_old, X_root, dx) boom_area_new = ai.wing_geometry(I_zz_req, I_zz_spar, N, b, calc_chord, boom_area_old,X_root, dx) airfoil_area, z_c_airfoil, y_c_airfoil = cw.get_skin_centroid(N, b, calc_chord,dx, cw.t_skin) z_centroid_all_sec, y_centroid_all_sec, y_loc_spar_up, y_loc_spar_low, y_loc_stiff_up, y_loc_stiff_low, y_vertical_spar, z_loc_stiff_up, spar_loc_sec, z_loc_stiff_low, spar_areas_verti = cw.wing_centroid(boom_area_new, cw.spar_areas_hori, cw.t_spar_v, z_c_airfoil, y_c_airfoil, cw.n_stiff_up, cw.n_stiff_low, N, b, calc_chord, X_root, dx) # # # # print("I_zz_req",I_zz_req) # boom_area = boom_area_new # boom_area_all[idx] = max(boom_area_new) * 10000 print("Updated boom area for strut pos" + str(A_S_L[idx])) # print(max(boom_area_new) * 10000) # print() ## I_zz_sections, I_yy_wing, I_yz_wing = ai.inertia_wing(I_zz_spar, I_yy_spar, I_yz_spar, boom_area_new, N, b, calc_chord, X_root, dx) # # print("I_zz_sections",I_zz_sections)
def required_Izz(N, b, c, Mz, boom_area, X_root, dx): data_y_all_sec_up = airfoil_geometry(N, b, c, X_root)[1] data_y_all_sec_low = airfoil_geometry(N, b, c, X_root)[2] airfoil_area, z_c_airfoil, y_c_airfoil = cw.get_skin_centroid( N, b, c, dx, cw.t_skin) z_centroid_all_sec, y_centroid_all_sec, y_loc_spar_up, y_loc_spar_low, y_loc_stiff_up, y_loc_stiff_low, y_vertical_spar, z_loc_stiff_up, spar_loc_sec, z_loc_stiff_low, spar_areas_verti = cw.wing_centroid( boom_area, cw.spar_areas_hori, cw.t_spar_v, z_c_airfoil, y_c_airfoil, cw.n_stiff_up, cw.n_stiff_low, N, b, c, X_root, dx) I_zz_req_all_sec = np.zeros(len(X_root)) sigma_ult = 114 * 10**6 for i in range(len(X_root)): y_up_max = -max(data_y_all_sec_up[i]) - (-1) * y_centroid_all_sec[i] y_low_max = -min(data_y_all_sec_low[i]) - (-1) * y_centroid_all_sec[i] # print(y_low_max) # print(Mz[i]) y_max = max(abs(y_up_max), abs(y_low_max)) I_zz_req_all_sec[i] = abs(Mz[i]) * y_max / sigma_ult # print("Mz",Mz[i]) # print("y_max",y_max) # print("I_zz_req",I_zz_req_all_sec) # print(y_max) return I_zz_req_all_sec
def I_zz_spars(l_spar_h, t_spar_v, t_spar_h, N, b, c, boom_area, X_root, dx): airfoil_area, z_c_airfoil, y_c_airfoil = cw.get_skin_centroid( N, b, c, dx, cw.t_skin) z_centroid_all_sec, y_centroid_all_sec, y_loc_spar_up, y_loc_spar_low, y_loc_stiff_up, y_loc_stiff_low, y_vertical_spar, z_loc_stiff_up, spar_loc_sec, z_loc_stiff_low, spar_areas_verti = cw.wing_centroid( boom_area, cw.spar_areas_hori, cw.t_spar_v, z_c_airfoil, y_c_airfoil, cw.n_stiff_up, cw.n_stiff_low, N, b, c, X_root, dx) I_zz_spar = np.zeros((len(X_root), 1)) I_yy_spar = np.zeros((len(X_root), 1)) I_yz_spar = np.zeros((len(X_root), 1)) for j in range(len(X_root)): I_zz_up = 0 I_yy_up = 0 I_yz_up = 0 I_zz_low = 0 I_yy_low = 0 I_yz_low = 0 I_zz_vertical = 0 I_yy_vertical = 0 I_yz_vertical = 0 # print(len(l_spar_h)) # # print(len(cw.spar_areas_hori[0])) for i in range(2): I_zz_up += (1 / 12) * l_spar_h[j] * t_spar_h[i]**3 + l_spar_h[ j] * t_spar_h[i] * (-y_loc_spar_up[j][i] - (-1) * y_centroid_all_sec[j])**2 I_yy_up += (1 / 12) * t_spar_h[i] * l_spar_h[j]**3 + l_spar_h[ j] * t_spar_h[i] * (spar_loc_sec[j][i] - z_centroid_all_sec[j])**2 I_yz_up += l_spar_h[j] * t_spar_h[i] * ( -y_loc_spar_up[j][i] - (-1) * y_centroid_all_sec[j]) * (spar_loc_sec[j][i] - z_centroid_all_sec[j]) I_zz_low += (1 / 12) * l_spar_h[j] * t_spar_h[i]**3 + l_spar_h[ j] * t_spar_h[i] * (-y_loc_spar_low[j][i] - (-1) * y_centroid_all_sec[j])**2 I_yy_low += (1 / 12) * t_spar_h[i] * l_spar_h[j]**3 + l_spar_h[ j] * t_spar_h[i] * (spar_loc_sec[j][i] - z_centroid_all_sec[j])**2 I_yz_low += l_spar_h[j] * t_spar_h[i] * ( -y_loc_spar_low[j][i] - (-1) * y_centroid_all_sec[j]) * (spar_loc_sec[j][i] - z_centroid_all_sec[j]) l_spar_v = y_loc_spar_up[j][i] - y_loc_spar_low[j][i] # print("l_spar_v", l_spar_v) I_zz_vertical += ( 1 / 12) * t_spar_v[i] * l_spar_v**3 + l_spar_v * t_spar_v[i] * ( -y_vertical_spar[j][i] - (-1) * y_centroid_all_sec[j])**2 I_yy_vertical += (1 / 12) * l_spar_v * t_spar_v[ i]**3 + l_spar_v * t_spar_v[i] * (spar_loc_sec[j][i] - z_centroid_all_sec[j])**2 I_yz_vertical += l_spar_v * t_spar_v[i] * ( -y_vertical_spar[j][i] - (-1) * y_centroid_all_sec[j]) * (spar_loc_sec[j][i] - z_centroid_all_sec[j]) I_zz = I_zz_up + I_zz_low + I_zz_vertical I_yy = I_yy_up + I_yy_low + I_yy_vertical I_yz = I_yz_up + I_yz_low + I_yz_vertical I_zz_spar[j] = I_zz I_yy_spar[j] = I_yy I_yz_spar[j] = I_yz # print("I_zz in spar",I_zz_spar) return I_zz_spar, I_yy_spar, I_yz_spar
def inertia_wing(I_zz_spar, I_yy_spar, I_yz_spar, boom_area, N, b, c, X_root, dx): airfoil_area, z_c_airfoil, y_c_airfoil = cw.get_skin_centroid( N, b, c, dx, cw.t_skin) z_centroid_all_sec, y_centroid_all_sec, y_loc_spar_up, y_loc_spar_low, y_loc_stiff_up, y_loc_stiff_low, y_vertical_spar, z_loc_stiff_up, spar_loc_sec, z_loc_stiff_low, spar_areas_verti = cw.wing_centroid( boom_area, cw.spar_areas_hori, cw.t_spar_v, z_c_airfoil, y_c_airfoil, cw.n_stiff_up, cw.n_stiff_low, N, b, c, X_root, dx) # print("boom area in izz", boom_area) I_zz = np.zeros(len(X_root)) I_yy = np.zeros(len(X_root)) I_yz = np.zeros(len(X_root)) for i in range(len(X_root)): I_zz_booms = 0 I_yy_booms = 0 I_yz_booms = 0 I_zz_airfoil = 0 I_yy_airfoil = 0 I_yz_airfoil = 0 for j in range(len(y_loc_stiff_up[0])): I_zz_booms += boom_area[i] * (-y_loc_stiff_up[i][j] - (-1) * y_centroid_all_sec[i])**2 I_yy_booms += boom_area[i] * (z_loc_stiff_up[i][j] - z_centroid_all_sec[i])**2 I_yz_booms += boom_area[i] * (-y_loc_stiff_up[i][j] - (-1) * y_centroid_all_sec[i]) * ( z_loc_stiff_up[i][j] - z_centroid_all_sec[i]) for k in range(len(y_loc_stiff_low[0])): I_zz_booms += boom_area[i] * (-y_loc_stiff_low[i][k] - (-1) * y_centroid_all_sec[i])**2 I_yy_booms += boom_area[i] * (z_loc_stiff_low[i][k] - z_centroid_all_sec[i])**2 I_yz_booms += boom_area[i] * (-y_loc_stiff_low[i][k] - (-1) * y_centroid_all_sec[i]) * ( z_loc_stiff_low[i][k] - z_centroid_all_sec[i]) I_zz_airfoil += airfoil_area[i] * (-y_c_airfoil[i] - (-1) * y_centroid_all_sec[i])**2 I_yy_airfoil += airfoil_area[i] * (z_c_airfoil[i] - z_centroid_all_sec[i])**2 I_yz_airfoil += airfoil_area[i] * (-y_c_airfoil[i] - (-1) * y_centroid_all_sec[i]) * ( z_c_airfoil[i] - z_centroid_all_sec[i]) # print("boom_area", boom_area) # print("I_zz_booms",I_zz_booms) # print(I_zz_airfoil, I_yy_airfoil, I_yz_airfoil) I_zz[i] = I_zz_booms + I_zz_spar[i][0] + I_zz_airfoil I_yy[i] = I_yy_booms + I_yy_spar[i][0] + I_yy_airfoil I_yz[i] = I_yz_booms + I_yz_spar[i][0] + I_yz_airfoil # print("I_zz used",I_zz_spar[i][0]) # # print("Izz wing",I_zz_airfoil) # print("I_zz", I_zz[0]) return I_zz, I_yy, I_yz
def wing_geometry(I_zz_req, I_zz_spars, N, b, c, boom_area, X_root, dx): # dx = 0.1 # print(X_root) airfoil_area, z_c_airfoil, y_c_airfoil = cw.get_skin_centroid( N, b, c, dx, cw.t_skin) z_centroid_all_sec, y_centroid_all_sec, y_loc_spar_up, y_loc_spar_low, y_loc_stiff_up, y_loc_stiff_low, y_vertical_spar, z_loc_stiff_up, spar_loc_sec, z_loc_stiff_low, spar_areas_verti = cw.wing_centroid( boom_area, cw.spar_areas_hori, cw.t_spar_v, z_c_airfoil, y_c_airfoil, cw.n_stiff_up, cw.n_stiff_low, N, b, c, X_root, dx) single_boom_area = np.zeros((len(X_root), 1)) # print(z_centroid_all_sec) # print(y_centroid_all_sec) # print(np.shape(I_zz_spars)) for i in range(len(X_root)): y_2 = 0 I_zz_airfoil = 0 for k in range(len(y_loc_stiff_up[0])): y_2 += (-y_loc_stiff_up[i][k] + y_centroid_all_sec[i])**2 for j in range(len(y_loc_stiff_low[0])): y_2 += (-y_loc_stiff_low[i][j] + y_centroid_all_sec[i])**2 I_zz_airfoil += airfoil_area[i] * (-y_c_airfoil[i] - (-1) * y_centroid_all_sec[i])**2 # I_yy_airfoil += airfoil_area[i]*(z_c_airfoil[i] - z_centroid_all_sec[i])**2 # I_yz_airfoil += airfoil_area[i]*(-y_c_airfoil[i] - (-1)*y_centroid_all_sec[i])*(z_c_airfoil[i] - z_centroid_all_sec[i]) # single_boom_area[i] = (I_zz_req[i] - I_zz_spars[i][0] - I_zz_airfoil)/y_2 if X_root[i] <= b / 2 - 16.05: # single_boom_area = np.ones(len(X_root))*max(single_boom_area) ## print("locatie",np.argmax(max(single_boom_area))) single_boom_area[i] = 0.018 - ((0.018 - 0.000) / (b / 2)) * X_root[i] elif X_root[i] > b / 2 - 16.05: single_boom_area[ i] = 0.0 #0.0011 - ((0.0011-0.000)/(b/2))*X_root[i] # if single_boom_area[i] <= 0: # single_boom_area[i] = 0. # elif single_boom_area[i] > 0: # single_boom_area[i] = single_boom_area[i] # plt.plot(X_root, single_boom_area) # plt.show() # print("single_boom_area",single_boom_area*10000, len(single_boom_area)) return single_boom_area