You are on page 1of 15

3D Doublet Panel Method

V
An Issue With Doublet Panels
Consider a cut through the body surface
V=Vtang
V<Vtang
V<<Vtang

no flow

• Panels appear as a series of discrete vortices with strengths equal to the difference between adjacent
panel strengths. At the control points we see almost none of the tangential velocity generated by nearby
vortices. This is wrong.
• It is as though the surface were a continuous vortex sheet, and we calculated the tangential velocity at
the c.p. ignoring the discontinuous jump between the inside and outside. This jump, equal to half the local
sheet strength is called the principal value and must be added to the tangent velocity calculated at a
control point V=Vtang
• The principal value for a doublet panel can be
V=0 estimated as -½ local gradient of the panel
strength on the surface.

• This must be added to the tangential velocity calculated at any control point
3D Doublet Panel Code
Non-lifting bodies

• Handling vectors in Matlab


• Specifying a 3D body
• Specifying Panel Geometry
• Panel Influence – solving for the panel
strengths
• Getting the surface pressure
%3D doublet panel method for acyclic flow around 3D bodies.
clear all;
vinf=[1;0;0]; %free stream velocity

%Specify body of revolution geometry


th=-pi/2:pi/20:pi/2;xp=sin(th);yp=cos(th);nc=20;
[r,rc,nw,sw,se,ne,no,we,so,ea]=bodyOfRevolution(xp,yp,nc);

% determine surface area and normal vectors at control points (assumes counter clockwise around com
ac=0.5*v_cross(r(:,sw)-r(:,ne),r(:,se)-r(:,nw));nc=ac./v_mag(ac);

%determine influence coefficient matrix coeff


npanels=length(rc(1,:));coef=zeros(npanels);
for n=1:npanels
cmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))+ffil(rc(:,n),r(:,se),r(:,ne))+f
coef(n,:)=nc(1,n)*cmn(1,:)+nc(2,n)*cmn(2,:)+nc(3,n)*cmn(3,:);
end

%determine result vector and solve matrix for filament strengths


rm=(-nc(1,:)*vinf(1)-nc(2,:)*vinf(2)-nc(3,:)*vinf(3))';
coef(end+1,:)=1;rm(end+1)=0; %prevents singular matrix - sum of panel strengths on closed body is z

ga=coef\rm;

%Determine velocity and pressure at control points


ga=repmat(ga',[3 1]);
for n=1:npanels %Determine velocity at each c.p. without principal value
cmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))+ffil(rc(:,n),r(:,se),r(:,ne))+f
v(:,n)=vinf+sum(ga.*cmn,2);
end %Determine principle value of velocity at each c.p., -grad(ga)/2
gg=v_cross((rc(:,we)-rc(:,no)).*(ga(:,we)+ga(:,no))+(rc(:,so)-rc(:,we)).*(ga(:,so)+ga(:,we))+(rc(:,

v=v-gg/2; %velocity vector


cp=1-sum(v.^2)/(vinf'*vinf); %pressure

%plotting of pressure distribution and velocity vectors


Vectors In Matlab
Use arrays with 3 rows, one for %3D doublet panel method for flow around 3D bodies.
clear all;
each component. E.g. V vinf=[1;0;0]; %free stream velocity

Easy to make functions for function c=v_dot(a,b);


c=zeros(size(a));
vector operations like dot and c(1,:)=a(1,:).*b(1,:)+a(2,:).*b(2,:)+a(3,:).*b(3,:);
cross products, and magnitude c(2,:)=c(1,:);c(3,:)=c(1,:);

With these it is now easier to function c=v_cross(a,b);


c=zeros(size(a));
make more complex functions c(1,:)=(a(2,:).*b(3,:)-a(3,:).*b(2,:));
c(2,:)=(a(3,:).*b(1,:)-a(1,:).*b(3,:));
E.g. ffil(r,rs,re) c(3,:)=(a(1,:).*b(2,:)-a(2,:).*b(1,:));

function q=ffil(r,rs,re);
r1(1,:)=rs(1,:)-r(1,:); r1(2,:)=rs(2,:)-r(2,:); r1(3,:)=rs(3,:)-r(3,:);
r2(1,:)=re(1,:)-r(1,:); r2(2,:)=re(2,:)-r(2,:); r2(3,:)=re(3,:)-r(3,:);
r0(1,:)=r1(1,:)-r2(1,:);r0(2,:)=r1(2,:)-r2(2,:);r0(3,:)=r1(3,:)-r2(3,:);
c=v_cross(r1,r2);
c2=v_dot(c,c);
q=c./c2.*v_dot(r0,r1./v_mag(r1)-r2./v_mag(r2))/4/pi;
Specifying a 3D Body
First we must choose shape. %Specify body of revolution geometry
th=-pi/2:pi/20:pi/2;xp=sin(th);yp=cos(th);nc=20;
E.g. Body of revolution: [r,rc,nw,sw,se,ne,no,we,so,ea]=bodyOfRevolution(xp,yp,nc)

Then we generate the


coordinates, in vector form, of (number of
circumferential points)
all the points on the body.
These points (in a rectangular
array, become the panel corner
points r

function [r,rc,nw,sw,se,ne,no,we,so,ea]=bodyOfRevolution(xp,yp,nc)

%Define vertices of panels


x=repmat(xp,[nc+1 1]); %grid of x points
al=[0:nc]/(nc)*2*pi; %vector of circumferential angles (about x axis)
y=cos(al)'*yp;
z=sin(al)'*yp;
r=zeros([3 size(x)]);r(1,:)=x(:);r(2,:)=y(:);r(3,:)=z(:); %position vector of vertices
ri=reshape(1:prod(size(x)),size(x)); %index of vertices
no Panel Geometry
ne
ea Control point locations have locations rc
nw Panel vertices have locations r
nc
we
se rc  1
4
rnw  rsw  rne  rse 
sw
Defining the indices, also defines how the
rc so body closes
r
r=zeros([3 size(x)]);r(1,:)=x(:);r(2,:)=y(:);r(3,:)=z(:); %position vector of vertices
ri=reshape(1:prod(size(x)),size(x)); %index of vertices

%panel i,j has corners i,j i+1,j i+1,j+1 i,j+1


nw=ri(1:end-1,1:end-1);sw=ri(2:end,1:end-1); %indices of upper and lower left corners
ne=ri(1:end-1,2:end);se=ri(2:end,2:end); %indices of upper and lower right corners
% determine panel centers (control points) and indices
rc=(r(:,nw)+r(:,sw)+r(:,ne)+r(:,se))/4;rc=reshape(rc,[3 size(nw)]);
ci=reshape(1:prod(size(nw)),size(nw));
% determine indices of panels bordering each control point
no=ci([end 1:end-1],:);so=ci([2:end 1],:); %Panels above and below.
we=ci(:,[1 1:end-1]);ea=ci(:,[2:end end]); %Panels to left and right.
no Panel Geometry
ne
ea Control point locations have locations rc
nw Panel vertices have locations r
nc
we
se rc  1
4
rnw  rsw  rne  rse 
sw
Defining the indices, also defines how the
rc so body closes
Seam
r
2nd index increasing
r=zeros([3 size(x)]);r(1,:)=x(:);r(2,:)=y(:);r(3,:)=z(:); %position vector of vertices
ri=reshape(1:prod(size(x)),size(x)); %index of vertices
n
e
%panel i,j has corners i,j i+1,j i+1,j+1 i,j+1 w
s
nw=ri(1:end-1,1:end-1);sw=ri(2:end,1:end-1); %indices of upper and lower left corners
ne=ri(1:end-1,2:end);se=ri(2:end,2:end); %indices of upper and lower right corners
% determine panel centers (control points) and indices
rc=(r(:,nw)+r(:,sw)+r(:,ne)+r(:,se))/4;rc=reshape(rc,[3 size(nw)]);
ci=reshape(1:prod(size(nw)),size(nw)); 1st index increasing
% determine indices of panels bordering each control point
no=ci([end 1:end-1],:);so=ci([2:end 1],:); %Panels above and below.
we=ci(:,[1 1:end-1]);ea=ci(:,[2:end end]); %Panels to left and right.
Panel Geometry
rse-rnw
ne
Determine area vector and outward
nw normal of each panel by cross product
nc
se
a c  12 (rsw  rne )  (rse  rnw )
rsw-rne
sw nc  ac / | ac |

[r,rc,nw,sw,se,ne,no,we,so,ea]=bodyOfRevolution(xp,yp,nc);

% determine surface area and normal vectors at control points (assumes counter clockwise
around compass by RH rule points out of surface)
ac=0.5*v_cross(r(:,sw)-r(:,ne),r(:,se)-r(:,nw));nc=ac./v_mag(ac);
Panel Influence
Velocity due to panel m at control point n:
V (rc( n ) )
(m)

 f fil (rc( n ) , rnw
( m) ( m)
, rsw )  f fil (rc( n ) , rsw
(m)
, rse( m ) )
ne  f fil (rc( n ) , rse( m ) , rne( m ) )  f fil (rc( n ) , rne( m ) , rnw
(m)
)  (m)
nw (m)
or V (r (n)
c )  C ( n ,m )  ( m )
Panel m
se Summed velocity at control point n is thus:

sw V (rc( n ) )  V   C ( n ,m )  ( m ) (w/o tangential velocity
m due to principal value)
Normal component is
r(m)
V (rc( n ) ).n c( n )  0  V n c( n )   C ( n ,m ) .n (cn )  ( m )
m

(n) So, to get the (m)’s we need to solve the


rc simultaneous equations:
 V n (cn )   C ( n ,m ) .n (cn )  ( m )
m
Control
point n Nx1 matrix of freestream NxN coefficient Nx1 matrix of
components matrix panel strengths
Panel Influence
Velocity due to panel m at control point n:
V (rc( n ) )
(m)

 f fil (rc( n ) , rnw
( m) ( m)
, rsw )  f fil (rc( n ) , rsw
(m)
, rse( m ) )
ne  f fil (rc( n ) , rse( m ) , rne( m ) )  f fil (rc( n ) , rne( m ) , rnw
(m)
)  (m)
nw (m)
or V (r (n)
c )  C ( n ,m )  ( m )
Panel m
%determine Total
se velocity
influence at control
coefficient point
matrix n is
coef thus:
 npanels=length(rc(1,:));coef=zeros(npanels);
sw
for n=1:npanels ( n )
V (rc )  V  C ( n ,m )
 
(m) (w/o tangential velocity
cmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))
m due to principle value)
+ffil(rc(:,n),r(:,se),r(:,ne))+ffil(rc(:,n),r(:,ne),r(:,nw));
Normal component is
coef(n,:)=nc(1,n)*cmn(1,:)+nc(2,n)*cmn(2,:)+nc(3,n)*cmn(3,:);
r(m) end

).n c 
(n)
V (rc vector
%determine result 0 solve
and c 
(n)
V nmatrix
m
.n c  strengths
C filament
for
(n)
 ( n ,m ) (n) (m)

rm=(-nc(1,:)*vinf(1)-nc(2,:)*vinf(2)-nc(3,:)*vinf(3))';
So, to get the 
coef(end+1,:)=1;rm(end+1)=0;(m)%prevents singular matrix
’s we need to solve the
rc(n) ga=coef\rm;
simultaneous equations:
 V n (cn )   C ( n ,m ) .n c( n )  ( m )
m
Control
point n Nx1 matrix of freestream NxN coefficient Nx1 matrix of
components matrix panel strengths
Determining Surface Pressure
Total velocity at control point

V (rc( n ) )  V   C ( n ,m )  ( m ) 
no Tangential velocity
due to principal
m value at rc
ea
Tangential velocity
nc due to principal   12   Evaluated at rc
value at rc
we
Using the gradient theorem and values of  at
neighboring control points we can show that
rc so
(rwe  rno )(we  no )  (rso  rwe )(so  we ) 
 (r  r )(   )  (r  r )(   )  n c
   ea so ea so no ea no ea 

(rno  rso )  (rwe  rea )

(n) 2
We can then use Bernoulli V (r
c )
C p (r (n)
c )  1
to compute the pressure V
2
Determining Surface Pressure
Velocity at control point

V (rc( n ) )  V   C ( n ,m )  ( m ) 
no Tangential velocity
due to principal
m value at rc
ea
Tangential velocity
nc due to principal   12   Evaluated at rc
value at rc
we
%Determine velocity and pressure at control points
for n=1:npanels Using
%Get the gradient
velocity theorem
at each and
c.p. w/o of  at
values value
principal
cmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))
neighboring control points we can show that
+ffil(rc(:,n),r(:,se),r(:,ne))+ffil(rc(:,n),r(:,ne),r(:,nw));
rc so
rwe  rno )(principle
(%Determine
v(:,n)=vinf+sum(ga.*cmn,2);
we  no ) value,
 (rso -grad(ga)/2
rwe )(so  we ) 
  nc
end

 (rea  rso )(ea  so )  (rno  rea )(no  ea )
gg=v_cross((rc(:,we)-rc(:,no)).*(ga(:,we)+ga(:,no))+(rc(:,so)-...
  
v=v-gg/2; %velocity vector
(rno  rso )  (rwe  rea )
cp=1-sum(v.^2)/(vinf'*vinf); %pressure

(n) 2
We can then use Bernoulli V (r
c )
C p (r (n)
c )  1
to compute the pressure V
2
Determining Surface Pressure
Velocity
%Determine velocity at control
and pressure at point
control points
for n=1:npanels %Get velocity at each c.p. w/o principal value


no Tangential velocity
cmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))
V (rc( n ) )  V  C ( n ,m )  ( m )  due to principle
+ffil(rc(:,n),r(:,se),r(:,ne))+ffil(rc(:,n),r(:,ne),r(:,nw));
v(:,n)=vinf+sum(ga.*cmn,2); m value at rc
end %Determine principle value, -grad(ga)/2
ea
gg=v_cross((rc(:,we)-rc(:,no)).*(ga(:,we)+ga(:,no))+(rc(:,so)-...
Tangential velocity
v=v-gg/2; %velocity vector
n c due to principle
cp=1-sum(v.^2)/(vinf'*vinf); %pressure
  12   Evaluated at rc
value at rc
we
Using the gradient theorem and values of  at
neighboring control points we can show that
rc so
(rwe  rno )(we  no )  (rso  rwe )(so  we ) 
 (r  r )(   )  (r  r )(   )  n c
   ea so ea so no ea no ea 

(rno  rso )  (rwe  rea )

(n) 2
We can then use Bernoulli V (r
c )
C p (r(n)
c )  1
to compute the pressure V
2
Using the Code
• Plotting the pressure, streamlines
• Deforming the body shape
• Changing the shape
• More than one body

You might also like