Skip to main content

Stripped down version of XFOIL as compiled python module

Project description


General
-------
This is a stripped down version of XFOIL, presented in the form of a Python module. What's unique about this package
w.r.t. many others out there allowing an interface to XFOIL, is the fact that the Python code talks directly to a
compiled Fortran library. This approach avoids having to read/write in-/output files to the disk and communicating with
the XFOIl executable. Eliminating the need for constant disk I/O operations can significantly speed up parallel
frameworks in particular, giving this approach a clear advantage.

Building and Installing the Python Module
-----------------------------------------
If you are on a Windows machine (64bit) with Python 3.6, installing XFoil is a simple matter of running:

```bash
pip install xfoil
```

If you are using a different type of machine, or a different version of Python, you will have to make sure some
software is installed on your system in order for the package to be successfully built. First of all, the module targets
Python 3, and does NOT support Python 2. So make sure a Python 3 environment is installed and available.
Furthermore, working compilers for C and Fortran have to be installed and on the PATH. On Windows, the build and
installation have ONLY been tested with MinGW, using gcc and gfortran.

Then, installing XFoil should be as simple as running

```bash
pip install .
```

from the root of the downloaded repository.

On Windows, you may have to force the system to use MinGW. To do so, create a file named `distutils.cfg` in
`PYTHONPATH\Lib\distutils` with the following contents:

```INI
[build]
compiler=mingw32
```

If you are not able to create this file for your Python environment, you can instead create a file named `setup.cfg` in
the root of the repo with the same contents. It is also possible to force the use of MinGW directly when invoking
`pip` by calling:

```bash
pip install --global-option build_ext --global-option --compiler=mingw32 .
```

Using the Module
----------------
All XFoil operations are performed using the `XFoil` class. So the first step when using this module is to create an
instance of this class:

```pycon
>>> from xfoil import XFoil
>>> xf = XFoil()
```

If this does not produce any errors, the installation should be functioning properly.


The symmetric NACA 0012 airfoil is included as a test case. It can be loaded into the XFoil library like this:

```pycon
>>> from xfoil.test import naca0012
>>> xf.airfoil = naca0012

Number of input coordinate points: 160
Counterclockwise ordering
Max thickness = 0.120008 at x = 0.308
Max camber = 0.000000 at x = 0.033

LE x,y = -0.00000 0.00000 | Chord = 1.00000
TE x,y = 1.00000 0.00000 |

Current airfoil nodes set from buffer airfoil nodes ( 160 )
```

Once the airfoil has been loaded successfully it can be analyzed. Let's analyze it for a range of angles of attack, at a
Reynolds number of one million. Let's limit the maximum number of iterations to 40 (the default is 20) as well.
For the range of angles of attack, we will go from -20 degrees to 20 degrees with steps of 0.5 degrees:

```pycon
>>> xf.Re = 1e6
>>> xf.max_iter = 40
>>> a, cl, cd, cm = xf.aseq(-20, 20, 0.5)
```

The XFOIL library should produce a lot of output, which should be familiar to those who have used the original XFOIL
application before. The final result are lists of angles of attack, `a`, and the corresponding lift coefficients, `cl`,
drag coefficients, `cd`, and moment coefficients, `cm`. We can now, for example, plot the lift curve for this airfoil:

```pycon
>>> import matplotlib.pyplot as plt
>>> plt.plot(a, cl)
>>> plt.show()
```

This should produce the following figure:

![NACA 0012 Lift Curve](https://github.com/daniel-de-vries/xfoil-python/raw/master/naca0012-lift-curve.png)

Just like in the original XFOIL application, an airfoil can also analyzed for a single angle of attack, single lift
coefficient, or a range of lift coefficients. The commands for these operations are

```pycon
>>> cl, cd, cm = xf.a(10)
>>> a, cd, cm = xf.cl(1)
>>> a, cl, cd, cm = xf.cseq(-0.5, 0.5, 0.05)
```

to analyze for an angle of attack of 10 degrees, a lift coefficient of 1.0, and for a range of lift coefficients from
-0.5 to 0.5 with steps of 0.05.

For other features and specifics, see the documentation in the Python source files.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xfoil-0.0.12.tar.gz (10.5 kB view details)

Uploaded Source

Built Distributions

xfoil-0.0.12-py3.6-macosx-10.7-x86_64.egg (266.4 kB view details)

Uploaded Source

xfoil-0.0.12-cp36-cp36m-win_amd64.whl (442.2 kB view details)

Uploaded CPython 3.6m Windows x86-64

xfoil-0.0.12-cp36-cp36m-macosx_10_7_x86_64.whl (270.6 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

File details

Details for the file xfoil-0.0.12.tar.gz.

File metadata

  • Download URL: xfoil-0.0.12.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.4

File hashes

Hashes for xfoil-0.0.12.tar.gz
Algorithm Hash digest
SHA256 e61b32f8a45a9e6998434cc5bff9f7a28e34cfa0464130d3df2df1a894b39449
MD5 a8649002b08e55295b7baad14be49e2e
BLAKE2b-256 3a6636128c8095e4d46bdd908a25460e60d6cabc744cd1cd20c63d90e957ae92

See more details on using hashes here.

File details

Details for the file xfoil-0.0.12-py3.6-macosx-10.7-x86_64.egg.

File metadata

  • Download URL: xfoil-0.0.12-py3.6-macosx-10.7-x86_64.egg
  • Upload date:
  • Size: 266.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.4

File hashes

Hashes for xfoil-0.0.12-py3.6-macosx-10.7-x86_64.egg
Algorithm Hash digest
SHA256 1488386368eb9bfba43bdbfdb935104ba9b5d13980aa06463939fee049178acc
MD5 a68a3c0f88b5fd7a8d77af161c008749
BLAKE2b-256 2988713c2d164924181de18cf4181c4efd20d2a8faf654a4df0c66353e3c3ff4

See more details on using hashes here.

File details

Details for the file xfoil-0.0.12-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: xfoil-0.0.12-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 442.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for xfoil-0.0.12-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3fa32b34e4bf2800d6a35aa9c3b1c91b54623b33c4970c60ad15f18b6e669843
MD5 12bef29889f6aa312ecef364cdd9948e
BLAKE2b-256 ac58d5d271442cccb3f11569dac88b71217745fa7f5b3774a9dbf2a361c3bb97

See more details on using hashes here.

File details

Details for the file xfoil-0.0.12-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: xfoil-0.0.12-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 270.6 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.4

File hashes

Hashes for xfoil-0.0.12-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 76aea44a5ef043fae94cc49f0d70c3b8a9df8b02ba94fe21333432d08da195ed
MD5 2b81e55819be981b1a73f25d8224fda3
BLAKE2b-256 2a5b3efa72290b8b2006402c71d0eaadc53c7d065a279e6d4c15bb9e1ae44533

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page