xFoil Analysis Interface Module (AIM)
xFoil Analysis Interface Module (AIM)
xFoil AIM Example

Table of Contents

This is a walkthrough for using xFoil AIM to analyze a single airfoil cross-section.

Prerequisites

It is presumed that ESP and CAPS have been already installed, as well as xFoil.

Script files

Two scripts are used for this illustration:

  1. airfoilSection.csm: Creates geometry, as described in [Part 1] of the next section.
  2. xfoil_PyTest.py: pyCAPS script for performing analysis, as described in the [Part 2] of the next section.

Creating Geometry using ESP

In our example *.csm file setting up the CAPS fidelity is the first step. If multiple bodies exist in the *.csm file the tag, capsIntent, can be used to distinguish what type of analysis the body may be used for. In this example, the geometry model generated can be used for CFD analysis, as shown:

A typical geometry model can be created and interactively modified using design parameters. These design parameters are either design- or geometry- based. In this example, a single airfoil cross-section is created using the following design parameters.

despmtr thick 0.12 frac of local chord
despmtr camber 0.00 frac of local chord
despmtr area 10.0 Planform area of the full span wing
despmtr aspect 6.00 Span^2/Area
despmtr taper 0.60 TipChord/RootChord

After our design parameters are defined they are used to setup other local variables (analytically) for the wing.

set span sqrt(aspect*area)
set croot 2*area/span/(1+taper)
set ctip croot*taper

Once all design and locale variables are defined, a single airfoil cross-section is created using the NACA series airfoils (following a scale).

udprim naca Thickness thick Camber camber sharpte 1
scale ctip

Performing analysis using pyCAPS

The first step in the pyCAPS script is to import the required modules. For this example, the following modules are used,

from __future__ import print_function
import os
import argparse

In order to create a new capsProblem the pyCAPS module also needs to be imported; on Linux and OSX this is the pyCAPS.so file, while on Windows it is the pyCAPS.pyd file. For convenience, it is recommended that the path to this file is added to the environmental variable PYTHONPATH.

from pyCAPS import capsProblem

Similarly, local variables used throughout the script may be defined.

workDir = "xFoilAnalysisTest"

Once the required modules have been loaded, a capsProblem can be instantiated.

myProblem = capsProblem()

Using the loadCAPS() function, the desired geometry file is then loaded into the problem.

myGeometry = myProblem.loadCAPS("../csmData/airfoilSection.csm")

Any design parameters available in *.csm file are also available within the pyCAPS script. The following snippet changes the despmtr "camber" which will force a rebuild of the geometry that xFoil will now use.

myGeometry.setGeometryVal("camber", 0.1)

Next the xFoil AIM needs to be loaded.

xfoil = myProblem.loadAIM(aim = "xfoilAIM",
analysisDir = workDir,
capsIntent = "LINEARAERO")

Once loaded analysis parameters specific to xFoil need to be set (see AIM Inputs). These parameters are automatically converted into xFoil specific format and transferred into the xFoil configuration file.

# Set Mach number, Reynolds number
xfoil.setAnalysisVal("Mach", 0.5 )
xfoil.setAnalysisVal("Re", 1.0E6 )
# Set custom AoA
xfoil.setAnalysisVal("Alpha", [0.0, 3.0, 5.0, 7.0, 9.0, 11, 13, 14, 15.0])
# Set AoA seq
xfoil.setAnalysisVal("Alpha_Increment", [1.0, 2.0, 0.10])
# Set custom Cl
xfoil.setAnalysisVal("CL", 0.1)
# Set Cl seq
xfoil.setAnalysisVal("CL_Increment", [0.8, 3, .25])

After all desired options are set aimPreAnalysis needs to be executed.

xfoil.preAnalysis()

At this point the required files necessary run xFoil should have be created and placed in the specified analysis working directory. Next xFoil needs to executed such as through an OS system call like,

print ("\n\nRunning xFoil......")
currentDirectory = os.getcwd() # Get our current working directory
os.chdir(xfoil.analysisDir) # Move into test directory
os.system("xfoil < xfoilInput.txt > Info.out"); # Run xfoil via system call
os.chdir(currentDirectory) # Move back to top directory

After xFoil is finished running aimPostAnalysis needs to be executed.

xfoil.postAnalysis()

Finally, available AIM outputs (see AIM Outputs) may be retrieved, for example:

# Retrieve Cl and Cd
Cl = xfoil.getAnalysisOutVal("CL")
print("Cl = ", Cl)
Cd = xfoil.getAnalysisOutVal("CD")
print("Cd = ", Cd)
# Angle of attack
Alpha = xfoil.getAnalysisOutVal("Alpha")
print("Alpha = ", Alpha)
# Transition location
TranX = xfoil.getAnalysisOutVal("Transition_Top")
print("Transition location = ", TranX)

results in,

Cl = [0.951, 1.2403, 1.4266, 1.6214, 1.7724, 1.8756, 1.8507, 1.7748, 1.6766, 1.0562,
1.0665, 1.0767, 1.0869, 1.0969, 1.107, 1.1168, 1.1264, 1.1356, 1.1448, 1.05,
1.3, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55, 1.55]
Cd = [0.01293, 0.016, 0.01916, 0.02326, 0.03022, 0.04169, 0.06602, 0.08659, 0.11208,
0.01387, 0.01394, 0.01403, 0.01412, 0.01422, 0.01429, 0.01439, 0.0145, 0.01462,
0.01476, 0.0139, 0.01704, 0.02139, 0.02139, 0.02139, 0.02139, 0.02139, 0.02139,
0.02139, 0.02139, 0.02139, 0.02139, 0.02139]
Alpha = [0.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 14.0, 15.0, 1.1, 1.2, 1.3, 1.4, 1.5,
1.6, 1.7, 1.8, 1.9, 2.0, 1.055, 3.66, 6.227, 6.227, 6.227, 6.227, 6.227,
6.227, 6.227, 6.227, 6.227, 6.227, 6.227]

When finally finished with the script, the open CAPS problem should be closed.

myProblem.closeCAPS()

Executing pyCAPS script

Issuing the following command executes the script:

python xfoil_PyTest.py

Below is a representative image obtained by plotting the data presented above:

xFoil_Ex1.png
xFoil generated lift and drag coefficients for various angles of attack