Thread: XFOIL with MATLAB

1. 5 Cups of Ubuntu
Join Date
Oct 2009
Location
Surabaya, Indonesia
Beans
19
Distro
Ubuntu 10.04 Lucid Lynx

Re: XFOIL with MATLAB

Originally Posted by azredwing
I suppose you could iterate over many airfoils to maximize CL for a particular alfa and Re, but this is really an NP-complete problem: airfoil optimization is extremely difficult computationally and quite frankly XFOIL is not designed to perform airfoil optimization.

The problem is this: given some starting values of CL for, say, a 4-digit NACA airfoil, how do you determine what to vary? You could increase the camber (first digit), location of camber (second digit), or thickness (final two digits) - but varying these will have effects on CL_0, stall behavior, etc. There's no way to uncouple CL from these other factors on the CL-alfa curve, and there's no clear functional relationship between CL and any of the parameters you could vary in a 4-digit NACA airfoil - and any functional relationship will also be a function of Re and Ma, so you've got to have a very strict flight regime to even think of doing some type of airfoil optimization.

This gets even more complicated using a 5-digit series airfoil, and we're truly in an NP-complete situation when you want to build custom airfoils. Ph.Ds do this with extremely powerful CFD software that is way outside the bounds of my knowledge of the field of aerodynamics.

If any Ph.Ds want to contribute to the project, contact me
yeah, mapping CL and CD over some airfoil is what I'm trying to do. I let XFOIL to calculate CL and CD over some airfoil (4-digit NACA) and Matlab handle the flow. The calculation is done with some limitation range of camber, camber position, thickness and alfa but Re is fixed. It went stuck on the way to calculate an airfoil, for example NACA 6807 with alfa 3. I tried directly the airfoil with XFOIL and it converged, so it means should have no problem. Is XFOIL have limitation over memory it can handle?

btw, what is NP-complete problem? unluckily I'm no Ph.D student yet

2. First Cup of Ubuntu
Join Date
Sep 2010
Beans
6

Re: XFOIL with MATLAB

Sorry for the late reply, I wasn't at home this weekend. The same problem arises for a range of alpha.

3. Gee! These Aren't Roasted!
Join Date
Apr 2008
Beans
135

Re: XFOIL with MATLAB

Originally Posted by Schuifpui2
Sorry for the late reply, I wasn't at home this weekend. The same problem arises for a range of alpha.
Thanks for confirmation - I'll take a look this weekend. I've got lots of ideas for the next iteration of this project, but usage is absolutely #1 on the list.

4. First Cup of Ubuntu
Join Date
Oct 2010
Beans
3

Re: XFOIL with MATLAB

azredwing,
Looks like a great tools.
I am facing the following issue.
I am using mac os x.
I followed the read me instructions.

When I use mpxfoil i get the following error message:

Can't open perl script "xfw.pl": No such file or directory
> In mpxfoil at 137

The script xfw.pl is in the same directory as mpxfoil.
Any clue on what the issue could be ?

Thanks

5. Gee! These Aren't Roasted!
Join Date
Apr 2008
Beans
135

Re: XFOIL with MATLAB

Originally Posted by bmuyl
azredwing,
Looks like a great tools.
I am facing the following issue.
I am using mac os x.
I followed the read me instructions.

When I use mpxfoil i get the following error message:

Can't open perl script "xfw.pl": No such file or directory
> In mpxfoil at 137

The script xfw.pl is in the same directory as mpxfoil.
Any clue on what the issue could be ?

Thanks
Hi bmuyl:

I don't have any experience with Macs so this is gonna be a bit difficult to do for me. But, I think I can see what the problem is. From what directory are you calling the mpxfoil function? I have a feeling that you're in a different directory than where mpxfoil.m is located - I use relative paths to call xfw.pl. Try setting your current directory to be the same directory as mpxfoil.m and see what happens.

TO ALL: I am having a very difficult time keeping up with my school work and managing this project. If anyone is interested in helping me develop these tools, please let me know.

6. First Cup of Ubuntu
Join Date
Oct 2010
Beans
3

Re: XFOIL with MATLAB

azredwing

Thanks !
Was as easy as that.

Cheers

7. First Cup of Ubuntu
Join Date
Oct 2010
Beans
3

Re: XFOIL with MATLAB

azredwing,
I have now xfw.pl found by mpxfoil.m
and I have added xfoil path to matlab so that xfw.pl finds it.
That is working as mpxfoil opens an xfoil window ( would be great to avoid that, by the way..)

But I get the following message:

>> mpxfoil('6312', 3000000, 0, 500, 0)
XFOIL error: process ended prematurely at xfw.pl line 98

> In mpxfoil at 147

ans =

NaN

Line 98, is the following one:

\$h->pump;

Any clue ?
Thanks

Benjamin

8. First Cup of Ubuntu
Join Date
Jan 2011
Beans
4

Re: XFOIL with MATLAB

Hi
Just a short question: why do you use a perl wrapper?

It seems to me that everything can be done within matlab: writing a list of command for xfoil in a file input.in and calling xfoil with: system('/path/to/xfoil/xfoil < input.in')

I haven't tried, but doesn't this work on windows?
Do you want to make this portion of code independent of matlab to use it with other languages like python or with a shell script?

9. Gee! These Aren't Roasted!
Join Date
Apr 2008
Beans
135

Re: XFOIL with MATLAB

Originally Posted by elmanuelito
Hi
Just a short question: why do you use a perl wrapper?

It seems to me that everything can be done within matlab: writing a list of command for xfoil in a file input.in and calling xfoil with: system('/path/to/xfoil/xfoil < input.in')

I haven't tried, but doesn't this work on windows?
Do you want to make this portion of code independent of matlab to use it with other languages like python or with a shell script?

Hi emanuelito:

The main reason why I use the Perl wrapper is because I use psuedo-ttys to catch when XFOIL fails to iterate and needs to manually have the user enter a '!' to continue iterating. As far as I know this isn't possible with MATLAB alone. (Really, you could use Python or any shell script you'd like - the Perl wrapper I wrote makes it very easy to run pseudotty.)

I used to simply build the list of commands like you've got written, but the system ends up just waiting for a '!' that will never come if you do it naively. You can't know in advance when you'll need a '!' which is why I have Perl check. I can read the ptty in real time from XFOIL.

10. Gee! These Aren't Roasted!
Join Date
Apr 2008
Beans
135

Re: XFOIL with MATLAB

Originally Posted by elmanuelito
Hi
Just a short question: why do you use a perl wrapper?

It seems to me that everything can be done within matlab: writing a list of command for xfoil in a file input.in and calling xfoil with: system('/path/to/xfoil/xfoil < input.in')

I haven't tried, but doesn't this work on windows?
Do you want to make this portion of code independent of matlab to use it with other languages like python or with a shell script?

Now that I think about it (this probably won't help for you), you can bypass the Perl script because MATLAB can leverage *NIX's popen() functionality via this module: http://www.mathworks.com/matlabcentr...exchange/13851

To keep the program platform independent (even though really the Windows version is just a hack), I use the Perl backend.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•