def specific_excess_power(aircraft, x, u): """calculate specific excess power""" w = aircraft['weight']['weight'] # [lbs] v = (x[0]**2 + x[2]**2)**0.5 # [ft/s] c = c_f_m(aircraft, x, u) p_s = (c[0]) * v * 60 / w # [ft/min] return p_s
def takeoff_ground_roll(aircraft, x_0, u_0): """return derivatives for aircraft on ground.""" m = aircraft['weight']['weight'] / g j = aircraft['weight']['inertia'] c = c_f_m(aircraft, x_0, u_0) c_t, c_g, normal_loads = landing_gear_loads(aircraft, x_0, c, True) dxdt = nonlinear_eom(x_0, m, j, c_t) return dxdt
def alpha_stab(x): u = array([0, x[1], 0, 0.01]) x = array([ speed * cos(x[0]), 0, speed * sin(x[0]), 0, x[0] + deg2rad(gamma), 0, 0, 0, 0, 0, 0, altitude ]) cfm = c_f_m(aircraft, x, u) return abs(cfm[2]) + abs(cfm[4])
def v_stab(x): u = array([0, x[0], 0, 0.01]) x_in = array([ x[1] * cos(alpha), 0, x[1] * sin(alpha), 0, alpha + deg2rad(gamma), 0, 0, 0, 0, 0, 0, altitude ]) cfm = c_f_m(aircraft, x_in, u) return abs(cfm[2]) + abs(cfm[4])
def alpha_stab(x): u = array([0, x[1], 0, th]) speed = x[2] x = array([ speed * cos(x[0]), 0, speed * sin(x[0]), 0, x[0], 0, 0, 0, 0, 0, 0, altitude ]) cfm = c_f_m(aircraft, x, u) return abs(cfm[2]) + abs(cfm[4])
def aileron_rudder(x): u = array([x[0], 0, x[1], 0.01]) b2w = body_to_wind(alpha, beta) v_b = linalg.inv(b2w) @ array([speed, 0, 0]) x = array([ v_b[0], v_b[1], v_b[2], 0, alpha, 0, roll_rate, 0, yaw_rate, 0, 0, altitude ]) dxdt = c_f_m(aircraft, x, u) return sqrt(sum(dxdt**2)) / 1000
def obj(x): u = array([0, x[1], 0, th]) speed = x[2] x = array([ speed * cos(x[0]), 0, speed * sin(x[0]), 0, x[0], 0, 0, 0, 0, 0, 0, altitude ]) c_1 = c_f_m(aircraft, x, u) p_s = (c_1[0]) * speed * 60 / aircraft['weight']['weight'] # [ft/min] return -p_s
def oei_constraint(x): v = x[0] plane['vertical']['control_1']['cf_c'] = x[1] s = array([ float(v * cos(deg2rad(alpha))), 0, float(v * sin(deg2rad(alpha))), 0, float(deg2rad(alpha)), 0, 0, 0, 0, 0, 0, 0 ]) u = [0, deg2rad(x[2]), dr, 1] cfm = c_f_m(plane, s, u, engine_out=True) return abs(cfm[2]) + abs(cfm[4]) + abs(cfm[5])
def aileron_rudder_speed(x): u = array([x[0], x[3], x[1], 1]) alpha = x[2] b2w = body_to_wind(alpha, beta) v_b = linalg.inv(b2w) @ array([x[4], 0, 0]) x = array([ v_b[0], v_b[1], v_b[2], 0, alpha, 0, roll_rate, 0, yaw_rate, 0, 0, altitude ]) cfm = c_f_m(aircraft, x, u) return cfm[1] + cfm[2] + cfm[3] + cfm[4] + cfm[5]
def long_constraint(x): v = x[0] plane['horizontal']['control_1']['cf_c'] = x[1] s = array([ float(v * cos(deg2rad(alpha))), 0, float(v * sin(deg2rad(alpha))), 0, float(deg2rad(alpha)), 0, 0, 0, 0, 0, 0, alt ]) u = [0, de, 0, 0.01] cfm = c_f_m(plane, s, u) return abs(cfm[2]) + abs(cfm[4])
def sp_constraint(x): plane['wing']['station'] = x[0] plane['horizontal']['planform'] = x[1] plane['weight']['weight'], plane['weight']['cg'] = MassProperties( plane).weight_buildup(req) zeta_sp, omega_sp, cap = short_period_mode(plane, s, u) plane['horizontal']['control_1']['cf_c'] = 0.99 s_r = array([vr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, alt_to]) cfm = c_f_m(plane, s_r, u_r) c_t, c_g, normal_loads = landing_gear_loads(plane, s_r, cfm) c = array([zeta_sp - zeta_req, float(normal_loads[0])]) return c
def nonlinear_eom_to_ss(aircraft, x_ss, u_ss, x_0, u_0, m, j, dx=0.1, du=0.1): """aircraft system linearization routine.""" """return jacobians a, b wrt to x_ss and output matrices c, and d wrt u_ss.""" x = x_0 u = u_0 a = zeros((len(x_0), len(x_0))) b = zeros((len(x_0), len(u_0))) for ii in range(0, len(x_0)): x[ii] = x[ii] + dx c = c_f_m(aircraft, x, u_0) dxdt_1 = nonlinear_eom(x, m, j, c) x[ii] = x[ii] - dx c = c_f_m(aircraft, x, u_0) dxdt_2 = nonlinear_eom(x, m, j, c) ddx_dx = (dxdt_1 - dxdt_2) / (2 * dx) a[:, ii] = transpose(ddx_dx) x = x_0 for ii in range(0, len(u_0)): u[ii] = u[ii] + du c = c_f_m(aircraft, x_0, u) dxdt_1 = nonlinear_eom(x, m, j, c) u[ii] = u[ii] - du c = c_f_m(aircraft, x_0, u) dxdt_2 = nonlinear_eom(x, m, j, c) ddx_dx = (dxdt_1 - dxdt_2) / (2 * du) b[:, ii] = transpose(ddx_dx) u = u_0 a_out = a[x_ss, :] a_out = a_out[:, x_ss] b_out = b[x_ss, :] b_out = b_out[:, u_ss] c_out = identity(len(x_ss)) d_out = zeros((len(x_ss), len(u_ss))) return a_out, b_out, c_out, d_out
def obj(x): u = array([0, x[1], 0, th]) speed = x[2] x = array([ speed * cos(x[0]), 0, speed * sin(x[0]), 0, x[0], 0, 0, 0, 0, 0, 0, altitude ]) c_1 = c_f_m(aircraft, x, u) throttle = ones(aircraft['propulsion']['n_engines']) tsfc = g * speed / (aircraft['propulsion']['energy_density'] * aircraft['propulsion']['total_efficiency']) t = Propulsion(aircraft['propulsion'], x, throttle, aircraft['weight']['cg']).thrust_f_m() f_s = tsfc * t[0] p_s = (c_1[0]) * speed * 60 / aircraft['weight']['weight'] # [ft/min] return f_s / p_s
def rejected_takeoff(aircraft, s_f, x_0, u_0, v_max=350): """return derivatives for aircraft on ground.""" v = linspace(5, v_max, 100) m = aircraft['weight']['weight'] / g j = aircraft['weight']['inertia'] x = [] for vi in v: x_0[0] = 0.707 * vi c = c_f_m(aircraft, x_0, u_0) c_t, c_g, normal_loads = landing_gear_loads(aircraft, x_0, c, True, brake=1) dxdt = nonlinear_eom(x_0, m, j, c_t) x.append(s_f + (vi**2) / (2 * dxdt[0])) v = flip(v) x = flip(x) return v, x
def v_stab(x): x = array([x[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, altitude]) c = c_f_m(aircraft, x, u_0) c_t, c_g, normal_loads = landing_gear_loads(aircraft, x, c) return float(normal_loads[0])
def v_stab(x): plane['horizontal']['control_1']['cf_c'] = x[0] s = array([vr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) c = c_f_m(plane, s, u) c_t, c_g, normal_loads = landing_gear_loads(plane, s, c) return float(normal_loads[0])
def aileron(x): u = array([x[0], 0, 0, 0.01]) x = array([speed, 0, 0, 0, 0, 0, roll_rate, 0, 0, 0, 0, altitude]) dxdt = c_f_m(aircraft, x, u) return sqrt(sum(dxdt**2)) / 1000