5.0

5.0 | 4 ratings Rate this file 79 Downloads (last 30 days) File Size: 11.61 KB File ID: #30478
image thumbnail

XFOIL - MATLAB interface

by Rafael Oliveira

 

21 Feb 2011

Class interface between XFOIL and MATLAB, with the ability of running many instances in parallel.

| Watch this File

File Information
Description

I developed this interface some time ago, so I finally decided to refine and make it available here. It provides an interface between XFOIL and MATLAB, creating the files required by XFOIL to run, and reading the results back in an easy to access polar structure.

As the goal was to perform airfoil optimization, this interface is capable of parallel execution, so that you can create multiple instances and run all at the same time, without blocking MATLAB. Also, it is possible to hide the plotting window, so XFOIL will not interrupt your work-flow while it is running.

A simple example script using an NACA 23012 is provided, showing the main features of the interface.

XFOIL is not included on this package, but the class will download and extract it for you automatically in case the XFOIL executable is not available in your path.

XFOIL is an analysis software provided by Prof. Mark Drela (from MIT), for the design and analysis of subsonic airfoils. For more info, check his website at http://web.mit.edu/drela/Public/web/xfoil/

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
NACA 4 digit Airfoil Generator, NACA 5 digit Airfoil Generator

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (14)
06 Mar 2011 sunil anandatheertha

thank you so much my friend. I saved a lotttttttttt of time using this.. Thnx. Big FAN (:

06 Mar 2011 sunil anandatheertha

Please include more of the common xfoil features .... Thx (:

07 Mar 2011 Rafael Oliveira

I just implemented what I needed for my project, but you can use the XFOIL.addActions('') to send custom commands to it (just do what you want in an XFOIL section, and take note of the commands you typed).
If you have a list of commands you need, I can try to implement it into the class too...

18 Apr 2011 ZerO

Vey Nice , Please Check www.Airloads.net

28 Jul 2011 toto13000

I look that you kill Xfoil when it freezes.
Do you know that happen so that Xfoil freezes ?

24 Nov 2011 Matthias  
24 Nov 2011 Matthias

Thanks a lot,
could you help me with implementing trailing edge deflection?

29 Nov 2011 Rafael Oliveira

Hi Matthias, I know I've already answered you, but I'll copy it here as a reference for other people:

xFlap = 0.6;
yFlap = 0;
FlapDeflection = 5;

xf = XFOIL;

% Create a NACA 5-series airfoil
xf.Airfoil = Airfoil.createNACA5('23012',150);

% Add a flap deflection to the airfoil
xf.addActions('GDES')
xf.addActions('FLAP')
xf.addActions(num2str(xFlap));
xf.addActions(num2str(yFlap));
xf.addActions(num2str(FlapDeflection));
xf.addActions(''); %Simulate an enter, to get out of GDES mode

18 Feb 2012 Mingyao

Would you be so kind as to explain what the following lines of your code do? Thanks.

            warning('off','MATLAB:DELETE:FileNotFound')
            for i=1:length(this.PolarFiles)
                delete(this.PolarFiles{1})
            end
            warning('on','MATLAB:DELETE:FileNotFound')

20 Feb 2012 Rafael Oliveira

Hi! This part of the code is used to delete any polar files that might exist from previous runs, so that when XFOIL is run a few lines later, with:

PB=java.lang.ProcessBuilder(arg);
this.Process = PB.start;

We can be sure that the polar files are going to be created due to this run, and not previous results. This happens very often when making small modifications in the airfoil that affects the XFOIL convergence, so that you can have a mix of old and new results.

20 Feb 2012 Mingyao

Hi, Rafael! Thank you for your response. I think what I don't really understand about the code is the 'delete' command. I tried a search in MATLAB Help, but the same command seems intended to delete files located in a folder or a handle object. If I simply try to delete a cell in the command window like this, MATLAB will complain. Could you please shed light on the subject? Thanks.

21 Feb 2012 Rafael Oliveira

Hi Mingyao,

The delete command in this case is used to delete the files whose names are stored in the cell array PolarFiles

This cell will have inside something like this:
PolarFiles = {'file1.txt', 'file2.txt', 'file3.txt'};

This is a common misunderstanding with MATLAB, about the difference between a cell array and a normal array of numbers, and how to access the elements. In the case of a cell array, you can access the content using {index}, and a sub-part of the cell as (index).
For example, let's say you have:
>> PolarFiles = {'file1.txt', 'file2.txt', 'file3.txt'};

Then, if you run:
>> PolarFiles(2)
 ans = {'file2.txt'} % Returns a cell array with one element

>> PolarFiles{2}
 ans = 'file2.txt' % Returns the string that was stored in the cell

If you have any further doubt, send me an email and I can answer you directly!

21 Feb 2012 Mingyao

Hi Rafael,

I shot another email to your listed mailbox. Thanks.

Mingyao

03 Mar 2012 Rajesh Senthil Kumar  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
aerospace Rafael Oliveira 22 Feb 2011 11:24:54
xfoil Rafael Oliveira 22 Feb 2011 11:24:54
airfoil Rafael Oliveira 22 Feb 2011 11:24:54
aeronautics Rafael Oliveira 22 Feb 2011 11:24:54
aerodynamics Rafael Oliveira 22 Feb 2011 11:24:54
aircraft Rafael Oliveira 22 Feb 2011 11:24:54
airfoil The University of Iowa 25 Jan 2012 21:04:29
aerodynamics Pranav O 19 Mar 2012 13:45:19
aerospace Pranav O 19 Mar 2012 13:45:20
airfoil Pranav O 19 Mar 2012 13:45:24
xfoil Pranav O 19 Mar 2012 13:45:24

Contact us at files@mathworks.com