File Exchange

image thumbnail

rafael-aero/XFOILinterface

version 1.1 (9.77 KB) by

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

4.66667
18 Ratings

16 Downloads

Updated

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

Comments and Ratings (47)

Dylan Mack

Is this interface available for Mac in any way? Other downloading platforms say this interface works for Mac OS X, however the error "Unix version not yet implemented!" shows whenever I try to use the interface.

Hi armando pirlo have you solve this problem, if so please what have you done to solve the problem.
Error using textscan
HeaderLines must be integer-valued.
Error in Airfoil (line 34)

Thanks,
Aziz

Hi Rafael.

I'm using the R2017a version, and apparently, their a change using the textscan function and the error that trow is:
Error using textscan
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in Airfoil (line 24)
tmp=textscan(Header, '%f%f','MultipleDelimsAsOne',true);

Error in exampleXFOIL (line 7)
xf.Airfoil = Airfoil('SC(2)-0610 AIRFOIL.dat');
Apperently even if you change the value from "TRUE" to "1", in line 24, it still not working.

I dont know if you have any idea on how to fix it

Cheers

Hi Rafael,

Thank you for the amazing program. i wonder if the viscous solution is on of off in this code. if it is of, is there a way to consider the viscous solution only.

Best Regards,
Aziz

Henry Jiang

Hi Rafael,

Do you have any updates on the error stated by eren karaca earlier? I realized that the code still works provided it is running on an older version of MATLAB, and not a newer version.

Thanks!

Martin Kurien

er, I may be wrong about that since the fix doesn't quite work. I know that I haven't been able to get importing from a .dat file to work with a NACA0012 that I got from Airfoil Tools. It isn't a big deal since I can always generate it, but It seems weird that there is a problem.

Martin Kurien

I found an error in lines 52 and 53 in the Airfoil Class. The indexing is given as iLE:-1:1, when it should be end:-1:iLE.

eren karaca

Hi Rafael,
The code works perfect until i receive the following errors;

Error using XFOIL/readPolars (line 27)
Invalid polar file Polar.txt

Error in exampleXFOIL (line 55)
xf.readPolars;

Are there any solution you may offer?
Thanks so much!

Russell Woo

Hi Rafael,
This interface is so great and very useful!
When I load my design airfoil.dat ,it show me some errors.
error fgetl (line 33)
[tline,lt] = fgets(fid);

error Airfoil (line 23)
Header = fgetl(fid);

error exampleXFOIL (line 7)
xf.Airfoil = Airfoil('2412-1.dat');

I am a new guy to use the matlab.My matlab version is 2016b.
Can you solve this problem? appreciate~~~

Rafael Oliveira

Rafael Oliveira (view profile)

Hi Nicolas,
you can try this:

for alpha = 0:0.1:25
xf.addAlpha(alpha);
xf.addActions(sprintf('CPWR alpha_%f.txt',alpha));
end

Hi Rafael,
Do you know how I can extract the Cp values computed by XFoil for a single set of parameters ?
Thanks for your help and your program !

Thang Le Duc

armando pirlo

Hi Rafael,
with your tips the code works.
I use the versione R2015b.

Thanks.

Rafael Oliveira

Rafael Oliveira (view profile)

Hi Armando,

which version of MATLAB are you using? It seems that textscan has changed since I published this code, try replacing the lines with
HasHeader = false;
HasHeader = true;

in the Airfoil.m code with
HasHeader = 0;
HasHeader = 1;

And letting me know if it works!

armando pirlo

Hi Rafael,
I'm trying to import .dat file with coordinates of an airfoil but when i start the script i get an error:

Error using textscan
HeaderLines must be integer-valued.

Error in Airfoil (line 34)
Coordinates = textscan(fid, '%f%f','HeaderLines',HasHeader,'MultipleDelimsAsOne',true);

Error in exampleXFOIL (line 10)
xf.Airfoil = Airfoil('MH_115.dat');

The MH_115.dat file is a standard two column text file in the Selig format (you ask the Eppler format but it's the same, right?).

Thanks for the code.

Hi Rafael,

Thanks a lot, works great. I tried doing it through:
xf.changePaneling(80); %Change number of panels

but with not much luck. Although it does run faster.

Thanks for making the code as well man! ;)

Rafael Oliveira

Rafael Oliveira (view profile)

Hi George,
You can reinterpolate the coordinates of the airfoil using the pchip function from MATLAB, something like:

af.UpperY = pchip(af.UpperX, af.UpperY,linspace(af.UpperX(1),af.UpperX(end),200));
af.UpperX = linspace(af.UpperX(1),af.UpperX(end),200);

and then the same for the LowerX / LowerY coordinates.

Hi Rafael,
Is there a way to change the number of panels (or number of airfoil points) for an imported airfoil?
Thanks

Wenxiang Ding

Andrea

Andrea (view profile)

Rafael, can you please help me with your matlab coding? I need to compare them with mine: same naca number. Thanks

This is a great work

Tom Clark

This is seriously very good.

So good its annoying how much time I put into my previous solution :(

It could do with better commenting within the source for maintainability and better description of the inputs - but people familiar with xfoil should pick it up pretty quickly.

Frustrating that it doesn't run on unix - if I get some time I'll update and share the code back.

Thanks rafael!

H E

H E (view profile)

I've used XFOIL-MATLAB interface with R2014a with no problems, it's been great! However, I just upgraded to R2014b and, when reading my own airfoil .dat file, I get the error:

Error using textscan
HeaderLines must be integer-valued.

Error in Airfoil (line 35)
Coordinates = textscan(fid, '%f%f','HeaderLines',HasHeader,'MultipleDelimsAsOne',true);

Changing line 26 of Airfoil.m to "HasHeader=1" instead of "HasHeader=true" seems to fix the problem. I'm not sure why, as those two statements should be equivalent.

Arash

Arash (view profile)

SREEJITH

how can i develop interface for 'INTE'..?

Lucas Augusto

hey, i'm having this problem:
>> exampleXFOIL
Cannot find an exact (case-sensitive) match for 'XFOIL'

The closest match is: xfoil in C:\Users\Lucas94\Documents\MATLAB\xfoil.m

Error in exampleXFOIL (line 2)
xf = XFOIL;
Could anyone help me?

Guilherme

Thanks for the awesome interface!

I am though, facing some issues when trying to paralell processing XFOIL in a program, using parfor loops. Could you give me some tips or a guide on how to simultaneosly run more than one airfoil analysis at the same time? Thanks!

James

James (view profile)

I am a masters student of aeronautics at Durham finding this very useful, is it possible to print the tables of the results as i then need to to use the nubers to generate lift profiles. Any help would be great I am not all to familiar with matlab.

2 questions for you. I have been trying to get the program to print a pressure file, specifically a CPWR file. I saw that you already have the framework for it in the XFOIL.m file, but I'm have trouble getting the commands right. Also, I would like to cycle through a couple of different airfoils in the program. How would I do that?

Rafael Oliveira

Rafael Oliveira (view profile)

Hi Matt,
To hide the xfoil window, just set (assuming x = XFOIL;)
x.Visible = false;
Any other doubts, drop me an email!

Matt Brown

Is there any way to supress the xfoil window? I implemented this into a loop and the repeated open/close of xfoil gets to be a bit much.

Other than that, good code!

Mingyao

Hi Rafael,

I shot another email to your listed mailbox. Thanks.

Mingyao

Rafael Oliveira

Rafael Oliveira (view profile)

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!

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.

Rafael Oliveira

Rafael Oliveira (view profile)

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.

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')

Rafael Oliveira

Rafael Oliveira (view profile)

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

Matthias

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

Matthias

toto13000

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

Rafael Oliveira

Rafael Oliveira (view profile)

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

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

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

Updates

1.1

Fixed the URL to download XFoil automatically

MATLAB Release
MATLAB 7.11 (R2010b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video