For all the people who use Linux - this also works for Linux. One thing, which does not depend on your operating system: In my xfoil version, I had to modify the matlab code. The output I got, had different numbers of heading and also in the cp calculation file, I did not have the y-values. So just small modifications. However, with these small adjustments, the Matlab code works really well. JoshTheEngineer, thank you for your effort.
@@JoshTheEngineer I have went throw the python code in your website for running xfoile and it is working fine and was able to change it to much the analysis i want to carry. but, when i usedin for loop it calculate only the first step then stop calculation i have no clue why can you please take alook to my code and tell me if i did somethg wrong: Ps def Xfoil(Xloc,Yloc,Degree): # %% CREATE LOADING FILE # Knowns NACA = '4418' Renolds ='1000000' AoA = '5' iteration ='200' # Create the airfoil fid = open(xfoilFlnm,"w") fid.write("NACA " + NACA + " ") fid.write("GDES ") fid.write("flap ") fid.write(Xloc +" ") fid.write('999' +" ") fid.write(Yloc +" ") fid.write(Degree +" ") fid.write("exec ") fid.write("
") fid.write("PPAR ") fid.write("
") fid.write("PSAV " + saveFlnmAF + " ") fid.write("OPER ") fid.write("iter ") fid.write(iteration +" ") fid.write("v ") fid.write(Renolds +" ") fid.write("ALFA " + AoA + " ") fid.write("CPWR " + saveFlnmCp + " ") fid.write("pacc ") fid.write(saveFlnmCL+" ") fid.write(" ") fid.write("ALFA " + AoA + " ") fid.write(" ") fid.write("quit") fid.close() for Xloc in Xl: for Yloc in Yl: for Degree in Degr: Xfoil(Xloc,Yloc,Degree) os.system("xfoil.exe < xfoil_input.txt") if os.path.exists(xfoilFlnm): os.remove(xfoilFlnm) if os.path.exists(saveFlnmCL): os.remove(saveFlnmCL)
Josh your videos are very helpful, thank you very much for all your videos. Please keep posting, you are a great teacher and an engineer. i want to run XFoil from Python......is there any tutorial on it?
dude wtf, i was just talking to a friend about how i wanted to learn how to do this ( it was mentioned briefly in my aero class). i literally told my friend about your channel yesterday too. are you watching me???
@@JoshTheEngineer haha same with me Josh, can you please help me, I have made equations for airfoil geometry generation. I want to optimize airfoil with my equation using genetic algorithm in matlab, I will be very glad if you can help me.
Hi, have you ever encountered a problem where XFOIL converged and generated results for the pressure distribution data (XCp and Cp) and other results from the foil struct as well but not for the polar data (CL,CD,Cm)? When I input a particular coordinates to my XFOIL (which is a solution from an optimization problem im currently doing) it generated all the foil struct just fine including the XCp and Cp, but the CL came out as NaN and other polar struct datas such as CD and Cm came out an empty cell. Can you help me with this? Thanks in advance
I saw your video repeatedly, and thank you for this Gold Mine, I have a question when I go to the steps on making that loaded file to be deleted on the Matlab code the comment "% Delete files if they exist" and "delete(saveFlnmAF); " parts, when I uncomment it and click RUN it is saying to error "Warning: File 'Save_Airfoil.txt' not found. > In MATLAB_XFOIL (line 52) Undefined variable 'dataBuffer'. Error in MATLAB_XFOIL (line 55) XB = dataBuffer{1}(:,1); % Boundary point X-coordinate >> What should I do, I watched your video for the 5th time today and I can't see any difference that I am making to get this kind of error, and anyone who can help, Please
Hello, I am using a similar script in Python to optimize some airfoils for a wing I'm designing, but I am having some trouble with Xfoil not converging in some cases and ruining the code run, have you ran into a similar obstacle and if you have, do you have any tips on how to handle these unconverge cases from MATLAB/Python?
Honestly, I only use it for these super simple cases (in my panel methods video playlist), and I've never had any convergence issues. Unfortunately I won't be able to help you here, but I seem to recall some really good tutorials online (not necessarily videos).
@@JoshTheEngineer I actually managed to make it work, the main issue is that I was initially only telling it the one CL I needed and that usually implied a pretty high AoA to begin with, leading to xfoil not converging. By running an AoA sequence and then interpolating or extrapolating the required CL, I managed to get a somewhat slower but functioning optimization algorithm
Yep, you should be able to just load the airfoil data into XFoil instead of creating the NACA airfoil internally. I'll need to do this for some future videos, so I'll probably update this video to show how to load airfoils as well.
I am really running through a very weird problem. I am working on Airfoil optimization for wind turbines and I am using XFOIL coupled with a MATLAB code using genetic algorithm for the optimization process. Your code really helped me a lot in the coupling process but sometimes the XFOIL gives wrong results for some certain solutions, and when I try to solve these solutions independently from the optimization code, I get the right results although I use the exact same XFOIL settings in both cases, and I even tried to solve these airfoils using another code having the same lines which call the XFOIL and it also gave the correct results. Can anyone help me with this problem please?
Hi, I'm am working on the same thing for the next few months basically. A GA that calls XFOIL and optimizes high endurance airfoils for turbines. i would love to ask you some questions about how you went about it. Please email me at matthew.s.ravenscroft@gmail.com
Hi! I will also be working on a similar project for my dissertation, 'multi-objective optimisation of 4-digit NACA aerofoils using GA'. It would be very helpful to know how you went about interfacing XFOIL with MATLAB for the optimisation process. It would be great if you could email me at imfatima8@gmail.com
Hi everyone, I have been searching for the Xfoil 6.96 version. Sadly I have not been able to find It. So if someone has one or now were to find It I would be greatful.
this is basically deceiving people. title says: Run XFoil from MATLAB what he does: read XFoil data within MATLAB i was looking for a way to iterate 50 different mach numbers for the same angle of attack in XFoil, but here he explains in eleven minutes, what a simple search query ("reading text data matlab or something similar) and 5 minute reading would do.
This is running the XFoil executable from MATLAB. Not sure what else you were expecting. You can literally see it opening XFoil, executing the commands, and then returning the data.
I am very new to matlab and havent used Xfoil yet. I have downloaded the xfoil.m and Cl from Matlab file exchange, but my code looks very different from what is being review in this video, am i missing something?
Just saved me a lot of time on my thesis dude. Well done
Thank you!
These videos on panel methods have been fabulous. They helped me a lot with my projects. Thank you.
For all the people who use Linux - this also works for Linux. One thing, which does not depend on your operating system: In my xfoil version, I had to modify the matlab code. The output I got, had different numbers of heading and also in the cp calculation file, I did not have the y-values. So just small modifications. However, with these small adjustments, the Matlab code works really well. JoshTheEngineer, thank you for your effort.
Josh your videos are very helpful, thank you very much for all your videos. Please keep posting, you are a great teacher and an engineer :)
Thank you!
Thank you so much for this video!!!
Really helpful
Great Job Man you deserve a million like for that
Thanks!
@@JoshTheEngineer I have went throw the python code in your website for running xfoile and it is working fine and was able to change it to much the analysis i want to carry. but, when i usedin for loop it calculate only the first step then stop calculation i have no clue why can you please take alook to my code and tell me if i did somethg wrong:
Ps
def Xfoil(Xloc,Yloc,Degree):
# %% CREATE LOADING FILE
# Knowns
NACA = '4418'
Renolds ='1000000'
AoA = '5'
iteration ='200'
# Create the airfoil
fid = open(xfoilFlnm,"w")
fid.write("NACA " + NACA + "
")
fid.write("GDES
")
fid.write("flap
")
fid.write(Xloc +"
")
fid.write('999' +"
")
fid.write(Yloc +"
")
fid.write(Degree +"
")
fid.write("exec
")
fid.write("
")
fid.write("PPAR
")
fid.write("
")
fid.write("PSAV " + saveFlnmAF + "
")
fid.write("OPER
")
fid.write("iter
")
fid.write(iteration +"
")
fid.write("v
")
fid.write(Renolds +"
")
fid.write("ALFA " + AoA + "
")
fid.write("CPWR " + saveFlnmCp + "
")
fid.write("pacc
")
fid.write(saveFlnmCL+"
")
fid.write("
")
fid.write("ALFA " + AoA + "
")
fid.write("
")
fid.write("quit")
fid.close()
for Xloc in Xl:
for Yloc in Yl:
for Degree in Degr:
Xfoil(Xloc,Yloc,Degree)
os.system("xfoil.exe < xfoil_input.txt")
if os.path.exists(xfoilFlnm):
os.remove(xfoilFlnm)
if os.path.exists(saveFlnmCL):
os.remove(saveFlnmCL)
This is great! You are saving me so much time of work. Thank you very much.
You're welcome!
you Sir just saved me! amazing tutorial
Glad I could help!
Josh your videos are very helpful, thank you very much for all your videos. Please keep posting, you are a great teacher and an engineer. i want to run XFoil from Python......is there any tutorial on it?
Just here to like your video. cuz I liked your Linear Interpolation video the most.
Hey, thanks!
@@JoshTheEngineer Welcome Sir..!
dude wtf, i was just talking to a friend about how i wanted to learn how to do this ( it was mentioned briefly in my aero class). i literally told my friend about your channel yesterday too. are you watching me???
You're precisely the reason why I made this video. Don't be creeped out though.
@@JoshTheEngineer haha same with me Josh, can you please help me, I have made equations for airfoil geometry generation. I want to optimize airfoil with my equation using genetic algorithm in matlab, I will be very glad if you can help me.
You rock Josh! thanks for this video
No problem!
hey josh
how your cp_text file has 3 column x, y, and cp while here i got only 2 columns x and cp. I use the command cpwr to save.
So if I understand it well, it is only useful to load data from NACA airfoil? It cannot be used to load data from other types of airfoil?
What an Amazing Video
Thank you for this great job.
Thanks, and you're welcome!
great tutorial. any tips on running XFOIL in parallel to test several airfoils at once?
Thanks! Unfortunately I can't help you with your question though, since I haven't attempted anything like that.
Can i have multiple plots on the same axis? like have different naca aerofoils
Hi, have you ever encountered a problem where XFOIL converged and generated results for the pressure distribution data (XCp and Cp) and other results from the foil struct as well but not for the polar data (CL,CD,Cm)? When I input a particular coordinates to my XFOIL (which is a solution from an optimization problem im currently doing) it generated all the foil struct just fine including the XCp and Cp, but the CL came out as NaN and other polar struct datas such as CD and Cm came out an empty cell. Can you help me with this? Thanks in advance
How would you alter the code to also extract different polars? Like CL vs alpha
Thank you so much. I have a request, can you modify the program Matlab to display the CL and Cd Vs AOA?
ı have trouble getting naca63-209 on xfoil why is this happening
I saw your video repeatedly, and thank you for this Gold Mine, I have a question when I go to the steps on making that loaded file to be deleted on the Matlab code the comment "% Delete files if they exist" and "delete(saveFlnmAF); " parts, when I uncomment it and click RUN it is saying to error "Warning: File 'Save_Airfoil.txt' not found. > In MATLAB_XFOIL (line 52)
Undefined variable 'dataBuffer'.
Error in MATLAB_XFOIL (line 55)
XB = dataBuffer{1}(:,1); % Boundary point X-coordinate
>> What should I do, I watched your video for the 5th time today and I can't see any difference that I am making to get this kind of error, and anyone who can help, Please
Hello, I am using a similar script in Python to optimize some airfoils for a wing I'm designing, but I am having some trouble with Xfoil not converging in some cases and ruining the code run, have you ran into a similar obstacle and if you have, do you have any tips on how to handle these unconverge cases from MATLAB/Python?
Honestly, I only use it for these super simple cases (in my panel methods video playlist), and I've never had any convergence issues. Unfortunately I won't be able to help you here, but I seem to recall some really good tutorials online (not necessarily videos).
@@JoshTheEngineer I actually managed to make it work, the main issue is that I was initially only telling it the one CL I needed and that usually implied a pretty high AoA to begin with, leading to xfoil not converging. By running an AoA sequence and then interpolating or extrapolating the required CL, I managed to get a somewhat slower but functioning optimization algorithm
Thx for ur video , for me when I save cp.txt I have just two columns X and cp but no Y column!
Hi, how can I adjust this code for macOS? I run Xfoil using the terminal.
Hello Josh where can I download this script, would appreciate it a lot !
can we do the same for other airfoils like E423?
Yep, you should be able to just load the airfoil data into XFoil instead of creating the NACA airfoil internally. I'll need to do this for some future videos, so I'll probably update this video to show how to load airfoils as well.
Amazzzzing
Thanks you for great job.
Always To The Best :)
No problem!
I am really running through a very weird problem. I am working on Airfoil optimization for wind turbines and I am using XFOIL coupled with a MATLAB code using genetic algorithm for the optimization process. Your code really helped me a lot in the coupling process but sometimes the XFOIL gives wrong results for some certain solutions, and when I try to solve these solutions independently from the optimization code, I get the right results although I use the exact same XFOIL settings in both cases, and I even tried to solve these airfoils using another code having the same lines which call the XFOIL and it also gave the correct results. Can anyone help me with this problem please?
Hi, I'm am working on the same thing for the next few months basically. A GA that calls XFOIL and optimizes high endurance airfoils for turbines. i would love to ask you some questions about how you went about it. Please email me at matthew.s.ravenscroft@gmail.com
I sent an email to you one week ago.
Hi! I will also be working on a similar project for my dissertation, 'multi-objective optimisation of 4-digit NACA aerofoils using GA'. It would be very helpful to know how you went about interfacing XFOIL with MATLAB for the optimisation process. It would be great if you could email me at imfatima8@gmail.com
How to get result(cl and cd) from Xfoil in Matlab without window of Xfoil being opened ?
Hi everyone, I have been searching for the Xfoil 6.96 version. Sadly I have not been able to find It. So if someone has one or now were to find It I would be greatful.
Is it possible to use xfoil for slender body ? axisymmetrical bodies
I don't see why you wouldn't be able to load in a profile of your body, but it depends on what information you're trying to get from the analysis.
This is so useful and instructive. Thank you very much Josh!
You're welcome!
Hi, I cant download the script. Can Anyone?
thank you
You're welcome!
this is basically deceiving people.
title says: Run XFoil from MATLAB
what he does: read XFoil data within MATLAB
i was looking for a way to iterate 50 different mach numbers for the same angle of attack in XFoil, but here he explains in eleven minutes, what a simple search query ("reading text data matlab or something similar) and 5 minute reading would do.
This is running the XFoil executable from MATLAB. Not sure what else you were expecting. You can literally see it opening XFoil, executing the commands, and then returning the data.
I am very new to matlab and havent used Xfoil yet. I have downloaded the xfoil.m and Cl from Matlab file exchange, but my code looks very different from what is being review in this video, am i missing something?
Noticed maybe this is the script mentioned in the desc. but the weblink is not active anymore?