Вы находитесь на странице: 1из 28

Computational fluid Dyanamics

WS 2013/14

Lehrestuhl fur Strmungsmechanik

Professor:
Prof. Dr. Ing. Ernst von Lavante
Assistant Professor:
Diplom. Ing. Harun Kaya
M. Sc. Saeid Shirazian

Page

Submitted by: Kamlesh Ghael


Matriculation No.: 3009666
Course: Computational Fluid Dynamics

Computational fluid Dyanamics

WS 2013/14

Projekt -Numerische Simulation


Project1
Given is a two-dimensional flow field consisting of a channel. The flow is assumed to be
frictionless, incompressible, steady and irrotational. Consequently, I is the so called
potential flow, described by either a potential function or a stream function . In both
cases the flow field is obtained by solving the elliptic Laplace equation for either one of
these functions. The inflow velocity is 10 m/s, the working fluid is water at a density of
=1000 kg/m.
1. The stream function should be found by solving the Laplace equation at discrete
points. The resulting function (x,y) should be stored in a separate file.
2. The corresponding velocity components u and v should be computed and stored for
each point, u = d/dy, v = -d/dx.
3. The resulting pressure distribution, given by the Bernoulli equation, should be found.
In particular, the pressure coefficient cp should be calculated for each point.
4. The results should be displayed using a proper graphics representation. In particular,
following pictures should be produced:
a. Stream lines
b. Contours of the stream function
c. Contours of the velocity magnitude
d. Contours of the pressure coefficient
As an option, the velocity vectors and/or the contours of the single velocity components
can be given.

Page

The results should be summerized in a report. This report should include: The above
discribed pictures, a complete listing of your program, a short discussion of your results
(1/2 to 1 page) and a comparison with the corresponding results obtained using the
commercial product StarCD-CCM+. Few words and some screen shots are better than
long treatese over several pages, too.

Computational fluid Dyanamics

WS 2013/14

RESULTS OBTAINED FROM STARCCM+ SOFTWARE


Following Inputs are given:
Inlet Velocity 1(for small hole): [0.0, -7.0, 0.0] m/s
Inlet Velocity 2(for big hole): [10.0, 0.0, 0.0] m/s
Base size: 0.05 m
Mesh Condtions: Surface remesher, polyhedral mesher, prism layer mesher
Physical Conditions: gradient, two dimensional, steady, segregated flow, Inviscid, liquid
(water with density 1000.0 kg/m), constant density.

1) Mesh File

Page

2) Mesh File Zoomed

Computational fluid Dyanamics

WS 2013/14

3) Residuals

4) Pressure coefficient

Page

5) Stream Function

Computational fluid Dyanamics

WS 2013/14

6) Velocity Magnitude

Page

7) Velocity Vector

Computational fluid Dyanamics

WS 2013/14

MATLAB CODE
The basic idea of this problem is to separate the domain into many points and then find
the values of the steam function at those points.
Few formulas has to defined before starting programming:
1. Stream function is defined from the discretization equation, an explicit form of the
equation can be obtained:
l
l 1
l
l
l
i , j 0.25(i 1, j i , j 1 i 1, j 1 i , j 1 )
With l is the current number of the iteration.
2. Pressure Coeficient is defined from Bernoullis equation:
Po + (0.5*den*Vin1^2) + Po + (0.5*den*Vin2^2) = P + (0.5*den*Vot1^2) + P +
(0.5*den*Vot2^2)
From this Cp is defined as:
= {

2 2
12 + 22
}
=
{1

}
0.5 (12 + 22 )
12 + 22

clear all;
close all;
Xm=200;
Ym=50;
dH=0.1;
dx=0.1; dy=0.1;
crit=1*10^(-6);
error=1;
G = zeros(Xm+1,Ym+1);
Uin1=7;
Uin2=10;
Uot=8.5;

% Length Of The Channel


% Height Of The Channel
% Spatial Increment

% Error
% Inlet velocity

uy=zeros(Xm+1,Ym); vx=zeros(Xm+1,Ym);
V=zeros(Xm+1,Ym);cp=zeros(Xm+1,Ym);
G(:,Ym+1) = 5;
% Inlet Section
for i = 1:41
G(i,Ym)= 0;
end

Page

for i = 52:Xm+1
G(i,Ym)= 0;
end

for i = 42:51
G(i,Ym+1) = (i-1)*Uin1/Xm;
end

Computational fluid Dyanamics

WS 2013/14

for j = 2:Ym+1
G(1,j) = (j-1)*Uin2/Ym;
end
% Outlet Section
for i = 1:51
G(i,1)= 0;
end
for i = 52:101
G(i,31)= 0;
end
for i = 102:151
G(i,1)= 0;
end
for i = 152:161
G(i,1) = (i-1)*Uot/Xm;
end
for i = 162:Xm+1
G(i,1)= 0;
end
for j= 2:31
G(51,j)= 0;
G(101,j)= 0;
End
for j= 2:Ym+1
G(Xm+1,j) = (j-1)*Uot/Ym;
end
i = (1:Xm+1);
j = (1:Ym+1);

for j = 2:Ym

Page

while error >=crit


G1=G;
for j = 2:Ym
for i = 2:50
G(i,j) = 0.25*(G(i-1,j)+G(i+1,j)+G(i,j-1)+G(i,j+1));
end;
end;
E1 = abs((G(i,j)-G1(i,j))/G(i,j));
for j = 32:Ym
for i = 51:101
G(i,j) = 0.25*(G(i-1,j)+G(i+1,j)+G(i,j-1)+G(i,j+1));
end;
end;
E2 = abs((G(i,j)-G1(i,j))/G(i,j));
for j = 2:Ym
for i = 102:Xm
G(i,j) = 0.25*(G(i-1,j)+G(i+1,j)+G(i,j-1)+G(i,j+1));
end;
end;
E3 = abs((G(i,j)-G1(i,j))/G(i,j));
error = (E1+E2+E3)/3;
end;

%while error >= crit

Computational fluid Dyanamics

WS 2013/14

for i = 2:51
uy(i,j)=(G(i,j+1)-G(i,j-1))/(2*dy);
vx(i,j)=(G(i+1,j)-G(i-1,j))/(2*dx);
V(i,j)=(uy(i,j)^2+vx(i,j)^2)^0.5;
cp(i,j)=1-V(i,j)^2/(Uin1^2+Uin2^2);
end;
end;
for j = 32:Ym
for i = 51:101
uy(i,j)=(G(i,j+1)-G(i,j-1))/(2*dy);
vx(i,j)=(G(i+1,j)-G(i-1,j))/(2*dx);
V(i,j)=(uy(i,j)^2+vx(i,j)^2)^0.5;
cp(i,j)=1-V(i,j)^2/(Uin1^2+Uin2^2);
end;
end;
for j = 2:Ym
for i = 102:Xm
uy(i,j)=(G(i,j+1)-G(i,j-1))/(2*dy);
vx(i,j)=(G(i+1,j)-G(i-1,j))/(2*dx);
V(i,j)=(uy(i,j)^2+vx(i,j)^2)^0.5;
cp(i,j)=1-V(i,j)^2/(Uin1^2+Uin2^2);
end;
end;

Page

figure(1);pic = figure(1);
set(pic,'Name','Mesh of streamlines');
mesh(G);
colorbar;pause(1)
figure(2);pic = figure(2);
set(pic,'Name','Plot of streamlines);
plot(G');
colorbar;pause(1)
figure(3);pic = figure(3);
set(pic,'Name','Contourlines of Stream Functions);
contour(G',100);
figure(4);pic = figure(4);
set(pic,'Name','velocity 3D');
mesh(V);
figure(3);pic = figure(5);
set(pic,'Name','Contourlines of Velocity');
contour(V',400);
figure(3);pic = figure(6);
set(pic,'Name','Contourlines of Coefficeint of pressure');
contour(cp',600);
colorbar;pause(1)

Computational fluid Dyanamics

WS 2013/14

RESULTS OBTAINED FROM MATLAB


1) Stream Function Contours

Page

2) Stream Lines

Computational fluid Dyanamics

WS 2013/14

3) Velocity Contours

Page

10

4) Velocity 3D

Computational fluid Dyanamics

WS 2013/14

5) Pressure Coefficient contour

Page

11

6) Contours of Velocity

Computational fluid Dyanamics

WS 2013/14

CONCLUSION
The results of Matlab are different than StarCCM+ because of the following points as
Numerical code depends on Laplace equation while StarCCM+ solves problem with
Navier-Stocks and many other equations and using more different numerical methods.
Then we are using different grid size in both tools. Matlab using bigger grid size as it cant
solve smaller grids as it takes a lot of time in solving it.
Also we have to derive and derive few equations and also make some assumptions before
programming which result in not much accuracy.
However graph generated by Matlab representing flow seems similar behavior with
StarCCM+ graphs which reflects that Matlab graphs are also acceptable if not much
accuracy is needed.

Page

12

When the flow go over the step the properties of the fluid flow was changed, the velocity
of the flow is increased and became maximum in this region. The sudden sharp
contraction of duct area is the cause of increasing the velocity at the region of step, and
also vortex formation, which causes losses over duct. Velocity magnitude show the
change in flow direction and it also show the observable changes in the region. Pressure
is maximum at the edge in star CCM+ near the outlet.

Computational fluid Dyanamics

WS 2013/14

Project 2
Gegeben ist das erste Stokessche Problem, in dem die instationre Strmung zwischen
zwei horizontal angeordneten Platten zu berechnen ist. Zur Zeit t=0 (Anfang) sind beide
Platten im Ruhestand. Die Platten sind 6 m lang und der Abstand (Hhe) betrgt
h=0,01m. Das Fluid zwischen den Platten ist Glyzerin, = 1400,8 kg/m, = 0,9554 Pa
s. Die obere Platte wird nachfolgend pltzlich auf Geschwindigkeit U = 0,7 m/s
beschleunigt und bleibt fr alle Zeiten t>0 auf dieser Geschwindigkeit. Es soll die
Verteilung der axialen Geschwindigkeit u (in x Richtung entlang der Platten) als Funktion
von Zeit und Raum, u(t,y) ermittelt werden. Es wurde gezeigt, dass die dimensionslose
Darstellung des Problems u(t, ) wesentlich gnstiger ist und empfohlen wird.
1. Es soll die parabolische Gleichung, die die axiale Geschwindigkeitskomponente u
beschreibt, numerisch gelst werden. Hierzu soll die explizite Methode wie auch die
implizite Methode verwendet werden. Die Ergebnisse fr jede einzelne Zeit sollen in eine
Datei geschrieben werden, um spter graphisch nachbearbeitet zu werden.
2. Die Ergebniss sollen in einem Bericht diskutiert werden. Insbesondere sollen die
explizite und die implizite Methode verglichen werden. Die jeweiligen Ergebnisse u(t, )
sollen fr verschiedene dimensionslose Zeite geplotet werden.

Page

13

3. Die eigene numerische Lsung soll mit der Lsung des Star CD CCM+ verglichen
werden. Insbesondere soll die Genauigkeit und Qualitt der Ergebnisse diskutiert werden.

Computational fluid Dyanamics

WS 2013/14

MATLAB CODE (Explicit Method)


''STOKE'S PROBLEM''
clear all;
close all;
Suw=0.7;
Ht=0.01;
DV=0.9554;
D=1400.8;
vx=50;
T=40000;
dt=0.0001;

%
%
%
%
%
%
%

top moving wall speed


Total Height
Dynamic Viscosity
Density of Glycerin
interim space
total time
time step

Re=Suw*D*Ht/(DV);
cric=0.5*Re*(1/vx)^2;

% Reynolds Number
% Stability Condition

v=zeros((T+1),vx);
v(:,vx)=1;

% Matrix Size

if(dt<cric)
disp('solution is stable')
for t=1:T
for i=2:(vx-1)
v(t+1,i)=v(t,i)+((dt*(v(t,i+1)-(2*v(t,i))+v(t,i-1)))/(Re*(1/vx)^2));
end
end
figure(1);pic = figure(1);
set(pic,'Name','Stoke''s Problem: Explicit Method');mesh(v);
colorbar;pause(1)
figure(2);pic1 = figure(2);
set(pic1,'Name','Stoke''s Problem: Explicit Method');
plot(v(480,:),'r');
hold on
plot(v(1700,:),'g');
hold on
plot(v(7780,:),'b');
hold on
plot(v(15300,:),'y');
hold on
plot(v(32870,:),'m');
legend('480','1700','7780','15300','32870')
else
disp('solution is unstable')

Page

14

end

Computational fluid Dyanamics

WS 2013/14

RESULTS OBTAINED FROM MATLAB


1) Velocity Distribution:

Page

15

2) Velocity 3D:

Computational fluid Dyanamics

WS 2013/14

MATLAB CODE (Implicit Method)


clear all;
close all;
Ht=0.01;
T=4000;
Suw=0.7;
vx=100;
dT=0.00010;
D=1400.8;
DV=0.9554;
Re = D*Suw*Ht/DV;
G=zeros((T+1),(vx+1));
G(:,vx+1)=1;

% Total Height
% Total Time
% Speed of upper plate
% Time Step
% Density of Glycerin
% Dynamic Viscosity
% Reynolds Number
% Matrix Size

x=zeros(1,99);x(1,:)=2*dT/(Re*(1/vx)^2)+1;
y=zeros(1,98);y(1,:)=-dT/(Re*(1/vx)^2);
z=zeros(1,98);z(1,:)=-dT/(Re*(1/vx)^2);
A=diag(x,0)+diag(y,1)+diag(z,-1);
K=zeros(99,1);
K(99,1)=dT/(Re*(1/vx)^2);
Y =(A^-1)*K;
for t=1:T,
for i=1:99,
G(t+1,i+1)=Y(i,1);
end
K=Y;
K(99,1)=K(99,1)+dT/(Re*(1/vx)^2);
Y=(A^-1)*K;
end
figure(1);pic = figure(1);colorbar;
set(pic,'Name','Stoke''s Problem: Implicit Method');
mesh(G);colorbar;
pause(1)

Page

16

figure(2);pic1 = figure(2);
set(pic1,'Name','Stoke''s Problem: Implicit Method');
plot(G(70,:),'r');
hold on
plot(G(244,:),'g');
hold on
plot(G(917,:),'b');
hold on
plot(G(1980,:),'y');
hold on
plot(G(3870,:),'m');
legend('70','244','917','1980','3870')

Computational fluid Dyanamics

WS 2013/14

RESULTS OBTAINED FROM MATLAB


1) Velocity Distribution

Page

17

2) Velocity 3D

Computational fluid Dyanamics

WS 2013/14

RESULTS OBTAINED FROM STARCCM+ SOFTWARE


1) Residual

2) XY Plot

Page

18

3) Scalar Velocity Magnitude:

Computational fluid Dyanamics

WS 2013/14

4) Scalar Velocity Magnitude (Zoomed):

5) Vector Velocity (Zoomed):

Page

19

6) Vector Velocity:

Computational fluid Dyanamics

WS 2013/14

CONCLUSION
From the graphical results displayed by the simulation in star-CCM+ and Matlab, it is
observed that the matlab results are approximate and Star-CCM+ results are more
accurate. Reason behind this difference is that, Star CCM+ is comercially developed
software for flow simulation and uses complex equations of Naviers stokes, while in
Matlab we have to input various parameters by making approximations and it solves
Eulers Equation.
From Star CCM+ graph we can check how fluid will flow and how its properties changes
as its upper most layers moves with the velocity of upper plate and how velocity is
distributed along its depth.
It can be seen that explicit method programming is relatively easy to set up as compared
to implicit method . Base on the graphs we saw that the implicit method have a better
flexibility compared to explicit method. The time step of explicit method is bound in a
region where dt<(1/2*Re*dH2) to ensure the flow is stable.

Page

20

Therefore in explicit results the run time is more than the implicit solution hence the
implicit solution needs less number of iterations than explicit one, to achieve the
termination criteria.

Computational fluid Dyanamics

WS 2013/14

Aufgabe C:
Die Ausbreitung einer schwachen Druckwelle wird nherungsweise durch die
Wellengleichung 1.-Ordnung beschrieben:
pt + c px = 0

(1)

wobei c>0 eine konstante Ausbreitungsgeschwindigkeit ist, die in diesem Fall die
Schallgeschwindigkeit ist, c0 = 310 m/s. Das Problem ist durch die Anfangsverteilung des
Druckes definiert,

1. Das Problem soll in geeigneter Form dimensionslos gemacht werden. Die


Bezugsdichte kann als

2. Es soll die hyperbolische Gleichung (1), die den Druck als Funktion von Zeit und Raum,
p(x,t), beschreibt, numerisch gelst werden. Hierzu soll eine explizite upwind Methode
verwendet werden. Die Ergebnisse fr verschiedene Zeiten (mindestens 4) sollen in eine
Datei geschrieben werden, um spter graphisch nachbearbeitet zu werden.
3. Die eigene numerische Lsung soll mit der Lsung des Star CD CCM+ verglichen
werden. Insbesondere soll die Genauigkeit und Qualitt der Ergebnisse diskutiert werden.
Achtung: es mssen dimensionsbehaftete Daten verglichen werden, da CCM+ nur mit
Dimensionen funktioniert.
Insbesondere sollen anhand von Abbildungen folgende Fragen beantwortet werden:
a) Welche Methode ist dissipativer?
b) Wie ist die Dispersion der beiden Methoden (Art und Gre)
4. Der Teil 2. soll fr den nichtlinearen (aber realistischeren) Fall c = c(p) wiederholt
werden. Dabei
-

Page

21

5.Alle Ergebnisse sollen mit der (bekannten) analytischen Lsung verglichen werden.

Computational fluid Dyanamics

WS 2013/14

MATLAB CODE
clear all;
close all;
L=10;
C = 310;
dt=0.0001;
dl = 0.1;
T = 0.1;
TL = 0:dl:L;

%
%
%
%
%

Total Length
velocity of sound
Time step
Spatial increment
Total Time

Page

22

% Number of Iterations
Iteration=T/dt;
K=zeros(Iteration+1,101);
pO = 7000;
p = pO*(1 + cos(2*(pi)*(dl/L)));
% Boundary Conditions (Velocity)
V1=p;
V101=0;
K(:,1)=V1;
K(1,101)=V101;
t=1;
while t<=Iteration, t;
for i = 2:101,
K(:,1)=V1;
K(t+1,i) = K(t,i) - ((C*dt)/dl)*(K(t,i)-K(t,i-1));
end
t=t+1;
end
figure(1);pic = figure(1);
set(pic,'Name','wave propagation');
mesh (K)
colorbar;pause(1)
figure(2);pic=figure(2);
set(pic,'Name','wave propagation');
plot(K')
colorbar;pause(1)

Computational fluid Dyanamics

WS 2013/14

RESULTS OBTAINED FROM MATLAB


1) Hyperbolic Partial Differential Equation

Page

23

2) Pressure distribution in 2D

Computational fluid Dyanamics

WS 2013/14

RESULTS OBTAINED FROM STARCCM+ SOFTWARE

Steady flow at 7000 Pa pressure:


1) Mesh

Page

24

2) Residuals

Computational fluid Dyanamics

WS 2013/14

3) Velocity

4) Velocity Vector

Page

25

5) Pressure Coefficient

Computational fluid Dyanamics

WS 2013/14

6) XY Plot

Unsteady flow at 70,000 Pa pressure:


1) Geometry

Page

26

2) Residual:

Computational fluid Dyanamics

WS 2013/14

3) Velocity:

4) Pressure Coefficient:

27

Vectors:

Page

5)

Computational fluid Dyanamics

WS 2013/14

CONCLUSION:
As can be seen from the graphs that the method of Matlab is dissipative, because of its inability to
exhibit oscillatory behaviour.
The graph obtain from STAR-CCM+ is however dispersive because of its oscillatory behaviour of
second order.

Page

28

The results obtain exhibit truncation error of first order as compared to STAR-CCM+ of second
order. The Matlab however offer to the user a fast alternative of obtaining quick solution as can be
seen from the graph obtained. STAR-CCM+ requires more iteration before being able to reach a
certain target value.

Вам также может понравиться