3 Coding Assignment 2 Aero 2
3 Coding Assignment 2 Aero 2
Abstract—This report is the 2nd coding assignment of Thus, in a uniform flow condition 𝑉𝑉∞ at 0° angle of attack
Aerodynamics II Course (AE 3210) about Vortex Panel Method. using m vortex panels, the velocity potential at the i-th control
Under this report, a calculation of pressure distribution and lift point (𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 ) is,
at 0° angle of attack and compare between vortex panel method
and experiment results using XFLR5. The airfoil that is 𝜙𝜙(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 ) = V∞ (𝑥𝑥𝑖𝑖 cos 𝛼𝛼 + 𝑦𝑦𝑖𝑖 sin 𝛼𝛼)
analyzed is a NACA 1412 airfoil. 𝑚𝑚
𝛾𝛾�𝑠𝑠𝑗𝑗 �
− �� arctan 𝛽𝛽 𝑑𝑑𝑠𝑠𝑗𝑗 (1)
Keywords—Aerodynamics II, Vortex Panel Method, NACA 2𝜋𝜋
𝑗𝑗=1
1421
where:
I. BASIC THEORY
𝑠𝑠𝑗𝑗
An airfoil is the section of a wing cut by a plane parallel 𝛾𝛾�𝑠𝑠𝑗𝑗 � = 𝛾𝛾𝑗𝑗 + �𝛾𝛾𝑗𝑗+1 − 𝛾𝛾𝑗𝑗 � � � (2)
𝑆𝑆𝑗𝑗
to the xz-plane [1]. Within the assumed inviscid flow, the lift
and moments on the airfoil are due from pressure distribution and
below the stall region. Under these conditions, a theoretical 𝑦𝑦𝑖𝑖 − 𝑦𝑦𝑗𝑗
estimation of airfoil lift and moments can be predicted. In 𝛽𝛽 = (3)
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑗𝑗
order to do so, further conceptual understanding regarding the
vortex sheets must be done. Following the notation established in in Fig. 1., we
represent the coordinates of an arbitrary point on the j-th panel
A. Vortex Panels Method
using (𝑥𝑥𝑗𝑗 , 𝑦𝑦𝑗𝑗 ). This panel has a length denoted by 𝑆𝑆𝑗𝑗 and is
Vortex Panel Method is one variation of the use of panel positioned a distance 𝑠𝑠𝑗𝑗 away from the leading edge
method which involves representation of the airfoil by a
(measured along the panel itself). The subsequent integration
closed polygon of vortex panels. This method only works for
process encompasses the entire panel, extending from the
calculating the lift generated by the airfoil and wing itself. The
starting point (𝑋𝑋𝑗𝑗 , 𝑌𝑌𝑗𝑗 ) to the ending point (𝑋𝑋𝑗𝑗+1 , 𝑌𝑌𝑗𝑗+1 ). It ss
calculation of fuselage and nacelle characteristics and their
interference flows dictates the need to use source, and possibly important to note that capital letters consistently represent the
doublet as well as vortex panels. coordinates of boundary points. The (m + 1) values designated
as 𝛾𝛾𝑗𝑗 at these boundary points remain unknown constants,
Within this framework, the vortex-panel method offers a requiring numerical determination.
unique characteristic: the circulation intensity across each
panel transitions linearly from one corner to the other, The boundary condition requires that the velocity in the
ensuring continuity at the connection points (as shown in Fig. direction of the unit outward normal vector 𝒏𝒏𝒊𝒊 be vanishing at
1). This formulation already incorporates the Kutta condition, the i-th control point, so that
maintaining numerical stability even with a moderate number 𝜕𝜕
of panels. However, employing an excessive number of 𝜙𝜙(𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 ) = 0; 𝑖𝑖 = 1,2, … , 𝑚𝑚
𝜕𝜕𝑛𝑛𝑖𝑖
panels, particularly on airfoils with sharply pointed trailing
edges, can introduce numerical instability. Carrying out the involved differentiation and integration
for source panels. we obtain
𝑚𝑚
Error (%)
XFLR5 JavaFoil
0.29730 1.19155
V. CODE LISTING
The code listing is shown after references in the form of
Appendix B. This report uses MATLAB as the application for
the coding, and all computing languages uses the MATLAB
standard.
REFERENCES
[1] A. I. H. A. and V. D. A. E., Theory of Wing Sections: Including a
Summary of Airfoil Data. New York: Dover, 2015.
[2] A. M. Kuethe and C. C. Yen, Foundations of Aerodynamics Bases of
Aerodynamic Design. Chichester Wiley, 1998
[3] J. D. Anderson and C.P Cadou, Fundamentals of Aerodynamics, 7th
ed., New York: McGraw Hill, pp. 156-165.
APPENDIX
See next page.
Appendix A
Algorithm of The Panel Model for Airfoil
Algorithm of The ‘programAirfoil’ Function: The Vortex Panel Method
Algorithm of The ‘ClfromCp’ Function: Calculating Lift Coefficient from Pressure Disteibution
Appendix B
%% clear, clc
Gamma =
0.1666
-0.0933
-0.1105
-0.1174
Cl = ClFromCp(X, CP);
C. Figure Visualizaton: Cp and Airfoil
n = abs(minA)+abs(maxA);
figure(1)
hold on
yyaxis left
plot(X,CP);
set(gca,YMinorTick = 'on')
xlabel('x/c');
ylabel('Coefficient of Pressure');
set(gca,'YDir','reverse')
yyaxis right
fill(airfoil(1,:),airfoil(2,:),[0.9290 0.6940 0.1250]);
alpha(0.5)
ylabel('Thickness (x/c)');
xlim([0 1])
ylim([-maxA/n -minA/n])
figure(2)
hold on
xlabel('x/c');
ylabel('Thickness (x/c');
axis equal
xlim([0 1])
ylim([-0.2 0.2])
grid on
E. Analysis: Effect of Number of Panels
Get numbers of half-vortex-panels
Np1 = 6;
Np2 = 24;
Gamma =
0.0106
-0.1439
-0.1591
figure(3)
hold on
yyaxis left
plot(X, CP);
scatter(X1, CP1, 36, 'o');
scatter(X2, CP2, 36, 'filled', 'o');
set(gca,YMinorTick = 'on')
xlabel('x/c');
ylabel('Coefficient of Pressure');
set(gca,'YDir','reverse')
yyaxis right
fill(airfoil(1,:), airfoil(2,:), [0.9290 0.6940 0.1250]);
alpha(0.5)
ylabel('Thickness (x/c)');
xlim([0 1])
ylim([-maxA/n -minA/n])
dataXFLR = readmatrix("Alpha0Re3.150Naca1412.csv");
n = abs(minA)+abs(maxA);
if 0.9*abs(minA)/n < abs(minB)
n = n*0.9*abs(minB)*n/abs(minA);
elseif 0.9*abs(maxA)/n < abs(maxB)
n = n*0.9*abs(maxB)*n/abs(maxA);
end
figure(4)
hold on
% yyaxis left
plot(X,CP);
plot(XXFLR, CPiXFLR)
set(gca,YMinorTick = 'on')
xlabel('x/c');
ylabel('Coefficient of Pressure');
set(gca,'YDir','reverse')
% yyaxis right
% fill(airfoil(1,:),airfoil(2,:),[0.9290 0.6940 0.1250]);
% alpha(0.5)
% ylabel('Thickness (x/c)');
xlim([0 1])
ylim([-maxA/n -minA/n])
M = length(X);
Cpl = Cp(1:(M/2));
Cpl = flip(Cpl);
Cpu = Cp(((M/2)+1):end);
Cl = trapz(dX,dCp);
end
M = Np * 2;
% Airfoil Acquizition
XB = airfoil(1, :);
YB = airfoil(2, :);
% Calculation of Coefficients
for i = 1:M
for j = 1:M
if (i == j)
CN1(i, j) = -1.0;
CN2(i, j) = 1.0;
CT1(i, j) = 0.5*pi;
CT2(i, j) = 0.5*pi;
else
A = -(X(i) - XB(j)) * cos(theta(j)) - (Y(i) - YB(j)) *
sin(theta(j));
B = (X(i) - XB(j))^2 + (Y(i) - YB(j))^2;
C = sin(theta(i) - theta(j));
D = cos(theta(i) - theta(j));
E = (X(i) - XB(j)) * sin(theta(j)) - (Y(i) - YB(j)) *
cos(theta(j));
F = log(1.0 + S(j) * (S(j) + 2 .* A) / B);
G = atan2(E * S(j), B + A * S(j));
P = (X(i) - XB(j)) * sin( theta(i) - 2 * theta(j) ) ...
+ (Y(i) - YB(j)) * cos( theta(i) - 2 * theta(j) );
Q = (X(i) - XB(j)) * cos( theta(i) - 2 * theta(j) ) ...
- (Y(i) - YB(j)) * sin( theta(i) - 2 * theta(j) );
CN2(i, j) = D + 0.5 * Q * F / S(j) - (A * C + D * E) * G /
S(j);
CN1(i, j) = 0.5 * D * F + C * G - CN2(i, j);
CT2(i, j) = C + 0.5 * P * F / S(j) + (A * D - C * E) * G /
S(j);
CT1(i, j) = 0.5 * C * F - D * G - CT2(i, j);
end
end
end
for j = 2:M
AN(i, j) = CN1(i, j) + CN2(i, j-1);
AT(i, j) = CT1(i, j) + CT2(i, j-1);
end
end
AN(M + 1, 1) = 1.0;
AN(M + 1, M + 1) = 1.0;
for j = 2:M
AN(M + 1, j) = 0.0;
end
RHS(M + 1) = 0.0;
for i = 1:M
V(i) = cos(theta(i) - AoA);
for j = 1:M + 1
V(i) = V(i) + AT(i, j) * Gamma(j);
CP(i) = 1.0 - V(i)^2;
end
end
Gamma = Gamma';
end
function [airfoil, camberline, upperline, lowerline] = generateNACA4(series,
num, spacing, closed_te)
% Generate Coordinate for NACA 4-digit and modified 4-digit airfoil
% Input:
% series: name of the series
% num: number of data points
% spacing: turn on for half-cosine spacing, otherwise unfirom spacing
% closed_te: turn on for closed trailing edge
% Output:
% AF: coordinates of the airfoils
series = char(series);
len = length(series);
if (spacing)
beta = linspace(0, pi, num+1);
x = (1 - cos(beta)) / 2;
else
x = linspace(0, 1, num+1);
end
if (len == 4)
% Normal NACA 4-digit series
m = str2double(series(1))/100;
p = str2double(series(2))/10;
t = str2double(series(3:4))/100;
yc = zeros(1, length(x));
dycdx = zeros(1, length(x));
yt = zeros(1, length(x));
xU = zeros(1, length(x));
yU = zeros(1, length(x));
xL = zeros(1, length(x));
yL = zeros(1, length(x));
for i=1:length(x)
if (x(i) < p)
yc(i) = m/p^2 * (2*p*x(i) - x(i)^2);
dycdx(i) = 2*m/p^2 * (p - x(i));
else
yc(i) = m/(1-p)^2 * ((1-2*p)+2*p*x(i)-x(i)^2);
dycdx(i) = 2*m/(1-p)^2 * (p - x(i));
end
if (closed_te)
yt(i) = t/0.2 * (0.2969*sqrt(x(i)) - 0.1260*x(i) -
0.3516*x(i)^2 + 0.2843*x(i)^3 - 0.1036*x(i)^4);
else
yt(i) = t/0.2 * (0.2969*sqrt(x(i)) - 0.1260*x(i) -
0.3516*x(i)^2 + 0.2843*x(i)^3 - 0.1015*x(i)^4);
end
theta = atan(dycdx(i));