You are on page 1of 15

ME 4943 Course Project - Part I

Numerical Implementation of the Source Panel Method


by Jeffrey A. Kornuta
Mechanical Engineering
Louisiana State University
October 9, 2007

Contents
1 Verification of Algorithm
1.1 N = 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 N = 50 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3
4
5

2 Method Applied to Arbitrary Shape


2.1 The Square . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6
6

Appendices

A MATLAB Code
8
A.1 Part I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
A.2 Part II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

List of Figures
1
2
3
4
5

Visualizations of (a) N = 3 and (b) N = 50 for N = 3, R = 1 m,


and V = 20 m/s. . . . . . . . . . . . . . . . . . . . . . . . . . . .
Visualizations of (a) v() and (b) Cp () for N = 3, R = 1 m, and
V = 20 m/s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Visualizations of (a) v() and (b) Cp () for N = 50, R = 1 m, and
V = 20 m/s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Visualization of square with N = 80 panels. . . . . . . . . . . . .
Visualizations of (a) v() and (b) Cp () for N = 80, (2 2) m, and
V = 20 m/s. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

.
.

5
6

Verification of Algorithm

Two cases are considered:


1. N = 3, R = 1 m, and V = 20 m/s
2. N = 50, R = 1 m, and V = 20 m/s.
Geometry, N = 3

1
0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

0.2

!0.2

0.4

!0.4

0.6

!0.6

0.8

!0.8

1
1

0.5

Geometry, N = 50

0.5

!1
!1

(a) N = 3

!0.5

0.5

(b) N = 50

Figure 1: Visualizations of (a) N = 3 and (b) N = 50 for N = 3, R = 1 m, and


V = 20 m/s.
The following governing equations are utilized by the source panel method to
generate the velocity and pressure coefficient distribution at the surface of a shape:
V cos i +

N
X
j
i
+
Iij = 0, where
2 j=1,j6=i 2
Z

Iij =
(ln rij ) dsj .
j ni

(1)
(2)

Solving for ~ = {1 , 2 , ..., N } using Eq.1 and Eq.2, one can solve for the velocities
at the surface of the circle using the following equation:
Z
N
X
j

(ln rij ) dsj .


Vi = V sin i +
2 sj sj
j=1,j6=i
3

(3)

Finally, the pressure coefficients can be found using the following:


2

Vi
.
Cp,i = 1
V

(4)

Refer to pages 264-270 in Andersons Fundamentals of Aerodynamics, Fourth edition for details regarding notation.

1.1

N =3
Velocity v()

30

0.5

20

10

0.5

10

1.5

20

30

2.5

40
0

50

100

150

200
250
(degrees)

Pressure coefficient Cp()

Cp

Velocity (m/s)

40

300

350

3
0

400

(a) v()

50

100

150

200
250
(degrees)

300

350

400

(b) Cp ()

Figure 2: Visualizations of (a) v() and (b) Cp () for N = 3, R = 1 m, and


V = 20 m/s.

Note that with only three panels, the geometry forms a triangle [Figure 1a].
Although when the analytical and numerical values of v() and Cp () are plotted
against each other, the marked points lie on the curve [Figure 2], lines connecting
the numerically calculated points would reveal an extremely inaccurate representation of the analytical solutions. Thus, more panels would be needed to give a
good approximation of the velocity and pressure coefficient distributions.

1.2

N = 50
Velocity v()

30

0.5

20

10

0.5

10

1.5

20

30

2.5

40
0

50

100

150

200
250
(degrees)

Pressure coefficient Cp()

Cp

Velocity (m/s)

40

300

350

3
0

400

(a) v()

50

100

150

200
250
(degrees)

300

350

400

(b) Cp ()

Figure 3: Visualizations of (a) v() and (b) Cp () for N = 50, R = 1 m, and


V = 20 m/s.

Note that with 50 panels, the geometry closely represents a circle [Figure 1b].
When the analytical and numerical values of v() and Cp () are plotted against
each other, the marked points not only lie on the curve [Figure 3], but lines that
would connect the numerically calculated points would reveal an accurate representation of the analytical solutions. Thus, this number of panels gives a good
approximation of the velocity and pressure coefficient distributions. In fact, reducing the number of panels to as little as 20 would yield a fair representation.
These results suggest that the algorithm used for this scenario is valid.

2
2.1

Method Applied to Arbitrary Shape


The Square
Geometry, N = 80

1.5

x (m)

0.5

0.5

1.5
1.5

0.5

0
y (m)

0.5

1.5

Figure 4: Visualization of square with N = 80 panels.

The algorithm previously defined [Appendix A.1] will now be applied to an


arbitrary shapein this case, a (2 2) m square [Figure 4, Appendix A.2]. For
this square, the number of panels N = 80, and from the plots generated, this
number seems to indicate that the surface is well-resolved [Figure 5].
As one may notice, the overall characteristics of these curves coincide with the
results produced by the circle [Figure 3]. The stagnation points are located in the
same locations, and the average maxima and minima values remain similar. These
similarities suggest that the results for the square are sound. The only noticeable
peculiarities lie with the values obtained for v() and Cp () around the corners of
the square. At these corners,
lim R,
R0

where R is the radius of curvature at the edges; thus, values of v (and correspondingly Cp ) yield singularities at these points. These points are clearly seen in Figure
5 where there exist sharp spikes.

Velocity v()

60

Pressure coefficient Cp()

0
40
1

3
0

Cp

Velocity (m/s)

20

4
20

6
40
7

60

50

100

150

200
(degrees)

250

300

350

400

(a) v()

50

100

150

200
(degrees)

250

300

350

400

(b) Cp ()

Figure 5: Visualizations of (a) v() and (b) Cp () for N = 80, (2 2) m, and


V = 20 m/s.

In reality, this type of behavior would not occur. Since singularities of this kind
are rarely seen in nature, these results suggest that a deficiency in the algorithm
exists. In brief, this deficiency is characterized by two things: the absence of
infinitely small radii of curvature, and the presence of viscous effects in the fluid.
In actuality, edges cannot physically have an infinitely small radius of curvature,
so these singularities would not exist in this scenario since R > 0. Also, the
boundary layer of the surrounding fluid would separate at these sharp edges if
they were indeed that sharp. Viscosity would cause the boundary layer to peel off
at the corners, forming a wake. This scenario is void of singularities and would
prove to be a much more reliable model to represent this shape, as compared to
the inviscid model described by the source panel method.

Appendices
A
A.1

MATLAB Code
Part I

% Jeff Kornuta
% ME4943 - Project Part I-1
clear all;
clf;
clc;
% ask user for required information
N = input(Enter number of panels: );
fprintf(\n);
U = input(Enter freestream velocity [m/s]: );
fprintf(\n);
R = 1;
% plot a plane-jane circle
for t = 1:361
theta = (t-1)*pi/180;
u(t) = cos(theta);
v(t) = sin(theta);
end;
%hold off
%plot(u,v,r)
%axis square
% now plot polygon (endpoints)
hold on
for i = 1:(N+1)
dtheta = 2*pi/N;
beta(i) = pi-(i-1)*dtheta;
Phi(i) = beta(i)-pi/2;
theta(i) = beta(i)+dtheta/2;
tempX(i) = R*cos(theta(i));
tempY(i) = R*sin(theta(i));
%plot(tempX,tempY)
8

%pause(.25)
end;
% resize X, Y, and Beta to have one less element
for i = 1:N
X(i) = tempX(i);
Y(i) = tempY(i);
if (beta(i) < 0)
beta(i) = beta(i)+2*pi;
end;
Beta(i) = beta(i)*180/pi;
end;
% plot midpoints of panels
for i = 1:N
if (i ~= N)
x(i) = (X(i+1)+X(i))/2;
y(i) = (Y(i+1)+Y(i))/2;
else
x(i) = (X(1)+X(N))/2;
y(i) = (Y(1)+Y(N))/2;
% find length of segments
S = sqrt((X(1)-X(N))^2+(Y(1)-Y(N))^2);
end;
%plot(x(i),y(i),o)
%pause(.25)
end;
% that was fun, now lets find I(i,j)
for i = 1:N
for j = 1:N
if (i ~= j)
A(i,j) = -(x(i)-X(j))*cos(Phi(j)) - (y(i)-Y(j))*sin(Phi(j));
B(i,j) = (x(i)-X(j))^2 + (y(i)-Y(j))^2;
% dont divide by zero
if (B(i,j) == 0)
B(i,j) = 1e-12;
end;
C(i,j) = sin(Phi(i)-Phi(j));
D(i,j) = (y(i)-Y(j))*cos(Phi(i)) - (x(i)-X(j))*sin(Phi(i));
E(i,j) = (x(i)-X(j))*sin(Phi(j)) - (y(i)-Y(j))*cos(Phi(j));

% please, stop dividing by zero


if (E(i,j) == 0)
E(i,j) = 1e-12;
end;
I(i,j) = C(i,j)/2*log((S^2+2*A(i,j)*S+B(i,j))/B(i,j)) +...
(D(i,j)-A(i,j)*C(i,j))/E(i,j)*(atan((S+A(i,j))/E(i,j))-...
atan(A(i,j)/E(i,j)));
else
I(i,j) = pi;
end;
end;
end;
% set up system of equations
for i = 1:N
for j = 1:N
M(i,j) = I(i,j)/(2*pi);
end;
b(i,1) = -U*cos(beta(i));
end;
% get those lambdas & check em
lambda = inv(M)*b
Sum = sum(lambda)
% find velocities & pressure coefficients
for i = 1:N
Vs = 0;
for j = 1:N
if (i ~= j)
M2(i,j) = ((D(i,j)-A(i,j)*C(i,j))/(2*E(i,j)))...
*log((S^2+2*A(i,j)*S+B(i,j))/B(i,j))-C(i,j)...
*(atan((S+A(i,j))/E(i,j))-atan(A(i,j)/E(i,j)));
Vs = Vs+lambda(j)/(2*pi)*M2(i,j);
end;
end;
V(i) = -(U*sin(beta(i))+Vs);
Cp(i) = 1-(V(i)/U)^2;
end;

10

% plot velocities & pressure coefficients


for i = 1:361
t = (i-1)*pi/180;
Cpreal(i) = 1-4*(sin(t))^2;
Vreal(i) = -2*U*sin(t);
end;
clear t;
t=[0:360];
hold off
%plot(t,Vreal)
plot(t,Cpreal)
axis square
hold on
%plot(Beta,V,+)
plot(Beta,Cp,+)
xlabel(\theta (degrees));
%ylabel(Velocity (m/s));
%title(Velocity v(\theta));
ylabel(C_p);
title(Pressure coefficient C_p(\theta));

11

A.2

Part II

% Jeff Kornuta
% ME4943 - Project Part I-2
clear all;
clf;
clc;
%
N
U
S

set required information


= 80;
= 20;
= .1;

% plot a square
hold off
t = [-1:.01:1];
one = ones(1,201);
negone = -1*ones(1,201);
% plot(negone,t)
% hold on
% plot(t,one)
% plot(one,t)
% plot(t,negone)
% axis([-1.5 1.5 -1.5 1.5])
% axis square
% find endpoints, midpoints, and angles
for i = 1:11
X(i) = -1;
Y(i) = (i-1)*S;
if (i ~= 11)
x(i) = -1;
y(i) = Y(i)+S/2;
beta(i) = pi;
Phi(i) = pi/2;
end;
end;
for i = 12:31
X(i) = -1+S*(i-11);
Y(i) = 1;
12

x(i-1) = X(i)-S/2;
y(i-1) = Y(i);
beta(i-1) = pi/2;
Phi(i-1) = 0;
end;
for i = 32:51
X(i) = 1;
Y(i) = 1-S*(i-31);
x(i-1) = 1;
y(i-1) = Y(i)+S/2;
beta(i-1) = 0;
Phi(i-1) = 3*pi/2;
end;
for i = 52:71
X(i) = 1-S*(i-51);
Y(i) = -1;
x(i-1) = X(i)+S/2;
y(i-1) = Y(i);
beta(i-1) = 3*pi/2;
Phi(i-1) = pi;
end;
for i = 72:80
X(i) = -1;
Y(i) = -1+S*(i-71);
x(i-1) = X(i);
y(i-1) = Y(i)-S/2;
beta(i-1) = pi;
Phi(i-1) = pi/2;
end;
% get those last ones
x(N) = -1;
y(N) = -S/2;
beta(N) = pi;
Phi(N) = pi/2;
% that was fun, now find theta values to keep things tidy
for i = 1:20
theta(i) = pi-atan(abs(y(i))/abs(x(i)));
end;
for i = 21:40

13

theta(i) = atan(y(i)/x(i));
end;
for i = 41:60
theta(i) = 2*pi-atan(abs(y(i))/abs(x(i)));
end;
for i = 61:80
theta(i) = pi+atan(abs(y(i))/abs(x(i)));
end;
%
%
%
%
%
%
%

plot endpoints & midpoints


plot(X,Y,r+,x,y,g.)
axis square
axis([-1.5 1.5 -1.5 1.5])
title(Geometry, N = 80)
xlabel(y (m))
ylabel(x (m))

%that was fun, now lets find I(i,j)


for i = 1:N
for j = 1:N
if (i ~= j)
A(i,j) = -(x(i)-X(j))*cos(Phi(j)) - (y(i)-Y(j))*sin(Phi(j));
B(i,j) = (x(i)-X(j))^2 + (y(i)-Y(j))^2;
%dont divide by zero
if (B(i,j) == 0)
B(i,j) = 1e-12;
end;
C(i,j) = sin(Phi(i)-Phi(j));
D(i,j) = (y(i)-Y(j))*cos(Phi(i)) - (x(i)-X(j))*sin(Phi(i));
E(i,j) = (x(i)-X(j))*sin(Phi(j)) - (y(i)-Y(j))*cos(Phi(j));
%please, stop dividing by zero
if (E(i,j) == 0)
E(i,j) = 1e-12;
end;
I(i,j) = C(i,j)/2*log((S^2+2*A(i,j)*S+B(i,j))/B(i,j)) +...
(D(i,j)-A(i,j)*C(i,j))/E(i,j)*(atan((S+A(i,j))/E(i,j))-...
atan(A(i,j)/E(i,j)));
else
I(i,j) = pi;
end;

14

end;
end;
%set up system of equations
for i = 1:N
for j = 1:N
M(i,j) = I(i,j)/(2*pi);
end;
b(i,1) = -U*cos(beta(i));
end;
%get those lambdas & check em
lambda = inv(M)*b
Sum = sum(lambda)
%find velocities & pressure coefficients
for i = 1:N
Vs = 0;
for j = 1:N
if (i ~= j)
M2(i,j) = ((D(i,j)-A(i,j)*C(i,j))/(2*E(i,j)))...
*log((S^2+2*A(i,j)*S+B(i,j))/B(i,j))-C(i,j)...
*(atan((S+A(i,j))/E(i,j))-atan(A(i,j)/E(i,j)));
Vs = Vs+lambda(j)/(2*pi)*M2(i,j);
end;
end;
V(i) = -(U*sin(beta(i))+Vs);
Cp(i) = 1-(V(i)/U)^2;
end;
axis square
subplot(1,2,1),plot(theta*180/pi,V,o)
xlabel(\theta (degrees));
ylabel(Velocity (m/s));
title(Velocity v(\theta));
subplot(1,2,2),plot(theta*180/pi,Cp,sq)
xlabel(\theta (degrees));
ylabel(C_p);
title(Pressure coefficient C_p(\theta));

15

You might also like