Code Monkey home page Code Monkey logo

xfoil-python's Introduction

IMPORTANT NOTE: major changes and upgrades are currently taking place. This readme file might not be up to date. Please contact me if you need any details on current usage. (July 2020)

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

See #7 (comment) for installation instructions.

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:

>>>  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:

>>>  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:

>>>  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:

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

This should produce the following figure:

NACA 0012 Lift Curve

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

>>>  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.

xfoil-python's People

Contributors

daniel-de-vries avatar danieldevriesdarcorp avatar kikem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

xfoil-python's Issues

Automatic installation

There seems to be a problem in the build with the dynamic library.

It stops because it tries to find a file which is not present. However, even if it reports error, the library has actually been compiled correctly.

BLD: problems with the installation

The user @parmonon reported a problem after installing the library and then running it.

>>> from xfoil import Xfoil
>>> xf = Xfoil()
Traceback (most recent call last):

  File "<ipython-input-2-334904b966f4>", line 1, in <module>
    xfoil.XFoil()

  File "/usr/local/lib/python3.5/dist-packages/xfoil-0.0.16-py3.5.egg/xfoil/xfoil.py", line 66, in __init__
    copy2(lib_path, self._lib_path)

  File "/usr/lib/python3.5/shutil.py", line 251, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)

  File "/usr/lib/python3.5/shutil.py", line 114, in copyfile
    with open(src, 'rb') as fsrc:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/Kike/Library/Mobile Documents/com~apple~CloudDocs/Documents/Inbox/TU_Delft/MsC/Q1/Aircraft_Aerodynamics/Code/xfoil-python/build/lib.macosx-10.7-x86_64-3.6/xfoil/libxfoil.dylib'

Problems with the __del__ magic command in Xfoil

While running in a notebook, after going through an optimization routine, this output came out.

Exception ignored in: <bound method XFoil.__del__ of <xfoil.xfoil.XFoil object at 0x12e0c54a8>>
Traceback (most recent call last):
  File "/Users/Kike/Library/Mobile Documents/com~apple~CloudDocs/Documents/Inbox/TU_Delft/MsC/Q1/Aircraft_Aerodynamics/Code/xfoil-python/src/xfoil/xfoil.py", line 78, in __del__
    handle = self._lib._handle
AttributeError: 'XFoil' object has no attribute '_lib'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.