Professional Documents
Culture Documents
Chapter 07-Chapter 06 300999
Chapter 07-Chapter 06 300999
Chapter 6 Navier-Stokes equations
vN
Boundary (W)
uW Boundary (E)
uE
y
vS
x
Boundary (S)
Figure 1 Control Volume
If the time step Δt and the spatial step Δx and Δy are infinitely small, Equation (3) becomes the
partial differential equation
u v
0 (4)
t x y
Equation (4) is the continuity equation. If the density of the fluid is constant, i.e. the flow is
incompressible flow, Equation (4) becomes
u v
0 (5)
x y
Water flows are treated as incompressible flow in most of engineering applications. If an air
flow has a velocity much smaller than tha sound speed, the fluid is also usually treated as
incompressible flow.
1
Computational Fluid Dynamics Chapter 06
plates follows a linear function of y as shown in Figure 2, and the shear stress between two layers of
fluid (and between the plates on the fluid) can be calculated by
u
(6)
y
where
o μ = dynamic viscosity of the fluid;
o τ = the shear stress.
o ν= μ/ρ is defined as the kenimatic viscosity
If the flow is Newtonian flow, the shear stress and the gradient of the velocity satisfies Equation
(6). Most engineering flows (such as water flow, air flow, etc) can be treated as Newtonian flow.
Stokes extended Newton's idea from simple 1-D flows (where only one component of velocity is
present) to multidimensional flows. Now we consider the control volume shown in Figure 3. The
fluid element may experience a strain rate both due to gradients such as ∂u/∂y as well as ∂v/∂x. He
developed the following relations, collectively known as Stokes relations. For two-dimensional flows,
the Stokes relations are:
u u v
xx 2 (7)
x x y
v u v
yy 2 (8)
y x y
u v
xy yx (9)
y x
2
(10)
3
pN
τyy,N
τyx,N
vN τxy,E
pW uw uE τxx,E pE
τxx,W
y vS
τxy,W
τyx, S
x τyy, S
pS
Figure 3 Stresses on a control volume
2
Computational Fluid Dynamics Chapter 06
According to the Newton’s second law, the change rate of the momentum of a fluid mass equals
to the force. Consider within a small time step, the forces in the x-direction on the control volume in
Figure 3 include:
o Pressure force on the west boundary: pW y (11)
o Pressure force on the east boundary: p E y (12)
o Normal viscous force on the west boundary: xx,W y (13)
o Normal viscous force on the east boundary: xx, E y (14)
o Tangential viscous force on the south boundary: yx, S x (15)
o Tangential viscous force on the east boundary: yx, N x (16)
The momentum in the x-direction that enters the control volume include
o Through the west boundary: uW2 y (17)
o Through the east boundary: u y
2
E (18)
o Through the south boundary: uv 2 x (19)
o Through the north boundary: uv 2 x (20)
The change rate of the momentum of a fluid mass equals to the force plus the momentum
flowing into the control volume. The change of the momentum is
The momentum change rate within the control volume is
( u )
xy (21)
t
The x-momentum flowing into the control volume is (based on Equation (17) – (20))
uW2 uE2 y uvS uvN x (22)
The total x-force on the control volume is (based on Equations (11) – (16))
pW PE y xx, E xx,W y yx, N yx, E x (23)
The change rate of the x-momentum of a fluid mass equals to the force plus the momentum
flowing into the control volume. Then we can get the following equation
( u )
xy u E2 uW2 y uv N uv S x
t (24)
p E PW y xx , E xx ,W y yx , N yx , E x
Dividing the above equation by ΔxΔt, we get
( u ) u E2 uW2 uv N uv S p P xx,W yx, N yx, E
E W xx , E (25)
t x y x x y
If the control volume (Δx and Δy) is infinitesimal, the above equation becomes
( u ) ( u 2 ) ( uv) p yx
xx (26)
t x y x x y
The above equation is the momentum equation in the x-direction. Similarly, we can get the
momentum equation in the y-direction:
( v) ( uv) ( v 2 ) p xy yy
(27)
t x y y x y
Equation (4), (26) and (27) are the two-dimensional (2D) Navier-Stokes Equations for the
compressible flow. If the flow is incompressible, i.e. the density is a constant, the 2D Navier-Stokes
equation becomes
3
Computational Fluid Dynamics Chapter 06
u v
0 (28)
x y
u u u 1 p 2u 2u
u v 2 2 (29)
t x y x x y
v v v 1 p 2v 2v
u v 2 2 (30)
t x y y x y
Equations (28) – (30) are the 2D Navier-Stokes equations for incompressible flows. If the flow
is three-dimensional, the three-dimensional (3D) Navier-Stokes equaitons need be solved. The
imcompressible 3D NS equations are:
u v w
0 (31)
x y z
u u u u 1 p 2u 2u 2u
u v w 2 2 2 (32)
t x y z x x y z
v v v v 1 p 2v 2v 2v
u v w 2 2 2 (33)
t x y z y x y z
w w w w 1 p 2w 2w 2w
u v w 2 2 2 (34)
t x y z z x y z
where x, y and z are the three-dimensional coordinates, u, v, and w are the velocities in the x-, y- and
z-directions, respectively.
In addition to the continuity equation of mass and the momentum equation, energy equation is
also a part of Navier-Stokes equations. The energy equation is expressed as
E uE vE wE T T T
K K K
t x y z x x y y z z
up vp wp
x y z (35)
u xx u yx u zx v xy v yy v zy w xz w yz w zz
x y z x y z x y z
f x u f y v f z w
where
o E=e+V2/2 is the total energy,
o e is the internal energy,
o V is the magnitude of the fluid velocity,
o τ is the shear stress
o fx, fy and fz are the external force on unit mass of the fluid in the x-, y- and z-direcitons,
respectively.
Energy equation can be simplified in different ways. If the fluid is imcompressible, the energy
equations can be written as
T T T T 2T 2T 2T
c p u v w K 2 2 2 (36)
t x y z x y z
4
Computational Fluid Dynamics Chapter 06
where T is the temperature, cp is the specific heat and is the energy dissipation function
representing the work done against viscous forces:
u 2 v 2 w 2 v u 2 w v 2 u w 2
2 (37)
x y z x y y z z x
6.2 FDM solution of the Two-dimensional incompressible Navier-Stokes equations
Now we consider an example of two-dimensional water flow past a square cylinder as shown in
Figure 4. The size of the square cylinder is 0.01 m × 0.01 m. A coordinate system is defined with its
origin at the center of the square cylinder and its x-axis pointing the flow direction. The velocity in
the x- and y-directions are u and v, respectively. A computational domain of 0.1 m × 0.06 m is used.
When a flow passes a two-dimensional structure shown in Figure 4, vortices will generate
downstream the structure and form a dynamic wake flow. The wake flow is called vortex shedding
flow because vortices are generated from the cylinder.
Wake vortices
flow
x
0.01 m
0.06 m
0.01 m
0.025 m
0.1 m
The flow defined in Figure 4 will be simulated by solving the NS equations using the FDM
method in this section. A computational grid system is used to simulate the flow as shown in Figure
5. The whole fluid domain is divided into grids in the x- and y-directions. The grid numbers in the x-
and y–directions are defined as i and j, respectively. The total grid numbers in the x- and y-directions
are nx and ny, respectively. The position of each point on the grid system can be identified by a pair
of numbers of i,j.
The problem is a transient flow problem, i.e. the flow is not steady.
The initial conditions are:
The velocity and pressure is zero in the whole fluid domain.
The boundary conditions are:
Velocity:
The velocity at the inlet (left) boundary is given as u=uin.
The gradient of the velocity at the right boundary in the streamwise direction is zero. The
simplest formulae is u nx , j u nx 1, j and vnx , j vnx 1, j .
5
Computational Fluid Dynamics Chapter 06
On the top and bottom boundaries, the velocity v is zero and the gradient of the velocity u in
the y-direction is zero. In the FDM, we can use v 0 and ui ,1 u i , 2 and ui ,ny ui ,ny 1 .
On the cylinder surface, the non-slip boundary condition is used, i.e. u 0 and v 0 .
Pressure:
On the outlet (right) boundary, the pressure is given to be zero.
On the inlet boundary, the gradient of the pressure in the x-direciton is zero, i.e. p1, j p2, j .
On the top and bottom boundaries, the gradient of the pressure in the y-direction is zero, i.e.
pi ,1 pi , 2 and pi ,ny pi ,ny 1 .
On the cylinder surface, the gradient of the pressure in the normal direction of the surface is
zero.
j2
j1
j =1,2, …
i=1,2, …
i1 i2
Figure 5 The computational grid system for solving the flow problem defined in Figure 4.
6
Computational Fluid Dynamics Chapter 06
n uin, j uin1, j n vin, j vin1, j
u u
i , j
n , if u n
i, j 0 v
n ui , j , if uin, j 0
u x and u x (33)
x i , j n ui 1, j ui , j u n i 1, j vi , j , if u n 0
n n n n
x v
ui , j , if uin, j 0 i, j
x i , j x
i, j
vi , j , if vi , j 0
n
vi , j , if vin, j 0
y y
The FDM formulae for the diffusion terms are
n
2u 2u u n 2uin, j uin1, j uin, j 1 2uin, j uin, j 1
2 2 i 1, j
(35)
x y i , j
2 2
x y
n
2v 2v vin1, j 2vin, j vin1, j vin, j 1 2vin, j vin, j 1
2 2
(36)
x y i, j x 2
y 2
Then we solve the following pressure Possion equation to find out the pressure at the next step:
2 p n 1 2 p n 1 u n1 v n1
(37)
x 2 y 2 t x y
The final velocity is calculated by considering the pressure terms:
uin, j 1 ui,nj1 1 p n 1
(38)
t x
vin, j 1 vi,nj1 1 p n1
(39)
t y
Eq. (33) is derived based on the continuity equation. If we differentiate Eq. (38) and (39) with
respective to x and y, respectively, and add them together, we have
uin, j 1 vin, j 1 ui,nj1 vi,nj1 2 n 1 2 n 1
t p p (40)
x
y x y x 2
y
2
Because the velocity at the next step (n+1 step) must satisfy the continuity equation (Eq. (28)),
the first term of Eq. (40) must be zero. Then Eq. (40) becomes Eq. (37), the pressure Poisson
equation. The method of solving the pressure Poisson equation (Eq. (37)) is the same as the one for
solving the Laplace equation in Chapter 5.
The procedure for solving the NS equations are summarized as follows.
1. Solve Eq. (31) and (32) to find out the provisional velocities.
2. Solve Eq. (37) to find out the pressure in the next time step.
3. Solve Eq. (38) and (39) to find out the final velocities in the next step.
4. Go back to step one for the calculation in the next time step.
Appendix is the MATLAB program for solving the flow problem defined in Figure 4. Figure 6
is the results of the MATLAB program, where the vortices in the wake of the cylinder is successfully
predicted.
In this section, the 2D NS equations are solved by a very basic simple FDM method. This
method could be improved in the following ways. (1) The accuracy can be improved by using a
higher order upwind method. (2) The stability of the model will be improved by using the implicit
method. (3) The accuracy can be improved by using a high order temporal discretization method.
7
Computational Fluid Dynamics Chapter 06
0.07
0.06
0.05
0.04
0.03
0.02
0.01
-0.01
0 0.02 0.04 0.06 0.08 0.1 0.12
Figure 6 Velocity vectors calculated from the MATLAB program in the Appendix
Appendix
The MATLAB program for solving the NS equation (the problem is defined in Figure 4)
% A matlab program for solving the 2D flow past a square cylinder
% in a rectangular fluid domain (see the sketch below)
%
8
Computational Fluid Dynamics Chapter 06
clear;
nu = 1.3e-6;
rho= 1000;
length = 0.1;
width = 0.06;
nx = 101;
ny = 61;
dx = length/(nx-1);
dy = width/(ny-1);
i1 = 26;
i2 = 36;
j1 = 26;
j2 = 36;
u_in = 0.1;
dt = dx/u_in/4;
ndt = 20000;
u(1:nx,1:ny) = 0;
v(1:nx,1:ny) = 0;
p(1:nx,1:ny) = 0;
u0(1:nx,1:ny) = 0;
v0(1:nx,1:ny) = 0;
bp(1:nx,1:ny) = 0;
x1 = 0:dx:(nx-1)*dx;
y1 = 0:dy:(ny-1)*dy;
[xg,yg]=meshgrid(x1,y1);
for n=1:ndt
disp(n);
% --------------------- predicted velocity -----------------------
u0(1:nx,1:ny) = u(1:nx,1:ny);
v0(1:nx,1:ny) = v(1:nx,1:ny);
for i=1:nx
for j=1:ny
if(i==1)
u(i,j) = u_in;
v(i,j) = 0;
continue
elseif(i==nx)
u(i,j) = u(i-1,j);
v(i,j) = v(i-1,j);
continue;
elseif(i>=i1 && i<=i2 && j>=j1 && j<=j2)
u(i,j) = 0;
v(i,j) = 0;
continue
elseif(j==1)
u(i,j) = u(i,j+1);
v(i,j) = 0;
elseif(j==ny)
u(i,j) = u(i,j-1);
v(i,j) = 0;
else
u_new = u(i,j);
v_new = v(i,j);
% convection in the x-direction
if(u0(i,j)>0)
u_new = u_new-dt*u0(i,j)*(u0(i,j)-u0(i-1,j))/dx;
v_new = v_new-dt*u0(i,j)*(v0(i,j)-v0(i-1,j))/dx;
else
u_new = u_new-dt*u0(i,j)*(u0(i+1,j)-u0(i,j))/dx;
v_new = v_new-dt*u0(i,j)*(v0(i+1,j)-v0(i,j))/dx;
9
Computational Fluid Dynamics Chapter 06
end
% convection in the y-direction
if(v0(i,j)>0)
u_new = u_new-dt*v0(i,j)*(u0(i,j)-u0(i,j-1))/dy;
v_new = v_new-dt*v0(i,j)*(v0(i,j)-v0(i,j-1))/dy;
else
u_new = u_new-dt*v0(i,j)*(u0(i,j+1)-u0(i,j))/dy;
v_new = v_new-dt*v0(i,j)*(v0(i,j+1)-v0(i,j))/dy;
end
% diffusion
u_new=u_new+nu*dt/(dx*dx)*(u0(i-1,j)-2*u0(i,j)+u0(i+1,j));
v_new=v_new+nu*dt/(dx*dx)*(v0(i-1,j)-2*v0(i,j)+v0(i+1,j));
u(i,j) = u_new;
v(i,j) = v_new;
end
end
end
% ---------------------------- pressure ---------------------------
for i=1:nx
for j=1:ny
if(i==nx) % out_boundary
bp(i,j) =0;
continue;
elseif(j==1) % side boundary (bottom)
bp(i,j) = 0;
continue;
elseif(j==ny) % side boundary (top)
bp(i,j) = 0;
continue;
elseif(i>i1 && i<i2 && j>j1 && j<j2) % in the box
bp(i,j) = 0;
continue;
else
bp(i,j) = 0;
if (i==1)
bp(i,j) = bp(i,j)-rho/dt*(u(i+1,j)-u(i,j))/dx;
elseif(i==i1&&j>=j1&&j<=j2) % left boundary of box
bp(i,j) = bp(i,j)-rho/dt*(u(i,j)-u(i-1,j))/dx;
elseif(i==i2&&j>=j1&&j<=j2) % right boundary of box
bp(i,j) = bp(i,j)-rho/dt*(u(i+1,j)-u(i,j))/dx;
else
bp(i,j) = bp(i,j)-rho/dt*(u(i+1,j)-u(i-1,j))/(dx*2);
end
if(j==j1&&i>=i1&&i<=i2) % bottom boundary of box
bp(i,j) = bp(i,j)-rho/dt*(v(i,j)-v(i,j-1))/dy;
elseif(j==j2&&i>=i1&&i<=i2) % top boundary of box
bp(i,j) = bp(i,j)-rho/dt*(v(i,j+1)-v(i,j))/dy;
else
bp(i,j) = bp(i,j)-rho/dt*(v(i,j+1)-v(i,j-1))/(dy*2);
end
end
end
end
for k=1:20
erp = 0;
for i=1:nx
for j=1:ny
if(i==nx) % out_boundary
10
Computational Fluid Dynamics Chapter 06
p(i,j) =0;
continue;
elseif(i==1) % inlet
p(i,j) = p(i+1,j);
continue;
elseif(j==1) % side boundary (bottom)
p(i,j) = p(i,j+1);
continue;
elseif(j==ny) % side boundary (top)
p(i,j) = p(i,j-1);
continue;
elseif(i>i1 && i<i2 && j>j1 && j<j2) % in the box
p(i,j) = 0;
continue;
else
b = bp(i,j);
if(i==i1&&j>=j1&&j<=j2) % left boundary of box
b = b+2*p(i-1,j)/(dx*dx);
elseif(i==i2&&j>=j1&&j<=j2) % right boundary of box
b = b+2*p(i+1,j)/(dx*dx);
else
b = b+(p(i-1,j)+p(i+1,j))/(dx*dx);
end
if(j==j1&&i>=i1&&i<=i2) % bottom boundary of box
b = b+2*p(i,j-1)/(dy*dy);
elseif(j==j2&&i>=i1&&i<=i2) % top boundary of box
b = b+2*p(i,j+1)/(dy*dy);
else
b = b+(p(i,j-1)+p(i,j+1))/(dy*dy);
end
p_new = b / (2/(dx*dx)+2/(dy*dy));
erp = erp+abs(p_new-p(i,j));
p(i,j) = p_new;
end
end
end
erp = erp/(nx*ny);
end
% ------------------------ correct velocity ----------------------
for i=1:nx
for j=1:ny
if(i==1)
u(i,j) = u_in;
v(i,j) = 0;
continue
elseif(i==nx)
u(i,j) = u(i-1,j);
v(i,j) = v(i-1,j);
continue;
elseif(i>=i1 && i<=i2 && j>=j1 && j<=j2)
u(i,j) = 0;
v(i,j) = 0;
continue
elseif(j==1)
u(i,j) = u(i,j+1);
v(i,j) = 0;
elseif(j==ny)
u(i,j) = u(i,j-1);
v(i,j) = 0;
else
11
Computational Fluid Dynamics Chapter 06
u(i,j) = u(i,j) -dt/rho*(p(i+1,j)-p(i-1,j))/(dx*2);
v(i,j) = v(i,j) -dt/rho*(p(i,j+1)-p(i,j-1))/(dy*2);
end
end
end
% to draw the velocity vectors after every 10 steps (animation)
if(mod(n,10)==0)
disp (erp);
ut = transpose(u);
vt = transpose(v);
quiver(xg,yg,ut,vt,4,'k');
pause(0.1);
end
end
u = transpose(u);
v = transpose(v);
p = transpose(p);
contour(xg,yg,p,'ShowText','on');
figure(02);
quiver(xg,yg,u,v,4,'k'); % draw velocity vectors
12