Professional Documents
Culture Documents
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
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
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 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
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
- 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.
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
a − a*
Relative convergence: <ε
a
FINITE DIFFERENCE METHODS
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
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.
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
∂ρ ∂ ( ρu ) ∂ ( ρv) ∂ ( ρw)
+ + + =0
∂t ∂x ∂y ∂z
∂ρ ∂ρ ∂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
ρ ∞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 )
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.
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
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
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
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 ' = 1
……….
y2 ' = y3 yn ' = yn +1
……….
y3 ' = y4 y'n+1 = f (y1, y2, y3,.....yn+1)
.
.
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
⎡ 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
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
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
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)
Round off
error
Truncation
error
Number of
Optimum
steps
*
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
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.
F1 = hf ( x, y ) w1 = w2 = 1 ⇒ MODIFIED EULER
α =1 β =1 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:
ρ 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
C D ≈ 0.18 , Re>2x106
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:
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.
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
⎛ 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.
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
⎛ 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
Advantages
1. Lead to the tri-diagonal matrices
2. Often lead to diagonally dominant matrices
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
γ 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
δ 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
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)
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
− 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
dθ
−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)
⎛ θ −θ ⎞
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
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)
• 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
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
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
⎣ ⎦
ξ d ξ 2 dU
α= (U ξ ) , β =
ν dx ν dx
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
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⎦
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
y ( k ) − y ( k −1)
i.e
(k )
<ε
y
• Take η = 5-6
• Plot f , f ′ versus η
• Take β=0,1,&5
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
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
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
∂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.
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)
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
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
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.
u L ∂ 2u ∂ 2
u
= a 2
-∞ <x<∞
∂t 2 ∂x 2
x
u(0,t)=0 u(L,t)=0
∂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τ
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
x = at
x = -ct
∂ 2φ 2 ∂ φ
2
=c water-hammer problems wave equation.
∂t 2
∂x 2
Parabolic PDEs
Only one characteristic direction at a point
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
b.l. edge
Viscous flow
U
Unsteady heat conduction: the best known example
T
∂T ⎛ ∂ 2T ∂ 2T ⎞
T2 =α ⎜ 2 + 2 ⎟ α :const.
∂t ⎝ ∂x ∂y ⎠
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
y ∂ 2
u ∂ 2
u
e.g. + 2 =0
∂x ∂y
2
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:
∇ 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 ⎠
∂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
⎛ ∂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.
⎛ ∂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
Dω
= ν∇ 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. ...
∂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
⎛ ∂ 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
⎛ ∂ 4u ⎞ ( ∆x )
4
⎛ ∂ 2u ⎞
+ ⎜ 2 ⎟ ( ∆x ) + ⎜ 4 ⎟
2
ui +1, j + ui −1, j =2ui , j + ...
⎝ ∂x ⎠i , j ⎝ ∂x ⎠i , j 12
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 ⎣ ⎦
⎛ ∂u ⎞ 2∆x ⎛ ∂ u ⎞ ( 2∆x )
2 2
ui + 2, j =ui , j +⎜ ⎟ +⎜ 2 ⎟ +...
∂x
⎝ ⎠i , j 1! ⎝ ∂x ⎠i , j 2!
∆x
∆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
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 )
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.
(
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 ) ⎤⎦
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
∆t
ui,j-1
ui,j+1 xi
tj-1 tj tj+1
xi-1
Notes: ∆t
R =α
1. Method is unconditionally stable, i.e. for any value of ( ∆x )
2
( ∆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
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
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
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,
∆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
n n+1 ∂u ui , j − ui*, j
= + O (∆t ) 2
∂t ∆t
∆t
central difference eq. of step ∆t/2
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 ⎠
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
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
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
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
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
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
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
⎧ ⎫
∂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
∂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 +
2
( )
ui , j + ui*, j + w**
1
estimate p** =
2
(
p + p* )
• Iterate
ELLIPTIC PROBLEMS
• Steady state heat conduction equation
• Velocity potential eq. & stream function eq. for incomp., inviscid, irrotational flow
∂ 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
T1 ≠ T0
T2
T0 < T1 < T2 < T3
T3 T1
Then, there is no T in interior with
T4 T < T0 ; T > T3
i,j+1
y
∆y
(1,M+1) (N+1,M+1) ∆x
(1,2)
2 are known
1 of u is known
Solution Algorithms:
a) Direct methods
b) Iterative methods
ui(,kj)
1− ( k +1)
<∈ for all i,j
u i, j
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 ⎠⎭
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
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 ⎤
⎦
∂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 ⎫ *
−k ⎨ ⎬ = h {u N +1, j − u∞ }
*
(5)
⎩ 2h ⎭
Use eq.(5) to eliminate u N + 2, j in eq.(4).
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
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
e.g. ∂ 2u 1
=
∂x 2 ij 3h 2
{ − 3uij + 12ui +1, j − 15ui + 2, j + 3ui + 3, j } + ( )
O h 3
∂u
∇ u +u
2
=0
∂x
Improved method for derivative conditions
Higher order approximation for derivative
But must retain diagonal dominance
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)
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
(i+1,j)
i,j
(i+1,j-1)
i
Define operators
∂ ∂
ξ= , η=
∂x ∂y
⎛ ∂ 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)
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)
(
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
∇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
(N+1,M+1)
j-1
i-1 i i+1
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
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 ⎤⎦
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-1,j h
i+1,j
i,j b
k
y
x
i,j-1 1,1
N+1,1
a
TYPICAL CODE
ui , j =
1
2(1 + γ )
{ }
− h 2 fi , j + ui +1, j + ui −1, j + γ ( ui , j +1 + ui , j −1 ) (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∞ )
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
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)
⎧ 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)
∂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)
∇.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 ω
∂ω z ∂ω z
u +v =0
∂x ∂y
∂v ∂u ∂ 2ψ ∂ 2ψ
ωz = − = − 2 − 2
∂x ∂y ∂x ∂y
∇ 2ψ = −ω z
0
2 D
ψB
U m D = ψ upper wall −ψ lower wall
Q=ψA – ψB
∂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
ψ=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 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 ω −ψ
∂Ω ∂Ω ∂Ω 1 ⎛ ∂ 2 Ω ∂ 2 Ω ⎞
+u +v = ⎜ 2 + 2 ⎟ (1)
∂t ∂x ∂y Re ⎝ ∂x ∂y ⎠
∂ 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
⎨ + ⎬ (5a)
( ∆x ) ( ∆y )
2 2
Re ⎪ ⎪
⎪ ⎪
⎩ ⎭
n +1 / 2 n +1/ 2
δ xx Ωij δ yy Ωij
n n
In eq.(5b) can use ui , j & vi , j instead of (n+1/2) time level
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
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ψ = −Ω
∂ψ ⎫
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
( ∆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
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
−ψ 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
∂ψ ∂ψ 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
ψ N +1, j = −ψ N −1, j + 2ψ N , j
outflow
∂Ω 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 → ∞
Ω → 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 ⎠⎦
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.
∂P ∂Ω 2
= −µ (P3)
∂x wall ∂y wall
∂v ∂u Wall y=0, 1 x
Ω wall = −
∂x wall
∂y wall
u=v=0
• 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
Explicit Formulations:
1. Euler’s FTCS method:
uin +1 − uin
∆t
= −a
uin+1 − uin−1
2∆x
(
O ∆t, ( ∆x )
2
) (2)
1 n
∂u
n +1
(
ui − ui +1 + uin−1
2
)
= (4)
∂t ∆t
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
( ∆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
⎡ ( ) ( ) ⎤
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
∂ 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
⎛ ∂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
∂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
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
∂ ∂ξ ∂ ∂η ∂
= + (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 ⎠
⎛ 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)
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.
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
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
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
• 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
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)
⎡ 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
η
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
2. orthogonally at surface
Steger, J.L & Sorenson, R.L.
PDE Techniques (summary)
PDE Methods
1. elliptic
2. parabolic
3. hyperbolic