Airfoil toolbox
A list of functions and script used for analysis of airfoils and related data with Matlab.
Disclaimer
This toolbox was mainly developed under Matlab R2018a. The various functions were not tested on older versions. A code compatibility analysis showed no errors, so in theory it should work properly with any other versions of Matlab as well. If for some reason it does not work on your version, please open an issue.
The functions in this repository are intended to be used as a Matlab package (see Matlab documentation for more details).
Documentation
Each function contains a complete description in its preamble. Type help <function>
in Matlab command window to print it.
Install and use
Installation
- Either clone this repository or download a
.zip
version of the source code. - Place the
+af_tools/
folder somewhere on your Matlab Path such as:
- in you current project
- in a folder that is already in Matlab's path (e.g.
/Documents/Matlab/
). - somewhere else, but then explicitly add it to Matlab's Path.
Remark
Unfortunately, Matlab packages have a few limitations. Hence, you should avoid changing the package name if you do not know what you are doing.
- The
+
in the folder's name is required for Matlab to treat it as a package. - Some functions of this package are interconnected (e.g., nacairfoil calls nacacamber). In that situation, Matlab forces the main function to re-import explicitly all sub-functions before using them, even if they are part of the same package (people have complained about that design choice for quite some time, to no avail). If you rename the package, these links will be broken and Matlab will not find the connected functions.
- All functions that import other functions will have an import line at the beginning. If you rename the package, you must therefore update these imports.
Use
Once the +af_tools/
folder is placed somewhere where Matlab will find
it, you can start using its features.
- If you are only interested in a single function of the package, use
import af_tools.<functionName>
functionName(args)
- If you want to import all functions, use
import af_tools.*
xf2mat(args)
nacacamber(args)
...
- If you want to use functions on-the-fly without importing them, call them directly
af_tools.xf2mat(args)
Functions
- All functions can be used as standalone functions and give meaningful output on their own (they are not sub-routines used to perform intermediary tasks).
- Most functions can be run without input arguments. In that case, the functions will prompt the user for the few mandatory arguments while the others will be set to their default values.
xf2mat
Aggregates airfoil polars obtained using XFOIL v6.99 of XFLR5 v6.55 into a single Matlab structure.
This function can either aggregate multiple polar files into a single structure (e.g. same airfoil at different Reynolds) or simply convert a single polar data into a Matlab-ready structure.
import af_tools.xf2mat
Polar = xf2mat
Polar = xf2mat(autosave, trimAoas, inputDir, inputFiles)
Input | Example | Default |
---|---|---|
autosave |
false , true
|
false |
trimAoas |
false , true
|
- |
inputDir |
'.' , 'xf_results'
|
- |
inputFiles |
'*' , '*0012*' , '{'*0012_1*', '*0012_2*'}
|
false |
The output is a structure with the following fields, where M is the number of angles of attack and N is the number of input files.
Field | Data | Size |
---|---|---|
origin |
Program from which the polars came (XFOIL/XFLR5) | [1 x N] |
airfoil |
Airfoil name (parsed from XFOIL/XFLR5 results) | [1 x N] |
alpha |
Angles of attacks | [M x N] |
reynolds |
Reynolds numbers | [1 x N] |
mach |
Mach number | [1 x N] |
nCrit |
BL transition factor | [1 x N] |
cl |
Lift coefficient | [M x N] |
cd |
Drag coefficient | [M x N] |
cm |
Moment coefficient | [M x N] |
extendpolar
This function extends known C_l
and C_d
polars to the full range of
angle of attacks [-180; 180]. This is especially useful when studying rotors and
propellers in off-design configuration (with the Blade Element Momentum Theory
for instance).
import af_tools.extendpolar
[alphaExt, clExt, cdExt] = extendpolar
[alphaExt, clExt, cdExt] = extendpolar(method, limit, Polar)
[alphaExt, clExt, cdExt] = extendpolar(method, limit, alpha, cl, cd)
Input | Example | Default |
---|---|---|
method |
'viterna' |
- |
limit |
'stall','limit' |
- |
Polar |
MyPolar |
- |
alpha |
1:10 |
- |
cl |
1:10 , rand(10,2)
|
- |
cd |
1:10 , rand(10,2)
|
- |
nacacamber
Determines the camber line of a NACA 4 or 5 digits airfoil.
import af_tools.nacacamber
[xc, yc, gradY] = nacacamber
[xc, yc, gradY] = nacacamber(digits, nPoints, spacing)
Input | Example | Default |
---|---|---|
digits |
'0012' , '24012'
|
- |
nPoints |
100 , 130
|
100 |
spacing |
halfcosine , cosine , linear
|
halfcosine |
nacaairfoil
Generates the full coordinates of a NACA 4 or 5 digits airfoil.
import af_tools.nacaairfoil
[x, y] = nacaairfoil
[x, y] = nacaairfoil(digits, nPoints, spacing, finiteTrail)
Input | Example | Default |
---|---|---|
digits |
'0012' , '24012'
|
- |
nPoints |
100 , 130
|
100 |
spacing |
halfcosine , cosine , linear
|
halfcosine |
finiteTrail |
true , false
|
false |
plotpolars
Plots the following polars: C_l-\alpha
, C_d-\alpha
, C_m-\alpha
C_l/C_d-\alpha
, C_l-C_d
.
import af_tools.plotpolars
plotpolars
plotpolars(Polar)
plotpolars(alpha, cl, cd, cm)
Input | Example | Default |
---|---|---|
Polar |
MyPolar |
- |
alpha |
1:10 |
- |
cl |
1:10 , rand(10,2)
|
- |
cd |
1:10 , rand(10,2)
|
- |
cm |
1:10 , rand(10,2)
|
- |
findstall
Finds the stall angle of attack and the associated C_l
and C_d
.
import af_tools.findstall
[alpha_s, cl_s, cd_s] = findstall
[alpha_s, cl_s, cd_s] = findstall(Polar)
[alpha_s, cl_s, cd_s] = findstall(alpha, cl, cd)
Input | Example | Default |
---|---|---|
Polar |
MyPolar |
- |
alpha |
1:10 |
- |
cl |
1:10 , rand(10,2)
|
- |
cd |
1:10 , rand(10,2)
|
- |
findzerolift
Finds the zero-lift angle of attack and the associated C_d
.
import af_tools.findzerolift
[alpha_zeroL, cd_zeroL] = findzerolift
[alpha_zeroL, cd_zeroL] = findzerolift(Polar)
[alpha_zeroL, cd_zeroL] = findzerolift(alpha, cl, cd)
Input | Example | Default |
---|---|---|
Polar |
MyPolar |
- |
alpha |
1:10 |
- |
cl |
1:10 , rand(10,2)
|
- |
cd |
1:10 , rand(10,2)
|
- |
findcllinearrange
Finds the range of angles of attack for which the C_l
can be considered
linear.
import af_tools.findcllinearrange
[alphaRange, clRange, clSlope] = findcllinearrange
[alphaRange, clRange, clSlope] = findcllinearrange(Polar)
[alphaRange, clRange, clSlope] = findcllinearrange(alpha,cl)
Input | Example | Default |
---|---|---|
Polar |
MyPolar |
- |
alpha |
1:10 |
- |
cl |
1:10 , rand(10,2)
|
- |
Licence
Copyright (c) 2022 Thomas Lambert, University of Liège.
All functions and scripts of the af_tools code are licensed under the Apache 2.0 Licence.