Beispiel #1
0
def find_3D_coefficients(airfoil,
                         alpha,
                         Reynolds=0,
                         iteration=10,
                         NACA=True,
                         N=10,
                         span=10.,
                         taper=1.,
                         chord_root=1,
                         alpha_root=1.,
                         velocity=1.):
    """ Calculate the 3D distribution using the Lifting Line Theory.
    
    :param airfoil: if NACA is false, airfoil is the name of the plain
           filewhere the airfoil geometry is stored (variable airfoil).
           If NACA is True, airfoil is the naca series of the airfoil
           (i.e.: naca2244). By default NACA is False.

    :param Reynolds: Reynolds number in case the simulation is for a
          viscous flow. In case not informed, the code will assume
          inviscid. (Use the aero_module function to calculate reynolds)
          
    :param alpha: list/array/float/int of angles of attack.

    :param iteration: changes how many times XFOIL will try to make the
          results converge. Specialy important for viscous flows

    :param NACA: Boolean variable that defines if the code imports an
          airfoil from a file or generates a NACA airfoil.
    
    :param N: number of cross sections on the wing
    
    :param span: span in meters
    
    :param taper: unidimendional taper (This options is still not 100%
            operational)
    
    :param chord_root: value of the chord at the the root
    
    :param alpha_root: angle of attack of the chord at the root (degrees)

    :param velocity: velocity in m/s

"""
    coefficients = xf.find_coefficients(airfoil, alpha, Reynolds, iteration,
                                        NACA)
    alpha_L_0_root = xf.find_alpha_L_0(airfoil, Reynolds, iteration, NACA)
    return ar.LLT_calculator(alpha_L_0_root, coefficients['CD'], N, span,
                             taper, chord_root, alpha_root, velocity)
Beispiel #2
0
def find_3D_coefficients(airfoil, alpha, Reynolds=0, iteration=10, NACA=True,
                         N=10, span=10., taper=1., chord_root=1, alpha_root=1.,
                         velocity=1.):
    """ Calculate the 3D distribution using the Lifting Line Theory.
    
    :param airfoil: if NACA is false, airfoil is the name of the plain
           filewhere the airfoil geometry is stored (variable airfoil).
           If NACA is True, airfoil is the naca series of the airfoil
           (i.e.: naca2244). By default NACA is False.

    :param Reynolds: Reynolds number in case the simulation is for a
          viscous flow. In case not informed, the code will assume
          inviscid. (Use the aero_module function to calculate reynolds)
          
    :param alpha: list/array/float/int of angles of attack.

    :param iteration: changes how many times XFOIL will try to make the
          results converge. Specialy important for viscous flows

    :param NACA: Boolean variable that defines if the code imports an
          airfoil from a file or generates a NACA airfoil.
    
    :param N: number of cross sections on the wing
    
    :param span: span in meters
    
    :param taper: unidimendional taper (This options is still not 100%
            operational)
    
    :param chord_root: value of the chord at the the root
    
    :param alpha_root: angle of attack of the chord at the root (degrees)

    :param velocity: velocity in m/s

"""
    coefficients = xf.find_coefficients(airfoil, alpha, Reynolds, iteration,
                                     NACA)
    alpha_L_0_root = xf.find_alpha_L_0(airfoil, Reynolds, iteration, NACA)
    return ar.LLT_calculator(alpha_L_0_root, coefficients['CD'], N, span, taper, chord_root,
                          alpha_root, velocity)
Beispiel #3
0
    
    #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

if __name__ == '__main__':
    import math
#    print find_3D_coefficients(airfoil='naca0012', alpha=1.)
    alpha = 0.
    x_hinge = 0.25/0.6175
    deflection = -math.pi/2. #0.17453292519943295 #0.0010573527055
    
    # generate original airfoil
    airfoil = "naca0012"
    xf.call(airfoil, output='Coordinates')
    filename = xf.file_name(airfoil, output='Coordinates')
    Data = xf.output_reader(filename, output='Coordinates', header = ['x','y'])
    Cm = calculate_flap_moment(Data['x'], Data['y'], alpha, x_hinge,
                               deflection, unit_deflection = 'rad')
    
    data = xf.find_pressure_coefficients('flapped', alpha, NACA = False)
    C_m = ar.calculate_moment_coefficient(data['x'], data['y'], data['Cp'], alpha)
    
    data_CM = xf.find_coefficients('flapped', alpha, NACA = False)
    print 'aeropy: overall: ', C_m
    print 'aeropy: flap: ', Cm
    
    print 'xfoil: overall: ', data_CM['CM']
Beispiel #4
0
import numpy as np
import matplotlib.pyplot as plt

import xfoil_module as xf
from CST_module import *
from aero_module import Reynolds
from airfoil_module 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
Beispiel #5
0
    Created in Jul 17 2015
    """
    Air_Data = air_properties(height, unit='feet')
    rho = Air_Data['Density']
    L = c
    nu = Air_Data['Dynamic Viscosity']
    return rho * V * L / nu


if __name__ == '__main__':

    alpha = 0.
    import xfoil_module as xf
    data = xf.find_pressure_coefficients('naca0012', alpha)
    C_m = calculate_moment_coefficient(data['x'], data['y'], data['Cp'], alpha)
    data_CM = xf.find_coefficients('naca0012', alpha)
    print 'calculated:', C_m

    print 'objective:', data_CM['CM']

    import matplotlib.pyplot as plt

    Cm_xfoil = []
    Cm_aeropy = []

    alpha_list = np.linspace(0, 10, 11)
    for alpha in alpha_list:
        alpha = float(alpha)
        data = xf.find_pressure_coefficients('flapped', alpha, NACA=False)
        Cm_aeropy.append(
            calculate_moment_coefficient(data['x'], data['y'], data['Cp'],
Beispiel #6
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 18 14:47:32 2017

@author: claudio
"""

import numpy as np
import matplotlib.pyplot as plt

import xfoil_module as xf

print xf.find_coefficients('naca0012',0.0,NACA=True)

#upper = {'x':[0,.1,10,20,30], 'y':[0,2,4,2,1]}
#lower = {'x':[0,.1,10,20,30], 'y':[0,-10,-2,-1,0]}
#plt.plot(lower['x'], lower['y'], 'r')
#plt.plot(upper['x'], upper['y'], 'r', label = 'original data')
#rotated_upper, rotated_lower = xf.prepare_xfoil(upper, lower, 1.0, reposition=True)
#print rotated_upper
#print rotated_lower
#
#plt.plot(rotated_lower['x'], rotated_lower['y'], 'b')
#plt.plot(rotated_upper['x'], rotated_upper['y'], 'b', label='after LE rotation/translation')
#plt.legend(loc='best')
#plt.xlabel('x-coordinate')
#plt.ylabel('y-coordinate')
#plt.grid()
#plt.show()
Beispiel #7
0
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
Beispiel #8
0
    altitude = 10000  #feet

    Reynolds = ar.Reynolds(altitude, V, 1.0)

    deflection_list = list(np.linspace(5, 30, 4))
    alpha_list = list(np.linspace(0, 15, 20))

    # Calculate coefficients for without flap
    CL_list = []
    CD_list = []
    ratio_list = []
    CM_list = []

    for alpha_i in alpha_list:
        Data_0 = xf.find_coefficients('naca0012',
                                      alpha_i,
                                      Reynolds=Reynolds,
                                      iteration=200)
        CL_list.append(Data_0['CL'])
        CD_list.append(Data_0['CD'])
        ratio_list.append(Data_0['CL'] / Data_0['CD'])
        CM_list.append(Data_0['CM'])
    All_data = {
        0: {
            r'$c_m$': CM_list,
            r'$c_l$': CL_list,
            r'$c_d$': CD_list,
            r'$c_l/c_d$': ratio_list
        }
    }  #:Data_0['CL']/Data_0['CD']}}

    # Calculate foeccifient when using flap
Beispiel #9
0
    @author: Pedro Leal
    Created in Jul 17 2015
    """
    Air_Data = air_properties(height, unit='feet')
    rho = Air_Data['Density']
    L = c
    nu = Air_Data['Dynamic Viscosity']
    return rho*V*L/nu

if __name__ == '__main__':
    
    alpha  = 0.
    import xfoil_module as xf
    data = xf.find_pressure_coefficients('naca0012', alpha)
    C_m = calculate_moment_coefficient(data['x'], data['y'], data['Cp'], alpha)
    data_CM = xf.find_coefficients('naca0012', alpha)
    print 'calculated:', C_m
    
    print 'objective:', data_CM['CM']
    
    import matplotlib.pyplot as plt
    
    Cm_xfoil = []
    Cm_aeropy = []
    
    alpha_list = np.linspace(0,10,11)
    for alpha in alpha_list:
        alpha = float(alpha)
        data = xf.find_pressure_coefficients('naca0012', alpha)
        Cm_aeropy.append(calculate_moment_coefficient(data['x'], data['y'], data['Cp'], alpha))
        data_CM = xf.find_coefficients('naca0012', alpha)