UNDERGRADUATE COMPUTATIONAL ENGINEERING AND SCIENCE

UCES

"Fluid Flow in 2D"

Course:   Methods and Analysis in UCES

Prerequisites:

  1. Math:   Calculus 3, matrices
  2. Computing:   Maple or Matlab, loops
  3. Science:   Physics

Objectives:

  1. Math:   Potential and stream function models
  2. Computing:   SOR
  3. Science:   Fluid flow models

General Information: We present two fluid flow models in 2D: flow in a saturated porous media and ideal fluids. Both these models are similar to steady state 2D heat diffusion.

Contact Person:   R. E. White, NCSU,white@math.ncsu.edu

Revision Date:   8-3-94

Copyright ©1994, R. E. White. All rights reserved.

Return to Table of Contents


3.5   Fluid Flow in 2D

3.5.1.   Introduction.

We present two fluid flow models in 2D: flow in a porous media and ideal fluids. Both these models are similar to steady state 2D heat diffusion. The porous media flow uses a potential formulation, and we apply this model to groundwater management. The ideal fluid flow model uses a stream function formulation, and we apply it to flow around an obstacle.


3.5.2.   Applied Area.

In both applications we will assume the velocity of the fluid has the form (u(x,y), v(x,y), 0). In other words, this means it is a 2D steady state fluid flow. In both problems it is useful to be able to give a mathematical description of compressibility and circulation of the fluid.

The compressibility of the fluid can be quantified by the divergence of the velocity. In 2D the divergence of (u,v) is ux + vy. This measures how much mass enters a small volume in a given unit of time. In order to understand this, consider the small thin rectangular mass with density rho and discretize ux + vy

flow in and out of vol. (dx dx T) = rho T dy (u(x+dx, y) - u(x,y)) dt
    + rho T dx (v(x, y+dy) - v(x,y)) dt.

Divide by (dx dy T)dt and let dx and dy go to zero to get

rate of change of mass per unit volume is rho (ux + vy ).

Figure: Incompressible and Irrotational 2D Fluid

A fluid with no circulation or rotation can be described by the curl of the velocity vector. In 2D the curl of (u, v) is vx - uy. Also the discrete form of this gives some insight to the meaning of this. The circulation or momentum of the loop about the volume (dx dy T) with cross sectional area A and density rho is

momemtum = rho A dy (v(x+dx, y) - v(x,y))
    -rho A dx (u(x, y+dy) - u(x,y)).

Divide by rho (A dy dx) and let dx and dy go to zero to get vx - uy = 0 for no rotation.

Application to Saturated 2D Fluid Flow in a Porous Medium. Consider a shallow saturated porous medium which is to have at least one well. We will assume the region is in the xy-plane and that the water moves towards the well in such a way that the velocity vector is in the xy-plane. At the top and bottom of the xy region we will assume there is no flow through these boundaries. However, assume there is ample supply from the left and right boundaries so that the pressure is fixed. The problem is to determine the flow rates of well(s), location of well(s) and number of wells so that there is still water to be pumped out.

If a cell does not contain a well and is in the interior, then ux + vy = 0. If there is a well in a cell, then ux + vy < 0. The motion of the fluid is governed by an empirical law which is analogous to the Fourier heat law.

Darcy's Law. (u,v) = -K(hx ,hy ) where
    h is the hydraulic head pressure and
    K is the hydraulic conductivity which is constant for saturated regions.

So, we have ux + vy = - (Khx )x - (Khy )y is zero or negative. The particular boundary conditions will be discussed in the next section.

Figure: Groundwater 2D Porous Flow

Application to Ideal 2D Fluid Flow. The figure below depicts the flow about an obstacle. Because the fluid is not compressible it must significantly increase its speed in order to pass near the obstacle. This can cause severe erosion of the nearby soil. The problem is to determine these velocities.

Ideal 2D steady state fluid flow is defined to be incompressible and irrotational. Thus, both ux + vy and vx - uy must be zero. One can use the incompressibility condition and Green's theorem (more on this later) to show that there is a stream function, psi, such that (psix , psiy ) = (-v,u). The irrotational condition gives vx - uy = -psixx - psiyy = 0. This and appropriate boundary conditions will allow us give an analysis of the fluid flow.

We call psi a stream function because the curves (x(tau), y(tau)) defined by setting psi to a constant are parallel to the velocity vectors (u,v). In order to see this, let psi(x(tau), y(tau)) = c, compute the derivative with respect to tau and use the chain rule:

Thus, (u,v) and the tangent to the curve given by psi(x(tau), y(tau)) = c must be parallel.

Figure: Ideal Fluid Flow Around an Obstacle


3.5.3.   Model.

Both models have a partial differential equation similar to that of the 2D heat diffusion model, but all three have different boundary conditions. For our present fluid flow problems, they are either a given function along part of the boundary, or they are a zero derivative for the remainder of the boundary.

Groundwater Fluid Flow.

Ideal Flow Around an Obstacle.


3.5.4.   Method.

In both problems we will use the finite difference method coupled with the SOR iterative method. For the (dx dy) cells in the interior this is exactly as in the 2D heat diffusion problem. For the portions of the boundary where the derivative is set equal zero on a half cell (dx/2 dy) or (dx dy/2), we insert some additional code inside the SOR loop. For example, consider the groundwater model where hy = 0 at y = H on the half cell (dx dy/2). The finite difference equation and corresponding line of SOR code are, respectively, u = h:

-[(u(i+1,j) - u(i,j))/dx - (u(i,j) - u(i-1,j))/dx]/dx - [( 0 ) -(u(i,j) - u(i,j-1))/dy]/(dy/2) = 0

utemp = ((u(i+1,j) + u(i-1,j))/(dx*dx) + 2*u(i,j-1)/(dy*dy))/(2/(dx*dx) + 2/(dy*dy)).

u(i,j) = (1 - omega)* u(i,j) + omega*utemp.

In the following implementations observe where the extra lines of code are that reflect these derivative boundary conditions.


3.5.5.   Implementation.

The groundwater model uses the following parameters:

L = 5,000 dx = h = 100 xw = (iw-1)h h = 100
H = 1,000 dy = h = 100 yw = (jw-1)h K = 10.

A single well with a flow rate of -1000 was used in the first numerical experiment. The first output graphs are plots of the hydraulic head pressure as a function of x and y. Note the pressure near the well has dropped from 100 to about 30. The second experiment has two wells with the same flow rate. In this case the pressures are negative near both wells. This indicates that before any steady state solution was achieved, the wells went dry!

Maple Code for Fluid Flow in 2D Saturated Porous Medium.


   Input Data:
        > with(linalg):
        > with(plots):
        > K:=10;
        > well:= -1000:
        > iw:=6:
        > jw:=16:
        > eps:=.0001: 
        > nx:= 50:
        > ny:=10:
        > H:=1000:
        > w:=1.7:

   Procedure BVP2DPOR is Defined:
        > BVP2DPOR:=proc(well,iw,jw,K,nx,ny,H,w,eps):
        > u:=matrix(nx+1,ny+1,100):
        > h:=H/ny:
        > maxit:=400:
        > tol:=eps*h*h:
        > for m from 1 to maxit do
        >     numi:=0:
        >     j:= 1:
        >     for i from 2 to nx do
        >         utemp:= evalf(( 2*u[i,j+1] 
		                  + u[i+1,j] + u[i-1,j])/4):
        >         utemp:= (1-w)*u[i,j] + w*utemp:
        >         error:= abs(utemp - u[i,j]):
        >         u[i,j]:=utemp:
        >         if error < tol then 
		     numi:=numi +1
                  fi:
        >     od:
        >     for j from 2 to ny do
        >         for i from 2 to nx do
        >             utemp:= evalf(( u[i,j-1] + u[i-1,j]
                                               + u[i+1,j] + u[i,j+1])/4):
        >             if (i=iw and j=jw) then
                         utemp:= evalf(( u[i,j-1] + u[i-1,j]
                                                  + u[i+1,j] + u[i,j+1] + well/K)/4):	
        >             fi:
        >             utemp:= (1-w)*u[i,j] + w*utemp:
        >             error:= abs(utemp - u[i,j]):
        >             u[i,j]:=utemp:
        >             if error < tol then 
                         numi:=numi +1
                      fi:
        >         od:
        >     od:
        >     j:= ny + 1:
        >     for i from 2 to nx do
        >         utemp:= evalf(( 2*u[i,j-1] 
                                  + u[i+1,j] + u[i-1,j])/4): 
        >     utemp:= (1-w)*u[i,j] + w*utemp:
        >     error:= abs(utemp - u[i,j]):
        >     u[i,j]:=utemp:
        >     if error < tol then 
                 numi:=numi +1
              fi:
        >     od:
        >     if numi = (nx-1)*(ny+1) then break fi:
        > od:
        > end:

   Output Data:
        > BVP2D(well,16,6,K,50,10,H,1.7,.0001):
        > matrixplot(u,style=wireframe,axes=boxed);
        > m; 
        27
        > numi;
        539


Figure: Well at (16,6) with Flow Rate 1000



Figure: Wells at (16,6) and (32,4) with Flow Rates of 1000

The code for the ideal flow around an obstacle has the parameters:

The obstacle is defined by the input data ip and jp which identifies the point of the obstacle. Two numerical experiments are given with different size obstacles. Note for the larger obstracle, the stream lines are closer indicating larger y derivatives of the stream function, which is the horizontal component of the velocity.

Matlab Code for Ideal Flow Around an Obstacle.


        uo = 1;
        ip = 21;
        jp =4;
        nx = 25;
        ny = 5;
        H = 10;
        w = 1.4;
        h = H/ny;
        tol =.01*h*h;
        numunk = nx*(ny-1) - (jp-1)*(nx+2-ip);
        maxit = 500;
        u = zeros(nx+1,ny+1);
        for j = 1:ny+1
            u(1,j) = uo*(j-1)*h;
        end
        for i = 2:nx+1
            u(i,ny+1) = uo*H;
        end
        for iter = 1:maxit
            numi = 0;
            for j = 2:jp
                for i = 2:ip-1
                    utemp = (u(i,j-1) + u(i-1,j) + u(i+1,j) + u(i,j+1))*.25;
                    utemp = (1. - w)*u(i,j) + w*utemp;
                    error = abs(utemp- u(i,j));
                    u(i,j) = utemp;
                    if error<tol
                       numi = numi + 1;
                    end
                end
            end
            for j = jp+1:ny
                for i = 2:nx
                    utemp = (u(i,j-1) + u(i-1,j) + u(i+1,j) + u(i,j+1))*.25;
                    utemp = (1. - w)*u(i,j) + w*utemp;
                    error = abs(utemp- u(i,j));
                    u(i,j) = utemp;
                    if error<tol
                       numi = numi + 1;
                    end
                end
                i = nx + 1;
                utemp = (u(i,j-1) + 2.*u(i-1,j) + u(i,j+1))*.25;
                utemp = (1. - w)*u(i,j) + w*utemp;
                error = abs(utemp- u(i,j));
                u(i,j) = utemp;
                if error<tol
                   numi = numi + 1;
                end
            end
        end
        if numi==numunk; 
           break;
        end
        end
   Output Data:
        Use ip = 21 and jp = 3.
        contour(u')
L = 500 dx = h = 20 xp = (ip-1)h u0 = 1
H = 100 dy = h = 20 yp = (jp-1)h.
Figure: Ideal Flow Around an Obstacle
Use ip = 21 and jp = 4. contour(u')
Figure: Ideal Flow Around a Bigger Obstacle


3.5.6.   Assessment.

Both these models have enough assumptions to rule out many real applications. For groundwater problems the soils are usually not fully saturated, and the hydraulic conductivity can be highly nonlinear and can vary with space according to the soil types. Often the soils are very heterogeneous, and the soil properties are unknown. Both models may require 3D calculations and irregular shaped domains. Fluid flow may often compressible and irrotational, for example, flow over an aircraft or weather prediction models. The good news is that the more complicated models have many subproblems which are similar to our present models from heat diffusion, fluid flow in saturated porous media and ideal fluid flow.

The existence of stream functions such that (psix , psiy ) = (-v,u) needs to be established. Recall the conclusion of Green's Theorem:

Let ux + vy = 0, let Q = u and P = -v. Then the line integral about a closed curve with this (P,Q) = (-v,u) will always be zero. This means that the line integral will be independent of the path taken between two points.

Define the stream function to be the line integral of (P,Q) = (-v,u) starting at some (x0,y0 ) and ending at (x,y). In order to show that (psix , psiy ) = (-v,u), first consider the path C1 + C1x and show psix = -v = P.

The proof that psiy = u = Q is similar, but one should use the other path C2 + C2y.

Figure: Two Paths to (x,y)

Existence of Stream Function Theorem. If u(x,y) and v(x,y) have continuous first order partial derivatives and ux + vy = 0, then there is a stream function such that

(psix , psiy ) = (-v,u)


3.5.7.   Homework.

  1. Consider the groundwater problem. Experiment with the choice of omega and eps. Observe the number of iterations required for convergence.

  2. Consider the groundwater problem. Experiment with the mesh size and convince yourself the discrete problem has converged to the continuum problem.

  3. Consider the groundwater problem. Experiment with the physical parameters K, H, L and pump rate R.

  4. Consider the groundwater problem. Experiment with the number and location of the wells.

  5. Consider the ideal fluid problem. Experiment with the choice of omega and eps. Observe the number of iterations required for convergence.

  6. Consider the ideal fluid problem. Experiment with the mesh size and convince yourself the discrete problem has converged to the continuum problem.

  7. Consider the ideal fluid problem. Experiment with the physical parameters u0 , H, L and the obstacle given by (xp, yp). Calculate the velocities at x = L.

  8. Prove the other part of the existence theorem for stream functions.