2DNavierStokesCavityFlow

Embed Size (px)

Citation preview

  • 8/2/2019 2DNavierStokesCavityFlow

    1/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

    (1)u =y

    y, v = -

    y

    x

    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

    (2)v = u Hx, yL i + v Hx, yL jIn two-dimensional flow the vorticity is given by

    (3)w = w Hx, yL kwhere k is the unit vector directed along the z axis. The equation of continuity for the flow is given by

    (4) v = 0

    or in component form

    (5)u

    x+v

    y= 0

    From the definition of the stream function y we see that the equation of continuity is satisfied identically

    (6)2y

    x y-

    2 y

    y x= 0

    The vorticity w of the flow is defined in terms of velocity field by

    (7)w = v =v

    x-u

    yk

    Substituting in for the stream function gives

    (8)w = v = -2 y

    x2-2 y

    y2k

    Thus we have

    (9)2 y = -w

  • 8/2/2019 2DNavierStokesCavityFlow

    2/8

    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

    (10)rv

    t+ v v = - p + m 2v + rg

    The conservative body force rg can be written as the gradient of a scalar potential f:

    (11) f = - r g

    We can eliminate the pressure p from the momentum equations by taking the curl of Eqn. (10). Thus

    (12)r v

    t+ Hv vL = - p + m 2 v - f

    Now noting that the curl of the gradient of a scalar is zero

    (13) f = 0, p = 0

    we get

    (14)rw

    t+ Hv vL = m 2w

    Using indicial notation one can readily show that for w = wHx, yL k, the vorticity equation (14) becomes

    (15)w

    t+y

    y

    w

    x-y

    x

    w

    y= n

    2w

    where n = m r is the kinematic viscosity. Thus for steady two-dimensional flow in a rectangular cavity we need to solve thefollowing system of equations

    (16)

    2

    y = - w

    2

    w =1

    n:y

    y

    w

    x-y

    x

    w

    y>

    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

    (17)v n = 0

    where n is the outward directed unit normal to the walls of the cavity. Thus we have

    (18)

    BC1 : v Hx, 0L = 0BC2 : u Ha, yL = 0BC3 : v Hx, bL = 0BC4 : u H0, yL = 0

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

    wall:

    2 2DNavierStokesCavityFlow.nb

  • 8/2/2019 2DNavierStokesCavityFlow

    3/8

    (19)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

    (20)

    BC5 : u Hx, 0L = 0BC6 : v Ha, yL = 0BC7 : u

    Hx, b

    L= V

    BC8 : v H0, yL = 0

    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

    (21)x`

    =x

    a, y

    `=

    y

    b, y

    `=

    y

    V a, w

    `=

    w a

    V, g =

    a

    b, Re =

    V a

    n

    The dimensionless form of the governing equations becomes

    (22)2 y

    x`2

    + g22 y

    y`2

    = - w`

    (23)2w

    `

    x`2

    + g22w

    `

    y`2

    = Re g :y

    `

    y`

    w`

    x`

    -y

    `

    x`

    w`

    y`>

    defined on the domain 0 x`

    1, 0 y`

    1. The boundary conditions are defined by Eq. (22)

    (24)

    w` Ix`, 0M = - g2

    2 y

    `

    y`2

    y`

    =0

    , w` Ix`, 1M = - g2

    2 y

    `

    y`2

    y`

    =1

    w I0, yM = - 2

    y

    `

    x`2

    x`

    =0

    , w I1, yM = - 2

    y

    `

    x`2

    x`

    =1

    y` Ix`, 0M = 0, y` Ix`, 1M = 0, y` I0, y`M = 0, y` I1, y`M = 0

    In the analysis that follows we will drop the ^ notation for dimensionless variables.

    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

    (25)

    2 y

    x2+ g

    22 y

    y2= - w

    2 w

    x2+ g

    22 w

    y2= Re g :

    y

    y

    w

    x-y

    x

    w

    y>

    2DNavierStokesCavityFlow.nb 3

  • 8/2/2019 2DNavierStokesCavityFlow

    4/8

    Let the x domain of the cavity hasNx nodes starting from i = 1, 2, ..., Nx , and the y-domain haveNy 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

    (26)yi+1,j - 2 yi,j + yi-1,j

    h2

    + g2yi,j+1 - 2 yi,j + yi,j-1

    h2

    = - w Ixi, yjM

    Likewise we discretize the vorticity transport equation at (ith, jth) node:

    (27)wi+1,j - 2 wi,j + wi-1,j

    h2+ g

    2wi,j+1 - 2 wi,j + wi,j-1

    h2= f Iwi,j, yi,jM

    where

    (28)f Iwi,j, yi,jM = Re g :yi,j+1 - yi,j-1

    2 h

    wi+1,j - wi-1,j

    2 h-

    yi+1,j - yi-1,j

    2 h

    wi,j+1 - wi,j-1

    2 h>

    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

    (29)1

    2 I1 + g2MIyi+1,j + yi-1,j + g2 Iyi,j+1 + yi,j-1MM + h2 w Ixi, yjM - yij = 0

    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

    (30)Ri,j =1

    2 I1 + g2MIyi+1,j + yi-1,j + g2 Iyi,j+1 + yi,j-1MM + h2 w Ixi, yjM - yi,j

    In a smilar way we define the residual for Eq. 26

    (31)

    Li,j =1

    2 I1 + g2MIwi+1,j + wi-1,j + g2 Iwi,j+1 + wi,j-1MM

    -Re

    4g 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,

    Thus if the values ofwi,j and yi,j are exact on the nodes spanned by the residual functions, then

    (32)Ri,j = 0, Li,j = 0

    We then construct the following iterative equations for the k+ 1 iterative

    (33)

    yi,jk+1 = F

    k Hy, wL yi,jk + p Ri,jk

    wi,jk+1

    = Gk Hy, wL wi,jk + p Li,jk

    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 yp, wp we have

    4 2DNavierStokesCavityFlow.nb

  • 8/2/2019 2DNavierStokesCavityFlow

    5/8

    yp = FIyp, wpMwp = G Iyp, wpM

    at any grid node as RIyp, wpM = 0, and LIyp, wpM = 0.

    All that remains is to determine the values ofy and w on the boundary of the cavity.

    The BCs for y are

    (35)

    BC1 : yi,1 = 0, i = 1, Nx

    BC2 : yNx,j = 0, j = 1, , Ny

    BC3 : yi,Ny = 0, i = 1, , Nx

    BC4 : y1,j = 0, 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)

    (36)w1,j = -1

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

    This expression involves the fictitious node y0,j. We can eliminate this term using the no-slip boundary condition on the side

    wall, viz.,

    (37)v = -y

    x= 0 at x = 0

    Using central differences we can write this condition as

    (38)-y

    x 1,j= 0 -

    y2,j - y0,j

    2 h= 0

    This formula can be used to eliminate y0,jthat appears in Eqn.(33) and noting that y1,j = y1,j+1 = y1,j-1 = 0 we get

    (39)BC5 : w1,j = -2

    h2Iy2,jM, j = 2, , Ny - 1

    In a similar manner we get the following expression for the stream function on the other walls of the cavity

    (40)w Ixi, yjM = -yi+1,j - 2 yi,j + yi-1,j

    h2+ g

    2yi,j+1 - 2 yi,j + yi,j-1

    h2

    (41)

    BC6 : wi,1 = -2

    h2

    g2 Iyi,2M, i = 1, 2, , Nx

    BC7 : wNx,j = -2

    h2IyNx-1,jM, j = 2, , Ny - 1

    BC8 : wi,Ny = -2 g2

    h2yi,Ny-1 +

    h

    g, i = 1, 2, , Nx

    Note that BC8 is applied on the moving lid, and we get the extra term as the tangential velocity is non-zero.

    2DNavierStokesCavityFlow.nb 5

  • 8/2/2019 2DNavierStokesCavityFlow

    6/8

    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 parametersNx & 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 Li,jk

    . The iteration is halted if max Li,jk

    < e@iD . The calculations can be speeded up by reducing the number of nodes

    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

  • 8/2/2019 2DNavierStokesCavityFlow

    7/8

    In[58]:= t@1D = TimingBForBk = 1, Max@Abs@Table@L@i, jD, 8i, 2, Nx - 1

  • 8/2/2019 2DNavierStokesCavityFlow

    8/8

    In[62]:= eplt1 = ListContourPlot@VortData1,Contours 8- 4, - 2, - 0.5, - 0.1, 0.2, 0.3, 0.5, 1