You are on page 1of 334

Numerical Fluid Dynamics

z Dr. Hasan Gunes


z guneshasa@itu.edu.tr
z http://atlas.cc.itu.edu.tr/
~guneshasa
INTRODUCTION

The Scientific Method and


Mathematical Modeling
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.

The process of modeling of physical systems in the real world should


generally follow the path illustrated schematically in the chart below:
Numerical Solution Procedure
Physical System
i.e. Reality

Physical Laws +
1
Models

Mathematical Model
Analytical Solution
i.e. Governing Equations
(Fluid Dynamics Æ PDEs)

2 Discretization

System of Algebraic
Equations (or ODEs)

3 Matrix Solver

Numerical Solution
Physical
World

Physical
Properties
Assumptions
•Algebraic eqs.
•Differential eqs.
Mathematical Model oOrdinary diff. eqs.
(Equations) oPartial diff.eqs.

Conservation Laws

Linear Non linear

Iterations Linearized Non linear


Approximation (Exact or approximate)

Nonlinear
Linear solution solution
(Analytical, Numerical)
•FORTRAN
•C
Test solution •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

sea surface temperature output from an eddy resolving ocean model


Source: http://www.epm.ornl.gov/chammp/chammp.html
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 1011 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, andE.g.,
muscles, details of

- 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

PDE’s (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: a − a * < ε (tolerance)

a − a*
Relative convergence: <ε
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+1

i-1, j i+1, j

i,j

J=1
i, j-1

X
i=1 i=N
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 Neumann’s 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. Lax’s 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


∂ρ ⎛ →⎞
+ ∇ ⋅⎜ ρ V ⎟ = 0 or in Cartesian coordinate system
∂t ⎝ ⎠

∂ρ ∂ ( ρu ) ∂ ( ρv) ∂ ( ρw)
+ + + =0
∂t ∂x ∂y ∂z

Non conservative form of continuity eq.

∂ρ ∂ρ ∂u ∂ρ ∂v ∂ρ ∂w
+u +ρ +v +ρ +w +ρ =0
∂t ∂x ∂x ∂y ∂y ∂z ∂z
Example 2: 1-D heat conduction
∂T ∂ ⎛ ∂T ⎞
ρc = ⎜k ⎟ Conservative form
∂t ∂x ⎝ ∂x ⎠

∂T ∂ 2 T ∂k ∂T
ρc =k 2 + Non-conservative
, form
∂t ∂x ∂x ∂x
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.

Dimensionless Equations

tV ⎛ x, y ⎞ ⎛ u, v ⎞ p
T= ∞ x, y = ⎜ ⎟ (u, v) = ⎜⎜ ⎟⎟ P=
L ⎝ L ⎠ ⎝ V∞ ⎠ ρ ∞V∞2

L: characteristic length ρ ∞ , V∞ : reference density, velocity



∇ ⋅V = 0
∂V → → 1 2→
+ (V ⋅ ∇) V = −∇P + ∇ V Non-conservative form
∂t Re

ρ ∞V∞ L
Re =
µ∞
body force is neglected (Fr if not)

∇ ⋅V = 0
∂V → → 1 2→
+ (V ⋅ ∇) V = −∇P + ∇ V
∂t Re
∂u ∂ 2 ∂ 1 ⎛ ∂ 2u ∂ 2u ⎞
+ (u + p) + (uv) = ⎜⎜ 2 + 2 ⎟⎟
∂t ∂x ∂y Re ⎝ ∂x ∂y ⎠

∂v ∂ ∂ 2 1 ⎛ ∂ 2v ∂ 2v ⎞
+ (uv) + (v + p) = ⎜⎜ 2 + 2 ⎟⎟ Conservative form
∂t ∂x ∂y Re ⎝ ∂x ∂y ⎠
Exercise: Prove that conservative & non-conservative form of NS eqs. are equal to
each other.
Important in numerical solution algorithms
1) Primitive-variable solutions, u , v, p
2) Vorticity-Stream Function Formulations, Ω, ψ

2-D ρ = constant
→ →
Ω = ∇x V
∂Ψ
u=
∂y
∂Ψ
v=−
∂x
CLASSIFICATION OF DIFFERENTIAL EQUATIONS

O.D.E P.D.E
One independent variable More then one independent
variable
dy ∂ 2u ∂ 2u
= f ( x, y ) + 2 =0
dx ∂x 2
∂y
y = y ( x) 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

y (0) = 0 y '(0) = 0 ⇒ IVP


e.g. y ''+ sin ty = cos t
y (0) = 0 y (1) = 2 ⇒ BVP

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.

1 h A 's
P( x) = ⋅ A 'c ( x ) R ( x) = − ⋅
Ac k Ac
T(0) = 200 0C
x
d 2θ dθ
2
+ P ( x ) + R( x)θ ( x) = 0
h = 20 W / m2 0C dx dx
T∞ = 20 0C
ODE of the boundary value type is obtained by
T (0) = Tw θ = T − T∞ neglecting the influence of all but one of the
independent variables.
T ( L) = Tt
ORDINARY DIFFERENTIAL EQUATIONS

A. Initial Value Problems


First order ODE
dy
= f ( x , y ) ⇒ Φ ( x, y , y ' ) = 0 General form
dx family of
solutions

Chose one solution using the initial condition y ( x0 ) = y0

Exact Solutions
1. Linear equations
dy
= p( x) y + q ( x)
dx

∫ p( x)dx} Not analytically evaluated, not analytic problems (need numerical solution)
Evaluated analytically, analytic problems

General Solution is in the form

y ( x) = e ∫ ∫ dx + ce ∫
p ( x ) dx − pdx pdx
∫ q ( x )e
2. Separable Eqs.

dy dy y (1) = 2
= F ( x)G ( y ) = xy (x 2
+1) )
dx dx y = 2e 2 x2
2
y = ce 2
dy x 2
∫y ∫= xdx ⇒ ln y =
2
+ c1 c=
e

2 1

C=0
1

-2 -1

dy M ( x, y ) ∂N ? ∂M
3. Exact = =−
dx N ( x, y ) ∂x ∂y
4. Homogeneous

dy y dy dp
= f(x ) = p⇒ = p+x
dx y 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:

an y ( n ) + an −1 y ( n−1) + ........... + a1 y '+ a0 y = F (t )

dny dny dy d n −1 y
y (n)
= n ,.... or = f (t , y, ,......., n −1 )
dt dt n
dt dt

Theorem: An nth order ODE can be represented as a system of n first order ODEs.
Let us define new variables y1 , y2 , y3 ,......., yn +1

y1 = t , y2 = y , y3 = y ', y4 = y '',........., yn = y ( n − 2) , yn +1 = y ( n −1)

y1 ' = 1
……….

y2 ' = y3 yn ' = yn +1
……….
y3 ' = y4 y'n+1 = f (y1, y2, y3,.....yn+1)
.
.

I.C.s y2 = (t0 ) , …, yn +1 = (t0 ) all specified

In vector relation,
Y ' = F (Y ) Y (t0 ) = yi
Y = ( y1 , y2 ,......., yn +1 )T , Y ' = ( y '1 , y '2 ,......., y 'n +1 )T ,
F = (1, y3 , y4 ,......., yn +1 , f )T T: Transpose.
dy
Eg: y ''+ b(t ) y '+ c(t ) y = d (t ) y'= y (t0 ) = y0 y '(t0 ) = y1
dt

Initial Var. New Variable Initial Value Dif.Eq.


y z1 y0 dz1
= z2
dt
y’ z2 y1 dz2
= d ( z3 ) − d ( z3 ) z2 − c ( z3 ) z1
dt
t z3 t0 dz3
=1
dt
dz
dz3 = f ( z)
=1 dt
dt ⎡ f1 ⎤ ⎡ z2 ⎤
dz1 f = ⎢⎢ f 2 ⎥⎥ = ⎢⎢ d ( z3 ) − c( z3 ) z1 − b( z3 ) z2 ⎥⎥
= z2
dt ⎢⎣ f3 ⎥⎦ ⎢⎣ 1 ⎥⎦
dz2 ⎡ y0 ⎤
= d ( z3 ) − d ( z3 ) z2 − c( z3 ) z1
dt z (t0 ) = ⎢⎢ y1 ⎥⎥
⎢⎣ t0 ⎥⎦
Example 2 x ''' = cos x + sin x '− e x '' + t 2
x(0) = 3
x '(0) = 7
x ''(0) = 13
Old New Initial
Diff. eq.
variables variables value
x’1=1
t x1 0
x’2=x3
x x2 3
x’3=x4
x’ x3 7
x’4=cos x2+sin x3-
x’’ x4 13
ex4+x12

So, corresponding first order system is:

⎡ x1 ' ⎤ ⎡ 1 ⎤ ⎡0⎤
⎢ x '⎥ ⎢ ⎥ ⎢3⎥
x
x' = ⎢ 2 ⎥, F =⎢ 3 ⎥ x(0) = ⎢ ⎥ at x1=0, t=0
⎢ x3 ' ⎥ ⎢ x4 ⎥ ⎢7⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢⎣ x4 '⎥⎦ ⎢⎣ cos x2 + sin x 3 − e x4
+ x1⎥
⎦ ⎣13⎦
Example 3 .
x '' = x − y − (3x ') 2 + ( y ')3 + 6 y ''+ 2t
y ''' = y ''− x '+ e x − t
x(1)=2 , x’(1)=-4 , y(1)=-2 , y’(1)=7 , y’’(1)=6

Initial
Old variables New variables Diff. eq.
value
x’1=1
t x1 1
x’2=x3
x x2 2
x’3=x2-x4-
x’ x3 -4
9x32+x53+6x6+2x1
y x4 -2
x’4=x5
y’ x5 7
x’5=x6
y’’ x6 6
x’6=x6-x3+ex2-x1

x(1) = [1, 2, −4, −2, 7, 6]


T
REVIEW OF TAYLOR --DERIVATION
f(t)

t=a
f(a), f’(a), f’’(a),…… t
f(t)=a0+a1(t-a)+a2(t-a)2+………+an(t-a)n+…….
a0=f(a)
a1=f’(a)
f’(t)=a1+2a2(t-a)+3a3(t-a)2+………+nan(t-a)n-
1+…….
a2=(1/2)f’’(a)
a3=(1/2*3)f’’’(a) f’’(t)=2a2+2*3a3(t-a)+………+n*(n-1)an(t-a)n-2+…….

ai=f(i)(a)/i!
N (n )
f (a )
Taylor series expansion of f(t) about the point t=a. f ( t ) = ∑
n=0 n!
(t − a ) n + E

For a=0 the series is called MacLaurin series.


N (n )
f (a )
Truncation: f (t ) = ∑
n=0 n!
(t − a ) n + E E: Truncation Error

f ( N +1) (ξ ) a ≤ξ ≤t
E= (t − a ) N +1
( N + 1)!

f(t) N
f ( n ) ( x) n
f ( x + h) = ∑ h +E
n =0 n!

f ( N +1) (ξ ) N +1
E= h
( N + 1)!
h
x ≤ξ ≤ x+h
t=x t=x+h
π
Example: Develop the Taylor series for Sin (x) about the point x=
2
f(x)=Sin x , f’(x)=Cos x , f’’(x)=-Sin x , f’’’(x)=-Cos x , fIV(x)=Sin x
π
f ( ) = 1,.......
2
1 π 1
sin x = 1 − ( x − ) + ( x − π ) 4 − ..........
2

2! 2 4! 2
( 2 k +1) π (2k ) π π
f ( ) = 0 f ( 2 ) = (−1)
k x− =h
2 2

( −1) ( −1)
k k
π N N
sin( + h) = ∑ ( x − π )2k + E sin x = ∑ ( x − π )2k + E
2 k = 0 2k !
2 k =0 2k ! 2
1
(− 1)k
Estimate the error for h=10-2 ∑
k =0 2 k!
h 2k
π 1
sin( + 0.01) = 1 − 10−4 = 0.99995
2 2 10−6
E ≤
3!
( )
3

Taylor error formula 10−2 π π


E = cos ξ <ξ < + 0.01 bound-on error
3! 2 2
Numerical Solution of ODEs of the Initial Value Type
Taylor’s Method:

dy
= f ( x, y ) y ( x0 ) = y0 y ( x0 + h) = ?
dx
Difference methods or discrete variable methods
Continuous function y(x) is approximated by a set of discrete values yi,

dy h2 d 2 y h3 d 3 y
y ( x0 + h) = y ( x0 ) + h + + + ........
y dx x0 2! dx 2 x0
3! dx 3 x0

y dy
= f ( x0 , y0 )
dx x0
y
y d 2 y d ⎛ dy ⎞ df ∂f ∂f dy ⎡ ∂f ∂f ⎤
= ⎜ ⎟ = = + = + f
y0 dx 2 dx ⎝ dx ⎠ dx ∂x ∂y dx ⎢⎣ ∂x ∂y ⎥⎦ x0 , y0

x f = f ( x, y ( x ))
x0 x1 x2 xi b
d 3 y d ⎛ d 2 y ⎞ d ⎡ ∂f ∂f ⎤ ∂ ⎡ ∂f ∂f ⎤ ∂ ⎡ ∂f ∂f ⎤
= ⎜ 2 ⎟= ⎢ + f ⎥ = ⎢ +f ⎥ +f ⎢ +f
dx 3
dx ⎝ dx ⎠ dx ⎣ ∂x ∂y ⎦ ∂x ⎣ ∂x ∂y ⎦ ∂y ⎣ ∂x ∂y ⎥⎦

= f xx + f x f y + ff xy + ff xy + ff y2 + f 2 f yy

2
y ( x0 ) = y0
d y dy
2
= f ( x , y , ) → We need ⎛ dy ⎞
dx dx & ⎜ ⎟ = y1
⎝ dx ⎠ x0
Euler’s Method:

y
Target

y ( x0 + h) = y ( x0 ) + hf ( x0 , y0 )
y1
y0
x
x0 x0 + h = x1
dy
predicted tan α = = f ( x0 , y0 )
y dx
y1
error

y(x)
α Actual value
y0
yi +1 = yi + hf ( xi , yi )
h
x
x0 x0 + h = x1
Local truncation error: O(h2)

Global error: a) Accumulated local error


b) Switching of solution curves
c) Round off error
If y1 has an error → generates wrong value for f ( x0 + h, y1 )
Error

Round off
error

Truncation
error

Number of
Optimum
steps
*

[a,b] interval, at each step the local error

hM=b-a ( 2) h2
y (ck ) M =
( b − a ) y ( 2) h
= Q ( h)
2 2
MODIFIED EULER’S METHOD: HEUN'S METHOD
y

y1

y0
y1 = y0 + hf ( x0 , y0 )

x
x0 x0 + h = x1
f tan α = f ( x0 , y0 )
dy
f0 = f ( x, y ( x))
dx x +h 0

f1 f(x,y)
y ( x0 + h) = ∫
x = x0
f ( x, y ( x))dx + y0

slope averaging
x
x0 x0 + h = x1
f 0 = f ( x0 , y0 )
⎛ f 0 + f1 ⎞
y = y0 + hf 0
1
p
y = y0 + h ⎜
c
1 ⎟ (2)
⎝ 2 ⎠
f1 = f ( x0 + h, y1 ) = f ( x1 , y1 ) Trapezoidal rule

Use Euler as predictor to calculate y1, then calculate f1 & use eq. (2) to correct the result.
TAYLOR’S METHOD:
dx dx 5t 2 5
dt
= 5 xt x(1)=2 ∫ x = ∫ 5tdt ln x =
2
+C ln 2 =
2
+C

5 ⎛x⎞ 5 x 5 ( t 2 −1)
C = − + ln 2 ln ⎜ ⎟ = (t 2 − 1) =e 2
2 ⎝2⎠ 2 2

Taylor series method:


• Not practical to use Taylor’s series expansion method if f has complicated derivates,
therefore,
• No generalized computer program can be constructed
• nth order R-K is an alternative.
d2y
= 5 x + 5 xt (5t ) d3y
dt 2
3
= 25 x (2t ) + 5 xt ⎡
⎣ 5(1 + 5t 2
) ⎤⎦
dx
= 5 x + 25 xt 2
= 50 xt + 25 xt + 125 xt 3
= 5 x(1 + 5t 2 )

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 ) y ( x0 ) = y0 y ( x + h) = y ( x) + w1 F1 + w2 F2 w1 , w2 : weights
dx

F1 = hf ( x, y ) w1 = w2 = 1 ⇒ MODIFIED EULER
α =1 β =1 2

F2 = hf ( x + α h, y + β F1 ) Obtain α , β , w1 , w2 that the error is the same as in 2nd


order Taylor’s method.
(α h ) ( β F1 )
2 2
2(α h)( β F1 )
f xx + f yy + f xy + Q(h3 )
2! 2! 2!

⎧ df df ⎫
F2 = h ⎨ f ( x, y ) + α h + β F1 + Q(h 2 ) ⎬
⎩ dx dy ⎭
Taylor’s series for a function of two variables.
⎡ ∂f ∂f ⎤
y ( x + h) = y ( x) + w1hf + w2 ⎢ hf + α h 2 + β h 2 f ⎥ + ........
⎣ ∂x ∂y ⎦
= y ( x) + h( w1 + w2 ) f + w2 h 2 ⎡⎣α f x + β ff y ⎤⎦ + ......
h2
TAYLOR → y ( x + h) = y ( x) + hf + ⎡⎣ f x + ff y ⎤⎦ + ........
2!

w1 + w2 = 1
α = β =1
1
⇒ 2nd order Runge-Kutta
w2 =
2
4th Order Runge-Kutta: yk +1 = yk + w1 F1 + w2 F2 + w3 F3 + w4 F4

h
yk +1 ( x + h) = yk ( x ) + ( F1 + 2 F2 + 2 F3 + F4 )
6
F1 = f ( xk , yk )
⎛ h F⎞
F2 = f ⎜ xk + , yk + 1 ⎟
⎝ 2 2⎠
⎛ h F ⎞
F3 = f ⎜ xk + , yk + 2 ⎟
⎝ 2 2 ⎠
F4 = f ( xk + h, yk + F3 )
Extensions to systems of differential equations:

dx
= f (t , x, y )
dt x(t 0 ) = x 0
with
dy y (t 0 ) = y 0
= g (t , x, y )
dt
RK4
h
xk +1 = xk + ( F1 + 2 F2 + 2 F3 + F4 ) k = 0,1, 2,........MAX
6
h b−a
yk +1 = yk + (G1 + 2G2 + 2G3 + G4 ) h=
6 N

F1 = f (tk , xk , yk )
G1 = g (tk , xk , yk )
⎛ h h h ⎞
F2 = f ⎜ tk + , xk + F1 , yk + G1 ⎟
⎝ 2 2 2 ⎠
⎛ h h h ⎞
G2 = g ⎜ tk + , xk + F1 , yk + G1 ⎟
⎝ 2 2 2 ⎠
⎛ h h h ⎞
F3 = f ⎜ tk + , xk + F2 , yk + G2 ⎟
⎝ 2 2 2 ⎠
⎛ h h h ⎞
G3 = g ⎜ tk + , xk + F2 , yk + G2 ⎟
⎝ 2 2 2 ⎠
F4 = f ( tk + h, xk + hF3 , yk + hG3 )
G4 = g ( tk + h, xk + hF3 , yk + hG3 )
Örnek: TAYLOR (serisi) yöntemi:

y ' = x2 + y 2 y(0)=0 [a=0 , b=1]


n=10 step h= (b-a)/n=0.1

yi ' h 2 h3 y’ , y’’ , y’’’ necessary.


yi +1 = yi + h + yi ''+ yi '''
1! 2! 3! +O(h4) Truncation error results from taking finite
number of terms in an infinite series.
y ' = f ( x, y ) = x 2 + y 2
y '' = f x + ff y = 2 x + 2 yf = 2 x + 2 yy '
y ''' = f xx + 2 f xy y '+ f yy ( y ') 2 + f y ⎡⎣ f x + ff y ⎤⎦ = f xx + 2 f xy y '+ f yy ( y ') 2 + f y y ''
y ''' = 2 + 0 + 2( y ') 2 + 2 yy ''
x0=0 , y0=0 , y0’=0 , y0’’=0 , y0’’’=2
h2 h3 2
y1 = y0 + hy0′ + y0′′ + y0′′′ = (0.1)3 = 0.3333*10−3
2 3! 6
x1=0.1 , y1=0.333*10-3
y1′ ≅ 0.01 y1′′ ≅ 0.2 y1′′′≅ 2.0003 y5=0.041784 exact value 0.041791
h2 h3 .
y2 = y1 + hy1′ + y1′′ + y1′′′≅ 0.002667 .
2 3!
. y10=0.350064 exact value 0.350232
.
FREE FALLING OF A SOLID SPHERE

ρ dz
v=
z=0 at t=0 dt
g Motion of sphere:
v=v(t)=?
z=z(t)=? Displacement
d vacuum → only external force is gravitational force but
in a fluid additional forces

πd 3
1. Buoyant force: weight of fluid displaced bt body: − m f g − 6 ρ f g

2. Force on an accelerating body: due to flow field exists for frictionlessflow as well,
1 dv
− mf
2 dt
3. Viscous forces: In real fluid → shear stress on surface
CD: drag coef.[-]
ρ A=πd2/4 1
FD ≡ C D ρV 2 A
z 2
FD:total drag force
v A:projected frontal area

Drag due to
1) pressure forces (from drag) Valid for ρ = const. Over any body
2) friction forces (shear stress) Viscous fluid flow pg.182 (white)
CD = CD (Re, body shape) → dimensional analysis
Transition to turb.
I stokes “drag crises”
sol.
a
II
III c
b IV e
d

100 103 104 105 106 Re


Rough
surface
24
I – stoke’s solution → C D = , Re≤1
Re
24
II – approx. Fitted curve → C D = , 1<Re≤400
Re0.646

III - approx. Const. Drag coef. → C D ≈ 0.5 , 400<Re≤3x105


C D ≈ 0.000366 Re 0.4275 , 3x105<Re≤2x106

C D ≈ 0.18 , Re>2x106

4. Wave drag: M=v(1) M=V/a shock waves cause wave drag.

M<<1 wave drag is neglected


Newton’s 2nd Law applied to spherical body.
dv 1 dv 1 v ρ: density of sphere
m = mg − m f g − m f − ρ f v( C Re)
dt gravit f . 2 dt 2 π 2 D special case:
buoyant f. d
force due to accel. 4 in a vacuum: ρ = 0
viscous force
dv 1 ,A=1 , B=g , C=0
= [B − Cv / V / C D (Re)]
dt A
dz
=v
dt
ρf
1
(
A = 1+ ρ , B = 1− ρ g , C =
2
)

4d
, ρ=
ρ
dz
=v dz
dt = v = g (v )
dv dt
= g → v = gt + v0 dv 1
dt = [B − Cv / V / C D (Re)] = f (v)
dz 1 dt A
= gt + v0 ⇒ z = v0 t + gt 2
dt 2
RK4
1
F1 = f (v ) = [ ] vk +1 = vk +
h
(F1 + 2 F2 + 2 F3 + F4 )
A
G1 = g (v ) = v
6
h
⎛ h ⎞
F2 = f ⎜ v + F1 ⎟
z k +1 = z k + (G1 + 2G2 + 2G3 + G4 )
⎝ 2 ⎠ 6
⎛ h ⎞ h
G2 = g ⎜ v + G1 ⎟ = v + G1 [a, b] ≡ [0,10]
⎝ 2 ⎠ 2
b − a 10
⎛ h ⎞ h= = = 0.1
F3 = f ⎜ v + F2 ⎟ N 100
⎝ 2 ⎠
⎛ h ⎞ h h:step size
G3 = g ⎜ v + G2 ⎟ = v + G2
⎝ 2 ⎠ 2 N:number of steps
F4 = f (v + hF3 ) We are going to march from a to b by step size h.
G4 = g (v + hG3 ) = v + hG3
HW1

dx
= x′ = 1 − y
dt
dy
= y′ = x 2 − y 2
dt

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

y ıv + y ′′2 + r ( x ) + y ′3 + q( x )y = f ( x ) (1)
Let ⎫

y ′′ = z ⎬ (2)
z′′ + z 2 + ry ′3 + 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


f ′′′ + ff ′′ = 0

f (0) = f ′(0) = 0
f ′(∞ ) = 1
y
u = U∞ f ′(η ) , v = U∞ x 1/ 2 {η 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 g = f ′ g ′′ + fg ′ = 0 (A)


or
g= f′
η
f = ∫ gdη (B) numerical integration such as trapezoid rule.
0

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
y ′′ + p ( x ) y ′ + r ( x ) y = f ( x ) (3)
• 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
dt
h(T-T∞ ) = k
dx
∂T
Tb x = L → T = Tt , = 0 (insulated)
∂x

L
x

y ′′ + p ( x ) y ′ + r ( x ) y = f ( x ) (3)
y (a) = A Wish to solve eq.(3) for x in (a,b) y(x)=?
y (b) = B
Range (a,b) is first split into n equal parts of mesh length h and each point is labelled as
indicated below.

y0 y1 yj-1 yj yj+1 yn

x0 = a x1 = a+h xj-1 = a+(j-1)h xj = a+jh xj+1 = a+(j+1)h


At a typical point in the mesh at x=xj , we write finite difference representation to eq.(3)
as,
y j +1 − 2 y j + y j −1 y j +1 + y j −1 1
2
+ p( x j ) + r(x j ) y j = f (x j ) + 2
Cy j (4)
h 2h h
error term

Here yj = y(xj) , pj = p(xj)

⎛ h ⎞ ⎛ h ⎞
y j +1 ⎜ 1 + p j ⎟ + ( −2 + h 2 rj ) y j + ⎜ 1 − p j ⎟ y j −1 = h 2 f j + Cy j (5)
⎝ 2 ⎠ ⎝ 2 ⎠

Assuming Cyj negligible, then, finite difference approximation to eq.(3) at the point
xj = a+jh (j=1,2,..,n-1) is given iby eq.(5)

Example:
y ′′ − y = x For illustration purposes, select h=0.25 P(x)=0 , r(x)=-1 , f(x)=x

y ( 0) = 0 y0 y1 y2 y3 y4 =1
y (1) = 1
0 0.25 0.5 0.75 1

( )
y j +1 + −2 + h 2 y j + y j −1 = h 2 x j x j = jh j = 1, 2,3 interior points!
0

y0 − 2.0625 y1 + y2 = 0.015625 ⎪

y1 − 2.0625 y2 + y3 = 0.031250 ⎬ (6)
y2 − 2.0625 y3 + y4 = 0.046875⎪

1 ⎭
y0=0 , y4=1 , Eq.(6) represents 3 equations and 3 unknowns.

Linear systems of equations


• Cramer’s 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 y ′′ − y = x y=
2
e −1
2
e (
x +1
− e )
− ( x −1)
−x
Comparision
Numerical Exact
y0 0 0
y1 0.18023 0.17990
y2 0.38735 0.38682
y3 0.64993 0.64945
y4 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

⎛ h ⎞ ⎛ h ⎞
( )
y j +1 ⎜1 + p j ⎟ + −2 + h 2 rj y j + ⎜1 − p j ⎟ y j −1 = h 2 f j
⎝ 2 ⎠ ⎝ 2 ⎠
aj d j
bj cj

b j y j +1 + a j y j + c j y j −1 = d j (A) Linear system of eqs.


xj = a+jh , where j = 1, 2,..., (n-1)

(n-1) eqs. (n-1) unknowns y1 , y2 ,..., yn-1


y0 = A , yn = B (known from BCs)
need to solve (n-1) linear eqs. in (n-1) unknowns.

⎛ h ⎞ ⎛ h ⎞
b j = ⎜1 + p j ⎟ , c j = ⎜1 − p j ⎟
Coefficient for the general eq. ⎝ 2 ⎠ ⎝ 2 ⎠
(
a j = − 2 + h 2 rj ) , d j = h2 f j
Compute and store in one dimensional arrays, pj = p(xj) , rj = r(xj) , xj = 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

a k ,k > a k ,1 + ... + a k ,k −1 + a k ,k +1 + ... + a k , N for k = 1,2,.., N


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.
Let’s write the coefficient matrix
a11 a12 a13 . a1N
a21 a22 a23 . a2 N
. . . . . a3,3 > a3,1 + a3, 2 + a3, 4 + .... + a3, N

. . . . .
a N1 . . . a NN

Let’s write eq.(A) in open form,


a1 y1 + b1 y2 = d1 − c1 y0
c2 y1 + a2 y2 + b2 y3 = d2
c3 y2 + a3 y3 + b3 y4 = d3
:
:
ck yk −1 + ak y k + bk yk +1 = dk
:
:
cn − 2 yn −3 + an − 2 yn − 2 + bn − 2 yn −1 = d n−2
cn −1 yn − 2 + an −1 yn −1 = d n −1 − bn −1 yn
known
• (n-1) eqs. & (n-1) unknowns yi, i=1,2,..,(n-1)
• y0 & yn are known from BCs
• need to eliminate each successive yi
^
d1 − b1 y2
y1 = (1')
a1
^
d1 − b1 y2
c2 + a2 y2 + b2 y3 = d 2 (2)
a1
^
⎛ b1 ⎞ d1
a − c
⎜ 2 2 ⎟ 2 2 3y + b y = d 2 − c2 (2')
⎝ a1 ⎠ a1
α2 γ2

α 2 y2 + b2 y3 = γ 2 (2' ' ) use (2’’) to eliminate y2 in (3),


γ 2 − b2 y3
y2 = (2''')
α2 ck +1bk (I)
⎛γ −b y ⎞ α k +1 = ak +1 −
c3 ⎜ 2 2 3 ⎟ + a3 y3 + b3 y4 = d3 (3) αk Forward elimination,
⎝ α2 ⎠ c γ
k=1,2,..,(n-1)
⎛ b2 ⎞ γ2 γ k +1 = d k +1 − k +1 k Recursion relations for α
⎜ a3 − c3 ⎟ y3 + b3 y4 = d3 - c3 (3') αk and γ
⎝ α2 ⎠ α2
α3 γ3
α k y k + bk y k +1 = γ k (kth eq.)

γ k − bk y k +1
yk = (II) Back subtitution k=(n-1),(n-2),..,1
αk
TDMA - Tri-diagonal matrix algorithm.
To obtain values to start the recursion relations off,
Compare (kth) eq. with (1)
a1 y1 + b1 y2 = d1 − c1 y0 (1)
α k yk + bk yk +1 = γ k (kth)
^
α1 = a1 , γ 1 = d1 − c1 y0 = d 1 (*)

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 yn = B is known
THE THOMAS ALGORITHM
• more efficient scheme
• numerically stable scheme

Start by calculating two arrays δ and F starting from initial values

δ 0 = y0 = A
F0 = 0
Using the recursion relations,
bk +1 d −c δ
Fk +1 = − , δ k +1 = k +1 k +1 k k = 0,1,2,..,(n-1)
(ak +1 + ck +1 Fk ) (ak +1 + ck +1 Fk )
It may be proved by mathematical induction that

yk = Fk yk +1 + δ k
yn = B is known ⇒ k = (n-1),(n-2),.., 2, 1

Thomas algorithm is preferred direct method of solution.


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

T(0) = 200 0C
x

h = 20 W / m2 0C
T∞ = 20 0C

d 2T ⎛ 1 dAc ⎞ dT ⎛ 1 h dAs ⎞
2
+ ⎜⎜ ⎟⎟ − ⎜⎜ ⎟⎟(T − T∞ ) = 0
dx ⎝ Ac dx ⎠ dx ⎝ Ac k dx ⎠
Ac(x): Cross-sectional area
As(x): Surface area measured from the base.
Note: if Ac(x)= const. ⇒ As(x)= P x P: perimeter of cross-section of the fin

d 2T ⎛ hP ⎞
2
− ⎜⎜ ⎟⎟(T − T∞ ) = 0
dx ⎝ kAc ⎠
Common boundary conditions

1. T = Tb at x = 0
2. At x = L
1. dT/dx = 0 (insulated; Neumann condition)
2. T = TL (specified temperature; Dirichlet condition)
3. T = T∞ (for long fins)

4. − k dT = −h(T − T∞ ) (convection condition; Mixed or Robin condition)


dx x= L

Object of fin analysis

1. Solve for T(x) dT


2. Compute q B = − kAC ( x ) ⇒ energy dissipated by the fin
dx x =0

Methods a) Exact solutions for Ac(x)= const.


b) Numerical Methods
Numerical Solution of fin equation
1 dAc
P( x) =
Tb=T(0) Ac dx
x
h dAs
R( x) = −
h, T∞ kAc dx
θ = T − T∞

x0 x1 xj xn

d 2θ dθ
2
+ P ( x ) + R( x)θ = 0
dx dx
b jθ j +1 + a jθ j + c jθ j −1 = d j j = 1, 2, …, (n-1)

∆x ∆x dj = 0
bj = 1+ Pj cj = 1− Pj a j = −2 + (∆x) 2 R j
2 2
a) Specified temperature at x = L θ = θL at x = L
θ = θb at x = 0

Thomas algorithm is readily applied.


F0=0; δ0 = θ0 = θb

− bk +1 d k +1 − c k +1δ k
Fk +1 = δ k +1 =
a k +1 + c k +1 Fk a k +1 + c k +1 Fk

θ k = Fkθ k +1 + δ k k = (n-1),(n-2),…, 2, 1.

b) Convection condition at x = L


−k = −hθ at x = L & θ = θb at x = 0
dx x=L

introduce
additional point
h=∆x h
n-1 n n+1
Fin equation at x = xn = L (j = n)

bnθ n+1 + anθ n + cnθ n−1 = d n

⎛ θ −θ ⎞
Convection condition: − k ⎜⎜ n+1 n −1 ⎟⎟ = − hθ n
⎝ 2( ∆x) ⎠
2 ( ∆x ) h
Eliminate θn+1; θ n +1 = θ n −1 − θn
k
⎛ 2 ( ∆x ) h ⎞
⎜ n
a − b n ⎟θ n + (c n + bn )θ n −1 = d n
⎝ k ⎠

A B
d n − Bθ n −1
Aθ n + Bθ n −1 = d n ⇒ θn = (1)
A

θ k = Fkθ k +1 + δ k k = (n-1),(n-2),… For k = n-1


θ n−1 = Fn−1θ n + δ n−1 (2)

Substitute Eq. (2) into Eq. (1):


d n − BFn−1θ n − Bδ n−1
θn = ⇒ ( A + BFn−1 )θ n = d n − Bδ n−1
A

d n − Bδ n−1
θn = Back substitute as before. Note dj= 0.
A + BFn−1

dT
Heat Flux: q f = −kAc (0)
T1 T2 T3 T4 dx x =0

dT T2 − T1 dT − 3T1 + 4T2 − T3
≅ , or ≅ , or
dx x =0 ∆x dx x =0 2(∆x)

dT − 11T1 + 18T2 − 9T3 + 2T4



dx x =0 6(∆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:

y ′′ + p ( x) y 2 y ′ + r ( x) y 3 = f ( x) (1)
x = a & x = b conditions are specified
Finite difference approximation at xj to eq.(1)

y j +1 − 2 y j + y j −1 + p j y 2j ( y j +1 − y j −1 ) + h 2 r j y 3j = h 2 f j +
h
Cy j (2)
2
truncation term
Note: Equation (2) is non-linear
To solve eq.(2) , we start off by guessing a solution,
y (j0) , j = 0,1,2,.., n
Use above guessed solution to linearize the non-linear terms in eq.(2)

y (1)
j +1 − 2y (1)
j +y (1)
j −1
h
2
{ } (y
+ p j y (j0 )
2 (1)
j +1 −y (1)
j −1 )+ h r y
2
j
(0)2
j y (j1) = h 2 f j (3)
Eq.(3) is a linearize eq.& can be solved by a direct method (e.g. Thomas Alg.) to
obtain the first solution iterate, y (j1) j=0,1,2,...,n
Now, test to see wheather y (j1) is within a specified tolerance of y (j0 ) at each
internal mesh point; if not repeat the process, but this time using our refined estimate of
(1)
the solution, y j to linearize the non-linear terms.

y (k )
j +1 − 2y (k )
j +y (k )
j −1
h
2
{
+ p j y (jk −1 ) } (y
2 (k )
j +1 −y (k )
j −1 )+ h r y
2
j
( k −1) 2
j y (jk ) = h 2 f j

CONVERGENCE TESTS:
To determine the iteration two basic tests
I. The absolute test
E.g. ε = 10-4
y (jk +1) − y (jk ) < ε It is not a significant figure test

y m( k ) = 3 × 10 −5 , y m( k ) = 3 × 10 −5 y is small
Absolute test → convergence occured
But iterates do not agree to even one significant figure
E.g. ym is large : test may be much more demanding than we wish
ym = 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

y (jk +1) − y (jk ) y (jk )


( k +1)
<ε or 1− ( k +1)
<ε Test for significant figures.
y j y j

If ε = 10-4 two successive iterates must agree to within 4 significant figures at each
internal mesh point
Generally gives more satisfactory results
−7
y j ≥ 10→ 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) → (η)

u ( x, y ) = U ( x) f ′(η ) (1)
y
η=
ξ ( x)
ψ ( x, y ) = U ( x)ξ ( x) f (η ) (2)
B.L. eqs.
∂u ∂u dU ∂ 2u
u +v =U +ν 2
∂x ∂y dx ∂y
∂ψ ∂ψ
u= , v=−
∂y ∂x
Substitute (2) in to B.L. eqs. written in terms of ψ and show

f ′′′ + α ff ′′ + β ⎡1 − ( f ′ ) ⎤ = 0 Falkner-scan eq.


2

⎣ ⎦
ξ d ξ 2 dU
α= (U ξ ) , β =
ν dx ν dx

Flow over a wedge:


α=1 , β=arbitrary
Boundary conditions

f ′(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
BVP

f ′′′ + ff ′′ + β ⎡1 − ( f ′ ) ⎤ = 0
2
Notes
⎣ ⎦ • Complicated b.c. in η →∞
f ′( x) = f (0) = 0 , f ′(∞) = 1
• Non-linear 3rd order BVP.
solve f (η ) & obtain f ′′(0)
1/ 2
⎛ µU I ⎞
τ w = A⎜ ⎟ f ′′(0)
⎝ x ⎠
∂u

∂y y =0

Better to use 2nd order skim,


η
Let f ′(η ) = y (η ) ⇒ f (η ) = ∫ y (t )dt
0

y′′ + fy′ + β (1 − y 2 ) = 0 (1)


η
f (η ) = ∫ y (t )dt (2) trapezoid or simpson rule
0
• 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

suggested initial guess for y


-η 2
y = erf η or 1- e
Finite difference representation of eq.(1)

yi +1 − 2 yi + yi −1 yi +1 − yi −1
2
+ f i − β yi0 yi = − β (3)
h 2h
h
yi +1 − 2 yi + yi −1 + fi ( yi +1 − yi −1 ) − h 2 β yi0 yi = − h 2 β (4)
2
⎡ h⎤ ⎡ h⎤
yi +1 ⎢1 + f i ⎥ + yi ⎡⎣ −2 − h 2 β yi0 ⎤⎦ + yi −1 ⎢1 − fi ⎥ = − h 2 β (5)
⎣ 2⎦ ⎣ 2⎦

Eq.5 is of the form,

bi yi +1 + ai yi + ci yi −1 = di (6)

Procedure
1. Guess a solution for y 0 (η )
−η 2
e.g. y (η ) = 1 − e
0

2. Solve for f (η ) from (2)


ηi

i.e. f (ηi ) = ∫ y (t )dt trapezoid rule


0
3. Use f (ηi ) to solve y1 (η ) eq.(5) (thomas algorithm)
4. Iterate until convergence

y ( k ) − y ( k −1)
i.e
(k )

y
• Take η = 5-6

• Plot f , f ′ versus η
• Take β=0,1,&5

LAMINAR NATURAL CONVECTION ON A VERTICAL SURFACE


x

Tw u Similarity solutions:
Vertical surface is held at a uniform surface temperature, Tw .
v
T1: ambient fluid temperature

b.l

y
Boundary Layer equations governing the flow

∂ 2u ∂ 2u
<< 2 , v << u , Gr >> 1
∂x 2
∂y
∂u ∂v
+ =0 B.Cs:
∂x ∂y At y=0 , u=v=0 , T=Tw
∂u ∂u ∂ 2u For large y: u→0 , T→ T1
u +v = ν 2 + β g (T − T1 ) Velocity & temperature profiles are
∂x ∂y ∂y
similar at all values of x.
∂T ∂T ∂ 2T i.e.
u +v =α 2
∂x ∂y ∂y
u ⎛ y⎞
µ k = func ⎜ ⎟
ν= , α= ur ⎝δ ⎠
ρ ρcp
T − T1 ⎛ y⎞
= func ⎜ ⎟
Tw − T1 ⎝δ ⎠
ur = β g (Tw − T1 ) x
ur : reference velocity
δ: measure of both local velocity & thermal b.layer thicknesses
Define a streched variable near the plate

Gr1/ 4 y
η = 3/ 4 1/ 4 which magnifies the thin b.l. region (Gr>>1)
L x
The velocity components are
U 1/ 2 UL1/ 4
u = 1/ 4 x f ′(η ) , v = 1/ 4 1/ 4
(η f ′ − 3 f )
L 4Gr x
U = g β L(Tw − T1 )
T − T1
θ (η ) =
Tw − T1

Substituting momentum eq. & energy eq.


driving force
3 1
f ′′′ + ff ′′ − f ′2 + θ =0
4 2
3
θ ′′ + Pr f θ ′ = 0 Prandtl number
4
B.Cs

At y = 0 u = 0 ⇒ η = 0 : f ′ = 0 (no-slip)
At y = 0 v = 0 ⇒ η = 0 : f = 0 (solid wall)
At y = 0 T = Tw ⇒ η = 0 : θ = 1 (const. plate temp.)
For large y: u → 0 ⇒ η → ∞ : f ′ → 0 (no motion in the ambient)
For large y: T → T1 ⇒ η → ∞ : θ → 0
Local nusselt number gives the heat transfer from the plate to the fluid
per unit area per unit time
x3/ 4 ∂θ
Nu x = −Gr 1/ 4
θ ′(0) needs to be numerically calculated
L3/ 4 ∂η η =0

Numerical solution
f ′′′ + 3 ff ′′ − 2 f ′2 + θ = 0 (1)
θ ′′ + 3Pr f θ ′ = 0 (2)
Let f ′=y
y′′ + 3 fy′ − 2 y 2 + θ = 0
θ ′′ + 3Pr f θ ′ = 0
Finite difference representation
yi +1 − 2 yi + yi −1 yi +1 − yi −1
+ − i + θi = 0
2
2
3 f i 2 y
h 2h
3h (1)
yi(1)
+1 − 2 y (1)
i + y (1)
i −1 + f i (
2
)
−1 − 2h yi yi + h θ i = 0
yi +1 − yi(1) 2 (0) (1) 2

⎡ 3h ⎤ ⎡ 3h ⎤
yi(+k1) ⎢1 + fi ⎥ + yi( k ) ⎡⎣ −2 − 2h 2 yi( k −1) ⎤⎦ + yi(−k1) ⎢1 − fi ⎥ = − h 2θi
⎣ 2⎦ ⎣ 2⎦
(k) d (k)
ai i
bi(k) ci(k)

θi +1 − 2θi + θi −1 θi +1 − θ i −1
+ 3Pr f i =0
h2 2h
⎛ 3h ⎞ ⎛ 3h ⎞
θi +1 ⎜1 + fi Pr +
⎟ i θ ( − 2) + θ i −1 ⎜ 1 − f i Pr ⎟=0
⎝ 2 ⎠ a ⎝ 2 ⎠ di
i
bi ci

Procedure
1. Guess y 0 (η )
ηi

2. Find f (ηi ) = ∫ y (t )dt trapezoid rule


0
3. Use Thomas algorithm to find θi
4. Use thomas algorithm to find yi(1) [using θ i & yi(0) ]
5. Iterate until convergence
y ( k ) − y ( k −1)
i.e.
(k )
<ε for all i=0,..,N
y
Notes:
•Infinity about 12
• Use iterative averaging, i.e %50 old, %50 new
• Limit IMAX 100
2
• provide good initial guess, e.g. y (η ) = 1 − e−η

From the derivation of B.L. eqs.


δ ⎡ 1 ⎤
= ϑ ⎢ 1/ 4 ⎥
x ⎣ Grx ⎦
β g (Tw − T1 ) x3
Grx =
ν2

Grashof number main parameter in free convection controlling the nature of the motion
η : similarity variable
y 1/ 4
η= Grx
x
u T − T1
= F ′(η ) ; = θ (η )
β g (Tw − T1 ) x Tw − T1

Following dimensionless variables are introduced


u ⎛ ux ⎞
U= = ⎜ ⎟ Grx−0.5
β g (Tw − T1 ) x ⎝ ν ⎠
v ⎛ vx ⎞
V= = ⎜ ⎟ Grx−0.5
β g (Tw − T1 ) x ⎝ ν ⎠
1
cont. eq. V = −0.5
[η F ′ − 3F ]
4Grx

Writing momentum eq. in terms of dimensionless variables

∂u U 2 ∂u ∂ 2u 1 θ
U + +V =ν 2 +
∂x 2 x ∂y ∂y β g (Tw − T1 ) x 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 schemesÆ march 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.

y′′ + p ( x) yy′ + r ( x) y 4 = f ( x) (1)


y (a) = A , y (b) = B (2)

Let us recast the problem as a sequence of two first order equations


y′ = z ⎫
4⎬
(3)
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 don’t 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

Values of
y(b)
B γ3
γ2
γ1
α1 α2 α3
Guess for y’(a) α
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)
γ -γ 1 α -α1
= linear interpolation
γ 1 − γ 2 α1 − α 2
But we want γ=B so this gives us a revised guess to try for α3

α 3 = α1 +
( α1 − α 2 )( B-γ 1 )
(4)
γ1 − γ 2
Use α3 to start another integration of eq.(3)

y′(a ) = z (a ) = α 3 → y (b) = γ 3
(α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
α i +1 − α i ≤ ε tolerance (5)
γ i +1 − 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
y
(1)
(3) Desired

(2) * boundary
value

a x b
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.
y′′ = f ( x, y′, u , u ′)
u ′′ = g ( x, y′, u , u ′) Two values at x=b must be shot at.
Parallel shooting techniques can be used but
with the B.C. labourious methods
y (a ) = A , y (b) = B
u (a ) = C , u (b) = D
3. Shooting methods may also fail when the eqs. contain an unwanted
solution that may invariably be introduced in the marching procedure.

Example
y′′ − y = 0
general solution y(x)=A1e − x + A 2 e x
if B.C. are specified such that
y (0) = 1 , y → 0 as x → ∞
⇒ A1 = 1, A2 = 0

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

• Steady state temperature distributions


D BCs must be • Incompressible inviscid flows
satisfied on B • Equilibrium stress distribution in solids

Ex1: Heat conduction in solids in steady state


y
Seperation of variables,
T=0
1

T=0
∇ T =0
2 T=0 T ( x, y ) = ∑ An sin(nπ x) sinh [ nπ ( y − 1) ]
n =1

2T0 ⎡⎣(−1) − 1⎤⎦


x n

T=T0 1 An =
nπ sinh(nπ )
Ex2: Irrotational flow of an incompressible inviscid fluid is governed by
Laplace’s eq.
∇ 2φ = 0
V = ∇φ
y

F(r,θ)=r-rb(θ)=0
U

a θ x

B.Cs on surface of cylinder is V .∇F = 0


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 ∞

K cos θ Kx
φ = U∞ x + = U∞ x +
x2 + y2 x2 + y2
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
B Dif. eq. must be
satisfied in D

x
Initial data
surface

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

∂u2
2 ∂ u
2
= c
∂t 2
∂x 2

∂u ∂u2
=α 2
∂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

∂ 2u ∂ 2u ∂ 2u
A 2 +B +C 2 = f
∂x ∂x∂y ∂y

∂u ∂u
Where A,B,C,f may all be functions of x,y, , but not allowed to contain
∂x ∂y
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
, as well as depending on x & y
∂x ∂y
If B2-4AC > 0 → Hyperbolic PDE , Two real distinct characteristics exist at each point in
x-y plane
B2-4AC = 0 → Parabolic PDE , one real characteristic
B2-4AC < 0 → Elliptic PDE , characteristics are imaginary

dy B ± B 2 − 4 AC
= See Tannehill et.al. 1997, page 24 for derivation
dx 2A
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
Domain of influence: region influenced by P
y
Right-running
β2
II β3
Left-running
P
α2 α3
I III

x
a b c Initial data along the x axis
upon which P depends
Domain of dependence for P
(boundary conditions)
α = 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
Example: Best known example, one dimensional wave eq.

u L ∂ 2u ∂ 2
u
= a 2
-∞ <x<∞
∂t 2 ∂x 2
x
u(0,t)=0 u(L,t)=0

With I.C. u(x,0)=f(x) A=a2 , B=0 , C=1

∂u dt B ± B 2 − 4 AC 0 ± 0 − 4a 2 1
( x, 0) = g ( x) = = = ±
∂t dx 2A 2a 2 a
x
x - at= x0 - at0
P(x0 , t0)
x + at= x0 + at0 x + at = const. = x0 – at0
x – at = const.
-1/a
1/a
1 1 x

x0 + at0 Domain of
x0 - at0 dependence
u(x,t) = F1 (x + ct) + F2 (x - ct)
D’ Alembert solution of wave equation.
u(x,t) at (x0 , t0) depends only upon initial data contained in the interval.
x0 - at0 ≤ x ≤ x0 + at0

x + at
f ( x + ct ) + f ( x - ct ) 1
u ( x, t ) =
2
+ ∫
2a x − at
g (τ )dτ

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)
∂u ∂u
Initial velocity ( x, 0) e.g. ( x, 0) = 0 (released from rest)
∂t ∂t

Find u(x,t) = ? for t>0 all x u ( x, t ) = sin ⎛


πx⎞ ⎛ πx⎞
⎜ ⎟ cos ⎜a ⎟
⎝ L ⎠ ⎝ L ⎠
⎧at right-running dt
Characteristic lines x=⎨ = ±L
⎩-at left-running dx
t
x + at = const. = x0 + at0
x – at = const. = x0 – at0
P

x = at
x = -ct

Fluid Mechanics Examples: M>1


I. Steady, inviscid supersonic flow
y
d 2Φ d 2Φ
(M −1
2
) dx 2
− 2 =0
dy
x
Φ : disturbunce velocity profile
II. Unsteady, inviscid compressible flow
Unsteady 1-D & 2-D inviscid flows → hyperbolic
Time is the marching direction

∂ 2φ 2 ∂ φ
2
=c water-hammer problems wave equation.
∂t 2
∂x 2

Parabolic PDEs
Only one characteristic direction at a point

Characteristic direction (lines)


y Normally associated
c Boundary cond. known with IVPs but only one
I.C is required instead
d of two (as for
Domain of P
dependence hyperbolic eq.)
Region influced by P
a
b.c. known
b Time like variable

x
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
∂T ⎛ ∂ 2T ∂ 2T ⎞
T2 =α ⎜ 2 + 2 ⎟ α :const.
∂t ⎝ ∂x ∂y ⎠

t→∞ Heat conduction eq. (diffusion eq.)


t2
t1
T1
t=0

x
L
∂u ∂ 2u
=ν 2
T(x,0)=T1=const. ∂t ∂x
T(L,t)=T2=const. ∂T ∂ 2T
=α 2
T(0,t)=T1=const. ∂t ∂x x u
T(x,t)=? α : thermal diffusity
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

y ∂ 2
u ∂ 2
u
e.g. + 2 =0
∂x ∂y
2

P Conditions must be specified on closed curve C


u is continious on R+C
C Max/Min Property: Umax and Umin must be
on C
x
Boundary conditions
y

C. piecewise regular

∇ 2u = 0
I. u=f(x,y) on C.. Dirichlet Problem (unique)

∂u
II. = g ( x, y ) on C: Neumann Probl. (not unique) u must be specified at least
∂n one point
∂u ∂u
III. Combination of u & is known + Au = B ⇒ Robin's Probl.
∂n ∂n
IV. Mixed problems → combination of these conditions on various parts of C
Also can have non-linear conditions e.g. radition ∂u n
+ AT = B
∂n
Example:

• Heat conduction in solids. ∇ 2T = f ( x, y )

• Steady, subsonic, inviscid


• Incompressible inviscid flow. M→0

∇ 2ψ = 0 streamlines
irrototainal flow ω = ∇.V = 0

∂u ⎛ ∂ 2u ∂ 2u ⎞
x =⎜ 2 + 2 ⎟
∂t ⎝ ∂y ∂z ⎠

z
Steady, Fully-developed velocity profile

∂u ∂u ∂u 1 ∂p ⎛ ∂ 2u ∂ 2u ⎞
+u +v =− +ν ⎜ 2 + 2 ⎟
∂t ∂x ∂y ρ ∂x ⎝ ∂x ∂y ⎠
convective terms

Creeping flow: ∇ 2 P = 0

∇.V = 0
DV
ρ = −∇P + µ∇ 2 V
Dt
ρ=const. ⎛ ⎞

ρ ⎜⎜
V
+ ( )
V .∇ V ⎟ = −∇P + µ∇ 2 V

⎜ ∂t 0 non-linear term ⎟
⎝ ⎠
Parallel flow, v=w=0 , u≠0

∂u ∂v ∂w ∂u
continuity + + =0→ = 0 → u = u ( y, z , t )
∂x ∂y ∂z ∂x
∂P ∂P
y-comp. =0 , = 0 → p = p ( x, t )
∂y ∂z
⎛ ∂u ∂u ∂u ∂u ⎞ ∂P ⎛ ∂ 2u ∂ 2u ∂ 2u ⎞
x-comp. ρ ⎜ + u +v +w ⎟=− +µ⎜ 2 + 2 + 2 ⎟
∂t ∂x ∂y ∂z ∂x ⎜ ∂x ∂y ∂z ⎟⎠
⎝ ⎠ ⎝
∂u ∂P ⎛ ∂ 2u ∂ 2u ⎞
ρ =− +µ⎜ 2 + 2 ⎟ Parabolic
∂t ∂x ⎝ ∂y ∂z ⎠

Linear differantial equation for u(y,z,t)

∂u
Steady flow → =0
∂t
1 ∂P
∇ 2u =
µ ∂x Poisson equation basic differential equation for fully devoloped
duct flow.
elliptic
Ex
I. Coutte flows II. Poiseuille Flow
U

∂P
<0
∂x

CREEPING FLOW: Re<<1 , limiting case of very large viscosity


Full N-s , for ρ=const. , µ=const. (steady flow)

⎛ ∂V ⎞
ρ⎜ ( )
+ V .∇ V ⎟ = −∇P + µ∇ 2 V
⎝ ∂t ⎠ viscous force

(V .∇ )V → 0 (inertial force) ∂p ⎛ ∂ 2u ∂ 2u ∂ 2u ⎞
= µ⎜ 2 + 2 + 2 ⎟
∂x ⎝ ∂x ∂y ∂z ⎠
∇P = µ∇ 2 V
∇.V = 0
Take div( ∇.) of the momentum eq.

∇.(∇P) = ∇ 2 P = ∇.( µ∇ 2 V ) µ =const.


= µ∇.(∇ 2 V ) = µ∇ 2 (∇V ) = 0
∇2 P = 0 Laplace equation

VORTICITY TRANSPORT EQ:


2-D , vorticity-stream function formulation , ρ=const.
∇.V = 0 (1)
∂ψ ∂ψ
u= , v=- (2)
∂y ∂x
∂ 2ψ ∂ 2ψ
− =0 (1') Identical satisfied
∂x∂y ∂y∂x

Take the curl ( ∇ × ) of the 2-D vector momentum equation

⎛ ∂V ⎞
∇×⎜ ⎟ + ∇ ( )
× V .∇ V = ∇ × g −
1
ρ
(
∇ × ( ∇P ) + ν∇ × ∇ 2 V )
⎝ ∂t ⎠
Let ω = ∇ ×V be vorticity

∂ω
∂t
( )
+ V .∇ ω = ν∇ 2 ω Vorticity transport equation

ω = ω z k 2-D , ω x = ω y = 0
∂ω z ∂ω z ∂ω z ⎛ ∂ 2ω z ∂ 2ω z ⎞
+u +v =ν ⎜ 2 + 2 ⎟
∂t ∂x ∂y ⎝ ∂ x ∂ y ⎠
∂v ∂u
ωz = −
∂x ∂y

= ν∇ 2ω 2 eqs. 2 unknowns (u,v)
Dt
∂u ∂v
+ =0
∂x ∂y ∂v ∂u ∂ 2ψ ∂ 2ψ
ω = − = − 2 − 2 = −∇ 2ψ
∂x ∂y ∂x ∂y
Dω ⎫
= ν∇ 2ω ⎪
Dt ⎬ ω ,ψ formulation, 2-D , ρ =const.
∇ 2ψ = −ω ⎪⎭
Irrotational flow (inviscid) , ω = ∇ ×V = 0

∇ 2ψ = 0 Laplace eq.
⎛ ∂φ ∂φ ⎞
Velocity potential V = ∇φ = ⎜ i + j⎟
⎝ ∂x ∂y ⎠
∂ 2φ ∂ 2φ
∇.V = 0 ⇒ 2 + 2 = 0
∂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 ui,j be a component of velocity at point (i,j)
Taylor series expansion for ui+1,j , expanded about ui,j

⎛ ∂ 2u ⎞ ( ∆x ) ⎛ ∂ 3u ⎞ ( ∆x )
2 3
⎛ ∂u ⎞
ui +1, j =ui , j + ⎜ ⎟ ∆x +⎜ 2 ⎟ +⎜ 3 ⎟ + ... (1)
⎝ ∂x ⎠i , j ⎝ ∂x ⎠i , j 2! ⎝ ∂x ⎠i , j 3!
Eq.(1) mathematically an exact expression for ui+1,j if
1. number of terms is infinite
2. ∆x→0
∆x

∆y
i,j+1 i+1,j+1

i-1,j P i,j
i+1,j

i,j-1
stencil
lowest term in truncation error

⎛ ∂ 3u ⎞ ( ∆ x )
3
⎛ ∂u ⎞ ui +1, j − ui , j ⎛ ∂ 2u ⎞ ∆x
⎜ ⎟ = −⎜ 2 ⎟ −⎜ 3 ⎟ − ...
⎝ ∂x ⎠i , j ∆x ⎝ ∂x ⎠i , j 2 ⎝ ∂x ⎠i , j 6
finite difference represent
truncation error

⎛ ∂u ⎞ ui +1, j − ui , j
⎜ ⎟ ≅ − O(∆x) First-order forward difference
⎝ ∂x ⎠i , j ∆x terms of order ∆x

First-order accurate/Forward difference

Taylor series expansion for ui-1,j , expanded about ui,j

⎛ ∂ 2u ⎞ ( −∆x ) ⎛ ∂ 3u ⎞ ( −∆x )
2 3
⎛ ∂u ⎞
ui −1, j =ui , j + ⎜ ⎟ ( −∆x ) + ⎜ 2 ⎟ +⎜ 3 ⎟ + ... (2)
⎝ ∂x ⎠i , j ⎝ ∂x ⎠i , j 2! ⎝ ∂x ⎠i , j 3!
⎛ ∂u ⎞ ui , j − ui −1, j
⎜ ⎟ = − O (∆x) First-order rearward (or backward) difference
⎝ ∂x ⎠i , j ∆x

Substract eq.(2) from eq.(1)


⎛ ∂ 3u ⎞ ( ∆x )
3
⎛ ∂u ⎞
ui +1, j − ui −1, j =2 ⎜ ⎟ ( ∆x ) +2 ⎜ 3 ⎟ + ...
⎝ ∂x ⎠i , j ⎝ ∂x ⎠i , j 3!
⎛ ∂u ⎞ ui +1, j − ui −1, j Central difference formula,
⎜ ⎟ = + O ( ∆ x 2
)
⎝ ∂x ⎠i , j 2 ∆x second-order accurate

To obtain second order partial derivatives, summing eq.(1) & eq.(2)

⎛ ∂ 4u ⎞ ( ∆x )
4
⎛ ∂ 2u ⎞
+ ⎜ 2 ⎟ ( ∆x ) + ⎜ 4 ⎟
2
ui +1, j + ui −1, j =2ui , j + ...
⎝ ∂x ⎠i , j ⎝ ∂x ⎠i , j 12

⎛ ∂ 2u ⎞ ui +1, j − 2ui , j + ui −1, j Central difference formula


( )
2
⎜ 2⎟ = + O ∆ x of second-order accuracy
∂ ( )
2
⎝ x ⎠i , j ∆ x
Similarly,
⎛ ∂ 2u ⎞ ui , j +1 − 2ui , j + ui , j −1
( )
2
⎜ 2⎟ = + O ∆ y
∂ ( ∆y )
2
⎝ y ⎠i , j
Mixed derivatives:

e.g. ∂ 2u
∂x∂y
differentiate eq.(1) with respect to y,
⎛ ∂ 3u ⎞ ( ∆x ) ⎛ ∂ 4u ⎞ ( ∆x )
2 3
⎛ ∂u ⎞ ⎛ ∂u ⎞ ⎛ ∂ 2u ⎞
⎜ ⎟ =⎜ ⎟ +⎜ ⎟ ∆x + ⎜ 2 ⎟ +⎜ 3 ⎟ ... (3)
⎝ ∂y ⎠i +1, j ⎝ ∂y ⎠i , j ⎝ ∂x∂y ⎠i , j ⎝ ∂x ∂y ⎠i , j 2! ⎝ ∂x ∂y ⎠i , j 3!
differentiate eq.(2) with respect to y,

⎛ ∂ 3u ⎞ ( ∆x ) ⎛ ∂ 4u ⎞ ( ∆x )
2 3
⎛ ∂u ⎞ ⎛ ∂u ⎞ ⎛ ∂ 2u ⎞
⎜ ⎟ = ⎜ ⎟ -⎜ ⎟ ∆x + ⎜ 2 ⎟ −⎜ 3 ⎟ ... (4)
⎝ ⎠i −1, j ⎝ ∂y ⎠i , j
∂y ⎝ ∂x∂y ⎠i , j ⎝ ∂x ∂y ⎠i , j 2! ⎝ ∂x ∂y ⎠i , j 3!
Substracting eq.(4) from eq.(3) yields,

⎛ ∂ u ⎞ ( ∆x )
3
⎛ ∂u ⎞ ⎛ ∂u ⎞ ⎛ ∂u ⎞ 2 4

⎜ ⎟ − ⎜ ⎟ =2 ⎜ ⎟ ∆ +2 ⎜ 3 ⎟
x ...
⎝ ∂y ⎠i +1, j ⎝ ∂y ⎠i −1, j ⎝ ∂x∂y ⎠i , j ⎝ ∂x ∂y ⎠i , j 3!
⎛ ∂u ⎞ ui +1. j +1 − ui +1. j −1
( ) ...
2
⎜ ⎟ = + O ∆y
⎝ ∂y ⎠i +1, j 2∆y
⎛ ∂u ⎞ ui −1. j +1 − ui −1. j −1
( ) ...
2
⎜ ⎟ = + O ∆y
⎝ ∂y ⎠i −1, j 2∆y
⎛ ∂ 2u ⎞ ui +1. j +1 − ui +1. j −1 − ui −1. j +1 + ui −1. j −1
⎡ ( ) ( ) ⎤ ...
2 2
⎜ ⎟ = + O ∆ x , ∆ y
⎝ ∂x∂y ⎠i +1, j 4 ∆x ∆ y ⎣ ⎦

Second order central difference for the mixed derivative.


Derived finite difference expressions represent just “tip of the iceberg”.
Higher-order finite difference expressions
∂ 2u
e.g. 4th order central difference for is
∂x 2

⎛ ∂ 2u ⎞ −ui + 2, j + 16ui +1, j − 30ui , j + 16ui −1, j − ui − 2, j


( )
4
⎜ 2⎟ = + O ∆ x
∂ ( )
2
⎝ x ⎠ 12 ∆ x

⎛ ∂u ⎞ 2∆x ⎛ ∂ u ⎞ ( 2∆x )
2 2

ui + 2, j =ui , j +⎜ ⎟ +⎜ 2 ⎟ +...
∂x
⎝ ⎠i , j 1! ⎝ ∂x ⎠i , j 2!

∆x

i-2,j i-1,j i,j i+1,j i+2,j


• Information at five grid point is required to form above formula
• Can be derived by represent application of Taylor’s series expanded about
grid points (i+1,j) , (i,j) , (i-1,j)

What about at boundary?


⎛ ∂u ⎞ u2 − u1
3 ⎜ ⎟ = + O (∆y ) Forward difference
⎝ ∂y ⎠1 ∆y
∆y
2
• But only first-order accurate
• Second-order accuracy is needed
boundary 1

Method of undetermined coefficients (Polynomial approach)

∆x

x1 x2 x3

⎛ ∂u ⎞
⎜ ⎟ = au ( x1 ) + bu ( x2 ) + cu ( x3 ) Forward-difference, one-sided formulas
⎝ ∂x ⎠1
Up to 2nd order polynomialsÆ exact ⎛ ∂u ⎞
⎜ ⎟ = au ( x1 ) + bu ( x2 ) + cu ( x3 )
Let u ( x) = 1 , u '( x) = 0 , ⎝ ∂x ⎠1
0 = a + b + c (1)
⎛ ∂u ⎞
u ( x) = ( x − x1 ) , ⎜ ⎟ =1
⎝ ∂x ⎠1
1 = 0 + b ( x2 − x1 ) + c ( x3 − x1 )
1 = bh + 2hc (2) 3 eqs.& 3 unknowns: a,b,c
(2) & (3)
⎛ ∂u ⎞
u ( x) = ( x − x1 ) , ⎜ ⎟ = 2 ( x − x1 )
2

⎝ ∂x ⎠1
0 = h 2b + 4h 2 c (3)
1 2
c=− , b = −4c =
2h h
3
a=−
2h
⎛ ∂u ⎞ 3 4 1
⎜ ⎟ = − u ( x1 ) + u ( x2 ) − u ( x3 )
⎝ ∂x ⎠1 2h 2h 2h
⎛ ∂u ⎞ −3u ( x1 ) + 4u ( x2 ) − u ( x3 )
⎜ ⎟ = + O(h 2 )
⎝ ∂x ⎠1 2h
Similarly backward-difference
∆x

Xn-2 xn-1 xn

⎛ ∂u ⎞ 3u ( xn ) − 4u ( xn −1 ) + u ( xn − 2 )
⎜ ⎟ = + O ( h 2
)
⎝ ∂x ⎠n 2h
Formulas can be extended for non-equidistance mesh intervals.
PARABOLIC EQUATIONS:
simplest example in Fluid Mechanics
Stoke’s 1st & 2nd problem

Fluid
ρ=const.

U(t)

Preferred direction
1. Time – i.e. evolving flow
2. A spatial direction
e.g. boundary layers, duct flows

∂u ∂u ∂ 2u
u +v = 2
∂x ∂y ∂y

x
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
∂u ∂ 2u µ
=ν 2 , ν=
∂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.
∂T ∂ 2T k
=α 2 , α=
∂t ∂y ρcp
x
T
T2 0 L

T(x,t) temperature distribution in a rod of


t→∞ length L.
t2
t1
T1
t=0
x
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
∂u
(0, t ) = 0 , or = f (t ) a specified heat flux
∂x
∂u
c) a1 (t )u (0, t ) + b1 (t ) (0, t ) = γ (t )
∂x

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
FINITE DIFFERENCE METHODS (explicit, implicit)
PDE is replaced by finite-difference equations at the grid points
This results in algebraic equations called difference equations.

EXPLICIT METHODS

∂u ∂ 2u
=ν 2
∂t ∂y
t
∆y

∆t
ui,j+1 ui+1,j+1
Present time
ui-1,j P ui,j
ui+1,j
Previous time

ui,j-1
y

y1 y2 yi ym FTCS
tn = n∆t (uniform time step)
L
⎛ ∂u ⎞ ui , j +1 − ui , j ⎛ ∂ 2u ⎞ ∆t
⎜ ⎟ = −⎜ 2 ⎟ + .... Forward-difference in time
∂t
⎝ ⎠i , j ∆ t ⎝ ∂ t ⎠i , j 2
O ( ∆t )

⎛ ∂ 2u ⎞ ui +1, j − 2ui , j + ui −1, j


⎜ 2⎟ = Second order central-difference in space
⎝ ∂y ⎠i , j ( ∆y )
2

ui , j +1 − ui , j ui +1, j − 2ui , j + ui −1, j


=ν (A) difference equation
∆t ( ∆y )
2

After rearragement
∆t
ui , j +1 =ui , j + ν (ui +1, j − 2ui , j + ui −1, j ) (B)
( ∆y )
2

Difference equation (A) is just an approximation for original PDE due to truncation error.
Note: Truncation error for differential equation is O(∆t , (∆x) 2 )
Consistency of finite-difference representation of the PDE as ∆x→0 & ∆t→0
differential equation reduces to original differential equations.
i,j+1 Present time

∆t
Time-marching
Previous time direction
i-1,j i,j i+1,j

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 ui,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
( )
2
• In general, whether the scheme is unstable or not depends on the ratio, ν ∆ 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 ui , j = U j e Iik ∆y
Uj : amplitude at tj and k is the wave number, I = −1

ui , j +1 = U j +1e Iik ∆y , ui ∓1 = U j e I ( i ±1)k ∆y


Substitute above into finite-difference representation of PDE

(
u j +1e Iik ∆y = U j e Iik ∆y + R U j e I ( i −1)k ∆y − 2U j e Iik ∆y + U j e I ( i +1)k ∆y )
∆t
ui , j +1 = U i , j + R (U i −1, j − 2U i , j + U i +1, j ) , R =ν
( ∆y )
2

u j +1 = U j ⎡⎣1 + R ( e− Ik ∆y − 2 + e Ik ∆y ) ⎤⎦

For a stable solution

U j +1
≤1 , U j ~ e aj∆t
Uj
e Ik ∆t + e − Ik ∆t
cos k ∆y =
2
U j +1 = U j ⎡⎣1 − 2 R (1 − cos k ∆y ) ⎤⎦
λ :amplification factor

U j +1 = U j λ
U j +1
= λ ≤ 1 ⇒ stable solution
Uj

λ > 1 ⇒ U j +1 > U j , i.e. amplitude of solution becomes unbounded as j→∞ (time


2
goes to infinity)
⎡ ⎤
⎢1 − 2 R (1 − cos k ∆y ) ⎥ ≤ 1
⎢ ⎥
⎣ ≤1 ⎦ cosk∆y=-1 → R≤1/2 (for a minimum RHS)
−1 + R (1 − cos k ∆y ) ≤ 0
1
R≤
1 − cos k ∆y
∆t 1
ν ≤ stability criterion for unsteady heat conduction equations.
( ∆y )
2
2
diffusion
• Von neumann stability method ignores boundary conditions
• Effect of B.C. can be destabilizing
Other Explicit methods:
1. FTCS method O ⎡⎣ ∆t , ( ∆x )2 ⎤⎦
2. Richardson method
Central difference in both time&space derivatives
ui , j +1 − ui , j −1 ui +1, j − 2ui , j + ui −1, j
Approximate at xi, tj =α
2∆t ( ∆x )
2

∆t

ui+1,j ui+1,j+1 xi+1

ui,j-1
ui,j+1 xi
tj-1 tj tj+1
xi-1

If i know solution on tj & tj-1 have explicit formula


2∆tα
ui , j +1 =ui , j −1 + ( u + − 2 u + )
u − O ⎡
⎣ ( ∆t )
2
, ( ∆x )
2


( ∆x )
2 i 1, j i , j i 1, j
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
ui , j =
2
( ui, j +1 + ui, j −1 ) for stability
ui , j +1 − ui , j −1 ui +1, j − ( ui , j +1 + ui , j −1 ) + ui −1, j

2 ∆t ( ∆x )
2

⎛ 2α∆t ⎞ ⎛ 2α∆t ⎞ 2α∆t


2 ( i +1, j
ui , j +1 ⎜ 1 + ⎟ = ⎜ 1 − ⎟ u + u + ui −1, j )
⎜ ( ∆x ) ⎟ ⎜ ( ∆ x ) ⎟
2 2 i , j −1
( ∆x )
⎝ ⎠ ⎝ ⎠

Notes: ∆t
R =α
1. Method is unconditionally stable, i.e. for any value of ( ∆x )
2

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
⎧⎪ 2∆t ⎫⎪ j +1 ⎧⎪ 2∆t ⎫⎪ j −1 2∆t
⎨1 + = − + +
j j
⎬ u ⎨ 1 ⎬ u (u + u −1 )
⎩⎪ ( ∆x ) ⎭⎪ ⎩⎪ ( ∆x ) ⎭⎪ ( ∆x )
2 i 2 i 2 i 1 i

Show time level as superscript


⎧⎪ 2∆t ⎫⎪ ⎧ j ∂u ∂ 2 u ∆t 2 ⎫ ⎧⎪ 2∆t ⎫⎪ ⎧ j ∂u ⎫
⎨ 1 + u
2 ⎬⎨ i
+ ∆t + + ... =
⎬ ⎨ 1 − u
2 ⎬⎨ i
− ∆ t + ...⎬+
⎪⎩ ( ∆x ) ⎪⎭ ⎩ ∂ ∂ ⎭ ⎪⎩ ( ∆x ) ⎪⎭ ⎩ ∂
2
t t 2! t ⎭
2∆t ⎧ j ∂u ∂ 2u ∆x 2 ∂u ⎫
u + ∆x + 2
2 ⎨ i
+ ui − ∆x + ...⎬
j

( ∆x ) ⎩ ∂x ∂x 2! ∂x ⎭

∂u ∆t ∂ 2 u 2 ∆t ∂ 2 u
( )
2
∆t + ∆ t + O ( ∆ t 3
) = ∆ x + O ( ∆ t , ∆ x 2
)
∂t ( ∆x ) ∂t ( ∆x ) ∂x
2 2 2 2

2
∂u ⎛ ∆t ⎞ ∂ 2u ∂ 2u
+⎜ ⎟ = + O ( ∆ t 2
, ∆ x 2
)
∂t ⎝ ∆x ⎠ ∂t 2 ∂x 2
∂u ∂ 2u ⎛ 2 2 ⎛ ∆ t ⎞ ⎞
2

Consistent only if = 2 + O ⎜ ∆t , ∆ x , ⎜ ⎟ ⎟
∂t ∂x ⎜ ⎝ ∆x ⎠ ⎟⎠

∆t
→ 0 as ∆x, ∆t → 0
∆x
∆t
Otherwise, I am not approximating the eq. I thought I was = 1 then approximating
∆x
∂u ∂ 2u ∂ 2u
+ = represents a hyperbolic equation!
∂t ∂t 2 ∂x 2

• 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

ui , j +1 − ui , j ui +1, j +1 − 2ui , j +1 + ui −1, j +1


=α (1)
∆t ( ∆x )
2
i-1,j+1 i,j+1 i+1,j+1 Present time-unknown

xi Previous time-known
i,j
BTCS Method
In equation (1): 3 unknowns ui-1,j+1 , ui,j+1 , ui+1,j+1
Thus, it results in a set of coupled finite difference equations all grid points
Rearrange equation (1)

α∆t j +1
⎛ α ∆ t ⎞ j +1 α∆t j +1
u − ⎜ 1 + 2 ⎟ u + u = − u j

( ∆x )
2 i −1
⎜ ( ∆x ) ⎠
2
⎟ i
( ∆x )
2 i +1 i
⎝ di
ci ai bi

3 unknowns in each FDE


Algebraic equations
Coefficient matrix→Tridiagonal→Thomas algorithm (n-1) unknowns
Advantages
⎛ ( ∆x ) ⎞ ( ∆x ) j
2 2
j +1 j +1 j +1
1 ui −1 − ⎜ 2 + 2 ⎟ ui + 1 ui +1 = − ui
⎜ α∆t ⎠ ⎟ α∆t
ci
⎝ bi
d
i
ai
Now, all the uj+1 ‘s are known except those at the end points u0 , un (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 → O ( ∆t , ∆x 2 )
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,

uij +1 − uij 1 ⎡ uij++11 − 2uij +1 + uij−+11 uij+1 − 2uij + uij−1 ⎤


=α ⎢ + ⎥
∆t ( ∆x ) ( ∆x )
2 2
2⎢ ⎥⎦

∂u uij +1 − uij
=
⎛ ∆t ⎞ central difference of step ∆t/2 , i.e. (∆t)
2
∂t
2⎜ ⎟
⎝ 2 ⎠

j+1 Present time


(unknown)
∆t/2
(i,j+1/2)
j+1/2

∆t/2

j Previous time
∆x i x ∆x (known)
i

Unconditionally stable
O ( ( ∆ t ) 2 , ( ∆x ) 2 ) Second order scheme

⎛ ( ∆x ) ⎞ ( ∆x ) j
2 2
j +1 j +1 j +1
ui +1 − ⎜ 2 + 2 ⎟ ui + ui −1 = −2 ui − uij+1 + 2uij − uij−1
⎜ α∆t ⎟⎠ α ∆t

d j known
TDMA-Thomas Algorithm
Parabolic equations in two-space coordinates

∂u ⎛ ∂ 2u ∂ 2u ⎞
=α ⎜ 2 + 2 ⎟ α = const.
∂t ⎝ ∂x ∂y ⎠
On each portion of boundary, we know
y
I.u
∂u
II.
∂n
u(x,y,t) ∂u
III. A + Bu
x
∂n
Explicit method: FTCS
Forward difference in time derivative, central difference in space derivative
i,j+1 i,j+1
i+1,j
∆y

∆x
i,j i,j

i-1,j
(n) (n+1)
previous present
∆t

uin, +j 1 − uin, j ⎡ uin+1, j − 2uin, j + uin−1, j uin, j +1 − 2uin, j + uin, j −1 ⎤ O ⎡ ∆t , (∆x) 2 , (∆y ) 2 ⎤
=α ⎢ + ⎥ ⎣ ⎦
∆t ( ∆x ) ( ∆y )
2 2
⎢⎣ ⎥⎦

α ∆t α ∆t 1
Stability analysis : + ≤
( ∆ x ) ( ∆y )
2 2
2
α ∆t 1
∆x = ∆ y ⇒ ≤ twice as restrictive as the 1-D case
( ∆x ) 4
2
α=1 & ∆x=∆y
∆t
uin, +j 1 =uin, j + ⎡ u n
2 ⎣ i +1, j
− 4u n
+ u n
i −1, j + u n
i , j +1 + u n

i , j −1 ⎦
( ∆x )
i, j

α ∆t 1 ∆t 1
≤ upper limit =
( ∆x ) ( ∆x )
2 2
4 4

1 n
u n +1
i, j = ⎣ui +1, j + ui −1, j + ui , j +1 + ui , j −1 ⎤⎦
⎡ n n n
Five-point formula
4
ui,j

Steady state

Time accurate
solution

time

Valid solution at any intermediate level


Implicit Method: Crank-Nicolson

n n+1 ∂u ui , j − ui*, j
= + O (∆t ) 2
∂t ∆t
∆t
central difference eq. of step ∆t/2

uin, +j 1 = ui , j → unknown (present)


i,j+1
uin, j = ui*, j → known (previous) ∆y
i-1,j i+1,j
i,j ∆x

i,j-1
∂ u 1 ⎡ ui +1, j − 2ui , j + ui −1, j ui , j +1 − 2ui , j + ui −1, j ⎤
2 * * *

≅ ⎢ + ⎥ + O ( ∆ x ) 2

∂x 2 2 ⎢ ( ) ( )
2 2
⎣ ∆ x ∆ x ⎥⎦

∂ 2u 1 ⎡ ui , j +1 − 2ui , j + ui , j −1 ui , j +1 − 2ui , j + ui , j −1 ⎤
* * *

≅ ⎢ + ⎥ + O ( ∆ y ) 2

∂y 2 2 ⎢ ( ) ( )
2 2
⎣ ∆ y ∆y ⎥⎦
⎛ 2 ( ∆x ) ⎞
2

(
ui +1, j + ui −1, j + γ ui , j +1 + ui , j −1 ) − ⎜ 2 + 2γ +
⎜ ∆t ⎟
⎟ ui , j =
⎝ ⎠
⎛ 2 ( ∆x ) ⎞ *
2

(
−ui*+1, j − ui*−1, j − γ ui*, j +1 + ui*, j −1 ) + ⎜ 2 + 2γ −
⎜ ∆t ⎟
⎟ ui , j
⎝ ⎠
2
⎛ ∆x ⎞
where γ = ⎜ ⎟ is the ratio of step sizes
⎝ ∆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


∂u ⎛ ∂ 2u ∂ 2u ⎞
=α ⎜ 2 + 2 ⎟ Marching technique (1)
∂t ⎝ ∂x ∂y ⎠

u(t+∆t) will be obtained, in some fashion, from the known values of u(t)
Let’s use two-step process: first treat only x derivative implicitly
Step 1:
uin, +j 1/ 2 − uin, j uin++1,1/j 2 − 2uin, +j 1/ 2 + uin−+1,1/j 2 uin, j +1 − 2uin, j + uin, j −1
=α +α (2)
∆t ( ∆x ) ( ∆y )
2 2

Equation (2) reduces to the tridiagonal form


(n+1/2) : intermediate time
bi uin++11/, j 2 + ai uin, +j 1/ 2 + ci uin−+1,1/j 2 = di (2')
where
α∆t ⎛ α∆t ⎞
bi = ci = , ai = − ⎜1 + ⎟
2 ( ∆x )
2
⎜ ( ∆x )2 ⎟
⎝ ⎠
α∆t
di = −uin, j −
2 ( ∆y )
2 (un
i , j +1 − 2uin, j + uin, j −1 )
n +1/ 2
Eq.(2’) yields a solution for ui , j 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 uin, +j =1/12
Next, set j=2, and sweep in x (i=1,...,N) to find uin, +j =1/22
....
M sweeps in x-direction
Need to use Thomas Algorithm M times
t
At this place eq.(2’)
gives ui,j n+1/2

n+1/2
y
(1,M) (i,j)=(N,M)
∆t/2
Sweep j+1
direction j

x
(i,j)=(1,1) (i,j)=(N,1)
n
At the end of step1 (after M sweeps), the values of u at the intermediate time (t+∆t/2)
n +1/ 2
are known at all grid points: i.e. ui , j 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
uin, +j 1 − uin, +j 1/ 2 uin++1,1/j 2 − 2uin, +j 1/ 2 + uin−+1,1/j 2 uin, +j +11 − 2uin, +j 1 + uin, +j −11
=α +α (3)
∆t ( ∆x ) ( ∆y )
2 2

Eq.(3) reduces to the tridiagonal form

b j uin, +j 1+1 + a j uin, +j 1 + c j uin, +j −11 = d j (3')


where
α∆t ⎛ α∆t ⎞
bj = c j = , a j = − ⎜1 + ⎟
2 ( ∆x )
2
⎜ 2 ( ∆x )2 ⎟
⎝ ⎠
α ∆t
d j = −uin, +j 1/ 2 −
2 ( ∆x )
2 (u n +1/ 2
i +1, j − 2uin, +j 1/ 2 + uin−+1,1/j 2 )
yields a solution for uin, +j 1 for all j, keeping i fixed, via Thomas Algorithm

j=1,....,M i=1
j=1,....,M i=2
:
......... i=N
N times Thomas Algorithm
t
Present time

n+1
y
(1,M) i i+1 (i,j)=(N,M)
∆t/2

Sweep direction
x
(i,j)=(1,1) (i,j)=(N,1)
n+1/2
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

∂u ⎛ ∂ 2u ∂ 2u ⎞
=α ⎜ 2 + 2 ⎟ α =1
∂t ⎝ ∂x ∂y ⎠

Sweep 2 directions

Crank-Nicolson

ui,j* ui,j

ui , j − ui*, j 1 1
∆t
=
2∆x 2
δ{2
u
x i, j + δ 2 *
u
x i, j }
+
2∆y 2
δ 2
u{
y i, j + δ 2 *
u
y i, j + O }

⎣ ( ∆ t )
2
, ( ∆ x )
2
, ( ∆ y )
2


where
δ x2ui , j = ui +1, j − 2ui , j + ui −1, j ⎫⎪
⎬ compact operators
δ u = ui , j +1 − 2ui , j + ui , j −1 ⎪⎭
2
y i, j

⎧ ∆t 2 ∆t 2 ⎫ ⎧ ∆t 2 ∆t 2 ⎫ *
ui , j ⎨1 − δ
2 x
− 2 y⎬
δ = ⎨1 + δ
2 x
+ δ u
2 y ⎬ i, j
⎩ 2 ∆x 2∆y ⎭ ⎩ 2∆x 2 ∆y ⎭
⎧ ∆t 2 ∆t 2 ⎫ ⎧ ∆t 2 ⎫ ⎧ ∆t 2 ⎫ ⎡ ( ) ⎤
2
Let ⎨1 − δ − δ
2 y⎬
= ⎨1 − δ
2 x ⎬⎨
1 − δ
2 y⎬
+ O ∆t
⎩ 2∆x
2 x
2∆y ⎭ ⎩ 2∆x ⎭ ⎩ 2∆y ⎭ ⎣ ⎦
Define uˆi , j such that
⎧ ∆t 2 ⎫ ⎧ ∆t 2 ∆t 2 ⎫ *
⎨1 − δ ˆ
u
2 x ⎬ i, j
= ⎨1 + δ
2 x
+ δ u
2 y ⎬ i, j
(1)
⎩ 2∆x ⎭ ⎩ 2∆x 2∆y ⎭
Eq.(1) defines a set tridiagonal matrix problems along constant y lines
y

⎧ ∆t 2 ⎫
uˆi , j = ⎨1 − δ y ⎬ ui , j (2)
⎩ 2 ∆y
2

Sweep on lines of constant x
y

Notes:
1) Use eq.(2) to find values of û on vertical boundaries where ui,j known from B.C.s
2) Can reverse order of sweep
3) No iteration
4) Can be extended to higher dimensional problems

Above method is called Approximate Factorization


Keller Box Scheme
Implicit scheme for non-uniform meshes

Initially boundary layer near x=0 for small t


t Small meshes near x=0
Uniform meshes in x is wasteful
To deal with problem, 2 procedures is possible

x
1

I. Algebraic transformation
x
ξ = x & then use uniform mesh in ξ
a ξ=
t
II. Adopt a method which permits a non-uniform spacing
xi = xi −1 + hi −1 i=2,...,N
x1 = 0 , xN +1 = 1
h1 h2 h3

x1 x2 x3 x4

Sample problem
LOWER BOX xi

∂ u ∂u
2
x
=
*
2 1
* hi-1
∂x 2
∂t
xi-1

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
∂u ∂v ∂u
v= (1) , = (2)
∂x ∂x ∂t
ui − ui -1 1 *
= vi -1/ 2 = ( vi + vi -1 ) + O ( hi -1 )
2
Approximate eq (1) at
hi -1 2
or
2
vi + vi -1 = ( ui − ui-1 ) (3)
hi -1
Approximate eq (2) at box center

box center
1
2
(
vi −1 + vi*−1 )
vi , j −1/ 2 − vi −1, j −1/ 2 ui −1/ 2, j − ui −1/ 2, j −1
=
hi -1 k
1 j 1
2
vi + vij −1 = vi + vi*
vi , j −1/ 2 =
2
( ) ( )
Using simple averages, i.e.
1 ⎧ vi − vi −1 vi* − vi*−1 ⎫ 1 ⎧ ui + ui −1 − ui* − ui*−1 ⎫
⎨ + ⎬= ⎨ ⎬ (4)
2 ⎩ hi −1 hi −1 ⎭ 2 ⎩ k ⎭
Eliminate vi-1 using (3)
2vi 2 2v*i 2 ui − ui −1 − ui* − u *i −1
− 2 ( ui − ui −1 ) +
hi −1 h i −1
− 2 ui − u i −1 =
hi −1 h i −1
* *
( k
)
Upper Box
i+1

2 1 hi
i
k
Same type of approximations & eliminate vi+1
2vi 2 2 v *i 2 ui +1 + ui − ui +1* − u *i
− + ( ui +1 − ui ) − − 2 ( ui +1 − u i ) =
* *

hi h 2i hi hi k
Eliminate vi
2 2 2 2
( ui +1 − ui ) − ( ui − ui −1 ) − ( ui +1* − u*i ) − ( ui* − u*i −1 ) =
hi hi −1 hi hi −1
hi h
k
( ui +1 + ui − ui +1* − u *i ) + i −1 ( ui + ui −1 − ui* − u *i −1 )
k
Multiply by hi/2 and let

hi hi
αi = ratio of sizes , θi = & system becomes
hi −1 2k
bi ui +1 + ai ui + ci ui −1 = di
bi = 1 − hiθi , ci = α i − hi −1θi
ai = −1 − α i − hiθi − hi −1θi
( ) ( ) (
di = −ui*+1 + ui* + α i ui* − ui*−1 − hiθi ui*+1 − ui* − hi −1θi ui* + ui*−1 )
Thomas Algorithm
Selection of Mesh:
• Intense variation near x=0
• Small mesh near x=0

h1=h & progressively increase hi = (1+ ∈) hi −1 i = 2,.., N


αi

∈ is small, e.g. ∈= 0.02


α i = α = 1+ ∈
U1 UN+1
L
h2 = (1+ ∈) h N+1
hN
h3
h1 = h given
h3 = (1+ ∈) h...., hN = (1+ ∈)
2 N −1
h

L = h + (1+ ∈) h + (1+ ∈) h + ... + (1+ ∈)


2 N −1
h

L=
h

1{
( ) −1
+ ∈
N
}
3 parameters h, ∈ ,N

Select h, ∈ such that if you double N, you can compare two solutions!
Additional Features of Linear Equations
∂u ∂ 2u ∂u
= δ ( x, t ) 2 + p ( x, t ) + r ( x, t )u + F ( x, t )
∂t ∂x ∂x
ui − ui* δ i** ⎧ ui +1 − 2ui + ui −1 ui*+1 − 2ui* + ui*−1 ⎫ Pi** ⎧ ui +1 − ui −1 ui*+1 − ui*−1 ⎫ ri**
k
=
2 ⎩

h 2
+
h 2 ⎬+ ⎨ + ⎬+ { }
ui + ui* + Fi**
⎭ 2 ⎩ 2h 2h ⎭ 2
e.g. δ i** = δ ( xi , t ** )
j+1
t =t +k/2
** *
k/2
* (i,j+1/2)
t =known time level j+1/2
t ** =intermediate time level k/2
Tridiagonal form j
h ix h
i
2
h 2 h
bi = δ i** + pi** , ai = −2δ i** − + h 2 ri**
2 2
h **
ci = δ i − pi , di = ...
**

2
bi ui +1 + ai ui + ci ui −1 = di
DERIVATIVE BOUNDARY CONDITIONS
∂u
= g (t ) x=1 & u (0, t ) = A = u1
∂x

N+1 x=1

N-1

N-2
t* t
11u N +1 − 18u N + 9u N −1 − 2u N − 2
= g (t )
6h
Same procedure, with Thomas algorithm, as in boundary value problems
6hg (t ) − {δ N ( −18 + 9 FN − 2 − 2 FN −1 FN − 2 ) + δ N −1 ( 9 − 2 FN − 2 ) + δ N − 2 }
u N +1 =
11 − 18 FN + 9 FN FN −1 − 2 FN FN −1 FN − 2
Non-linear Parabolic Equations
Example: Boundary layer type of equation
Burger’s equation

∂u ∂u ∂u 2
=ν 2 − u
∂t ∂x ∂x
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
Crank-Nicolson method

ui − ui* 1 ⎧ ui +1 − 2ui + ui −1 ui*+1 − 2ui* + ui*−1 ⎫ 1 ** ⎧ ui +1 − ui −1 ui*+1 − ui*−1 ⎫


= ⎨ 2
+ 2 ⎬ − ui ⎨ + ⎬
k 2⎩ h h ⎭ 2 ⎩ 2 h 2 h ⎭
ui + ui*
ui =
**

2
h
bi = 1 − ui**
2
h2
ai = −2 − 2 ui,j* ui,j
k k
h
ci = 1 + ui**
2
2
h h
{ } 2
{ }
di = − ui*+1 − 2ui* + ui*−1 − ui** ui*+1 − ui*−1 − 2 ui*
2
Notes on non-linear equations
1. Non-linear diff. eqs. must be iterated at each time step
2. At first pass

** *
u i u i

3. Error test

k
ui
1 − k +1 < ε
ui
Typically 2-3 steps to satisfy iteration since k is small.
Newton Linearization

h **
2
( )
ui ( ui +1 − ui −1 )

h ui + ui ⎞
⎛ *
= ⎜ ⎟ ( ui +1 − ui −1 )
2⎝ 2 ⎠
h *
= ⎡⎣ui ( ui +1 − ui −1 ) + ui ( ui +1 − ui −1 ) ⎤⎦
4
ui ui +1 = −u i u i +1 + u i ui +1 + ui u i +1
u i → previous iterate
to start computation: set ui = u *
i
Upwind-Downwind Differencing
∂u ∂u 1 ∂ 2u
+u = , Re 1
∂t ∂x Re ∂x 2

τ = Re t
∂u ∂ 2u ∂u j+1 Present time
= 2 − Re u (unknown)
∂τ ∂x ∂x k/2
(i,j+1/2)
∂u ui − ui* j+1/2
=
∂τ k
k/2

j Previous time
h i x h (known)
i

∂ 2u 1 ⎧ ui +1 − 2ui + ui −1 ui*+1 − 2ui* + ui*−1 ⎫


= ⎨ + ⎬
∂x 2
2⎩ h 2
h2 ⎭
⎧u − u ⎫
if we use ui** ⎨ i +1 i −1 + ....⎬ problem with diagonal dominance
⎩ 2h ⎭
For ui** > 0

i+1
average on here

i
h i-1/2
i-1
τ* τ
k

∂u 1 ⎧⎪ ∂u ⎫⎪
*
∂u
= ⎨ + ⎬ + O(k )
2

∂x 2 ⎪⎩ ∂x i −1/ 2 ∂x i +1/ 2 ⎪⎭
1 ⎧ ui − ui −1 ui*+1 − ui* ⎫
= ⎨ + ⎬ + O ( h 2
, k 2
)
2⎩ h h ⎭
If ui** < 0
average on here

i+1/2 i+1

i
i-1/2 h
i-1
τ* τ
k

∂u 1 ⎧ ui +1 − ui ui* − ui*−1 ⎫
= ⎨ + ⎬ + O ( h 2
, k 2
)
∂x 2 ⎩ h h ⎭
Difference equations can be written in the following form:

⎛ h2 ⎞ ** ⎧ i
u − ui −1 ⎫
ui +1 − ⎜ 2 + 2 ⎟ ui + ui −1 − h Re ui +1 ⎨ ⎬
⎝ k ⎠ u
⎩ i +1 − u i ⎭

⎛ h 2
⎞ ⎧u *
i +1 − u *
⎫ for ui** > 0
= −ui +1 + ⎜ 2 − 2 ⎟ ui − ui −1 + h Re ui ⎨ *
* * * ** i
* ⎬
⎝ k ⎠ ⎩ ui − ui −1 ⎭ for ui** < 0
Notes:
1. At each time step it may be necessary to average
ui( k +1) = δ ui( k +1/ 2) + (1 − δ ) ui( k ) 0<δ <1
2. Inviscid form (Re→∞) can develop sharp fronts & multiplicity of solution

u u u

x x x
t0 < t1 < t2

Viscous form acts to prevent this!


3. “Parabolized Navier-Stokes” eqs. preferred direction in space

⎧ ⎫
∂u ∂u ∂P 1 ⎪ ∂ 2u ∂ 2u ⎪
u +v =− + ⎨ 2 + 2⎬
∂x ∂y ∂x Re ⎪ ∂x ∂y ⎪
⎩ neglect ⎭
∂u 1 ∂ 2u ∂u ∂P
u = −v −
∂x Re ∂y 2
∂y ∂x

& march in x-direction


Factor Algorithm for Navier-Stokes equations

∂u ∂ 2u ∂ 2u ∂u ∂u
= 2 + 2 + p + q + ru + w
∂t ∂x ∂y ∂x ∂y
p = p (u , x, y, t ) etc.
ui , j − ui*, j 1 1
k
=
2h12 {
δ 2
u
x i, j + δ 2 *
u }
x i, j +
2h22
δ{2
u
y i, j + δ 2 *
}
y ui , j +

p** Q** R**


4h1
{
µ xδ x ui , j + µ xδ x ui , j +
*
}
4h2
{ }
µ yδ y ui , j + µ yδ y ui , j +
*

2
( )
ui , j + ui*, j + w**

1
estimate p** =
2
(
p + p* )

Multiply by 2k & rearrange


⎧ k 2 kP** k 2 kQ** ⎫
⎨ 2 − kR **
− δ
2 x
− µ δ
x x − 2
δ y − µ δ
y y ⎬ ui , j =
⎩ h1 2h1 h2 2h2 ⎭
⎧ k 2 kP** k 2 kQ** ⎫ *
⎨ 2 + kR **
+ δ x + µ x δ x + δ y + µ y δ y ⎬ ui , j + 2 kw**

⎩ h12 2h1 h22 2h2 ⎭


1
if α =
2 − kR**
⎧ αk ⎡ 2 h1 ** ⎤ αk ⎡ 2 h2 ** ⎤⎫
⎨1 − 2 δ +
⎢ x 2 P µ δ
x x⎥− 2
δ +
⎢ y 2 Q µ δ
y y ⎥ ⎬ ui , j = Di , j
⎩ h1 ⎣ ⎦ h2 ⎣ ⎦⎭
{ }
Di , j = α 2 + kR** + .... ui*, j + 2α kw**
Factor
⎧ αk ⎡ 2 h1 ** ⎤⎫ ⎧ α k ⎡ 2 h2 ** ⎤⎫
⎨1 − 2 δ +
⎢ x 2 P µ δ
x x ⎥ ⎬ ⎨1 − 2
δ +
⎢ y 2 Q µ δ
y y ⎥ ⎬ ui , j ≅ Di , j
⎩ h1 ⎣ ⎦ ⎭ ⎩ h2 ⎣ ⎦⎭
⎧ αk ⎡ 2 h1 ** ⎤ ⎫ n +1/ 2
⎨1 − 2 δ +
⎢ x 2 P µ δ
x x ⎥ ⎬ ui , j = Di , j Solved in a manner similar to
⎩ h1 ⎣ ⎦⎭ diffusion equation
⎧ αk ⎡ 2 h1 ** ⎤ ⎫ n +1
⎨1 − 2 ⎢δ y + Q µ y δ y ⎥ ⎬ ui , j = ui
n +1/ 2
,j
⎩ h1 ⎣ 2 ⎦⎭

• Iterate
ELLIPTIC PROBLEMS
• Steady state heat conduction equation
• Velocity potential eq. & stream function eq. for incomp., inviscid, irrotational flow

Typical Elliptic equations

∂ 2u ∂ 2u ∂ 2u ∂ 2u
Laplace’s eq. + =0 Poisson’s eq. + 2 = f ( x, y )
∂x 2 ∂y 2 ∂x ∂y
2

Types of Eqs.
1. Linear: Laplace, Poisson
2. Non-Linear
a. Linear PDE with non-linear BCs
e.g. ∇ 2u = 0 ∂u = D u 4 − T 4 on C
∂n
( ∞ )
b. Non-Linear PDE
e.g. Navier-Stokes

∂u ∂u ∂P 1 ⎡ ∂ 2u ∂ 2u ⎤
u +v =− + ⎢ 2 + 2⎥
∂x ∂y ∂x Re ⎣ ∂x ∂y ⎦
non-linear
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

y
C

x
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


T0 Temperature is smooth &
continuous

T1 ≠ T0

e.g. heat transfer


c) Maximum prensible
For Laplace eq. extrama of function must occur on boundary

T2
T0 < T1 < T2 < T3
T3 T1
Then, there is no T in interior with
T4 T < T0 ; T > T3

• 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.

i,j+1
y
∆y
(1,M+1) (N+1,M+1) ∆x

i-1,j i,j i+1,j

(1,2)

i=1 2 3 i N N+1 x i,j-1

Let us use second – order accurate, central differences at point i,j


∇ 2 u = f ( x, y )
fi , j = f ( xi , yi )
ui +1, j − 2ui , j + ui −1, j ui , j +1 − 2ui , j + ui , j −1
2
+ 2
= fi , j
h k
ui +1, j − 2ui , j + ui −1, j + γ ( ui , j +1 − 2ui , j + ui , j −1 ) = h 2 f i , j (1)
2
⎛h⎞
γ =⎜ ⎟ : ratio of step sizes
⎝k⎠
Total of (M-1) x (N-1) eqs.
Typically 10000 such eqs. & up

2 are known
1 of u is known
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)
1
ui(,kj+1) = ⎡⎣ −h 2 fi , j + ui(+k1,) j + ui(−k1,) j + γ ui(,kj)+1 + γ ui(,kj)−1 ⎤⎦ (2)
2 (1 + γ )
k:iteration counter
Prodecure:
1. Guess ui,j at every point (k=0) (initial guess) ui,j(0) i=2,..,N , j=2,..,M
2. Apply (2) at every point in the mesh ui,j ,
use systematic sweep of mesh
3. Continue until convergence

ui(,kj)
1− ( k +1)
<∈ for all i,j
u i, j

e.g. ∈= 10 −4 4 significant figures

Notes:
1. Process is not used in practice because it is too slow
ein, j : error at n th iteration
ein, j = uin, j − ui , j
uin, j : estimate
ui , j : true value
ei(,nj+1) ≈ ρ ( J )ei(,nj)
ρ ( J ) : modulus of largest eigenvalue of iteration matrix. ρ ( J ) < 1
For equal mesh lengths h=k
rectangular regions & Poisson’s eq.
1⎧ ⎛ π ⎞ ⎛ π ⎞⎫
ρ ( J ) = ⎨cos ⎜ ⎟ + cos ⎜ ⎟⎬
2⎩ ⎝ N + 1 ⎠ ⎝ M + 1 ⎠⎭

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

i,j
i-1,j i+1,j

i,j-1
green dots have been computed, therefore use most recent
information
1
( k +1)
u = ⎡
⎣ −h fi , j + ui +1, j + ui −1, j + γ ui , j +1 + γ ui , j −1 ⎤⎦ (3)
2 (k ) ( k +1) (k ) ( k +1)

2 (1 + γ )
i, j

Note:
1. No need to hold previous iterate in core
2. Method is much faster than Jacobi
h=k , rectangular regions, Poisson eq.
ρ (G ) = ρ 2 ( J )

Analogy between the iterative method & time dependent parabolic equation
2-D unsteady heat conduction

∂u ∂ 2u ∂ 2u
= 2+ 2
∂t ∂x ∂y
Remember the Explicit formulation: FTCS

Let ∆x=∆y ,
∆t
u n +1
=u + n
⎡⎣uin+1, j + uin−1, j + uin, j +1 + uin, j −1 − 4uin, j ⎤⎦
( ∆x )
i, j i, j 2

∆t 1
≤ upper limit
( ∆x )
2
4
1 n
u n +1
i, j = ⎡⎣ui +1, j + uin−1, j + uin, j +1 + uin, j −1 ⎤⎦ (A) FTCS approx. of a parabolic eq.
4
2
⎛h⎞
Now, Jacobi iteration γ = ⎜ ⎟ = 1 , f ij = 0
⎝k⎠

1 k
uik, +j 1 = ⎡⎣ui +1, j + uik−1, j + uik, j +1 + uik, j −1 ⎤⎦ (B) Jacobi iteration for an elliptic eq.
4

• 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
ui,j Steady state ui,j Steady state

Time
accurate
solution

Time Number of iterations

Eq.(A) Eq.(B)
Solution is valid at any Intermediate solution of eq.(B)
intermediate time level if has no physical significance
imposed initial data & time step converged, or steady-state
represent physics solution
C) SUCCESSIVE OVER RELAXATION (SOR)
• Usually faster than G.S for linear problems
Gauss-Seidel iteration

1
ui(,kj+1) =
2 (1 + γ ) ⎣
( )
⎡ − h 2 fi , j + ui(+k1,) j + ui(−k1,+1)j + γ ui(,kj)+1 + ui(,kj+−1)1 ⎤

adding ui(,kj) -ui(,kj) to RHS & collect terms


1
ui(,kj+1) = ui(,kj) +
2 (1 + γ ) ⎣
( )
⎡ui(+k1,) j + ui(−k1,+1)j + γ ui(,kj)+1 + ui(,kj+−1)1 − 2 (1 + γ ) ui(,kj) ⎤

ui(,kj) → ui(,kj+1) (as solution proceeds)


To accelarate the solution, the bracket term is multiplied by ω, relaxation parameter
(factor)
ω
u k +1
=u + k
{ } (*)
2 (1 + γ )
i, j i, j

For convergence 0<ω<2


If 0<ω<1 under-relaxation (some non-linear problems) (iterative averaging ω≈0.5)
ω=1 : Gauss-Seidel is recovered
Rearrange eq.(*)
ω
uk +1
i, j = (1 − ω ) u + k
i, j
2 (1 + γ )
{ (
−h 2 fi , j + uik+1, j + uik−+1,1 j + γ uik, j +1 + uik, +j −11 )}
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
2
ωopt =
1 + (1 − ρ ( G ) )
1/ 2

Esimate ρ ( G ) by performing a large number of G.S iterations & estimate ρ ( G )


from
(k )
d
i. d = ∑∑ ui , j − ui , j
k k −1
ρ ( G ) = lim ( k −1) i j
k →∞
d
∑∑ ( )
2
ii. d = uik, j − uik, −j 1
k −1
d (k )
i, j = u −u
k
i, j i, j
i j
Special case
Rectangular domain subject to Dirichlet BCs with constant step sizes
2
⎡ ⎛π ⎞ ⎛π ⎞⎤
⎢ cos ⎜ ⎟ + γ cos ⎜ ⎟⎥
2 − 2 1− a N
⎝ ⎠ ⎝M ⎠⎥
ωopt = , a=⎢
a ⎢ 1+ γ ⎥
⎢⎣ ⎥⎦

Derivative Boundary Conditions


Conduction heat transfer

∂u ∂u
i. given = 0 insulated
∂n ∂n
∂u
−k * = q specified heat flux
∂n
∂u
ii. −k * = h* ( u − u∞ ) convection conditions
∂n
Example: suppose convection on right face.

∂u
(N+1,M+1) −k * = h * ( u − u∞ ) on x=a
∂n
θ =u − u ∞
h, u∞ ∂θ
−k * = h*θ
∂n
x = a = xN+1

Simplest method:
Approximate eq. at nodal points on boundary (x→a-)
At interior nodal points on x = a , j=2,...,M but not at corners j = 1&M+1

u N + 2, j + u N , j + γ {u N +1, j +1 + u N +1, j −1} − 2 (1 + γ ) u N +1, j = h 2 fij (4)


2
⎛h⎞
γ =⎜ ⎟
⎝k⎠
Derivative condition is also valid at x=a, i.e., i=N+1 (on boundary)

⎧ u N + 2, j − u N , j ⎫ *
−k ⎨ ⎬ = h {u N +1, j − u∞ }
*
(5)
⎩ 2h ⎭
Use eq.(5) to eliminate u N + 2, j in eq.(4).

2u N , j + γ {u N +1, j +1 + u N +1, j −1} − ( 2 + 2γ + 2hα ) u N +1, j = −2hα u∞ + h 2 fij (6)


⎛ h* ⎞
α =⎜ * ⎟
⎝k ⎠
Computational Algorithm:
Sweep interior points (G.S) as before plus additional sweep on right face

u N +1, j =
1
( 2 + 2γ + 2hα )
{
2u N , j + γ ( u N +1, j +1 + u N +1, j −1 ) + 2hα u∞ − h 2 fij } (7)

j=2,..,M

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
∂u 1,M+2
+ α (u − u∞ ) = 0
∂y

∂u
=0 2,M+1
∂x 0,M+1 1,M+1

1,M
Insulated condition → u0,M+1 = u2,M+1 (8)

Convective condition

u1, M + 2 − u1, M + 2hα ( u1, M +1 − u∞ ) = 0 (9)


Approx. to differential eq. at (1,M+1)
u2, M +1 − 2u1, M +1 + u0, M +1 + γ ( u1, M +1 − 2u1, M +1 + u1, M ) = h 2 f1, M +1 (10)
Eliminate u0, M +1 & u1, M + 2
1
u1, M +1 =
( 2 + 2γ + 2hαγ )
{
2u2, M +1 + 2γ u1, M + 2γ hα u∞ − h 2 f1, M +1 } (11) special eq. for the
corner.
Diagonal Dominance
Difference eq.

ui +1, j + ui −1, j + γ ( ui , j +1 + ui , j −1 ) − ( 2 + 2γ ) ui , j = h 2 f i , j

ui , j =
1
( 2 + 2γ )
{ }
− h 2 f i , j + ui +1, j + ui −1, j + γ ( ui , j +1 + ui , j −1 )

large #
Eq. is written in this form so system is diagonally dominant

Ax = b
ith eq. ai1 x1 + ai 2 x2 + ... + aii xi + ... + aim xm = bi
Diagonally dominant if

aii > ai1 + ai 2 + ... + ai ,i −1 + ai ,i +1 + ... + aim


The system is diagonally dominant if all eqs. have this property.
Iteration schemes will converge if the system has this property.
Notes:
1. Our system has
2 + 2γ = 1 + 1 + γ + γ
2. If one (or more) not diagonally dominant
iteration usually diverge

3. Non-centered differences , non-diagonally dominant systems.

e.g. ∂ 2u 1
=
∂x 2 ij 3h 2
{ − 3uij + 12ui +1, j − 15ui + 2, j + 3ui + 3, j } + ( )
O h 3

4. For non-linear equations


no guarantee that iterative solution will converge even if diagonally dominant

∂u
∇ u +u
2
=0
∂x
Improved method for derivative conditions
Higher order approximation for derivative
But must retain diagonal dominance

J+1 Sloping difference approximation


J ∂u
+ α ( u − u∞ ) = 0
J-1 ∂x

M-2 M-1 M M+1

1
16
{−2uM − 2, j + 9uM −1, j − 18uM , j + 11uM +1, j } + α ( uM +1, j − u∞ ) = 0 + O(h3 )
1
uM +1, j =
(11 + 6α h )
{18uM , j − 9uM −1, j + 2uM − 2, j + α u∞ } + O(h3 ) (13)

Substitute into approx. of diff.eq. at i=M

ui +1, j -2ui , j +ui −1, j +γ ( ui , j +1 − 2ui , j + ui , j −1 ) =h 2 fi , j (1)


1
11 + 6α h
{18uM , j +1 − 9uM −1, j + 2uM − 2, j + α u∞ } + uM −1, j +

γ {uM , j +1 + uM , j −1} − ( 2 + 2γ ) uM , j = h 2 fij (14)


Or
⎧ 9 ⎫ 2
⎨1- u
⎬ M -1, j + uM -2, j +
⎩ 11 + 6α h ⎭ (11 + 6α h )
⎛ 18 ⎞ α u∞
γ {uM , j +1 − uM , j -1} - ⎜ 2 + 2γ - u
⎟ M,j = h 2
f M +1, j - (15)
⎝ 11 + 6α h ⎠ 11 + 6α h
Let us check for diagonal dominance of eq.(15) for small h,

18 4
2 + 2γ − ≈ + 2γ
11 + 6α h 11

9 2 4
1− + + γ + γ ≈ + 2γ
11 + 6α h 11 + 6α h 11
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
CURVED IRREGULAR BOUNDARIES

Consider approx. at i,j


j+1
j ui +1, j + ui −1, j + ui , j +1 + ui , j −1 − 4ui , j = h 2 fi , j
j-1
C But ui , j +1 is not in interior

i-1 i i+1 i+2

Suppose C intersects ith line


point interpolation on ith mesh line, q<1
i,j+1
q ( q + 1)
C ui ,C = u ( xi , yi + qh) = ui , j +1 +
i-1,j qh 2
i,j
i+1,j q ( q − 1)
(1 − q )ui , j +
2
ui , j −1 + O ( h3 )
2
i,j-1 ui , j +1
Use above eq. to eliminate
Nine Point Formula For Laplacian (derivation)
(i-1,j+1) i,j+1
(i+1,j+1)

(i+1,j)
i,j

(i+1,j-1)
i

Define operators
∂ ∂
ξ= , η=
∂x ∂y

Hold one variable constant (e.g. x) and consider Taylor Series;

⎛ ∂ h2 ∂ 2 ⎞
u ( x + h, y ) = ⎜1 + h + + ... ⎟ u ( x , y ) = eξ
u ( x, y )
⎝ ∂x 2! ∂x 2

Similarly
u ( x, y + h ) = eη u ( x, y )
Consider the sum
S1 = ui +1, j + ui , j +1 + ui −1, j + ui , j −1
and
( )
S1 = eξ + eη + e −ξ + e −η u ( x, y ) x = xi
y= y j
(31)

but
ξ4 η4
eξ + e −ξ + e −η + eη = 2 + ξ 2 + + .... + 2 + η 2 + + ...
12 12
h4 ⎛ ∂ 2 ∂2 ⎞
= 4 + h ∇ + ⎜ 2 + 2 ⎟ + ...
2 2

12 ⎝ ∂x ∂y ⎠
and equation (31) becomes
h4 4
S1 = 4ui , j + h ∇ u i , j +
2 2

12
(
∇ u − 2 D 4u ) i, j
+ .... (32)
2
∂ 2
⎛ ∂2 ∂2 ⎞ If we neglect last term in (32) Standard
D =h
2
∇ =⎜ 2 + 2 ⎟
4
5 point Formula.
∂x∂y ⎝ ∂x ∂y ⎠
Now consider sum

( )
S 2 = ui +1, j +1 + ui −1, j +1 + ui −1, j +1 + ui −1, j −1 = eξ +η + e −ξ +η + e −ξ +η + e −ξ −η u ( x, y ) i , j
⎧ ξ2 ξ3 ⎫ ⎧ η4 ⎫ ⎧ ξ4 ⎫⎧ η4 ⎫
= ⎨1+ξ + + + ...⎬ ⎨2+η + + ...⎬ + ⎨2 + ξ + + ....⎬ ⎨2 + η + + ...⎬
2 2 2

⎩ 2! 3! ⎭ ⎩ 12 ⎭ ⎩ 12 ⎭⎩ 12 ⎭
⎛ ξ 4 η4 ⎞
(
= 4 + 2 ξ +η 2 2
) + ⎜ + + ξ 2η 2 ⎟ + ...
⎝ 6 6 ⎠
h4 4
= 4 + 2h ∇ + 2

6
∇ − 2D4 + 6D4
2
( )
h4 4
S 2 = ui , j + 2h ∇ u i , j +
2 2

6
∇ u + 4 D 4u ( ) i, j
+ ... (33)

To obtain 9 point formula, take 4x32 + 33

h2 4
4 S1 + S 2 = 20ui , j + 6h ∇ u i , j + ∇ u i , j + ...
2 2

12
4 S1 + S 2 − 20ui , j h 2 4
∇ u i, j =
2

6h 2

12
∇ u i, j
+ O h 4
( ) (34)

Note Laplace eq. ∇ 4u = 0


4 S1 + S 2 − 20ui , j = 0 (35)
• Still diagonally dominant
• Dirichlet conditions, very effective
• Derivative conditions more difficuilt to implement
• Mesh with ∆x=h , ∆y=k
(
2 h 2 − 5k 2 )
ui +1, j +1 + ui −1, j +1 + ui +1, j −1 + ui −1, j −1 −
h +k
2 2 (ui +1, j + ui −1, j )

(
2 5h 2 − k 2 )
+
h +k
2 2 (u i , j +1 + ui , j −1 ) − 20ui , j = 0 (36)

Poisson eq. ∇ 2u = f ( x, y )
Then (34) becomes
h2 2
ui +1, j +1 + ui −1, j +1 + ui +1, j −1 + ui −1, j −1 − 4 ( ui +1, j + ui −1, j + ui , j +1 + ui , j −1 ) − 20ui , j = 6h f i , j + ∇ f
2
i, j
12
i,j+2

i+1,j+2
i+2,j+2

i,j-2

Not diagonally dominant

∇2 u i, j =
1
12h 2
− {
60ui , j + 16 ( ui +1, j + ui −1, j + ui , j +1 + ui , j −1 ) − ( u i + 2, j + u i − 2, j + u i , j + 2 + u i , } ( )
j −1 ) + O h 2

Not good in solving differential equation, not diagonally dominant


ALTERNATING DIRECTION METHODS

(N+1,M+1)

Solve along rows at once in the direction y


j+1 increasing
j th row, assume j+1 & j-1 known
j

j-1

i-1 i i+1

ui +1, j − 2 (1 + γ ) ui , j + ui −1, j = h 2 f i , j − γ ui , j +1 − γ ui , j −1 (42)


i=2,..., N
u1, j & u N , j known (dirichlet BCs)

Thomas algorithm (line by line)


u i(+n1,)j − 2 (1 + γ ) u i(,nj ) + u i(−n1,)j = h 2 fi , j − γ u i(,nj+−11) − γ u i(,nj−)1 (43)
Gauss-Seidel
Could add SOR
u i(,nj ) = (1 − ω ) γ u i(,nj −1) + ωu i(,nj −1/ 2) i=2,..N (44)
Alternatively we can incorporate SOR factor directly in (43)
ω
u i(,nj ) = (1 − ω ) u i(,nj −1) +
2 (1 + γ )
{u (n)
i +1, j
+ u i(−n1,)j + γ u i(,nj+−11) + γ u i(,nj−)1 − h 2 f i , j }
rearrange
2 (1 + γ )
u i+1, j −
(n)
u i(,nj ) + u i(−n1,)j = −2 (1 + γ )(1 − ω ) u i(,nj −1) + h 2 fi , j − γ u i(,nj+−11) − γ u i(,nj−)1 (45)
ω
Must have diagonally dominance ω≤1+γ
Uniform mesh γ = 1 , ω≤ 2

Note:
1. SOR or just straight line relaxation
2. Number of iterations reduced significantly
3. But amount of computation comparable
ADI METHODS
• Alternating Direction Implicit
• Alternate sweeps in each of coordinate directions
• One implementation

ui +1, j − 2ui , j + ui −1, j = h 2 f i , j − γ {ui , j +1 − 2ui , j − ui , j −1} (47)


substract term ρ ui , j to each side
⎧ (n) ⎛ ρ⎞ n ( n +1/ 2) ⎫
( n +1/ 2)
u i+1, j − ( 2 + ρ ) ui, j
( n +1/ 2) ( n +1/ 2)
+ u i−1, j = h fi , j − γ ⎨u i , j+1
2
− ⎜ 2 − ⎟ u i , j − u i , j−1 ⎬ (48)
⎩ ⎝ γ ⎠ ⎭
ρ accelaration factor

sweeps on line of constant y


then sweep on lines of constant x

i, j i , j −1
{
γ u ( n +1) − ( 2 + γρ ) u ( n+1) + γ u ( n+1) = h 2 fi , j − u ( n +1/ 2) − ( 2 − ρ ) u ( n+1/ 2) − u ( n +1)
i , j +1 i +1, j i, j i −1, j
} (49)
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.
Laplace’s eq.: ∇ 2u = 0
Five-point formula T.E. O ⎡⎣ h 2 , k 2 ⎤⎦

ui +1, j − 2ui , j + ui −1, j ui , j +1 − 2ui , j + ui , j −1


2
+ 2
=0
h
h k
i,j i+1,j
k Most common formula

Nine-point formula:

h 2 − 5k 2
2 ( i +1, j
ui +1, j +1 + ui −1, j +1 + ui +1, j −1 + ui −1, j −1 − 2 2 u + ui −1, j ) +
h +k
5h 2 − k 2
2 ( i , j +1
2 2 u + ui , j −1 ) − 20ui , j = 0
h +k
i+1,j+1

h
i+1,j
i,j
k

• Diagonally dominant
• Greater accuracy for laplace’s eq.
• O ( h2 , k 2 )
• But becomes O ( h6 ) on a square mesh (h=k)
• T.E may be only O ( h 2 , k 2 ) when applied to a more general elliptic eq. (including
Poisson’s 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
∂ 2T ∂ 2T
+ = f ( x, y ) PDE
∂x 2 ∂y 2

Ti,j =
1
2 + 2γ
{ }
− h 2 f i , j + Ti +1, j + Ti −1, j + γ (Ti , j +1 + Ti , j −1 ) FDE
2
⎛h⎞
γ =⎜ ⎟
⎝k⎠

i,j+1 1,M+1 N+1,M+1

i-1,j h
i+1,j
i,j b
k
y
x
i,j-1 1,1
N+1,1
a
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 ∇ 2u = f ( x, y )

ui , j =
1
2(1 + γ )
{ }
− h 2 fi , j + ui +1, j + ui −1, j + γ ( ui , j +1 + ui , j −1 ) (1)

A. Convection at the right boundary:


∂u
(N+1,M+1) −k * = h* ( u − u∞ ) on x=a
∂x
* ( N + 2, j
u − uN , j )
−k = h* ( u N +1, j − u∞ )
2h
h*, u∞
h*
u N + 2, j = u N , j − * 2h ( u N +1, j − u∞ )
k
x = a = xN+1 α

j+1 u N + 2, j = u N , j − α 2h ( u N +1, j − u∞ )

N h
,j N+2
k

j-1
i=N+1 , j=j

u N +1, j =
1
2(1 + γ )
{ }
− h 2 f i , j + u N + 2, j + u N , j + γ ( u N +1, j +1 + u N +1, j −1 )

u N +1, j =
1
2(1 + γ )
{ }
− h 2 f i , j + 2u N , j − 2hα ( u N +1, j − u∞ ) + γ ( u N +1, j +1 + u N +1, j −1 )

u N +1, j =
1
(2 + 2γ + 2hα )
{ }
− h 2 f i , j + 2u N , j + γ ( u N +1, j +1 + u N +1, j −1 ) + 2hα u∞ j=2,...,M

If insulated α =0
B. Convection at the left boundary:
−k * (u 2, j − u0, j )
= h* ( u1, j − u∞ )
2h
u0, j = u2, j + 2hα ( u1, j − u∞ )
j+1

(M+1)
0 h
,j 2
k

j-1 h*

i=1 , j=j x = x1

u1, j =
1
2(1 + γ )
{
− h 2 f i , j + u2, j + u0, j + γ ( u1, j +1 + u1, j −1 )}
u1, j =
1
2(1 + γ )
{
− h 2 f i , j + 2u2, j + 2hα ( u1, j − u∞ ) + γ ( u1, j +1 + u1, j −1 ) }
u1, j =
1
(2 + 2γ − 2hα )
{ − h 2 fi , j + 2u2, j + γ ( u1, j +1 + u1, j −1 ) − 2hα u∞ } j=2,...,M

If insulated α =0
C. Convection at the top boundary:
M+2
h*

i-1 h
i+1
k

−k * (u i,M +2 − ui , M )
= h ( ui , M +1 − u∞ )
*
M
i=i , j=M+1
2k
ui , M + 2 = ui , M − 2kα ( ui , M +1 − u∞ )

ui , M +1 =
1
2(1 + γ )
{
− h 2 fi , j + ui +1, M +1 + ui −1, M +1 + γ ( ui , M + 2 + ui , M ) }
ui , M +1 =
1
2(1 + γ )
{ (
− h 2 fi , j + ui +1, M +1 + ui −1, M +1 + γ 2ui , M − 2kα ( ui , M +1 − u∞ ) )}
{
ui , M +1 (2 + 2γ + γ 2kα ) = −h 2 f i , j + ui +1, M +1 + ui −1, M +1 + γ ( 2ui , M + 2kα u∞ ) }
ui , M +1 =
1
(2 + 2γ + γ 2kα )
{ −h 2
fi , j + ui +1, M +1 + ui −1, M +1 + γ ( 2ui , M + 2kα u∞ )}
D. Convection at the bottom boundary:

−k * (u
i ,2 − ui ,0 )
= h* ( ui ,1 − u∞ ) i-1 h
2k
ui ,0 = ui ,2 + 2kα ( ui ,1 − u∞ )
i,j
i+1
k

ui ,1 =
1
2(1 + γ )
{ }
−h 2 fi ,1 + ui +1,1 + ui −1,1 + γ ( ui ,2 + ui ,0 )

ui , M +1 =
1
2(1 + γ )
{ (
−h 2 fi ,1 + ui +1,1 + ui −1,1 + γ 2ui ,2 + 2kα ( ui ,1 − u∞ ) )}
POINT TREATING AT CORNERS

h1 h2
α1 = , α2 =
k k

∂u
+ α1 ( u − u ∞ ) = 0
∂y

∂u
+ α 2 ( u − u∞ ) = 0
∂x
1,M+2

0,M+1 −
(u1, M + 2 − u1, M )
= α1 ( u1, M +1 − u∞ )
h
2k
1,M+1
k
2,M+1 u1, M + 2 = u1, M − 2kα1 ( u1, M +1 − u∞ )

1,M


( u 2, M +1 − u0, M +1 )
= α 2 ( u1, M +1 − u∞ )
2h
u0, M +1 = u2, M +1 + 2hα 2 ( u1, M +1 − u∞ )
Approx. dif. eq.
i=1 , j=M+1

u1, M +1 =
1
2(1 + γ )
{
− h 2 f1, M +1 + u2, M +1 + u0, M +1 + γ ( u1, M + 2 + u1, M ) }
(
(2 + 2γ )u1, M +1 = − h 2 f1, M +1 + 2u2, M +1 + 2hα 2 ( u1, M +1 − u∞ ) + γ 2u1, M − 2kα1 ( u1, M +1 − u∞ ) )
u1, M +1 =
1
(2 + 2γ + 2γ kα1 − 2hα 2 )
{
− h 2 f1, M +1 + 2u2, M +1 − 2hα 2u∞ + γ ( 2u1, M + 2kα1u∞ ) }
∂u
if = 0 ⇒ α2 = 0
∂x
h1 h2
α1 = , α2 =
k k

∂u
+ α1 ( u − u∞ ) = 0
∂y

∂u
+ α 2 ( u − u∞ ) = 0
∂x

N+1,M+2

N,M+1 N+2,M+1
h

k
N+1,M+1

( u N +1, M + 2 − u N +1, M )
= α1 ( u N +1, M +1 − u∞ )
2k
N+1,M u N +1, M + 2 = u N +1, M − 2kα1 ( u N +1, M +1 − u∞ )

( u N + 2, M +1 − u N , M +1 )
= α 2 ( u N +1, M +1 − u∞ )
2h
u N + 2, M +1 = u N , M +1 − 2hα 2 ( u N +1, M +1 − u∞ )

Approx. dif. eq.


i=1 , j=M+1

u N +1, M +1 =
1
2(1 + γ )
{ }
−h 2 f N +1, M +1 + u N + 2, M +1 + u N , M +1 + γ ( u N +1, M + 2 + u N +1, M )

(
(2 + 2γ )u N +1, M +1 = −h 2 f + 2u N , M +1 − 2hα 2 ( u N +1, M +1 − u∞ ) + γ 2u N +1, M − 2kα1 ( u N +1, M +1 − u∞ ) )
{
u N +1, M +1 (2 + 2γ + 2γ kα1 + 2hα 2 ) = − h 2 f + 2u N , M +1 + 2hα 2u∞ + γ ( 2u N +1, M + 2kα1u∞ ) }
CONVECTIVE TERMS
Navier-Stokes problems:
Example: 2-D , Steady Burgers equation

⎧ ∂u ∂u ⎫ ∂ 2u ∂ 2u
Re ⎨u +v ⎬= 2 + 2 (50)
⎩ ∂x ∂y ⎭ ∂x ∂y
⎧ ∂v ∂v ⎫ ∂ 2 v ∂ 2 v
Re ⎨u + v ⎬ = 2 + 2 (51)
⎩ ∂x ∂y ⎭ ∂x ∂y

Standart Central Difference:


i,j+1

•Similar to N-S but do not include pressure gradient


h •Coupled equations so iteration between equations
i,j are necessary
i+1,j
k
Approximating (50),

⎧⎪ ⎛ ui +1, j − ui −1, j ⎞ ⎛ ui , j +1 − ui , j −1 ⎞ ⎫⎪ ui +1, j − 2ui , j + ui −1, j ui , j +1 − 2ui , j + ui , j −1


Re ⎨ui , j ⎜ + v
⎟ i, j ⎜ ⎟⎬ = 2
+ (50)
⎩⎪ ⎝ 2h ⎠ ⎝ 2k ⎠ ⎭⎪ h k2
h2
Multiply by h , γ = 22

k
ui +1, j + ui −1, j + γ ui , j +1 + γ ui , j −1 − 2 (1 + γ ) ui , j − Re
h
2
{ }
ui , j ( ui +1, j − ui −1, j ) + vi , j γ 1/ 2 ( ui , j +1 − ui , j −1 ) = 0 (52)

Now non-linear algebraic eq.


Most Common Approach
Linearize by guessing selected coefficients
1st derivative term in (52)

⎧ h Re ( n −1) ⎫ ( n ) ⎧ h Re ( n −1) ⎫
u i+1, j ⎨1 −
(n)
u i , j ⎬ + u i−1, j ⎨1 + ui, j ⎬
⎩ 2 ⎭ ⎩ 2 ⎭
(n) ⎧ Re 1/ 2 ( n −1) ⎫ ( n ) ⎧ Re 1/ 2 ( n −1) ⎫
+u i , j+1 ⎨γ − γ hvi , j ⎬ + u i , j−1 ⎨γ + γ hvi , j ⎬ − 2 (1 + γ ) u i(,nj ) = 0 (53)
⎩ 2 ⎭ ⎩ 2 ⎭
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

u i , j = ωu i , j + (1 − ω ) u i , j
(n) (n) ( n −1)

ω = 0.5 & reduce


if ω <0.01 , not worth continuing

3.can use ADI


4.mesh restrictions
need (53) to be diagonally dominant
hRe 1/2 hRe
p= ui , j , q=γ vi , j
2 2
1 − p + 1 + p + γ − p + γ + p ≤ 2 (1 + γ )
Suppose p>1 1 − p + 1 + p =2p>2
& not diagonally dominant
select h,k p < 1 , q < γ
h h
i.e. Re ui , j < 1 , Re vi , j < γ 1/ 2
2 2

But difficult to select a priori


i.ui,j unknown , always try to non-dimensionalize so 0 ≤ ui , j < 1

ii. as Re inreases , smaller & smaller mesh sizes


Possible Acceleration?
Newton linearization
Consider term like (52)
ui , j ( ui +1, j − ui −1, j ) (54)
ui , j ( estimate ) uTi , j = ui , j + δ ui , j
Instead of taking ui,j from previous iterate, use
δ :assumed small
In (54)

(u i, j + δ ui , j )( ui +1, j + δ ui +1, j − ui −1, j − δ ui −1, j )


≈ ui , j ui +1, j + δ ui , j ui +1, j + ui , jδ ui +1, j + ... − ...
= ui , j ui +1, j + ui +1, j ( ui , j − ui , j ) + ui , j ( ui +1, j − ui +1, j ) + ...
= − ui , j ui +1, j + ui +1, jui , j + ui , jui +1, j − {− ui , j ui −1, j + ui −1, jui , j + ui , jui −1, j } (55)

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

∂u
Consider term u
∂x
∂u u − ui −1, j ⎫
( n −1) ⎧ i , j
If a ) ui , j > 0 u = ui, j ⎨ ⎬ + O ( h) (56)
∂x ⎩ h ⎭
∂u ( n −1) ⎧ i +1, j
u − ui , j ⎫
b) ui , j < 0 u = ui, j ⎨ ⎬ + O ( h) (57)
∂x ⎩ h ⎭
Similarly for
∂u
v
∂y
∂u v − vi , j −1 ⎫
( n −1) ⎧ i , j
a) vi , j > 0 v = vi , j ⎨ ⎬ + O(k ) (58)
∂y ⎩ k ⎭
∂u v − vi , j ⎫
( n −1) ⎧ i , j +1
b) vi , j < 0 v = vi , j ⎨ ⎬ + O(k ) (59)
∂y ⎩ k ⎭
Consider first approximate to x derivatives & denote values of ui,j , vi,j from
last iteration with u* i,j , v* i,j

∂ 2u ∂u
T1 = 2 − Re u
∂x ∂x
ui +1, j − 2ui , j + ui −1, j u *i , j ⎧⎪ui , j − ui −1, j , u *i , j > 0
= − Re ⎨
h2 h ⎪ui +1, j − ui , j , u *i , j < 0

or

( ) (
h 2T1 = ui +1, j + ui −1, j 1 + h Re u *i , j − ui , j 2 + h Re u *i , j ) u *i , j > 0

(
=ui +1, j 1 − h Re u *i , j )+u i −1, j − ui, j 2(− h Re u *
i, j
) u *i , j < 0

Note:
Diagonally dominant for all Re
For y derivatives

∂ 2u ∂u
T2 = 2 − Re v
∂y ∂y
ui , j +1 − 2ui , j + ui , j −1 v*i , j ⎪⎧ui , j − ui , j −1 , v*i , j > 0
= − Re ⎨
k2 k ⎪ui , j +1 − ui , j , v*i , j < 0

or

( ) (
h 2T2 = ui , j +1 + ui , j −1 1 + k Re v*i , j − ui , j 2 + h Re v*i , j ) v*i , j > 0

(
=ui , j +1 1 − k Re v*i , j )+u i , j −1 − ui, j 2(− k Re v *
i, j
) v*i , j < 0
Approximating to differential equation (50)
2
h
⎧ ∂u
Re ⎨u
∂u ⎫ ∂ 2u ∂ 2u
+v ⎬= 2 + 2 (50)
h 2T1 + 2 T2 = 0
⎩ ∂x ∂y ⎭ ∂x ∂y k
h 2T1 + γ T2 = 0 (62)
or in the form
b1ui +1, j + b2ui , j +1 + b3ui −1, j + b4ui , j −1 − b0ui , j = 0 (63)
where
b1 = 1 , b3 = 1 + h Re ui*, j ui*, j >0
= 1 − h Re ui*, j , b3 = 1 ui*, j <0
b2 = γ , (
b4 = γ 1 + k Re vi*, j ) vi*, j >0

(
= γ 1 + k Re vi*, j ) , b4 = γ vi*, j <0

(
b0 = 2 + h Re ui*, j + γ 2 + h Re vi*, j )
1
Simplified driven cavity problem

∂u 1 ⎧ ∂ 2u ∂ 2u ⎫
0 0 u = ⎨ 2 + 2⎬
∂x Re ⎩ ∂x ∂y ⎭

0
Typical code changes
F1 = h*Re
F2 = k*Re IF (X2.GT.0.0) THEN
DO 10 I = 2, N1 B2 = G
DO 10 J = 2, M1 B4 = X4
X1 = U(I,J) ELSE
X2 = V(I,J) B2 = X4
X3 = 1 + F1*ABS(X1) B4 = G
X4 = G*(1.0 + F2*ABS(X2)) END IF
IF (X1.GT.0.0) THEN B0 = X3 + 1.0 + X4 + G
B1 = 1.0 U(I,J) = (U(I+1,J)*B1+U(I-
B3 = X3 1,J)*B3+U(I,J+1)*B2 + U(I,J-1)*B4)/B0
ELSE Convergence test
B1 = X3 END DO
B3 = 1.0 END DO
END IF
DEFERRED CORRECTION
Upwind/downwind differencing , diagonally dominant ,
Convergence but accuracy problem

Central difference
∂u ui +1, j − ui −1, j
= + O(h 2 ) (64)
∂x 2h
∂u ui , j − ui −1, j
= + Cx+ + O(h 2 )
∂x h
ui +1, j − ui , j
= + Cx− + O(h 2 ) (65)
h
Choose correction Cx+ & Cx- so (64) & (65)

ui +1, j − 2ui , j + ui −1, j


Cx+ =
2h
ui +1, j − 2ui , j + ui −1, j
Cx− = − (66)
2h
∂u
Similar expressions for
∂y
∂u ui , j − ui , j −1
= + C y + + O(k 2 ) (67)
∂y k
ui , j +1 − ui , j
= + C y − + O(k 2 )
h
ui , j +1 − 2ui , j + ui , j −1
C y + = −C y − = (68)
2k

Difference equations become

b1ui +1, j + b2ui , j +1 + b3ui −1, j + b4ui , j −1 − b0ui , j = di , j (69)


hui*, j h2 *
di , j =−
2
{ui +1, j − 2ui , j + ui −1, j } − vi , j {ui , j +1 − 2ui , j + ui , j −1} (70)
2k
Implementation

1) perform several iteration with di,j=0


2) evaluate di,j at each point in mesh & add to right side of (69)
3) perform several iterations with di,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.

∇.V = 0
⎡ ∂V ⎤
ρ
DV
=ρ⎢ ( )
+ V .∇ V ⎥ = F − ∇P + µ∇ 2 V (1)
Dt ⎣ ∂t ⎦
Using characteristic velocity U and length L, and time is non-dimensionalized with L/U ,
t
τ=
L /U
Dimensionless eq.
∂V F ρ gL
∂τ
( )
+ V .∇ V =
ρU 2
− ∇ P +
1 2
Re
∇V

UL
Re =
ν
U2
Fr= when gravitational field is considered as the body force term
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
∂u ∂v
+ =0
∂x ∂y
∂ψ ∂ψ Note: continuity eq. is identically satisfied.
introduce ψ : u = , v=−
∂y ∂x Taking curl of (1) , vorticity eq. is obtained

∂ω
∂τ
( )
+ V .∇ω = ω.∇ V + ν∇ 2 ω

Inviscid flow → ν = 0 , F = 0, ∇ × ∇P = 0 (show!)


Vorticity is defined ∇ × V = ω
( )
Here ω.∇ V = 0 for 2-D flow since
ω z : perpendicular to plane of flow (only non-zero comp. of vorticity for 2-D flow)
∂ω Dω z
+ V .∇ω = =0 vorticity is preserved for steady inviscid flow!
∂τ Dτ
Steady flow, ωz along a streamline

∂ω z ∂ω z
u +v =0
∂x ∂y
∂v ∂u ∂ 2ψ ∂ 2ψ
ωz = − = − 2 − 2
∂x ∂y ∂x ∂y
∇ 2ψ = −ω z

i. For irrotational flow: ∇ 2ψ = 0 (Laplace eq.)


Velocity potential may also be used
V = ∇φ → ∇ 2φ = 0 (continuity eq.)
ii. For rotational flow ∇ 2ψ = −ω z
Analitical solutions for the inviscid or potential flow in simple configurations exist.
Numerical Solution
Elliptic problem → ψ must be specified at the boundaries
Example:
ψ = UmD A channel of varying area
INVISCID FLOW
D
Ue
d
inlet
outlet
ψ=0
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 Ue


Case I: Ue = const. = Um : uniform flow at inlet
Case II: Ue = π/2 Um sin πy/D : fully developed laminar flow

Um : average of velocity distribution at the inlet


Flow rate in both cases is Um D
D
π π
Q=∫ U m sin ydy ψA

0
2 D
ψB
U m D = ψ upper wall −ψ lower wall
Q=ψA – ψB

Boundary conditions for ψ


A. INLET
∂ψ ∂ψ
u= , v=−
∂y ∂x
∂ψ ∂ψ
= ue , = 0 → ψ ≠ ψ ( x)
∂y ∂x
ψ = Ue y + c
Take ψ =0 at y=0 → c=0
ψ =U e y
D⎛ π y ⎞ ∂ψ π πy
i. ψ = U m y ii. ψ = U m ⎜ 1 − cos ⎟ : = U m si n
2⎝ D ⎠ ∂y 2 D
B. UPPER WALL
ψ = UmD for both cases indicates the same volume flow rate
D
C. EXIT ψ = Um y
d
VORTICITY FOR THE CASES AT INLET

∂v ∂u
i. ω z = − =0
∂x ∂y
π2 πy π 2ψ π 2U m
ii. ωz = − U m cos = 2
− ≠0
2D D D 2D
Vorticity in preserved in inviscid flow

Governing eqs.

i. ωz = 0
π 2ψ π 2U m
ii. ωz = 2

D 2D
Non-dimensionalize for general results
x y ψ
X= , Y= , Ψ=
D D UmD

∂ 2
Ψ ∂ 2
Ψ
i. + =0
∂X 2
∂Y 2

∂2Ψ ∂2Ψ 2⎛1 ⎞


ii. + = π ⎜ − Ψ ⎟ = f (Ψ )
∂X 2
∂Y 2
⎝2 ⎠

ψ=1

ψ=0
Inlet
⎛ ⎞
i. Ψ =Y ⎜ U m DΨ = U m YD ⎟
⎜ y ⎟
⎝ ψ ⎠
1
ii. Ψ= (1 − cos π Y )
2
At outlet distribution for both cases
D
Ψ= Y
d
Poisson eq.

(δ 2
x )
+ δ y2 Ψ = f (Ψ )
G.S iteration scheme
1
Ψ i,j =
n+1 ⎡
2 (1 + γ ) ⎣
n n+1
( n n+1
) 2
( )⎦ (
Ψ i+1,j + Ψ i-1,j + γ Ψ i,j+1 + Ψ i,j-1 − ( ∆x ) f Ψ in, j ⎤ − f Ψ in, j )
SOR is possible Ψ i,jn+1 = (1 − ω ) Ψ i,jn + ω Ψ i,jn+1
Having obtained streamlines or lines of constant Ψ
Velocity components

Ψ i , j +1 − Ψ i , j −1
ui , j =
2 ∆y
Ψ i −1, j − Ψ i +1, j
vi , j =
2 ∆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

x ψ=0
∂ψ ∂ψ
u= ≠0 , v=− =0
∂y ∂x
Pressure field

1
p + ρV 2 = const.
2
V: flow speed at a point
Vi , j = ui2, j + vi2, j
pi , j is obtained & employed in B.L eqs.
Vorticity-Stream Function Formulation: pg.650
∂v ∂u
Ω = ∇ × V → 2-D → Ω z = −
∂x ∂y
∂ψ ∂ψ
2-D Flow → u = ,v = −
∂y ∂x
∂Ω ∂Ω ∂Ω ⎛ ∂ 2Ω ∂ 2Ω ⎞ ⎫
+u +v = ν ⎜ 2 + 2 ⎟⎪
∂t ∂x ∂y ⎝ ∂x ∂y ⎠ ⎪
⎬ dimensional
∂ψ ∂ψ
2 2

+ = −Ω ⎪
∂x 2 ∂y 2 ⎭
1
non-dimensional ν =
Re
ΩL ψ u x tU ∞
Ω =
*
, ψ =
*
, u =
*
, x =
*
, t =
*
,
U∞ U∞ L U∞ L 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 P ∂2 P ⎞ ⎛ ∂u ∂v ∂u ∂v ⎞
−⎜ 2 + 2 ⎟ = 2⎜ − ⎟
⎝ ∂x ∂y ⎠ ⎝ ∂y ∂x ∂x ∂y ⎠
⎡ ∂ 2ψ ∂ 2ψ ⎛ ∂ 2ψ ⎞ 2 ⎤
∇2 P = 2 ⎢ 2 −⎜ ⎟ ⎥ dimensionless form
⎢⎣ ∂x ∂y ⎝ ∂x∂y ⎠ ⎥⎦
2
Vorticity-stream function formulation ω −ψ

A. Vorticity-transport equation (parabolic)

∂Ω ∂Ω ∂Ω 1 ⎛ ∂ 2 Ω ∂ 2 Ω ⎞
+u +v = ⎜ 2 + 2 ⎟ (1)
∂t ∂x ∂y Re ⎝ ∂x ∂y ⎠

B. Stream function eq. (elliptic)

∂ 2ψ ∂ 2ψ
+ 2 = −Ω (2)
∂x 2
∂y
Numerical Algorithms
a. Unsteady flows:
1. Any scheme developed for parabolic eqs.
2. Any scheme developed for elliptic eqs.
b. Steady flows:

∂Ω ∂Ω 1 ⎛ ∂ 2 Ω ∂ 2 Ω ⎞
I. u +v = ⎜ 2 + 2 ⎟ (3)
∂x ∂y Re ⎝ ∂x ∂y ⎠
∇ 2ψ = −Ω
Two elliptic eqs.
can be solved by iterative scheme. e.g. G.S or upwind-downwind differencing
II. Unsteady equations are solved until steady state
Total computation time may be too excessive
III. Pseudo-transient approach
∂ψ ⎛ ∂ 2ψ ∂ 2ψ ⎞
−⎜ 2 + 2 + Ω⎟ = 0 Two parabolic eqs.
∂t ⎝ ∂x ∂y ⎠
Vorticity-transport equation
A. Explicit: FTCS scheme

Ωin,+j1 − Ωin, j Ωin+1, j − Ωin−1, j Ωin, j +1 − Ωin, j −1


+ uin, j + vin, j =
∆t 2 ∆x 2 ∆y
⎧ Ω n
1 ⎪ i +1, j − 2 Ω n
i, j + 2 Ω n
i −1, j Ω n
i , j +1 − 2 Ω n
i, j + 2Ω n ⎫
i , j −1 ⎪
⎨ + ⎬ (4)
( ∆x ) ( ∆y )
2 2
Re ⎪ ⎪⎭

DuFort-Frankel:
n +1 n −1
∂Ω Ωi , j − Ωi , j
= • Use of an upwind differencing scheme may be
∂t 2 ∆t appropriate for convection dominated flows
n +1 n −1
Ω i, j + Ω i, j
Ωin, j =
2
B. Implicit: Approximate Factorization for efficiency for multi-dimensional problems.
ADI formulation: two-step process; treat x der. implicitly & y der. implicitly.

Ωin,+j1/ 2 − Ωin, j Ωin++1,1/j2 − Ωin−+1,1/j2 Ωin, j +1 − Ωin, j −1


+u n
i, j +v
n
i, j =
∆t / 2 2∆x 2 ∆y
⎧ ⎫
⎪ n +1/ 2 n +1/ 2 n +1/ 2 ⎪
1 ⎪ Ωi +1, j − 2Ωi , j + 2Ωi −1, j Ωi , j +1 − 2Ωi , j + 2Ωi , j −1 ⎪
n n n

⎨ + ⎬ (5a)
( ∆x ) ( ∆y )
2 2
Re ⎪ ⎪
⎪ ⎪
⎩ ⎭
n +1 / 2 n +1/ 2
δ xx Ωij δ yy Ωij

Ωin,+j1 − Ωin,+j1/ 2 Ω n +1/ 2


+ − Ω n +1/ 2
− Ω n +1
+ − Ω n +1
, j −1
+ uin, +j 1/ 2 + vin, +j 1/ 2
i 1, j i 1, j i , j 1 i
=
∆t / 2 2∆x 2 ∆y
⎧ ⎫
⎪ n +1/ 2 n +1/ 2 n +1/ 2 n +1 n +1 n +1 ⎪
1 ⎪ Ωi +1, j − 2Ωi , j + 2Ωi −1, j Ωi , j +1 − 2Ωi , j + 2Ωi , j −1 ⎪
⎨ + ⎬ (5b)
( ∆x ) ( ∆y )
2 2
Re ⎪ ⎪
⎪ ⎪
⎩ ⎭
n +1/ 2 n +1
δ xx Ωii δ yy Ωij

n n
In eq.(5b) can use ui , j & vi , j 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⎛1 ⎞ n +1/ 2 1⎛1 ⎞
(5a) ⇒ - ⎜ cx + d x ⎟ Ωi −1, j + (1 + d x ) Ωi , j + ⎜ cx − d x ⎟ Ωin++1,1/j2 = Dx
n +1/ 2

2⎝2 ⎠ 2⎝2 ⎠
Bx
Ax Cx

1⎛1 ⎞ 1⎛1 ⎞
(5b) ⇒ - ⎜ c y + d y ⎟ Ωin,+j1−1 + (1 + d y ) Ωin,+j1 + ⎜ c y − d y ⎟ Ωin,+j1+1 = Dy
2⎝2 ⎠ 2⎝2 ⎠
By
Ay Cy

∆t ∆t
where cx = u , cy = v Courant numbers
∆x ∆y
1 ∆t 1 ∆t
dx = , dy = Diffusion numbers
Re ( ∆x )2 Re ( ∆y ) 2

1⎛1 ⎞ n 1⎛ 1 ⎞ n
Dx = ⎜ c y + d y ⎟ Ωi , j −1 + (1 − d y ) Ωi , j + ⎜ − c y + d y ⎟ Ωi , j +1
n

2⎝2 ⎠ 2⎝ 2 ⎠
1⎛1 ⎞ n +1/ 2 1⎛ 1 ⎞
Dy = ⎜ cx + d x ⎟ Ωi −1, j + (1 − d x ) Ωi , j + ⎜ − cx + d x ⎟ Ωin++1,1/j2
n +1/ 2

2⎝2 ⎠ 2⎝ 2 ⎠
Ax Ωin−+1,1/j2 + Bx Ωin,+j1/ 2 + C x Ωin++1,1/j2 = Dx (6a)
Ay Ωin,+j1−1 + By Ωin,+j1 + C y Ωin,+j1+1 = Dy (6b)
Tri-diagonal matrix algorithm Thomas Algorithm
Stream Function Equation

∇ 2ψ = −Ω
• Any numerical scheme for elliptic eq. is applicable, e.g., G.S.

1
ψ k +1
i, j =
2 (1 + γ ) ⎣
( )
⎡( ∆x )2 Ωik, j + ψ ik+1, j + ψ ik−+1,1j + γ ψ ik, j +1 + ψ ik, +j −11 ⎤

(7)

2
⎛ ∆x ⎞
γ =⎜ ⎟
⎝ ∆y ⎠
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
⎡ψ i ,1 −ψ i ,2 ⎤
Ωi ,1 = 2 ⎢ ⎥ + O ( ∆y )
⎢⎣ ( ∆y ) ⎥⎦
2

use under-relaxation here


Ωik,1+1 = (1 − λ ) Ωik,1 + λ Ωik,1+1
check convergence
return to (ii)
Body Surface B.Cs: Driven cavity problem

u=U0 , v=0
M+1
A B
u=0 , v=0 u=0 , v=0

x
j=1 N+1
i=1 , u=v=0 C
Looks as if too much information for ψ & not enough info for Ω
Answer:
a) ψ =0 (constant) for ∇ 2ψ = −Ω

∂ψ used to construct conditions on Ω


b)
∂n
Example: BCs at the left wall. u=v=0 at x=0

∂ψ ⎫
u= =0 ⎪
∂y ⎪
⎬ψ = const. (arbitrary) (B1)
∂ψ
v=− = 0⎪
∂x ⎪⎭
∂ψ
on x=0 ψ & known but not Ω
∂x

Use stream function eq. to find B.Cs for vorticity; i.e. ∇ 2ψ = −Ω on the left wall. i=1 , j=j

Thom’s method:
⎛ ∂ 2ψ ∂ 2ψ ⎞
⎜ 2 + 2 ⎟ = −Ω1, j (B2)
⎝ ∂x ∂y ⎠1, j
∂ 2ψ
Along A (left wall) ⇒ = 0 (ψ is constant along y)
∂y 2
1, j

∂ 2ψ
= −Ω1, j (B3)
∂x 2
1, j
To obtain an expression for the second-derivative in eq. above, use Taylor Series
expansion

( ∆x )
2
∂ψ ∂ψ
2
ψ 2, j = ψ 1, j + ∆x + + ... (B4)
∂x 1, j ∂x 2 1, j
2

Along boundary A, v=0


∂ψ
v1, j = − =0
∂x 1, j

( ∆x )
2
∂ψ 2
+ O ( ∆x )
3
ψ 2, j = ψ 1, j +
∂x 2 1, j
2

∂ 2ψ 2 (ψ 2, j − ψ 1, j )
= + O ( ∆x ) (B5)
∂x 2 ( ∆x )
2
1, j

Substitute (B5) into (B3)


2 (ψ 1, j − ψ 2, j )
Ω1, j = + O ( ∆x ) (B6)
( ∆x )
2
Similarly, for right wall B & bottom wall C:
( ∆x )
2
∂ψ ∂ψ 2
ψ N , j = ψ N +1, j − ∆x +
∂x N +1, j
∂x 2 N +1, j
2

2 (ψ N , j −ψ N +1, j ) ∂ 2ψ
+ O ( ∆x ) = 2
( ∆x ) ∂x
2
N N+1 N +1, j

∂ 2ψ 2 (ψ N +1, j − ψ N , j )
B: Ω N +1, j =− 2 =
∂x ( ∆x )
2
N +1, j

∂ 2ψ 2 (ψ i ,1 − ψ i ,2 )
C: Ωi ,1 = − 2 =
∂y ( ∆y )
2
i ,1
II.Method:
∂ 2ψ ψ 2, j − 2ψ 1, j +ψ 0, j
+ O ( ∆x ) = −Ω1, j
2
(B3) ⇒ = −Ω1, j ⇒
∂x 2 ( ∆x )
2
1, j

∂ψ ψ 2, j −ψ 0, j
ψ 0, j = ? v1, j =− =− + O(∆x) 2 = 0 ⇒ ψ 2, j = ψ 0, j + O(∆x)3
∂x 1, j 2∆x
2 (ψ 1, j −ψ 2, j )
Ω1, j = + O ( ∆x )
( ∆x )
2
Now suppose upper boundary moving with a specified velocity, U0

( ∆y )
2
∂ψ ∂ 2ψ
ψ i , j −1 = ψ i , j − ∆y + 2 + ...
∂y i, j
∂y i, j
2!
U 0 (j=M+1)

j=M+1
( ∆y )
2

+ O ( ∆y )
3
ψ i , M = ψ i , M +1 − U 0 ∆y − Ω i , M +1
2
∂ 2ψ ∂ 2ψ
+ = −Ω i , M +1
∂y 2 i , M +1
∂ x 2
i , M +1

2 (ψ i , M +1 − ψ i , M ) 2U 0
Ω i , M +1 = − + O ( ∆y )
( ∆y ) ∆y
2

2 (ψ i , M +1 − ψ i , M )
Note that → U 0 = 0 ⇒ Ω i , M +1 =
( ∆y )
2

A second order equivalent of (B6) is given


ψ 3, j − 8ψ 2, j + 7ψ 1, j
+ O ( ∆x )
2
Ω1, j =
2 ( ∆x )
2
• Higher order implementation of B.Cs, in general, will increase the accuracy of
solution , but it may cause instabilities for high Reynolds number flow

−ψ i , M +1 + 8ψ i , M − 7ψ i , M −1 3U o
ψ i , M +1 = −
2 ( ∆y ) ∆y
2

INFLOW: u is specified
ψ =C Inlet velocity profile u = u(x,y) at x = x0 then
y
∂ψ 0

u= → ψ ( x0 , y ) = ∫ u ( x0 , y )dy
∂y 0
ψ =0
∂ψ ∂ψ
u= ,v = −
∂y ∂x
i. Values of ψ along the inflow are specified
∂ψ
u = U0 → = U0 →ψ = U0 y
∂y
ii. Its values is determined from the interiour
∂ψ 1
v=0→ = 0 ⇒ −3ψ 1, j + 4ψ 2, j −ψ 3, j = 0; ψ 1, j = ⎡⎣ 4ψ 2, j −ψ 3, j ⎤⎦
∂x 1, j 3
Vorticity at the inflow:
⎛ ∂ 2ψ ∂ 2ψ ⎞
a. ⎜ + 2 ⎟ = −Ω1, j
⎝ ∂x ∂y ⎠1, j
2

2 (ψ 1, j −ψ 2, j ) ψ 1, j +1 − 2ψ 1, j + ψ 1, j −1
Ω1, j = −
( ∆x ) ( ∆y )
2 2

b. ∂v ∂u ⎛ ∂ 2ψ ∂u ⎞
Ωi , j = − = ⎜− 2 + ⎟
∂x ∂y ⎝ ∂x ∂y ⎠i , j

specified u is directly used to evaluate Ω & set i=1

−3ψ 1, j + 4ψ 2, j −ψ 3, j u1, j +1 − u1, j −1


Ω1, j = −
( ∆x ) 2∆y
2

second order forward dif. second order central dif.


OUTFLOW: value of streamfunction is usually extrapolated from the interior solution.
∂ψ
Utilizing =0 second-order backward approximation
∂x

∂ψ ∂ψ 3ψ N +1, j − 4ψ N , j + ψ N −1, j
=0 =0=
∂x ∂x N +1, j 2∆x
(v = 0) 1
N-1 N N+1 ψ N +1, j =
3
( 4ψ N , j −ψ N −1, j )

∂ 2ψ
The condition =0 is also used
∂x 2

Second-order backward approx.


1
ψ N +1, j = (ψ N − 2, j − 4ψ N −1, j + 5ψ N , j )
2
First-order backward approximation

ψ N +1, j = −ψ N −1, j + 2ψ N , j
outflow

Take this far


away
As with the inflow B.C vorticity at outlet can be determined by numerous methods,
Examples:

2 (ψ N +1, j −ψ N , j ) (ψ N +1, j +1 − 2ψ N +1, j + ψ N +1, j −1 )


Ω N +1, j = −
( ∆x ) ( ∆y )
2 2

Simple extrapolation may be used for which one sets

∂Ω 1
= 0 ⇒ Ω N +1, j = ( 4Ω N , j − Ω N −1, j )
∂x 3
SYMMETRY BOUNDARIES:

y ∂u ∂v ∂u
v=0 , =0⇒Ω= − =0
x u(y) v=0 , ∂y ∂x ∂y
∂u
u symmetric → =0
∂y
2-D jet flow
x
Stream function
1 ∂ψ ∂ψ
Vr = , Vθ = −
r ∂θ ∂r
∂Vθ Vθ 1 ∂Vr
Ω = ∇ ×V = + − (*)
∂r r r ∂r
Vorticity transport:

∇ 2ψ = −Ω
B.Cs
1 ∂ψ
as r → ∞ Vr = → cos θ
r ∂θ
∂ψ
Vθ = − → − sin θ
∂r
ψ ~ r sin θ as r → ∞
Ω = 0 (*) as r → ∞
1 ∂ψ
on r=1 Vr = = 0 → ψ = 0 on r=1
r ∂θ
∂ψ ∂ψ
Vθ = − =0 = 0 on r=1
∂r ∂r
Boundary Conditions For Vorticity

∇ 2ψ = −Ω
∂Ω ∂Ω 1 ⎧ ∂ 2 Ω ∂ 2 Ω ⎫
u +v = ⎨ 2 + 2⎬
∂x ∂y Re ⎩ ∂x ∂y ⎭

Stream function:

1 ∂ψ ∂ψ
Vr = , Vθ = − (71)
r ∂θ ∂r Vθ Vr
∂Vθ Vθ 1 ∂Vr
Ω=∇ × V = + − (72) U=1 r θ
∂r r r ∂θ
governing eq. i) Vorticity transport
ii) ∇ 2ψ = −Ω
Boundary conditions for cylindrical coordinates
i)
1 ∂ψ
as r → ∞ Vr = → cos θ
r ∂θ
∂ψ
Vθ = − → − sin θ
∂r
ψ ≈ r sin θ as r → ∞

And from (72)

Ω → 0 as r → ∞
ψ &Ω known
1 ∂ψ
ii) on r = 1 Vr = =0 ψ =0 on r=1
r ∂θ
∂ψ ∂ψ
Vθ = − =0 =0
∂r ∂r
∂ψ
ψ, known but not Ω
∂r
Pressure Equation:

⎡⎛ ∂ 2ψ ⎞ ⎛ ∂ 2ψ ⎞ ⎛ ∂ 2ψ ⎞ ⎤
∇ P = 2 ρ ⎢⎜ 2 ⎟ ⎜ 2
2
⎟−⎜ ⎟ ⎥ = S (P1) see page 652 for derivation
⎣⎝ ∂x ⎠ ⎝ ∂y ⎠ ⎝ ∂x ∂y ⎠⎦

Second-order difference representation

⎡⎛ ψ ⎞ ⎛ ψ i , j +1 − 2ψ i , j + ψ i , j −1 ⎞ ⎛ ψ i +1, j +1 −ψ i +1, j −1 −ψ i −1, j +1 + ψ i −1, j −1 ⎞ 2 ⎤


i +1, j − 2ψ i , j + ψ i −1, j
Si , j = 2 ρ i , j ⎢⎜ ⎟⎜ ⎟−⎜ ⎟ ⎥ (P2)
⎢⎣⎝⎜ ( ∆x ) ⎟⎜ ( ∆y ) ⎟ ∆ ∆
2 2
⎠⎝ ⎠ ⎝
4 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.
⎛ ∂u ∂u ⎞ ∂P ⎛ ∂ 2u ∂ 2u ⎞
ρ ⎜u +v ⎟=− +µ⎜ 2 + 2 ⎟
⎜ ∂x ∂y ⎟⎠
⎝ ∂x ∂y ⎠ ∂x ⎝
∂P ∂ 2u y
=µ 2 3
∂x wall ∂y wall

∂P ∂Ω 2
= −µ (P3)
∂x wall ∂y wall
∂v ∂u Wall y=0, 1 x
Ω wall = −
∂x wall
∂y wall
u=v=0

Pi +1,1 − Pi −1,1 ⎛ −3Ωi ,1 + 4Ωi ,2 − Ωi ,3 ⎞


= −µ ⎜ ⎟ (P4)
2∆x ⎝ 2 ∆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 in (P4)
∂x
• Thereafter, use eq.(P4) to find pressure at all other wall points.
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.)
∂u ∂u
+a =0 , a>0 (speed of sound) (1)
∂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. Euler’s FTCS method:

uin +1 − uin
∆t
= −a
uin+1 − uin−1
2∆x
(
O ∆t, ( ∆x )
2
) (2)

Von Neumann stability analysis shows it is unconditionally unstable.


2. The Lax method:
n
In FTCS method: replace ui with an average value
1 n
uin =
2
( )
ui +1 + uin−1 (3)

1 n
∂u
n +1
(
ui − ui +1 + uin−1
2
)
= (4)
∂t ∆t

Substituting (2) & (4) into (1), we have

u n
+ u n
∆ t u n
− u n
uin +1 = i +1 i −1 − a i +1 i −1
(5)
2 ∆x 2
Von Neumann stability analysis
Assume an error of the form ∈m ( x, t ) = ebt eikm x & substitute in (5),
amplification factor becomes

Note: the error also satisfies the differential eq.


∈in +1 stable solution
≤1
∈i n

ebt = cos(km ∆x) − iC sin(km ∆x)


∆t
where C = a
∆x
the stability requirement is ebt ≤ 1
∆t
C=a ≤ 1 Courant number (CFL condition) (6)
∆x
important stability requirement for hyperbolic eqs.

3. Midpoint Leapfrog method


second-order central differencing for both time&space derivatives

uin +1 − uin −1 uin+1 − uin−1


2∆t
= −a
2∆x
(
O (∆t) 2 ,(∆x) 2 ) (7)

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
∂ 2u ( ∆t )
2
∂u
u ( x , t + ∆t ) = u ( x , t ) + ∆ t + 2 +O ( ∆t )
3
(8)
∂t ∂t 2!
or in terms of indices
∂ 2 u ( ∆t )
2
∂u
+O ( ∆t )
n +1 3
ui = ui + ∆t + 2
n
(9)
∂t ∂t 2!
Now consider the model eq.
∂u ∂u
= −a (10)
∂t ∂x
∂ 2u ∂ ⎛ ∂u ⎞ ∂ ⎛ ∂u ⎞ 2 ∂ u
2
= −a ⎜ ⎟ = −a ⎜ ⎟ = a (11)
∂t 2
∂t ⎝ ∂x ⎠ ∂x ⎝ ∂t ⎠ ∂x 2

Substituting (10) & (11) into (9) produces

( ∆t ) 2 ∂ 2u
2
n +1 ⎛ ∂u ⎞
ui = ui + ⎜ −a ⎟ ∆t +
n
a
⎝ ∂x ⎠ 2 ∂x 2
Use central differencing of second order for the spatial derivatives

uin+1 − uin−1 1 2 2 ui +1 − 2ui + ui −1


n n n
un +1
=u −a
n
∆t + a ( ∆t )
( ∆x )
i i
2∆x 2 2

⎡ ( ) ( ) ⎤
2 2
Lax-Wendroff method O ∆t , ∆x
⎣ ⎦
Stability analysis shows explicit method is stable for C ≤ 1

Implicit Formulations
1. Euler’s BTCS method:
uin +1 − uin a
=− ⎡⎣uin++11 − uin−+11 ⎤⎦
∆t 2∆x
1 n +1 n +1 1 n +1 ⎡ ∆t , ( ∆x )2 ⎤
Cui −1 − ui − Cui +1 = −uin
2 2 ⎣ ⎦
TDMA

2. Crank-Nicolson method:
uin +1 − uin a ⎡ uin++11 − uin−+11 uin+1 − uin−1 ⎤
=− ⎢ + ⎥
∆t 2 ⎣ 2 ∆x 2 ∆x ⎦
O ⎡( ∆t ) , ( ∆x ) ⎤ TDMA
2 2

⎣ ⎦
SOLUTION OF EULER’S 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)
∂ρ ⎛ ∂u ∂ρ ∂v ∂ρ ⎞
Continuity: = −⎜ ρ +u +ρ +v ⎟ (1) no boundary forces
∂t ⎝ ∂x ∂x ∂y ∂y ⎠
∂u ⎛ ∂u ∂u 1 ∂P ⎞
x-mom: = −⎜u +v + ⎟ (2)
∂t ⎝ ∂x ∂y ρ ∂x ⎠
∂v ⎛ ∂v ∂v 1 ∂P ⎞
y-mom: = −⎜u + v + ⎟ (3)
∂t ⎝ ∂x ∂y ρ ∂y ⎠
∂e ⎛ ∂e ∂e P ∂u P ∂v ⎞
Energy: = −⎜u + v + + ⎟ (4)
∂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 ρ ⎞ ( ∆t )
n n 2
⎛ ∂ρ ⎞
ρi , j = ρi , j + ⎜ ⎟ ∆t + ⎜ 2 ⎟
n +1 n
+... (5)
⎝ ∂t ⎠i , j ⎝ ∂t ⎠i , j 2!
If flow field at time level n is known,
Eq.(5) gives the new flow field at time (n+1)→t+∆t
n n
⎛ ∂ρ ⎞ ⎛ ∂2 ρ ⎞
⎟ & ⎜ 2 ⎟ are found ρi , j
n +1
if ⎜ can be calculated explicitly, from eq.(5)
⎝ ∂t ⎠i , j ⎝ ∂t ⎠i , j
Analogous Taylor series for all other dependent variables can be written as follows:

⎛ ∂ 2u ⎞ ( ∆t )
n n 2
n +1 ⎛ ∂u ⎞
ui , j = ui , j + ⎜ ⎟ ∆t + ⎜ 2 ⎟
n
+... (6)
⎝ ∂t ⎠i , j ⎝ ∂t ⎠i , j 2!
⎛ ∂ v ⎞ ( ∆t )
n n 2
⎛ ∂v ⎞
2
vin, +j 1 = vin, j + ⎜ ⎟ ∆t + ⎜ 2 ⎟ +... (7)
⎝ ∂t ⎠i , j ⎝ ∂t ⎠i , j 2!
⎛ ∂ e ⎞ ( ∆t )
n n 2
⎛ ∂e ⎞
2
n +1
ei , j = ei , j + ⎜ ⎟ ∆t + ⎜ 2 ⎟
n
+... (8)
⎝ ∂t ⎠i , j ⎝ ∂t ⎠i , j 2!
Using spatial derivatives (second-order central dif.) from eq.(1)
⎛ ∂ρ ⎞
n
⎛ n uin+1, j − uin−1, j ρin+1, j − ρin−1, j vin, j +1 − vin, j −1 ρin, j +1 − ρin, j −1 ⎞
⎟ = − ⎜⎜ ρi , j + ui , j + ρi , j + vi , j
n n n
⎜ ⎟⎟ (9)
⎝ ∂t ⎠i , j ⎝ 2 ∆ x 2 ∆ x 2 ∆ y 2 ∆ y ⎠
In (9), all quantities on RHS are known.
n
⎛ ∂2 ρ ⎞
Differentiate eq.(1) with respect to time ⎜ 2 ⎟ =?
⎝ ∂t ⎠i , j
n
⎛ ∂2 ρ ⎞ ⎛ ∂ 2u ∂u ∂ρ ∂ 2 ρ ∂ρ ∂u ∂ 2 v ∂v ∂ρ ∂ 2 ρ ∂ρ ∂v ⎞
⎜ 2 ⎟ = −⎜ ρ + +u + +ρ + +v + ⎟ (10)
⎝ ∂t ⎠i , j ⎝ ∂x ∂t ∂x ∂t ∂x ∂ t ∂x ∂t ∂y ∂ t ∂y ∂t ∂y ∂ t ∂y ∂t ⎠

∂ 2u
=?
∂x∂t
Differentiate eq.(2) wrt x;
2
∂ 2u ∂ 2u ⎛ ∂u ⎞ ∂ 2u ∂u ∂v 1 ∂ 2 P 1 ∂P ∂ρ
= −u 2 + ⎜ ⎟ + v + + − 2 (11)
∂x∂t ∂x ⎝ ∂x ⎠ ∂x∂y ∂y ∂x ρ ∂x 2
ρ ∂x ∂x
In eq.(11) all terms on RHS are expressed as second-order, central dif. eqs. at time
level n:
n 2
⎛ ∂ 2u ⎞ uin+1, j − 2uin, j + uin−1, j ⎛ ui +1, j − ui −1, j ⎞
⎟ = −ui , j +⎜ ⎟ +
n

⎝ ∂x∂t ⎠i , j ( ∆x ) 2∆x
2
⎝ ⎠
uin+1, j +1 + uin−1, j −1 − uin−1, j +1 − uin+1, j −1 uin, j +1 − uin, j −1 vin+1, j − vin−1, j
vn
+ +
4 ( ∆x )( ∆y )
i, j
2∆y 2 ∆x
1 Pi +1, j − 2 Pi , j + Pi −1, j
n n n
1 Pi +n1, j − Pi −n1, j ρin+1, j − ρin−1, j
− (12)
ρi , j ( ∆x )
2
(ρ )
n
2
2 ( ∆x ) 2 ( ∆x )
i, j

In eq.(12) all terms on RHS are known.


∂2 ρ
Continuing with the evaluation of eq.(10), a number for is found by
∂x∂t
differentiating eq.(1) wrt x & replacing all derivatives on RHS with second-order
central differences, similar to eq.(12).

∂ 2v
differentiate eq.(3) wrt y
∂y∂t
∂2 ρ
differentiate eq.(1) wrt y
∂y∂t
∂u ∂v
, central difference; eqs.(2) & (3) , respectively.
∂t ∂t
Finally;
n
⎛ ∂2 ρ ⎞
⎜ 2 ⎟ is calculated from eq.(10)
⎝ ∂t ⎠i , j
From eq.(5) ρin, +j 1 is known

For the remaining flow-field variables, uin, +j 1 , vin, +j 1 , ein, +j 1 repeat the above procedure

(
uin, +j 1 = f uin, j , uin, j +1 , uin, j −1 , uin+1, j , uin−1, j )

Remarks on Lax-Wendroff
•second-order accuracy in both space & time
•Algebra is lengthy
t
i,j

n+1 i,j-1

y i,j+1

i-1,j i,j
i+1,j
i,j-1
x
n
MACCORMACK’S 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
⎛ ∂ρ ⎞
ρin, +j 1 = ρin, j + ⎜ ⎟ ∆t (13)
⎝ ∂t ⎠av
⎛ ∂ρ ⎞ ∂ρ
Where ⎜ ⎟ representative mean value of between times t & t+∆t, i.e.
⎝ ∂t ⎠ av ∂t
time levels n and (n+1)

⎛ ∂ρ ⎞ is to be calculated so as to preserve second-order accuracy without the


⎜ ⎟
⎝ ∂t ⎠ av n
⎛ ∂2ρ ⎞
need to calculate values of the second time derivative ⎜ 2 ⎟
⎝ ∂t ⎠i , j
Similar relations for the other flow-field variables,

⎛ ∂u ⎞
uin, +j 1 = uin, j + ⎜ ⎟ ∆t (14)
⎝ ∂t ⎠ av
⎛ ∂v ⎞
vin, +j 1 = vin, j + ⎜ ⎟ ∆t (15)
⎝ ∂t ⎠ av
n +1 ⎛ ∂e ⎞
ei, j = e + ⎜ ⎟ ∆t
n
i, j (16)
⎝ ∂t ⎠av
Use the predictor-corrector philosophy as follows
Predictor step: in the continuity eq.(1), replace the spatial derivatives of the RHS
with FORWARD differences

⎛ ∂ρ ⎞
n
⎛ n uin+1, j − uin, j ρin+1, j − ρin, j vin, j +1 − vin, j ρin, j +1 − ρin, j ⎞
⎟ = − ⎜⎜ ρi , j + ui , j + ρi , j + vi , j
n n n
⎜ ⎟⎟ (17)
⎝ ∂t ⎠i , j ⎝ ∆x ∆x ∆y ∆y ⎠

Obtain a predicted value of density, ρ n +1 from the first two terms of a Taylor series;

⎛ ∂ρ ⎞
ρ n +1
i, j = ρ + ⎜ ⎟ ∆t
n
i, j (18)
predicted value of density
⎝ ∂t ⎠i , j
(only first-order accurate)
A similar fashion, predicted values of u,v&e can be obtained.

n +1 ⎛ ∂u ⎞
u i, j = u + ⎜ ⎟ ∆t
n
i, j (19)
⎝ ∂t ⎠i , j
n +1 ⎛ ∂v ⎞ Forward differences for the spatial
v i, j = v + ⎜ ⎟ ∆t
n
i, j (20)
⎝ ∂t ⎠i , j derivatives

⎛ ∂e ⎞
ei n, j+1 = ein, j + ⎜ ⎟ ∆t (21)
⎝ ∂t ⎠i , j

Corrector step:
n +1
⎛ ∂ρ ⎞
First obtain a predicted value of the time derivative at time t+∆t , ⎜ ⎟
⎝ ∂t ⎠i , j
by substituting the predicted values of ρ, u and v into the RHS of continuity eq.,
replacing the spatial derivatives with BACKWARD differences.

⎛ ∂ρ ⎞
n +1
⎛ n +1 uin, +j 1 − uin−+1,1j ρin, +j 1 − ρin−+1,1j v n +1 − vin, j+−11 ρin, +j 1 − ρin, +j −11 ⎞
⎟ = − ⎜⎜ ρi , j + ρi , j
n +1 n +1 i , j n +1
⎜ + ui , j + vi , j ⎟⎟ (22)
⎝ ∂t ⎠i , j ⎝ ∆ x ∆ x ∆ y ∆ y ⎠
In eq.(13)
⎡ ⎤
1 ⎢⎛ ∂ρ ⎞ ∂ρ ⎞ ⎥
n n +1
⎛ ∂ρ ⎞ ⎛
⎜ ⎟ = ⎢⎜ ⎟ +⎜ ⎟ ⎥
⎝ ∂t ⎠av 2 ⎢⎝ ∂t ⎠i , j ⎝ ∂t ⎠i , j ⎥
⎢⎣ from eq.(17) from eq.(22) ⎥⎦
⎛ ∂ρ ⎞
ρin, +j 1 = ρin, j + ⎜ ⎟ ∆t (13) repeated
⎝ ∂t ⎠ av
Same accuracy as the Lax-Wendroff method
n
⎛ ∂2 ρ ⎞
• Simpler (no need to evaluate second derivative ⎜ 2 ⎟
⎝ ∂t ⎠i , j
• 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
• 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. ∇.V = 0
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 MacCormack’s technique, explicit
time step ∆t is restricted by stability condition.
For compressible flow, speed of sound a is
finite.
1
∆t ≤ Above eq. gives a finite value of ∆t for numerical
u v 1 1 solution
+ +a +
∆x ∆y ( ) ( ) For an incompressible flow, a is theoretically
2 2
∆ x ∆ y
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.
∂u ∂ 2 ∂P ∂ 1 2
+
∂t ∂x
u +( ) + ( uv ) =
∂x ∂y Re
∇u (1)

∂v ∂ ∂ 2 ∂P 1 2
+ ( uv ) +
∂t ∂x ∂y
v +( ) =
∂y Re
∇v (2)
Differentiate eq.(1) wrt x & differentiate eq.(2) wrt y and add two resulting eqs.
After arrangment
∂2 P ∂2 P ∂D ∂ 2 2 ∂2 ∂2 2 1 ⎡ ∂2 ∂2 ⎤
+
∂x 2 ∂y 2
= − −
∂t ∂x 2
( ) ∂x∂y ( ) ∂y 2 ( ) Re ⎢ ∂x2 ( ) ∂y 2 ( )⎥
u − 2 uv − v + D + D (3)
⎣ ⎦
∂ ∂
D= +
∂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,

∂P 1 ⎛ ∂u ∂v ⎞
+ ⎜ + ⎟=0 (4)
∂t τ ⎝ ∂x ∂y ⎠
τ : artificial compressibility of fluid
compressibility ∼ pseudo-speed of sound, a
1 P
τ = 2 → a2 =
a ρ
Steady, incompressible N-S eqs. (2-D cartesian coord.)

∂P 2 ⎛ ∂u ∂v ⎞
+a ⎜ + ⎟=0 (5)
∂t ⎝ ∂x ∂y ⎠
∂u ∂ 2 ∂ 1
+ ( u + P ) + ( uv ) = ( ∇ 2u ) (6)
∂t ∂x ∂y Re
∂v ∂ ∂ 1
+ ( uv ) + ( v 2 + P ) = ( ∇ 2v ) (7)
∂t ∂x ∂y Re
Solution on Regular Grid
To facilitate application of finite dif. formulations, eqs (5)-(7) are written in a flux
vector form as

∂Q ∂E ∂F 1
+ + = [ N ] ∇ 2Q (8)
∂t ∂x ∂y Re
⎡P⎤ ⎡ a 2u ⎤ ⎡ a 2v ⎤ ⎡0 0 0⎤
⎢ 2 ⎥ ⎢ ⎥
Q= ⎢ u ⎥ , E= ⎢u + P ⎥ , F= ⎢ uv ⎥ , N= ⎢⎢ 0 1 0⎥⎥
⎢ ⎥
⎢⎣ v ⎥⎦ ⎢ uv ⎥ ⎢v 2 + P ⎥ ⎢⎣0 0 1 ⎥⎦
⎣ ⎦ ⎣ ⎦
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
P k +1
= ⎡ Pi +k1, j + Pi −k1,+1j + γ ( Pi ,kj +1 + Pi ,kj+−11 ) ⎤ + ( RHS )i , j
2 (1 + γ ) ⎣ ⎦
i, j

( RHS )i , j : central difference formula discretized eq. of RHS of (3)


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 )
Relations between physical and computational planes
η = η ( x, y )
x η

i,j
i,j

ξ
y Computational plane
Physical plane
Main issue: how to find the location of the grid points in the physical domain

(x,y): physical coordinates


(ξ,η): computational coordinates

∂ ∂ξ ∂ ∂η ∂
= + (1)
∂x ∂x ∂ξ ∂x ∂η
∂ ∂ξ ∂ ∂η ∂
= +
∂y ∂y ∂ξ ∂y ∂η
∂ξ ∂ξ ∂η ∂η
, , , called metrics of transformation
∂x ∂y ∂x ∂y
Example:
∂u ∂u
+c + y =0 (A) original PDE
∂x ∂y
ξ = ξ ( x, y )
η = η ( x, y )
∂u ∂u ∂u ∂u ∂u ∂u
= ξx + η x ; = ξy + ηy
∂x ∂ξ ∂η ∂y ∂ξ ∂η
∂u ∂u
( ξx + cξ y ) ∂ξ + (η x + cη y ) ∂η + y ( ξ ,η ) = 0 (B) transformed PDE
• 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.
∂ξ ∆ ξ i.e. metrics represent the ratio of are lengths in the
2. ξx = ≅
∂x ∆x computational plane to that of the physical plane.
Computation of metrics

d ξ = ξ x dx + ξ y dy (2)
dη = η x dx + η y dy
or in a compact form,

⎛ d ξ ⎞ ⎛ ξ x ξ y ⎞ ⎛ dx ⎞
⎜ ⎟ = ⎜η η ⎟ ⎜ ⎟ (3)
⎝ dη ⎠ ⎝ x y ⎠ ⎝ dy ⎠

To transform back to physical plane,


or reversing the role of independent variables, i.e.
x = x (ξ ,η )
y = y (ξ , η )
dx = xξ d ξ + xη dη ; dy = yξ d ξ + yη dη

⎛ dx ⎞ ⎛ xξ xη ⎞⎛ d ξ ⎞
⎜ ⎟=⎜y ⎟⎜ ⎟ (4)
yη ⎠⎝ dη ⎠
⎝ dy ⎠ ⎝ ξ

Compare 4 with 3
−1
⎛ ξ x ξ y ⎞ ⎛ xξ xη ⎞
⎜ ⎟=⎜ ⎟
⎝ η x η y ⎠ ⎝ yξ yη ⎠
1 1
ξ x = yη , ξ y = − xη
J J
1 1
η x = − yξ , η y = xξ (6)
J J
J=xξ yη − yξ xη = Jacobian of transformation
J: ratio of areas (volumes in 3-D) of computational space to that of physical space.
In determining the grid points (mapping) following requirements are necessary.

Notes:
1. Mapping must be one-to-one. J≠0
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.
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
Known functions are used in one, two
ξ = x , η = y / f ( x) (7) or three dimensions to take arbitrary
represents
upper boundary
shaped physical regions into a
rectangular computational domain
⎧ H − H1 ⎫
x=ξ , y = ⎨ H1 + 2 ξ ⎬η (8)
⎩ 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.
Example:
Generation of Grid: Algebraic Grid
y 1. define a uniform grid in ξ,η plane

(L,H2)
1+x
(0,H1)

H1 H2

x
(0,0) L (L,0)
η
1.0
j=M+1

∆η

i=1 ∆ξ i=M+1
L
Analytical calculation of metrics
ξx = 1 , ξy = 0
⎛ H − H1 ⎞
yf ′( x)
−⎜ 2 ⎟η
⎝ L ⎠
ηx = − 2 = 2
f ( x) ⎧ ⎛ 1
H − H 2 ⎞ ⎫
⎨ H1 + ⎜ ⎟ξ ⎬
⎩ ⎝ L ⎠ ⎭
1 1
ηy = =
f ( x) ⎧ ⎛ H 2 − H1 ⎞ ⎫
H +
⎨ 1 ⎜ ⎟ξ ⎬
⎩ ⎝ L ⎠ ⎭
To numerically find metrics
⎧ xi +1, j − xi −1, j
x
⎪ ξ i, j =
⎪ 2∆ ξ
for interval points ⎨
⎪x xi , j +1 − xi , j −1
= , etc. yξ , yη
⎪⎩ η i , j 2∆η
evaluate J = xξ yη − yξ xη
evaluate ξ x , ξ y ,η x ,η y from (6)
derivatives at boundaries are evaluated with forward or backward 2nd order approximation
−3 xi ,1 + 4 xi ,2 − xi ,3
j = 1; xη =
i ,1 2∆η
Clustering Techniques
To cluster near bottom (Consider duct problem)
ξ=x Metrics
ξx = 1 , η x = 0
⎧ β +1− y / H ⎫
log ⎨ ⎬ 2β
⎩ β − 1 + y / H ⎭ ξy = 0 , η y =
η = 1− 1<β < ∞ ⎧⎪ 2 ⎧ ⎛ β + 1 ⎞ ⎫⎫⎪
H ⎨ β 2 − (1 − y / H ) ⎨log ⎜
⎛ β +1 ⎞ β − 1 ⎟ ⎬⎬
log ⎜ ⎪⎩ ⎩ ⎝ ⎠ ⎭⎭⎪
β − 1 ⎟
⎝ ⎠ Clustering on both walls
β : clustering parameter ξ=x
as β → 1 more grid points near y=0 ⎧ y ⎫
⎪ β + ( 2α + 1) − 2α ⎪
log ⎨ H
Inverse y ⎬
⎪ β − ( 2α + 1) + 2α ⎪
x=ξ η = α + (1 − α ) ⎩ H ⎭
⎛ β +1 ⎞
1−η log ⎜ ⎟
⎧ ⎧ β + 1⎫ ⎫ ⎝ β −1 ⎠
⎪ ( β + 1) − ( β − 1) ⎨ ⎬ ⎪ α = 0 clustering at y=H

y=H⎨ ⎩ β −1⎭ ⎪
1−η ⎬ α = 1/ 2 clustering equally at y=0 , H
⎪ ⎛ β +1 ⎞ ⎪
⎪ ⎜ β −1 ⎟ + 1 ⎪
⎩ ⎝ ⎠ ⎭
Clustering on both walls
ξ=x
⎧ y ⎫
⎪ β + ( 2α + 1) − 2α ⎪
log ⎨ H
y ⎬
⎪ β − ( 2α + 1) + 2α ⎪
η = α + (1 − α ) ⎩ H ⎭
⎛ β +1 ⎞
log ⎜ ⎟
⎝ β − 1 ⎠
α = 0 clustering at y=H
α = 1/ 2 clustering equally at y=0 , H
Clustering in Interior

ξ=x
1 ⎧⎛ y ⎞ ⎫
η = A + sinh ⎨⎜ − 1⎟ sinh ( β A ) ⎬
−1

β ⎩⎝ D ⎠ ⎭

A=
1 ⎧

log ⎨
1 + (
e β
)
− 1 ( D / H ) ⎫⎪

2β ( −β
)
⎪⎩1 + e − 1 ( D / H ) ⎪⎭
D is where clustering desired
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.

y=x2 y=x2 1≤x≤2

1
y

x x=1 x=2

Nozzle geometry
Equally spaced increments in x direction ξ=x
y y
Uniform division in the y direction η = =
y max x2
Ymax : nozzle boundary equation.

2.2968
3.06 1
3.0
1.68
y 1.53 0.25
1 1.25 1.75 2

x x=1 x=2 x=ξ


y=ηξ2
physical coordinates
∆ξ=0.25 , ∆η=0.25
Metrics of transformation ξx = 1 , ξy = 0
y 1 1 2η
η x = −2 3 , ηy = 2 = 2 = −
x x ξ ξ
If numerical methods are used to generate required transformation use second-
order finite difference
yη xη yξ xξ
ξx = , ξy = − , ηx = − , ηy = −
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
x
x3 1.75 yξ ya +1 − ya -1
η x = −2 , J = xξ yη - yξ xη = yη =
J 2∆η
1

3.0625 − 1.53125
Numerical calculation yη = = 3.06250
2 ( 0.25 )
3 − 1.6875
yξ = = 2.625 → η x = −0.85714
2 ( 0.25 )
not always the same for many problems
NORMALIZING TRANSFORMATION

y η

ξ=constant
+1 1,1
0,1 1,1
η=constant ξ

-1
2,0 -1 1
0,0 x
⎛ 1 + ξ ⎞⎛ 3 − η ⎞
x=⎜ ⎟⎜ ⎟ (ξ ,η ) = (1,1) ⇒ ( x, y ) = (1,1)
⎝ 2 ⎠⎝ 2 ⎠
η +1
y= (ξ ,η ) = ( −1,1) ⇒ ( x, y ) = ( 0,1)
2
Any quadrilateral physical domain can be transformed into a rectangle in
computational space by use of a normalizing transformation.
y
x=ξ
y=(1+ ξ) η x

2
1+x
1

0 1 x ξ
2,4
2+x
0,2
4(x-1)

1,0 x

x=aξ +bη +cηξ x=ξ (1+η )


y=dξ +eη +fηξ y=2η (1+ξ )
Trapezoid defined by boundaries

y
x=0
2
x=1
1+x y=0
1 y=1+x
Take two disconnected boundaries (upper &
lower boundary)

0 1 x
x1 (ξ ) = x (ξ , 0 ) = ξ ⎫

y1 (ξ ) = y (ξ , 0 ) = 0 ⎪ x = ξ (1 − η ) + ξη = ξ
⎬⇒
x2 (ξ ) = x (ξ ,1) = ξ ⎪ y = 0 + (1 + ξ )η
y2 (ξ ) = y (ξ ,1) = 1 + ξ ⎪⎭
A different point distribution can be obtained by choosing a non linear function for
boundary parametrization.
Example:

x1 = ξ 2 ⎫⎪ x =ξ 2

2⎬

(
x2 = ξ ⎪⎭ y = 1 + ξ η
2
)
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

T1
Looks like a good grid
flux lines
Let ξ, η satisfy Laplace’s equation.
-k dT/dx=h(T-Tinf)
dT/dx=0 ξ xx + ξ yy = 0
η xx + η yy = 0 (9)
T0 Iterative scheme is used to solve
Constant T lines Isothermal lines, grid lines

(ξ,η) coordinates in computational space


(x,y) coordinates in phsical space
To transform equations (9) dependent and independent variables are interchanged
see Appendix E

axξξ − 2bxξη + cxηη = 0 (10)


ayξξ − 2byξη + cyηη = 0 (11)
a = xη2 + yη2
b = xξ xη + yξ yη
c = xξ2 + yξ2 (12)
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

y
η

M
i=N
ξ

η x j=1 ξ
j=M j=1 i=1 N
Example:
2 2
⎧ xi , j +1 − xi , j −1 ⎫ ⎧ yi , j +1 − yi , j −1 ⎫
a=⎨ ⎬ +⎨ ⎬
⎩ 2 ∆ η ⎭ ⎩ 2 ∆η ⎭
discretization of (10)

⎪⎧ xi +1, j − 2 xi , j + xi −1, j ⎪⎫ ⎧ xi +1, j +1 − xi +1, j −1 − xi −1, j −1 + xi −1, j +1 ⎫ ⎧⎪ xi , j +1 − 2 xi , j + xi , j −1 ⎫⎪


a⎨ ⎬ − 2b ⎨ ⎬+c⎨ ⎬ = 0 (13)
( ∆ξ ) 4∆η∆ξ ( ∆η )
2 2
⎪⎩ ⎪⎭ ⎩ ⎭ ⎪⎩ ⎪⎭
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

⎡ a c ⎤ a c
2⎢ + ⎥ x = ⎡ x
2 ⎣ i +1, j
+ x ⎤
i −1, j ⎦ + ⎡ x + xi , j −1 ⎤⎦
2 ⎣ i , j +1
⎢⎣ ( ∆ξ ) ( ∆η ) ⎥⎦ ( ∆ξ ) ( ∆η )
2 2 i, j

b
− ⎡⎣ xi +1, j +1 − xi +1, j −1 − xi −1, j −1 + xi −1, j +1 ⎤⎦
2∆ξ∆η
⎡ a c ⎤ a c
2⎢ + ⎥ x = ⎡ x
2 ⎣ i +1, j
+ x ⎤
i −1, j ⎦ + ⎡ x + xi , j −1 ⎤⎦
2 ⎣ i , j +1
⎢⎣ ( ∆ξ ) ( ∆η ) ⎥⎦ ( ∆ξ ) ( ∆η )
2 2 i, j

b
− ⎡⎣ xi +1, j +1 − xi +1, j −1 − xi −1, j −1 + xi −1, j +1 ⎤⎦
2∆ξ∆η

For yi,j
⎡ a c ⎤ a c
2⎢ + ⎥ yi , j = ⎡ y
2 ⎣ i +1, j

+ yi −1, j ⎦ + ⎡y
2 ⎣ i , j +1
+ yi , j −1 ⎤⎦
⎢⎣ ( ∆ξ ) ( ∆η ) ⎥⎦ ( ∆ξ ) ( ∆η )
2 2

b
− ⎡⎣ yi +1, j +1 − yi +1, j −1 − yi −1, j −1 + yi −1, j +1 ⎤⎦
2∆ξ∆η
İterate until convergence,
Example:
N ,M
Ex = ∑
i=2
xik, +j 1 − xik, j , E y = ...
j =2

ET = Ex + E y < ε
Double-Connected Domain:
Domain is not reducible. i.e. domain includes one configuration within region of interest

B2
B1
B3
A
C

B4

Can be rendered simply-connected by introducing a suitable branch cut


Unwrap the domain

η
C
B3 C B2 C
B2
B3
B1
A B4

A A B1 A

B4
C
ξ
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 B3&B4 , i.e. on the branch cut.
Location of grids along line AC must be updated. Compute new values of x1,j and y1,j
after each iteration.
Note: It is not necessary to compute xN,j and yN,j since grid lines i=1 & i=N are
coincident.
xN,j = x1,j and yN,j = y1,j

Gauss-Seidel Formulation

⎧⎪ a c b ⎫⎪
⎨ ⎡ x + xN −1, j ⎦⎤ +
2 ⎣ 2, j
⎡x
2 ⎣ 1, j +1
+ x1, j −1 ⎦⎤ − ⎣⎡ x2, j +1 − x2, j −1 − xN −1, j −1 + xN −1, j +1 ⎦⎤ ⎬
⎪( )
∆ξ ( )
∆η 2 ∆ξ ∆ η ⎪⎭
x1, j = ⎩ (14)
⎡ a c ⎤
2⎢ + 2⎥
⎢⎣ ( ∆ξ ) ( ∆η ) ⎥⎦
2

similarly,

y1, j =
{ } .. (15)
..
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,
Circle
t 2π
y=
0.2
(
0.2969 x1/ 2 − 0.126 x − 0.3516 x 2 + ... + x 4 ) ∆δ =
N-1
max thickness of chord δ ( i ) = i * ∆δ

∆x=
c
N:odd, symmetry of grid points x ( i, M ) = R *cos (δ ( i ) )
( N+1) − 1
y ( i, M ) = − R *sin (δ ( i ) )
2

Doubly-connected region

i=N
x
i=1

R
GRID CONTROL:
1. clustering in different regions

ξ xx + ξ yy = P(ξ ,η ) Can show


η xx + η yy = Q(ξ ,η ) 1
2 {
axξξ − 2bxξη + cxηη = − Pxξ + Qxη }
P, Q: sources of sinks J
1
ayξξ − 2byξη + cyηη = − 2 {Py ξ + Qyη }
J
P,Q complicated functions
Thonson, JF., Warsi, Z.U.A, & Mastin, C.W.
Numerical Grid Generation
North Holland, 1985

SOFTWARE 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

You might also like