Cfdpre
Cfdpre
Cfdpre
Methods
in
Fluid
Flow
and
Heat
Transfer
z Dr. Hasan Gunes
z guneshasa@itu.edu.tr
z http://atlas.cc.itu.edu.tr/
~guneshasa
The
Scientific
Method
and
Mathematical
Modeling
The
process
of modeling
of physical
systems
in the
real
world
should
generally
follow
the
path
illustrated
schematically
in the
chart
below:
The
mathematical
formulation
of the
problem is the
reduction
of the
physical
problem to
a set of either
algebraic
or
differential
equations
subject
to
certain
assumptions.
INTRODUCTION
Physical
System
i.e. Reality
Mathematical
Model
i.e. Governing
Equations
(Fluid
Dynamics PDEs)
System
of Algebraic
Equations
(or
ODEs)
Numerical
Solution
Physical
Laws
+
Models
Discretization
Matrix
Solver
1
2
3
Analytical
Solution
Numerical
Solution
Procedure
Iterations
Physical
World
Physical
Properties
Assumptions
Mathematical
Model
(Equations)
Non
linear Linear
Linearized
Approximation
Non
linear
(Exact
or
approximate)
Nonlinear
solution
Linear
solution
(Analytical, Numerical)
Test solution
Conservation
Laws
Algebraic
eqs.
Differential
eqs.
oOrdinary
diff. eqs.
oPartial
diff.eqs.
FORTRAN
C
MATLAB
MAPLE
TECPLOT
Solution
Approaches
Three
approaches
or
methods
are
used
to
solve
a problem in fluid
mechanics
& heat
transfer
1.
Experimental
methods: capable
of being
most
realistic, experiment
required,
scaling
problems, measurement
difficulties, operating
costs.
2.
Theoretical
(analytical) methods: clean, general information
in formula
form,
usually
restricted
to
simple
geometry
&physics, usually
restricted
to
linear
problems.
3.
Numerical
(CFD) (computational) methods
(Simulation):
No restriction to linearity
Complicated physics can be treated
Time evolution of flow
Large Re flow
Disadvantages:
Truncation errors
Boundary condition problems
Computer costs
Need mathematical model for certain complex phenomena
Simulation: The Third Pillar of
Science
z Traditional scientific and engineering paradigm:
1)
Do theory
or paper design.
2)
Perform experiments
or build system.
z Limitations:
z Too difficult -- build large wind tunnels.
z Too expensive -- build a throw-away passenger jet.
z Too slow -- wait for climate or galactic evolution.
z Too dangerous -- weapons, drug design, climate
experimentation.
z Computational science paradigm:
3)
Use high performance computer systems to
simulate
the phenomenon
z Base on known physical laws and efficient numerical methods.
Some Particularly Challenging
Computations
z Science
z Global climate modeling
z Astrophysical modeling
z Biology: Genome analysis; protein folding (drug design)
z Engineering
z Crash simulation
z Semiconductor design
z Earthquake and structural modeling
z Business
z Financial and economic modeling
z Transaction processing, web services and search engines
z Defense
z Nuclear weapons -- test by simulations
z Cryptography
Economic Impact of HPC
z Airlines:
z System-wide logistics optimization systems on parallel systems.
z Savings: approx. $100 million per airline per year.
z Automotive design:
z Major automotive companies use large systems (500+ CPUs) for:
z CAD-CAM, crash testing, structural integrity and aerodynamics.
z One company has 500+ CPU parallel system.
z Semiconductor industry:
z Semiconductor firms use large systems (500+ CPUs) for
z device electronics simulation and logic validation
z A lot of Savings!!
Global Climate Modeling Problem
z Problem is to compute:
f(latitude, longitude, elevation, time)
temperature, pressure, humidity, wind velocity
z Approach:
z Discretize the domain, e.g., a measurement point every
1km
z Devise an algorithm to predict weather at time t+1 given t
Uses:
-
Predict major events,
e.g., Katrina
-
investigate
climate
change
Source: http://www.epm.ornl.gov/chammp/chammp.html
sea
surface
temperature
output
from
an eddy
resolving
ocean
model
Global Climate Modeling
Computation
z One piece is modeling the fluid flow in the atmosphere
z Solve Navier-Stokes problem
z Roughly 100 Flops per grid point with 1 minute timestep
z Computational requirements:
z To match real-time, need 5x 10
11
flops in 60 seconds = 8
Gflop/s
z Weather prediction (7 days in 24 hours) 56 Gflop/s
z Climate prediction (50 years in 30 days) 4.8 Tflop/s
z To use in policy negotiations (50 years in 12 hours) 288
Tflop/s
z To double the grid resolution, computation is at least 8x
z Current models are coarser than this
z flops: floating-point operations per second
Heart Simulation
z Problem is to compute blood flow in the heart
z Approach:
z Modeled as an elastic structure in an incompressible fluid.
z The immersed boundary method due to Peskin and
McQueen.
z 20 years of development in model
z Many applications other than the heart: blood clotting, inner
ear, paper making, embryo growth, and others
z Uses
z Current model can be used to design artificial heart valves
z Can help in understand effects of disease (leaky valves)
z Related projects look at the behavior of the heart during a heart
attack
z Ultimately: real-time clinical work
Heart Simulation Calculation
The involves solving Navier-Stokes equations
zDone on a Cray C90 -- 100x faster and 100x more
memory
zUntil recently, limited to vector machines
-
Needs more features:
-
Electrical model of the
heart, and details of
muscles, E.g.,
-
Chris Johnson
-
Andrew McCulloch
-
Lungs, circulatory
systems
Vehicle
Aerodynamics
Flow
around
a moving
truck
in a wind
tunnel.
z Need to fix the model & blow air at it.
z Floor also has to move at the air speed a difficult
task.
Vehicle
Aerodynamics
Flow
around
a moving
car in a wind
tunnel.
z Drag coefficient, lift coefficient, moment coefficient
z Pathlines/streamlines/streaklines
Turbomachinery analysis
Flow
in an inline duct fan
z Need to consider rotating fluid zone.
z Absolute & Relative velocities
CFD:
obtain
approximate
solutions
to
complex
problems
numerically.
Need
to
use
a discretization
method
which
approximates
the
differential
equations
by
a system
for
algebraic
equations, which
can then
be solved
on
a computer.
Accuracy
of numerical
solutions
quality
of discretization
Components
of a numerical
solution
method
1.
Mathematical
Model:
Set of PDEs
or
integro-differantial
eqs. and
the
corresponding
boundary
conditions.
2.
Discretization
Method:
Finite
difference
Finite
volume
Finite
element
Spectral
(element) methods
Boundary
element
PDEs
(continuous) discrete
equations
(FDE's)
3.
Coordinate
&Basic
Vector
System
4.
Numerical
Grid: grid
generation
Structured
(regular) grid
Block
structured
grid
Unstructured
grid
Discrete
locations
at which
the
variables
are
to
be calculated
are
defined
by
the
numerical
grid, or
mesh.
5.
Finite
Approximations:
approx. used
in discretization
process
is selected
e.g. Finite
difference: approximations
for
the
derivatives
at the
grid
points
need
to
be selected
The
choice
influences:
Accuracy
of approximation
Developing
the
solution
method
Coding, debugging, speed
of code
Compromise
between
simplicity
easy
of
implementation,accuracy
and
computational
efficiency
has to
be made
Second
order
methods
in general are
used.
6.
Solution
Method
Discretization
yields
a large
system
of linear/non-linear
algebraic
equations.
Linear
equations
Algebraic
equation
solvers
Non-linear
equations
iteration
scheme
used
i.e. linearize
the
equations
& resulting
linear
systems
are
solved
by
iterative
techniques.
Unsteady
flows: methods
based
on marching
in time
Steady
flows: usually
by
pseudo-time-marching
or
equivalent
iteration
scheme
7.
Convergence
criteria
(for
iterative
procedures)
Need
to
set convergence
for
the
iterative
method.
Accuracy
& efficiency
is important
Absolute
convergence:
) (
*
tolerance a a <
Relative
convergence: <
a
a a
*
FINITE DIFFERENCE METHODS
Definitions
& Remarks
Derivatives
in a given
PDE are
approximated
by
finite
difference
relations
(using
Taylor series
expansions)
Resulting
approximate
eqs. which
represent
the
original
PDE, is called
a
Finite Difference Equation. (FDE)
STENCIL
i,j
i, j+1
i+1, j
i, j-1
i-1, j
i=1 i=N
X
Y
J=1
FDE algebraic
eq. (written
for
each
grid
point
within
the
domain)
Objectives:
study
the
various
schemes
to
approximate
the
PDE s by
FDE
explore
numerical
techniques
for
solving
resulting
FDE
Additional
Terminology:
1.
Consistency: a finite
dif. approx. of PDE is consistent
if
the
FDE approaches
the
PDE as
the
grid
size approaches
zero.
2.
Stability:
a numerical
scheme
is said
to
be stable
if
any
error
introduced
in the
FDE does
not grow
with
the
solution
of the
finite
difference
equations.
Von
Neumanns
method: without
boundary
conditions
(BCs)
Conditional
stability
on some
schemes
Time step be smaller
than
a certain
limit.
Under-relaxation
needs
to
be used
i.
Temporal
problems: stability
guaranties
that
method
produces
a bounded
solution
ii.
Iterative
methods: stable
method
does
not diverge
It
is difficult
to
do the
stability
analysis
when
BCs
& non-linearities
are
present
3.
Convergence:
a finite
difference
scheme
is convergent
if
the
solution of the
FDE
approaches
that
of the
PDE as the
grid
size approaches
zero
4.
Laxs
equivalent
theorem: for
a FDE which
approximates
a well-posed, linear
initial
value
problem, the
necessary
& sufficient
condition
for
convergence
is that
the
FDE
must
be stable
and
consistent.
For
linear
problems
which
are
strongly
influenced
by
BCs.
Stability
& convergence
of a method
are
difficult
to
demonstrate
Thus, we
check
via
numerical
experiments
(grid
refinement)
Grid-independent
solutions
Boundedness
Realizability
Accuracy:
Numerical
solutions
of fluid
flow
& heat
transfer problems
are
only
approximate
solutions. Involve
some
kind
of error.
Numerical
solutions
include
three
kind
of errors:
Modeling
Errors: difference
between
actual
flow
& exact
solution
of mathematical
model
N-S eqs. Represent
accurate
model of a laminar
flow.
Problem with
turbulent
flows, two-phase
flows, combustion
etc. simplifying
geometry
BCs.
Discretization
Errors: difference
between
exact
solutions
of conservations
eqs. & exact
solution
of algebraic
system
of eqs. Obtained
by
discretizing
these
eqs.(truncation
error)
Iteration
Errors: difference
between
the
iterative
& exact
solutions
of the
algebraic
eqs.
(round-off
error)
THE CONSERVATIVE (DIVERGENT) FORM OF A PDE
PDEs
normally
represent
a physical
conservation
statement.
Definition:
Coefficients
of the
derivatives
are
either
constant
or
if
variable, their
derivatives
do not
appear
anywhere
in the
equation. i.e. divergence
of physical
quantity
can be identified
in
the
equation
Example
1: Conservative
form of a continuity
equation
0 =
V
t
or
in Cartesian
coordinate
system
0
) ( ) ( ) (
=
z
w
y
v
x
u
t
Non
conservative
form of continuity
eq.
0 =
z
w
z
w
y
v
y
v
x
u
x
u
t
Example
2:
1-D heat
conduction
x
T
k
x t
T
c
x
T
x
k
x
T
k
t
T
c
2
2
Conservative
form
Non-conservative
form
A difference
formulation
based
on a PDE in non-conservative
form may
lead
to
numerical
difficulties
in situations
where
the
coefficients
may
be
discontinuous
as in flows
containing
shock
waves.
tV
T
L
=
L
y x
y x
,
,
V
v u
v u
,
) , (
2
=
V
p
P
V ,
Dimensionless
Equations
,
L: characteristic
length
: reference
density, velocity
0 =
V
+ = +
V P V V
t
V
2
Re
1
) (
L V
Re
Non-conservative
form
body force
is neglected
(Fr
if
not)
0 =
V
+ = +
V P V V
t
V
2
Re
1
) (
+ +
2
2
2
2
2
Re
1
) ( ) (
y
u
x
u
uv
y
p u
x t
u
= +
2
2
2
2
2
Re
1
) ( ) (
y
v
x
v
p v
y
uv
x t
v
Conservative
form
Exercise: Prove
that
conservative
& non-conservative
form of NS eqs. are
equal
to
each
other.
Important
in numerical
solution
algorithms
p v u , ,
,
1) Primitive-variable
solutions,
2)
Vorticity-Stream
Function
Formulations,
2-D
=
constant
x
v
y
u
V x
=
=
CLASSIFICATION OF DIFFERENTIAL EQUATIONS
O.D.E
One
independent
variable
P.D.E
More
then
one
independent
variable
( , )
( )
dy
f x y
dx
y y x
=
=
2 2
2 2
0
( , )
u u
x y
u u x y
+ =
=
O.D.E : I.V.P: conditions
are
specified
at one
point
B.V.P: conditions
are
specified
at more
then
one
point
'' sin cos y ty t + =
(0) 0
(0) 0
y
y
=
=
'(0) 0
(1) 2
y IVP
y BVP
=
=
e.g.
Solution procedure differs between IVP & BVP
Which types of physical phenomena lead to ODEs
and PDEs?
Question:
Modeling Concepts:
A. Particle viewpoint:
systems described by single particle which moves in space
without undergoing any physical changes in position.
e.g. free falling of a solid sphere
Position of each particle identified solely as a function of time.
In fluid mechanics: Lagrangian
description of motion.
ODE of the initial value type is the mathematical description of
physical laws formulated
by the particle viewpoint.
B. Field Viewpoint:
Plays a dominant role in fluid mechanics, heat transfer, thermo,
optics, and
electromagnetism.
Physical system is regarded as a continuum , i.e., we abandon the notion of large
number of individual elementary particles.
CONTINIUM ASSUMPTION
Eulerian
description of motion.
Field quantity is assumed to have a well-defined value at each point in space.
In general each field quantity can depend on x, y, z, t (4 independent variables).
( , , , ) V V x y z t
=
( , , , ) T T x y z t = ( , , , ) P P x y z t =
Natural mathematical language
PDEs.
C. A third viewpoint:
ODEs
often occur in situations which have nothing to do with particles.
Example: Steady state temperature distribution in a fin.
h = 20 W / m
2 0
C
T
= 20
0
C
T(0) = 200
0
C
x
(0)
w
T T =
( )
t
T L T =
T T
=
1
( ) ' ( )
c
c
P x A x
A
=
'
( )
s
c
A h
R x
k A
=
2
2
( ) ( ) ( ) 0
d d
P x R x x
dx dx
+ + =
ODE of the boundary value type is obtained by
neglecting the influence of all but one of the
independent variables.
ORDINARY DIFFERENTIAL EQUATIONS
A. Initial Value Problems
First order ODE
( )
family of
solutions
( , ) , , ' 0
dy
f x y x y y
dx
= =
_
General form
Chose one solution using the initial condition
0 0
( ) y x y =
Exact Solutions
1. Linear equations
( ) ( )
dy
p x y q x
dx
= +
}
Evaluated analytically, analytic problems
( )
Not analytically evaluated, not analytic problems (need numerical solution)
p x dx
= +
2.
Separable Eqs.
( ) ( )
dy
F x G y
dx
=
dy
xy
dx
=
2
1
ln
2
dy x
xdx y c
y
= = +
2
2
x
y ce =
( )
2
1)
2
(1) 2
2
2
x
y
y e
c
e
+
=
=
=
1
1
2
-1
-2
C=0
3. Exact
( , )
( , )
dy M x y
dx N x y
=
?
N M
x y
=
4.
Homogeneous
( )
dy
x
f
y
dx
=
y dy dp
p p x
x dx dx
= = +
( )
( )
dp dp dx
p x f p
dx f p p x
+ = =
In general numerical methods are needed for solution
Nth order ODE:
( ) ( 1)
1 1 0
........... ' ( )
n
n
n n
a y a y a y a y F t
+ + + + =
( )
,....
n
n
n
d y
y
dt
=
1
1
( , , ,......., )
n n
n n
d y dy d y
f t y
dt dt dt
=
or
Theorem:
An nth order ODE can be represented as a system of n first order
ODEs.
Let us define new variables
1 2 3 1
, , ,.......,
n
y y y y
+
1
, y t =
2
, y y =
3
', y y =
4
'',........., y y =
( )
2
,
n
n
y y
=
( 1)
1
n
n
y y
+
=
1 '
1
= y
.
2 3
' y y =
1
'
n n
y y
+
=
.
3 4
' y y =
1 1 2 3 1
' ( , , ,..... )
n n
y f y y y y
+ +
=
.
.
I.C.s
2 0
( ) y t =
, ,
1 0
( )
n
y t
+
=
all specified
In vector relation,
' ( ) Y F Y =
, , ,
0
( )
i
Y t y =
,
1 2 1
( , ,......., ) ,
T
n
Y y y y
+
=
,
1 2 1
' ( ' , ' ,......., ' ) ,
T
n
Y y y y
+
=
,
3 4 1
(1, , ,......., , )
T
n
F y y y f
+
=
,
T: Transpose.
Eg:
'' ( ) ' ( ) ( ) y b t y c t y d t + + =
'
dy
y
dt
=
0 0
( ) y t y =
0 1
'( ) y t y =
1
2
dz
z
dt
=
2
3 3 2 3 1
( ) ( ) ( )
dz
d z d z z c z z
dt
=
3
1
dz
dt
=
Initial Var.
New Variable
Initial Value
Dif.Eq.
y z
1
y
0
y
z
2
y
1
t z
3
t
0
3
1
2
2
3 3 2 3 1
1
( ) ( ) ( )
dz
dt
dz
z
dt
dz
d z d z z c z z
dt
=
=
=
1 2
2 3 3 1 3 2
3
0
0 1
0
( )
( ) ( ) ( )
1
( )
d z
f z
dt
f z
f f d z c z z b z z
f
y
z t y
t
=
= =
=
,
,
,
,
,
Example 2
'' 2
''' cos sin '
x
x x x e t = + +
(0) 3
'(0) 7
''(0) 13
x
x
x
=
=
=
Old
variables
New
variables
Initial
value
Diff. eq.
t
x
x
x
x
1
x
2
x
3
x
4
0
3
7
13
x
1
=1
x
2
=x
3
x
3
=x
4
x
4
=cos
x
2
+sin x
3
-
e
x4
+x
1
2
So, corresponding first order system is:
1
2
3
4
'
'
' ,
'
'
x
x
x
x
x
=
,
4
3
4
2 3 1
1
cos sin
x
x
F
x
x x e x
=
+ +
,
0
3
(0)
7
13
x
=
at x
1
=0, t=0
Example 3
.
2 3
'' (3 ') ( ') 6 '' 2
''' '' '
x
x x y x y y t
y y x e t
= + + +
= +
x(1)=2 , x(1)=-4 , y(1)=-2 , y(1)=7 , y(1)=6
Old variables New variables
Initial
value
Diff. eq.
t
x
x
y
y
y
x
1
x
2
x
3
x
4
x
5
x
6
1
2
-4
-2
7
6
x
1
=1
x
2
=x
3
x
3
=x
2
-x
4
-
9x
3
2
+x
5
3
+6x
6
+2x
1
x
4
=x
5
x
5
=x
6
x
6
=x
6
-x
3
+e
x2
-x
1
[ ]
(1) 1, 2, 4, 2, 7, 6
T
x =
,
REVIEW OF TAYLOR --DERIVATION
f(t)
t=a t
f(a), f(a), f(a),
f(t)=a
0
+a
1
(t-a)+a
2
(t-a)2++a
n
(t-a)n+.
a
0
=f(a)
a
1
=f(a)
f(t)=a
1
+2a
2
(t-a)+3a
3
(t-a)2++na
n
(t-a)n-
1+.
a
2
=(1/2)f(a)
a
3
=(1/2*3)f(a)
f(t)=2a
2
+2*3a
3
(t-a)++n*(n-1)a
n
(t-a)n-2+.
a
i
=f(i)(a)/i!
Taylor series expansion of f(t) about the point t=a.
( )
E a t
n
a f
t f
N
n
n
n
+ =
=0
) (
!
) (
) (
For a=0 the series is called MacLaurin
series.
Truncation:
( )
E a t
n
a f
t f
N
n
n
n
+ =
=0
) (
!
) (
) ( E: Truncation Error
( )
1
1
( )
( )
( 1)!
N
N
f
E t a
N
+
+
=
+
a t
f(t)
h
t=x
t=x+h
( )
0
( )
( )
!
n
N
n
n
f x
f x h h E
n
=
+ = +
( )
1
1
( )
( 1)!
N
N
f
E h
N
+
+
=
+
x x h +
Example: Develop the Taylor series for Sin (x)
about the point
2
x
=
f(x)=Sin x , f(x)=Cos
x , f(x)=-Sin x , f(x)=-Cos
x , fIV(x)=Sin x
( ) 1,.......
2
f
=
2 4
1 1
sin 1 ( ) ( ) ..........
2 2
2! 4!
x x x
= +
( )
2 1
( ) 0
2
k
f
+
=
( )
2
( ) ( 1)
2
k
k
f
=
( )
2
0
1
sin ( )
2
2 !
k
N
k
k
x x E
k
=
= +
2
x h
=
( )
2
0
1
sin( ) ( )
2
2 2 !
k
N
k
k
h x E
k
+ = +
1
0
2
! 2
1
k
k
k
h
k
4
1
sin( 0.01) 1 10 0.99995
2 2
+ = =
Taylor error formula
( )
3
2
10
cos
3!
E
= 0.01
2 2
< < +
6
10
3!
E
bound-on error
Numerical Solution of ODEs
of the Initial Value Type
Taylors Method:
) , ( y x f
dx
dy
=
0 0
( ) y x y =
0
( ) ? y x h + =
Difference methods or discrete variable methods
Continuous function y(x) is approximated by a set of discrete values yi,
y
y
0
y
y
y
x
0
x
1
x
2
x
i
b
x
0
0 0
2 2 3 3
0 0
2 3
( ) ( ) ........
2! 3!
x
x x
dy h d y h d y
y x h y x h
dx dx dx
+ = + + + +
0
0 0
( , )
x
dy
f x y
dx
=
0 0
2
2
, x y
d y d dy df f f dy f f
f
dx dx dx dx x y dx x y
= = = + = +
( , ( )) f f x y x =
3 2
3 2
d y d d y d f f f f f f
f f f f
dx dx dx dx x y x x y y x y
= = + = + + +
2 2
xx x y xy xy y yy
f f f ff ff ff f f = + + + + +
2
2
( , , )
d y dy
f x y
dx dx
=
0
0 0
1
( )
&
x
y x y
dy
y
dx
=
=
We need
Eulers Method:
0 0 0 0
( ) ( ) ( , ) y x h y x hf x y + = +
Target
x
x
0
x
0
+ h = x
1
y
0
y
1
y
x
x
0
x
0
+ h = x
1
y
0
y
1
y
h
Actual
value
y(x)
error
predicted
0 0
tan ( , )
dy
f x y
dx
= =
1
( , )
i i i i
y y hf x y
+
= +
Local truncation error: O(h
2
)
Global error: a) Accumulated local error
b) Switching of solution curves
c) Round off error
If y
1
has an error generates wrong value for
0 1
( , ) f x h y +
Truncation
error
Round
off
error
Number
of
steps
Optimum
Error
[a,b] interval, at each step the local error
hM=b-a
( )
( )
( ) 2
2
2
( ) ( )
2 2
k
b a y h
h
y c M Q h
= =
****
MODIFIED EULERS METHOD: HEUN'S METHOD
x
x
0
x
0
+ h = x
1
y
0
y
1
y
1 0 0 0
( , ) y y hf x y = +
x
x
0
x
0
+ h = x
1
f
1
f
0
f
f(x,y)
0 0
tan ( , ) f x y =
( , ( ))
dy
f x y x
dx
=
0
0
0 0
( ) ( , ( ))
x h
x x
y x h f x y x dx y
+
=
+ = +
slope averaging
0 0 0
1 0 1 1 1
( , )
( , ) ( , )
f f x y
f f x h y f x y
=
= + =
1 0 0
p
y y hf = +
0 1
1 0
Trapezoidal rule
2
c
f f
y y h
+
= +
_
(2)
Use Euler as predictor to calculate y
1
, then calculate f
1
& use eq. (2) to correct the result.
TAYLORS METHOD:
5
dx
xt
dt
=
5
dx
tdt
x
=
2
5
ln
2
t
x C = +
5
ln 2
2
C = +
5
ln 2
2
C = +
2
5
ln ( 1)
2 2
x
t
=
2
5
( 1)
2
2
t x
e
=
x(1)=2
Taylor series method:
Not practical to use Taylors series expansion method if f has complicated derivates,
therefore,
No generalized computer program can be constructed
nth order R-K is an alternative.
2
2
2
2
5 5 (5 )
5 25
5 (1 5 )
d y
x xt t
dt
x xt
x t
= +
= +
= +
3
2
3
3
25 (2 ) 5 5(1 5 )
50 25 125
d y
x t xt t
dx
xt xt xt
= + +
= + +
RUNGE-KUTTA METHODS:
Accurate, stable, easy to program
Involves only first order derivative evaluation (function itself
not derivative)
Produces results equivalent in accuracy to the higher order Taylor formulas.
Each R-K method is derived from an appropriate Taylor method.
Perform several function evaluations at each step to eliminate the necessity to
compute the higher derivatives
Can be constructed for any order.
( , )
dy
f x y
dx
=
0 0
( ) y x y =
1 1 2 2
( ) ( ) y x h y x w F w F + = + +
1 2
, : w w weights
1
2 1
( , )
( , )
F hf x y
F hf x h y F
=
= + +
1 =
1 =
1 2
1
2
w w = =
,
MODIFIED EULER
Obtain
1 2
, , , w w
that the error is the same as in 2nd
order Taylors method.
( ) ( )
2 2
1 3
1
2( )( )
( )
2! 2! 2!
xx yy xy
h F
h F
f f f Q h
+ + +
2
2 1
( , ) ( )
df df
F h f x y h F Q h
dx dy
= + + +
Taylors series for a function of two variables.
2 2
1 2
2
1 2 2
( ) ( ) ........
( ) ( ) ......
x y
f f
y x h y x whf w hf h h f
x y
y x h w w f w h f ff
+ = + + + + +
= + + + + +
TAYLOR
2
( ) ( ) ........
2!
x y
h
y x h y x hf f ff
+ = + + + +
1 2
2
1
1
1
2
w w
w
+ =
= =
=
2nd order Runge-Kutta
4th Order Runge-Kutta:
1 1 1 2 2 3 3 4 4 k k
y y w F w F w F w F
+
= + + + +
1 1 2 3 4
( ) ( ) ( 2 2 )
6
k k
h
y x h y x F F F F
+
+ = + + + +
( )
1
1
2
2
3
4 3
( , )
,
2 2
,
2 2
,
k k
k k
k k
k k
F f x y
F h
F f x y
F h
F f x y
F f x h y F
=
= + +
= + +
= + +
Extensions to systems of differential equations:
) , , (
) , , (
y x t g
dt
dy
y x t f
dt
dx
=
=
with
0 0
0 0
) (
) (
y t y
x t x
=
=
RK4
1 1 2 3 4
1 1 2 3 4
( 2 2 )
6
( 2 2 )
6
k k
k k
h
x x F F F F
h
y y G G G G
+
+
= + + + +
= + + + +
0,1, 2,........ k MAX
b a
h
N
=
=
( )
( )
1
1
2 1 1
2 1 1
3 2 2
3 2 2
4 3 3
4 3 3
( , , )
( , , )
, ,
2 2 2
, ,
2 2 2
, ,
2 2 2
, ,
2 2 2
, ,
, ,
k k k
k k k
k k k
k k k
k k k
k k k
k k k
k k k
F f t x y
G g t x y
h h h
F f t x F y G
h h h
G g t x F y G
h h h
F f t x F y G
h h h
G g t x F y G
F f t h x hF y hG
G g t h x hF y hG
=
=
= + + +
= + + +
= + + +
= + + +
= + + +
= + + +
rnek:
TAYLOR (serisi) yntemi:
2 2
' y x y = + y(0)=0 [a=0 , b=1]
n=10 step h= (b-a)/n=0.1
2 3
1
'
'' '''
1! 2! 3!
i
i i i i
y h h
y y h y y
+
= + + +
y
, y
, y
necessary.
+O(h4) Truncation error results from taking finite
number of terms in an infinite series.
2 2
2 2
2
' ( , )
'' 2 2 2 2 '
''' 2 ' ( ') 2 ' ( ') ''
''' 2 0 2( ') 2 ''
x y
xx xy yy y x y xx xy yy y
y f x y x y
y f ff x yf x yy
y f f y f y f f ff f f y f y f y
y y yy
= = +
= + = + = +
= + + + + = + + +
= + + +
x
0
=0 , y
0
=0 , y
0
=0 , y
0
=0 , y
0
=2
2 3
3 3
1 0 0 0 0
2
(0.1) 0.3333*10
2 3! 6
h h
y y hy y y
= + + + = =
1
0.01 y
1
0.2 y
1
2.0003 y
x
1
=0.1 , y
1
=0.333*10
-3
2 3
2 1 1 1 1
0.002667
2 3!
h h
y y hy y y
= + + +
.
.
y
5
=0.041784 exact value 0.041791
.
.
y
10
=0.350064 exact value 0.350232
FREE FALLING OF A SOLID SPHERE
dt
dz
v =
z=0 at t=0
g
d
Motion
of sphere:
v=v(t)=?
z=z(t)=? Displacement
vacuum
only
external
force
is gravitational
force
but
in a fluid
additional
forces
1.
Buoyant
force: weight
of fluid
displaced
bt
body:
g m
f
g
d
f
6
3
2.
Force
on an accelerating
body: due
to
flow
field
exists
for
frictionlessflow
as well,
dt
dv
m
f
2
1
3.
Viscous
forces: In
real
fluid
shear
stress
on surface
z
v
A=d
2
/4
C
D
: drag
coef.[-]
A V C F
D D
2
2
1
F
D
:total drag
force
A:projected
frontal
area
Drag
due
to
1) pressure
forces
(from
drag)
2) friction
forces
(shear
stress)
C
D
= C
D
(Re, body shape) dimensional
analysis
Valid
for
= const. Over
any
body
Viscous
fluid
flow
pg.182 (white)
stokes
sol.
e
Rough
surface
10
0
10
3
10
4
10
5
10
6
Re
III
Transition
to
turb.
drag
crises
d
c
IV
b
a
II
I
Re
24
C
D
=
D
0.646
24
C
Re
=
5 . 0 C
D
4275 . 0
D
Re 000366 . 0 C
18 . 0 C
D
I
stokes
solution
II
approx. Fitted
curve
III -
approx. Const. Drag
coef. , 400<Re3x10
5
, 3x10
5
<Re2x10
6
, Re>2x10
6
, Re1
, 1<Re400
4.
Wave
drag: M=v(1) M=V/a shock
waves
cause
wave
drag.
M<<1 wave
drag
is neglected
Newtons
2nd Law
applied
to
spherical
body.
_
_
force viscous
2
accel. to due force
f. buoyant
. f gravit
Re)
4
(
2
1
2
1
D f f f
C
d
v
v
dt
dv
m g m mg
dt
dv
m
=
[ ]
( ) ,
4
3
, 1 ,
2
1
1
(Re) / /
1
f
D
d
C g B A
v
dt
dz
C V Cv B
A dt
dv
= = = + =
=
=
: density
of sphere
special
case:
in a vacuum:
0 =
,A=1 , B=g , C=0
2
0 0
0
2
1
gt t v z v gt
dt
dz
v gt v g
dt
dv
v
dt
dz
+ = + =
+ = =
=
[ ] ) ( (Re) / /
1
) (
v f C V Cv B
A dt
dv
v g v
dt
dz
D
= =
= =
RK4
( ) [ ]
( )
( )
( )
3 3 4
3 4
2 2 3
2 3
1 1 2
1 2
1
1
2 2
2
2 2
2
1
hG v hG v g G
hF v f F
G
h
v G
h
v g G
F
h
v f F
G
h
v G
h
v g G
F
h
v f F
v v g G
A
v f F
+ = + =
+ =
+ =
+ =
+ =
+ =
+ =
+ =
= =
= =
( )
( )
4 3 2 1 1
4 3 2 1 1
2 2
6
2 2
6
G G G G
h
z z
F F F F
h
v v
k k
k k
+ + + + =
+ + + + =
+
+
[ ] [ ]
1 . 0
100
10
10 , 0 ,
= =
N
a b
h
b a
h:step size
N:number
of steps
We
are
going
to
march
from
a to
b by
step size h.
HW1
2 2
1
y x y
dt
dy
y x
dt
dx
=
=
=
=
x(0)=-1.2
y(0)=0
[0,5] , h=0.1 & 0.01
Show the
result
Plot
phaseportrait
ORDINARY DIFFERENTIAL EQUATIONS OF THE BOUNDARY
VALUE TYPE (BVPs)
Finite-difference
method
(Relaxation
method)
Introduction:
We
will
concentrate
mainly
on second
order
BVPs
since first
order
problems
can be considered
as initial
value
problems.
In
practice, some
higer
order
equations
occur. When
equations
of higer
order
then
second
occur, we
can treat
them
as a coupled
set of second
order
equations.
Example
# 1 A non-linear
4th order
equation
+ + + + =
+ + + =
2 3
2 3
( ) ( ) ( ) (1)
(2)
( )
v
y y r x y q x y f x
Let
y z
z z ry qy f x
LINEAR EQUATIONS
Easiest
problem: Linear
equation
function
values
are
specified
at the
both
ends.
Analytical
solution:
Big
difference
between
the
solution
of linear&non-linear
problems.
Numerical
solution:
Techniques
for
linear
equations
can be easily
modified
for
non-
linear
problems.
E.g. 2 Boundary
Layer
Over
a Flat
Surface:
B.L eqs. reduce
an ODE a similarity
solution
{ }
+ =
= =
=
= = =
1/ 2
0
(0) (0) 0
( ) 1
( ) , ,
f ff
f f
f
y
u U f v U x f f
x
Third-order
non-linear
differential
eqs.
Almost
always
better
to
write
the
equation
as a series
of first
and
second
order
equations.
Let
us define
f g
=
f g
g f g
=
=
+
(A) 0
or
0
(B) gd f
numerical
integration
such
as trapezoid
rule.
Eqs. (A)&(B) can be solved
numerically
using
an iterative
procudure.
Direct
schemes
of solution
for
higer
order
eqs. (then
two) can be unstable.
General second
order
linear
ODE can be written
as
(3) ) ( ) ( ) ( x f y x r y x p y = +
+
Special
cases
p&r constant
and
f(x)=0 exact
analytical
solution
is obtaained
in the
form of
simple
exponentials
or
sine and
cosine
solutions
p&r constant
and
f is a special
form such
as a polynomial, an exponential, or
a sine
ar cosine
function
an analytical
solution
may
also
be obtained
by
the
method
of
undetermined
coefficient
f=0 special
situations
Bessel
functions, Legendre
functions
which
satisfy
special
forms
of eq.(3)
Special
situatons
are
exception
rather
than
the
rule
Need
to
find
ways
of computing
the
solution
of eq.(3) numerically
FUNCTIONS VALUES SPECIFID AT THE END POINTS:
2nd order
BVP two
conditions
need
to
be specified
These
conditions
the
function
or
its
derivative
or
a combination
of both.
Example
L
x
T
b
ted) (insula
x
T
, T T L x
dx
dt
k ) h(T-T
t
0 =
= =
=
(3) ) ( ) ( ) ( x f y x r y x p y = +
+
B b y
A a y
=
=
) (
) (
Wish
to
solve
eq.(3) for
x in (a,b) y(x)=?
Range
(a,b) is first
split
into
n equal
parts
of mesh length
h and
each
point
is labelled
as
indicated
below.
x
0
= a x
1
= a+h x
j-1
= a+(j-1)h x
j
= a+jh x
j+1
= a+(j+1)h
y
0
y
1
y
j-1
y
j
y
j+1
y
n
At a typical
point
in the
mesh at x=xj
, we
write
finite
difference
representation
to
eq.(3)
as,
(4)
1
) ( ) (
2
) (
2
error term
2
1 1
2
1 1
_
j j j j
j j
j
j j j
Cy
h
x f y x r
h
y y
x p
h
y y y
+ = +
+
+
+
+ +
Here
y
j
= y(x
j
) , p
j
= p(x
j
)
( )
2 2
1 1
1 2 1 (5)
2 2
j j j j j j j j
h h
y p h r y p y h f Cy
+
+ + + + = +
Assuming
Cy
j
negligible, then, finite
difference
approximation
to
eq.(3) at the
point
x
j
= a+jh
(j=1,2,..,n-1) is given
iby
eq.(5)
Example:
1 ) 1 (
0 ) 0 (
=
=
=
y
y
x y y
For
illustration
purposes, select
h=0.25
0 0.25 0.5 0.75 1
y
0
y
1
y
2
y
3
y
4
=1
P(x)=0 , r(x)=-1 , f(x)=x
( )
2 2
1 1
2 1 2 3 interior points!
j j j j j
y h y y h x x jh j , ,
+
+ + + = = =
0
0 1 2
1 2 3
2 3 4
1
2.0625 0.015625
2.0625 0.031250 (6)
2.0625 0.046875
y y y
y y y
y y y
+ =
+ =
+ =
y
0
=0 , y
4
=1 , Eq.(6) represents
3 equations
and
3 unknowns.
Linear
systems
of equations
Cramers
rule: few
number
equations; 3-4
Gauss elimination: moderate
number
of equations; 10-50
Iterative
techniques
(Jacobi, Gauss Seidel, SOR): large
number
of equations; 100-1000
Exact
solution
of
x y y =
( ) x e e
e
y
x x
=
+ ) 1 ( 1
2
1
2
Comparision
Numerical
Exact
y
0
0 0
y
1
0.18023
0.17990
y
2
0.38735
0.38682
y
3
0.64993
0.64945
y
4
1.0
1.0
Good
to
3 significant
figures
of a accuracy
even
for
this
large
h=0.25
Agreement
will
improve
as h decreases
Computer
Programming
General difference
equation
( )
2 2
1 1
1 2 1
2 2
j
j
j j
j j j j j j j
d
a
b c
h h
y p h r y p y h f
+
+ + + + =
_
_ _
j j j j j j j
d y c y a y b = + +
+ 1 1
(A) Linear
system
of eqs.
x
j
= a+jh
, where
j = 1, 2,..., (n-1)
(n-1) eqs. (n-1) unknowns
y
1
, y
2
,..., y
n-1
y
0
= A , y
n
= B (known
from
BCs)
need
to
solve
(n-1) linear
eqs. in (n-1) unknowns.
Coefficient
for
the
general eq.
( )
j j j j
j j j j
f h d r h a
p
h
c p
h
b
2 2
, 2
2
1 ,
2
1
= + =
+ =
Compute
and
store
in one
dimensional
arrays, p
j
= p(x
j
) , r
j
= r(xj
) , x
j
= a+jh
Eq.(A) in obtained
by
selection
of central
difference
formula
to
approximate
the
differential
eq.
Advantages
1.
Lead
to
the
tri-diagonal
matrices
2.
Often
lead
to
diagonally
dominant matrices
Definition:
A matrix
of dimension
NxN
is said
to
be strictly
diagonally
dominant
if
N 1,2,.., k for ... ...
, 1 , 1 , 1 , ,
= + + + + + >
+ N k k k k k k k k
a a a a a
Need
to
have
diagonally
dominant matrix
for
convergence!!
TRI-DIAGONAL MATRIX:
All
elements
other
than
diagonal, upper
and
lower
diagonal
elements
of a matrix
are
zero.
Note
if
matrix
is tri-diagonal
direct
method
of solution
should
be the
way
of solving
the
matrix.
Lets
write
the
coefficient
matrix
NN N
N
N
a a
a a a a
a a a a
. . .
. . . . .
. . . . .
.
.
1
2 23 22 21
1 13 12 11
N
a a a a a
, 3 4 , 3 2 , 3 1 , 3 3 , 3
.... + + + + >
Lets
write
eq.(A) in open
form,
1 1 1 2 1 1 0
2 1 2 2 2 3 2
3 2 3 3 3 4 3
1 1
2 3 2 2 2 1 2
1 2 1 1 1 1
:
:
:
:
k k k k k k k
n n n n n n n
n n n n n n n
known
a y b y d c y
c y a y b y d
c y a y b y d
c y a y b y d
c y a y b y d
c y a y d b y
+
+ =
+ + =
+ + =
+ + =
+ + =
+ =
(n-1) eqs. & (n-1) unknowns
y
i
, i=1,2,..,(n-1)
y
0
& y
n
are
known
from
BCs
need
to
eliminate
each
successive
y
i
2
2
^
1 1 2
1
1
^
1 1 2
2 2 2 2 3 2
1
^
1 1
2 2 2 2 3 2 2
1 1
(1')
(2)
(2')
d b y
y
a
d b y
c a y b y d
a
b d
a c y b y d c
a a
+ + =
+ =
_
_
) ' (2'
2 3 2 2 2
= + y b y use
(2) to
eliminate
y2
in (3),
3
3
2 2 3
2
2
2 2 3
3 3 3 3 4 3
2
2 2
3 3 3 3 4 3 3
2 2
(2''')
(3)
- (3')
b y
y
b y
c a y b y d
b
a c y b y d c
+ + =
+ =
_
_
1
1 1
1
1 1
k k
k k
k
k k
k k
k
c b
a
c
d
+
+ +
+
+ +
=
=
(I)
Forward
elimination,
k=1,2,..,(n-1)
Recursion
relations
for
and
eq.) (kth
1 k k k k k
y b y = +
+
k
k k k
k
y b
y
1 +
= (II) Back
subtitution
k=(n-1),(n-2),..,1
TDMA -
Tri-diagonal
matrix
algorithm.
To
obtain
values
to
start the
recursion
relations
off,
Compare
(kth) eq. with
(1)
1 1 1 2 1 1 0
1
^
1
1 1 1 1 1 0
(1)
(kth)
, (*)
k k k k k
a y b y d c y
y b y
a d c y d
+
+ =
+ =
= = =
Summary:
TDMA: Direct
process
of solution
Step #1:
and
are
calculated
using
the
recursion
relations
(I)
starting
from
the
initial
values
given
in (*)
Called
forward
elimination
k=1,2,..,(n-1)
Step #2:
Back
substitution
using
eq.(II) k=(n-1),(n-2),..,1
as y
n
= B is known
THE THOMAS ALGORITHM
more
efficient
scheme
numerically
stable
scheme
Start by
calculating
two
arrays
and
F starting
from
initial
values
0
0
0 0
=
= =
F
A y
Using
the
recursion
relations,
( ) ( )
,
1 1
1 1
1
1 1
1
1
k k k
k k k
k
k k k
k
k
F c a
c d
F c a
b
F
+ +
+ +
+
+ +
+
+
+
=
+
=
It
may
be proved
by
mathematical
induction
that
1
is known k (n-1),(n-2),.., 2, 1
k k k k
n
y F y
y B
+
= +
= =
Thomas algorithm
is preferred
direct
method
of solution.
k 0,1,2,..,(n-1) =
subroutine thomas(a,
b,
c,
d,
N,
y)
implicit double precision (a-h,o-z)
dimension a(N), b(N), c(N), d(N)
dimension F(0:2000), Delta(0:2000),y(0:N)
c
boundary condition #1 at x = 0
y(0) = 250.0
Delta(0) = y(0)
F(0) = 0.0
c
Forward Elimination
do 5 k = 0, N-1
F(k+1) = -(b(k+1))/(a(k+1)+c(k+1)*F(k))
Delta(k+1)=(d(k+1)-c(k+1)*Delta(k))/(a(k+1)+c(k+1)*F(k))
5 continue
c derivative
boundary condition #2 at x = L
(insulation)
AA = a(N)
BB = c(N) + b(N)
y(N) = (d(N)-
BB*Delta(N-1))/(AA+BB*F(N-1))
print*, y(N)
c back substitution
do 6 k = N-1,1,-1
y(k) = F(k)*y(k+1) + Delta(k)
6 continue
return
end
Example
of a Boundary
Value
Problem: Fins
or
Extended
surfaces
h = 20 W / m
2 0
C
T
= 20
0
C
T(0) = 200
0
C
x
( ) 0
1 1
2
2
=
+
T T
dx
dA
k
h
A dx
dT
dx
dA
A dx
T d
s
c
c
c
A
c
(x): Cross-sectional
area
A
s
(x): Surface
area
measured
from
the
base.
Note: if
A
c
(x)= const. A
s
(x)= P x P: perimeter
of cross-section
of the
fin
( ) 0
2
2
=
T T
kA
hP
dx
T d
c
Common
boundary
conditions
1.
T = Tb
at x = 0
2.
At x = L
1.
dT/dx
= 0 (insulated; Neumann
condition)
2.
T = T
L
(specified
temperature; Dirichlet
condition)
3.
T = T
(for
long
fins)
(convection
condition; Mixed
or
Robin
condition) ) (
=
= T T h
dx
dT
k
L x
4.
Object
of fin
analysis
1.
Solve
for
T(x)
2.
Compute
0
) (
=
=
x
C B
dx
dT
x kA q
energy
dissipated
by
the
fin
Methods
a) Exact
solutions
for
A
c
(x)= const.
b) Numerical
Methods
Numerical
Solution
of fin
equation
h, T
x
T
b
=T(0)
dx
dA
A
x P
c
c
1
) ( =
dx
dA
kA
h
x R
s
c
= ) (
= T T
x
0
x
1
x
j
x
n
0 ) ( ) (
2
2
= + +
x R
dx
d
x P
dx
d
j j j j j j j
d c a b = + +
+ 1 1
j = 1, 2, , (n-1)
j j
P
x
b
2
1
+ =
j j
P
x
c
2
1
=
j j
R x a
2
) ( 2 + =
0 =
j
d
a) Specified
temperature
at x = L
=
L
at x = L
=
b
at x = 0
Thomas algorithm
is readily
applied.
F
0
=0;
0
=
0
=
b
k k k
k
k
F c a
b
F
1 1
1
1
+ +
+
+
+
=
k k k
k k k
k
F c a
c d
1 1
1 1
1
+ +
+ +
+
+
k k k k
F + =
+1
k = (n-1),(n-2),, 2, 1.
b) Convection
condition
at x = L
h
dx
d
k
L x
=
=
at x = L &
=
b
at x = 0
h
h=x
introduce
additional
point
n-1 n n+1
Fin equation
at x = x
n
= L (j = n)
n n n n n n n
d c a b = + +
+ 1 1
Convection
condition:
n
n n
h
x
k
=
+
) ( 2
1 1
Eliminate
n+1
;
n n n
k
h x
) ( 2
1 1
=
+
( )
n n n n n n n
d b c
k
h x
b a = + +
1
) ( 2
A B
n n n
d B A = +
1
A
B d
n n
n
1
(1)
k k k k
F + =
+1
k = (n-1),(n-2),
For
k = n-1
1 1 1
+ =
n n n n
F
(2)
Substitute
Eq. (2) into
Eq. (1):
A
B BF d
n n n n
n
1 1
=
1 1
) (
= +
n n n n
B d BF A
1
1
=
n
n n
n
BF A
B d
=
or
,
) ( 2
4 3
3 2 1
0
x
T T T
dx
dT
x
+
=
or
) ( 6
2 9 18 11
4 3 2 1
0
x
T T T T
dx
dT
x
+ +
=
Non-Linear
Equations:
Methods
similar
to
those
used
in the
linear
case
can be used
Obtain
a set of non-linear
difference
eqs. but no general direct
methods
for
solving
non-linear
algebraic
eqs.
i.e. difference
eqs. cannot
be solved
immediately
as in the
linear
case
Standart Approach
in Non-linear
Case
1.
Linearize
difference
eq. usually
by
approximating
a portion
of non-linear
terms
with
a
guessed
solution
2.
Then, solve
the
linearized
dif. eq. with
a direct
method
such
as Thomas Algorithm
to
approximately
obtain
solution
3.
ITERATION needed
until
two
succesive
numerical
solutions
agree
at each
mesh
point
to
within
some
tolerance
specified
NOTE: Main
extra
feature
of non-linear
BVPs
is that
some
iteration
is necessary.
EXAMPLE:
Unlike
the
linear
case, we
cannot
write
down
a general non-linear
equation; thus
let
us illustrate
the
linearization
with
an example:
(1) ) ( ) ( ) (
3 2
x f y x r y y x p y = +
+
x = a & x = b conditions
are
specified
Finite
difference
approximation
at x
j
to
eq.(1)
( )
(2)
2
2
term truncation
2 3 2
1 1
2
1 1 j j j j j j j j j
Cy f h y r h y y y p
h
y y y
j j
+ = + + +
+ +
Note: Equation
(2) is non-linear
To
solve
eq.(2) , we
start off
by
guessing
a solution,
n j y
j
,.., 2 , 1 , 0 ,
) 0 (
=
Use
above
guessed
solution
to
linearize
the
non-linear
terms
in eq.(2)
{ } ( ) (3)
2
2
2 ) 1 ( ) 0 ( 2 ) 1 (
1
) 1 (
1
2
) 0 ( ) 1 (
1
) 1 ( ) 1 (
1
2
j j j j j j j j j j j
f h y y r h y y y p
h
y y y = + + +
+ +
Eq.(3) is a linearize
eq.& can be solved
by
a direct
method
(e.g. Thomas Alg.) to
obtain
the
first
solution
iterate,
) 1 (
j
y
j=0,1,2,...,n
Now, test to
see
wheather
) 1 (
j
y
is within
a specified
tolerance
of
) 0 (
j
y
internal
mesh point; if
not repeat
the
process, but this
time using
our
refined
estimate
of
the
solution,
at each
) 1 (
j
y
to
linearize
the
non-linear
terms.
{ } ( )
2
2
2 ) ( ) 1 ( 2 ) (
1
) (
1
2
) 1 ( ) (
1
) ( ) (
1
2
j
k
j
k
j j
k
j
k
j
k
j j
k
j
k
j
k
j
f h y y r h y y y p
h
y y y = + + +
+
+
CONVERGENCE TESTS:
To
determine
the
iteration
two
basic
tests
I. The
absolute
test
<
+ ) ( ) 1 ( k
j
k
j
y y
E.g.
= 10
-4
It
is not a significant
figure
test
small is y 10 3 , 10 3
5 ) ( 5 ) (
= =
k
m
k
m
y y
Absolute
test convergence
occured
But iterates
do not agree
to
even
one
significant
figure
E.g. y
m
is large
: test may
be much
more
demanding
than
we
wish
y
m
= 1234,5678 test asking
for
8 significant
figures
of agreement
in successive
iterates.
It
is not uncommon
for
the
solution
of a dif. eq. to
contain
pivotal
values
of widely
differing
in magnitude.
Need
a test which
takes
this
into
account
II.
The Relative Test
< <
+ +
+
) 1 (
) (
) 1 (
) ( ) 1 (
1 or
k
j
k
j
k
j
k
j
k
j
y
y
y
y y
Test for
significant
figures.
If
= 10
-4
two
successive
iterates
must
agree
to
within
4 significant
figures
at each
internal
mesh point
Generally
gives
more
satisfactory
results
7
10
j
y
settle
for
only
testing
pivotal
values
down
to
a certain
minimum magnitude
Falkner-Skan
Similarity
Solutions
Boundary
Layer
eqs. (x,y)
Similarity
methods
(x,y) ()
( , ) ( ) ( ) (1)
( )
( , ) ( ) ( ) ( ) (2)
u x y U x f
y
x
x y U x x f
=
=
=
B.L. eqs.
2
2
,
u dU u u
u v U
y dx y x
u v
y x
+ = +
= =
Substitute
(2) in to
B.L. eqs. written
in terms
of
and
show
( )
2
2
1 0 Falkner-scan eq.
= ( ) ,
f ff f
d dU
U
dx dx
+ + =
=
Flow
over
a wedge:
=1 , =arbitrary
Boundary
conditions
(0) 0 no slip at the wall (u=0) f
=
(0) 0 no slip at the wall (v=0) f =
( ) 1 as B.L. solution merges into the inviscid solution f
=
BVP
( )
2
1 0
( ) (0) 0 , ( ) 1
solve ( ) & obtain (0)
f ff f
f x f f
f f
+ + =
= = =
1/ 2
0
(0)
I
w
y
U
A f
x
u
y
=
=
Notes
Complicated
b.c. in
Non-linear
3rd order
BVP.
Better
to
use
2nd order
skim,
Let
0
( ) ( ) ( ) ( ) f y f y t dt
= =
2
0
(1 ) 0 (1)
( ) ( ) (2) trapezoid or simpson rule
y fy y
f y t dt
+ + =
=
Need
to
iterate
Use
finite
difference
method
not shooting
-0.19 solution
hes
multiple
solution
(do not try)
guess
for
y& solve
for
f by
(2)
use
f to
solve
y by
(1)
iterate
until
convergence
2
-
or 1- y erf e
=
suggested
initial
guess
for
y
Finite
difference
representation
of eq.(1)
( )
0
1 1 1 1
2
2 0 2
1 1 1 1
2 0 2
1 1
2
(3)
2
2 (4)
2
1 2 1 (5)
2 2
i i i i i
i i i
i i i i i i i i
i i i i i i
y y y y y
f y y
h h
h
y y y f y y h y y h
h h
y f y h y y f h
+ +
+ +
+
+
+ =
+ + =
+ + + =
Eq.5 is of the
form,
1 1
(6)
i i i i i i i
b y a y c y d
+
+ + =
Procedure
1.
Guess
a solution
for
0
( ) y
e.g.
2
0
( ) 1 y e
=
2.
Solve
for
( ) f
from
(2)
i.e.
0
( ) ( ) trapezoid rule
i
i
f y t dt
3.
Use ( )
i
f to
solve
1
( ) y eq.(5) (thomas
algorithm)
4.
Iterate
until
convergence
i.e
( ) ( 1)
( )
k k
k
y y
y
<
Take
= 5-6
Plot
, versus f f
Take
=0,1,&5
LAMINAR NATURAL CONVECTION ON A VERTICAL SURFACE
Similarity
solutions:
Vertical
surface
is held
at a uniform
surface
temperature, T
w
.
y
b.l
u
v
x
T
w
T1: ambient
fluid
temperature
Boundary
Layer
equations
governing
the
flow
2 2
2 2
2
1
2
2
2
, , 1
0
( )
, =
p
u u
v u Gr
x y
v u
y x
u u u
u v g T T
y y x
T T T
u v
y y x
k
c
<< << >>
+ =
+ = +
+ =
=
B.Cs:
At y=0 , u=v=0 , T=Tw
For
large
y: u0 , TT1
Velocity
& temperature
profiles
are
similar
at all
values
of x.
i.e.
( )
1
1
1
r
w
r w
u y
func
u
T T y
func
T T
u g T T x
=
u
r
: reference
velocity
: measure
of both
local
velocity
& thermal
b.layer
thicknesses
Define a streched
variable
near
the
plate
1/ 4
3/ 4 1/ 4
which magnifies the thin b.l. region (Gr>>1)
Gr y
L x
=
The
velocity
components
are
1/ 4
1/ 2
1/ 4 1/ 4 1/ 4
1
1
1
( ) , ( 3 )
4
( )
( )
w
w
U UL
u x f v f f
L Gr x
U g L T T
T T
T T
= =
=
Substituting
momentum eq. & energy
eq.
_
driving force
2
3 1
0
4 2
f ff f
+ + =
3
Pr 0 Prandtl number
4
f
+ =
B.Cs
1
At 0 0 0: 0 (no-slip)
At 0 0 0: 0 (solid wall)
At 0 0: 1 (const. plate temp.)
For large y: 0 : 0 (no motion in the ambient)
For large y:
w
y u f
y v f
y T T
u f
T T
= = = =
= = = =
= = = =
: 0
Local
nusselt
number
gives
the
heat
transfer from
the
plate
to
the
fluid
per
unit
area
per
unit
time
3/ 4
1/ 4
3/ 4
0
x
x
Nu Gr
L
(0)
needs
to
be numerically
calculated
Numerical
solution
2
2
3 2 0 (1)
3Pr 0 (2)
Let f =y
3 2 0
3Pr 0
f ff f
f
y fy y
f
+ + =
+ =
+ + =
+ =
Finite
difference
representation
( )
(k)
i
(k) (k)
i i
2
1 1 1 1
2
(1) (1) (1) (1) (1) 2 (0) (1) 2
1 1 1 1
( ) ( ) 2 ( 1) ( )
1 1
2
3 2 0
2
3
2 2 0
2
3 3
1 2 2 1
2 2
i i i i i
i i i
i i i i i i i i i
k k k k
i i i i i i
a
b c
y y y y y
f y
h h
h
y y y f y y h y y h
h h
y f y h y y f
+ +
+ +
+
+
+ + =
+ + + =
+ + +
_
_ _
(k)
i
2
d
1 1 1 1
2
1 1
2
3Pr 0
2
3 3
1 Pr ( 2) 1 Pr 0
2 2
i
i
i i
i
i i i i i
i
i i i i i
d
a
b c
h
f
h h
h h
f f
+ +
+
=
+
+ =
+ + + =
_ _
Procedure
1. Guess
0
( ) y
2. Find
0
( ) ( ) trapezoid rule
i
i
f y t dt
3. Use
Thomas algorithm
to
find
i
4. Use
thomas
algorithm
to
find
(1) (0)
i
[using & ]
i i
y y
5. Iterate
until
convergence
i.e.
( ) ( 1)
( )
k k
k
y y
y
<
for
all
i=0,..,N
Notes:
Infinity
about
12
Use
iterative
averaging, i.e %50 old, %50 new
Limit IMAX 100
provide
good
initial
guess, e.g.
2
( ) 1 y e
=
From
the
derivation
of B.L. eqs.
1/ 4
3
1
2
1
( )
x
w
x
x Gr
g T T x
Gr
=
Grashof
number
main
parameter
in free
convection
controlling
the
nature
of the
motion
1/ 4
1
1
1
: similarity variable
( ) ; ( )
( )
x
w
w
y
Gr
x
T T u
F
T T
g T T x
= =
Following
dimensionless
variables
are
introduced
0.5
1
0.5
1
0.5
( )
( )
1
cont. eq. [ 3 ]
4
x
w
x
w
x
u ux
U Gr
g T T x
v vx
V Gr
g T T x
V F F
Gr
= =
= =
=
Writing
momentum eq. in terms
of dimensionless
variables
2 2
2
1
1
2
( )
w
u U u u
U V
x x y y x
g T T x
+ + = +
Shooting
Methods
for
BVPs
Make
use
of techniques
that
are
normally
designed
to
solve
IVP.
Usually
4th order
RK methods
are
used
Called
marching
schemesmarch away from the initial data point constructing the
solution in a step-by-step manner.
Let
us illustrate
the
approach
using
an example
of a non-linear
second
order
dif. eq.
4
( ) ( ) ( ) (1)
( ) , ( ) (2)
y p x yy r x y f x
y a A y b B
+ + =
= =
Let
us recast
the
problem as a sequence
of two
first
order
equations
4
(3)
( ) ( ) ( )
y z
z f x p x yz r x y
=
Now, if
y(a) & z(a)=y(a) were
known, eqs.(3) would
define an IVP, and
could
use
a RK4
scheme
to
construct
the
solution
in a step-by-step manner
for
values
of x>a .
We
dont
know
z(a)=y(a)
& so
we
GUESS
some
value
for
it, z(a)=
1
so
the
system
of two
equations
(3) may
be integrated
forward
in x as an initial
value
problem. But, when
we
reach
x=b , y(b)=B will
not be, in general, satisfied. Other
value
y(b)=
1
Problem is to
find
an intelligent
way
to
go
back
and
adjust
the
guess
for
y(a)
so
that
the
condition
at x=b will
be satisfied.
Select
another
value
of y(a), say z(a)=
2
and
integrate
again
& produce
another
value
y(b) =
2
The
problem is determine
where
this
numerical
function
intersets
the
true
boundary
condition,
=B = ? In
practice,
Having
guessed
two
values
1
and
2
for
z(a)=y(a),
z(a)=
1
y(b)=
1
z(a)=
2
y(b)=
2
Equation
of the
line
passing
through
(
1
,
1
) & (
2
,
2
)
B
Values
of
y(b)
Guess
for
y(a)
1
2
3
3
1 1
1 2 1 2
- -
linear interpolation
=
But we
want
=B so
this
gives
us a revised
guess
to
try
for
3
( )( )
1 2 1
3 1
1 2
-
(4)
B
= +
Use
3
to
start another
integration
of eq.(3)
3 3
( ) ( ) ( ) y a z a y b
= = =
(
1
,
1
) , (
2
,
2
) , (
3
,
3
)
take
a line
between
whichever
of the
three
points
have
values
of
closes
to
B, and
use
this
line
to
obtain
a new
estimate
of z(a)=
4
Iterate
until
convergence
1
1
tolerance (5)
i i
i
B
+
+
Technique
is called
shooting
method
We
are
adjusting
the
slope
of our
gun
with
the
objective
of hitting
the
target
of the
true
boundary
condition
at x=b
x b
a
y
(1)
(3)
(2)
Desired
boundary
value
Comments
on this
procedure
1.
Method
may
not convergence
at all
if
1
&
2
the
initial
guesses
are
not reasonably
close
to
the
correct
value
of y(b)=B. Usually
some
trial&error
calculations
may
be
necessary
in order
to
ensure
that
1
&
2
produce
values
af
1
&
2
which
are
not
radically
different
from
B
2.
this
method
is very
laborious
& almost
useless
if
more
than
one
B.C. must
be shot
at
E.g.
( , , , )
( , , , )
with the B.C.
( ) , ( )
( ) , ( )
y f x y u u
u g x y u u
y a A y b B
u a C u b D
=
=
= =
= =
Two
values
at x=b must
be shot
at.
Parallel
shooting
techniques
can be used
but
labourious
methods
*
3.
Shooting
methods
may
also
fail when
the
eqs. contain
an unwanted
solution
that
may
invariably
be introduced
in the
marching
procedure.
Example
1 2
1 2
0
general solution y(x)=A A
if B.C. are specified such that
(0) 1 , 0
1, 0
x x
y y
e e
y y as x
A A
=
+
=
= =
If
we
try
to
shoot
for
the
value
0 for
large
values
of x, failure
of the
scheme
will
occur
abruptly
with
an overflow
due
to
exp(x) .
Can solve
it by
going
back
& try
to
adjust
the
guessed
slope
if
values
of y get
too
large
But difficult
Boundary
value
methods
are
in general
preferable
for
boundary
value
problems
PARTIAL DIFFERENTIAL EQUATIONS (PDEs)
Physical
classification
Equilibrium
Problems: BVPs
(Jury
problems)
PDEs
must
be satisfied
in D
BCs
must
be
satisfied
on B
D
B
Steady
state
temperature
distributions
Incompressible
inviscid
flows
Equilibrium
stress
distribution
in solids
Ex1: Heat
conduction
in solids
in steady
state
T=0
T=0
T=0
T=T
0
1
1
y
x
Seperation
of variables,
[ ]
1
0
( , ) sin( ) sinh ( 1)
( 1) 1
2
sinh( )
n
n
n
n
T x y A n x n y
T
A
n n
=
=
=
2
0 T =
Ex2:
Irrotational
flow
of an incompressible
inviscid
fluid
is governed
by
Laplaces
eq.
2
0
V
=
=
,
a
y
x
F(r,)=r-r
b
()=0
U
B.Cs
on surface
of cylinder
is
. 0 V F =
,
Where
F(r,)=0 is equation
of surface
of cylinder.
In
addition, velocity
must
approach
free
stream
value
as distance
from
body becomes
large, i.e., as (x,y)
U
=
,
2 2
2 2
cos K Kx
U x U x
x y
x y
= + = +
+
+
Marching
Problems: IVP or
IBVP
Marching
or
propagation
problems
are
transient
or
transient-like
problems
t or
y (marching
direction)
BCs
must
be
satisfied
on B
Initial
data
surface
x
B
Dif. eq. must
be
satisfied
in D
Domain for
a marching
problem
The
solution
must
be computed
by
marching
outward
from
initial
data surface
while
satisfying
BCs.
Mathematically, these
problems
are
governed
by
either
hyperbolic
or
parabolic
PDEs.
Examples: 1-Dimensional
Wave
eq. &
1-Dimensional
diffusion
equation
2 2
2
2 2
2
2
u u
c
t x
u u
t x
=
=
Mathematical
Classification
of PDEs
Need
to
examine
some
mathematical
properties
of PDEs.
Governing
PDEs
in Fluid
Mech. are
quasi-linear
i.e. highest-order
derivatives
occur
linearly
no products
or
exponentials
of the
highest-order
derivatives.
The
general quasi-linear
second
order
PDE in two
independent
variables
is given
below
2 2 2
2 2
u u u
A B C f
x x y y
+ + =
Where
A,B,C,f may
all
be functions
of x,y,
,
u u
x y
but not allowed
to
contain
second
derivatives.
Strict
linear
case
: A,B,C are
functions
of x and
y and
f is, at worst, a linear
combination
of
,
u u
x y
as well
as depending
on x & y
If
B
2
-4AC > 0 Hyperbolic
PDE , Two
real
distinct
characteristics
exist
at each
point
in
x-y plane
B
2
-4AC = 0 Parabolic
PDE , one
real
characteristic
B
2
-4AC < 0 Elliptic
PDE , characteristics
are
imaginary
2
4
2
dy B B AC
dx A
=
See
Tannehill
et.al. 1997, page
24 for
derivation
Characteristic
lines
are
related
to
directions
in which
information
can be transmitted
in physical
problems
governed
by
PDEs.
Hyperbolic
PDEs
with
two
independent
variable
x & y
x
y
a
b
c
2
Right-running
P
I
II
III
Left-running
Domain of dependence
for
P
Initial
data along
the
x axis
upon
which
P depends
(boundary
conditions)
Domain of influence: region
influenced
by
P
= cont. & =const. lines
represent
the
two
families
of characteristics
along
which
signals
can propagate
Observer
at point
P can feel
the
effects
of what
has happened
in Region
I.
The
domain of dependence
region.
Outside
Region
I, disturbance
cannot
be felt
by
P.
Disturbance
created
at point
P can be felt
only
in the
Region
II, i.e. Region
II is
the
domain of influence
of point
P.
Hyperbolic
eqs.
domains
extend
to
infinity
in the
time like
coordinate
Solution
can be obtained
by
marching
forward
in the
distance
y, starting
from
the
given
boundary
Spatial
coordinate
may
or
may
not be bounded
Normally
associated
with
initial
value
problems
Typically
two
initial
conditions
at t=0 are
specified
If
the
spatial
region
is bounded
boundary
conditions
2 2
2
2 2
- <x<
u u
a
t x
=
With
I.C. u(x,0)=f(x)
A=a
2
, B=0 , C=1
( , 0) ( )
u
x g x
t
2 2
2
4 0 0 4 1
2 2
dt B B AC a
dx A a a
= = =
x
x
P(x
0
, t
0
)
x + at= x
0
+ at
0
x -
at= x
0
- at
0
1 1
-1/a
1/a
x
0
+ at
0
x
0
- at
0
Domain of
dependence
x + at = const. = x
0
at
0
x
at = const.
Example:
Best
known
example, one
dimensional
wave
eq.
x
u
L
u(0,t)=0 u(L,t)=0
u(x,t) = F
1
(x + ct) + F
2
(x -
ct)
D
Alembert
solution
of wave
equation.
u(x,t) at (x
0
, t
0
) depends
only
upon
initial
data contained
in the
interval.
x
0
- at
0
x
x
0
+ at
0
( ) ( - ) 1
( , ) ( )
2 2
x at
x at
f x ct f x ct
u x t g d
a
+
+ +
= +
u(x,t) displacement
of the
string
of length
L above
the
equilibrium
position
t: time
Initial
conditions:
Initial
displacements
u(x,0) of string; e.g. u(x,0)=sin(x/L)
Initial
velocity ( , 0) e.g. ( , 0) 0 (released from rest)
u u
x x
t t
=
Find
u(x,t) = ? for
t>0 all
x
( , ) sin cos
x x
u x t a
L L
=
Characteristic
lines
at right-running
-at left-running
dt
x L
dx
= =
x
t
P
x = -ct
x = at
x + at = const. = x
0
+ at
0
x
at = const. = x
0
at
0
Fluid
Mechanics
Examples:
I. Steady, inviscid
supersonic
flow
( )
2 2
2
2 2
1 0
: disturbunce velocity profile
d d
M
dx dy
=
y
x
M>1
II. Unsteady, inviscid
compressible
flow
Unsteady
1-D & 2-D inviscid
flows
hyperbolic
Time is the
marching
direction
2 2
2
2 2
c
t x
=
water-hammer
problems
wave
equation.
Parabolic
PDEs
Only
one
characteristic
direction
at a point
P
Domain of
dependence
b.c. known
b
d
Region
influced
by
P
c
y
a
x
Time like
variable
Boundary
cond. known
Characteristic
direction
(lines)
Normally
associated
with
IVPs
but only
one
I.C
is required
instead
of two
(as for
hyperbolic
eq.)
Parabolic
equation
in two
independent
variables
x & y
Information
at point
P influences
the
entire
region
on one
side
of the
vertical
characteristic
and
contained
by
the
boundaries
marching
solutions
applicable
Fluid
Mech.
B.L. eqs.parabolized N-S eqs.
b.l. edge
Viscous
flow
U
Unsteady
heat
conduction:
the
best
known
example
T
x
L
T
1
t
t=0
t
2
t
1
T
2
2 2
2 2
:const.
T T T
t x y
= +
Heat
conduction
eq. (diffusion
eq.)
T(x,0)=T
1
=const.
T(L,t)=T
2
=const.
T(0,t)=T
1
=const.
T(x,t)=?
2
2
: thermal diffusity
T T
t x
=
x
u
2
2
u u
t x
=
Elliptic
PDEs
Consider
an elliptic
equation
in two
independent
variables
x & y
Characteristic
curves
are
imaginary
No preferred
direction
of propation
i.e. information
is propagated
everywhere
in all
directions
any
disturbance
at point
P
influences
the
solution
everywhere
x
y
P
C
e.g.
2 2
2 2
0
u u
x y
+ =
Conditions
must
be specified
on closed
curve
C
u is continious
on R+C
Max/Min
Property: U
max
and
U
min
must
be
on C
II.
x
y
R
C. piecewise
regular
2
0 u =
I. u=f(x,y) on C.. Dirichlet
Problem (unique)
( , ) on C: Neumann Probl. (not unique)
u
g x y
n
u must
be specified
at least
one
point
III.
Combination
of u &
u
n
is known
Robin's Probl.
u
Au B
n
+ =
IV. Mixed
problems
combination
of these
conditions
on various
parts
of C
Also
can have
non-linear
conditions
e.g. radition
n
u
AT B
n
+ =
Boundary
conditions
Example:
Heat
conduction
in solids.
2
( , ) T f x y =
Steady, subsonic, inviscid
Incompressible
inviscid
flow. M0
2
0 streamlines
irrototainal flow . 0 V
=
= =
, ,
x
y
z
u
t
2 2
2 2
u u
y z
= +
Steady, Fully-developed
velocity
profile
u
t
2 2
2 2
convective terms
1 u u p u u
u v
x y x x y
+ + = + +
_
Creeping
flow:
2
0 P =
=const.
( )
2
0 non-linear term
. 0
.
V
DV
P V
Dt
V
V
t
=
= +
,
,
,
,
,
2
V P V
= +
, ,
continuity 0 0 ( , , )
y-comp. 0 , 0 ( , )
x-comp.
u v w u
u u y z t
x y z x
P P
p p x t
y z
u u
u
t x
+ + = = =
= = =
+
v +
u
w
y
2
2
u P u
z x x
= +
2 2
2 2
2 2
2 2
Parabolic
u u
y z
u P u u
t x y z
+ +
= + +
Linear
differantial
equation
for
u(y,z,t)
Steady
flow
0
u
t
2
elliptic
1 P
u
x
=
_
Poisson
equation
basic
differential
equation
for
fully
devoloped
duct
flow.
Parallel
flow, v=w=0 , u0
Ex
U
I. Coutte
flows II.
Poiseuille
Flow
0
P
x
<
CREEPING FLOW:
Re<<1 , limiting
case
of very
large
viscosity
Full
N-s , for
=const. , =const. (steady
flow)
( )
( )
2
viscous force
2
.
. 0 (inertial force)
. 0
V
V V P V
t
V V
P V
V
+ = +
=
=
,
, , ,
, ,
,
,
2 2 2
2 2 2
p u u u
x x y z
= + +
Take
div(
.) of the
momentum eq.
2 2
2 2
2
.( ) .( ) =const.
.( ) ( ) 0
0 Laplace equation
P P V
V V
P
= =
= = =
=
,
, ,
VORTICITY TRANSPORT EQ:
2-D , vorticity-stream
function
formulation
, =const.
2 2
. 0 (1)
, - (2)
0 (1') Identical satisfied
V
u v
y x
x y y x
=
= =
=
,
Take
the
curl ( )
of the
2-D vector
momentum equation
( )
.
V
V V g
t
+ =
,
, , ,
( )
1
P
( )
2
V +
,
Let
V =
, ,
( )
2
. V
t
+ =
,
, , ,
2 2
2 2
2-D , 0
z x y
z z z z z
z
k
u v
t x y x y
v u
x y
= = =
+ + = +
=
, ,
2
2 eqs. 2 unknowns (u,v)
0
D
Dt
u v
x y
=
+ =
2 2
2
2 2
2
2
, formulation, 2-D , =const.
v u
x y x y
D
Dt
= = =
=
be vorticity
Vorticity
transport equation
Irrotational
flow
(inviscid) ,
0 V = =
, ,
2
2 2
2 2
0 Laplace eq.
Velocity potential V
.V 0 0
i j
x y
x y
=
= = +
= + =
, , ,
,
DISCRETIZATION of PDEs
1.
Finite
difference
methods
2.
Finite
volume
methods
3.
Finite
element methods
4.
Spectral
(element) methods
5.
Boundary
element methods
6.
...
Need
to
replace
a partial
derivative
with
a suitable
finite
difference
quotient
( , ) ?
u
u x y
x
Let
u
i,j
be a component
of velocity
at point
(i,j)
Taylor series
expansion
for
u
i+1,j
, expanded
about
u
i,j
( ) ( )
2 3
2 3
1, ,
2 3
,
, ,
= + + + ... (1)
2! 3!
i j i j
i j
i j i j
x x
u u u
u u x
x x x
+
+
Eq.(1) mathematically
an exact
expression
for
ui+1,j
if
1.
number
of terms
is infinite
2.
x0
i+1,j
i+1,j+1
i,j-1
i,j
i,j+1
i-1,j P
x
y
stencil
( )
lowest term in truncation error
3
2 3
1, ,
2 3
,
, ,
finite difference represent
truncation error
= ...
2 6
i j i j
i j
i j i j
u u x
u u x u
x x x x
+
_
_
1, ,
,
terms of order x
( )
i j i j
i j
u u
u
O x
x x
+
_
First-order
forward
difference
First-order
accurate/Forward
difference
Taylor series
expansion
for
u
i-1,j
, expanded
about
u
i,j
( )
( ) ( )
2 3
2 3
1, ,
2 3
,
, ,
= + + + ... (2)
2! 3!
i j i j
i j
i j i j
x x
u u u
u u x
x x x
+
, 1,
,
( )
i j i j
i j
u u
u
O x
x x
=
First-order
rearward
(or
backward) difference
Substract
eq.(2) from
eq.(1)
( )
( )
3
3
1, 1,
3
,
,
=2 +2 ...
3!
i j i j
i j
i j
x
u u
u u x
x x
+
+
1, 1,
2
,
( )
2
i j i j
i j
u u
u
O x
x x
+
= +
Central
difference
formula,
second-order
accurate
To
obtain
second
order
partial
derivatives, summing
eq.(1) & eq.(2)
( )
( )
4
2 4
2
1, 1, ,
2 4
, ,
=2 + + ...
12
i j i j i j
i j i j
x
u u
u u u x
x x
+
+ +
( )
( )
2
2
1, , 1,
2 2
,
2
= +
i j i j i j
i j
u u u
u
O x
x
x
+
+
Central
difference
formula
of second-order
accuracy
Similarly,
( )
( )
2
2
, 1 , , 1
2 2
,
2
= +
i j i j i j
i j
u u u
u
O y
y
y
+
+
Mixed
derivatives:
e.g.
differentiate
eq.(1) with
respect
to
y,
2
u
x y
( ) ( )
2 3
2 3 4
2 3
1, , , , ,
= + + ... (3)
2! 3!
i j i j i j i j i j
x x
u u u u u
x
y y x y x y x y
+
+
differentiate
eq.(2) with
respect
to
y,
( ) ( )
2 3
2 3 4
2 3
1, , , , ,
= - + ... (4)
2! 3!
i j i j i j i j i j
x x
u u u u u
x
y y x y x y x y
Substracting
eq.(4) from
eq.(3) yields,
( )
3
2 4
3
1, 1, , ,
=2 +2 ...
3!
i j i j i j i j
x
u u u u
x
y y x y x y
+
( )
( )
2
1. 1 1. 1
1,
2
1. 1 1. 1
1,
...
2
...
2
i j i j
i j
i j i j
i j
u u
u
O y
y y
u u
u
O y
y y
+ + +
+
+
= +
= +
Second
order
central
difference
for
the
mixed
derivative.
( ) ( )
2
2 2
1. 1 1. 1 1. 1 1. 1
1,
, ...
4
i j i j i j i j
i j
u u u u
u
O x y
x y x y
+ + + +
+
+
= +
Derived finite difference expressions represent just tip of the iceberg.
Higher-order
finite
difference
expressions
e.g. 4th order
central
difference
for
2
2
u
x
is
( )
( )
2
4
2, 1, , 1, 2,
2 2
16 30 16
12
i j i j i j i j i j
u u u u u
u
O x
x
x
+ +
+ +
= +
( )
2
2
2, ,
2
,
,
2
2
= + + +...
1! 2!
i j i j
i j
i j
x
u x u
u u
x x
+
i-2,j i-1,j i,j i+1,j i+2,j
x
Information
at five
grid
point
is required
to
form above
formula
Can be derived
by
represent
application
of Taylors
series
expanded
about
grid
points
(i+1,j) , (i,j) , (i-1,j)
What
about
at boundary?
y
3
2
1
boundary
2 1
1
( )
u u u
O y
y y
= +
Forward
difference
But only
first-order
accurate
Second-order
accuracy
is needed
Method
of undetermined
coefficients
(Polynomial
approach)
x
1
x
2
x
3
x
( ) ( ) ( )
1 2 3
1
u
au x bu x cu x
x
= + +
Forward-difference, one-sided
formulas
Up
to
2nd order
polynomialsexact
( )
( ) ( )
( ) ( )
1
1
2 1 3 1
2
1 1
1
Let ( ) 1 , '( ) 0 ,
0 (1)
( ) , 1
1 0
1 2 (2)
( ) , 2
0
u x u x
a b c
u
u x x x
x
b x x c x x
bh hc
u
u x x x x x
x
= =
= + +
= =
= + +
= +
= =
2 2
4 (3) h b h c = +
3 eqs.& 3 unknowns: a,b,c
(2) & (3)
1 2 3
1
2
1 2 3
1
1 2
, 4
2
3
2
3 4 1
( ) ( ) ( )
2 2 2
3 ( ) 4 ( ) ( )
( )
2
c b c
h h
a
h
u
u x u x u x
x h h h
u x u x u x u
O h
x h
= = =
=
= +
+
= +
( ) ( ) ( )
1 2 3
1
u
au x bu x cu x
x
= + +
Similarly
backward-difference
X
n-2
x
n-1
x
n
x
2
1 2
3 ( ) 4 ( ) ( )
( )
2
n n n
n
u x u x u x u
O h
x h
+
= +
Formulas can be extended for non-equidistance mesh intervals.
PARABOLIC EQUATIONS:
simplest
example
in Fluid
Mechanics
Stokes
1st & 2nd problem
U(t)
Fluid
=const.
Preferred
direction
1.
Time
i.e. evolving
flow
2.
A spatial
direction
e.g. boundary
layers, duct
flows
x
2
2
u u u
u v
x y y
+ =
Unsteady
motion
of an infinitely
extended
fluid
in response
to
an infinite
plate
suddenly
set in motion
along
its
own
plate.
Incompressible
N-S equations
reduce
to
2
2
, =
u u
t y
=
B.C: u(y,t=0)=0
u(y=0,t)=U(t)
u(y,t)0 (but in numerical
computations
space
coordinates
must
be finite)
Example:
Unsteady
1-D heat
conduction
equation.
2
2
, =
p
T T k
t y c
=
T
x
L
T
1
t
t=0
t
2
t
1
T
2
0 L
x
T(x,t) temperature
distribution
in a rod
of
length
L.
Boundary
Conditions
At t=0 u(x,t=0)=f(x) specified
For
t>0 :
a)
u(0,t)=g(t) , u(L,t)=h(t) ends
held
at specified
temperature
b)
One
end
could
be insulated
(0, ) 0 , or ( ) a specified heat flux
u
t f t
x
= =
1 1
( ) (0, ) ( ) (0, ) ( )
u
a t u t b t t t
x
+ =
c)
Problem is to
determine
u(x,t) for
t>0.
Solution
evolves
in time starting
from
some
initial
value
Marching
solution
with
respect
to
time.
Two
methods
of solution
a)
The
method
of lines
, reduce
Partial
Differential
Equations
to
a set of Order
Differential
Equations
b) Pure
finite
difference
methods
EXPLICIT METHODS
2
2
u u
t y
=
u
i+1,j
u
i+1,j+1
u
i,j-1
u
i,j
u
i,j+1
u
i-1,j
P
y
t
y
L
y
1
y
2
y
i
y
m
t
Previous
time
Present
time
FTCS
t
n
= nt
(uniform
time step)
FINITE DIFFERENCE METHODS (explicit, implicit)
PDE is replaced
by
finite-difference
equations
at the
grid
points
This
results
in algebraic
equations
called
difference
equations.
2
, 1 ,
2
,
,
( )
....
2
i j i j
i j
i j
O t
u u
u u t
t t t
+
= +
_
Forward-difference
in time
( )
2
1, , 1,
2 2
,
2
=
i j i j i j
i j
u u u
u
y
y
+
+
Second
order
central-difference
in space
( )
, 1 , 1, , 1,
2
2
= (A)
i j i j i j i j i j
u u u u u
t
y
+ +
+
difference
equation
After
rearragement
( )
( )
, 1 , 1, , 1,
2
= 2 (B)
i j i j i j i j i j
t
u u u u u
y
+ +
+ +
Difference
equation
(A) is just
an approximation
for
original
PDE due
to
truncation
error.
Note: Truncation
error
for
differential
equation
is
2
( , ( ) ) O t x
Consistency
of finite-difference
representation
of the
PDE as x0 & t0
differential
equation
reduces
to
original
differential
equations.
Present
time
Previous
time
i,j
i-1,j
i+1,j
i,j+1
t
Time-marching
direction
Properties
at level
(j+1) (present
time) to
be calculated
from
values
at level
j (previous
time) Remember
that
parabolic
PDEs
lend
themselves
to
a marching
solution, here
marching
variable
is time, t
Eq.(B) allows
direct
calculation
of u
i,j+1
from
the
known
values
on the
RHS of eq.(B)
Explicit
approach:
each
difference
eq. contains
only
one
unknown
and
therefore
can
be solved
explicitly
for
this
unknown
in a straight
forward
manner.
Comments
on this
method
Explicit
methods
can be very
unstable
and
should
be used
with
caution
In
general, whether
the
scheme
is unstable
or
not depends
on the
ratio,
( )
2
/ t y
For
a given
(y), t
must
be less
than
some
limit imposed
by
stability
constraints
Relatively
simple
to
set up
and
program
Von
Neumann
Stability
Method: (Fourier
method)
Assume
solution
can be expanded
in the
form of Fourier
Series
Let
,
Iik y
i j j
u U e
=
U
j
: amplitude
at t
j
and
k is the
wave
number,
1 I =
( ) 1
, 1 1 1
,
I i k y
Iik y
i j j i j
u U e u U e
+ +
= =
Substitute
above
into
finite-difference
representation
of PDE
( ) ( )
( )
1 1
1
2
I i k y I i k y Iik y Iik y Iik y
j j j j j
u e U e R U e U e U e
+
+
= + +
( )
( )
( )
, 1 , 1, , 1,
2
1
2 ,
1 2
i j i j i j i j i j
Ik y Ik y
j j
t
u U R U U U R
y
u U R e e
+ +
+
= + + =
= + +
For
a stable
solution
1
1 , ~
j aj t
j
j
U
U e
U
+
( )
1
:amplification factor
1
1
cos
2
1 2 1 cos
1 stable solution
Ik t Ik t
j j
j j
j
j
e e
k y
U U R k y
U U
U
U
+
+
+
+
=
=
=
=
_
1
1
j j
U U
+
> >
, i.e. amplitude
of solution
becomes
unbounded
as j
(time
goes
to
infinity)
( )
( )
2
1
1 2 1 cos 1
1 1 cos 0
1
1 cos
R k y
R k y
R
k y
_
cosky=-1 R1/2 (for
a minimum RHS)
( )
2
diffusion
1
2
t
y
_
stability
criterion
for
unsteady
heat
conduction
equations.
Von
neumann
stability
method
ignores
boundary
conditions
Effect
of B.C. can be destabilizing
Other
Explicit
methods:
1.
FTCS method
( )
2
, O t x
2.
Richardson
method
Central
difference
in both
time&space
derivatives
( )
, 1 , 1 1, , 1,
2
2
=
2
i j i j i j i j i j
u u u u u
t
x
+ +
+
u
i,j+1
u
i+1,j+1
t
j-1
u
i+1,j
u
i,j-1
t
t
j
t
j+1
x
i-1
x
i+1
x
i
If
i know
solution
on t
j
& t
j-1
have
explicit
formula
( )
( )
, 1 , 1 1, , 1,
2
2
= 2
i j i j i j i j i j
t
u u u u u
x
+ +
+ +
( ) ( )
2 2
, O t x
Approximate at xi
, tj
Notes:
n methods like this must keep
time step (t) uniform
Starting
formula
Stability
analysis
UNCONDITIONALLY UNSTABLE CANNOT BE USED TO
SOLVE HEAT EQUATION. AVOID THIS
3.
DuFort-Frankel
method
Variant
of Richardson
in which
( )
, , 1 , 1
1
=
2
i j i j i j
u u u
+
+
for
stability
( )
( )
( ) ( ) ( )
( )
1, , 1 , 1 1,
, 1 , 1
2
, 1 , 1 1, 1,
2 2 2
=
2
2 2 2
1 1
i j i j i j i j
i j i j
i j i j i j i j
u u u u
u u
t
x
t t t
u u u u
x x x
+ +
+
+ +
+ +
+ = + +
Notes:
1.
Method
is unconditionally
stable, i.e. for
any
value
of
( )
2
t
R
x
2.
Requires
two
time levels
of storage
& uniform
time step
One
step method, starter
solution
(FTCS) can be used
3.
Can be dangerous
without
a consistency
analysis
Consistency
requires
that
as the
step sizes
x & t
0 , FDE must
reduce
to
original
PDE
( ) ( ) ( )
1 1
1 1
2 2 2
2 2 2
1 1 ( )
j j j j
i i i i
t t t
u u u u
x x x
+
+
+ = + +
Show time level
as superscript
( ) ( )
( )
2 2
2 2 2
2 2
2 2
2 2
1 ... 1 ...
2!
2
...
2!
j j
i i
j j
i i
t u u t t u
u t u t
t t t
x x
t u u x u
u x u x
x x x
x
+ + + + = + +
+ + + +
( ) ( )
( )
2 2
2
2 3 2
2 2 2 2
2
2 2
2 2
2 2
( ) ( , )
( , )
u t u t u
t t O t x O t x
t t x
x x
u t u u
O t x
t x t x
+ + = +
+ = +
Consistent
only
if
2
2
2 2
2
, ,
u u t
O t x
t x x
= +
0 as , 0
t
x t
x
Otherwise, I am
not approximating
the
eq. I thought
I was
1
t
x
then
approximating
2 2
2 2
u u u
t t x
+ =
represents
a hyperbolic
equation!
Show that
explicit FTCS
method
is consistent!
IMPLICIT METHODS:
In
implicit
method
information
at the
boundaries
at the
same
level
does
not feed
into
the
computation.
First-order
backward
difference
approximation
for
time-derivative
and
second-order
central
difference
approximation
for
space-derivative
( )
1, 1 , 1 1 1 , 1 , ,
2
2
= (1)
i i j i j j i i j j
u u u u u
x
t
+ + + + +
+
Present
time-unknown
Previous
time-known
i,j
i-1,j+1
i+1,j+1
x
i
BTCS Method
In
equation
(1):
3 unknowns
u
i-1,j+1
, u
i,j+1
, u
i+1,j+1
Thus, it results
in a set of coupled
finite
difference
equations
all
grid
points
Rearrange
equation
(1)
( )
( ) ( )
1 1
2
1 1
2 2
1
1 2
i
i i
i
j j j
i i i i
j
d
c b
a
t t t
u u u u
x x x
+
+ + +
+ + =
_
3 unknowns
in each
FDE
Algebraic
equations
Coefficient
matrixTridiagonalThomas
algorithm
(n-1) unknowns
i,j+1
Advantages
( )
( )
2 2
1 1
1
1
1
1 2 2 1
i i
i
i
j j j j
i i i i
c b
d
a
x x
u u u u
t t
+
+ + +
+ + =
_
Now, all
the
u
j+1
s are
known
except
those
at the
end
points
u
0
, u
n
(known
from
B.Cs)
Identical
formulation
as in the
BVP is applicable
Notes:
1.
Derivative
B.C. can be inferred
from
the
section
on BVPs
2.
Stability
problem is removed
for
this
scheme
and
the
method
is stable
for
all
values
of R (unconditionally
stable)
3.
Accuracy
problem exists
in time backward
difference
( )
2
, O t x
4. Larger
step size in time is permitted
Crank-Nicolson
Method:
Approximate
differential
equation
at (i,j+1/2);
central
difference
at time levels
j & j+1,
( ) ( )
1 1 1 1
1 1 1 1
2 2
2 2 1
=
2
j j j j
i
j j j j
i i i i i i i
u u u u
t
u u u
x x
u
+ + + +
+ +
+ +
+
1
2
2
j j
i i
u u u
t
t
+
=
central
difference
of step t/2 , i.e. (t)
2
t/2
t/2
x x i
(i,j+1/2)
j+1
j
j+1/2
x
i
Present
time
(unknown)
Previous
time
(known)
Unconditionally
stable
( )
2 2
( ) , ( ) O t x
Second
order
scheme
( ) ( )
2 2
1
1 1 1
1
1
1
known
2 2 2 2
j
j j j j
i i i i i i
j j j
i
d
x x
u u u u u u u
t t
+ + +
+ +
+ + = +
_
TDMA-Thomas
Algorithm
Parabolic
equations
in two-space
coordinates
2 2
2 2
const.
u u u
t x y
= + =
u(x,y,t)
y
x
On each
portion
of boundary,
we know
I.u
u
n
u
A Bu
n
II.
III.
i,j
i,j
i,j+1
i,j+1
i+1,j
i-1,j
(n)
previous
(n+1)
present
t
x
y
( ) ( )
1, , 1, , 1 , ,
2
1
, , 1
2
2 2
=
n n n n n n
i j i j i j i j i j i j
n n
i j i j
u u u u u u u
x y
t
u
+
+ +
+ +
+
2 2
, ( ) , ( ) O t x y
Stability
analysis
:
( ) ( )
2 2
1
2
t t
x y
+
( )
2
1
4
t
x y
x
+ + + +
( )
2
1
4
t
x
upper
limit
( )
2
1
4
t
x
, 1, 1, 1
1
, , 1
1
=
4
n n n n
i j i j i j i j i j
n
u u u u u
+ +
+
+ + +
Five-point
formula
time
Time accurate
solution
Steady
state
u
i,j
Valid
solution
at any
intermediate
level
Implicit
Method: Crank-Nicolson
n
n+1
t
*
, ,
2
central difference eq. of step t/2
( )
i j i j
u u
u
O t
t t
= +
_
1
, ,
*
, ,
unknown (present)
known (previous)
n
i j i j
n
i j i j
u u
u u
+
=
=
i,j
i-1,j
i+1,j
x
y
i,j-1
i,j+1
( ) ( )
( ) ( )
* * *
2
1, , 1, , 1 , 1,
2
2 2 2
* * *
2
, 1 , , 1 , 1 , , 1
2
2 2 2
2 2
1
( )
2
2 2
1
( )
2
i j i j i j i j i j i j
i j i j i j i j i j i j
u u u u u u
u
O x
x
x x
u u u u u u
u
O y
y
y y
+ +
+ +
+ +
+ +
+ +
+ +
( )
( )
( )
( )
2
1, 1, , 1 , 1 ,
2
* * * * *
1, 1, , 1 , 1 ,
2
2
2 2
2
2 2
where is the ratio of step sizes
i j i j i j i j i j
i j i j i j i j i j
x
u u u u u
t
x
u u u u u
t
x
y
+ +
+ +
+ + + + + =
+ + +
Coefficient
matrix
is pentadiagonal (5 unknowns
in one-algebraic
equation.)
Solve:
1.
Gauss-Seidel
, SOR (iteration) , iterate
until
convergence
at each
time step
2.
Alternating
Direction
Implicit
(ADI)
Alternating
Direction
Implicit
(ADI) Method
2 2
2 2
Marching technique (1)
u u u
t x y
= +
u(t+t) will
be obtained, in some
fashion, from
the
known
values
of u(t)
Lets
use
two-step process: first
treat
only
x derivative
implicitly
Step 1:
( ) ( )
1/ 2 1/ 2 1/ 2 1/ 2
, , 1, , 1, , 1 , , 1
2 2
2 2
= (2)
n n n n n n n n
i j i j i j i j i j i j i j i j
u u u u u u u u
t
x y
+ + + +
+ +
+ +
+
Equation
(2) reduces
to
the
tridiagonal
form
(n+1/2) : intermediate
time
( ) ( )
( )
( )
1/ 2
2 2
, , 1 , ,
1/ 2 1/ 2
1 , 1,
1
,
2
(2')
where
, 1
2
2
2
i i i
n n n n
i i j i
j j
n n n
i i i i i i i
j i i j
j
j
t t
b c a
x x
t
d u u u u
u c u d
y
bu a
+
+ + +
+
= = = +
=
+
+
+ =
Eq.(2) yields
a solution
for
1/ 2
,
n
i j
u
+
for
all
i, keeping
j fixed, via
Thomas Algorithm
In
Eq.(2) first set j=1, and sweep
in x (i=1,...,N)
to
find
1
1/ 2
,
n
i j
u
+
=
....
M
sweeps
in x-direction
Need
to
use
Thomas Algorithm
M
times
Next, set j=2,
and sweep
in x (i=1,...,N)
to
find
2
1/ 2
,
n
i j
u
+
=
x
(i,j)=(N,1)
j
j+1
(i,j)=(N,M)
(i,j)=(1,1)
(1,M)
Sweep
direction
At this
place
eq.(2)
gives
u
i,j
n+1/2
y
t
t/2
n+1/2
n
At the
end
of step1 (after
M sweeps), the
values
of u at the
intermediate
time (t+t/2)
are
known
at all
grid
points: i.e.
1/ 2
,
n
i j
u
+
is known
at all
(i,j)
Step 2:
Take the solution to the time (t+t), using
the
known
values
at time (t+t/2)
Again
replace
spatial
derivatives
with
central
differences, but this
time treat
y
derivative
implicitly
( ) ( )
1 1/ 2 1/ 2 1/ 2 1/ 2 1 1 1
, , 1, , 1, , 1 , , 1
2 2
2 2
= (3)
n n n n n n n n
i j i j i j i j i j i j i j i j
u u u u u u u u
t
x y
+ + + + + + + +
+ +
+ +
+
Eq.(3) reduces
to
the
tridiagonal
form
( ) ( )
( )
( )
2 2
1/ 2 1/ 2 1/ 2 1/ 2
, 1, , 1,
1 1 1
, 1 , , 1
2
(3')
where
, 1
2 2
2
2
n n n
j j
j j j
n n n n
i i i
j i j i j i
j j j j j
j i j
t t
b c a
x x
b u
t
a u c u d
d u u u u
x
+ +
+ + + +
+
+
+
= = = +
= +
+ + =
yields
a solution
for
1
, i
n
j
u
+
j=1,....,M i=1
j=1,....,M
i=2
:
.........
i=N
N
times
Thomas Algorithm
for
all
j, keeping
i
fixed, via
Thomas Algorithm
x
(i,j)=(N,1)
i i+1
(i,j)=(N,M)
(i,j)=(1,1)
(1,M)
Present
time
y
t
t/2
n+1
n+1/2
Sweep
direction
Remarks:
Involves
only
tridiagonal
forms
Alternating
direction
implicit
Scheme
is second-order
accurate
General class
of scheme
involving
splitting
of two
or
more
directions
in an implicit
solution
of the
governing
flow
equation
to
obtain
tridiagonal
forms
Approximate
factorization
For
3-D, see
the
scheme
in Computational Fluid Dynamics for Engineers Vol.1
Klaus
A. Hoffmann
& S.T. Chiang
pg.90
Approximate
Factorization
-
Factored
ADI Method
2 2
2 2
=1
u u u
t x y
= +
Sweep
2 directions
Crank-Nicolson
u
i,j
*
u
i,j
{ } { }
( ) ( ) ( )
*
2 2 2
, ,
2 2 * 2 2 *
, , , ,
2 2
2
, 1, , 1,
2
, , 1 , , 1
2 2
,
2 2
2
2
1 1
, ,
2 2
where
2
compact operators
2
1
2
1
2 2
i j i j
x i j x i j y i j y i j
x i j i j i j i j
y i j i j i j i j
i j y x x
u u
u u u u O t x y
t x y
u u u u
u u u u
t t t
u
x y x
+
+
= + + + +
= +
= +
=
+ +
2 *
,
2
2
y i j
t
u
y
( )
2
2
2
2
2 2
2 2
,
,
2 2 *
,
2 2
2
2
2
Let 1
2 2
(
1
1 1
2
) 1
1
2 2
2 2
x
x y
x y i j
x y
i j
i j
t t t
x
O t
t
y
t t
u
t
y x
x y
u
u
x
= +
+ +
Eq.(1) defines
a set tridiagonal
matrix
problems
along
constant
y lines
x
y
, ,
2
2
2
2
( 1 )
y i j i j
t
y
u u
=
Sweep
on lines
of constant
x
x
y
Notes:
1) Use
eq.(2) to
find
values
of
u
2)
Can reverse
order
of sweep
3)
No iteration
4)
Can be extended
to
higher
dimensional
problems
Above method is called Approximate Factorization
on vertical
boundaries
where
u
i,j
known
from
B.C.s
Keller Box
Scheme
Implicit
scheme
for
non-uniform
meshes
x
u
t
1
Initially
boundary
layer
near
x=0 for
small
t
Small
meshes
near
x=0
Uniform
meshes
in x is wasteful
To
deal
with
problem, 2 procedures is possible
I. Algebraic
transformation
a
x =
& then
use
uniform
mesh in
x
t
=
II.
Adopt
a method
which permits
a non-uniform
spacing
1 1
1 1
i=2,...,N
0 , 1
i i i
N
x x h
x x
+
= +
= =
x
1
x
2
x
3
x
4
h
1
h
2
h
3
x
i
x
i-1
h
i-1
x
1 2
Sample
problem
2
2
u u
x t
=
PROCEDURE
Reduce
the
eq(s) to
a first
order
system
& write
finite
difference
equations
using
central
differences
Linearize
if
they
are
non-linear
Obtain
matrix
for
TDMA
Solve
with
Thomas Algorithm
LOWER BOX
* *
( ) ( )
( )
2
-1
-1/ 2 -1 -1
-
-1 -1
-
1
1
, =
1
2
(1)
2
(2)
(3)
i i
i i i i
i i
i
i
i i
v v u u
u v u
v
x x t
u u
v v v O
h
or
h
h
=
= = + +
+ =
Approximate
eq (2)
at box
center
( )
*
1 1
1
2
box center
, 1/ 2 1, 1/ 2 1/ 2, 1/ 2, 1
-1
i i
v v
i j i j i j i j
i
v v u u
h k
+
=
Using
simple
averages, i.e.
( ) ( )
* * *
1
*
1 1 1 1
*
, 1/ 2
1 1
1 1
2 2
(4)
1 1
2 2
i i i i i
j j
i j i
i i i
i
i
i
i
i
v v
v v v v u u u u
h h k
v v v
+
= +
+ =
= +
Approximate
eq (1)
at
*
Eliminate
v
i-1
using
(3)
( )
( )
* * *
* *
1 1
1 1
2 2
1 1 1 1
2 2 2 2
i i i i i i
i i i i
i i i i
v v u u u u
u u u u
h h h h k
+ =
Upper
Box
i+1
i
h
i 1 2
k
Same
type
of approximations
& eliminate
v
i+1
( )
( )
* * *
* *
1 1
1 1
2 2
2 2 2 2
i i i i i i
i i i i
i i i i
v v u u u u
u u u u
h h h h k
+ +
+ +
+
+ =
Eliminate
v
i
( ) ( )
( ) ( )
( ) ( )
* * * *
1 1 1 1
1 1
* * * *
1
1 1 1 1
2 2 2 2
i i i i i i i i
i i i i
i i
i i i i i i i i
u u u u u u u u
h h h h
h h
u u u u u u u u
k k
+ +
+ +
=
+ + +
Multiply
by
h
i
/2 and
let
( ) ( ) ( )
1
1 1
1
1
* * * * * * * *
1 1 1 1 1
ratio of sizes , & system becomes
2
1 ,
1
i i
i
i i i i
i i
i
i
i
i
i i i
i i i i i
i i i i i
i i i i i i i i i i i i i
h h
h k
u u u
h h
h h
u u u u h u u h u
b a c d
b c
a
d u
+ +
= =
+ + =
= =
=
= + + +
Thomas Algorithm
Selection
of Mesh:
Intense
variation
near
x=0
Small
mesh near
x=0
h1
=h
& progressively
increase
( )
1
1 2,..,
i
i i
h h i N
= + =
0.02 =
is small, e.g.
1
i
= = +
L
N+1
U
N+1
U
1
( )
2
1 h h = +
3
h
N
h
( ) ( )
1
2 1
3
given
1 ...., 1
N
N
h h
h h h h
=
= + = +
( ) ( ) ( )
( )
{ }
2 1
1 1 ... 1
3 paramet
1 1
ers h, ,N
N
N
L
h
L
h h h h
=
= + + + + + + +
+
Select
h,
such
that
if
you
double
N, you
can compare
two
solutions!
Additional
Features
of Linear
Equations
{ }
* ** * * * ** * * **
* **
1 1 1 1 1 1 1 1
2 2
** **
2
2
** *
*
2 2
2 2 2 2 2
e.g. ( , )
/ 2
=kno
( , ) (
wn
, ) ( , )
time
( ,
leve
)
l
i
i i i i i i i i i i i i i i i
i i
i i
u u u u u u u u P u u u u r
u u F
k h h
u u u
x t p x t r x t
h h
x t
t t
u
k
F x t
t x x
t
t
+ + + +
+ +
= + + + + + +
= + + +
=
+
=
**
=intermediate time level
Tridiagonal
form
2
** ** ** 2 **
1
**
1
**
2
, 2
2 2
, ...
2
i i i i i i
i i i
i i i i i i i
i
h h
b p a h r
bu a u c u
h
c p d
d
+
= + =
+
+
=
+ =
=
k/2
k/2
h h i
(i,j+1/2)
j+1
j
j+1/2
x
i
DERIVATIVE BOUNDARY CONDITIONS
1
( ) x=1 & (0, )
u
g t u t A u
x
= = =
N+1
N
N-1
N-2
t
t
*
x=1
1 1 2
11 18 9 2
( )
6
N N N N
u u u u
g t
h
+
+
=
Same
procedure, with
Thomas algorithm, as in boundary
value
problems
( ) ( )
{ }
2 1 2 1 2 2
1
1 1 2
6 ( ) 18 9 2 9 2
11 18 9 2
N N N N N N N
N
N N N N N N
hg t F F F F
u
F F F F F F
+
+ + +
=
+
Non-linear
Parabolic
Equations
Example: Boundary
layer
type
of equation
Burgers
equation
2
2
u u
x
u
u
x t
=
REMARKS
We prefer
Crank-Nicolson
scheme
Difference
equations
we
must
solve
at
each
time step are
non-linear
Cannot
be solved
directly, need
to
linearize
them
and
iterate
at each
time step until
convergence
Need
to
take
reasonably
small
steps
in time to
ensure accuracy
The
solution
at the
previous
time step provides
a convenient
first
guess
for
the
solution
{ } { }
* * * * * *
1 1 1 1 1 1 1 1
2 2
*
2
2
* * * * *
**
**
**
**
** *
1 1 1 1
2 2 1 1
2 2 2 2
2
1
2
2 2
1
2
2 2
2 2
i
i
i i i i i i i i i i i i
i i
i
i
i
i i i i i i
i
i
i
i
u u u u u u u u u u u u
k h h h h
u u
h
b
h
a
k
h
c
h h
d u
u
u
u
u u u u u
u
u
+ + + +
+ +
+ +
= + +
+
=
=
=
= +
= +
u
i,j
*
u
i,j
k
Crank-Nicolson method
Notes
on non-linear equations
1.
Non-linear
diff. eqs. must
be iterated
at each
time step
2.
At first
pass
** *
i i
u u =
3. Error test
1
1
k
i
k
i
u
u
+
<
Typically 2-3 steps to satisfy iteration since k is small.
Newton Linearization
( )
( )
( )
( ) ( )
1 1
1 1
1 1 1 1
1 1
1
*
1
*
*
*
*
2
2
4
previous iterate
to start computation: set
2
i i
i i
i i i i
i i
i
i i
i i
i i
i i i i
i
i i
h
u u
h
u u
h
u u u u
u u u u u u u
u
u u
u u
u
u
u u
+
+
+ +
+ +
+ +
+
=
= +
= + +
Upwind-Downwind
Differencing
* * * 2
1 1 1 1
2 2 2
**
1 1
2 2 1
2
if we use .... problem with diagonal dominance
2
i i i i i i
i i
i
u u u u u u u
x h h
u u
u
h
+ +
+
+ +
= +
+
2
2
2
2
*
1
, Re 1
Re
=Re
Re
i i
u u
t x
t
u u
u
u
x
u
u
x x
u u u
k
+ =
=
=
>
k/2
k/2
h
h i
(i,j+1/2)
j+1
j
j+1/2
x
i
Present
time
(unknown)
Previous
time
(known)
i+1
i-1
i
i-1/2
average
on here
k
h
*
*
2
1/ 2 1/ 2
* *
2 2
1 1
1
( )
2
1
( , )
2
i i
i i i i
u u u
O k
x x x
u u u u
O h k
h h
+
+
= + +
= + +
For
**
0
i
u >
If
**
0
i
u <
* *
2 2
1 1
1
( , )
2
i i i i
u u u u u
O h k
x h h
+
= + +
Difference
equations
can be written in the following form:
2
1
**
1 1 1
1
* *
2
* * * ** 1
1 1
* *
1
**
**
0
0
2 2 Re
for
2 2 Re
for
i i
i i i i
i i
i i i
i i i
i i
i
i
u u
h
u u u h u
u u k
u u
h
u u u h u
k u
u
u u
+ +
+
+
+
+ +
= + +
>
<
i-1/2
average
on here
h
i+1
i-1
i
k
*
i+1/2
Notes:
1.
At each
time step it may
be necessary
to
average
( )
( 1) ( 1/ 2) ( )
1 0< <1
k k k
i i i
u u u
+ +
= +
2.
Inviscid
form (Re) can develop
sharp
fronts
& multiplicity
of solution
u
x
u
u
x x
t
0
< t
1
< t
2
Viscous form acts to prevent this!
2
2
neglect
1
Re
u u P u
u v
x y x x
+ = +
2
2
2
2
1
Re
u
y
u u u P
u v
x y y x
=
& march
in x-direction
3. Parabolized
Navier-Stokes
eqs. preferred
direction
in space
Factor
Algorithm
for
Navier-Stokes equations
{ } { }
{ } { } ( )
( )
2 2
2 2
*
, ,
2 2 * 2 2 *
, , , ,
2 2
1 2
** ** **
* * * **
, , , , , ,
1 2
** *
( , , , ) etc.
1 1
2 2
4 4 2
1
estimate
2
i j i j
x i j x i j y i j y i j
x x i j x x i j y y i j y y i j i j i j
u u u u u
p q ru w
t x y x y
p p u x y t
u u
u u u u
k h h
p Q R
u u u u u u w
h h
p p p
= + + + + +
=
= + + + +
+ + + + + +
= +
Multiply
by
2k & rearrange
** **
** 2 2
,
2 2
1 1 2 2
** **
** 2 2 * **
,
2 2
1 1 2 2
**
2 ** 2 **
1 2
, ,
2 2
1 2
2
2 2
2 2
2 2
1
if
2
1
2 2
x x x y y y i j
x x x y y y i j
x x x y y y i j i
k kP k kQ
kR u
h h h h
k kP k kQ
kR u kw
h h h h
kR
h h k k
P Q u D
h h
=
+ + + + + +
=
+ + =
{ }
2 2 **
2
2
2
2 **
**
1
2
1
2 **
1
2
1
** * **
, ,
, ,
,
1/ 2
1
1
2
,
1
,
1
2
1
2
1
2
2 .... 2
F
1
ac r
2
to
j
i j i j
i j i j x x x
x i j
n
i
x
j
y y y
y y y
n
i j x
h k
D kR u kw
u D Q
h
h k
Q
h k
P
h
h k
P
h
u D
u
h
u
+
+
+
+
+
= + + +
=
=
1/ 2
,
n
i j
+
Iterate
Solved in a manner similar to
diffusion equation
ELLIPTIC PROBLEMS
Steady
state
heat
conduction
equation
Velocity
potential
eq. & stream
function
eq.
for
incomp.,
inviscid, irrotational flow
Typical
Elliptic
equations
2 2
2 2
0
u u
x y
+ =
Poissons
eq.
2 2
2 2
( , )
u u
f x y
x y
+ =
Types
of Eqs.
1.
Linear: Laplace, Poisson
2.
Non-Linear
a. Linear
PDE with
non-linear
BCs
e.g.
( )
2 4 4
u
0 on C
n
u D u T
= =
b. Non-Linear
PDE
e.g. Navier-Stokes
2 2
2 2
non-linear
1
Re
u u P u u
u v
x y x x y
+ = + +
_
Laplaces
eq.
Nature
of Solution
a)
Any
disturbance
at a point
P influences
the
solution
everywhere
always
necessary
to
consider
solution
globally
in
well
posed
elliptic
problems, BCs
needed
on all
boundaries
x
y
C
b)
Singularities
Discontinuation
in the
BCs
are
smoothed
out
in the
interior. No discontinuous
behavior
in interiour: only
in boundary
data
No propagation
into
interior
P
T
1
T
0
T
0
Temperature
is smooth
&
continuous
e.g. heat
transfer
c)
Maximum
prensible
For
Laplace
eq. extrama
of function
must
occur
on boundary
T
1
T
2
T
3
T
4
T
0
< T
1
< T
2
< T
3
Then, there
is no T in interior
with
T <
T
0
; T > T
3
Domain Methods: Finite
Difference
& Finite
Element Methods
Boundary
Integral
Methods
Finite
Difference
Formulations:
Start by
considering
the
case
where
u is known
on boundary.
Five-point
formula
second
order
accurate.
Split
x interval
into
N equal
points
& y into
M equal
points.
x
y
(1,M+1)
(N+1,M+1)
(1,2)
i=1
2
3
i
N
N+1
y
x
i,j+1
i+1,j
i,j-1
i,j
i-1,j
Let us use second
order accurate, central
differences at point i,j
( )
2
1, , 1, , 1 , , 1 ,
2
,
1, , 1, , 1 , , 1
,
2 2
2
( , )
( , )
2
2
2
( 2 ) 1
i j i i
i j i j i j i j i j i j
i
i j i j i j i j i j i j i j
j
u f x y
f f x y
u u
u u
u u u u
f
u u u u
h
h f
k
h
k
+ +
+ +
+ + + =
=
=
+ +
+ =
=
Total of (M-1) x (N-1) eqs.
Typically
10000 such
eqs. & up
1 of u is known
2 are
known
: ratio of step sizes
Solution
Algorithms:
a)
Direct
methods
b)
Iterative
methods
a)
Eq.(1) is not
tridiagonal
can
be solved
with
general G.S. elimination
based
on partial
pivoting, or
special
algorithm
which
takes
into
account
banded
structure
of matrix.
but
substantial
amount
of computation
in forward
elimination
& back
substitution
at
around
3000-5000 becomes
non-comptetive
with
iterative
methods.
Therefore, usually
use
iterative
methods
with
elliptic
eqs.
ITERATIVE METHODS:
Simple
& easy
to
program
A.
Jacobi
iteration
Rewrite
eq.(1)
( )
2
, , 1, 1, ,
( 1) ( ) ( ) ( (
1 ,
) )
1
1
:iteration count
)
er
(2
2 1
i j i j i j i j i j j
k k k k k
i
u h f u u u
k
u
+ +
+
= + + + +
+
Prodecure:
1.
Guess
u
i,j
at every
point
(k=0) (initial
guess) u
i,j
(0)
i=2,..,N , j=2,..,M
2.
Apply
(2) at every
point
in the
mesh u
i,j
,
use systematic
sweep
of mesh
3.
Continue
until
convergence
( )
,
( 1)
,
1
k
i j
k
i j
u
u
+
<
for
all
i,j
e.g.
4
10
=
4 significant
figures
Notes:
1.
Process
is not used
in practice
because
it is too
slow
th
,
, , ,
,
,
( 1) ( )
, ,
: error at n iteration
: estimate
: true value
( )
( ) : modulus of largest eigenvalue of iteration matrix. ( ) 1
n
i j
n n
i j i j i j
n
i j
i j
n n
i j i j
e
e u u
u
u
e J e
J J
+
=
<
For
equal
mesh lengths
h=k
rectangular
regions
& Poissons
eq.
1
( ) cos cos
2 1 1
J
N M
= +
+ +
i.
For
coarse
meshes, (J) is smaller
Fast
convergence
(but not necessarily
correct
answers)
ii.
Smaller
meshes
1
(M, N)
Slow
convergence
with
finer
meshes
B) GAUSS-SEIDEL
ITERATION
Current
values
of u is used
Sweeping
on lines
of constant
x in +y
direction
i,j
i+1,j
i,j-1
i-1,j
i,j+1
green
dots have been computed, therefore use most recent
information
( )
( 1) ( 1) ( 2
, , 1, 1,
( ) ( )
, 1
1
, 1
)
1
(3)
2 1
i j i j i j i j i j i
k
j
k k k k
u h f u u u u
+ + +
+ +
= + + + +
+
Note:
1.
No need
to
hold
previous
iterate
in core
2.
Method
is much
faster
than
Jacobi
h=k , rectangular
regions, Poisson
eq.
( ) ( )
2
G J =
Analogy
between
the
iterative
method
& time dependent
parabolic
equation
2-D unsteady
heat
conduction
2 2
2 2
u u u
t x y
= +
Remember the
Explicit
formulation:
FTCS
Let
x=y ,
( )
( )
1
, , 1, 1, , 1 , 1 ,
2
1
, 1, 1, , 1 , 1
2
t
4
x
t 1
upper limit
4
x
(A) FTCS app
1
4
rox. of a parabolic eq.
n n n n n n n
i j i j i j i j i j i
n n n n n
i
j i j
j i j i j i j i j
u u u
u u u u u u
u u
u
+
+ +
+
+ +
= + + +
= + + + +
Now, Jacobi
iteration
2
ij
1 , f 0
h
k
= = =
1
, 1, 1, , 1 , 1
(B) Jacobi iteration for an elliptic eq
4
.
1
k k k k k
i j i j i j i j i j
u u u u u
+
+ +
= + + +
Mathematically
(to
the
computer) the
same
but the
different
physical
phenomena
Thus, some
techniques
used
for
parabolic
eqs. can be extended
or
modified
for
elliptic
equations
u
i,j
Steady
state
Time
accurate
solution
Time
Eq.(A)
Solution
is valid
at any
intermediate
time level
if
imposed
initial
data & time step
represent
physics
u
i,j
Steady
state
Number
of iterations
Eq.(B)
Intermediate
solution
of eq.(B)
has no physical
significance
converged, or steady-state
solution
C) SUCCESSIVE
OVER RELAXATION (SOR)
Usually
faster
than
G.S for
linear
problems
Gauss-Seidel
iteration
( )
( )
( )
( )
( )
( 1) 2 ( ) ( 1) ( ) ( 1)
, , 1, 1, , 1 , 1
( ) ( )
, ,
( 1) ( ) ( ) ( 1) ( ) ( 1) ( )
, , 1, 1, , 1 , 1 ,
1
2 1
adding - to RHS & collect terms
1
2 1
2 1
k k k k k
i j i j i j i j i j i j
k k
i j i j
k k k k k k k
i j i j i j i j i j i j i j
u h f u u u u
u u
u u u u u u u
+ + +
+ +
+ + +
+ +
= + + + +
+
= + + + + +
+
( ) ( 1)
, ,
(as solution proceeds)
k k
i j i j
u u
+
To
accelarate
the
solution, the
bracket
term
is multiplied
by
,
relaxation
parameter
(factor)
( )
{ }
1
, ,
(*)
2 1
k k
i j i j
u u
+
= +
+
For
convergence
0<<2
If
0<<1
under-relaxation
(some
non-linear
problems)
(iterative
averaging
0.5)
=1
: Gauss-Seidel is
recovered
Rearrange
eq.(*)
( )
( )
( )
{ }
1 2 1 1
, , , 1, 1, , 1 , 1
1
2 1
k k k k k k
i j i j i j i j i j i j i j
u u h f u u u u
+ + +
+ +
= + + + + +
+
1<<2
over-relaxation
(best
for
linear
problems)
1.65
Method
of Estimating
opt
opt
is related
to
spectral
radius
of Gauss-Seidel
matrix
by
( )
( )
1/ 2
2
1 1
opt
G
=
+
Esimate ( )
G
by
performing
a large
number
of G.S iterations
& estimate ( )
G
from
( )
( )
( 1)
( ) 1
, , ,
lim
k
k
k
k k k
i j i j i j
d
G
d
d u u
=
=
,
,
1
, ,
k k
i j i j
i j
d u u
=
,
( )
2
1
, ,
k k
i j i j
i j
d u u
=
,
i.
ii.
Special
case
Rectangular
domain subject
to
Dirichlet
BCs
with
constant
step sizes
2
cos cos
2 2 1
,
1
opt
a
N M
a
a
+
= =
+
Derivative
Boundary
Conditions
Conduction
heat
transfer
*
given 0 insulated
specified heat flux
u u
n n
u
k q
n
=
( )
* *
convection conditions
u
k h u u
n
i.
ii.
Example:
suppose
convection
on right
face.
h, u
x = a = x
N+1
(N+1,M+1)
( )
* *
* *
on x=a
=
u
k h u u
n
u u
k h
n
Simplest
method:
Approximate
eq. at nodal
points
on boundary
(xa-)
At interior
nodal
points
on x = a , j=2,...,M but not at corners
j = 1&M+1
{ }
( )
2
, 1, 1 1, 1 1, 2,
2
2 1 (4)
N j N j N j N j i j j N
u u u u h f
h
k
u
+ + + + +
+ + + + =
=
Derivative
condition
is also valid at x=a,
i.e., i=N+1
(on
boundary)
{ }
2, ,
* *
1,
(5)
2
N j N j
N j
u
k h u u
h
u
+
+
=
Use
eq.(5) to
eliminate
2, N j
u
+
in eq.(4).
{ }
( )
2
, 1, 1 1, 1 1,
*
*
2 2 2 2 2 (6)
N j N j N j N j ij
u u u h u h u h f
h
k
+ + + +
+ + + + = +
=
Computational
Algorithm:
Sweep
interior
points
(G.S) as before
plus
additional
sweep
on right
face
( )
( )
{ }
2
1, , 1, 1 1, 1
1
2 2 (7)
2 2 2
j=2,..,M
N j N j N j N j ij
u u u u h u h f
h
+ + + +
= + + +
+ +
Notes:
1.
simplest
method
but inaccurate
2.
additional
sweep
on any
face
where
derivatives are specified
3.
for insulated
boundary simply set =0
4.
special care is needed for conditions
on adjoining
edges
1,M+2
2,M+1
1,M
1,M+1
0,M+1
Insulated
condition
u
0,M+1
= u
2,M+1
(8)
Convective
condition
( )
1, 2 1, 1, 1
2 0 (9)
M M M
u u h u u
+ +
+ =
Approx. to
differential
eq. at (1,M+1)
( )
2
2, 1 1, 1 0, 1 1, 1 1, 1 1, 1, 1
2 2 (10)
M M M M M M M
u u u u u u h f
+ + + + + +
+ + + =
Eliminate
0, 1 1, 2
&
M M
u u
+ +
( )
{ }
2
1, 1 2, 1 1, 1, 1
1
2 2 2
2
2
1
2
(1 )
M M M M
u u u h u h f
h
+ + +
= + +
+ +
special
eq. for
the
corner.
0
u
x
( ) 0
u
u u
y
+ =
Diagonal
Dominance
Difference
eq.
( )
( )
( )
( )
{ }
2
1, 1, , 1 , 1 , ,
2
, , 1, 1, , 1 , 1
large #
2 2
1
2 2
i j i j i j i j i j i j
i j i j i j i j i j i j
u u u u u h f
u h f u u u u
+ +
+ +
+ + + + =
= + + + +
+
_
Eq. is written
in this
form so
system
is diagonally
dominant
Ax b =
i
th
eq.
1 1 2 2
... ...
i i ii i im m i
a x a x a x a x b + + + + + =
Diagonally
dominant if
1 2 , 1 , 1
... ...
ii i i i i i i im
a a a a a a
+
> + + + + + +
The
system
is diagonally
dominant if
all
eqs. have
this
property.
Iteration
schemes
will
converge
if
the
system
has this
property.
2.
If
one
(or
more) not diagonally
dominant
iteration
usually
diverge
3. Non-centered
differences
, non-diagonally
dominant systems.
e.g.
{ } ( )
2
3
1, 2, 3,
2 2
1
3 12 15 3
3
ij i j i j i j
ij
u
u u u u O h
x h
+ + +
= + + +
4.
For non-linear
equations
no guarantee
that
iterative
solution
will
converge
even
if
diagonally
dominant
2
0
u
u u
x
+ =
Notes:
1.
Our
system
has
2 2 1 1 + = + + +
Improved
method
for
derivative
conditions
Higher
order
approximation
for
derivative
But must
retain
diagonal
dominance
J+1
J
J-1
M+1 M
M-1
M-2
( )
0
u
u u
x
+ =
Sloping
difference
approximation
{ } ( )
3
2, 1, , 1, 1,
1
2 9 18 11 0 ( )
16
M j M j M j M j M j
u u u u u u O h
+ +
+ + + = +
( )
{ }
3
1, , 1, 2,
1
18 9 2 ( ) (13)
11 6
M j M j M j M j
u u u u u O h
h
+
= + + +
+
Substitute
into
approx. of diff.eq. at i=M
{ }
{ }
( )
, 1 1, 2, 1,
2
, 1 , 1 ,
1
18 9 2
11 6
2 2 (14)
M j M j M j M j
M j M j M j ij
u u u u u
h
u u u h f
+
+
+ + + +
+
+ + =
Or
( )
{ }
-1, -2,
2
, 1 , -1 , 1,
9 2
1-
11 6 11 6
18
- 2 2 - -
11 6 11 6
(15)
M j M j
M j M j M j M j
u u
h h
u
u u u h f
h h
+ +
+ +
+ +
+ =
+ +
( )
2
1, , 1, , 1 , , 1 ,
-2 + + 2 = (1)
i j i j i j i j i j i j i j
u u u u u u h f
+ +
+
18 4
2 2 2
11 6 11 h
+ +
+
9 2 4
1 2
11 6 11 6 11 h h
+ + + +
+ +
Procedure:
1.
sweep
interior
points
with
the
conventional
eq.
2.
on line
adjacent
to
right
boundary
use
(15)
3.
u values
on right
face, obtained
from
(13) after
convergence
Let us check
for
diagonal
dominance
of eq.(15) for
small
h,
CURVED IRREGULAR BOUNDARIES
C
i-1
i i+1
i+2
j-1
j
j+1
Consider
approx. at i,j
2
1, 1, , 1 , 1 , ,
4
i j i j i j i j i j i j
u u u u u h f
+ +
+ + + =
But , 1 i j
u
+ is not in interior
Suppose
C intersects
i
th
line
C
i+1,j
i,j-1
i,j
i-1,j
i,j+1
qh
point
interpolation
on ith
mesh line, q<1
, , 1
2 3
, , 1
( 1)
( , )
2
( 1)
(1 ) ( )
2
i C i i i j
i j i j
q q
u u x y qh u
q q
q u u O h
+
+
= + = +
+ +
Use
above
eq. to
eliminate
, 1 i j
u
+
Nine Point
Formula For
Laplacian (derivation)
i
(i+1,j+1)
(i+1,j)
(i+1,j-1)
i,j
i,j+1
(i-1,j+1)
Define operators
,
x y
= =
Hold
one
variable
constant
(e.g. x) and
consider
Taylor Series;
( ) ( )
2 2
2
, 1 ... , ( , )
2!
h
u x h y h u x y e u x y
x x
+ = + + + =
Similarly
( )
, ( , ) u x y h e u x y
+ =
Consider
the
sum
( )
1 1, , 1 1, , 1
1
4 4
2 2
4 2 2
2 2
2 2
( , ) (31)
2 .... 2 ...
12 12
4 ...
12
and equation (31)
i
j
i j i j i j i j
x x
y y
S u u u u
and
S e e e e u x y
but
e e e e
h
h
x y
+ +
=
=
= + + +
= + + +
+ + + = + + + + + + +
= + + + +
( )
4
2 2 4 4
1 ,
,
,
2
2 2 2
2 4
2 2
becomes
4 2 .... (32)
12
D
i j
i j
i j
h
S u h u u D u
h
x y x y
= + + +
= = +
If
we
neglect
last
term
in (32) Standard
5 point
Formula.
Now
consider
sum
( )
( )
2 1, 1 1, 1 1, 1 1, 1
,
2 3 4 4 4
2 2 2
4 4
2 2 2 2
4
2 2 4
( , )
= 1+ ... 2+ ... 2 .... 2 ...
2! 3! 12 12 12
4 2 ...
6 6
4 2
6
i j i j i j i j
i j
S u u u u e e e e u x y
h
h
+ + +
+ + + +
= + + + = + + +
+ + + + + + + + + + + +
= + + + + + +
= + +
( )
( )
4 4
4
2 2 4 4
2 ,
,
,
2 6
2 4 ... (33)
6
i j
i j
i j
D D
h
S u h u u D u
+
= + + + +
To
obtain
9 point
formula, take
4x32 + 33
( )
2
2 2 4
1 2 ,
, ,
2
1 2 ,
2 4 4
2
, ,
4
1 2 ,
4 20 6 ...
12
4 20
(34)
6 12
Note Laplace eq. 0
4 20 0 (35)
i j
i j i j
i j
i j i j
i j
h
S S u h u u
S S u
h
u u O h
h
u
S S u
+ = + + +
+
= +
=
+ =
Still
diagonally
dominant
Dirichlet
conditions, very
effective
Derivative
conditions
more
difficuilt
to
implement
Mesh with
x=h , y=k
( )
( )
( )
( )
2 2
1, 1 1, 1 1, 1 1, 1 1, 1,
2 2
2 2
, 1 , 1 ,
2 2
2 5
2 5
20 0 (36)
i j i j i j i j i j i j
i j i j i j
h k
u u u u u u
h k
h k
u u u
h k
+ + + + +
+
+ + + +
+
+ + =
+
Poisson
eq.
2
( , ) u f x y =
Then
(34) becomes
( )
2
2 2
1, 1 1, 1 1, 1 1, 1 1, 1, , 1 , 1 , ,
,
4 20 6
12
i j i j i j i j i j i j i j i j i j i j
i j
h
u u u u u u u u u h f f
+ + + + + +
+ + + + + + = +
i,j+2
i+1,j+2
i+2,j+2
i,j-2
Not diagonally
dominant
( ) ( )
{ } ( )
2 2
, 1, 1, , 1 , 1 2, 2, , 2 , 1
2
,
1
60 16
12
i j i j i j i j i j i j i j i j i j
i j
u u u u u u u u u u O h
h
+ + + +
= + + + + + + + +
Not good
in solving
differential
equation, not diagonally
dominant
ALTERNATING DIRECTION METHODS
i-1
(N+1,M+1)
i i+1
j+1
j-1
j
Solve
along
rows
at once
in the
direction
y
increasing
j
th
row, assume
j+1 & j-1 known
( )
2
1, , 1, 1
1,
, 1 , ,
,
2 1 (42)
i=2,..., N
& known (dirichle
t BCs)
i j i j i j i j i j i j
j N j
u u u h f
u
u
u
u
+ +
+ = +
Thomas algorithm
(line
by
line)
( )
( )
1, , 1, , 1 , 1
, , ,
( ) ( ) ( ) 2 ( 1) ( )
,
( ) ( 1) ( 1/ 2)
2 1 (43)
Gauss-Seidel
Could add SOR
1 i=2,..N (44)
i j i j i j i j i j
i j i j i j
n n n n n
i j
n n n
u u u h f u u
u u u
+ +
+ + =
= +
Alternatively
we
can incorporate
SOR factor
directly
in (43)
( )
( )
{ }
( )
( )( )
, , 1, 1, , 1 , 1
1, , 1, , , 1 , 1
( ) ( 1) ( ) ( ) ( 1) ( ) 2
,
( ) ( ) ( ) ( 1) 2 ( 1) ( )
,
1
2 1
2 1
2 1 1 (45)
i j i j i j i j i j i j
i j i j i j i j i j i j
n n n n n n
i j
n n n n n n
i j
u u u u u u h f
rearrange
u u u u h f u u
+ +
+ +
= + + + +
+
+
+ = + +
Must
have
diagonally
dominance
1+
Uniform
mesh
= 1 ,
2
Note:
. SOR or
just
straight
line
relaxation
Number
of iterations
reduced
significantly
But amount
of computation
comparable
ADI METHODS
Alternating
Direction
Implicit
Alternate
sweeps
in each
of coordinate
directions
One
implementation
{ }
( )
1, , 1, , 1 , , 1
2
1, , 1, , , 1 , , 1
,
( 1/ 2) ( 1/ 2) ( 1/ 2) 2 ( ) ( 1/ 2)
,
2 2 (47)
substract term to each side
2 2 (48)
i j i j i j i j i j i j
i j i j i j i j i j i j i j
i j
n n n n n n
i j
u u u h f u u u
u
u u u h f u u u
+ +
+ +
+ + + +
+ =
+ + =
accelaration
factor
sweeps
on line
of constant
y
then
sweep
on lines
of constant
x
( ) ( )
{ }
, 1 , , 1 1, , 1,
( 1) ( 1) ( 1) 2 ( 1/ 2) ( 1/ 2) ( 1)
,
2 2 (49)
i j i j i j i j i j i j
n n n n n n
i j
u u u h f u u u
+ +
+ + + + + +
+ + =
Notes:
1.
SOR again
on each
x or
y sweep
or
after
complete
sweep
2.
h=k =1 optimum value
=2sin(/R)
R is largest
of M+1 , N+1
3.
same
problem with
SOR of finding
wopt
ADI + SOR
20
40 % reduction
in computation
But programming
ADI difficuilt.
Laplaces
eq.:
2
0 u =
Five-point
formula
T.E.
2 2
, O h k
i,j
i+1,j
h
k
1, , 1, , 1 , , 1
2 2
2 2
0
i j i j i j i j i j i j
u u u u u u
h k
+ +
+ +
+ =
Most
common
formula
Nine-point
formula:
( )
( )
2 2
1, 1 1, 1 1, 1 1, 1 1, 1,
2 2
2 2
, 1 , 1 ,
2 2
5
2
5
2 20 0
i j i j i j i j i j i j
i j i j i j
h k
u u u u u u
h k
h k
u u u
h k
+ + + + +
+
+ + + + +
+
+ =
+
i,j
i+1,j
h
k
i+1,j+1
Diagonally
dominant
Greater
accuracy
for
laplaces
eq.
( )
2 2
, O h k
But becomes
( )
6
O h on a square
mesh (h=k)
T.E may
be only
( )
2 2
, O h k when
applied
to
a more
general elliptic
eq. (including
Poissons
eq.) containing
other
terms
High
accuracy
is difficuilt
to
maintain
near
boundaries
with
such
schemes
Dirichlet
conditions, very
effective
Derivative
conditions, more
difficult
to
implement
GAUSS-SEIDEL ITERATION FOR POISSON EQUATION
( ) { }
2
1 , 1 , , 1 , 1 ,
2
2
2
2
2
FDE
2 2
1
PDE ) , (
=
+ + + +
+
=
=
+ +
k
h
T T T T f h
T
y x f
y
T
x
T
j i j i j i j i j i i,j
i,j
i+1,j
h
k
i,j+1
i,j-1
i-1,j
a
b
N+1,1
N+1,M+1 1,M+1
1,1
y
x
TYPICAL CODE
C
SET PROBLEM PARAMETERS & DIMENSIONS
C
a, b, N, M, EPS, ITERMAX, ETC
C
APPLY BCs
for
T(I,J)
C
ASSIGN GUESSED INITIAL VALUES T(I,J) FOR ALL INTERNAL
POINTS
C
X2=2.0 + 2.0*GAMMA
100
JC=0
ITER=ITER+1
DO 10 I=2,N !all
internal
grid
points
DO 10 J=2,M !all
internal
grid
points
X1=T(I,J)
T(I,J)=(-h**2*F(I,J)+T(I,J)+ T(I-1,J)+GAMMA* (T(I,J+1)+ T(I,J-1)))/X2
IF(T(I,J).EQ.0.0) GO TO 10
TEST=ABS(1.0-X1/
T(I,J))
IF(TEST.GT.EPS)JC=1
10
CONTINUE
IF(ITER.GT.ITERMAX) STOP
IF (JC.EQ.1) GO TO 100
...
General formula
for
2
( , ) u f x y =
( )
{ }
2
, , 1, 1, , 1 , 1
1
(1)
2(1 )
i j i j i j i j i j i j
u h f u u u u
+ +
= + + + +
+
A. Convection
at the
right
boundary:
h
*
, u
x = a = x
N+1
(N+1,M+1)
( )
( )
( )
( )
( )
* *
2, ,
* *
1,
*
2, , 1,
*
2, , 1,
on x=a
2
2
2
N j N j
N j
N j N j N j
N j N j N j
u
k h u u
x
u u
k h u u
h
h
u u h u u
k
u u h u u
+
+
+ +
+ +
=
=
=
,j
N+2
h
k
j-1
j+1
N
i=N+1 , j=j
( )
{ }
( ) ( )
{ }
( )
{ }
2
1, , 2, , 1, 1 1, 1
2
1, , , 1, 1, 1 1, 1
2
1, , , 1, 1 1, 1
1
2(1 )
1
2 2
2(1 )
1
2 2 j=2,...,M
(2 2 2 )
If insulated =0
N j i j N j N j N j N j
N j i j N j N j N j N j
N j i j N j N j N j
u h f u u u u
u h f u h u u u u
u h f u u u h u
h
+ + + + +
+ + + + +
+ + + +
= + + + +
+
= + + +
+
= + + + +
+ +
,j
2
h
k
j-1
j+1
0
i=1 , j=j
( )
{ }
( ) ( )
{ }
( )
{ }
2
1, , 2, 0, 1, 1 1, 1
2
1, , 2, 1, 1, 1 1, 1
2
1, , 2, 1, 1 1, 1
1
2(1 )
1
2 2
2(1 )
1
2 2 j=2,...,M
(2 2 2 )
If insulated =0
j i j j j j j
j i j j j j j
j i j j j j
u h f u u u u
u h f u h u u u u
u h f u u u h u
h
+
+
+
= + + + +
+
= + + + +
+
= + + +
+
h
*
x = x
1
(M+1)
B. Convection
at the
left
boundary:
( )
( )
( )
2, 0,
* *
1,
0, 2, 1,
2
2
j j
j
j j j
u u
k h u u
h
u u h u u
=
= +
C.
Convection
at the
top boundary:
h*
( )
( )
( )
, 2 ,
* *
, 1
, 2 , , 1
2
2
i M i M
i M
i M i M i M
u u
k h u u
k
u u k u u
+
+
+ +
=
=
i+1
h
k
M
M+2
i-1
( )
{ }
( )
( ) { }
( )
{ }
2
, 1 , 1, 1 1, 1 , 2 ,
2
, 1 , 1, 1 1, 1 , , 1
2
, 1 , 1, 1 1, 1 ,
2
, 1 , 1,
1
2(1 )
1
2 2
2(1 )
(2 2 2 ) 2 2
1
(2 2 2 )
i M i j i M i M i M i M
i M i j i M i M i M i M
i M i j i M i M i M
i M i j i
u h f u u u u
u h f u u u k u u
u k h f u u u k u
u h f u
k
+ + + + +
+ + + + +
+ + + +
+ +
= + + + +
+
= + + +
+
+ + = + + + +
= +
+ +
( )
{ }
1 1, 1 ,
2 2
M i M i M
u u k u
+ +
+ + +
i=i , j=M+1
D.
Convection
at the
bottom
boundary:
( )
( )
( )
,2 ,0
* *
,1
,0 ,2 ,1
2
2
i i
i
i i i
u u
k h u u
k
u u k u u
=
= +
i,j
i+1
h
k
0
2
i-1
( )
{ }
( ) ( ) { }
2
,1 ,1 1,1 1,1 ,2 ,0
2
, 1 ,1 1,1 1,1 ,2 ,1
1
2(1 )
1
2 2
2(1 )
i i i i i i
i M i i i i i
u h f u u u u
u h f u u u k u u
+
+ +
= + + + +
+
= + + + +
+
POINT TREATING AT CORNERS
1 2
1 2
,
h h
k k
= =
( )
1
0
u
u u
y
+ =
( )
2
0
u
u u
x
+ =
1,M+1
2,M+1
h
k
1,M
1,M+2
0,M+1
( )
( )
( )
1, 2 1,
1 1, 1
1, 2 1, 1 1, 1
2
2
M M
M
M M M
u u
u u
k
u u k u u
+
+
+ +
=
=
( )
( )
( )
2, 1 0, 1
2 1, 1
0, 1 2, 1 2 1, 1
2
2
M M
M
M M M
u u
u u
h
u u h u u
+ +
+
+ + +
=
= +
Approx. dif. eq.
i=1 , j=M+1
( )
{ }
( ) ( )
( )
( )
{ }
2
1, 1 1, 1 2, 1 0, 1 1, 2 1,
2
1, 1 1, 1 2, 1 2 1, 1 1, 1 1, 1
2
1, 1 1, 1 2, 1 2 1, 1
1 2
2
1
2(1 )
(2 2 ) 2 2 2 2
1
2 2 2 2
(2 2 2 2 )
u
if 0 0
x
M M M M M M
M M M M M M
M M M M
u h f u u u u
u h f u h u u u k u u
u h f u h u u k u
k h
+ + + + +
+ + + + +
+ + +
= + + + +
+
+ = + + +
= + + +
+ +
= =
1 2
1 2
,
h h
k k
= =
( )
1
0
u
u u
y
+ =
( )
2
0
u
u u
x
+ =
N+1,M+1
N+2,M+1
h
k
N+1,M
N+1,M+2
N,M+1
( )
( )
( )
1, 2 1,
1 1, 1
1, 2 1, 1 1, 1
2
2
N M N M
N M
N M N M N M
u u
u u
k
u u k u u
+ + +
+ +
+ + + + +
=
=
( )
( )
( )
2, 1 , 1
2 1, 1
2, 1 , 1 2 1, 1
2
2
N M N M
N M
N M N M N M
u u
u u
h
u u h u u
+ + +
+ +
+ + + + +
=
=
Approx. dif. eq.
i=1 , j=M+1
( )
{ }
( ) ( )
( )
( )
{ }
2
1, 1 1, 1 2, 1 , 1 1, 2 1,
2
1, 1 , 1 2 1, 1 1, 1 1, 1
2
1, 1 1 2 , 1 2 1, 1
1
2(1 )
(2 2 ) 2 2 2 2
(2 2 2 2 ) 2 2 2 2
N M N M N M N M N M N M
N M N M N M N M N M
N M N M N M
u h f u u u u
u h f u h u u u k u u
u k h h f u h u u k u
+ + + + + + + + + +
+ + + + + + + +
+ + + +
= + + + +
+
+ = + +
+ + + = + + + +
2 2
2 2
2 2
2 2
Re (50)
Re (51)
u u u u
u v
x y x y
v v v v
u v
x y x y
+ = +
+ = +
i,j
i+1,j
h
k
i,j+1
CONVECTIVE TERMS
Navier-Stokes
problems:
Example: 2-D , Steady
Burgers
equation
Similar
to N-S
but do not include
pressure
gradient
Coupled
equations
so
iteration
between
equations
are
necessary
Standart Central
Difference:
1, 1, , 1 , 1 1, , 1, , 1 , , 1
, ,
2 2
2
2
2
2 2
Re (50)
2 2
Multiply by ,
i j i j i j i j i j i j i j i j i j i j
i j i j
u u u u u u u u u u
u v
h k h k
h
h
k
+ + + +
+ +
+ = +
=
( )
( ) ( )
{ }
1/ 2
1, 1, , 1 , 1 , , 1, 1, , , 1 , 1
2 1 Re 0 (52)
2
i j i j i j i j i j i j i j i j i j i j i j
h
u u u u u u u u v u u
+ + + +
+ + + + + =
( )
, 1, 1 ,
, ,
,
, 1 , 1 ,
( ) ( )
( ) ( )
( 1) ( 1)
1/ 2 ( 1) 1/ 2 ( 1) ( )
Re Re
1 1
2 2
Re Re
2 1
2
0 (53)
2
i j i i j i j
i j i j
j
i j i i j j
n n
n n
n n
n n n
u u
h h
u u
h u u u v hv
+
+
+
+
+ +
+ +
=
Approximating
(50),
Now
non-linear algebraic eq.
Most
Common
Approach
Linearize
by
guessing
selected
coefficients
1st derivative
term
in (52)
Typical
code
involves
Gauss-Seidel
A1 = 0.5*RE*H
G = H*H/(AK*AK)
A2
= 2.0*(1+G)
GR
= SQRT(G)
DO 10 I = 2, N1
DO 10 J = 2, M1
B1 = 1.0
A1*U(I,J)
B3 = 2.0
B1
B2 = G -
A1*G2*V(I,J)
B4 = 2.0*G
B2
U(I,J) = (U(I+1,J)*B1+ U(I-1,J)*B3+ U(I,J+1)*B2+ U(I,J-1)*B4)/A2
V(I,J) = .
END DO
END DO
Notes:
1.We could
use
SOR but often
divergence
2.Often
we must
use
under-relaxation
as Re increases
( )
, , ,
( ) ( ) ( 1)
1
0.5 & reduce
if <0.01 , not worth continuing
i j i j i j
n n n
u u u
= +
=
3.can
use
ADI
4.mesh restrictions
need
(53) to
be diagonally
dominant
( )
1/2
, ,
1/ 2
, ,
Re Re
p= , q=
2 2
1 1 2 1
Suppose p>1 1 1 =2p>2
&
sele
not diagonally dominant
ct h,k 1 ,
. . Re 1 , R
e
2 2
i j i j
i j i j
h h
u v
p p p p
p p
p q
h h
i e u v
+ + + + + +
+ +
< <
< <
But difficult
to
select
a priori
i.u
i,j
unknown
, always
try
to
non-dimensionalize
so
,
0 1
i j
u <
ii.
as Re inreases
, smaller
& smaller
mesh sizes
Possible
Acceleration?
Newton linearization
Consider
term
like
(52)
( )
, 1, 1,
(54)
i j i j i j
u u u
+
Instead
of taking
u
i,j
from
previous
iterate, use
( )
,
, , ,
:assumed small
i j
T
i j i j i j
u estimate u u u
= +
In
(54)
( )( )
( ) ( )
, , 1, 1, 1, 1,
, 1, , 1, , 1,
, 1, 1, , , , 1, 1,
, 1, 1, , , 1, , 1,
... ...
...
i j i j i j i j i j i j
i j i j i j i j i j i j
i j i j i j i j i j i j i j i j
i j i j i j i j i j i j i j i j i
u u u u u u
u u u u u u
u u u u u u u u
u u u u u u u u u
+ +
+ + +
+ + + +
+ + +
+ +
+ + +
= + + +
= + + +
{ }
1, , , 1,
(55)
j i j i j i j
u u u
+
Danger, must
be close
to
solution
or
divergence
Damping
UPWIND-DOWNWIND DIFFERENCES
(FORWARD-BACKWARD ALGORITHM)
As Re increases, difficult
to
reduce
mesh to
maintain
diagonal
dominance
Need to consider difference
in local
flow
direction
Consider
term
u
u
x
If
,
,
1, ,
,
( 1)
( 1)
, 1,
,
) ( ) (56)
) ( 0 ) (5 )
0
7
i j
i j
i j i j
n
i j i j
i
i
j
j
n
u
a u u O h
x
u
b
u u
u
h
u u
u h
u
u O
x
h
<
>
= +
Similarly
for
u
v
y
,
,
, , 1
( 1)
,
, 1 ,
( 1)
,
) 0 ( ) (58)
) 0 ( ) (59)
i j
i j
i j i j
n
i j
i j i j
n
i j
v v
u
a v v v O k
y k
v v
u
b v v v O k
y k
> = +
< = +
Consider
first
approximate
to
x derivatives
& denote
values
of u
i,j
, v
i,j
from
last
iteration
with
u*
i,j
, v*
i,j
( ) ( )
( )
, ,
,
,
,
,
,
2 * * *
1 1
2
, 1, ,
1
2
*
*
, 1,
1, , 1,
2
*
1, ,
*
1, 1, ,
1 Re 2 Re 0
Re
, 0
2
Re
, 0
= 1 Re 2 Re
i j
i
i j i
i j i j
j
i j
i j
i j i j
i j i j i j
i j i
i j i j
i j i
i j
i j
j
j
u u
T u
x x
u u u
u
u u u
h h
u u u
u h u u
h T u u h u u h u
u h u
u
or
+
+
+
+
=
>
+
=
=
<
+ +
+
+ >
( )
, ,
* *
0
j i j
u <
Note:
Diagonally
dominant for
all
Re
( ) ( )
( )
,
,
,
, ,
,
,
2
2
2
*
*
, , 1
, 1 , , 1
2
*
*
, 1 ,
* * *
, 1
, 1 , 1
2
,
,
1
, 2
Re
, 0
2
Re
, 0
1 Re 2 Re
1 Re 2
0
=
i j i j
i j
i j
i j
j
j
i
i
i j i j i
i j i j
i j i j i j
i j i
j
j
i i j i j
j
u
u u
T
u k v u h v
v
y y
u u v
v
u u u
k k
u u v
o
u k v
T
u u k
r
v h
+
+
+
+
=
>
+
=
<
+ +
+ >
+
( )
, ,
* *
Re 0
i j i j
v v <
Approximating
to
differential
equation (50)
2
2
1 2
2
2
1 2
0
0 (62)
h
h T T
k
h T T
+ =
+ =
For y derivatives
2 2
2 2
Re (50)
u u u u
u v
x y x y
+ = +
or
in the
form
* *
,
1 1, 2 , 1 3
* *
,
1, 4 , 1 0 ,
1
3 ,
2
, 3
0 (63)
where
,
1 1 Re
, 1 Re 1
>
<0
0
i
i j i
j i j i j i j i
j
j
j
i i j
h u
h u
b u b u b u b u b u
b b
b u
u
b
+ +
+ + + =
= =
=
+
= =
( )
( )
( )
4
4
* *
0 ,
* *
, ,
,
* *
, ,
,
,
1 Re >
2 Re 2 Re
1
0
Re <0
i j
i j i j
i i j
i j
j
k v v
k b
b
b h u h
v v
v
=
= =
= + + +
+
+
1
0
0
0
Simplified
driven
cavity
problem
2 2
2 2
1
Re
u u u
u
x x y
= +
Typical
code
changes
F1 = h*Re
F2 = k*Re
DO 10 I =
2, N1
DO 10 J = 2, M1
X1 = U(I,J)
X2 = V(I,J)
X3 = 1 + F1*ABS(X1)
X4 = G*(1.0
+ F2*ABS(X2))
IF (X1.GT.0.0)
THEN
B1 = 1.0
B3 = X3
ELSE
B1 = X3
B3 = 1.0
END IF
IF (X2.GT.0.0)
THEN
B2 = G
B4 = X4
ELSE
B2 = X4
B4 = G
END IF
B0 = X3 + 1.0
+ X4 + G
U(I,J) = (U(I+1,J)*B1+U(I-
1,J)*B3+U(I,J+1)*B2 + U(I,J-1)*B4)/B0
Convergence
test
END DO
END DO
DEFERRED CORRECTION
Upwind/downwind
differencing
, diagonally
dominant ,
Convergence
but
accuracy
problem
Central
difference
1, 1,
, 1
2
2
,
1, ,
2
( ) (64)
( )
( ) (65)
2
i j i j
i j i j
x
i j i j
x
u u
h
u u
C
h
u u
C
u
O h
x
u
h
x
O h
h
O
+
= +
= +
= +
+
Choose
correction
C
x
+
& C
x
-
so
(64) & (65)
1, , 1,
1, , 1,
2
2
2
(66)
2
i j i j i j
x
i j i j i j
x
u u u
C
h
u u u
C
h
+
+
+
+
=
+
=
Similar
expressions
for
u
y
, , 1
2
, 1 ,
2
, 1 , , 1
( ) (67)
( )
2
(68)
2
i j i j
y
i j i j
y
i j i j i j
y y
u u
u
C O k
y k
u u
C O k
h
u u u
C C
k
+
+
+
= + +
= + +
+
= =
Difference
equations
become
{ } { }
1 1, 2 , 1 3 1, 4 ,
*
2
,
*
, 1, , 1, , , 1 ,
,
,
, 1 0
1
(69)
2 (7 2
2
0
2
)
i j i j i j i j i j i j
i j
i j i j i j i j i j i j i j i j
d
hu
b u b u b u b u b
h
d u u u v u u u
k
u
+ +
+ +
+ + + =
= + +
Implementation
1) perform
several
iteration
with
d
i,j
=0
2) evaluate
d
i,j
at each
point
in mesh & add
to
right
side
of (69)
3)
perform
several
iterations
with
d
i,j
constant
4) return
to
(2)
COMPUTATION OF FORCED CONVECTION
WITH CONSTANT
FLUID PROPERTIES
If
flow
properties
are
constant,
flow
field
is independent
of temperature
distribution.
Continuity
& momentum eqs.
( )
2
. 0
. (1)
V
DV V
V V F P V
Dt t
=
= + = +
,
, ,
, , , ,
Using
characteristic
velocity
U and
length
L, and
time is non-dimensionalized
with
L/U ,
/
t
L U
=
Dimensionless
eq.
( )
2
2
2
1
.
Re
Re
U
Fr= when gravitational field is considered as the body force term
V F gL
V V P V
U
UL
gL
+ = +
=
, ,
, , ,
Two
basic
approaches:
1.
Primitive
variables:
velocities
& pressure
are
the
unknown
dependent
parameters
(direct
approach)
2.
Stream
function-Vorticity
variables:
use
the
derived
variables
&
to
solve
the
problem
Temperature
field
is considered
after
velocity
field
is obtained!
(-) approach:
2-D flow
,
= constant
0
introduce : ,
u v
x y
u v
y x
+ =
= =
Note: continuity
eq. is identically
satisfied.
Taking
curl
of (1) , vorticity
eq. is obtained
( )
( )
2
. .
Inviscid flow 0 , F 0, 0 (show!)
Vorticity is defined
Here . 0 for 2-D flow since
: perpendicular to plane of flow (only non-zero comp. of vort
z
V V
P
V
V
+ = +
= = =
=
=
,
, , , , ,
,
, ,
, ,
icity for 2-D flow)
. 0
z
D
V
D
+ = =
,
, ,
Steady
flow,
z
along
a streamline
2 2
2 2
2
0
z z
z
z
u v
x y
v u
x y x y
+ =
= =
=
i.
For
irrotational
flow:
2
0 =
(Laplace
eq.)
Velocity
potential
may
also
be used
2
0 (continuity eq.) V = =
,
ii.
For
rotational
flow
2
z
=
Analitical
solutions
for
the
inviscid
or
potential
flow
in simple
configurations
exist.
vorticity is preserved for steady inviscid flow!
Numerical
Solution
Elliptic
problem must
be specified
at the
boundaries
Example:
= U
m
D
= 0
D
d
outlet
U
e
inlet
A channel
of varying
area
INVISCID
FLOW
Channel
is much
wider
in the
third
direction
so; 2-D flow
in (x,y) plane
may
be
considered.
Velocity
at the
outlet
is taken
uniform
(long
narrow
passage) =const. (inlet volume
flow
rate = outlet
volume
flow
rate)
Consider
two cases
for
velocity
at the
inlet U
e
Case
I: U
e
= const. = U
m
: uniform
flow
at inlet
Case
II: U
e
= /2 U
m
sin y/D : fully
developed
laminar
flow
U
m
: average
of velocity
distribution
at the
inlet
Flow
rate in both
cases
is U
m
D
0
upper wall lower wall
sin
2
D
m
m
Q U ydy
D
U D
=
=
B
Q=
A
B
Boundary conditions
for
A.
INLET
,
, 0 ( )
e
u v
y x
u x
y x
= =
= =
e
Take =0 at y=0 c=0
=U
e
U y c
y
= +
m
U y =
: si 1 cos
2 2
n
y
m m
y y
U
D
D
U
D
=
ii. i.
B. UPPER WALL
m
U D =
for
both
cases
indicates
the
same
volume
flow
rate
C. EXIT m
D
U y
d
=
VORTICITY FOR THE CASES AT INLET
0
z
v u
x y
= =
i.
2 2 2
2
cos 0
2 2
m
z m
U y
U
D D D D
= = ii.
Vorticity
in preserved
in inviscid
flow
Governing
eqs.
0
z
=
2 2
2
2
m
z
U
D D
=
i.
ii.
Non-dimensionalize
for
general results
, ,
m
x y
X Y
D D U D
= = =
2 2
2 2
0
X Y
+ =
i.
ii.
2 2
2
2 2
1
( )
2
f
X Y
+ = =
= 1
= 0
Inlet
m
U
m
y
Y D U YD
= =
_
( )
1
1 cos
2
Y =
i.
ii.
At outlet
distribution
for
both
cases
D
Y
d
=
Poisson
eq.
( )
( )
( )
( )
( ) ( )
( )
2
n+1 n n+1 n n+1
i,j i+1,j i-1,j i,j+1 i,j-1
2 2
n+1 n n+1
i,j i,j i,j
, ,
( )
G.S iteration scheme
SOR is possibl
1
2 1
e 1
n n
i j i
y
j
x
x f
f
f
= + + +
+ =
= +
+
Velocity
components
, 1 , 1
,
1, 1,
,
2
2
i j i j
i j
i j i j
i j
u
y
v
x
+
+
=
Note: inviscid
flow
(viscous
terms
neglected)
order
of governing
momentum equation
drops
from two
to
one
Only
one
physical
cond. wrt
velocity
field
can be satisfied
at boundaries
i.e.,
slip is allowed
parallel
to
walls
& normal
velocity
component
is taken
zero
Constant
value
of
obtained
along
the
wall.
= 1
= 0
x
y
0 , 0 u v
y x
= =
=
Pressure
field
2
2 2
, , ,
,
1
const.
2
V: flow speed at a point
is obtained & employed in B.L eqs.
i j i j i j
i j
p V
V u v
p
+ =
= +
Vorticity-Stream
Function
Formulation: pg.650
z
2 2
2 2
2 2
2 2
* * * * *
2-D
2-D Flow ,
dimensional
1
non-dimensional =
Re
, , , ,
v u
V
x y
u v
y x
u v
t x y x y
x y
t L u x
u x t
U U L U L
= =
= =
+ + = +
+ =
= = = = =
, ,
,
U
L
1.
N-S eqs.
; mixed
elliptic-parabolic
system
of eqs. , V P
,
simultaneous
solution
2.
Vorticity-stream
function
formulation:
formulation
Incompressible
N-S eqs. are
decoupled
into
one
elliptic
eq. & one
parabolic
eq.
can
be solved
sequentially
formulation
does
not include
the
pressure
term
i.e., velocity
is determined
first, pressure
is found
next
It
is best
for
2-D flows
B.Cs
on vorticity
need
to
be specified.(lack
of physical
B.Cs
on vorticity)
2
2 2 2
2
2 2
2
2
2
2
2
dimensionless orm 2 f
P P u v u v
x y y x x y
P
x y x y
=
+ =
2 2
2 2
1
(1)
Re
u v
t x y x y
+ + = +
Vorticity-stream function formulation
A.
Vorticity-transport equation
(parabolic)
B.
Stream
function
eq. (elliptic)
2 2
2 2
(2)
x y
+ =
a.
Unsteady
flows:
1.
Any
scheme
developed
for
parabolic
eqs.
2.
Any
scheme
developed
for
elliptic
eqs.
b.
Steady
flows:
2 2
2 2
2
1
(3)
Re
u v
x y x y
+ = +
=
Two
elliptic
eqs.
can
be solved
by
iterative
scheme. e.g. G.S or upwind-downwind
differencing
I.
II. Unsteady
equations
are
solved
until
steady
state
Total computation
time may
be too
excessive
Numerical
Algorithms
III. Pseudo-transient
approach
2 2
2 2
0 Two parabolic eqs.
t x y
+ + =
Vorticity-transport equation
A.
Explicit: FTCS
scheme
( ) ( )
, , 1, 1, , 1 , 1
, ,
1, , 1, , 1 , , 1
2 2
1
2 2
2 2 2 2
1
(4)
Re
n n n n n
i j i j i j i j i j i j
n n
i j i j
n n n n n n
i j i j i j i j i j i j
n
u v
t x y
x y
+ +
+ +
+
+ + =
+ +
+
DuFort-Frankel:
1 1
, ,
1 1
, ,
,
2
2
n n
i j i j
n n
i j i j
n
i j
t t
+
+
=
+
=
Use
of an upwind
differencing
scheme
may
be
appropriate
for
convection
dominated
flows
B.
Implicit: Approximate
Factorization
for
efficiency
for
multi-dimensional
problems.
ADI formulation:
two-step process;
treat
x der. implicitly
& y der. implicitly.
( ) ( )
1/ 2 1/ 2
1/ 2 1/ 2 1/ 2
, , 1, 1, , 1 , 1
, ,
1/ 2 1/ 2 1/ 2
1, , 1, , 1 , , 1
2 2
/ 2 2 2
2 2 2 2
1
Re
n n
xx ij yy ij
n n n n n n
i j i j i j i j i j i j
n n
i j i j
n n n n n n
i j i j i j i j i j i j
u v
t x y
x y
+ +
+ + +
+ +
+ + +
+ +
+ + =
+ +
+
_ _
( ) ( )
1/ 2
1 1/ 2 1/ 2 1/ 2 1 1
, , 1, 1, , 1 , 1
1/ 2 1/ 2
, ,
1/ 2 1/ 2 1/ 2 1 1 1
1, , 1, , 1 , , 1
2 2
/ 2 2 2
2 2 2 2
1
Re
(5a)
n
xx ii yy
n n n n n n
i j i j i j i j i j i j
n n
i j i j
n n n n n n
i j i j i j i j i j i j
u v
t x y
x y
+
+ + + + + +
+ +
+ +
+ + + + + +
+ +
+ + =
+ +
+
_
1
(5b)
n
ij
+
_
In
eq.(5b) can use
, ,
&
n n
i j i j
u v
instead
of (n+1/2) time level
No need
to
solve
at level
(n+1/2)
Computation
time reduced
With
this
argument, eqs. 5a&5b becomes,
( )
( )
1/ 2 1/ 2 1/ 2
1, , 1,
1 1 1
, 1 , , 1
1 1 1 1
(5a) - 1
2 2 2 2
1 1 1 1
(5b) - 1
2 2 2 2
x
x x
y
y y
n n n
x x i j x i j x x i j
B
A C
n n n
y y i j y i j y y i j
B
A C
x
D c d d c d
c d d c d
+ + +
+
+ + +
+
+ + + + =
+ + + + =
_
_ _
_
_ _
( ) ( )
2 2
where , Courant numbers
1 1
, Diffusion numbers
Re Re
x y
x y
y
t t
c u c v
x y
t t
d d
x y
D
= =
= =
( )
( )
1/ 2 1/ 2 1/ 2
1, , 1,
, 1 , , 1
1 1 1 1
1
2 2
1 1 1 1
1
2 2
2 2
2 2
n n n
y x x i
n n
j
n
x y y i j y i
x i j x x i
j y y i j
j
D c d d
D c d
c d
d c d
+ +
+
+
+
= + + + +
= + + + +
1/ 2 1/ 2 1/ 2
1, , 1,
1 1 1
, 1 , , 1
(6a)
(6b)
n n n
x i j x i j x i j x
n n n
y i j y i j y i j y
A B C D
A B C D
+ + +
+
+ + +
+
+ + =
+ + =
Thomas Algorithm
Stream
Function
Equation
2
=
Any
numerical
scheme
for
elliptic
eq. is applicable, e.g., G.S.
( )
( )
( )
2
1 1 1
, , 1, 1, , 1 , 1
2
1
(7)
2 1
=
k k k k k k
i j i j i j i j i j i j
x
x
y
+ + +
+ +
= + + + +
+
Tri-diagonal
matrix
algorithm
Procedure
i.
Computation
begins
with
the
solution
of vorticity
eq. (6-a,b) within
the
domain (
fixed) Perform
limited
number of
iterations
(5-10)
ii.
Vorticity
in eq.(7) is updated
and
the
eq.(7) is solved
for
. Iterate
on
2
=
(new
values
of
(5-10) )
iii.
Repeat
the
process
untill
the
desired
solution
is reached.
B.C relation
for
to
find
new
vorticity
values
Boundary
Conditions
Body surface
Far-field
Symmetry
line
Inflow
Outflow
( )
( )
( )
,1 ,2
,1
2
1 1
,1 ,1 ,1
2
use under-relaxation here
1
check convergence
return to (ii)
i i
i
k k k
i i i
O y
y
+ +
= +
= +
Body Surface
B.Cs:
Driven
cavity problem
x
y
M+1
A
B
u=0 , v=0
u=0 , v=0
i=1 , u=v=0
j=1
C
u=U
0
, v=0
Looks
as if
too
much
information
for
& not enough
info for
Answer:
a)
=0 (constant) for
2
=
n
b)
used
to
construct
conditions
on
N+1
Example: BCs
at the
left
wall.
u=v=0 at x=0
0
const. (arbitrary) (B1)
0
on x=0 & known but not
x
u
y
v
x
= =
=
= =
Use
stream
function
eq. to
find
B.Cs
for
vorticity; i.e.
2
=
on the
left
wall. i=1 , j=j
Thoms
method:
1,
1,
2 2
1,
2 2
1,
2
2
2
1,
2
(B2)
Along A (left wall) 0 ( is constant along y)
(B3
)
j
j
j
j
j
x
y
y
x
=
+ =
To
obtain
an expression
for
the
second-derivative
in eq. above, use
Taylor Series
expansion
( )
2
2
2, 1,
2
1,
1,
... (B4)
2
j j
j
j
x
x
x x
= + + +
( )
( )
( )
( )
( )
( )
( )
( )
1,
1,
2
2
3
2, 1,
2
1,
2
2, 1,
1, 2,
1,
2
2 2
1,
Along boundary A, v=0
0
2
2
(B5)
Substitute (B5) into (B3)
(B6
2
)
j
j
j j
j
j j
j j
j
j
v
x
x
O x
x
O x
x
x
x
O x
= =
= + +
= +
+
N+1 N
, 1, N j N j
x
+
=
( )
( )
( )
( )
2
2
2
1, 1,
2
, 1,
2 2
1,
2
2
N j N j
N j N j
N j
x
x
x
O x
x
x
+ +
+
+
+ =
Similarly, for
right wall B & bottom wall C:
B:
( )
( )
2
1, ,
1,
2 2
1,
2
N j N j
N j
N j
x
x
+
+
+
= =
C:
( )
( )
2
,1 ,2
,1
2 2
,1
2
i i
i
i
y
y
= =
II.Method:
( )
( )
( )
( )
( )
1
0,
2
2
2, 1,
1, 1,
2 2
1,
2, 0,
2 3
1, 2, 0
, 2
0,
,
1
,
,
,
2
1
2
(B3)
( ) 0 ( )
2
2
?
j j j
j j
j
j j
j j j
j j
j
j
j
O x
x
x
v O x O x
x x
O x
x
= + =
= = + = = +
+ =
=
Now
suppose
upper
boundary
moving
with
a specified
velocity, U
0
( )
( )
( )
0
2
2
, 1 ,
2
, ,
U (j=M+1)
2
3
, , 1 0 , 1
2 2
2 2
, 1
...
2!
j=M+1
2
i j i j
i j i j
i M i M i M
i M
y
y
y y
y
U y O y
y x
+ +
+
= + +
= +
+
_
( )
( )
( )
( )
( )
, 1
, 1
, 1
, 1
,
0
, 1
2
,
0 , 1
2
2
2
2
Note that 0
i
i M i M
M
i M
i M M
i
i M
i
M
U
O y
y
y
U
y
+
+
+
+
+
+
= +
= =
A second
order
equivalent
of (B6)
is given
( )
( )
2
3, 2, 1,
1,
2
8 7
2
j j j
j
O x
x
+
= +
Higher
order
implementation
of B.Cs, in general, will
increase
the accuracy
of
solution
, but it may
cause
instabilities
for
high
Reynolds
number
flow
( )
, 1 , , 1
, 1
2
8 7
3
2
i M i M i M
o
i M
U
y
y
+
+
+
=
INFLOW:
u is specified
C =
0 =
Inlet
velocity
profile u = u(x,y) at x = x
0
then
0
0 0
0
( , ) ( , )
y
u x y u x y dy
y
= =
, u v
y x
= =
i. Values
of
along
the
inflow
are
specified
0 0 0
u U U U y
y
= = =
ii.
Its
values
is determined
from
the
interiour
1, 2, 3 1, 2, 3, ,
1,
0 0 3 4 4
3
0;
1
j j j j j j
j
v
x
= = + = =
Vorticity
at the
inflow:
( )
( ) ( )
2 2
1,
2 2
1,
1, 2,
1, 1 1, 1, 1
1,
2 2
2
2
j
j
j j
j j j
j
x y
x y
+
+ =
+
=
a.
b.
2
,
2
,
i j
i j
v u u
x y x y
= = +
specified
u is directly
used
to
evaluate
& set i=1
( )
1, 2, 3, 1, 1 1, 1
1,
2
second order central dif.
second order forward dif.
3 4
2
j j j j j
j
u u
y
x
+
+
=
_
_
OUTFLOW:
value
of streamfunction
is usually
extrapolated
from
the
interior
solution.
Utilizing 0
x
=
second-order
backward
approximation
N+1
N
N-1
0
( 0)
x
v
=
=
( )
1, , 1,
1,
1, , 1,
3 4
0
4
3
2
1
N j
N j N j N
N j N j
N
j
j
x x
+
+
+
+
=
= =
The
condition
2
2
0
x
=
is
also used
Second-order
backward
approx.
1, 1, ,
2
N j N j N j
+
= +
( )
1, 2, 1, ,
1
4 5
2
N j N j N j N j
+
= +
First-order
backward
approximation
Take
this
far
away
As with
the
inflow
B.C vorticity
at outlet
can be determined
by
numerous
methods,
Examples:
( )
( )
( )
( )
1, , 1, 1 1, 1, 1
1,
2 2
2 2
N j N j N j N j N j
N j
x y
+ + + + +
+
+
=
Simple
extrapolation
may
be used
for
which
one
sets
( )
1, , 1,
1
0 4
3
N j N j N j
x
+
= =
outflow
SYMMETRY BOUNDARIES:
x
y
u(y)
v=0 ,
2-D jet flow
x
0 0
u symmetric 0
u v u
y x y
u
y
= = =
v=0 ,
Stream
function
1
,
1
(*)
r
r
V V
r r
V V V
V
r r r r
= =
= = +
,
Vorticity
transport:
2
=
B.Cs
1
as cos
sin
~ sin as
0 (*) as
1
on r=1 0 0 on r=1
0 0 on r=1
r
r
r V
r
V
r
r r
r
V
r
V
r r
= = =
= = =
Boundary
Conditions
For
Vorticity
2
2 2
2 2
1
Re
u v
x y x y
=
+ = +
Stream
function:
2
1
, (71)
1
= (72)
governing eq. i) Vorticity transport
ii)
r
r
V V
r r
V V V
V
r r r
= =
= +
=
,
r
U=1
V
r
V
Boundary
conditions for cylindrical coordinates
i)
1
as r cos
sin
sin as r
r
V
r
V
r
r
And
from
(72)
0 as r
& known
ii)
1
on r 1 0 =0 on r=1
0 0
, known but not
r
V
r
V
r r
r
= = =
= = =
Pressure
Equation:
2 2 2
2
2 2
2 (P1) P S
x y x y
= =
see
page
652 for
derivation
( ) ( )
2
1, , 1, , 1 , , 1 1, 1 1, 1 1, 1 1, 1
, ,
2 2
2 2
2 (P2)
4
i j i j i j i j i j i j i j i j i j i j
i j i j
S
x y
x y
+ + + + + +
+ + +
=
Note:
For
a steady
flow
problem, the
pressure
equation
is only
solved
once, i.e. after
steady-state
values
of &
have
been
computed.
If
only
wall
pressures
are
desired, no need
to
solve
poisson
eq. over
entire
flow
field.
Pressure
dist. on airfoil
turbine
blades, etc.
Second-order
difference
representation
u
u
x
v +
2
2
u P u
y x x
= +
2
2
2
2
wall
wall
wall
wall
wall
(P3)
u
y
P u
x y
P
x y
v
x
=
=
wall
wall
u
y
1,1 1,1 ,1 ,2 ,3
3 4
(P4)
2 2
i i i i i
P P
x y
+
+
=
In
order
to
apply
(P4) the
pressure
must
be known
for
at least
one
point
on the
wall
surface.
Then
pressure
at adjacent
point
can be determined
using
a first
order, one-sided
difference
formula
for
P
x
in (P4)
Thereafter, use
eq.(P4) to
find
pressure
at all
other
wall
points.
3
2
1
Wall
y=0,
u=v=0
y
x
HYPERBOLIC EQUATIONS:
Method
of characteristics: paths
of propagation
of physical
disturbance,
inviscid
supersonic
flow
fields:
mach
lines
are
characteristics
of the
flow,
difficult
to
use
for
3-D problems
and
problems
with
non-linear
terms
Finite
difference
formulations
Model equation:
First
order
wave
equation
(linear
if
a =const.)
0 , a>0 (speed of sound) (1)
u u
a
t x
+ =
I.C. u(x,t=0) = f(x) initial
disturbance
B.Cs
x=0 u(0,t)=0 no-displacement
x=L u(L,t)=0 at boundaries
Explicit
Formulations:
1.
Eulers
FTCS method:
( )
( )
1
2
1 1
t, x (2)
2
n n n n
i i i i
u u u u
a O
t x
+
+
=
Von
Neumann
stability
analysis
shows
it is unconditionally
unstable.
2.
The
Lax
method:
In
FTCS method: replace
n
i
u
with
an average
value
( )
( )
1 1
1
1 1
1
(3)
2
1
2
(4)
n n n
i i i
n n n
i i i
u u u
u u u
u
t t
+
+
+
= +
+
=
Substituting
(2) & (4) into
(1), we
have
1
1 1 1 1
(5)
2 2
n n n n
n
i i i i
i
u u u u t
u a
x
+
+ +
+
=
Von
Neumann
stability
analysis
Assume
an error
of the
form
( , )
m
ik x bt
m
x t e e =
amplification factor
becomes
& substitute
in (5),
Note: the
error
also
satisfies
the
differential
eq.
cos( ) sin( )
where
the stability requirement is 1
Courant number (CFL condition) (6)
important stability requirement for hyperbolic eqs.
1
bt
m m
bt
e k x iC k
t
x
t
C a
x
e
C a
x
=
1
1
n
i
n
i
+
stable
solution
3.
Midpoint
Leapfrog
method
second-order
central
differencing
for
both
time&space
derivatives
( )
1 1
2 2
1 1
( t) ,( ) (7)
2 2
n n n n
i i i i
u u u u
a O x
t x
+
+
=
Method
is stable
when
C
1
Two
sets
of initial
values
are
required
to
start the
solution,
a starter
scheme
is needed
(affects
the
order
of accuracy
of the
method),
large
increase
in computer
storage.
4.
The
Lax-Wendroff
method:
The
L-W method
is derived
from
Taylor series
expansion
of the
dependent
variable
as follows
( ) ( )
( )
( )
( )
( )
2
2
3
2
2
3
1
2
2
2
2
, = , + + + (8)
2!
or in terms of indices
+ + (9)
2!
Now consider the model eq.
(10)
n n
i i
t
u u
u x t t u x t t O t
t t
t
u u
u u
t
t O t
u
t
a
x
u
t
u
t
+
= +
=
2
2
2
(11)
u u u
a a a
t x x t x
= =
Substituting
(10) & (11) into
(9) produces
( )
2
2
2
2
1
+
2
n n
i i
t
u
u u
a a
x x
u t
+
= +
Use
central
differencing
of second
order
for
the
spatial
derivatives
( )
( )
2
1 2
1 1 1 1
2
2 1
+
2 2
n n n n n
n n
i i i i i
i i
u u u u u
u u a t a t
x
x
+
+ +
+
=
Lax-Wendroff
method
( ) ( )
2 2
, O t x
Stability
analysis
shows
explicit
method
is stable
for
C
1
Implicit
Formulations
1.
Eulers
BTCS method:
( )
1
1 1
1 1
2
1 1 1
1 1
2
1 1
,
2 2
n n
n n
i i
i i
n n n n
i i i i
u u a
u u
t x
Cu u Cu u t x
+
+ +
+
+ + +
+
=
=
TDMA
2.
Crank-Nicolson
method:
( ) ( )
1 1 1
1 1 1 1
2 2
2 2 2
, TDMA
n n n n n n
i i i i i i
u u u u u u a
t x x
O t x
+ + +
+ +
= +
SOLUTION OF EULERS EQUATIONS
Lax-Wendroff
Technique
Explicit
Particularly
suited
to
marching
solutions: hyperbolic & parabolic
eqs.
Example:
Time-marching
solution
of an inviscid
flow
using
unsteady
Euler
eqs.
For
unsteady, 2-D inviscid flow
eqs. (HYPERBOLIC IN TIME)
Continuity:
(1)
u v
u v
t x x y y
= + + +
no boundary
forces
x-mom:
1
(2)
u u u P
u v
t x y x
= + +
y-mom:
1
(3)
v v v P
u v
t x y y
= + +
Energy: (4)
e e e P u P v
u v
t x y x y
= + + +
Cv: specific
heat
at constant
volume
e: internal
energy, we have
thermodynamic
relation
e=e(T,P)
For perfect
gas
with constant
specific
heat e(T)=cvT
Eqs. (1) to
(4) are
hyperbolic
with
respect
to
time
Taylor series
expansion
in time
( )
2
2
2
,
,
1
, ,
+ +... (5)
2!
n
n
i j
i j
n n
i j i j
t
t t
t
+
= +
If flow
field
at time level
n is known,
Eq.(5) gives
the
new
flow
field
at time (n+1)t+t
if
,
n
i j
t
&
2
2
,
n
i j
t
are
found
1
,
n
i j
+
can be calculated
explicitly, from
eq.(5)
Analogous
Taylor series
for
all
other
dependent
variables can be written as follows:
( )
( )
2
2
,
,
2
2
,
,
2
2
1
, ,
2
1
2
, ,
1
, ,
,
+ +... (6)
2!
+ +... (7)
2!
+
n n
i j i j
n
n
n
i j
i j
n
n
i j
n
i j i j
n n
i j i
i
j
i j
n
j
t
u u
t t
v
u u t
t
v v t
e e t
v
t t
e e
t t
+
+
+
= +
= +
=
( )
,
2
+... (8)
2!
n
i j
t
Using
spatial
derivatives
(second-order
central
dif.) from
eq.(1)
1, 1, 1, 1, , 1 , 1 , 1 , 1
, , , ,
,
(9)
2 2 2 2
n n n n n n n n
i j i j i j i j i j i j i j i
n
i j
j
n n n n
i j i j i j i j
u u v v
u v
x x y y t
+ + + +
= + + +
In
(9), all
quantities
on RHS are
known.
Differentiate
eq.(1) with respect to time
2
2
,
?
n
i j
t
2 2 2 2 2
2
,
(10)
n
i j
v
y t y
u
x t
u u v v
u v
x t x t y t y t t t t x
= + + + + + + +
2
u
x t
=?
Differentiate
eq.(2) wrt
x;
2
2 2 2
2 2 2
2
1 1
(11)
u u u u v P P
u v
x x x y y x x x x
u
x t
= + + + +
In
eq.(11) all
terms
on RHS are
expressed
as second-order, central
dif. eqs. at time
level
n:
( )
( )( )
( )
( )
2
2
1, , 1, 1, 1,
,
2
,
1, 1 1, 1 1, 1 1, 1 , 1 , 1 1, 1,
,
1, , 1,
2 2
,
,
2
2
4 2 2
2
1 1
n
n n n
i j i j i j i j i j
n
i j
i j
n n n n n n n n
i j i j i j i j i j i j i j i j
n
i j
n n n
i j i j i j
n
i j
i j
u u u u u
u
u
x t x
x
u u u u u u v v
v
x y y x
P P P P
x
+ +
+ + + + + +
+
+
= + +
+
+ +
+
( ) ( )
1, 1, 1, 1,
(12)
2 2
n n n n
i j i j i j i j
P
x x
+ +
In
eq.(12) all
terms
on RHS are
known.
Continuing
with
the
evaluation
of eq.(10), a number
for
2
x t
is found
by
differentiating eq.(1) wrt
x & replacing
all
derivatives
on RHS with
second-order
central
differences, similar
to
eq.(12).
2
v
y t
differentiate
eq.(3) wrt
y
2
y t
differentiate
eq.(1) wrt
y
,
u v
t t
central
difference;
eqs.(2) & (3) , respectively.
Finally;
2
2
,
n
i j
t
is calculated
from
eq.(10)
From
eq.(5)
1
,
n
i j
+
is known
For
the
remaining
flow-field
variables,
1 1 1
, , ,
, ,
n n n
i j i j i j
u v e
+ + +
repeat
the
above
procedure
( )
1
, , , 1 , 1 1, 1,
, , , ,
n n n n n n
i j i j i j i j i j i j
u f u u u u u
+
+ +
=
Remarks on Lax-Wendroff
second-order
accuracy
in both
space & time
Algebra
is lengthy
x
i+1,j
i,j+1
y
t
n+1
n
i,j
i,j-1
i-1,j
i,j
i,j-1
MACCORMACKS TECHNIQUE
A variant
of Lax-Wendroff
approach
But much
simpler
in its
application
Explicit
finite-difference
(second-order
accurate
in time&space)
First
introduced
in 1969
Consider
again
the
Euler
eqs. given
in eqs.(1) to
(4)
Assume
that
flow
field
at each
grid
point
is known
at time level
n
1
, ,
(13)
av
n n
i j i j
t
t
+
= +
Where
av
t
representative
mean
value
of
t
time levels
n and
(n+1)
between
times
t & t+t, i.e.
av
t
is to
be calculated
so
as to
preserve
second-order
accuracy
without
the
need
to
calculate
values
of the
second
time derivative
2
2
,
n
i j
t
Similar
relations
for
the
other
flow-field
variables,
1
, ,
1
, ,
1
, ,
(14)
(15)
(16)
n n
i j i j
av
n n
i j i j
av
n n
i j i j
av
u
u u t
t
v
v v t
t
e
e e t
t
+
+
+
= +
= +
= +
Use
the
predictor-corrector
philosophy
as follows
Predictor
step:
in the
continuity
eq.(1), replace
the
spatial
derivatives
of the
RHS
with
FORWARD differences
1, , 1, , , 1 , , 1 ,
, , , ,
,
(17)
n n n n n n n n n
i j i j i j i j i j i j i j i j
n n n n
i j i j i j i j
i j
u u v v
u v
t x x y y
+ + + +
= + + +
Obtain
a predicted
value
of density,
1 n
+
from
the
first
two
terms
of a Taylor series;
1
, ,
,
predicted value of density
(only first-order accurate)
(18)
n n
i j i j
i j
t
t
+
= +
A similar
fashion, predicted
values
of u,v&e can be obtained.
1
, ,
,
1
, ,
,
1
, ,
,
(19)
(20)
(21)
n n
i j i j
i j
n n
i j i j
i j
n n
i j i j
i j
u
u u t
t
v
v v t
t
e
e e t
t
+
+
+
= +
= +
= +
Corrector
step:
First
obtain
a predicted
value
of the
time derivative
at time t+t ,
1
,
n
i j
t
by
substituting
the predicted
values
of , u and
v into
the
RHS of continuity
eq.,
replacing
the
spatial
derivatives
with
BACKWARD
differences.
1 1 1 1 1 1 1 1 1
, 1, , 1, , , 1 , , 1
1 1 1 1
, , , ,
,
(22)
n n n n n n n n n
i j i j i j i j i j i j i j i j
n n n n
i j i j i j i j
i j
u u v v
u v
t x x y y
+ + + + + + + + +
+ + + +
= + + +
Forward differences for the spatial
derivatives
1
, ,
from eq.(17) from eq.(2
1
, ,
2)
1
2
(13) repeated
n n
n n
i
av i j
v
j
i j
i
j
a
t
t
t
t t
+
+
= +
= +
_ _
Same
accuracy
as the
Lax-Wendroff
method
Simpler
(no need
to
evaluate
second
derivative
2
2
,
n
i j
t
Also
possible
to
ose
backward
differences
on the
predictor
and
forward
differences
on the
corrector
Remarks:
Lax-Wendroff
& MacCormack
techniques
can be applied
to
VISCOUS FLOWS
as well
Space
marching
possible
instead
of time-marching
step
Viscous
Flows
governed
by
Navier-Stokes
eqs.
Steady
N-S partially
elliptic
Lax-Wendroff
& MacCormack
techniques
are
NOT
appropriate
for
the
solution
of
elliptic
PDEs
In
eq.(13)
Unsteady
N-S
mixed
parabolic
& elliptic
behavior
L-W & MacCormack
techniques
ARE
suitable
The
approach
is the
same
Predictor
-
Corrector
Forward
differences
& backward
differences;
for
convective
terms
only
Viscous
terms
should
be centrally
differenced
on both
the
predictor&corrector
steps!!
Incompressible
N-S eqs.
Can be derived
in a sraightforward
fashion
from
the
compressible
N-S eqs. (set
=const.
. 0 V =
,
But numerical
solution
of incompressible
eqs. cannot
be obtained
in a straightforward
fashion
from
a numerical
technique
developed
for
the
compressible
eqs.
Eg.
Compressible
N-S eqs. using
a time-marching
MacCormacks
technique, explicit
time step t is restricted
by
stability
condition.
( ) ( )
2 2
1
1 1
t
u v
x y
x y
a
+ + +
For
compressible
flow, speed
of sound
a is
finite.
Above
eq. gives
a finite
value
of t for
numerical
solution
For
an incompressible
flow, a is theoretically
infinite, i.e above
eq. gives
t=0!!
Something
else must
be done! SIMPLE-
pressure
correction
algorithm.
Incompressible
N-S eqs.
Primative
variable
formulation
Governing
equations
are
a mixed
elliptic-parabolic
system
of eqs. which
are
solved
simultaneously.
Unknowns;
, V P
,
There
is no direct
link for
pressure
between
continuity&momentum equations.
(i.e. no eqs. for
pressure!)
Two
mathematical
manipulations
are
used
to
establish
a connection.
1.
P equation
for
pressure
is introduced
2.
Introduction
of artificial
compressibility
into
continuity
eq.
Specification
of b.conditions
for
pressure
may
be difficuilt
Extension
to
3-D is straightforward
Poisson
eq. for
pressure:
Used
for
computation
of pressure
field
In
lieu
of continuity
eq.
Conservative
form of x & y components
of momentum eq.
( )
( )
( )
( )
2 2
2 2
1
(1)
Re
1
(2)
Re
u P
u uv u
t x x y
v P
uv v v
t x y y
+ + + =
+ + + =
Differentiate
eq.(1) wrt
x & differentiate
eq.(2) wrt
y and
add
two
resulting
eqs.
After
arrangment
( )
( )
( )
( ) ( )
2 2 2 2 2 2 2
2 2
2 2 2 2 2 2
1
2 (3)
Re
D=
P P D
u uv v D D
x y t x x y y x y
x y
+ = + +
+
For
=const. , D=0!
However,due
to
numerical
considerations, keep
the
term
in (3) to
prevent
error
accumulation
in process
of iterative
solution
of eq.
Artificial
Compressibility:
Continuity
eq. is modified
by
inclusion
of a time-dependent
term,
2
2
1
0 (4)
: artificial compressibility of fluid
compressibility pseudo-speed of sound, a
1
P u v
t x y
P
a
a
+ + =
= =
Steady, incompressible
N-S eqs. (2-D cartesian
coord.)
( )
( )
( )
( )
( ) ( )
2
2 2
2 2
0 (5)
1
(6)
Re
1
(7)
Re
P u v
a
t x y
u
u P uv u
t x y
v
uv v P v
t x y
+ + =
+ + + =
+ + + =
Solution
on Regular
Grid
To
facilitate
application
of finite
dif. formulations, eqs
(5)-(7) are
written
in a flux
vector
form as
[ ]
2
2 2
2
2
1
(8)
Re
P 0 0 0
Q= u , E= , F= , N= 0 1 0
v 0 0 1
Q E F
N Q
t x y
a u a v
u P uv
uv v P
+ + =
+
+
Eq.(8) non-linear
systems
of eqs.
Explicit
formulation
of non-linear
eqs. can be formulated
with
no difficulty
Implicit
formulations: a linearization
procedure
must
be introduced
See
CFD for
Engineers
Vol.I, Klaus
A.Hoffman
& S.T.Chiang
Use
of Poisson
Equation
for
Pressure:
Instead
of eq.(4), use
eq.(3) Poisson
eq. for
pressure..
Procedure:
use
eq.(3) to
evaluate
pressure
at (n+1) time level.
Then, eqs. (1)&(2) [Mom. Eqs.] are
solved
for
values
of un+1 & vn+1 respectively.
To
solve
eq.(3) an iterative
scheme
is usually
used.
For
example; G-S
( )
( )
1 1 1
, 1, 1, , 1 , 1 ,
,
1
( )
2 1
( ) : central difference formula discretized eq. of RHS of (3)
k k k k k
i j i j i j i j i j i j
i j
P P P P P RHS
RHS
+ + +
+ +
= + + + +
+
Numerical Solution of Incompressible N-S equations:
Need for a staggered
grid:
Continuity equation:
0
u v
x y
+ =
1, 1, , 1 , 1
0
2 2
i j i j i j i j
u u v v
x y
+ +
+ =
Consider Checkerboard Velocity Distribution; u: 20,40,20,,, ; v: 5,2,5,...
Discrete velocity distribution shown
satisfies central difference form of the
continuity equation.
Physically nonsense!
This problem does not occur for
compressible flow, because inclusion of
density variation in the continuity equation
wipe out the checkerboard pattern after
first time step.
Consider the pressure gradient in Navier-Stokes equations:
1, 1, , 1 , 1
;
2 2
i j i j i j i j
p p p p
p p
x x y y
+ +
= =
Pressure field dicretized in below mesh, would not be felt by the Navier-Stokes
equationseffectively uniform pressure in x & y.
To fix the potential problem:
-Upwind
differences instead of central
differences
-Maintain central differencing but stagger
the grid.
Solid grid points:p
(i-1,j),(i,j),(i+1,j),
(i,j+1),(i,j-1),
Open grid points:u,v
(i-1/2,j),(i+1/2,j),
(i,j+1/2),(i,j-1/2)
u is calculated at:
(i-1/2,j),(i+1/2,j)
v is calculated at:
(i,j+1/2),(i,j-1/2)
Pressure and velocities are calculated at different grid points.
Open grid points are shown equidistant between solid grid points
but this is
not a necessity.
Central difference expression for continuity equation centered around
point (i,j)
becomes :
1/ 2, 1/ 2, , 1/ 2 , 1/ 2
0
i j i j i j i j
v u
x
v
y
u
+ +
=
-Because this equation is based on adjacent velocity points, possibility of a
checkerboard velocity pattern is eliminated.
Pressure Correction Method
-Basically an iterative approach
-Innovative physical reasoning used to construct next iteration from previous iteration
results.
Procedure:
1) Start by guessing pressure field (p
*
)
2) Usr p
*
to solve u,v,w from momentum equations. Denote them u
*
, v
*,
w
*
3) Since u
*
, v
*,
w
*
were obtained from guessed values,they will not necessarily
satisfy continuity equation. Using continuity equation, construct a pressure
correction p
which when added to p
*
,will bring velocity field more into agreement
with the continuity equation. Corrected
pressure p:
p = p
*
+p
(1)
Velocity corrections u,v,w
can be obtained from p
u = u
*
+u
(2)
v = v
*
+v
(3)
w = w
*
+w
(4)
4)Designate new value of p on the LHS as the new value of p
*
Return to step 2, repeat the process until veloity field satisfies continuity equation.
The Pressure Correction Formula
-How to calculate/find a formula for pressure correction, p
?
-For simplicity: consider 2D flow & neglect body forces
x & y momentum equations for an incomp. viscous flow in conservation form:
2 2 2
2 2
2 2 2
2 2
( ) ( ) ( )
( ) ( ) ( )
u u uv p u u
t x y x x y
v vu v p v v
t x y y x y
+ + = + +
+ + = + +
-The conservation form follows directly from the model of an infinitely small volume
fixed in spaceFinite difference form of momentum equations will be somewhat akin
to dicretized equations obtained from a finite volume approach.
-Formulation of pressure correction
method by Patankar and Spalding involved finite
volume approach using conservation form of the governing PDEs.
(5)
(6)
-We choose forward difference
in time and central difference
for spatial
derivatives
-The scheme is not the only approach,just a reasonable choice.
-Recall: *red grid points:p
*yellow grid points:u, blue grid points: v
-We will difference x momentum equation centered around (i+1/2,j)
1/ 2
1/ 2 , 1/ 2 1, 1/ 2
, 1/ 2 1, 1/ 2
1
At point a: ( )
2
1
At point b: ( )
2
j
j i j i j
i j i j
v v v
v v v
+ + +
+
+
+
+
Average values of v at points a
and b (top and bottom)
Centered around point (i+1/2,j) ,a difference representation of x momentum equation:
1 2 2
1/ 2, 1/ 2, 3/ 2, 1/ 2, 1/ 2, 1 1/ 2, 1
1, , 3/ 2, 1/ 2, 1/ 2, 1/ 2, 1 1/ 2, 1/ 2, 1
2 2
( ) ( ) ( ) ( ) ( ) ( )
2 2
2 2
( ) ( )
n n n n n n
i j i j i j i j i j i j
n n n n n n n n
i j i j i j i j i j i j i j i j
u u u u uv uv
t x y
p p u u u u u u
x x y
+
+ + + + + +
+ + + + + + +
= +
+ +
+ +
1
1/ 2, 1/ 2, 1, ,
( ) ( ) ( )
n n n n
i j i j i j i j
t
u u A t p p
x
+
+ + +
= +
2 2
3/ 2, 1/ 2, 1/ 2, 1 1/ 2, 1
3/ 2, 1/ 2, 1/ 2, 1/ 2, 1 1/ 2, 1/ 2, 1
2 2
( ) ( ) ( ) ( )
2 2
2 2
( ) ( )
n n n n
i j i j i j i j
n n n n n n
i j i j i j i j i j i j
u u uv uv
A
x y
u u u u u u
x y
+ + + +
+ + + + + +
= +
+ +
+ +
Difference equation representing x momentum equation
: and v use different grid points than those for u. Note v
(7)
Centered around point (i,j+1/2) ,a difference representation of y momentum equation:
Average values of u
at c and d (left and right sides)
1/ 2, 1/ 2, 1
1/ 2, 1/ 2, 1
1
At point c: u= ( )
2
1
At point d: u ( )
2
i j i j
i j i j
u u
u u
+
+ + +
+
= +
Using forward difference in time,central differences in space:
1
, 1/ 2 , 1/ 2 , 1 ,
( ) ( ) ( )
n n n n
i j i j i j i j
t
v v B t p p
x
+
+ + +
= +
+ + + +
+ + + + + +
= +
+ +
+ +
: and u use different grid points than those for v. Note u
(8)
At the beginning of each new iteration, p=p*
Equation 7 and 8 become respectively:
* 1 * * * *
1/ 2, 1/ 2, 1, ,
( ) ( ) ( )
n n
i j i j i j i j
t
u u A t p p
x
+
+ + +
= +
* 1 * * * *
, 1/ 2 , 1/ 2 , 1 ,
( ) ( ) ( )
n n
i j i j i j i j
t
v v B t p p
x
+
+ + +
= +
= +
= +
(11)
(12)
-Equations (11) and (12) are x and y momentum equations in terms of pressure
corrections p,u,v
defined by (1) ,(2) and (3).
-We are in a position to obtain a formula for the pressure correction p
by
insisting that the velocity field must satisfy the continuity equation.
-However, pressure correction method is an iterative approach
there is no inherent reason why the formula designed to predict p
from one
iteration to the next be physically correct.
-We are concerned with only two aspects:
1) Formula for p
must yield the values that ultimately lead th the proper,
converged solution
2) In the limit of converged solution,the formula for p
must reduce to the
physically correct continuity equation.
When this convergence is achieved, p0, and the formula for p
reduce to the
physically correct continuity equation.
Can use a formula with a numerical artifice !
Let us arbitrarly set A', B', ( ') , ( ') equal to zero in (11) and (12)
n n
u v
1
1/ 2, 1, ,
1
, 1/ 2 , 1 ,
( ') ( ' ' ) (13)
( ') ( ' ' ) (14)
n n
i j i j i j
n n
i j i j i j
t
u p p
x
t
v p p
y
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
=
1
, 1/ 2
1 1 1
, 1/ 2 , 1/ 2 , 1/
1 1
, 1/ 2 ,
2
1/ 2 , 1 ,
( )
Definition of ( ')
( ') ( ) ( *)
Equation (14) becomes:
(16)
Returning to continuity equation:
( u)
( *) ( ' ' )
n n n
i j i
n
i j
n n n
i j i j i
j i
j
j i j
v
t
v v p p
y
v v v
+
+
+ +
+ +
+
+
+ +
+
+ +
=
=
i+1/2,j i-1/2,j i,j+1/2 i,j-1/2
( )
0
x
And writing corresponding central difference equations around (i,j)
( u) ( u) ( ) ( )
0 (17)
v
y
v v
x y
+ =
+ =
, 1, 1, , 1 , 1
' ' ' ' ' 0
i j i j i j i j i j
ap bp bp cp cp d
+ +
+ + + + + =
Substituting (15) and (16) in (17):
1/ 2, 1/ 2, , 1/
2 2
2 , 1/ 2
2 2
2
( ) ( ) (
1 1
( *) ( *) ( *) (
( )
*
)
)
i j i j i j i j
d u u v v
x
t t t t
a b c
y x y
y
x
+ +
= + = =
= +
(18)
-Elliptic behaviour,consistent with the fact that a pressure disturbance will propagate
everywhere throughout an incompressible flow.
-Thus, equation (18) can be solved for p
by means of a numerical relaxation
technique, like Gauss-Seidel iteration
During the course of the iterative process,u* and v* define a velocity field that does not
satisfy the continuity equation ;hence in (18) , for all but the last iteration.
-d is a mass source therm.
-Theoretically d=0 for the last iteration.
-Although a mathemetical artifice was used to obtain (18),in the last iterative step we
can construe (18) as being a proper physical statement of the conservation of mass.
0 d
, 1, 1, , 1 , 1
' ' ' ' ' 0
i j i j i j i j i j
ap bp bp cp cp d
+ +
+ + + + + = (18)
Pressure correction formula
The pressure correction formula (18) is a central difference formulation of the Poisson
equation in terms of pressure correction p.
2 2
2 2
' '
(19)
-If second partial derivatives in (19) are replaced by central differences, and
-If Then equation (18) is obtained.
( )
p p
Q
x y
d
Q
t x
+ =
=
Notes:-Pressure correction formula is nothing than a diiference equation representing
Poisson equation for p.
-Poisson equation is elliptic;which mathematically verifies elliptic behaviour of
pressure correction formula
The Numerical Procedure:The SIMPLE Algorithm
-Following description is the essence of the SIMPLE algorithm as seth forth in Patankar.
-SIMPLE: Semi-implicit method for pressure linked equations.
-Semi implicit refers to our arbitrary setting of
allowing the pressure correction formula(18),to have p
appearing at only 4 grid points.
-If this artifice had not been used,resulting pressure correction
formula would have
included velocities at neighboring grid points.
-These velocities are influenced by pressure corrections in their
neighborhood, and
resulting pressure correction formula would have reached much further into the flow field.
Results in fully implicit equation
', ', ( ') , ( ') equal zero in (11) and (12)
n n
A B u v
n
n n
1)Guess values of (p*) at all the pressure grid points.
Also arbitrarly set values of ( u*) and ( *) at proper
velocity grid points.
-Here we are considering the grid points internal to the flow fi
v
n+1
n+1
n+1 n+1
eld;
not boundaries.
2)Solve for ( u*) from equation (9) and
( *) from (10) at all internal points.
3)Substitute these values of ( u*) and ( *) into (18),
and solve for p' at all internal
v
v
n+1
n+1
n+1
points.
4)Calculate p obtained in all internal points from equation (1)
( *) '
5)The values of p obtained in step 4 are used
to solve the momentum
n
p p p = +
n+1 n
equations.
For this,we designate p obtained above as the new values of (p*)
to be inserted in (9) and (10)
Return to step 2 ;repeat until convergence.
Reasonable criterion is when mass source term "d" aprroaches zero.
Step by step procedure for SIMPLE algortihm:
-When convergence is achieved,velocity distribution is obtained which satisfies
continuity equation.
-Equation (18) is to aim the iteration process in such a direction that when the velocity
distribution is calculated from the momentum equations,it will eventually converge to
correct distribution which satisfies continuty equation.
-Eq. (5) and (6) are the unsteady momentum equations,and hence the corresponding
difference equations (7) and (8) utilize the standart superscript notation ,n
for a given
time level and n+1 for the next time level.
-However,no problem, because pressure correction method is deisgned for steady
flow,and we obtain this via an iterative process.
-Sequential iteration steps ,with no significance to any real transient variation.
-t is a parameter which has some effect on the speed at which convergence is
achieved.
-Eq. (18) may diverge in some cases:
Patankar suggests using some underrelaxation in such cases:
Instead of using the equation in step 4 , use:
1
( *) '
where is an underrelaxation factor;a value of 0.8 is suggested.
n n
p
p p p
+
= +
Boundary Conditions For the Pressure Correction Method
1 3 5 7
1)At inflow boundary,p and v are specified and u is allowed to float.
p' p' p' p' 0
Then p' is zero at the inflow boundary.
= = = =
8 10 12 14
15 17 19 21 22 24 26 28
2)At the outflow boundary,p is specified and u and v are allowed to float.
p' p' p' p' 0
3) At the walls,the viscous,no slip condition holds at the wall.
0 u u u u u u u u
= = = =
= = = = = = = =
Since (18) is elliptic,and is solved by relaxation technique,a boundary condition
associated with p
must be specified over the complete boundary containing
the computational domain.
A condition associated with p
at walls derived as:
-Evaluate y momentum equation at the wall where u=v=0
( )
( )
2 2
2 2
2 2
w
2 2
(19)
In equation (19),since v 0, / 0.
Also near vicinity of the wall,v is small: / 0
So: 0
w w
w
w
w
p v v
y x y
v x
v y
p
y
= +
= =
=
=
1 3 16 29 5 7
(20)
Discretizing (20):
etc. p p p p p p = = =
Grid
Generation
Introduction:
Have
assumed
rectangular
domain
Any
curved
domain can be mapped
to
rectangle
Flow
in curved
passage
Transformation
of governing
partial
differential
equations.
Mapping
( , )
( , )
x y
x y
=
=
Relations
between
physical
and
computational
planes
Physical
plane
Computational
plane
i,j
i,j
x
y
Main
issue: how
to
find
the
location
of the
grid
points
in the
physical
domain
(x,y): physical
coordinates
(,): computational
coordinates
(1)
, , , called metrics of transformation
x
y
y
x
y
x x
x
y
y
= +
= +
Example:
( ) ( )
( )
0 (A) original PDE
( , )
( , )
;
, 0 (B) transformed PDE
x x y y
x y x y
u u
c y
x y
x y
x y
u u u u u u
x y
u u
c c y
+ + =
=
=
= + = +
+ + + + =
Equation
(B) is solved
on a uniform
grid
in the
computational
plane
Relationship
between
physical
and
computational
planes
are
given
by
the
metrics
of
transformation, i.e. x , y , x , y .
Notes:
1. Form
and
type
of the
transformed
equation
remains
the
same
as the
original
partial
differential
equation.
x
x x
=
i.e. metrics
represent
the
ratio
of are
lengths
in the
computational
plane
to
that
of the
physical
plane.
2.
(3)
x y
x y
d dx
d dy
=
To
transform
back
to
physical
plane,
or
reversing
the
role of independent
variables, i.e.
( , )
( , )
x x
y y
=
=
Computation
of metrics
(2)
x y
x y
d dx dy
d dx dy
= +
= +
or in a compact form,
1
,
(6)
Jacobian of transformation
J: ratio of areas (volumes in 3-D) of computational space to t
1 1
1 1
,
hat of phy
=
si
J
x y
x
x y
y
y
x
y x
J J
y x
J J
x y x
x
y
y
x
y
=
= =
= =
=
cal space.
Compare
4 with
3
(4)
x x d
dx
y y d
dy
=
; dx x d x d dy y d y d
= + = +
Notes:
1.
Mapping
must
be
one-to-one. J0
2.
Want
smoothness
in grid
distribution
(smooth
behavior
of metrics)
3.
May want
to
cluster
points
in certain
regions
of physical
spaces
4.
May want
orthogonality
in grid, at least
in certain
regions. Excessive
grid
skewness
should
be avoided.
In
determining
the
grid
points
(mapping) following
requirements
are
necessary.
Methods
of Grid
Generation
1.
Conformal
mapping
(based
on complex
variables),
not extendible
to
3-D
2.
Algebraic
Methods
3.
Solution
of Differential
Equations
(Partial
differential
equations)
Fixed
Grid,
independent
of solution.
Adaptive
Grid,
evolves
as a result
of solution
of flow
equations
(high
gradients).
Algebraic
Methods
Example: Figure
3&4 : half
difusser
2 1
1
, / ( ) (7)
, (8)
represents
upper boundary
x y f x
H H
x y H
L
= =
= = +
To
generate
grid
1.
Define a uniform
grid
in ,
plane
2.
Corresponding
points
in physical
plane
found
from
(8)
Metrics
and
Jacobian
of transformation
must
be evaluated
before
any
transformed
Partial
Differential
Equations
can be solved.
Known functions are used in one, two
or three dimensions to take arbitrary
shaped physical regions into a
rectangular computational domain
1+x
x
y
(L,0)
(0,0)
(0,H
1
)
(L,H
2
)
H
1
H
2
L
i=M+1
i=1
j=M+1
L
1.0
Example:
Generation
of Grid: Algebraic
Grid
1.
define a uniform
grid
in ,
plane
Analytical
calculation of metrics
2 1
2 2
1 2
1
2 1
1
1, 1,
,
, 1 , 1
,
1 , 0
( )
( )
1 1
( )
2
for interval points
,
2
To numerically find metrics
x y
x
y
i j i j
i j
i j i j
i j
H H
yf x
L
f x
H H
H
L
f x H H
H
L
x x
x
x x
x
+
+
= =
= =
+
= =
+
,1 ,2 ,3
,1
. ,
evaluate
evaluate , , , from (6)
derivatives at boundaries are evaluated with forward or backward 2nd order approximation
3 4
1;
2
x y x y
i i i
i
etc y y
J x y y x
x x x
j x
=
+
= =
Clustering
Techniques
To
cluster
near
bottom
(Consider
duct
problem)
( ) ( )
1
1
1 /
log
1 /
1 1<
1
log
1
: clustering parameter
as 1 more grid points near y=0
Inverse
1
1 1
1
1
1
1
x
y H
y H
x
y H
=
+
+
= <
+
=
+
+
=
+
+
Metrics
( )
2
2
1 , 0
2
0 ,
1
1 / log
1
= =
= =
+
x x
y y
H y H
( )
( )
( )
2 1 2
log
2 1 2
1
1
log
1
0 clustering at y=H
1/ 2 clustering equally at y=0 , H
Clustering on both walls
x
y
H
y
H
=
+ +
+ +
= +
+
=
=
Clustering
in Interior
( )
( )
( )
1
1
sinh 1 sinh
1 1 ( / )
1
log
2
1 1 ( / )
D is where clustering desired
x
y
A A
D
e D H
A
e D H
=
= +
+
=
+
Remarks on Algebraic
Methods
Advantages:
1.
fast
computationally
2.
metrics
can be evaluated
analytically,
avoiding
numerical
errors
3.
clustering
easy
Disadvantages
1.
smoothness
and
skewness
hard to
control
2.
discontinuities
at boundary
may
propogate
into
interior,
errors
due
to
sudden
changes
in metrics.
Algebraic methods (continued)
Example:
Body fitted
mesh is desired
to
solve
for
the
flow
in a divergent
nozzle.
x
y
x=1
x=2
1
4
y=x
2
y=x
2
1x2
Nozzle
geometry
Equally
spaced
increments
in x direction
=x
Uniform
division
in the
y direction
2
max
y
=
y
y
x
=
Y
max
: nozzle
boundary
equation.
x
y
x=1
x=2
x=
y=
2
physical
coordinates
3.06
=0.25 , =0.25
3.0
1.68
1.53
2.2968
1
1
2
1.25 1.75
0.25
Metrics
of transformation
x
= 1 ,
y
= 0
3 2 2
1 1 2
2 ,
x y
y
x x
= = = =
If
numerical
methods
are
used
to
generate
required
transformation
use
second-
order
finite
difference
, , ,
x y x y
y x y x
J J J J
J x y y x
= = = =
=
Example:
Select
point
(1.75 , 2.2969) = (x,y)
0.75
2 2 =-0.85714 analytical
3
1.75
x
x
= =
Numerical
calculation
( )
( )
1 -1
1
2 , -
2
3.0625 1.53125
3.06250
2 0.25
3 1.6875
2.625 0.85714
2 0.25
not always the same for many problems
a a
x
x
y
y y
J x y y x y
J
y
y
+
= = = =
= =
= = =
NORMALIZING TRANSFORMATION
-1
-1
+1
1
1,1
=constant
=constant
x
y
1,1
2,0
0,0
0,1
( ) ( ) ( ) ( )
( ) ( ) ( ) ( )
1 3
, 1,1 , 1,1
2 2
1
, 1,1 , 0,1
2
x x y
y x y
+
= = =
+
= = =
Any
quadrilateral
physical
domain can be transformed
into
a rectangle
in
computational
space
by
use
of a normalizing
transformation.
1+x
x
y
2
1
0
1
x
x=
y=(1+ )
2+x
4(x-1)
1,0
0,2
2,4
x
x=a +b +c
y=d +e +f
( )
x= (1+ )
y=2 1+
Example:
( )
2
2
1
2
2
2
1
x
x
y
x
= +
=
Most
problems, boundaries
are
not analytic
functions
but are
simply
prescribed
as a
set of data points.
Boundaries
must
be approximated
by
a curve
fitting
procedure
to
employ
algebraic
mappings.
Tension
splines, avoids
wiggless
in boundary
Algebraic
mappings
summary
direct
analytical
evaluation
of metrics
can be applied
to
3D problems
straightforward
way
some
ingenuity
is required
for
a proper
grid
Elliptic
Grid
Generators
For
situations
where
all
physical
boundaries
specified
Smoother
grid
Example:
Heat
conduction
in a solid
flux
lines
Constant
T lines
T
0
T
1
Looks
like
a good
grid
Let
,
satisfy
Laplaces
equation.
0
0 (9)
xx yy
xx yy
+ =
+ =
(,) coordinates
in computational
space
(x,y) coordinates in phsical
space
dT/dx=0
-k dT/dx=h(T-Tinf
)
Iterative scheme is used to solve
Isothermal lines, grid lines
To
transform
equations
(9) dependent
and
independent
variables
are
interchanged
see
Appendix
E
2 2
2 2
2 0 (10)
2 0 (11)
(12)
ax bx cx
ay by cy
a x y
b x x y y
c x y
+ =
+ =
= +
= +
= +
System
of equations
(10)-(11) is solved
in computational
domain (,) to
provide
grid
point
locations
in physical
space
(x,y)
Eqs. (10)
(12) is a
set of coupled
non-linear
elliptic
equations
Solve
numerically
,
linearization
procedure
is necessary
a,b,c are
evaluated
at the
previous
iteration
level.
Simply-Connected
Domain:
Any
contour
connecting
2 points
can be deformed
without
passing
out
of region.
Domain which is reducible & can be contracted to a point,
i.e, no object within the domain
Procedure:
1.
start with
test grid
generated
by
same
algebraic
method
this
defines
at every
point
in computational
and
physical
space
an estimate
of
x(,) , y(,)
2.
discretize
(10)-(11) linearize
by
calculating
a,b,c, and
hold
constant.
Simply-Connected
Domain: Example
i=1
N
M
x
y
j=1 j=M
i=N
j=1
Example:
( ) ( )
2 2
, 1 , 1 , 1 , 1
1, , 1, 1, 1 1, 1 1, 1 1, 1 , 1 , , 1
2 2
2 2
discretization of (10)
2 2
a 2 0 (13)
4
i j i j i j i j
i j i j i j i j i j i j i j i j i j i j
x x y y
a
x x x x x x x x x x
b c
+ +
+ + + + + +
= +
+ + +
+ =
Can write similar
equation
for
y (replace
x by
y)
Iterate
Gauss-Seidel
and
update
a,b,c from
time to
time
Note
grid
on boundaries
of physical
plane
must
be specified
If
Gauss-Seidel
iterative
scheme
is used,
equation
(13) is arranged
as
( ) ( ) ( ) ( )
, 1, 1, , 1 , 1
2 2 2 2
1, 1 1, 1 1, 1 1, 1
2
2
i j i j i j i j i j
i j i j i j i j
a c a c
x x x x x
b
x x x x
+ +
+ + + +
+ = + + +
+
( ) ( ) ( ) ( )
, 1, 1, , 1 , 1
2 2 2 2
1, 1 1, 1 1, 1 1, 1
2
2
i j i j i j i j i j
i j i j i j i j
a c a c
x x x x x
b
x x x x
+ +
+ + + +
+ = + + +
+
( ) ( ) ( ) ( )
, 1, 1, , 1 , 1
2 2 2 2
1, 1 1, 1 1, 1 1, 1
2
2
i j i j i j i j i j
i j i j i j i j
a c a c
y y y y y
b
y y y y
+ +
+ + + +
+ = + + +
+
For yi,j
,
1
, ,
2
2
, ...
N M
k k
x i j i j y
i
j
T x y
E x x E
E E E
+
=
=
= =
= + <
Computational
domain (uniform grid)
i.e. location
of every
grid
point
(,) is known.
Employ
Elliptic
Grid
Generation
to
determine
grid
points
in physical
space. Equations
(10)
& (11)
need
to
be solved.
Similar
procedure
Gauss-Seidel
Difference, treatment
of grid
points
on B
3
&B
4
, i.e. on the
branch
cut.
Location
of grids
along
line
AC must
be updated. Compute
new
values
of x
1,j
and
y
1,j
after
each
iteration.
Note:
It
is not necessary
to
compute
x
N,j
and
y
N,j
since grid
lines
i=1 & i=N are
coincident.
x
N,j
= x
1,j
and
y
N,j
= y
1,j
Gauss-Seidel
Formulation
( ) ( )
( ) ( )
{ }
2, 1, 1, 1 1, 1 2, 1 2, 1 1, 1 1, 1 2 2
1,
2 2
1,
2
(14)
2
similarly,
.. (15)
..
j N j j j j j N j N j
j
j
a c b
x x x x x x x x
x
a c
y
+ + +
+ + + +
=
+
=
Use
equation
(14)
& (15)
after
each
iteration
to
find
new
location
of grid
points
on the
branch
cut.
Skewness
in grid
If
grid
points
on branch
cut
are
kept
fixed, highly
skewed
grids
at branch
cut
are
obtained!!
Example: airfoil,
( )
( )
1/ 2 2 4
0.2969 0.126 0.3516 ...
0.2
max thickness of chord
c
x= N:odd, symmetry of grid points
N+1
1
2
t
y x x x x = + +
( )
( ) ( ) ( )
( ) ( ) ( )
Circle
2
=
N-1
*
, *cos
, *sin
i i
x i M R i
y i M R i
=
=
=
y
i=N
i=1
R
x
Doubly-connected
region
GRID CONTROL:
1.
clustering
in different
regions
( , )
( , )
, : sources of sinks
xx yy
xx yy
P
P
Q
Q
+ =
+ =
Can show
{ }
{ }
2
2
1
2 P
1
2 Py
P,Q complicated functions
ax bx cx x Qx
J
ay by cy Qy
J
+ = +
+ = +
Thonson, JF., Warsi, Z.U.A, & Mastin, C.W.
Numerical
Grid
Generation
North Holland, 1985
SOFTWARES Gridgen, Eagle, Gambit, ...
2. orthogonally
at surface
Steger, J.L & Sorenson, R.L.
PDE
Techniques (summary)
PDEs
are
used
to
create
the
grid
system
A system
of PDEs
is solved
for
the
location
of the
grid
points
in physical
domain
Computational
domain is a rectangular
shape
with
uniform
grid
spacing
PDE Methods
1.
elliptic
2.
parabolic
3.
hyperbolic