Anda di halaman 1dari 19

APPENDIX

Computer programs
Program 1.1
Calculation of flow past a circular cylinder including surface
velocity, comparison with exact solution
program circle(input,output); {calculates flow past a circular cylinder.
type
index = 1..51 ;
vector = array [index] of real;
matrix = array [index,index] of real;
var
k,m,n,ij
coup
xdata,ydata,ds,slope,sine,cosine/hs,ans
x 1 ,y 1 ,x2,y2,radius,fi,dfi,pi, vel

: integer;
: matrix;
: vector;
: real;

{*** Input data procedure ***}


procedure input_data;
begin
writeln('number of pivotal points?'); read(m);
writeln('mainstream velocity?'); read(vel);
writeln('cylinder radius?'); read(radius);
dfi := 2.0*pi/m;
forn := 1 tom+1 do
begin
fi := (n-l)*dfi;
xdata[n] := radius*(l.O-cos(fi)); ydata[n] := radius*sin(fi);
end;
end;
{*** Profile data preparation ***}
procedure data_preparation;
const
ex = 0.000001;
var
abscos,t: real; n : integer;
begin
xl := xdata[l]; yl := ydata[l];
writelnCpivotal points':24); writeln;
writeln('x':ll,y:14); writeln;
forn:=l torn do
499

Appendix
begin
x2 := xdata[n+l]; y2 := ydata[n+l];
ds[n] := sqrt(sqr(x2-xl)+sqr(y2-yl));
sine[n] := (y2-yl)/ds[n]; cosinefn] := (x2-xl)/ds[n];
abscos := abs(cosine[n]);
if abscos>ex then t := arctan(sine[n]/cosine[n]);
if (abscos<ex) or (abscos=ex)
then slope[n] := sine[n]/abs(sine[n])*pi/2.0;
if cosine[n]>ex then slope[n] := t;
if cosine[n]<(-ex) then slope[n] := t-pi;
xdatafn] := (xl+x2)*0.5; ydata[n] := (yl+y2)*0.5;
xl := x2; yl := y2;
writeln(xdata[n]: 14:6,ydata[n]: 14:6);
end; writeln;
end;
{*** Coupling coefficients ***}
procedure coupling_coefficients;
var
r,u,v,twopi: real; i j : integer;
begin
twopi := 2.0*pi;
{*** Calculate the self inducing coupling coefficients ***
coup[l,l] := -0.5-(slope[2]-slope[m]-2.0*pi)/(8.0*pi);
coup[m,m] := -0.5-(slope[l]-slope[m-l]-2.0*pi)/(8.0*pi);
fori := 2 tom-1 do
begin
coup[i,i] := -0.5-(slope[i+l]-slope[i-l])/(8.0*pi);
end;
{*** Calculate coupling coefficients for j <> i ***}
for i := 1 to m do for j := i to m do if j o i then
begin
r := sqr(xdata[j]-xdata[i])+sqr(ydata[j]-ydata[i]);
u := (ydata[j]-ydata[i])/(twopi*r);
v := -(xdata[j]-xdata[i])/(twopi*r);
coup[j,i] := (u*cosine[j]+v*sine[j])*ds[i];
coup[ij] := -(u*cosine[i]+v*sine[i])*ds[j];
end;
end;
I"1
procedure invert_matrix;
var
a,b :real; pivot: vector; i,j,k: integer;
begin
for i := 1 to m do
begin
500

Computer programs
a := coup[i,i]; coup[i,i] := 1.0;
forj := 1 torn do
begin
pivot[j] := coup[j,i]/a; coup[j,i] := pivot[j];
end;
forj := 1 torn do
begin
if i o j then
begin
b := coup[i j ] ; coup[i,j] := 0.0;
for k := 1 to m do coup[k,j] := coup[k j]-b*pivot[k];
end;
end;
end;
end;
{*** Calculate right hand side values ***}
procedure right_hand_sides;
var i : integer;
begin
for i := 1 to m do rhs[i] := -vel*cosine[i];
end;
{*** Solve for surface vorticity element strengths ***}
procedure solution;
var exact: real; i j : integer;
begin
writelnClocation'/numerical': 14,'exact': 13); writeln;
for i := 1 to m do
begin
{*** Multiply rhs column vector by inverted matrix ***}
ans[i] := 0.0;
forj := 1 to m do ans[i] := ans[i]+coup[ij]*rhs[j];
exact := 2.0*vel*sin((i-0.5)*dfi);
{Exact solution}
writeln(i:5,ans[i]: 18:6,exact: 14:6);
end;
end;
{*** Main program ***}
begin
pi:=4.0*arctan(1.0);
input_data;
data_preparation;
coupling_coefficients;
invert_matrix;
right_hand_sides;
solution;
end.
501

Appendix
Program 1.2
Calculation of the flow past a circular cylinder by the Douglas Neumann
source panel method
program source(input,output);
type
index = 1..51 ;
vector = array [index] of real;
matrix = array [index,index] of real;
var
k,m,n,i j,ndivs
: integer;
coup
: matrix;
xdata,ydata,ds,slope,sine,cosine,pivot,rhs,
ans,source,delx,dely
: vector;
: real;
u,v/,xl,yl,x2,y2/ad,fi,dfi,pi,twopi,vel
{*** procedures ***}
procedure inputdata;
var n : integer,
begin
writeln(fnumber of pivotal points?'); read(m);
writeln('number of sub-elements?1); readln(ndivs);
writeln('mainstream velocity?'); read(vel);
writeln('cylinder radius?'); read(rad);
dfi := 2.0*pi/m;
for n := 1 to m+1 do
begin
fi:=(n-1.0)*dfi;
xdata[n] := rad*(1.0-cos(fi)); ydatafn] := rad*sin(fi);
end;
end;
{*** profile data preparation ***}
procedure data_preparation;
const
ex = 0.000001;
var
abscos,t : real; n : integer;
begin
xl := xdata[l]; yl := ydata[l];
writelnCpivotal points':24); writeln;
writeln(Y:ll,y:14); writeln;
for n:=l to m do
begin
x2 := xdata[n+l]; y2 := ydata[n+l];
delx[n] := (x2-xl)/ndivs; dely[n] := (y2-yl)/ndivs;
502

Computer programs
ds[n] := sqrt(sqr(x2-xl)+sqr(y2-yl));
sine[n] := (y2-yl)/ds[n]; cosine[n] := (x2-xl)/ds[n];
abscos := abs(cosine[n]);
if abscos>ex then t := arctan(sine[n]/cosine[n]);
if (abscos<ex) or (abscos=ex)
then slope[n] := sine[n]/abs(sine[n])*pi/2.0;
if cosine[n]>ex then slope[n] := t;
if cosine[n]<(-ex) then slope[n] := t-pi;
xdata[n] := (xl+x2)*0.5; ydata[n] := (yl+y2)*0.5;
x l : = x 2 ; y l := y2;
writeln(xdata[n]: 14:6,ydata[n]: 14:6);
end; writeln;
end;
{*** coupling coefficients ***}
procedure source_coupling_coefficients;
var i jjc: integer;
begin
for i := 1 to m do
begin
for j := 1 to m do if j o i then
begin
u := 0.0; v := 0.0;
for k := 1 to ndivs do
begin
xl := xdata[i]+(k-0.5*(l+ndivs))*delx[i];
yl := ydata[i]+(k-0.5*(l+ndivs))*dely[i];
r := sqr(xdata[j]-xl)+sqr(ydata[j]-yl);
u := u+(xdata[j]-xl)/r;
v := v+(ydata[j]-yl)/r;
end;
u := u/(twopi*ndivs); v := v/(twopi*ndivs);
coup[j,i] := (-u*sine[j]+v*cosine[j])*ds[i];
end;
end;
for i := 1 to m do
begin
coup[i,i] := 0.5;
end;
end;
{*** matrix inversion ***}
procedure invert_matrix;
(Same as for program 1.1)
{** calculate rhs values ***}
procedure right_hand_sides;
var i: integer;
begin
503

Appendix
for i := 1 to m do rhs[i] := vel*sine[i];
end;
{*** solve for source element strengths ***}
procedure solve_for_source_strength;
var i j : integer;
begin
for i := 1 to m do
begin
source[i] := 0.0;
for j := 1 to m do source[i] := source[i]+coup[ij]*rhs[j];
end;
end;
{*** Perform second integral for surface velocity ***}
procedure calculate_surface_velocity;
var exact : real; i j j c : integer;
begin
for i := 1 to m do
begin
{Contribution due to uniform stream)
ans[i] := vel*cosine[i];
{Contribution due to the surface source distribution)
for j := 1 to m do if j o i then
begin
u := 0.0; v := 0.0;
for k := 1 to ndivs do
begin
xl := xdata[j]+(k-0.5*(l+ndivs))*delx[j];
yl := ydata[j]-f(k^0.5*(l+ndivs))*dely[j];
r := sqr(xl-xdata[i])+sqr(yl-ydata[i]);
u := u+(xdata[i]-xl)/r;
v := v+(ydata[i]-yl)/r;
end;
u := u*source[j]*ds[j]/(twopi*ndivs);
v := v*source[j]*ds[j]/(twopi*ndivs);
ans[i] := ans[i]+u*cosine[i]+v*sine[i];
end;
end;
{Now print out results)
writelnClocation'/numerical'iH/exact': 13); writeln;
fori := 1 torn do
begin
exact := 2.0*vel*sin((i-0.5)*2.0*pi/m);
writeln(i:5,ans[i]/vel:18:6,exact/vel:14:6);
end;
end;

504

Computer programs
{*** main program ***}
begin
pi := 4.0*arctan(1.0); twopi := 2.0*pi;
inputdata;
data_preparation;
source_coupling_coefficients;
invert_matrix;
right_hand_sides;
solve_for_source_strength;
calculate_surface_velocity;
end.

Program 1.3
Calculation of the flow past an ellipse, including surface velocity comparison
with exact solution and streamline pattern
program ellipse(input,output); {Calculates flow past an ellipse}
type
vector =array[1..51] of real;
vectorl = array[1..100] of real;
matrix = array [1..50,1..50] of real;
var
k,m,number,diff,n,ij
: integer;
coup
: matrix;
xdata,ydata,ds,slope,sine,cosine/hs,vorticity,ystart
: vector;
x,y
: vectorl;
major/atio,theta,xl,yl,x2,y2,rad,fi,dfi,pi,Winf,
Uinf,Vinf,alpha,xl,xr
: real;
{*** Procedures***}
procedure inputdata;
var i,n : integer,
begin
writeln('number of pivotal points?1); read(m);
writeln('mainstream velocity?'); read(Winf);
writeln('angle of attack?1); readln(alpha);
alpha := alpha*pi/180.0;
Uinf := Winf*cos(alpha); Vinf := Winf*sin(alpha);
writeln('major axis?1); read(major);
writeln('minor axis/major axis?'); readln(ratio);
{*** Data coordinates for ellipse ***}
dfi := 2.0*pi/m;
forn := 1 tom+1 do
begin
fi:=(n-l)*dfi;
505

Appendix
xdata[n] := 0.5*major*(1.0-cos(fi));
ydatafn] := ratio*0.5*major*sin(fi);
end;
{*** Set up specifications for streamlines ***}
writelnCFor forward difference enter I1);
writeln(fFor central difference enter number of iterations');
readln(diff); xl := 0.0; xr := 0.0;
for i := 1 to m do if xdata[i]<xl then xl := xdata[i];
for i := 1 to m do if xdata[i]>xr then xr := xdata[i];
writeln('furthest data to left is at x =',xl: 10:6);
writeln('Enter x location on left to begin streamlines1);
readln(xl);
writeln('furthest data to write is at x =',xr:10:6);
writeln('Enter x location on right to end streamlines');
readln(xr);
writelnCNumber of streamlines to be plotted'); readln(number);
writelnO.e. is roughly at y =',(ydata[l]+ydata[m])/2.0:10:6);
writeln('Enter y positions for streamline starts');
for n := 1 to number do
begin
write('Streamline',n:4,' of ,number4,''); readln(ystart[n]);
end;
x[l] := xl;
{x starting position for streamlines)
for i := 1 to m+1 do writeln(filel,xdata[i]:10:6,ydata[i]:10:6);
end;
{*** Profile data preparation ***}
procedure data_preparation;
{*** Coupling coefficients ***}
procedure coupling_coefficients;
{* * * Matrix inversion * * *}
procedure invert_matrix;

}
}
} Same as for
} program 1.1
}
}

{*** Calculate right hand side values ***}


procedure right_hand_sides;
var i : integer;
begin
for i := 1 to m do rhs[i] := -Uinf*cosine[i]-Vinf*sine[i];
end;
{*** Multiply rhs column vector by inverted matrix ***}
procedure solution;
var
exact,f,abyr: real; i j : integer;
begin
abyr := sqrt((1.0-ratio)/(l.Of ratio));
writelnOlocationVnumericar: 14,'exact': 13); writeln;
506

Computer programs
for i := 1 to m do
begin
ans[i] := 0.0;
for j := 1 to m do ans[i] := ans[i]+coup[ij]*rhs[j];
{*** Exact solution***}
theta := pi-(i-0.5)*2.0*pi/m;
f := sqrt(1.0+sqr(srq(abyr))-2.0*sqr(abyr)*cos(2.0*theta));
exact := 2.0*Winf*sin(theta-alpha)/f;
writeln(i:5,ans[i]:18:6,exact:14:6);
end;
end;
{*** Induced u,v velocities at x,y due to surface vorticity ***}
procedure velocities(var u,v,x,y : real);
var rsq,con,dx,dy ' real; i: integer;
begin
u := 0.0; v := 0.0;
for i := 1 to m do
begin
dx := x-xdata[i]; dy := y-ydata[i];
rsq := sqr(dx)+sqr(dy);
con := ans[i]*ds[i]/2.0/pi/rsq;
u := u+con*dy; v := v-con*dx;
end;
u := u+Uinf; v := v+Vinf;
end;
{*** Calculation of streamlines ***)
procedure streamlines;
var
con,ul,vl,u2,v2,dt/ : real; ij,n : integer;
begin
dt := (xr-xl)/50.0/Uinf;
for n := 1 to number do
begin
j : = l ; y[l] := ystartfn];
while ((j<200) and (x[j]<xr)) do
begin
velocities(u 1 ,v 1 ,x[j] ,y [j]);
x[j+l] := x[j]+ul*dt; y[j+l] := y[j]+vl*dt;
if diff>l then for k := 1 to (diff-1) do
begin
velocities(u2,v2,x[j+l],y|j+l]);
u2 := 0.5*(ul+u2); v2 := 0.5*(vl+v2);
xU+1] := x[j]+u2*dt; y[j+l] := y[j]+v2*dt;
end;
end;
507

Appendix
writeln; writeln(filel j-1);
fori := 1 to j-1 do writeln(filel,x[i]:10:6,y[i]:10:6);
end;
end;
{*** Main Program***)
begin
pi:=4.0*arctan(1.0);
{*** Open and name one output file ***}
writelnCName of output data file?1); readln(stl);
assign(filel,stl); rewrite(filel);
{*** Main computational sequence ***}
inputdata;
data_preparation;
coupling^coefficients;
invert_matrix;
right_hand_sides;
solution;
streamlines;
writeln('Solutions are in file \stl); writeln;
end.

Program 2.1
Calculation of flow past a cylinder with bound circulation
program circle l(input,output);
type
index = 1..51;
vector = array [index] of real;
matrix = array [index,index] of real;
var
k,m,n,i j
coup
xdata,ydata,ds,slope,sine,cosine,rhs,ans
xl,yl,x2,y2,radius,ii,dfi,pi,vel,gamma

: integer;
: matrix;
: vector;
: real;

{*** Input data procedure ***}


procedure input_data;
var n : integer,
begin
writeln('number of pivotal points?1); read(m);
writelnCmainstream velocity?1); read(vel);
writeln('bound circulation strength?1); read(gamma);
writeln('cylinder radius?'); read(radius);
dfi := 2.0*pi/m;
508

Computer programs
for n := 1 to m+1 do
begin
fi := (n-l)*dfi;
xdata[n] := radius*(l.O-cos(fi)); ydata[n] := radius*sin(fi);
end;
end;
procedure data_preparation;

(Same as for program 1.1)

procedure coupling_coefficients;

(Same as for program 1.1)

{*** Procedure to add ds[i] to all matrix coefficients ***}


{*** to allow for bound circulation ***}
procedure modify_matrix_for_bound_circ;
var i j : integer;
begin
for i := 1 to m do for j := 1 to m do coup[j,i] := coup[j,i]+ds[i];
end;
procedure invert_matrix;

(Same as for program 1.1)

{*** Calculate right hand side values ***}


procedure right_hand_sides;
var i : integer;
begin
for i := 1 to m do rhs[i] := -vel*cosine[i]+gamma;
end;
procedure solution;

(Same as for program 1.1)

{*** Main program ***}


begin
pi:=4.0*arctan(1.0);
input_data;
data_preparation;
coupling_coefficients;
modify_matrix_for_bound_circ;
invert_matrix;
right_hand_sides;
solution;
end.

509

Appendix
Program_2.2
Flow past an ellipse with prescribed bound circulation.
program ellipse l(input,output);
type
vector =array[1..51] of real;
matrix = array[1..50,1..50] of real;
var
k,m,nsubs,n,i j
coup
xdata,ydata,ds,slope,sine,cosine,rhs,ans
major,ratio,theta,x 1 ,y 1 ,x2,y2,rO,fi,pi,
twopi,Winf,Uinf,Vinf,alpha,gamma,sum

: integer;
: matrix;
: vector;
: real;

{*** Procedures***}
procedure inputdata;
var n : integer,
begin
writeln('number of pivotal points?1); read(m);
writeln('number of sub-elements?1); read(nsubs);
writeln(fmainstream velocity?'); read(Winf);
writeln('angle of attack?1); readln(alpha); alpha := alpha*pi/180.0;
Uinf := Winf*cos(alpha); Vinf := Winf*sin(alpha);
writelnCbound circulation?1); readln(gamma);
writeln('major axis?'); read(major);
writeln(f minor axis/major axis?1); readln(ratio);
for n := 1 to m+1 do
{*** Data coordinates for ellipse ***}
begin
fi := (n-l)*twopi/m;
xdata[n] :=0.5*major*(1.0-cos(fi));
ydatajn] := ratio*0.5*major*sin(fi);
end;
end;
procedure data_preparation;

(Same as for program 1.1)

{*** Coupling coefficients using sub-elements ***}


procedure coupling_coefficients;
var r,u,v : real; i j,k : integer,
begin
{Self-induced coupling coefficients}
coup[l,l] := -0.5-(slope[2]-slope[m]-2.0*pi)/(8.0*pi);
coup[m,m] := -0.5-(slope[l]-slope[m-l]-2.0*pi)/(8.0*pi);
fori :=2tom-l do
coup[i,i] := -0.5-(slope[i+l]-slope[i-l])/(8.0*pi);

510

Computer programs
{remaining coupling coefficients using sub-elements}
for i := 1 to m do
begin
for j := 1 to m do if i <> j then
begin
u := 0.0; v := 0.0;
for k := 1 to nsubs do
begin
xl := xdata[i]+(k-0.5*(l+nsubs))*ds[i]*cosine[i]/nsubs;
yl := ydata[i]+(k-0.5*(l+nsubs))*ds[i]*sine[i]/nsubs;
r := sqr(xdata[j]-xl)+sqr(ydata[j]-yl);
u := u+(ydata[j]-yl)/r, v := v-(xdata[j]-xl)/r;
end;
u := u/(twopi*nsubs); v := v/(twopi*nsubs);
coup[j,i] := (u*cosine[j]+v*sine[j])*ds[i];
end;
end;
end;
{*** Back diagonal correction of coupling coefficient matrix ***}
procedure back_diagonal_correction;
var i j : integer;
begin
for i := 1 to m do
begin
sum := 0.0;
for j := 1 to m do if j o ( m + l - i ) then
sum := sum+coup[J,i]*ds[j];
coup[(m+l-i),i] := -sum/ds[m+l-i];
end;
end;
{*** Adjust coupling coefficient matrix for ***}
{*** prescribed bound vortex strength ***}
procedure bound_vortex_correction;
var i j : integer;
begin
for i := 1 to m do for j := 1 to m do
coup[ij] :=coup[ij]+ds[j];
end;
procedure invert_matrix;

(Same as for program 1.1)

{*** Calculate right hand side values ***}


procedure right_hand_sides;
var i : integer;
begin

511

Appendix
for i := 1 to m do rhs[i] := -Uinf*cosine[i]-Vinf*sine[i]+gamma;
end;
procedure solution;
(Same as for program 1.3)
{*** Main program ***}
begin
pi := 4.0*arctan(1.0); twopi := 2.0*pi;
inputdata;
data_preparation;
coupling_coefficients;
back_diagonal_correction;
{Add in extra equation for prescribed)
bound_vortex_correction;
{bound vortex strength)
invert_matrix;
right_hand_sides;
solution;
end.

Program 2.3
Potential flow past an aerofoil
program aerofoil(input,output);
type
vector = array [1..71] of real;
matrix = array[1..71,1..71] of real;

var
stl
k,m,te,n,ij,newcase
coup
xdata,ydata,ds,slope,sine,cosine,pivot,
rhsl,rhs2,ansl,ans2
chord,a,b,x 1 ,y 1 ,x2,y2,pi,twopi,Winf,Uinf, Vinf,
ans,Cp,gamma,gammal,gamma2,alpha
filel

: lstring(12);
: integer;
: matrix;
: vector;
: real;
:text;

{*** procedures***}
procedure inputdata;
{Real profile data points - xdata,ydata)
var n: integer,
begin
{are the end coordinates of the elements)
readln(filel,m); m := m-1; te := m div 2; {te is trailing)
for n := 1 to m+1 do
{edge point)
begin readln(filel,xdata[n],ydata[n]); end;
chord := xdata[te+l]-xdata[l];
end;
procedure input_flow_data;
begin
512

Computer programs
writeln('mainstream velocity?1); read(Winf);
writeln('angle of attack?1); readln(alpha);
alpha := alpha*pi/180.0;
Uinf := Winf*cos(alpha); Vinf := Winf*sin(alpha);
end;
procedure data_preparation;
(same as program 1.1)
procedure coupling_coefficients;
(-"
)
procedure back_diagonal_correction;
(same as program 2.2)
procedure Kutta_condition;
{Trailing edge Kutta condition}
var i j : integer;
begin
{reduce matrix by one column and one row for Kutta condition}
{First subtract column te+1 from te}
for j := te to m do for i := 1 to m do
if j>te then coup[ij] := coup[ij+l]
elsecoup[ij] := coup[ij]-coup[ij+l];
{Now subtract row te+1 from row te}
for i := te to m do for j := 1 to m do
if i>te then coupfi j ] := coup[i+l j ]
elsecoup[ij] := coup[ij]-coup[i+l j ] ;
{Now adjust right hand sides to match)
for i := te+1 to m do
begin
if i>te+l thenrhsl[i-l] :=rhsl[i]
else rhsl[i-l]
:= rhsl[i-l]-rhsl[i];
if i>te+l then rhs2[i-l] := rhs2[i]
else rhs2[i-l]
:= rhs2[i-l]-rhs2[i];
end;
m := m-1; {Matrix size is now reduced by one)
end;
procedure invert_matrix;

(same as program 1.1)

procedure right_hand_sides; {*** calculate right hand side values ***}


var i : integer;
begin
for i := 1 to m do rhsl[i] := -cosine[i]; rhs2[i] := -sine[i];
end;
{*** Multiply rhs column vectors by inverted matrix ***}
procedure unit_solutions;
var
exact: real; i,j: integer;
begin
for i := 1 to m do
begin
ansl[i]:=0.0;ans2[i]:=0.0;
513

Appendix
forj := 1 torn do
begin
ansl[i] :=ansl[i]+coup[ij]*rhsl[j];
ans2[i] := ans2[i]+coup[i j]*rhs2[j];
end;
end;
m := m+1;
{Revert to original matrix size)
{Shift lower surface values along the array one place}
for i := te to m-2 do
begin
ansl[m-i+te] := ansl[m-i+te-l]; ans2[m-i+te] := ans2[m-i+te-l];
end;
{replace lower trailing edge value by minus t.e. value}
ansl[te+l] := -ansl[te]; ans2[te+l] := -ans2[te];
{Sum up unit bound vortex strengths}
gammal := 0.0; gamma2:= 0.0;
for i := 1 to m do gammal := gammal+ansl[i]*ds[i];
for i := 1 to m do gamma2 := gamma2+ans2[i]*ds[i];
end;
procedure solution;
var i: integer;
begin
writeln; writeln(fElement 7Cp':9); writeln;
for i := 1 to m do
begin
ans := Uinf*ansl[i]+Vinf*ans2[i]; Cp := 1.0-sqr(ans/Winf);
writeln(i:4,Cp:16:6);
end;
gamma := Uinf*gammal+Vinf*gamma2;
writeln; writeln('Predicted circulation =',gamma:10:6);
writeln; writeln('Cl =\(2.0*gamma)/(Winf*chord):10:6);
end;
{** main program ***}
begin
pi := 4.0*arctan(1.0); twopi := 2.0*pi;
{*** open and name aerofoil profile input data file ***}
writelnCName of data input file?'); readln(stl);
assign(filel,stl); reset(filel);
inputdata;
data_preparation;
coupling_coefficients;
right_hand_sides;
back_diagonal_correction;
Kutta_condition;
invert_matrix;
unit_solutions;
514

Computer programs
newcase:= 1;
while newcase > 0 do
begin
input_flow_data; solution; writeln;
writelnCFor new flow data enter 1 otherwise 0f); readln(newcase);
end;
end.

Program 2.4
To calculate the potential flow through a turbomachine cascade
program bladerow(input,output);
type
vector = array[1..71] of real;
matrix = array [1..71,1..71] of real;
var
stl
: lstring(12);
k,m,te,n,ij,newcase
: integer;
coup
: matrix;
xdata,ydata,ds,slope,sine,cosine,pivot,
rhs 1 ,rhs2,ans 1 ,ans2
: vector;
chord,pitch,stagger,a,b,x 1 ,y 1 ,x2,y2,pi,twopi,
Winf,Uinf,Vmf,Wl,ans,Cp,gamma,gammal,gamma2,
kl Jc2,betal ,beta2,betainf
: real;
filel
: text;
{** procedures***}
procedure inputdata;
var n : integer,
begin
readln(filel,m); m := m-1; te := m div 2;
{Trailing edge)
for n := 1 to m+1 do
{location te}
begin readln(filel,xdata[n],ydata[n]); end;
chord := sqrt(sqr(xdata[te+l]-xdata[l])+sqr(ydata[te+l]-ydata[l]));
writeln(Pitch/chord ratio?'); readln(pitch); pitch := pitch*chord;
writeln('S tagger angle?1); readln(stagger);
stagger := stagger*pi/180.0;
end;
procedure input_flow_data;
begin
writeln('Inlet velocity?1); read(Wl);
writeln('Inlet angle?'); readln(betal); betal := betal*pi/180.0;
end;
procedure data_preparation;

(same as program 1.1)


515

Appendix
procedure coupling_coefficients;
var
r,u,v,a,bjc,sinh,cosh,e : real; i,j: integer,
begin
for i := 1 to m do begin
sine[i] := sin(stagger+slope[i]);
cosinefi] := cos(stagger+slope[i]);
end;
{Self inducing coupling coefficients)
coup[l,l] := -0.5-(slope[2]-slope[m]-2.0*pi)/(8.0*pi);
coup[m,m] := -0.5-(slope[l]-slope[m-l]-2.0*pi)/(8.0*pi);
fori : = 2 t o m - l do
coup[i,i] := -0.5-(slope[i+l]-slope[i-l])/(8.0*pi);
for i := 1 to m do for j := i to m do if j o i then
if pitch/chord > 30.0 then
{Revert to single aerofoil for)
begin
{very wide blade spacing)
r := sqr(xdata[j]-xdata[i])+sqr(ydata[j]-ydata[i]);
u := (ydata[j]-ydata[i])/(r*twopi);
v := -(xdata[j]-xdata[i])/(r*twopi);
coup[j,i] := (u*cosine[j]+v*sine[j])*ds[i];
coupfij] := -(u*cosine[i]+v*sine[i])*ds[j];
end else
{Cascade coupling coefficients)
begin
a := ((xdata[i]-xdata[j])*cos(stagger)
-(ydata[i]-ydata[j])*sin(stagger))*twopi/pitch;
b := ((xdata[i]-xdata[j])*sin(stagger)
+(ydata[i]-ydata[j])*cos(stagger))*twopi/pitch;
e := exp(a); sinh := 0.5*(e-1.0/e); cosh := 0.5*(e+1.0/e);
k := 0.5y^itch/(cosh-cos(b));
coup[j,i] := (sinh*sine[j]-sin(b)*cosine[j])*k*ds[i];
coup[i j ] := (-sinh*sine[i]+sin(b)*cosine[i])*k*ds[j];
end;
end;
procedure back_diagonal_correction;
procedure Kutta_condition
procedure invert_matrix;
procedure rightjiand_sides;
procedure unit_solutions;

(Same as program
(Same as program
(Same as program
(Same as program
(Same as program

2.2)
2.3)
1.1)
2.3)
2.3)

procedure solution;
var i : integer;
begin
kl := (1.0-gamma2/2.0/pitch)/(1.0+gamma2/2.0^)itch;
k2 := gammal/pitch/(1.0+gamma2/2.0/pitch);
beta2 := arctan(kl*sin(betal)/cos(betal)-k2);
betainf := arctan(0.5*(sin(betal)/cos(betal)+sin(beta2)/cos(beta2)));
516

Computer programs
Winf := Wl*cos(betal)/cos(betainO;
Uinf := Winf*cos(betainf); Vinf := Winf*sin(betainf);
writeln; writeln('Element 7Cp':9);
writeln;
for i := 1 to m do
begin
ans := Uinf*ansl[i]+Vinf*ans2[i];
Cp:=1.0-sqr(ans/Wl);
writeln(i:4,Cp:16:6);
end;
gamma := Uinf*gammal+Vinf*gamma2;
writeln; writeln('Predicted circulation =f,gamma: 10:6);
writeln; writeln('Cl =\(2.0*gamma)/(Winf*chord):10:6);
writeln; writeln('Beta2 =!,beta2*180/pi:10:6);
end;
{*** main program ***}
begin
pi := 4.0*arctan(1.0); twopi := 2.0*pi;
{*** open and name blade profile input data file ***}
writelnCName of data input file?1); readln(stl);
assign(filel,stl); reset(filel);
inputdata;
data_preparation;
coupling_coefficients;
right_hand_sides;
back_diagonal_correction;
Kutta_condition;
invert_matrix;
unit_solutions;
newcase:= 1;
while newcase > 0 do
begin
input_flow_data; solution; writeln;
writelnCFor new flow data enter 1 otherwise 01); readln(newcase);
end;
end.

517

Anda mungkin juga menyukai