Beispiel #1
0
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
Beispiel #2
0
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))
Beispiel #3
0
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)
Beispiel #4
0
def get_mach_number(height, v_c):
    """

    :param height:
    :param v_c: Calibrated airspeed
    :return: Mach number
    """
    pressure = isa.get_p_at_temperature(isa.get_t_at_height(height))

    innermost = np.power(
        1 + (isa.gamma - 1) / (2 * isa.gamma) *
        (isa.rho_0 / isa.p_0) * np.power(v_c, 2),
        isa.gamma / (isa.gamma - 1),
    )
    middle = np.power(1 + isa.p_0 / pressure * (innermost - 1),
                      (isa.gamma - 1) / isa.gamma)
    M = np.sqrt(2 / (isa.gamma - 1) * (middle - 1))

    return M
Beispiel #5
0
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
Beispiel #6
0
def run_thrust_exe(height, calibrated_airspeed, fuel_flow_left,
                   fuel_flow_right, measured_temperature):
    """[summary]
    
    :param height: from stationary measurements 
    :param calibrated_airspeed: from stationary measurements 
    :param fuel_flow_left: from stationary measurements 
    :param fuel_flow_right: from stationary measurements 
    :param measured_temperature: from stationary measurements 
    :return: array of thrust values for both engines for each stationary measurement from thrust.exe program 
    """
    mach_number = get_mach_number(height, calibrated_airspeed)
    temperature_delta = measured_temperature - isa.get_t_at_height(height)
    matlab_data = np.vstack([
        height, mach_number, temperature_delta, fuel_flow_left, fuel_flow_right
    ]).T
    np.savetxt("matlab.dat", matlab_data, delimiter=" ")
    subprocess.call("thrust.exe")
    thrust = np.genfromtxt("thrust.dat")
    thrust = thrust[:, 0] + thrust[:, 1]
    return thrust
Beispiel #7
0
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