Objective function problem using "fmincon"
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Teva PM
am 23 Apr. 2020
Kommentiert: Teva PM
am 23 Apr. 2020
Dear Community,
I work on the optimization of the lift-coefficient of an airfoil. My goal is to know how to do that with a genetic algorithm, but I prefer beginnig with something easier.
Here is my main code :
[Xinit,Yinit,XU,YU,XL,YL] = airfoil_coord('NACA0012'); %load Xinit=[Xlower,Xupper] Yinit=[Ylower,Yupper] : (x,y)coordinates NACA0012
fun = @(YN)airfoilcoord(YN,CLtarget,Xinit,alpha,Re,M)
CLtarget = 0.6; %I assume here that {CLinit=0.4610} so {CLtarget=0.6} would be an optimization
alpha =4; %Flight conditons
Re = 32000000; %Flight conditons
M = 0.1764; %Flight conditons
% lb = transpose(ones(1,199)*(-0.08)); %I assume to not enforce a lower and upper bounds
% ub = transpose(ones(1,199)*(0.08));
% Code optimization
[Yopti]=fmincon(fun,Yinit,[],[],[],[]);
Here are the functions used in the code:
function error = airfoilcoord(YN,CLtarget,Xcoord, alpha, Re, M)
%
CL = run_xfoil(Xcoord, YN, alpha, Re, M); %I want the YN vector to change in every loop
error = (CLtarget - CL)
function [CL] = run_xfoil(xcoord, ycoord, alpha, Re, M)
for i=1:length(ycoord)
ycoordxfoil(i)=ycoord(200-i);
end
for i=1:length(xcoord)
xcoordxfoil(i)=xcoord(200-i);
end
Profil = [transpose(xcoordxfoil) , transpose(ycoordxfoil)];
%Necessary to use the XFOIL software
% Function xfoil in the directory
[pol,foil] = xfoil(Profil, alpha, Re, M, 'oper/iter 5000');
CL = pol.CL; %Return a double which is the CL for the airfoil represented as : (xcoord,yccord)
Here is my problem :
When I evaluate each member alone, it works well. But when I run the code, there is not improvement, the CL and the vector YN stay the same at each loop. I think there is a little mistake in my code but I can't find where..
Can someone help me ? Thank you for reading and the time you'll take to answer !
Teva
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 23 Apr. 2020
Whenever you have an optimization problem, a good first step is to verify that IF you pass in two slightly different set of parameters to your objective, you get a different result. We cannot test that, since we don't have the complete code. So, does the software produce a result that does not change for slightly different inputs?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Airfoil tools finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!