Skip to content
Snippets Groups Projects
Thomas Lambert's avatar
Thomas Lambert authored
Keep Readme short and readble. The doc should be fully contained in the
MATLAB code of each function/class.

This commit also adds details on how to use classes and the description
of the Polar class.
e64cf0b1
History

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

Every principal function or class contains a complete description in its preamble. Type help af_tools<function> in MATLAB command window to print it.

Install and use

Installation

  1. Either clone this repository or download a .zip version of the source code of the latest release.
  2. Place the +af_tools/ folder somewhere on your MATLAB Path such as:

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., nacaairfoil calls nacacamber). In that situation, MATLAB forces the main function to re-import explicitly the 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).
  • All functions can be called without arguments. If that is the case, they will prompt the user to manually enter or select the few mandatory arguments. The rest will be set to default values.

List of functions:

  • Generic
    • xf2mat: Aggregates multiple XFOIL or XFLR5 polar results into a single structure.
    • formatairfoilcoord: Load and re-format airfoil coordinates from datafile.
  • Airfoil generation
    • nacacamber: Generates the coordinates of the camberline for a NACA 4 or 5 digits airfoil.
    • nacaairfoil: Generates the full coordinates of a NACA 4 or 5 digits airfoil.
  • Polar manipulation
    • extendpolar: Extends polars to the full range of \alpha ([-180, 180] deg).
    • findstall: Finds the stall point and returns the corresponding \alpha, C_l and C_d.
    • findzerolift: Finds the zero-lift angle and the associate C_{d0}.
    • findcllinearrange: Finds the linear range of the lift coefficient and returns the range and lift slope.
    • plotpolars: Plot the different polar curves.

Documentation

Each function contains its own complete documentation. Print a full description of the function, its inputs/outputs and some examples by typing

help af_tools.<functionName>

Classes

This package defines two classes that can be used to simplify input/outputs in other codes.

Use of classes in Matlab

This is a very basic practical introduction to using classes in MATLAB, some terms are voluntarily inexact, but they facilitate the understanding of the concepts.

In MATLAB, objects behave a bit like structures (i.e. they use dot-indexing). The difference is that their properties are defined through the class and cannot be created or altered on-the-fly like for structures. To create an object of a given class, just do

import af_tools.*
Pol = Polar; % equivalent Pol = af_tools.Polar if no import

```

Then the properties can be set and accessed as for structures:
````matlab
Pol.prop1 = 1;
Pol.prop2 = 'test';
a = 1 + Pol.prop1;

The methods are a mixed between functions and properties:

Pol = Pol.loadpolar('myfile.mat');
Pol.plotpolars();

Polar

This class defines Polar objects. One Polar object can hold multiple polars curves (one per Reynolds number), but each object corresponds to a single airfoil.

Properties

  • Public properties (can be set and accessed directly by the user):
    • airfoil : Airfoil name
    • reynolds : Rynolds number of each polar curve
    • mach : Mach number of each polar curve
    • nCrit : nCrit number of each polar curve
    • aoa : Angles of attack (one column per Reynolds)
    • cl : Lift coefficient (one row per aoa, one column per Reynolds)
    • cd : Drag coefficient (one row per aoa, one column per Reynolds)
    • cm : Moment coefficient (one row per aoa, one column per Reynolds)
  • Private properties (Are set through the methods, but can be accessed directly by the user):
    • Ext : Struct with the data of the extended polars
    • Stall : Struct with the data of the stall point for each curve
    • Zero : Struct with the data of the zero-lift point for each curve
    • Lin : Struct with the data of the linear range each curve

Methods

Besides some ad-hoc methods, the polar manipulation function defined in the root of the package are re-implemented as methods for the Polar class. This simplifies greatly the obtention of important values for each of the polar curves contained in the object.

List of Polar methods:

  • Generic
    • loadpolar: Load a polar from a MAT-file into a Polar object
  • Polar manipulation
    • findstall: Finds the stall point and returns the corresponding \alpha, C_l and C_d.
    • findzerolift: Finds the zero-lift angle and the associate C_{d0}.
    • findcllinearrange: Finds the linear range of the lift coefficient and returns the range and lift slope.
    • analyse: Runs the above three methods successively
    • extendpolar: Extends polars to the full range of \alpha ([-180, 180] deg).
    • plotpolars: Plot the different polar curves.

As for the functions, the methods are completely documented in MATLAB. To access their documentation, just type:

help af_tools.Polar.<methodName>

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.