21. non-lifting 3d panel method

15
3D Doublet Panel Method V

Upload: janmejaya8692

Post on 21-Apr-2015

117 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 21. Non-Lifting 3D Panel Method

3D Doublet Panel Method

V

Page 2: 21. Non-Lifting 3D Panel Method

no flow

An Issue With Doublet PanelsConsider a cut through the body surface

V=VtangV<VtangV<<Vtang

Page 3: 21. Non-Lifting 3D Panel Method

3D Doublet Panel Code

• Handling vectors in Matlab• Specifying a 3D body• Specifying Panel Geometry• Panel Influence – solving for the panel

strengths• Getting the surface pressure

Non-lifting bodies

Page 4: 21. Non-Lifting 3D Panel Method

%3D doublet panel method for acyclic flow around 3D bodies.clear all;vinf=[1;0;0]; %free stream velocity

%Specify body of revolution geometryth=-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 comac=0.5*v_cross(r(:,sw)-r(:,ne),r(:,se)-r(:,nw));nc=ac./v_mag(ac);

%determine influence coefficient matrix coeffnpanels=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))+fcoef(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 strengthsrm=(-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 pointsga=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))+fv(:,n)=vinf+sum(ga.*cmn,2);

end %Determine principle value of velocity at each c.p., -grad(ga)/2gg=v_cross((rc(:,we)-rc(:,no)).*(ga(:,we)+ga(:,no))+(rc(:,so)-rc(:,we)).*(ga(:,so)+ga(:,we))+(rc(:,

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

%plotting of pressure distribution and velocity vectors

Page 5: 21. Non-Lifting 3D Panel Method

Vectors In MatlabUse arrays with 3 rows, one for each component. E.g. V

Easy to make functions for vector operations like dot and cross products, and magnitude

With these it is now easier to make more complex functionsE.g. ffil(r,rs,re)

function c=v_dot(a,b);c=zeros(size(a));c(1,:)=a(1,:).*b(1,:)+a(2,:).*b(2,:)+a(3,:).*b(3,:);c(2,:)=c(1,:);c(3,:)=c(1,:);

function c=v_cross(a,b);c=zeros(size(a));c(1,:)=(a(2,:).*b(3,:)-a(3,:).*b(2,:));c(2,:)=(a(3,:).*b(1,:)-a(1,:).*b(3,:));c(3,:)=(a(1,:).*b(2,:)-a(2,:).*b(1,:));

%3D doublet panel method for flow around 3D bodies.clear all;vinf=[1;0;0]; %free stream velocity

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;

Page 6: 21. Non-Lifting 3D Panel Method

Specifying a 3D BodyFirst we must choose shape. E.g. Body of revolution:

Then we generate the coordinates, in vector form, of 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 panelsx=repmat(xp,[nc+1 1]); %grid of x pointsal=[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 verticesri=reshape(1:prod(size(x)),size(x)); %index of vertices

(number of circumferential points)

%Specify body of revolution geometryth=-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)

Page 7: 21. Non-Lifting 3D Panel Method

Control point locations have locations rcPanel vertices have locations r

r=zeros([3 size(x)]);r(1,:)=x(:);r(2,:)=y(:);r(3,:)=z(:); %position vector of verticesri=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+1nw=ri(1:end-1,1:end-1);sw=ri(2:end,1:end-1); %indices of upper and lower left cornersne=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 pointno=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.

seneswnwc rrrrr 41

Panel Geometryno

ea

so

we

rc

sw

se

ne

nw

r

nc

Defining the indices, also defines how the body closes

Page 8: 21. Non-Lifting 3D Panel Method

Control point locations have locations rcPanel vertices have locations r

r=zeros([3 size(x)]);r(1,:)=x(:);r(2,:)=y(:);r(3,:)=z(:); %position vector of verticesri=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+1nw=ri(1:end-1,1:end-1);sw=ri(2:end,1:end-1); %indices of upper and lower left cornersne=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 pointno=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.

seneswnwc rrrrr 41

Panel Geometryno

ea

so

we

rc

sw

se

ne

nw

r

nc

Defining the indices, also defines how the body closes

Seam

n

se

w

1st index increasing

2nd index increasing

Page 9: 21. Non-Lifting 3D Panel Method

Panel Geometry

rsw-rnesw

se

ne

nw

nc

||/)()(2

1

ccc

nwseneswc

aanrrrra

rse-rnw

Determine area vector and outward normal of each panel by cross product

[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);

Page 10: 21. Non-Lifting 3D Panel Method

r(m)

Panel Influence

sw

se

ne

nw

)()()()()()()(

)()()()()()()()(

),,(),,(

),,(),,()(mm

nwm

nen

cfilm

nem

sen

cfil

mse

msw

ncfil

msw

mnw

ncfil

mnc

rrrfrrrf

rrrfrrrfrV

)(),()()( )( mmnmnc CrVor

Panel m

rc(n)

Control point n

Velocity due to panel m at control point n:

Normal component is

m

mnc

mnnc

nc

nc

)()(),()()()( .0).( nCnVnrV

So, to get the (m)’s we need to solve the simultaneous equations:

m

mnc

mnnc

)()(),()( .nCnV

NxN coefficient matrix

Nx1 matrix of freestream components

Nx1 matrix of panel strengths

Summed velocity at control point n is thus:

m

mmnnc

)(),()( )( CVrV (w/o tangential velocity due to principal value)

Page 11: 21. Non-Lifting 3D Panel Method

rc(n)

r(m)

)()()()()()()(

)()()()()()()()(

),,(),,(

),,(),,()(mm

nwm

nen

cfilm

nem

sen

cfil

mse

msw

ncfil

msw

mnw

ncfil

mnc

rrrfrrrf

rrrfrrrfrV

Panel Influence

sw

se

ne

nw )(),()()( )( mmnmnc CrVor

Panel m

Control point n

Velocity due to panel m at control point n:

Total velocity at control point n is thus:

m

mmnnc

)(),()( )( CVrV

Normal component is

m

mnc

mnnc

nc

nc

)()(),()()()( .0).( nCnVnrV

So, to get the (m)’s we need to solve the simultaneous equations:

m

mnc

mnnc

)()(),()( .nCnV

Nx1 matrix of freestream components

Nx1 matrix of panel strengths

NxN coefficient matrix

(w/o tangential velocity due to principle value)

%determine influence coefficient matrix coefnpanels=length(rc(1,:));coef=zeros(npanels); for n=1:npanelscmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))

+ffil(rc(:,n),r(:,se),r(:,ne))+ffil(rc(:,n),r(:,ne),r(:,nw));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 strengthsrm=(-nc(1,:)*vinf(1)-nc(2,:)*vinf(2)-nc(3,:)*vinf(3))';coef(end+1,:)=1;rm(end+1)=0; %prevents singular matrix ga=coef\rm;

Page 12: 21. Non-Lifting 3D Panel Method

no

ea

so

we

rc

Determining Surface Pressure

Using the gradient theorem and values of at neighboring control points we can show that

)()())(())((

))(())((

eawesono

ceanoeanosoeasoea

wesowesonowenowe

rrrr

nrrrr

rrrr

nc

m

mmnnc

)(),()( )( CVrV Tangential velocity due to principal value at rc

21Tangential velocity

due to principal value at rc

Evaluated at rc

Total velocity at control point

We can then use Bernoulli to compute the pressure 2

2)()(

)(1)(

V

rVr

ncn

cpC

Page 13: 21. Non-Lifting 3D Panel Method

no

ea

so

we

rc

Using the gradient theorem and values of at neighboring control points we can show that

Determining Surface Pressure

)()())(())((

))(())((

eawesono

ceanoeanosoeasoea

wesowesonowenowe

rrrr

nrrrr

rrrr

nc

m

mmnnc

)(),()( )( CVrV Tangential velocity due to principal value at rc

21Tangential velocity

due to principal value at rc

Evaluated at rc

Velocity at control point

We can then use Bernoulli to compute the pressure 2

2)()(

)(1)(

V

rVr

ncn

cpC

%Determine velocity and pressure at control pointsfor n=1:npanels %Get velocity at each c.p. w/o principal value

cmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))+ffil(rc(:,n),r(:,se),r(:,ne))+ffil(rc(:,n),r(:,ne),r(:,nw));

v(:,n)=vinf+sum(ga.*cmn,2);end %Determine principle value, -grad(ga)/2gg=v_cross((rc(:,we)-rc(:,no)).*(ga(:,we)+ga(:,no))+(rc(:,so)-...

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

Page 14: 21. Non-Lifting 3D Panel Method

no

ea

so

we

rc

Using the gradient theorem and values of at neighboring control points we can show that

Determining Surface Pressure

)()())(())((

))(())((

eawesono

ceanoeanosoeasoea

wesowesonowenowe

rrrr

nrrrr

rrrr

nc

m

mmnnc

)(),()( )( CVrV Tangential velocity due to principle value at rc

21Tangential velocity

due to principle value at rc

Evaluated at rc

Velocity at control point

We can then use Bernoulli to compute the pressure 2

2)()(

)(1)(

V

rVr

ncn

cpC

%Determine velocity and pressure at control pointsfor n=1:npanels %Get velocity at each c.p. w/o principal value

cmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))+ffil(rc(:,n),r(:,se),r(:,ne))+ffil(rc(:,n),r(:,ne),r(:,nw));

v(:,n)=vinf+sum(ga.*cmn,2);end %Determine principle value, -grad(ga)/2gg=v_cross((rc(:,we)-rc(:,no)).*(ga(:,we)+ga(:,no))+(rc(:,so)-...

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

Page 15: 21. Non-Lifting 3D Panel Method

Using the Code

• Plotting the pressure, streamlines• Deforming the body shape• Changing the shape • More than one body