def trim_alpha_de_throttle(aircraft, speed, altitude, gamma, n=1): """trim aircraft with angle of attack, elevator, and throttle""" a = Atmosphere(altitude).speed_of_sound() # [ft/s] rho = Atmosphere(altitude).air_density() # [slug / ft^3] mach = speed / a # [] c_l_a = Aircraft(aircraft, mach).c_l_alpha() # [1/rad] c_l_de = Aircraft(aircraft, mach).c_l_delta_elevator() # [1/rad] c_m_a = Aircraft(aircraft, mach).c_m_alpha() # [1/rad] c_m_de = Aircraft(aircraft, mach).c_m_delta_elevator() # [1/rad] c_l_0 = Aircraft(aircraft, mach).c_l_zero() # [] c_d_0 = Aircraft(aircraft, mach).c_d_zero(altitude) # [] w = aircraft['weight']['weight'] * n # [lb] q_bar = 0.5 * rho * speed**2 # [psf] s_w = aircraft['wing']['planform'] # [ft^2] c_bar = mac(aircraft['wing']['aspect_ratio'], s_w, aircraft['wing']['taper']) c_l_1 = w * cos(deg2rad(gamma)) / (s_w * q_bar) # [] t = Propulsion(aircraft['propulsion'], [speed, altitude], ones((aircraft['propulsion']['n_engines'])), aircraft['weight']['cg']).thrust_f_m() a = array([[-c_l_a, -c_l_de, 0], [c_m_a, c_m_de, (t[4]) / (s_w * q_bar * c_bar)], [-2 * c_l_1, 0, t[0] / (s_w * q_bar)]]) c_m_0 = Aircraft(aircraft, mach).c_m_zero(altitude) b = array([[-c_l_1 + c_l_0], [-c_m_0], [w * sin(deg2rad(gamma)) / (s_w * q_bar) + c_d_0]]) c = linalg.solve(a, b) # [rad] c[0:2] = rad2deg(c[0:2]) return c
def dynamic_pressure(mach, altitude): """returns incompressible dynamic pressure.""" rho = Atmosphere(altitude).air_density() a = Atmosphere(altitude).speed_of_sound() v = mach * a q_bar = 0.5 * rho * v**2 return q_bar
def reynolds_number(mach, altitude, x_ref): """return reynolds number.""" rho = Atmosphere(altitude).air_density() # [slug/ft^3] mu = Atmosphere(altitude).viscosity() a = Atmosphere(altitude).speed_of_sound() # [ft/s] v = mach * a # [ft/s] re = rho * v * x_ref / mu # [] return re
def propulsion_weight(aircraft): """return engine weight.""" w_p = [] fus = aircraft['fuselage'] w = aircraft['wing'] b = span(w['aspect_ratio'], w['planform']) length = fus['length'] for ii in range(0, aircraft['propulsion']['n_engines']): engine = aircraft['propulsion']["engine_%d" % (ii + 1)] if engine['type'] == 'prop': t = propeller(engine, [0, 0, 0], 0, 1) t = (sum(t[0:3]**2))**0.5 rho = Atmosphere(0).air_density() d = engine['diameter'] a = pi * (d / 2)**2 u_e = (2 * t / (rho * a))**0.5 u_disk = u_e / 2 p = t * u_disk w_controls = 60.27 * ((length + b) * 10**-2)**0.724 w_prop = 32 * (4**0.391) * (d * p * constants.lbft_s2hp() * 10**-3)**0.782 w_prop_control = 4.5 * (4**0.379) * ( d * p * constants.lbft_s2hp() * 10**-3)**0.759 w_engine = p * constants.lbft_s2hp() / constants.electric_hp_lb() w_p.append(w_engine + w_prop + w_prop_control + w_controls) if engine['type'] == 'jet': w_controls = 88.46 * ((length + b) * 10**-2)**0.294 w_engine = engine['thrust'] / constants.jet_lbt_lb() d_nac = 0.04 * engine['thrust']**0.5 l_nac = 0.07 * engine['thrust']**0.5 w_nac = 0.25 * d_nac * l_nac * engine['thrust']**0.36 w_p.append(w_engine + w_controls + w_nac) w_fuel_tank = 1.07 * (aircraft['propulsion']['fuel_mass'] * g)**0.58 w_total = sum(w_p) + w_fuel_tank return w_total
def trim_alpha_de(aircraft, speed, altitude, gamma, n=1): """trim aircraft with angle of attack and elevator""" a = Atmosphere(altitude).speed_of_sound() # [ft/s] rho = Atmosphere(altitude).air_density() # [slug / ft^3] mach = speed / a # [] c_l_a = Aircraft(aircraft, mach).c_l_alpha() # [1/rad] c_l_de = Aircraft(aircraft, mach).c_l_delta_elevator() # [1/rad] c_m_a = Aircraft(aircraft, mach).c_m_alpha() # [1/rad] c_m_de = Aircraft(aircraft, mach).c_m_delta_elevator() # [1/rad] c_l_0 = Aircraft(aircraft, mach).c_l_zero() # [] a = array([[c_l_a, c_l_de], [c_m_a, c_m_de]]) w = aircraft['weight']['weight'] * n # [lb] q_bar = 0.5 * rho * speed**2 # [psf] s_w = aircraft['wing']['planform'] # [ft^2] c_l_1 = w * cos(deg2rad(gamma)) / (s_w * q_bar) # [] c_m_0 = Aircraft(aircraft, mach).c_m_zero(altitude) b = array([[c_l_1 - c_l_0], [-c_m_0]]) c = linalg.solve(a, b) # [rad] return rad2deg(c)
def trim_aileron(aircraft, v, altitude, p): """trim aircraft with aileron and rudder""" a = Atmosphere(altitude).speed_of_sound() # [ft/s] mach = v / a b = span(aircraft['wing']['aspect_ratio'], aircraft['wing']['planform']) k = b / (2 * v) c_l_p = Aircraft(aircraft, mach).c_r_roll_rate() # [] c_l_da = Aircraft(aircraft, mach).c_r_delta_aileron() # [] da = -c_l_p * p * k / c_l_da da = rad2deg(da) return da
def c_f_m(aircraft, x, u, engine_out=False): """return aircraft body axis forces and moments.""" s = aircraft['wing']['planform'] # [ft2] altitude = x[-1] # [ft] a = Atmosphere(altitude).speed_of_sound() # [ft/s] v = sqrt(x[0]**2 + x[1]**2 + x[2]**2) # [ft/s] mach = v / a # [] alpha = arctan(x[2] / x[0]) # [rad] beta = arctan(x[1] / x[0]) # [rad] weight = array([0, 0, 0, 0, 0, 0]) c_bar = mac(aircraft['wing']['aspect_ratio'], s, aircraft['wing']['taper']) # [ft] b = span(aircraft['wing']['aspect_ratio'], s) # [ft] throttle = u[3] * ones(aircraft['propulsion']['n_engines']) # [] if engine_out: throttle[0] = 0.01 # get thrust contributions c_f_m_t = Propulsion(aircraft['propulsion'], x, throttle, aircraft['weight']['cg']).thrust_f_m() # get weight contributions weight[0:3] = aircraft['weight']['weight'] * array( [-sin(x[4]), cos(x[4]) * sin(x[3]), cos(x[4]) * cos(x[3])]) q_bar = dynamic_pressure(mach, altitude) # [psf] s = aircraft['wing']['planform'] # [ft2] if 'aero_model' in aircraft.keys(): c_aero = nonlinear_aero(aircraft, x, u) else: c_aero = linear_aero(aircraft, x, u) c = array([ -c_aero[0], c_aero[1], -c_aero[2], c_aero[3] * b, c_aero[4] * c_bar, c_aero[5] * b ]) * q_bar * s b_2_w = body_to_wind(alpha, beta) c[0:3] = linalg.inv(b_2_w) @ c[0:3] c[3:6] = linalg.inv(b_2_w) @ c[3:6] c = c + c_f_m_t + weight return c
def trim_vs(aircraft, altitude, gamma, n=1): """trim aircraft with angle of attack and elevator""" rho = Atmosphere(altitude).air_density() # [slug / ft^3] mach = 0.3 # [] assume moderate mach number c_l_a = Aircraft(aircraft, mach).c_l_alpha() # [1/rad] c_l_de = Aircraft(aircraft, mach).c_l_delta_elevator() # [1/rad] c_m_a = Aircraft(aircraft, mach).c_m_alpha() # [1/rad] c_m_de = Aircraft(aircraft, mach).c_m_delta_elevator() # [1/rad] c_l_0 = Aircraft(aircraft, mach).c_l_zero() # [] w = aircraft['weight']['weight'] * n # [lb] s_w = aircraft['wing']['planform'] # [ft^2] a_s = deg2rad(aircraft['wing']['alpha_stall']) c_m_0 = Aircraft(aircraft, mach).c_m_zero(altitude) a = array([[-w * cos(deg2rad(gamma)) / (0.5 * rho * s_w), c_l_de], [0, c_m_de]]) b = array([[-c_l_0 - c_l_a * a_s], [-c_m_0 - c_m_a * a_s]]) c = linalg.solve(a, b) # [rad] v_s = float((1 / c[0])**0.5) return v_s
def trim_aileron_rudder(aircraft, v, altitude, alpha, beta, p, r): """trim aircraft with aileron and rudder""" a = Atmosphere(altitude).speed_of_sound() # [ft/s] mach = v / a b = span(aircraft['wing']['aspect_ratio'], aircraft['wing']['planform']) k = b / (2 * v) c_l_b = Aircraft(aircraft, mach).c_r_beta(alpha) c_l_p = Aircraft(aircraft, mach).c_r_roll_rate() # [] c_l_r = Aircraft(aircraft, mach).c_r_yaw_rate(alpha) # [] c_l_da = Aircraft(aircraft, mach).c_r_delta_aileron() # [] c_l_dr = Aircraft(aircraft, mach).c_r_delta_rudder() # [] c_n_b = Aircraft(aircraft, mach).c_n_beta(alpha) # [] c_n_p = Aircraft(aircraft, mach).c_n_roll_rate(alpha) # [] c_n_r = Aircraft(aircraft, mach).c_n_yaw_rate(alpha) # [] c_n_da = Aircraft(aircraft, mach).c_n_delta_aileron() # [] c_n_dr = Aircraft(aircraft, mach).c_n_delta_rudder() # [] a = array([[c_l_da, c_l_dr], [c_n_da, c_n_dr]]) b = array([[-c_l_b * beta - c_l_p * p * k - c_l_r * r * k], [-c_n_b * beta - c_n_p * p * k - c_n_r * r * k]]) c = linalg.solve(a, b) # [rad] return rad2deg(c)