Sie sind auf Seite 1von 4

%% AAE 333 Airfoil Panel Method

%
% Author: Andrew Cox
% Version: 8/31/2012
clear;
clc;
close all;
%Get start time
t 0 = cputime;
%General variables
c = 1.000; %chord length
N = 200; %Positive integer number of points to use on one side
u inf = 1; %Strenght of the free stream velocity
aoa = 0*pi/180; %Angle between u inf and +xaxis in radians
%NACA inputs:
naca 1 = 0;
naca 2 = 0;
naca 3 4 = 24;
%Converting to useful airfoil measurements
m max = naca 1/100; %Maximum camber, in percent of chord
m x = naca 2/10; %Position of max camber, in tenths of chord
t max = c*naca 3 4/100; %Maximum thickness
%% Find the panel end points
% Define a vector of x coordinates
x = linspace(0, c, N); %Varied distances from 0 to chord along the airfoil
x = transpose(x);
%Calculate the height above mean chord line
y t = (t max/.2)*c*(.2969*sqrt(x/c)  .126*(x/c)  .3516*(x/c).2 + ...
.2843*(x/c).3  .1036*(x/c).4);
%Calculate the mean camber line
y c = zeros(length(x), 1);
y cPrime = zeros(length(x), 1); %the derivative of the y c line with ...
pect to x
theta = zeros(length(x), 1);
for i = 1:length(x)
if(x(i) < m x*c)
y c(i) = m max*(x(i)/m x2)*(2*m x  x(i)/c);
y cPrime(i) = (2*m max*(c*m x  x(i)))/(c*m x2);
theta(i) = atan2(2*m max*(c*m x  x(i)), c*m x2);
else
y c(i) = m max*((c  x(i))/(1  m x)2)*(1 + x(i)/c  2*m x);
y cPrime(i) = 2*m max*(c*m x  x(i))/(c*(1  m x)2);
theta(i) = atan2(2*m max*(c*m x  x(i)), c*(1  m x)2);
end
end
lowerPts = [x + y t.*sin(theta), y c  y t.*cos(theta)];
upperPts = [x  y t.*sin(theta), y c + y t.*cos(theta)];
%Make sure there is only one TE point and only one LE point
upperPts = upperPts(1:end1, :); %delete the TE point

lowerPts = lowerPts(2:end, :); %delete the LE point


%Create a combination of all points in order moving CW around the airfoil
%starting at the LE
allPts = vertcat(upperPts, flipud(lowerPts));
%% Calculate various lenghts, angles, and vectors
%Find the length of each panel
sideLen = zeros(length(allPts(:,1)),1);
for i = 1:length(allPts(:,1));
if(i + 1 > length(allPts))
sideLen(i) = sqrt((allPts(i, 1)  allPts(1, 1))2 + ...
(allPts(i, 2)  allPts(1, 2))2 );
else
sideLen(i) = sqrt((allPts(i, 1)  allPts(i + 1, 1))2 + ...
(allPts(i, 2)  allPts(i + 1, 2))2 );
end
end
%Find all control point locations and alpha values
CP = zeros(length(allPts(:,1)), 2);
alpha = zeros(length(allPts(:,1)), 1);
for i = 1:length(allPts(:,1))
if(i + 1 > length(allPts)) %connect the last point to the first point
alpha(i) = pi/2 + atan2(allPts(1, 2)  allPts(i, 2),...
allPts(1, 1)  allPts(i, 1));
CP(i,:) = allPts(i, :) + (allPts(1, :)  allPts(i, :))/2;
else
alpha(i) = pi/2 + atan2(allPts(i + 1, 2)  allPts(i, 2),...
allPts(i + 1, 1)  allPts(i, 1));
CP(i,:) = allPts(i, :) + (allPts(i + 1, :)  allPts(i, :))/2;
end
end
%Find the normal and tangent vectors for each panel
nVec = [cos(alpha), sin(alpha)];
tVec = [cos(alpha  pi/2), sin(alpha  pi/2)];
% Find distance between control points and the angle between each ray and
% the free stream velocity.
L = zeros(length(CP(:,1)), length(CP(:,1)));
beta = zeros(length(CP(:,1)), length(CP(:,1)));
for i = 1:length(CP(:,1))
for j = 1:length(CP(:,1))
if(i == j)
L(i,j) = 0;
beta(i,j) = alpha(i);
else
L(i, j) = sqrt((CP(j, 1)  CP(i, 1))2 + (CP(j, 2)  CP(i, 2))2);
beta(i, j) = atan2(CP(j, 2)  CP(i, 2), CP(j, 1)  CP(i, 1));
end
end
end
%convert u inf to a vector
u inf vector = zeros(length(allPts(:,1)),2);

u inf vector(:,1) = cos(aoa);


u inf vector(:,2) = sin(aoa);
% Find the normal and tangential components of u inf wrt each panel
b n = zeros(size(nVec(:,1)));
b t = zeros(size(tVec(:,1)));
for i = 1:length(allPts(:,1))
b n(i) = 1*dot(u inf vector(i,:), nVec(i,:));
b t(i) = dot(u inf vector(i,:), tVec(i,:));
end
% Find the normal influence components and the tangential influence ...
coefficients
normCoeff = zeros(length(CP(:,1)), length(CP(:,1)));
tanCoeff = zeros(length(CP(:,1)), length(CP(:,1)));
for i = 1:length(CP(:,1));
for j = 1:length(CP(:,1));
if(i == j)
normCoeff(i, j) = 1/(2*sideLen(i));
tanCoeff(i, j) = 0;
else
normCoeff(i, j) = cos(beta(j,i)  alpha(i))/(2*pi*L(j,i));
tanCoeff(i, j) = cos(beta(j,i)  alpha(i) + pi/2)/(2*pi*L(j,i));
end
end
end
% Use linear algebra to solve for the source strength of each panel
m = normCoeffnb n;
%Use the tangential influence coefficients to find the tangential
%velocities at each panel
v Si = tanCoeff*m + b t;
%Compute the coefficient of pressure
CPressure = 1  (v Si/u inf).2;
%Compute time to do the calculations
t elapsed = cputime  t 0;
fprintf('Time needed to do calculations: %6.4f', t elapsed);
%% Plotting
%Create title string
strTitle = sprintf('NACA %i%i%i', naca 1, naca 2, naca 3 4);
% Plot control points and normal vectors
figure();
hold on;
quiver(CP(:, 1), CP(:, 2), nVec(:,1), nVec(:,2), 0.5, 'g');
quiver(CP(:, 1), CP(:, 2), tVec(:,1), tVec(:,2), 0.5, 'm');
plot(CP(:, 1), CP(:, 2), 'r*');
%Plot the points
plot(allPts(:, 1), allPts(:,2), '*');
%connect the last point to the first point
plot([allPts(end,1), allPts(1,1)], [allPts(end,2), allPts(1,2)], '*');
axis([0.1, 1.1, .6, .6]); %Set the xMin, xMax, yMin, yMax respectively
set(gca,'DataAspectRatio', [1 1 1]);
grid on;

legend('Normal Vectors', 'Tangent Vectors', 'Control Points');


xlabel('x');
ylabel('y');
title(strTitle);
% Plot the airfoil and the coefficient of pressure
% Plot control points and normal vectors
figure();
hold on;
plot(allPts(1:N, 1), CPressure(1:N), 'g');
plot(allPts(N+1:end, 1), CPressure(N+1:end), 'r');
plot(allPts(:, 1), 1*allPts(:,2));
%connect the last point to the first point
plot([allPts(end,1), allPts(1,1)], 1*[allPts(end,2), allPts(1,2)]);
axis([0.25, 1.25, 1, 1]); %Set the xMin, xMax, yMin, yMax respectively
set(gca,'DataAspectRatio', [1 1 1]);
legend('C P  Top', 'C P  Bottom', 'Location', 'SE');
xlabel('x');
ylabel('C P');
title(strTitle);
set(gca, 'YDir', 'reverse');
grid on;
% Plot the velocities
figure();
hold on;
quiver(0.2, 0, u inf vector(1,1), u inf vector(1,2), 'r');
quiver(CP(:, 1), CP(:, 2), v Si.*tVec(:,1), v Si.*tVec(:,2), 'g');
plot(allPts(:, 1), 1*allPts(:,2));
%connect the last point to the first point
plot([allPts(end,1), allPts(1,1)], 1*[allPts(end,2), allPts(1,2)]);
axis([0.25, 1.1, 0.5, 0.5]);
set(gca,'DataAspectRatio', [1 1 1]);
grid on;
legend('U i n f', 'V s');
title(strTitle);
%Verification of L and beta measurements
% for i = 1:length(L(:,1))
% figure(i + 3);
% polar(beta(i,:), L(i, :), '*');
% end

Das könnte Ihnen auch gefallen