Title: Direct Numerical Simulations of Multiphase Flows
1A Finite Difference Code for the Navier-Stokes
Equations in Vorticity/Stream Function Formulation
Instructor Hong G. Im University of Michigan
Fall 2005
Lecture notes were prepared jointly with Prof.
Gretar Tryggvason, Department of Mechanical
Engineering, Worcester Polytechnic Institute.
2Objectives
Develop an understanding of the steps involved in
solving the Navier-Stokes equations using a
numerical method Write a simple code to solve
the driven cavity problem using the
Navier-Stokes equations in vorticity form
3Outline
- The Driven Cavity Problem
- The Navier-Stokes Equations in Vorticity/Stream
Function form - Boundary Conditions
- Finite Difference Approximations to the
Derivatives - The Grid
- Finite Difference Approximation of the
Vorticity/Streamfunction equations - Finite Difference Approximation of the Boundary
Conditions - Iterative Solution of the Elliptic Equation
- The Code
- Results
- Convergence Under Grid Refinement
4The Driven Cavity Problem
Moving wall
Stationary walls
5Nondimensional N-S Equation
Incompressible N-S Equation in 2-D
6The vorticity/stream function equations
The Vorticity Equation
7The vorticity/stream function equations
The Stream Function Equation
Define the stream function
which automatically satisfies the
incompressibility conditions
by substituting
8The vorticity/stream function equations
Substituting
into the definition of the vorticity
yields
9The vorticity/stream function equations
The Navier-Stokes equations in vorticity-stream
function form are
Advection/diffusion equation
Elliptic equation
10Boundary Conditions for the Stream Function
At the right and the left boundary
11Boundary Conditions for the Stream Function
At the top and the bottom boundary
12Boundary Conditions for the Stream Function
Since the boundaries meet, the constant must be
the same on all boundaries
13Boundary Conditions for the Vorticity
The normal velocity is zero since the stream
function is a constant on the wall, but the zero
tangential velocity must be enforced
At the right and left boundary
At the bottom boundary
At the top boundary
14Boundary Conditions for the Vorticity
The wall vorticity must be found from the
streamfunction. The stream function is constant
on the walls.
At the right and the left boundary
Similarly, at the top and the bottom boundary
15Summary of Boundary Conditions
16Finite Difference Approximations
To compute an approximate solution numerically,
the continuum equations must be discretized.
There are a few different ways to do this, but we
will use FINITE DIFFERENCE approximations here.
17Discretizing the Domain
Uniform mesh (hconstant)
jNY
Stored at each grid point
j2
j1
i1
i2
iNX
18Finite Difference Approximations
When using FINITE DIFFERENCE approximations, the
values of f are stored at discrete points and the
derivatives of the function are approximated
using a Taylor series Start by expressing the
value of f(xh) and f(x-h) in terms of f(x)
f(x-h) f(x) f(xh)
h
h
19Finite Difference Approximations
Finite difference approximations
2nd order in space, 1st order in time
20Finite Difference Approximations
For a two-dimensional flow discretize the
variables on a two-dimensional grid
j1 j j-1
i -1 i i1
21Finite Difference Approximations
Laplacian
22Finite Difference Approximations
Using these approximations, the vorticity
equation becomes
23Finite Difference Approximations
The vorticity at the new time is given by
24Finite Difference Approximations
The stream function equation is
25Discretized Domain
Discretize the domain
jny
for
j2
j1
i1
i2
inx
26Discrete Boundary Condition
j3 j2 j1
i -1 i i1
27Discrete Boundary Condition
Using
This becomes
Solving for the wall vorticity
28Discrete Boundary Condition
At the bottom wall (j1)
Similarly, at the top wall (jny)
At the left wall (i1)
Fill the blank
At the right wall (inx)
Fill the blank
29Solving the Stream Function Equation
Solving the elliptic equation
Rewrite as
j1
j
j-1
i
i1
i-1
30Solving the Stream Function Equation
If the grid points are done in order, half of the
points have already been updated
j1
j
j-1
i
i1
i-1
Successive Over Relaxation (SOR)
31Time Step Control
Limitations on the time step
32Solution Algorithm
for i1MaxIterations for i2nx-1 for
j2ny-1 s(i,j)SOR for the stream
function end end end
v(i,j)
for i2nx-1 for j2ny-1
rhs(i,j)Advectiondiffusion end end
v(i,j)v(i,j)dtrhs(i,j)
33MATLAB Code
34Solution Fields
nx17, ny17, dt 0.005, Re 10, Uwall 1.0
35Solution Fields
nx17, ny17, dt 0.005, Re 10, Uwall 1.0
36Accuracy by Resolution
Stream Function at t 1.2
37Accuracy by Resolution
Vorticity at t 1.2