Sie sind auf Seite 1von 8

2-D Navier Stokes Solution Lid-Driven Cavity Flow

BGHiggins UCDavis May_ 08

Introduction
These notes are based on the work of Jenny Hwang who studied cavity flow as part off her ECH198 project. We will examine the solution of the 2-D Navier Stokes equations for an incompressible fluid using the vorticity transport equation. The particular problem we will examine is flow in a rectangular cavity, driven by the motion of the lid. The velocity components of the flow are given in terms of the stream function y u= y y , v= y x (1)

Here u is the component of velocity in the x-coordinate direction defined by the unit vector i and v is the component of velocity in the y-coordinate direction defined by the unit vector j. Thus v = u Hx, yL i + v Hx, yL j In two-dimensional flow the vorticity is given by w = w Hx, yL k where k is the unit vector directed along the z axis. The equation of continuity for the flow is given by v = 0 or in component form u x + v y =0 (5) (4) (3) (2)

From the definition of the stream function y we see that the equation of continuity is satisfied identically 2 y x y 2 y y x =0 (6)

The vorticity w of the flow is defined in terms of velocity field by w = v = Substituting in for the stream function gives w = v = Thus we have 2 y = - w (9) 2 y x2 2 y y2 k (8) v x u y k (7)

Thus if the vorticity is known everywhere in the flow the stream function(and hence the velocity components) is determined by solving a Poisson equation. Of course, at the outset we do not know the vorticity but it is possible to find an additional equation for the vorticity by writing the momentum equations in terms of vorticity. For an incompressible Newtonian fluid the balance of linear momentum gives

2DNavierStokesCavityFlow.nb

Thus if the vorticity is known everywhere in the flow the stream function(and hence the velocity components) is determined by solving a Poisson equation. Of course, at the outset we do not know the vorticity but it is possible to find an additional equation for the vorticity by writing the momentum equations in terms of vorticity. For an incompressible Newtonian fluid the balance of linear momentum gives r v t + v v = - p + m 2 v + rg (10)

The conservative body force rg can be written as the gradient of a scalar potential f: f = -r g We can eliminate the pressure p from the momentum equations by taking the curl of Eqn. (10). Thus r v t + Hv vL = - p + m 2 v - f (12) (11)

Now noting that the curl of the gradient of a scalar is zero f = 0, p = 0 we get r w t + Hv vL = m 2 w (14) (13)

Using indicial notation one can readily show that for w = wHx, yL k, the vorticity equation (14) becomes w t + y w y x y w x y = n 2 w (15)

where n = m r is the kinematic viscosity. Thus for steady two-dimensional flow in a rectangular cavity we need to solve the following system of equations 2 y = - w 2 w = 1 n y w y x y w x y (16) >

These equations must be solved subject to the boundary conditions on y and w on the walls of the cavity. The cavity is oriented such that the bottom wall of the cavity is aligned along the positive x- axis. We locate the origin of the x-y coordinate system at the left bottom corner so that the left wall of the cavity is aligned with the y-axis. Let the length of the cavity by a and the height of the cavity be b. Thus the corners of the cavity are located at H0, 0L, Ha, 0L, Ha, bL, H0, bL The non-penetration condition (the walls of the cavity are impervious) mean that vn = 0 where n is the outward directed unit normal to the walls of the cavity. Thus we have BC1 : BC2 : BC3 : BC4 : v Hx, u Ha, v Hx, u H0, 0L yL bL yL = = = = 0 0 0 0 (17)

(18)

The no-slip boundary condition implies that the tangential velocity along the walls of the cavity be equal to the velocity of the wall:

2DNavierStokesCavityFlow.nb

v t = Vc where t is a unit vector tangent to the wall of the cavity and Vc is the motion of the walls. Thus we have BC5 : BC6 : BC7 : BC8 : u Hx, v Ha, u Hx, v H0, 0L yL bL yL = = = = 0 0 V 0

(19)

(20)

Dimensionless Form
It is convenient numerically to make the equations for y and w dimensionless. This means we need to introduce the appropriate scalings for the dimensionless variables. If b is the height of the cavity and a is the width of the cavity, then the appropriate dimensionless variables are y a Va ` x ` y ` ` wa x= , y= , y= , w= , g = , Re = a b Va V b n The dimensionless form of the governing equations becomes ` 2 y `2 x ` 2 w +g
2

(21)

` 2 y `2 y

` = -w

(22)

` ` ` ` y w y w +g = Re g : ` ` - ` ` > `2 `2 y x x y x y
2

` 2 w

(23)

` ` defined on the domain 0 x 1, 0 y 1. The boundary conditions are defined by Eq. (22) ` ` 2 y 2 y ` ` ` ` 2 2 w Ix, 0M = - g , w Ix, 1M = - g `2 `2 y `=0 y `=1 y y ` ` 2 y 2 y ` ` ` ` w I0, yM = , w I1, yM = `2 `2 x `=0 x `=1 x x ` ` ` ` ` ` ` ` y Ix, 0M = 0, y Ix, 1M = 0, y I0, yM = 0, y I1, yM = 0 In the analysis that follows we will drop the ^ notation for dimensionless variables. (24)

Finite Difference Formulation


In this section we plan to develop an iterative solution for solving the steady 2-D Navier Stokes equations. Our method is based on the procedure used by Burggraft (see Reference) with a minor change in choice of dimensionless variables. Our first step is to discretize the dimensionless form of the stream function and vorticity equations 2 y x2 w x2
2

+ g2

2 y y2 w y2
2

= -w (25)

+ g2

= Re g :

y w y x

y w x y

>

Let the x domain of the cavity has Nx nodes starting from i = 1, 2, ..., Nx , and the y-domain have Ny nodes starting from j = 1, 2, , Ny . The nodes of our mesh are separated by a distance h. The discretization of the Poisson equation at (ith , jth ) node is

2DNavierStokesCavityFlow.nb

Let the x domain of the cavity has Nx nodes starting from i = 1, 2, ..., Nx , and the y-domain have Ny nodes starting from j = 1, 2, , Ny . The nodes of our mesh are separated by a distance h. The discretization of the Poisson equation at (ith , jth ) node is yi+1,j - 2 yi,j + yi-1,j h2 + g2 yi,j+1 - 2 yi,j + yi,j-1 h2 = - w Ixi , yj M (26)

Likewise we discretize the vorticity transport equation at (ith , jth ) node: wi+1,j - 2 wi,j + wi-1,j h2 where f Iwi,j , yi,j M = Re g : yi,j+1 - yi,j-1 wi+1,j - wi-1,j 2h 2h yi+1,j - yi-1,j wi,j+1 - wi,j-1 2h 2h > (28) + g2 wi,j+1 - 2 wi,j + wi,j-1 h2 = f Iwi,j , yi,j M (27)

We apply these equations to the internal nodes of the cavity, i.e., nodes starting from i = 2, 3, ..., Nx - 1 and j = 2, 3, , Ny - 1. Note because we have used central difference formulas, the boundary nodes of the cavity are included by these formulas. Let us write Eq. (26) as 1 2 I1 + g2 M Iyi+1,j + yi-1,j + g2 Iyi,j+1 + yi,j-1 MM + h2 w Ixi , yj M - yij = 0 (29)

Thus if we have the exact values for the nodal values, then the LHS of Eq. 29 is identically zero Hence let us define the LHS of Eq. 29 as the residual at the i, node Ri,j = 1 2 I1 + g2 M Iyi+1,j + yi-1,j + g2 Iyi,j+1 + yi,j-1 MM + h2 w Ixi , yj M - yi,j (30)

In a smilar way we define the residual for Eq. 26 Li,j = 1 2 I1 + g2 M Iwi+1,j + wi-1,j + g2 Iwi,j+1 + wi,j-1 MM Re 4 (31) g 9yi,j+1 - yi,j-1 wi+1,j - wi-1,j - yi+1,j - yi-1,j wi,j+1 - wi,j-1 = - wi,j

Thus if the values of wi, j and yi, j are exact on the nodes spanned by the residual functions, then Ri,j = 0, Li,j = 0 We then construct the following iterative equations for the k + 1 iterative yk+1 = F k Hy, wL yk + p Rk i,j i,j i,j (33) wk+1 i,j = G Hy, wL
k

(32)

wk i,j

+p

k Li,j

where p is a relaxation parameter that lies in the range 0 < p 1. The actual value will depend on Re and has to be determined by numerical experimentation. Equation (33) represents a fixed point iteration scheme. At the fixed point y p , w p we have (34)

2DNavierStokesCavityFlow.nb

yp = F Iyp , wp M wp = G Iyp , wp M at any grid node as RIy p , w p M = 0, and LIy p , w p M = 0. All that remains is to determine the values of y and w on the boundary of the cavity. The BCs for y are BC1 : BC2 : BC3 : BC4 : yi,1 = 0, yNx ,j = 0, yi,Ny = 0, y1,j = 0, i = 1, Nx j = 1, , Ny (35) i = 1, , Nx j = 1, , Ny

The boundary conditions for w require additional effort. From Eqn. (22) we have along the left wall of the cavity Ii = 1, j = 1, 2, , Ny ) w1,j = 1 h
2

Iy2,j - 2 y1,j + y0,j + g2 Iy1,j+1 - 2 y1,j + y1,j-1 MM

(36)

This expression involves the fictitious node y0, j . We can eliminate this term using the no-slip boundary condition on the side wall, viz., v= y x = 0 at x = 0 (37)

Using central differences we can write this condition as y x


1,j

=0 -

y2,j - y0,j 2h

=0

(38)

This formula can be used to eliminate y0, j that appears in Eqn.(33) and noting that y1, j = y1, j+1 = y1, j-1 = 0 we get BC5 : w1,j = 2 h2 Iy2,j M, j = 2, , Ny - 1 (39)

In a similar manner we get the following expression for the stream function on the other walls of the cavity w Ixi , yj M = yi+1,j - 2 yi,j + yi-1,j h2 wi,1 = 2 h
2

+ g2

yi,j+1 - 2 yi,j + yi,j-1 h2 i = 1, 2, , Nx j = 2, , Ny - 1 h g , i = 1, 2, , Nx

(40)

BC6 : BC7 : BC8 :

g2 Iyi,2 M, 2 h2 IyNx -1,j M, yi,Ny -1 +

wNx ,j = wi,Ny = -

(41)

2 g2 h2

Note that BC8 is applied on the moving lid, and we get the extra term as the tangential velocity is non-zero. An alternative way to specify the vorticity on the bounday is to make use of one-sided finite difference formulas that do not involve the use of fictitious nodes. See Ref 3 for additional details. (34)

2DNavierStokesCavityFlow.nb

An alternative way to specify the vorticity on the bounday is to make use of one-sided finite difference formulas that do not involve the use of fictitious nodes. See Ref 3 for additional details. This completes the finite difference formulation.

Mathematica Implementation
We start by defining the mesh size, and grid spacing. Note we have selected the mesh spacing to be the same in the x and y directions. The parameters Nx & Ny denote the mesh size in the x and y coordinate directions. As our initial guess for w and y we assume that w=0, and y=0 at all the interior nodes of the cavity. The Reynolds Number for these calculations was set at Re=200. The aspect ratio of the cavity is 1, which means a = 1, b = 1, and g = 1. Next, we define a residual template for the finite difference formula defined on the domain defined by Eqn.(28). The Dirichlet boundary conditions for y and the BCs for w on the walls of the cavity are generated as a list. First, we set the value of maximum allowable residual value. We use a set of nested For loops to execute the iteration algorithm given by Eq.(29). At each step of the iteration we determine the maximum value of Lk j . The iteration is halted if max Lk j < e@iD . The calculations can be speeded up by reducing the number of nodes i, i, and increasing the maximum allowable residual at a node point. However, by reducing the residual we sacrifice accuracy. We wrap the For loops with function Timing to document how much time it takes Mathematica to run through the loops.

Grid Parameters
In[43]:=

a = 1; b = 1; Nx = 41; Ny = 41; Re = 200; p = 1.0; g = 1.; h = a HNx - 1L N; InitialvorticityDist = Table@w@i, jD = 0, 8i, 2, Nx - 1<, 8j, 2, Ny - 1<D Flatten; InitialSFDist = Table@y@i, jD = 0, 8i, 2, Nx - 1<, 8j, 2, Ny - 1<D Flatten;

Finite Difference Equations


In[47]:=

R@i_, j_D :=

1 2 I1 + g2 M

Iy@i + 1, jD + y@i - 1, jD + g2 Hy@i, j - 1D + y@i, j + 1DL + h2 w@i, jDM - y@i, jD

L@i_, j_D := 1 Re Iw@i + 1, jD + w@i - 1, jD + g2 Hw@i, j - 1D + w@i, j + 1DLM g HHy@i, j + 1D - y@i, j - 1DL 2 4 2 I1 + g M Hw@i + 1, jD - w@i - 1, jDL - Hy@i + 1, jD - y@i - 1, jDL Hw@i, j + 1D - w@i, j - 1DLL - w@i, jD

Boundary Conditions
In[49]:=

SFBC1 = Table@y@i, 1D = 0, 8i, 1, Nx<D; SFBC2 = Table@y@Nx, jD = 0, 8j, 2, Ny - 1<D; SFBC3 = Table@y@i, NyD = 0, 8i, 1, Nx<D; SFBC4 = Table@y@1, jD = 0, 8j, 2, Ny - 1<D; VortBC1 = TableAw@1, jD = - 2 y@2, jD h2 , 8j, 2, Ny - 1<E; VortBC2 = TableAw@i, 1D = - 2 g2 y@i, 2D h2 , 8i, 1, Nx<E; VortBC3 = TableAw@Nx, jD = - 2 y@Nx - 1, jD h2 , 8j, 2, Ny - 1<E; VortBC4 = TableBw@i, NyD = - 2 g2 y@i, Ny - 1D + h g h2 , 8i, 1, Nx<F;

Relaxation Algorithm
In[57]:=

e@1D = 0.005;

2DNavierStokesCavityFlow.nb

In[58]:=

t@1D = TimingBForBk = 1, Max@Abs@Table@L@i, jD, 8i, 2, Nx - 1<, 8j, 2, Ny - 1<DDD > e@1D, k ++, ForBi = 2, i < Nx, i ++, ForBj = 2, j < Ny, j ++, ynew@i, jD = y@i, jD + p R@i, jD; wnew@i, jD = w@i, jD + p L@i, jD; y@i, jD = ynew@i, jD; w@i, jD = wnew@i, jD; w@1, jD = - 2 y@2, jD h2 ; w@i, 1D = - 2 g2 y@i, 2D h2 ; w@Nx, jD = - 2 y@Nx - 1, jD h2 ; w@i, NyD = - 2 g2 y@i, Ny - 1D + h g h2 FFFF . 8x_, y_< x

Out[58]=

49.8643

Stream Function Field Plot


We organize the discrete values of the stream function into an array that we can plot using ListContourPLot
In[59]:= In[60]:=

SFData1 = Transpose@Partition@Flatten@Table@y@i, jD, 8i, 1, Nx<, 8j, 1, Ny<DD, NyDD; eplt1 = ListContourPlot@SFData1, Contours 8- 0.1, - 0.08, - 0.05, - 0.02, - 0.001<, ContourShading False, AspectRatio Automatic, ContourStyle Blue, DataRange 880, 1<, 80, 1<<, FrameLabel 8"x", "y"<, ImageSize 300, PlotLabel -> "Stream Function Plot"D

Stream Function Plot


1.0

0.8

0.6 y
Out[60]=

0.4

0.2

0.0 0.0 0.2 0.4 x 0.6 0.8 1.0

Vorticity Field Plot


In[61]:=

VortData1 = Transpose@Partition@Flatten@Table@w@i, jD, 8i, 1, Nx<, 8j, 1, Ny<DD, NyDD;

2DNavierStokesCavityFlow.nb

In[62]:=

eplt1 = ListContourPlot@VortData1, Contours 8- 4, - 2, - 0.5, - 0.1, 0.2, 0.3, 0.5, 1<, ContourShading False, AspectRatio Automatic, ContourStyle Blue, DataRange 880, 1<, 80, 1<<, FrameLabel 8"x", "y"<, ImageSize 300, PlotLabel -> "Vorticity Field"D

Vorticity Field
1.0

0.8

0.6 y 0.4 0.2 0.0 0.0 0.2 0.4 x 0.6 0.8 1.0

Out[62]=

Reference
The following references were helpful in putting together these notes.
1. B. Bradie, A Friendly Introduction to Numerical Analysis, Pearson/Prentice Hall 2006 2. O. R. Burggraft, The structure of steady separated flows, J. Fluid Mech. 33, 39 (1966) 3. C. Pozrikidis, Introduction to Theoretical and Computational Fluid Dynamics, Oxford University Press, 1998

Das könnte Ihnen auch gefallen