1. Xfoil Module Documentation

The functions herein defined are purposely made for use with Xfoil.

1.1. Core Function

aeropy.xfoil_module.call(airfoil, alfas='none', output='Cp', Reynolds=0, Mach=0, plots=False, NACA=True, GDES=False, iteration=10, flap=None, PANE=False, NORM=True)[source]

Call xfoil through Python.

The input variables are:

Parameters:
  • 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.
  • alfas – list/array/float/int of angles of attack.
  • output
    defines the kind of output desired from xfoil. There
    are four posssible choices (by default, Cp is chosen):
    • Cp: generates files with Pressure coefficients for
      desired alfas.
    • Dump: generates file with Velocity along surface, Delta
      star,theta and Cf vs s,x,y for several alfas.
    • Polar: generates file with CL, CD, CM, CDp, Top_Xtr,
      Bot_Xtr.
    • Alfa_L_0: generates a file with the value of the angle
      of attack that lift is equal to zero.
    • Coordinates: returns the coordinates of a NACA airfoil.
  • Reynolds – Reynolds number in case the simulation is for a viscous flow. In case not informed, the code will assume inviscid.
  • Mach – Mach number in case the simulation has to take in account compressibility effects through the Prandtl-Glauert correlation. If not informed, the code will not use the correction. For logical reasons, if Mach is informed a Reynolds number different from zero must also be informed.
  • plots – the code is able to save in a .ps file all the plots of Cp vs.alfa. By default, this option is deactivated.
  • NACA – Boolean variable that defines if the code imports an airfoil from a file or generates a NACA airfoil.
  • GDES – XFOIL function that improves the airfoil shape in case the selected points do not provide a good shape. The CADD function is also used. For more information about these functions, use the XFOIL manual.
  • iteration – changes how many times XFOIL will try to make the results converge. Speciallt important for viscous flows
  • flap – determines if there is a flap. In case there is the expected input is [x_hinge, y_hinge, deflection(angles)]. y_hinge is determined to be exactly in the middle between the upper and lower surfaces.
  • PANE – if there are more than 495 surface points, the paneling method will not be used. Need to use the PANE subroutine to solve this. It will find the best points that represent the geometry (only 160 of them).
  • NORM – For good results using the panel method, Xfoil requires normalized coordinates, so this option should always be True.
Return type:

dictionary with outputs relevant to the specific output type. Usually x,y coordinates will be normalized.

As a side note, it is much more eficient to run a single run with multiple angles of attack rather than multiple runs, each with a single angle of attack.

Created on Sun Mar 9 14:58:25 2014

Last update Fr Jul 13 15:38:40 2015

@author: Pedro Leal (Based on Hakan Tiftikci’s code)

1.2. Auxiliary Functions

XFOIL Python interface.

aeropy.xfoil_module.alfa_for_file(alfa)[source]

Generate standard name for angles.

This is mainly used by the file_name function.

@author: Pedro Leal

aeropy.xfoil_module.create_input(x, y_u, y_l=None, filename='test', different_x_upper_lower=False)[source]

Create a plain file that XFOIL can read.

XFOIL only reads file from the TE to the LE from the upper part first and then from the LE to the TE through the pressure surface.

Inputs:
  • x: list of coordinates along the chord
  • y_u: list of coordinates normal to the chord for the upper surface. If y_l is not defined it is the y vector of the whole upper surface,
  • y_l: list of coordinates normal to the chord for the lower surface
  • file_name: label used for the file created

Created on Thu Feb 27 2014

@author: Pedro Leal

aeropy.xfoil_module.file_name(airfoil, alfas='none', output='Cp')[source]

Create standard name for the files generated by XFOIL.

Parameters:
  • airfoil – the name of the plain file where the airfoil geometry is stored (variable airfoil).
  • alfas – list/array/float/int of a single angle of attack for Cp and Dump, but the whole list for a Polar. Only the initial and the final values are used
  • output

    defines the kind of output desired from xfoil. There are three posssible choices:

    • Cp: generates files with Pressure coefficients for
      desired alfas
    • Dump: generates file with Velocity along surface, Delta
      star and theta and Cf vs s,x,y for several alfas
    • Polar: generates file with CL, CD, CM, CDp, Top_Xtr,
      Bot_Xtr
    • Alpha_L_0: calculate the angle of attack that lift is
      zero
Returns:

The output has the following format (by default, Cp is chosen):

  • for Cp and Dump: output_airfoil_alfa
    >>> file_name('naca2244', alfas=2.0, output='Cp')
    >>> Cp_naca2244_0200
    
  • for Polar: Polar_airfoil_alfa_i_alfa_f
    >>> file_name('naca2244', alfas=[-2.0, 2.0], output='Polar')
    >>> Polar_naca2244_n0200_0200
    
  • for Alpha_L_0: Alpha_L_0_airfoil
    >>> file_name('naca2244', output='Alpha_L_0')
    >>> Alpha_L_0_naca2244
    

Created on Thu Mar 16 2014 @author: Pedro Leal

aeropy.xfoil_module.find_pressure_coefficients(airfoil, alpha, Reynolds=0, iteration=10, NACA=True, use_previous=False, chord=1.0, PANE=False, delete=False, GDES=False)[source]

Calculate the pressure coefficients of an airfoil.

aeropy.xfoil_module.output_reader(filename, separator='\t', output=None, rows_to_skip=0, header=0, delete=False, structure=False, type_structure=None)[source]

Function that opens files of any kind.

Able to skip rows and read headers if necessary.

Inputs:
  • filename: just the name of the file to read.

  • separator: Main kind of separator in file. The code will replace any variants of this separator for processing. Extra components such as end-line, kg m are all eliminated. Separator can also be a list of separators to use

  • output: defines what the kind of file we are opening to ensure we can skip the right amount of lines. By default it is None so it can open any other file.

  • rows_to_skip: amount of rows to initialy skip in the file. If the output is different then None, for the different types of files it is defined as: - Polar files = 10 - Dump files = 0 - Cp files = 2 - Coordinates = 1

  • header: The header list will act as the keys of the output dictionary. For the function to work, a header IS necessary. If not specified by the user, the function will assume that the header can be found in the file that it is opening.

  • delete: if True, deletes file read.

  • structure: the file that he is being read has a given structure. For a file with the following structure:

    0 0 0 0.0996174 0.00873875 1 0.0996174 0.00873875 0.199258 0.0172063

    For the case where the header:

    >> header = [‘element’, ‘x1’, ‘y1’, ‘x2’, ‘y2’]

    A possible structure is:

    >> structure = [[‘element’], [‘x1’, ‘y1’], [‘x2’, ‘y2’]]

  • type_structure: [‘string’, ‘time’, ‘float’, ‘time’, ‘float’]

Output:
  • Dictionary with all the header values as keys

Created on Thu Mar 14 2014

@author: Pedro Leal

aeropy.xfoil_module.prepare_xfoil(Coordinates_Upper, Coordinates_Lower, chord, reposition=False, FSI=False)[source]

Prepare XFOIL airfoil file.

The upper and lower functions will be the points in ordered fashion. Because of the way that XFOIL works the points start at the Trailing Edge on the upper surface going trough the Leading Edge and returning to the Trailing Edge form the bottom surface.

1.3. Utility Functions

aeropy.xfoil_module.find_coefficients(airfoil, alpha, Reynolds=0, iteration=10, NACA=True, delete=False, PANE=False, GDES=False)[source]

Calculate the coefficients of an airfoil.

Includes lift, drag, moment, friction etc coefficients.

aeropy.xfoil_module.find_alpha_L_0(airfoil, Reynolds=0, iteration=10, NACA=True)[source]

Find zero lift angle of attack.

Calculate the angle of attack where the lift coefficient is equal to zero.

aeropy.xfoil_module.M_crit(airfoil, pho, speed_sound, lift, c)[source]

Calculate the Critical Mach.

This function was not validated. Therefore use it with caution and please improve it.

@author: Pedro Leal