Page 5 of 8 FirstFirst ... 34567 ... LastLast
Results 41 to 50 of 80

Thread: XFOIL with MATLAB

  1. #41
    Join Date
    Apr 2008
    Beans
    135

    Re: XFOIL with MATLAB

    Thanks for helping out, aaepl. I've been really busy with work and personal stuff, so I've had ZERO time to work on solving this problem. I thought in xfoilwrapper.pl I had a Windows-friendly command, but perhaps it's not right.

    In any case, for anyone that can't get this working on Windows, I strongly suggest you change your Perl from the MATLAB-built-in interpreter to using ActivePerl.

    As aaepl said, messing around with the source code in xfoilwrapper.pl isn't too challenging - and if you're comfortable working in MATLAB, you shouldn't be too flummoxed by writing in Perl...

    I'm making some progress on the more generalized XFOIL/MATLAB hook, and at some point I might start a SourceForge page or something to make the project larger, should it require that. I don't see it getting that big, since all you need to be able to input is Re, Ma and alfa (and aseq to get a range of alfa), but it would be nice to have others help out.

    I'll keep everyone apprised as I continue. Development is kind of on hold due to issues with my own life that I'm taking care of.

  2. #42
    Join Date
    Apr 2008
    Beans
    135

    Re: XFOIL with MATLAB

    Quote Originally Posted by aaepl View Post
    Hi Folks,

    I too am interested in getting matlab talking to xfoil. I have worked with PABLO in the past, but XFOIL is industry standard. I too am running windows and matlab 7.4. I'm hitting an error probably due to an old perl version.

    However, my question is can we get this perl script to also output moment coefficient about the quarter chord and centre of pressure location. I.e expand the matlab function to:

    function [CL,CD, CM, XCP] = get_coeffs(alfa, Re, Ma, NACA)

    That would be golden. Furthermore, instead of specifing a NACA string can we make it a pointer to a file of coordinates that XFOIL can read?

    If these features can be included that will be one powerful simulation tool!

    I'll work on this as well and post any progress I make.

    Cheers

    Let me know how far you get - this would be pretty interesting to have and not at all difficult. I basically just grab CL and CD from the output coeffs.txt and pipe that back to MATLAB, but it wouldn't be difficult to make it output CM and XCP either.

    As for specifying non-NACA profiles: for right now, I just hardcoded airfoils into xfoilwrapper.pl, but this idea is definitely on the docket.

  3. #43
    Join Date
    Oct 2009
    Location
    Surabaya, Indonesia
    Beans
    19
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: XFOIL with MATLAB

    Hi all,

    I also interested of using matlab with xfoil but I'm not familiar yet with xfoil. I tried azredwing's script and I got CL and CD value as text, few additional matlab command then I got myself CL and CD value as matlab variables. I would like to do modification a NACA model to get best CL. I want xfoil to do the calculation of CL and Matlab do the optimization. Is there a way to do it?

  4. #44
    Join Date
    Jul 2010
    Beans
    4

    Re: XFOIL with MATLAB

    Quote Originally Posted by azredwing View Post
    Let me know how far you get - this would be pretty interesting to have and not at all difficult. I basically just grab CL and CD from the output coeffs.txt and pipe that back to MATLAB, but it wouldn't be difficult to make it output CM and XCP either.

    As for specifying non-NACA profiles: for right now, I just hardcoded airfoils into xfoilwrapper.pl, but this idea is definitely on the docket.
    Hi azredwing,

    Yeah I have got this function working. As you say CM is easy enough, and XCP is simply 0.25 - (cm/cl), becasue the moment coefficient is taken about the quarter chord.

    As for the aerofoil I have just put a folder of aerofoils that comes with xfoil in the same directory as the perl script. Then in my matlab function I point the script to the files in that folder. That opens up 1500 different aerofoils to use. If you want you can also make your own aerofoils on the fly in matlab, paste them into that same folder and get xfoil to crunch the numbers on them, pretty nifty when you want to linearly interpolate between two aerofoils.

    With this sort of power, it opens up so many possibilities. For instance I have now made a matlab program that uses xfoil to produce Lift/Drag plots as a function of CL for many different aerofoils all overlaid on the one plot. You can do the same for Cm and Cd, allowing you to rapidly determine the best aerofoils for a given flow condition.

    I don't have the time or will-power to take this any further, because it has addressed all my needs, but I'll check back here periodically to help out if I can.

    Cheers

  5. #45
    Join Date
    Apr 2008
    Beans
    135

    Re: XFOIL with MATLAB

    First of all, I'm glad everyone is so interested in my work. I'm really sorry that I haven't been able to check in here more often to help people out. Quite frankly the code I wrote does its job well enough for me, and I had no idea it would get as popular as it did. I'm thinking of getting a SourceForge page and making this a full-blown project. If there's anyone out there willing to help me out here, let me know - please PM me and we can discuss privately.

    Quote Originally Posted by aaepl View Post
    Hi azredwing,

    Yeah I have got this function working. As you say CM is easy enough, and XCP is simply 0.25 - (cm/cl), becasue the moment coefficient is taken about the quarter chord.

    As for the aerofoil I have just put a folder of aerofoils that comes with xfoil in the same directory as the perl script. Then in my matlab function I point the script to the files in that folder. That opens up 1500 different aerofoils to use. If you want you can also make your own aerofoils on the fly in matlab, paste them into that same folder and get xfoil to crunch the numbers on them, pretty nifty when you want to linearly interpolate between two aerofoils.

    With this sort of power, it opens up so many possibilities. For instance I have now made a matlab program that uses xfoil to produce Lift/Drag plots as a function of CL for many different aerofoils all overlaid on the one plot. You can do the same for Cm and Cd, allowing you to rapidly determine the best aerofoils for a given flow condition.

    I don't have the time or will-power to take this any further, because it has addressed all my needs, but I'll check back here periodically to help out if I can.

    Cheers
    I think I've got enough time now to start working on this more generally. Here's the function call for the framework I'm thinking of:

    Code:
    function [CL,CD,CM, Xcp] = xfoil(airfoil, Re, Ma, maxit, alfa_start, alfa_end, alfa_step)
    So you are required to specify airfoil, Re, Ma, and alfa_start; maxit will default to some number, alfa_end and alfa_step are only used when you want to do a MATLAB aseq command, since that's much more efficient than calling this function over and over again in a for loop.

    Other ideas for what needs to go in?

    Also could you post or send me your modifications? I'd like to incorporate them if they're already working. (Of course when this is released you will get full credit - I'd like to release under the GPL or something.)

  6. #46
    Join Date
    Apr 2008
    Beans
    135

    Re: XFOIL with MATLAB

    Quote Originally Posted by dewapur View Post
    Hi all,

    I also interested of using matlab with xfoil but I'm not familiar yet with xfoil. I tried azredwing's script and I got CL and CD value as text, few additional matlab command then I got myself CL and CD value as matlab variables. I would like to do modification a NACA model to get best CL. I want xfoil to do the calculation of CL and Matlab do the optimization. Is there a way to do it?
    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

  7. #47
    Join Date
    Apr 2008
    Beans
    135

    Re: XFOIL with MATLAB

    Hi all,

    Development is under full swing! Check out http://sourceforge.net/projects/mpxfoil/ - this will be updated rapidly in the next few days. A release for Linux should be coming up shortly - at this point it's just taking care of setting up svn and doing some legalese stuff.

    Windows users need to hold tight - there are several fundamental differences between Linux and Windows that dictate how I control XFOIL. It's proven very difficult to write for Windows, mostly because XFOIL expects a (pseudo)terminal and ptys don't exist in Windows. I'm trying to build a workaround, but there's a chance this utility might not be buildable for Windows in its current form.

  8. #48
    Join Date
    Apr 2008
    Beans
    135

    Re: XFOIL with MATLAB

    Hi all,

    MPXF 0.1 is available for release for Windows, Mac, and Linux! Get it at https://sourceforge.net/projects/mpxfoil/ .

    Read the README. There's some pretty major prerequisites to satisfy if you're running Windows, and a couple Perl modules that everyone needs to have installed to utilize this software.

    Please PM me or email me if you have any questions/comments/concerns/bug reports. I really hope this works out and finally provides the XFOIL/MATLAB interface everyone has been looking for!

  9. #49
    Join Date
    Sep 2010
    Beans
    6

    Re: XFOIL with MATLAB

    Hello all,

    I'm new here. I study aerospace engineering and for a project I'm trying to optimize an airfoil using MATLAB. I've tried the script posted on the first page of this thread, but it only works partially I think. I don't know anything about perl, so I would appreciate some help here.


    It all runs well until the coeffs.txt is created. That seems alright, but MATLAB then gives and error:

    ??? Error: Unexpected MATLAB operator.

    Error in ==> get_coeffs at 19
    eval(perl('xfoilwrapper.pl', alfa, Re, Ma, NACA));

    Error in ==> test at 9
    get_coeffs(alfa, Re, Ma, NACA)
    If I'm right the problem can only be caused by perl not being able to read the file coeffs.txt properly. I'm guessing it is because I have a different version of Xfoil. The exe file is called XfoilP4.exe, some commands were different too, but I fixed that.

    The coeffs.txt file looks like this:


    XFOIL Version 6.94

    Calculated polar for: NACA 0024

    1 1 Reynolds number fixed Mach number fixed

    xtrf = 0.100 (top) 0.250 (bottom)
    Mach = 0.000 Re = 1.200 e 6 Ncrit = 9.000

    alpha CL CD CDp CM Top_Xtr Bot_Xtr
    ------- -------- --------- --------- -------- ------- -------
    0.000 -0.0219 0.01241 0.00381 0.0038 0.1000 0.2500
    Do I need to change something in the part were the script tries to read this file?

    I this is not the case, could someone tell what's causing the error?


    thanks alot! And indeed if it all works it's very powerful.

  10. #50
    Join Date
    Apr 2008
    Beans
    135

    Re: XFOIL with MATLAB

    Quote Originally Posted by Schuifpui2 View Post
    Hello all,

    I'm new here. I study aerospace engineering and for a project I'm trying to optimize an airfoil using MATLAB. I've tried the script posted on the first page of this thread, but it only works partially I think. I don't know anything about perl, so I would appreciate some help here.


    It all runs well until the coeffs.txt is created. That seems alright, but MATLAB then gives and error:

    If I'm right the problem can only be caused by perl not being able to read the file coeffs.txt properly. I'm guessing it is because I have a different version of Xfoil. The exe file is called XfoilP4.exe, some commands were different too, but I fixed that.

    The coeffs.txt file looks like this:


    Do I need to change something in the part were the script tries to read this file?

    I this is not the case, could someone tell what's causing the error?


    thanks alot! And indeed if it all works it's very powerful.
    Check out the post directly above you - it should be a cleaner version of my original script. It does need the XFOIL binary to be named "xfoil.exe" if you're running Windows.

    Let me know if MPXF works out. I haven't tested it heavily on Windows.

Page 5 of 8 FirstFirst ... 34567 ... LastLast

Bookmarks

Posting Permissions

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