def get_cm_derivatives(weight, height, v_t, delta_cg, delta_de, dd_dalpha): """ :param weight: :param height: :param v_t: True airspeed :param delta_cg: Change in CG location :param delta_de: Change in elevator deflection :param delta_alpha: Change in angle of attack :return: cm_alpha, cm_delta """ averaged_weight = np.mean(weight) temperature = isa.get_t_at_height(height) pressure = isa.get_p_at_temperature(temperature) density = isa.get_rho(pressure, temperature) averaged_density = np.mean(density) averaged_v_t = np.mean(v_t) cm_delta = ( -1 / delta_de * averaged_weight / (0.5 * averaged_density * np.power(averaged_v_t, 2) * cessna.S) * delta_cg / cessna.c) cm_alpha = -dd_dalpha * cm_delta return cm_alpha, cm_delta
def get_thrust_coefficient(height, thrust, velocity): """ :param height: :param thrust: :param rps: Revolutions per second :return: Thrust coefficient """ temperature = isa.get_t_at_height(height) pressure = isa.get_p_at_temperature(temperature) density = isa.get_rho(pressure, temperature) return thrust / (density * np.power(velocity, 2) * np.power(cessna.D, 2))
def get_reduced_equivalent_airspeed(weight, height, v_t): """ :param weight: :param height: :param v_t: True airspeed :return: Reduced equivalent airspeed """ temperature = isa.get_t_at_height(height) pressure = isa.get_p_at_temperature(temperature) density = isa.get_rho(pressure, temperature) v_e = v_t * np.sqrt(density / isa.rho_0) return v_e * np.sqrt(cessna.W / weight)
def get_cl_params(alpha, weight, height, true_airspeed): """ Inputs should be single values or numpy arrays :param alpha: angle of attack :param weight: :param height: :param true_airspeed: :return: cn_alpha, alpha_0, cn from flight """ temperature = isa.get_t_at_height(height) pressure = isa.get_p_at_temperature(temperature) density = isa.get_rho(pressure, temperature) cn = weight / (0.5 * density * np.power(true_airspeed, 2) * cessna.S) popt, _ = opt.curve_fit(cl_curve, alpha, cn) cn_alpha, alpha_0 = popt return cn_alpha, alpha_0, cn
def get_cd_params(alpha, weight, height, true_airspeed, thrust): """ Inputs should be single values or numpy arrays :param alpha: angle of attack :param weight: :param height: :param true_airspeed: :param thrust: :return: cd_0, e, cd from flight """ temperature = isa.get_t_at_height(height) pressure = isa.get_p_at_temperature(temperature) density = isa.get_rho(pressure, temperature) cn_alpha, alpha_0, _ = get_cl_params(alpha, weight, height, true_airspeed) cl = cn_alpha * (alpha - alpha_0) cd = thrust / (0.5 * density * np.power(true_airspeed, 2) * cessna.S) popt, _ = opt.curve_fit(cd_curve, cl, cd) cd_0, e = popt return cd_0, e, cd