0% found this document useful (0 votes)
347 views4 pages

Perfil Aerodinamico Matlab

This document provides information on generating airfoil coordinates for NACA 4-digit airfoils using MATLAB code. It describes the inputs and outputs of the code, including the NACA airfoil designation, number of panels, and whether to use half-cosine or uniform x-spacing. The code calculates key airfoil parameters based on the designation, generates the x and z coordinates for the upper and lower surfaces, and can optionally write the data to a file. Examples of running the code and visualizing the results are also included.

Uploaded by

Manuel Huaman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
347 views4 pages

Perfil Aerodinamico Matlab

This document provides information on generating airfoil coordinates for NACA 4-digit airfoils using MATLAB code. It describes the inputs and outputs of the code, including the NACA airfoil designation, number of panels, and whether to use half-cosine or uniform x-spacing. The code calculates key airfoil parameters based on the designation, generates the x and z coordinates for the upper and lower surfaces, and can optionally write the data to a file. Examples of running the code and visualizing the results are also included.

Uploaded by

Manuel Huaman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

%

%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%
%

INPUTS------------------------------------------------------------------iaf.designation = NACA 4 digit iaf.designation (eg. '2412') - STRING !


iaf.n = no of panels (line elements) PER SIDE (upper/lower)
iaf.HalfCosineSpacing = 1 for "half cosine x-spacing"
= 0 to give "uniform x-spacing"
iaf.wantFile = 1 for creating airfoil data file (eg. 'naca2412.dat')
= 0 to suppress writing into a file
iaf.datFilePath = Path where the data file has to be created
(eg. 'af_data_folder/naca4digitAF/')
use only forward slash '/' (Just for OS portability)
OUTPUTS-----------------------------------------------------------------Data:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
af.x = x cordinate (nx1 array)
af.z = z cordinate (nx1 array)
af.xU = x cordinate of upper surface (nx1 array)
af.zU = z cordinate of upper surface (nx1 array)
af.xL = x cordinate of lower surface (nx1 array)
af.zL = z cordinate of lower surface (nx1 array)
af.xC = x cordinate of camber line (nx1 array)
af.zC = z cordinate of camber line (nx1 array)
af.name = Name of the airfoil
af.header = Airfoil name ; No of panels ; Type of spacing
(eg. 'NACA4412 : [50 panels,Uniform x-spacing]')
File:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
First line : Header eg. 'NACA4412 : [50 panels,Half cosine x-spacing]'
Subsequent lines : (2*iaf.n+1) rows of x and z values
Typical Inputs:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
iaf.designation='2312';
iaf.n=56;
iaf.HalfCosineSpacing=1;
iaf.wantFile=1;
iaf.datFilePath='./'; % Current folder
iaf.is_finiteTE=0;

% % [[Calculating key parameters-----------------------------------------]]


t=str2num(iaf.designation(3:4))/100;
m=str2num(iaf.designation(1))/100;
p=str2num(iaf.designation(2))/10;
a0= 0.2969;
a1=-0.1260;
a2=-0.3516;
a3= 0.2843;
if iaf.is_finiteTE ==1
a4=-0.1015; % For finite thick TE
else
a4=-0.1036; % For zero thick TE
end
% % [[Giving x-spacing---------------------------------------------------]]
if iaf.HalfCosineSpacing==1
beta=linspace(0,pi,iaf.n+1)';
x=(0.5*(1-cos(beta))); % Half cosine based spacing
iaf.header=['NACA' iaf.designation ' : [' num2str(2*iaf.n) 'panels,Half cosi
ne x-spacing]'];

else
x=linspace(0,1,iaf.n+1)';
iaf.header=['NACA' iaf.designation ' : [' num2str(2*iaf.n) 'panels,Uniform x
-spacing]'];
end
yt=(t/0.2)*(a0*sqrt(x)+a1*x+a2*x.^2+a3*x.^3+a4*x.^4);
xc1=x(find(x<=p));
xc2=x(find(x>p));
xc=[xc1 ; xc2];
if p==0
xu=x;
yu=yt;
xl=x;
yl=-yt;
zc=zeros(size(xc));
else
yc1=(m/p^2)*(2*p*xc1-xc1.^2);
yc2=(m/(1-p)^2)*((1-2*p)+2*p*xc2-xc2.^2);
zc=[yc1 ; yc2];
dyc1_dx=(m/p^2)*(2*p-2*xc1);
dyc2_dx=(m/(1-p)^2)*(2*p-2*xc2);
dyc_dx=[dyc1_dx ; dyc2_dx];
theta=atan(dyc_dx);
xu=x-yt.*sin(theta);
yu=zc+yt.*cos(theta);
xl=x+yt.*sin(theta);
yl=zc-yt.*cos(theta);
end
af.name=['NACA ' iaf.designation];
af.x=[flipud(xu) ; xl(2:end)];
af.z=[flipud(yu) ; yl(2:end)];
indx1=1:min( find(af.x==min(af.x)) ); % Upper surface indices
indx2=min( find(af.x==min(af.x)) ):length(af.x); % Lower surface indices
af.xU=af.x(indx1); % Upper Surface x
af.zU=af.z(indx1); % Upper Surface z
af.xL=af.x(indx2); % Lower Surface x
af.zL=af.z(indx2); % Lower Surface z
af.xC=xc;
af.zC=zc;
lecirFactor=0.8;
af.rLE=0.5*(a0*t/0.2)^2;
le_offs=0.5/100;
dyc_dx_le=(m/p^2)*( 2*p-2*le_offs );
theta_le=atan(dyc_dx_le);
af.xLEcenter=af.rLE*cos(theta_le);
af.yLEcenter=af.rLE*sin(theta_le);

% % [[Writing iaf data into file------------------------------------------]]


if iaf.wantFile==1
F1=iaf.header;
F2=num2str([af.x af.z]);
F=strvcat(F1,F2);
fileName=[iaf.datFilePath 'naca' iaf.designation '.dat'];
dlmwrite(fileName,F,'delimiter','')
end
==============================
(2)test code for naca4gen(use this code after running naca4gen)
==============================
iaf.designation='0012';
% designation='0008';
iaf.n=30;
iaf.HalfCosineSpacing=1;
iaf.wantFile=1;
iaf.datFilePath='./'; % Current folder
iaf.is_finiteTE=0;
af = naca4gen(iaf);
% plot(af.x,af.z,'bo-')
plot(af.xU,af.zU,'bo-')
hold on
plot(af.xL,af.zL,'ro-')
axis equal
=========================================
(3) Joukowski plot
=======================
disp('-------------------------------------------------------------------')
disp(' Joukowski Transformation Input Manager
')
disp('-------------------------------------------------------------------')
v_inf = 100;
v = v_inf/v_inf;
theta = 0;
theta = theta*pi/180;
disp('-------------------------------------------------------------------')
s_x = -0.107;
s_y = 0;
s = s_x + i*s_y;
r = 1.027;
disp('-------------------------------------------------------------------')
disp(' If Solution visualization is uncorrect try modify Tolerance TOLL')
disp('-------------------------------------------------------------------')
% FLUID PARAMETER
rho = 1.225;
% TRANSFORMATION PARAMETER
lambda = r-s;
% CIRCULATION
beta = (theta);
k = 2*r*v*sin(beta);
Gamma = k/(2*pi); %CIRCULATION
%COMPLEX ASYMPTOTIC SPEED
w = v * exp(i*theta);
%TOLLERANCE

toll = +5e-2;
% GENERATING MESH
x = meshgrid(-5:.1:5);
y = x';
% COMPLEX PLANE
z = x + i*y;
% Inside-circle points are Excluded!
for a = 1:length(x)
for b = 1:length(y)
if abs(z(a,b)-s) <= r - toll
z(a,b) = NaN;
end
end
end
% AERODYNAMIC POTENTIAL
f = w*(z) + (v*exp(-i*theta)*r^2)./(z-s) + i*k*log(z);
% JOUKOWSKI TRANSFORMATION,
J = z+lambda^2./z;
%GRAPHIC - Circle and Joukowski Airfoil
angle = 0:.1:2*pi;
z_circle = r*(cos(angle)+i*sin(angle)) + s;
z_airfoil = z_circle+lambda^2./z_circle;
% KUTTA JOUKOWSKI THEOREM
L = v_inf*rho*Gamma;
L_str = num2str(L);
%PLOTTING SOLUTION
figure(2)
hold on
contour(real(z),imag(z),imag(f),[-5:.2:5])
fill(real(z_circle),imag(z_circle),'y')
axis equal
axis([-5 5 -5 5])
title(strcat('Flow Around a Circle. Lift: ',L_str,' [N/m]'));
figure(1)
hold on
contour(real(J),imag(J),imag(f),[-5:.2:5])
fill(real(z_airfoil),imag(z_airfoil),'y')
axis equal
axis([-5 5 -5 5])
title(strcat('Flow Around the Corresponding Airfoil.
);
figure(3)
hold on
plot (real(z_airfoil),imag(z_airfoil))
axis equal

Lift: ',L_str,' [N/m]')

You might also like