예제 #1
0
def coefficient_LLT(AC, velocity, AOA):
    Au_P = [0.1828, 0.1179, 0.2079, 0.0850, 0.1874]
    Al_P = Au_P
    deltaz = 0

    # Determine children shape coeffcients
    AC_u = list(data.values[i, 0:4])
    Au_C, Al_C, c_C, spar_thicknesses = calculate_dependent_shape_coefficients(
        AC_u, psi_spars, Au_P, Al_P, deltaz, c_P, morphing=morphing_direction)

    # Calculate aerodynamics for that airfoil
    airfoil = 'optimal'
    x = create_x(1., distribution='linear')
    y = CST(x, 1., [deltaz / 2., deltaz / 2.], Al=Al_C, Au=Au_C)
    # Create file for Xfoil to read coordinates
    xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False)
    Data = xf.find_coefficients(airfoil,
                                AOA,
                                Reynolds=Reynolds(10000, velocity, c_C),
                                iteration=100,
                                NACA=False)
    deviation = 0.001
    while Data['CL'] is None:
        Data_aft = xf.find_coefficients(airfoil,
                                        AOA * deviation,
                                        Reynolds=Reynolds(
                                            10000, velocity, c_C),
                                        iteration=100,
                                        NACA=False)
        Data_fwd = xf.find_coefficients(airfoil,
                                        AOA * (1 - deviation),
                                        Reynolds=Reynolds(
                                            10000, velocity, c_C),
                                        iteration=100,
                                        NACA=False)
        try:
            for key in Data:
                Data[key] = (Data_aft[key] + Data_fwd[key]) / 2.
        except:
            deviation += deviation
    alpha_L_0 = xf.find_alpha_L_0(airfoil,
                                  Reynolds=0,
                                  iteration=100,
                                  NACA=False)

    coefficients = LLT_calculator(alpha_L_0,
                                  Data['CD'],
                                  N=100,
                                  b=span,
                                  taper=1.,
                                  chord_root=chord_root,
                                  alpha_root=AOA,
                                  V=velocity)
    lift = coefficients['C_L']
    drag = coefficients['C_D']

    return lift, drag
예제 #2
0
import numpy as np
import matplotlib.pyplot as plt

import aeropy.xfoil_module as xf
from aeropy.CST.module_2D import *
from aeropy.aero_module import Reynolds
from aeropy.geometry.airfoil import CST, create_x

# Au = [0.23993240191629417, 0.34468227138908186, 0.18125405377549103,
# 0.35371349126072665, 0.2440815012119143, 0.25724974995738387]
# Al = [0.18889012559339036, -0.24686758992053115, 0.077569769493868401,
# -0.547827192265256, -0.0047342206759065641, -0.23994805474814629]
Au = [0.172802, 0.167353, 0.130747, 0.172053, 0.112797, 0.168891]
Al = Au
# c_avian = 0.36                  #m
# deltaz = 0.0093943568219451313*c_avian
c_avian = 1.
deltaz = 0

airfoil = 'avian'
x = create_x(1., distribution='linear')
y = CST(x, 1., [deltaz / 2., deltaz / 2.], Au=Au, Al=Al)
# Create file for Xfoil to read coordinates
xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False)
print('Reynolds: ', Reynolds(10000, 30, c_avian))
Data = xf.find_coefficients(airfoil,
                            0.,
                            Reynolds=Reynolds(10000, 30, c_avian),
                            iteration=100,
                            NACA=False)
print(Data)
예제 #3
0
파일: AeroPy.py 프로젝트: belac626/AeroPy
def calculate_flap_moment(x, y, alpha, x_hinge, deflection,
                          unit_deflection = 'rad'):
    """For a given airfoil with coordinates x and y at angle of attack
    alpha (degrees), calculate the moment coefficient around the joint at x_hinge
    and deflection in radians (unit_deflection = 'rad') or degrees
    (unit_deflection = 'deg')"""

    # If x and y are not dictionaries with keys upper and lower, make them
    # be so
    if type(x) == list:
        x, y = af.separate_upper_lower(x, y)
    #Because parts of the program use keys 'u' and 'l', and other parts use
    #'upper' and 'lower'
    if 'u' in x.keys():
        upper = {'x': x['u'], 'y': y['u']}
        lower = {'x': x['l'], 'y': y['l']}
    elif 'upper' in x.keys():
        upper = {'x': x['upper'], 'y': y['upper']}
        lower = {'x': x['lower'], 'y': y['lower']}

    hinge = af.find_hinge(x_hinge, upper, lower)

    if deflection > 0:
        upper_static, upper_flap = af.find_flap(upper, hinge)
        lower_static, lower_flap = af.find_flap(lower, hinge,
                                                extra_points = 'lower')
    elif deflection < 0:
        upper_static, upper_flap = af.find_flap(upper, hinge,
                                                extra_points = 'upper')
        lower_static, lower_flap = af.find_flap(lower, hinge)
    else:
       upper_static, upper_flap = af.find_flap(upper, hinge,
                                               extra_points = None)
       lower_static, lower_flap = af.find_flap(lower, hinge,
                                               extra_points = None)

    upper_rotated, lower_rotated = af.rotate(upper_flap, lower_flap,
                                             hinge, deflection,
                                             unit_theta = unit_deflection)

    flapped_airfoil, i_separator = af.clean(upper_static, upper_rotated, lower_static,
                            lower_rotated, hinge, deflection, N = None,
                            return_flap_i = True)

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #Third step: get new values of pressure coefficient
    xf.create_input(x = flapped_airfoil['x'], y_u = flapped_airfoil['y'],
                    filename = 'flapped', different_x_upper_lower = True)

    Data = xf.find_pressure_coefficients('flapped', alpha, NACA = False)


    x, y, Cp = af.separate_upper_lower(x = Data['x'], y = Data['y'],
                                        Cp = Data['Cp'], i_separator = i_separator)

    #At the hinges, the reaction moment has the opposite sign of the
    #actuated torque
    Cm = - ar.calculate_moment_coefficient(x, y, Cp, alpha = alpha, c = 1.,
                                         x_ref = x_hinge, y_ref = 0.,
                                         flap = True)
    return Cm
예제 #4
0
파일: AeroPy.py 프로젝트: belac626/AeroPy
def calculate_flap_coefficients(x, y, alpha, x_hinge, deflection, Reynolds = 0,):
    """For a given airfoil with coordinates x and y at angle of attack
    alpha, calculate the moment coefficient around the joint at x_hinge
    and deflection """

    def separate_upper_lower(x, y, Cp = None, i_separator=None):
        """Return dictionaries with upper and lower keys with respective
        coordiantes. It is assumed the leading edge is frontmost point at
        alpha=0"""
        #TODO: when using list generated by xfoil, there are two points for
        #the leading edge
        def separate(variable_list, i_separator):
            if type(i_separator) == int:
                variable_dictionary = {'upper': variable_list[0:i_separator+1],
                                       'lower': variable_list[i_separator+1:]}
            elif type(i_separator) == list:
                i_upper = i_separator[0]
                i_lower = i_separator[1]

                variable_dictionary = {'upper': variable_list[0:i_upper],
                                       'lower': variable_list[i_lower:]}
            return variable_dictionary
        #If i is not defined, separate upper and lower surface from the
        # leading edge
        if i_separator == None:
            i_separator = x.index(min(x))

        if Cp == None:
            x = separate(x, i_separator)
            y = separate(y, i_separator)
            return x, y
        else:
            x = separate(x, i_separator)
            y = separate(y, i_separator)
            Cp = separate(Cp, i_separator)
            return x, y, Cp
    # If x and y are not dictionaries with keys upper and lower, make them
    # be so
    if type(x) == list:
        x, y = separate_upper_lower(x, y)

    upper = {'x': x['upper'], 'y': y['upper']}
    lower = {'x': x['lower'], 'y': y['lower']}

    #Determining hinge
    hinge = af.find_hinge(x_hinge, upper, lower)

    upper_static, upper_flap = af.find_flap(upper, hinge)
    lower_static, lower_flap = af.find_flap(lower, hinge, lower = True)

    upper_rotated, lower_rotated = af.rotate(upper_flap, lower_flap, hinge, deflection)

    flapped_airfoil, i_separator = af.clean(upper_static, upper_rotated, lower_static,
                            lower_rotated, hinge, deflection, N = 5,
                            return_flap_i = True)

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #Third step: get new values of pressure coefficient
    xf.create_input(x = flapped_airfoil['x'], y_u = flapped_airfoil['y'],
                    filename = 'flapped', different_x_upper_lower = True)
    Data = xf.find_coefficients('flapped', alpha, NACA = False,
                                Reynolds = Reynolds, iteration=500)

    return Data
예제 #5
0
def aerodynamic_performance(AC, psi_spars, Au_P, Al_P, c_P, deltaz, alpha, H,
                            V):
    morphing_direction = 'forwards'

    air_data = air_properties(H, unit='feet')
    density = air_data['Density']
    dyn_pressure = .5 * density * V**2

    # Generate dependent shape coefficients
    # try:
    Au_C, Al_C, c_C, spar_thicknesses = calculate_dependent_shape_coefficients(
        AC, psi_spars, Au_P, Al_P, deltaz, c_P, morphing=morphing_direction)

    # print 'Reynolds: ', Reynolds(H, V, c_C)
    # Generate aifoil file
    airfoil = 'test'
    x = create_x(1., distribution='linear', n=300)
    y = CST(x, 1., [deltaz / 2., deltaz / 2.], Au=Au_C, Al=Al_C)

    # Get strain data
    strains, av_strain = calculate_strains(Au_P, Al_P, c_P, Au_C, Al_C, c_C,
                                           deltaz, psi_spars, spar_thicknesses)

    intersections = intersect_curves(x, y['l'], x, y['u'])
    print(intersections, intersections[0][1:])
    if len(intersections[0][1:]) == 0:
        # print y
        create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False)

        # Get aerodynamic data
        print(airfoil, alpha, Reynolds(H, V, c_C))
        Data = find_coefficients(airfoil,
                                 alpha,
                                 Reynolds=Reynolds(H, V, c_C),
                                 iteration=200,
                                 NACA=False,
                                 delete=True,
                                 PANE=True,
                                 GDES=True)

        # plot_airfoil(AC, psi_spars, c_P, deltaz, Au_P, Al_P, image = 'save', iteration=counter, dir = airfoil+'_dir')

        # filtering data (for now I only care about negative strains
        str_output = {
            'CL': Data['CL'],
            'CD': Data['CD'],
            'CM': Data['CM'],
            'av_strain': av_strain,
            'Au_C': Au_C,
            'Al_C': Al_C,
            'spars': psi_spars
        }

        if Data['CM'] == None:
            str_output['lift'] = None
            str_output['drag'] = None
            str_output['moment'] = None
        else:
            str_output['lift'] = Data['CL'] / dyn_pressure / c_C,
            str_output['drag'] = Data['CD'] / dyn_pressure / c_C,
            str_output['moment'] = Data['CM'] / dyn_pressure / c_C
        for i in range(len(strains)):
            str_output['strain_' + str(i)] = strains[i]

        # Writing to a text file
        # f_worker = open(str(airfoil) + '.txt', 'wb')
        # for i in range(len(key_list)):
        # if i != len(key_list)-1:
        # if key_list[i][:1] == 'Au':
        # f_worker.write('%f\t' % str_output[key_list[i][:1]+'_C'][int(key_list[i][-1])])
        # else:
        # else:
        # if key_list[i][:1] == 'Au':
        # f_worker.write('%f\n' % str_output[key_list[i][:1]+'_C'][int(key_list[i][-1])])
    else:
        str_output = {
            'CL': 1000,
            'CD': None,
            'CM': None,
            'av_strain': av_strain,
            'spars': psi_spars,
            'Au_C': Au_C,
            'Al_C': Al_C,
            'lift': None,
            'drag': None,
            'moment': None
        }
        for i in range(len(strains)):
            str_output['strain_' + str(i)] = strains[i]
    # except:
    # str_output = {'CL':None, 'CD':None, 'CM':None, 'av_strain':None,
    # 'Au_C':[None]*len(AC), 'Al_C': [None]*len(AC),
    # 'lift': None, 'drag': None, 'moment':None,
    # 'strains':[None]*(len(AC)-1), 'spars':psi_spars}
    return str_output
예제 #6
0
파일: range.py 프로젝트: alexudem/AeroPy
def aircraft_range_LLT(AC, velocity, AOA):
    def to_integrate(weight):
        # velocity = 0.514444*108 # m/s (113 KTAS)

        span = 10.9728
        RPM = 1800
        a = 0.3089  # (lb/hr)/BTU
        b = 0.008 * RPM + 19.607  # lb/hr

        lbhr_to_kgs = 0.000125998
        BHP_to_watt = 745.7

        eta = 0.85

        thrust = weight / lift_to_drag

        power_SI = thrust * velocity / eta
        power_BHP = power_SI / BHP_to_watt
        mass_flow = (a * power_BHP + b)
        mass_flow_SI = mass_flow * lbhr_to_kgs

        SFC = mass_flow_SI / thrust
        dR = velocity / g / SFC * lift_to_drag / weight
        return dR * 0.001  #*0.0005399

    Au_P = [0.1828, 0.1179, 0.2079, 0.0850, 0.1874]
    Al_P = Au_P
    deltaz = 0

    # Determine children shape coeffcients
    AC_u = list(data.values[i, 0:4])
    Au_C, Al_C, c_C, spar_thicknesses = calculate_dependent_shape_coefficients(
        AC_u, psi_spars, Au_P, Al_P, deltaz, c_P, morphing=morphing_direction)

    # Calculate aerodynamics for that airfoil
    airfoil = 'optimal'
    x = create_x(1., distribution='linear')
    y = CST(x, 1., [deltaz / 2., deltaz / 2.], Al=Al_C, Au=Au_C)
    # Create file for Xfoil to read coordinates
    xf.create_input(x, y['u'], y['l'], airfoil, different_x_upper_lower=False)
    Data = xf.find_coefficients(airfoil,
                                AOA,
                                Reynolds=Reynolds(10000, velocity, c_C),
                                iteration=100,
                                NACA=False)
    deviation = 0.001
    while Data['CL'] is None:
        Data_aft = xf.find_coefficients(airfoil,
                                        AOA * deviation,
                                        Reynolds=Reynolds(
                                            10000, velocity, c_C),
                                        iteration=100,
                                        NACA=False)
        Data_fwd = xf.find_coefficients(airfoil,
                                        AOA * (1 - deviation),
                                        Reynolds=Reynolds(
                                            10000, velocity, c_C),
                                        iteration=100,
                                        NACA=False)
        try:
            for key in Data:
                Data[key] = (Data_aft[key] + Data_fwd[key]) / 2.
        except:
            deviation += deviation
    alpha_L_0 = xf.find_alpha_L_0(airfoil,
                                  Reynolds=0,
                                  iteration=100,
                                  NACA=False)

    coefficients = LLT_calculator(alpha_L_0,
                                  Data['CD'],
                                  N=100,
                                  b=span,
                                  taper=1.,
                                  chord_root=chord_root,
                                  alpha_root=AOA,
                                  V=velocity)
    lift_to_drag = coefficients['C_L'] / coefficients['C_D']

    g = 9.81  # kg/ms
    fuel = 56 * 6.01 * 0.4535 * g
    initial_weight = 1111 * g
    final_weight = initial_weight - fuel
    return scipy.integrate.quad(to_integrate, final_weight, initial_weight)[0]