Professional Documents
Culture Documents
(Reference: LEE, Jin-Tae, A Potential Based Panel Method for the Analysis of Marine Propellers in
Steady Flow,Thesis (Ph. D.), Massachusetts Institute of Technology, Dept. of Ocean Engineering,
1987, http://hdl.handle.net/1721.1/14641)
panel_naca_2D.m
% Kivanc Ali ANIL (10.12.2012)
%
% NACA four,five,six-digit-airfoil series
% PANEL METHODS
% Combined Source and Doublet Method
% Constant Strength Source Method (optional if alpha = 0
% and if foil is symmetric)
%
% This program uses following functions and subroutines:
% naca4dig.m (function)
% naca5dig.m (function)
% naca6dig.m (function)
% naca66a08.m (function)
% panelmet1.m
% panelmet2.m (option if alpha = 0 and if foil is symmetric)
clear,clc,close all
% ---------------------------------------------
% default values
% def0 = {'0012','1','8','1','20'};
% def0 = {'6418','1','-30:30','1','60'};
% def0 = {'6418','1','0','1','60'};
% def0 = {'4412','1','1.875','1','60'};
% def0 = {'0021','1','1.875','1','60'};
% def0 = {'21018','1','0','1','60'};
% def0 = {'63A018','1','0','1','60'};
% ---------------------------------------------
dlgTitle= 'NACA four,five,six-digit-airfoil series ';
prompt = {['Enter the NACA four-digit-airfoil number [6412, 0012, 0016, etc] OR ',...
'Enter the NACA five-digit-airfoil number [210XX, 220XX, 230XX, 240XX 250XX] OR ',...
'Enter the NACA 63A or 64A six-digit-airfoil number [63A0XX, 64A0XX] OR ',...
'Enter the NACA 66 (Mod) & a =.8 Camber'],...
'Enter the airfoil chord c',...
'Enter the flow angle of attack (alpha in degrees)',...
'Free stream velocity (U)',...
'Number of Panels (N) - ENTER AN EVEN NUMBER!'};
data = inputdlg(prompt,dlgTitle,1,def0);
if isempty(data)==1
clear
return
end
Nname = char(data(1)); % NACA airfoil number
c = str2num(char(data(2))); % chord (length of airfoil's chord line)
alphaarray = str2num(char(data(3))); %#ok<ST2NM>
U = str2num(char(data(4)));
N = str2num(char(data(5)));
% ---------------------------------------------
x = linspace(0,c,200);
x = x';
xtilda = 0:2*pi/N:pi;
xgc = (c/2)*(1-cos(xtilda)); % 0 - c
x2 = xgc; %2010
% ---------------------------------------------
if length(Nname) == 4
[Xu, Yu, Xl, Yl, Y] = naca4dig(Nname,x,c);
[xgcu, ygcu, xgcl, ygcl, Y2]= naca4dig(Nname,xgc,c);
elseif length(Nname) == 5
[Xu, Yu, Xl, Yl, Y] = naca5dig(Nname,x,c);
[xgcu, ygcu, xgcl, ygcl, Y2]= naca5dig(Nname,xgc,c);
elseif length(Nname) == 6
[Xu, Yu, Xl, Yl, Y] = naca6dig(Nname,x,c);
[xgcu, ygcu, xgcl, ygcl, Y2]= naca6dig(Nname,xgc,c);
else
dlgTitle= 'NACA 66, a=0.8 ';
prompt = { 'Thickness ratio (tmax/c)(maximim thickness/chord)',...
'Maximum camber ratio (f/c) (maximim camber/chord)'};
data2 = inputdlg(prompt,dlgTitle,1,def1);
if isempty(data2)==1
clear
return
end
tau = str2num(char(data2(1)));% thickness ratio (tmax/c)
e = str2num(char(data2(2)));% maximum camber ratio (f/c)
[Xu, Yu, Xl, Yl, Y] = naca66a08(tau,e,x,c);
[xgcu, ygcu, xgcl, ygcl, Y2]= naca66a08(tau,e,xgc,c);
end
naca4dig.m
function [XuG, YuG, XlG, YlG, YG] = naca4dig(NnameG,xG,cG)
% Kivanc Ali ANIL (08 Oct.2009)
% Function for NACA four-digit-airfoil number [6412, 0012, 0016, etc]
tau = str2num([NnameG(3) NnameG(4)])/100; % thickness ratio (maximim thickness/chord)
e = str2num(NnameG(1))/100; % maximum camber ratio (maximim camber/chord)
p = str2num(NnameG(2))/10 ;
YG = zeros(size(xG)); % camber line
theta = zeros(size(xG)); %
for i = 1:length(xG)
if xG(i)/cG < p
YG(i) = (e*xG(i)/p^2)*(2*p-xG(i)/cG);
theta(i) = atan(2*e*(p-xG(i)/cG)/p^2);
else
YG(i) = (e*(cG-xG(i))/(1-p)^2)*(1+xG(i)/cG-2*p);
theta(i) = atan(2*e*(p-xG(i)/cG)/(1-p)^2);
end
end
% ---------------------------------------------
% thickness distribution
ZZZ = 0.3537; % An Introduction to Theoretical and
% Computational Aerodynamics, Jack MORAN
% ZZZ = 0.3516; % Theory of Wing Sections
T = 10*tau*cG*(0.2969*sqrt(xG./cG)-0.126*(xG./cG)-...
ZZZ*(xG./cG).^2+0.2843*(xG./cG).^3-0.1015*(xG./cG).^4);
% ---------------------------------------------
XuG = xG-(T/2).*sin(theta);
YuG = YG+(T/2).*cos(theta);
XlG = xG+(T/2).*sin(theta);
YlG = YG-(T/2).*cos(theta);
naca5dig.m
function [XuG, YuG, XlG, YlG, YG] = naca5dig(NnameG,xG,cG)
% Kivanc Ali ANIL (08 Oct.2009)
% Function for NACA five-digit-airfoil number [210XX, 220XX, 230XX, 240XX 250XX]
dsg = str2num([NnameG(1) NnameG(2) NnameG(3)]); % Mean-Line Designation
if dsg == 210
m = 0.0580; k1 = 361.4;
elseif dsg == 220
m = 0.1260; k1 = 51.64;
elseif dsg == 230
m = 0.2025; k1 = 15.957;
elseif dsg == 240
m = 0.2900; k1 = 6.643;
elseif dsg == 250
m = 0.3910; k1 = 3.230;
else
wtxt = ['THIS PROGRAM IS NOT ABLE TO FIND A SOLUTION',...
' FOR THIS NACA FIVE-DIGIT AIRFOIL NUMBER'];
warn = warndlg(wtxt ,' WARNING');
uiwait(warn)
clear
return
end
% ---------------------------------------------
tau = str2num([NnameG(4) NnameG(5)])/100; % thickness ratio (maximim thickness/chord)
% p = str2num([NnameG(2) NnameG(3)])/200; % maximum camber location ratio
% CLD = str2num(NnameG(1))*3/20; % Design lift coefficient
% ---------------------------------------------
YG = zeros(size(xG)); % camber line
theta = zeros(size(xG)); %
for i = 1:length(xG)
if xG(i)/cG <= m
YG(i) = cG*(k1/6)*((xG(i)/cG)^3 - 3*m*(xG(i)/cG)^2 + (3*m^2-m^3)*(xG(i)/cG));
theta(i) = atan((k1/6)*(3*(xG(i)/cG)^2 - 6*m*(xG(i)/cG) + (3*m^2-m^3)));
else
YG(i) = cG*(k1/6)*m^3*(1-(xG(i)/cG));
theta(i) = atan(-(k1/6)*m^3);
end
end
% ---------------------------------------------
% thickness distribution
ZZZ = 0.3537; % An Introduction to Theoretical and
% Computational Aerodynamics, Jack MORAN
% ZZZ = 0.3516; % Theory of Wing Sections
T = 10*tau*cG*(0.2969*sqrt(xG./cG)-0.126*(xG./cG)-...
ZZZ*(xG./cG).^2+0.2843*(xG./cG).^3-0.1015*(xG./cG).^4);
% ---------------------------------------------
XuG = xG-(T/2).*sin(theta);
YuG = YG+(T/2).*cos(theta);
XlG = xG+(T/2).*sin(theta);
YlG = YG-(T/2).*cos(theta);
naca6dig.m
function [XuG, YuG, XlG, YlG, YG] = naca6dig(NnameG,xG,cG)
% Kivanc Ali ANIL (07 Jul.2009)
% Function for NACA 63A or 64A six-digit-airfoil number [63A0XX, 64A0XX]
tau = str2num([NnameG(5) NnameG(6)])/100; % thickness ratio (maximim thickness/chord)
d6X = str2num([NnameG(1) NnameG(2)]);
data63A010 = [ ...
0.000000 0.0000000
0.005000 0.0081600
0.007500 0.0098300
0.012500 0.0125000
0.025000 0.0173700
0.050000 0.0241200
0.075000 0.0291700
0.100000 0.0332400
0.150000 0.0395000
0.200000 0.0440000
0.250000 0.0471400
0.300000 0.0491300
0.350000 0.0499500
0.400000 0.0496800
0.450000 0.0483700
0.500000 0.0461300
0.550000 0.0431100
0.600000 0.0394300
0.650000 0.0351700
0.700000 0.0304400
0.750000 0.0254500
0.800000 0.0204000
0.850000 0.0153500
0.900000 0.0103000
0.950000 0.0052500
1.000000 0.0000000];
data64A010 = [ ...
0.000000 0.0000000
0.005000 0.0080400
0.007500 0.0096900
0.012500 0.0122500
0.025000 0.0166800
0.050000 0.0232700
0.075000 0.0281000
0.100000 0.0319900
0.150000 0.0381300
0.200000 0.0427200
0.250000 0.0460600
0.300000 0.0483700
0.350000 0.0496800
0.400000 0.0499500
0.450000 0.0489400
0.500000 0.0468400
0.550000 0.0438800
0.600000 0.0402100
0.650000 0.0359700
0.700000 0.0312700
0.750000 0.0262300
0.800000 0.0210300
0.850000 0.0158200
0.900000 0.0106200
0.950000 0.0054100
1.000000 0.0000000];
if d6X == 63
data6XA010 = data63A010;
elseif d6X == 64
data6XA010 = data64A010;
end
YG = zeros(size(xG));
XuG1 = data6XA010(:,1)*cG;
YuG1 = +(tau/.10)*data6XA010(:,2)*cG;
XlG1 = data6XA010(:,1)*cG;
YlG1 = -(tau/.10)*data6XA010(:,2)*cG;
YuG = interp1(XuG1,YuG1,xG,'spline');
YlG = interp1(XlG1,YlG1,xG,'spline');
XuG = xG;
XlG = xG;
naca66a08.m
function [XuG, YuG, XlG, YlG, YG] = naca66a08(tauG,eG, xG,cG)
% Kivanc Ali ANIL (02.12.2012)
% Function for Section mean line: NACA a = 0.8
% Section thickness distribution: NACA 66 (modified)
tmax = tauG*cG; % c = cG
f = eG*cG; % c = cG
panelmet1.m
% Kivanc Ali ANIL (12 JAN.2011)
% Subroutine for the Combined Source and Doublet Method
CLpanel = zeros(length(alphaarray),2);
CDpanel = zeros(length(alphaarray),1);
CMpanel = zeros(length(alphaarray),1);
CpN = zeros(length(alphaarray),N-1);%%%%%%%%%%
for k = 1 : length(alphaarray)
alpha = alphaarray(k)*pi/180;
Un = zeros(1,N);
aw = zeros(1,N);
xiL = zeros(N,N);
yiL = zeros(N,N);
xjL1 = zeros(N,N);
xjL2 = zeros(N,N);
r1 = zeros(N,N);
r2 = zeros(N,N);
theta1 = zeros(N,N);
theta2 = zeros(N,N);
Asource = zeros(N,N);
Adouble = zeros(N,N);
for i = 1:N % Collocation Points
% U*n for each panel (n is pointing outward)
Un(i) = -(U*cos(alpha)*nx(i)+U*sin(alpha)*ny(i));
% Two dimensional point vortex (unit strength) for wake
aw(i) = +(0.5/pi)*atan((YG(i)-GCO(N+1,2))/(XG(i)-GCO(N+1,1))); %2011
for j = 1:N
% Transformation from Global to Local Coordinates
% xiL(i,j) = (XG(i)-XG(j))*cos(thetaMP(j))+(YG(i)-YG(j))*sin(thetaMP(j));
% yiL(i,j) = (YG(i)-YG(j))*cos(thetaMP(j))-(XG(i)-XG(j))*sin(thetaMP(j));
xiL(i,j) = (XG(i)-XG(j))*tx(j)+(YG(i)-YG(j))*ty(j); % 2011
yiL(i,j) = (XG(i)-XG(j))*nx(j)+(YG(i)-YG(j))*ny(j); % 2011
xjL1(i,j) = -L(j)/2;
xjL2(i,j) = +L(j)/2;
r1(i,j) = ((xiL(i,j)-xjL1(i,j))^2+yiL(i,j)^2)^.5;
r2(i,j) = ((xiL(i,j)-xjL2(i,j))^2+yiL(i,j)^2)^.5;
theta1(i,j) = atan2(yiL(i,j),(xiL(i,j)-xjL1(i,j)));
theta2(i,j) = atan2(yiL(i,j),(xiL(i,j)-xjL2(i,j)));
% a unit source strength distribution
Asource(i,j)= (0.5/pi)* ((xiL(i,j)-xjL1(i,j))*log(r1(i,j))-...
(xiL(i,j)-xjL2(i,j))*log(r2(i,j))+yiL(i,j)*(theta2(i,j)-theta1(i,j)));
% if j == i
% Asource(i,j)= (0.5/pi)*(xjL2(i,j)-xjL1(i,j))*log((xjL2(i,j)-xjL1(i,j))/2);
% end
% a unit doublet strength distribution
Adouble(i,j)= -(0.5/pi)*(theta2(i,j)-theta1(i,j));
if j == i
Adouble(i,j)= 0.5;
end
% wake correction
if j == 1
Adouble(i,j) = Adouble(i,j)-aw(i);
elseif j == N
Adouble(i,j) = Adouble(i,j)+aw(i);
end
end
end
amatrix = Adouble;
bmatrix = -Asource*Un';
PHI1 = amatrix\bmatrix; % = mldivide(amatrix,bmatrix);
% = inv(amatrix)*bmatrix
% = (amatrix\eye(size(amatrix)))*bmatrix
% = pinv(amatrix)*bmatrix
PHIuf = zeros(1,N);
PHI = zeros(1,N);
for i = 1:N
PHIuf(i) = U*(GMP(i,1)*cos(alpha)+GMP(i,2)*sin(alpha));% uniformflow
PHI(i) = -PHI1(i)+PHIuf(i);
end
R = zeros(1,N-1);
VN = zeros(1,N-1);
XN = zeros(1,N-1);
for i = 1:N-1
kk = i+1;
R(i) = (L(kk)+L(i))/2;
VN(i) = (PHI(kk)-PHI(i))/R(i);
XN(i) = GCO(kk,1);
end
CpN(k,:) = 1-(VN/U).^2;
if alpha < 0
nyalpha = [ny(1:.5*N-1),ny(.5*N+1:N)];
nxalpha = [nx(1:.5*N-1),nx(.5*N+1:N)];
tyalpha = [ty(1:.5*N-1),ty(.5*N+1:N)]; %2010
txalpha = [tx(1:.5*N-1),tx(.5*N+1:N)]; %2010
else
nyalpha = [ny(1:.5*N) ,ny(.5*N+2:N)];
nxalpha = [nx(1:.5*N) ,nx(.5*N+2:N)];
tyalpha = [ty(1:.5*N) ,ty(.5*N+2:N)]; %2010
txalpha = [tx(1:.5*N) ,tx(.5*N+2:N)]; %2010
end
Cypanel = sum(-(CpN(k,:)).*R.*nyalpha/c); %2011
Cxpanel = sum(-(CpN(k,:)).*R.*nxalpha/c); %2011
% CLpanel(k,:) = [-2*(PHI1(N)-PHI1(1))/(U*c) ,Cypanel]; %2011
% CDpanel(k,:) = Cxpanel; %2011
CLpanel(k,:) = [-2*(PHI1(N)-PHI1(1))/(U*c) ,...
-Cxpanel*sin(alpha)+...
Cypanel*cos(alpha)]; %2011
CDpanel(k,:) = Cxpanel*cos(alpha)+...
Cypanel*sin(alpha); %2011
CyMpanel = sum(-(CpN(k,:)).*R.*nyalpha.*XN*cos(alpha)/c^2); %2011
CxMpanel = sum(-(CpN(k,:)).*R.*nxalpha.*XN*cos(alpha)/c^2); %2011
CMpanel(k,:) = -CxMpanel*sin(alpha)+...
CyMpanel*cos(alpha); %2011
% or:
% CMpanel(k,:) = -sum(-(CpN(k,:)).*R.*nxalpha*sin(alpha).*XN*cos(alpha)/c^2)+...
% sum(-(CpN(k,:)).*R.*nyalpha*cos(alpha).*XN*cos(alpha)/c^2); %2011
end
Panelmet2.m
% Kivanc Ali ANIL (12 JAN.2011)
% Subroutine for Constant Strength Source Method (optional if alpha = 0
% and if foil is symmetric)
CpN = zeros(length(alphaarray),N);
for k = 1 : length(alphaarray)
alpha = alphaarray(k)*pi/180;
aw = zeros(1,N);
xiL = zeros(N,N);
yiL = zeros(N,N);
xjL1 = zeros(N,N);
xjL2 = zeros(N,N);
r1 = zeros(N,N);
r2 = zeros(N,N);
theta1 = zeros(N,N);
theta2 = zeros(N,N);
UL = zeros(N,N);
WL = zeros(N,N);
UG = zeros(N,N);
WG = zeros(N,N);
A = zeros(N,N);
B = zeros(N,N);
Bmat = zeros(N,1);
for i = 1:N % Collocation Points
for j = 1:N
% Transformation from Global to Local Coordinates
% xiL(i,j) = (XG(i)-XG(j))*cos(thetaMP(j))+(YG(i)-YG(j))*sin(thetaMP(j));
% yiL(i,j) = (YG(i)-YG(j))*cos(thetaMP(j))-(XG(i)-XG(j))*sin(thetaMP(j));
xiL(i,j) = (XG(i)-XG(j))*tx(j)+(YG(i)-YG(j))*ty(j); % 2011
yiL(i,j) = (XG(i)-XG(j))*nx(j)+(YG(i)-YG(j))*ny(j); % 2011
xjL1(i,j) = -L(j)/2;
xjL2(i,j) = +L(j)/2;
r1(i,j) = ((xiL(i,j)-xjL1(i,j))^2+yiL(i,j)^2)^.5;
r2(i,j) = ((xiL(i,j)-xjL2(i,j))^2+yiL(i,j)^2)^.5;
theta1(i,j) = atan2(yiL(i,j),(xiL(i,j)-xjL1(i,j)));
theta2(i,j) = atan2(yiL(i,j),(xiL(i,j)-xjL2(i,j)));
% COMPUTE VELOCITY IN LOCAL REF. FRAME
if j == i
UL(i,j) = 0;
WL(i,j) = .5;
else
UL(i,j) = (0.5/pi)*log(r1(i,j)/r2(i,j));
WL(i,j) = (0.5/pi)*(theta2(i,j)-theta1(i,j));
end
% RETURN VELOCITY TO GLOBAL REF. FRAME
% UG(i,j) = UL(i,j)*cos(-thetaMP(j))+WL(i,j)*sin(-thetaMP(j));
% WG(i,j) = -UL(i,j)*sin(-thetaMP(j))+WL(i,j)*cos(-thetaMP(j));
% UG(i,j) = UL(i,j)*cos(thetaMP(j))-WL(i,j)*sin(thetaMP(j));
% WG(i,j) = UL(i,j)*sin(thetaMP(j))+WL(i,j)*cos(thetaMP(j));
UG(i,j) = UL(i,j)*tx(j)+WL(i,j)*nx(j);
WG(i,j) = UL(i,j)*ty(j)+WL(i,j)*ny(j);
% A(I,J) IS THE INFLUENCE COEFF. DEFINED BY THE TANGENCY CONDITION.
% B(I,J) IS THE INDUCED LOCAL TANGENTIAL VELOCITY TO BE USED IN CP CALCULATION.
% A(i,j) =-UG(i,j)*sin(thetaMP(i))+WG(i,j)*cos(thetaMP(i));
% B(i,j) = UG(i,j)*cos(thetaMP(i))+WG(i,j)*sin(thetaMP(i));
A(i,j) = UG(i,j)*nx(i)+WG(i,j)*ny(i); % 2011
B(i,j) = UG(i,j)*tx(i)+WG(i,j)*ty(i); % 2011
end
% Bmat(i,1) = sin(thetaMP(i));
Bmat(i,1) = -(U*cos(alpha)*nx(i)+U*sin(alpha)*ny(i)); % 2011
end
amatrix = A;
bmatrix = Bmat;
Sigma = amatrix\bmatrix;
XN = GMP(:,1)';
% for i = 1:N
% VN(i) = 0;
% for j = 1:N
% VN(i) = VN(i)+B(i,j)*Sigma(j);
% end
% end
VN = B*Sigma; % 2011
VN = VN'; % 2011
CpN(k,:) = 1-(VN+cos(thetaMP)).^2;
end