Finite Difference Method
MEL 807
Computational Heat Transfer (2-0-4)
Dr. Prabal Talukdar
Assistant Professor
Department of Mechanical Engineering
IIT Delhi
Discretization Methods
• Required to convert the general transport
equation to set of algebraic equations
Finite difference method
Finite volume method
Introduction to Finite Difference
−
−
+
∆
∂
∂
+
−
−
−
+
∆
∂
∂
+
∆
∂
∂
+
=
∆
+
!
n
)
x
(
x
f
2
)
x
(
x
f
x
x
f
)
x
(
f
)
x
x
(
f
n n n 2 2 2 Taylor series expansionDiscretization
−
−
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
φ
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
+
φ
=
φ
+6
)
x
(
x
2
)
(
x
x
x
3 j , i 3 3 2 j , i 2 2 j , i j , i j , 1 i xRepresentation of a Derivative
)
x
(
x
x
j , i j , 1 i j , i∆
+
∆
φ
−
φ
=
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
+O
−
−
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
−
∆
φ
−
φ
=
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
+6
)
x
(
x
2
)
x
(
x
x
x
2 j , i 3 3 j , i 2 2 j , i j , 1 i j , i Finite difference representation−
−
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
+
φ
=
φ
+6
)
x
(
x
2
)
x
(
x
x
x
3 j , i 3 3 2 j , i 2 2 j , i j , i j , 1 i Forward differenceBackward Difference
−
−
−
∆
−
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
−
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
−
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
+
φ
=
φ
−6
)
x
(
x
2
)
x
(
x
)
x
(
x
3 j , i 3 3 2 j , i 2 2 j , i j , i j , 1 i−
−
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
−
φ
=
φ
−6
)
x
(
x
2
)
x
(
x
x
x
3 j , i 3 3 2 j , i 2 2 j , i j , i j , 1 i)
x
(
x
x
j , 1 i j , i j , i∆
+
∆
φ
−
φ
=
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
−O
Backward differenceCentral difference
−
−
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
+
φ
=
φ
+6
)
x
(
x
2
)
x
(
x
x
x
3 j , i 3 3 2 j , i 2 2 j , i j , i j , 1 i−
−
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
−
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
∆
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
−
φ
=
φ
−6
)
x
(
x
2
)
x
(
x
x
x
3 j , i 3 3 2 j , i 2 2 j , i j , i j , 1 i 2 j , 1 i j , 1 i j , i)
x
(
x
2
x
∆
+
∆
φ
−
φ
=
⎟
⎠
⎞
⎜
⎝
⎛
∂
φ
∂
+ −O
Subtracting, Central differenceForward, backward and central
difference stencil
) x ( O x x j , i j , 1 i j , i ∆ + ∆ φ − φ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ∂ φ ∂ + ) x ( x x j , 1 i j , i j , i ∆ + ∆ φ − φ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ∂ φ ∂ − O 2 j , 1 i j , 1 i j , i ) x ( x 2 x ∆ + ∆ φ − φ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ∂ φ ∂ + − OStencil in y direction
) y ( y y j , i 1 j , i j , i ∆ + ∆ φ − φ = ⎟⎟ ⎠ ⎞ ⎜⎜ ⎝ ⎛ ∂ φ ∂ + O)
y
(
y
y
1 j , i j , i j , i∆
+
∆
φ
−
φ
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
−O
2 j , 1 i j , 1 i j , i ) y ( y 2 y ∆ + ∆ φ − φ = ⎟⎟ ⎠ ⎞ ⎜⎜ ⎝ ⎛ ∂ φ ∂ + − O2
nd
Order and Mixed Derivative
) ) x ( ) x ( 2 x 2 2 j , 1 i j , i j , 1 i j , i 2 2 ∆ + ∆ φ + φ − φ = ⎟⎟ ⎠ ⎞ ⎜⎜ ⎝ ⎛ ∂ φ ∂ + − 0 ) ) y ( ) y ( 2 y 2 2 1 j , i j , i 1 j , i j , i 2 2 ∆ + ∆ φ + φ − φ = ⎟⎟ ⎠ ⎞ ⎜⎜ ⎝ ⎛ ∂ φ ∂ + − 0 ] ) y ( , ) x [( y x 4 y x 2 2 1 j , 1 i 1 j , 1 i 1 j , 1 i 1 j , 1 i j , i 2 ∆ ∆ + ∆ ∆ φ − φ − φ + φ = ⎟⎟ ⎠ ⎞ ⎜⎜ ⎝ ⎛ ∂ ∂ φ ∂ + + − − − + + − OBoundary Consideration
• What kind of differencing scheme is possible at the
boundaries?
• Central difference approximation
is not possible as point 2’ is
beneath the boundary
• How we can get a second order
accurate scheme?
• Possibility:
Polynomial approach
)
y
(
y
y
1 2 1∆
+
∆
φ
−
φ
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
O
Polynomial Approach
• Assume
• At grid point 1, φ
1= a
• At grid point 2 where y = ∆y,
• At grid point 3 where y = 2∆y,
2
cy
by
a
+
+
=
φ
2 2=
a
+
b
∆
y
+
c
(
∆
y
)
φ
2 2=
a
+
b
2
∆
y
+
c
(
2
∆
y
)
φ
Polynomial Approach (cont’d)
• Solving these equations,
• Differentiation of
gives
• At point 1 (boundary),
• What is the order of
approximation??
y
2
4
3
b
1 2 3∆
φ
−
φ
+
φ
−
=
b
y
cy
2
b
y
cy
by
a
1 2=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
+
=
∂
φ
∂
+
+
=
φ
y
2
4
3
y
3 2 1 1∆
φ
−
φ
+
φ
−
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
Order of Approximation
• Taylor series gives,
• Comparing with the polynomial expression ,
we can say that our polynomial is of O(∆y)
3•
φ
1, φ
2, φ
3can all be expressed in terms of the polynomial
• Represents one-sided difference of 2
ndorder accuracy
− − − + ⎟⎟ ⎠ ⎞ ⎜⎜ ⎝ ⎛ ∂ φ ∂ + ⎟⎟ ⎠ ⎞ ⎜⎜ ⎝ ⎛ ∂ φ ∂ + ⎟⎟ ⎠ ⎞ ⎜⎜ ⎝ ⎛ ∂ φ ∂ + φ = φ 6 y y 2 y y y y ) y ( 3 1 3 3 2 1 2 2 1 1 2 3 3 2 1 1
)
y
(
y
)
y
(
y
2
4
3
y
∆
=
∆
∆
=
∆
φ
−
φ
+
φ
−
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
φ
∂
O
O
2cy
by
a
+
+
=
φ
FDM for 1D diffusion
• Uses truncated Taylor series expansion to approximate the
derivative of the DE
• Consider 1-D diffusion equation
• Expand φ
in Taylor series about
point 2
0
S
dx
d
2 2=
+
φ
Γ
FDM (cont’d)
)
)
x
(
)
x
(
2
dx
d
2 2 2 3 1 2 2 2∆
+
∆
φ
−
φ
+
φ
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛ φ
0
2 2 3 1 2 2 2)
x
(
2
dx
d
∆
φ
−
φ
+
φ
Γ
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛ φ
Γ
Second order truncation errorDropping the truncated terms
Adding the equations
2 3 2 1 2 2 2
S
)
x
(
)
x
(
)
x
(
2
+
φ
∆
Γ
+
φ
∆
Γ
=
φ
∆
Γ
FDM (cont’d)
• We can write one such equation for each grid
point
• Boundary conditions gives us boundary value
• Second order accurate
• Need to find a way to solve the couple
algebraic equation set
2 3 2 1 2 2 2
S
)
x
(
)
x
(
)
x
(
2
+
φ
∆
Γ
+
φ
∆
Γ
=
φ
∆
Γ
1D Steady State Conduction
• Consider the steady state heat conduction in a slab of thickness L,
in which energy is generated at a constant rate of S W/m
3. The
boundary surface at x = 0 is maintained at a constant temperature
T
o,while the boundary surface at x = 0 dissipates heat by
convection with a heat transfer coefficient h into an ambient at
temperature T
∞.
Compute the temperature inside the slab for h = 200
W/(m
2.°C), k = 18 W/(m.°C), L = 0.01 m, T
∞= 100°C, T
o= 50°C, and
S = 7.2 x 10
7.
To = 50 ° C 0.01 m T∞ = 100 ° C x ∆x 0 1 2 3 4 5Solution
0.01m
L
at x
hT
hT
dx
)
x
(
dT
k
0
at x
T
)
x
(
T
0
S
dx
T
d
k
o 2 2=
=
=
+
=
=
=
+
∞ B.C.16
S
k
)
5
/
L
(
S
k
)
x
(
T
T
2
T
S
T
)
x
(
k
T
)
x
(
k
2
T
)
x
(
k
S
T
)
x
(
k
T
)
x
(
k
T
)
x
(
k
2
i 2 i 2 1 i i 1 i i 1 i 2 i 2 1 i 2 i 1 i 2 1 i 2 i 2−
=
−
=
∆
−
=
+
−
⇒
−
=
∆
+
∆
−
∆
⇒
+
∆
+
∆
=
∆
+ − + − + −Treatment of Boundary Condition
16
T
T
2
T
i−1−
i+
i+1=
−
To = 50 ° C 0.01 m x ∆x 0 1 2 3 4 N=5Applicable to node 1-4
∆x/20
44
.
4
16
T
044
.
2
T
2
0
T
k
xh
2
k
S
)
x
(
T
k
xh
2
2
T
2
0
2
x
S
)
T
T
(
h
x
T
T
k
5 4 N 2 N 1 N N 1 N N=
+
+
−
⇒
=
∆
+
∆
+
⎟
⎠
⎞
⎜
⎝
⎛
+
∆
−
⇒
=
∆
+
−
−
∆
−
−
∞ − ∞ − T∞ cond convApplying it to
node 5
Treatment of Boundary Condition
(Another Way)
16
T
T
2
T
4−
5+
6=
−
4 5 6 5 4 6T
)
T
T
(
k
xh
2
T
0
)
T
T
(
h
x
2
T
T
k
+
−
∆
−
=
⇒
=
−
−
∆
−
−
∞ ∞16
T
T
2
T
i−1−
i+
i+1=
−
To = 50 ° C 0.01 m x ∆x 0 1 2 3 4 N=5Apply to node 5
T∞ B.C. gives 44 . 4 16 T 044 . 2 T 2 T k x h 2 16 T k x h 2 2 T 2 5 4 5 4 + − = − ⇒ ∆ + − = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ + ∆ − ∞Algebraic Equations
16
T
T
2
T
0−
1+
2=
−
16
T
T
2
T
1−
2+
3=
−
16
T
T
2
T
2−
3+
4=
−
16
T
T
2
T
3−
4+
5=
−
44
.
4
16
T
044
.
2
T
2
4−
5=
−
−
50
16
T
T
2
1+
2=
−
−
−
• Can be solved by Thomas’ algorithm
• Matrix inversion as shown in next slide
Matrix Form
⎥
⎥
⎥
⎥
⎥
⎥
⎦
⎤
⎢
⎢
⎢
⎢
⎢
⎢
⎣
⎡
−
−
−
−
−
=
⎥
⎥
⎥
⎥
⎥
⎥
⎦
⎤
⎢
⎢
⎢
⎢
⎢
⎢
⎣
⎡
⎥
⎥
⎥
⎥
⎥
⎥
⎦
⎤
⎢
⎢
⎢
⎢
⎢
⎢
⎣
⎡
−
−
−
−
−
44
.
20
16
16
16
66
T
T
T
T
T
044
.
2
2
0
0
0
1
2
1
0
0
0
1
2
1
0
0
0
1
2
1
0
0
0
1
2
5 4 3 2 1[ ][ ] [ ]
[ ] [ ] [ ]
x
A
B
B
x
A
1 −=
⇒
=
Prescribed Heat Flux
X=0 ∆x 0 1 2 3 N-1 N ∆x/2 X=L qo q NEnergy balance gives,
0
xS
2
1
x
T
T
k
q
0
xS
2
1
x
T
T
k
q
N N 1 N N 0 0 1 0=
∆
+
∆
−
+
=
∆
+
∆
−
+
−FDM representation
N
i
0
k
xq
2
k
S
)
x
(
T
2
T
2
0
i
0
k
xq
2
k
S
)
x
(
T
2
T
2
N N 2 N 1 N 0 0 2 0 1=
=
∆
+
∆
+
−
=
=
∆
+
∆
+
−
−for
for
N
i
0
k
S
)
x
(
T
2
T
2
0
i
0
k
S
)
x
(
T
2
T
2
N 2 N 1 N 0 2 0 1=
=
∆
+
−
=
=
∆
+
−
−for
for
For insulated or symmetry boundary,
Flux boundary,
Unsteady Heat Conduction with
FDM
• Unsteady heat conduction in
1-D with constant thermal
conductivity
• Expand the individual
terms with Taylor series,
2 2
x
T
t
T
∂
∂
α
=
∂
∂
−
−
−
−
+
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
∂
−
∆
−
=
⎟
⎠
⎞
⎜
⎝
⎛
∂
∂
+2
t
t
T
t
T
T
t
T
n i 2 2 n i 1 n i n i−
−
−
−
+
∆
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
∂
−
∆
+
−
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
∂
+ −12
)
x
(
x
T
)
x
(
T
T
2
T
x
T
n 2 i 4 4 2 n 1 i n i n 1 i n i 2 2Unsteady Heat Conduction (cont’d)
2 n 1 i n i n 1 i n i 1 n i)
x
(
)
T
T
2
T
(
t
T
T
∆
+
−
α
=
∆
−
+ − +Explicit Solutions
)
T
T
2
T
(
)
x
(
t
T
T
)
x
(
)
T
T
2
T
(
t
T
T
n 1 i n i n 1 i 2 n i 1 n i 2 n 1 i n i n 1 i n i 1 n i − + + − + ++
−
∆
∆
α
+
=
⇒
∆
+
−
α
=
∆
−
cm 10 5 50 x = = ∆α
=
17
x
10
−2cm
2/
s
Tw = 30C Tw = 100C 50 cmFind 1-D unsteady temperature distribution till steady state
Initial temp Tin = 30C, ∆t = 10 sec
2
1
)
x
(
t
2≤
∆
∆
α
Results
0 20 40 60 80 100 120 0 1 2 3 4 5 6 7 8 20sec 90sec 260sec 360 T(°C) Nodes2D Steady State Heat Conduction
0
k
)
y
,
x
(
S
y
T
x
T
2 2 2 2=
+
∂
∂
+
∂
∂
2 j , 1 i j , i j , 1 i j , i 2 2)
x
(
T
T
2
T
x
T
∆
+
−
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
∂
+ −2D steady state with heat generation
2 1 j , i j , i 1 j , i j , i 2 2
)
y
(
T
T
2
T
y
T
∆
+
−
=
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∂
∂
+ −l
y
x
0
k
l
S
T
4
T
T
T
T
2 j , i j , i 1 j , i 1 j , i j , 1 i j , 1 i=
∆
=
∆
=
+
−
+
+
+
+ − + −where
Flux Boundary Condition
Ti,,j+1 Ti,,j-1 Ti+1,,j Ti,,j l qo W/m2 l/2Nodes (i,j) on a prescribed heat flux boundary
0 k lq 2 k S l T 4 T T 2 T 0 S l 2 1 l T T 2 l k l T T kl l T T 2 l k l q o j , i 2 j , i 1 j , i j , 1 i 1 j , i j , i 2 j , i 1 j , i j , i j , 1 i j , i 1 j , i 0 = + + − + + = + − + − + − + − + + − + + After rearrangement
Flux Boundary Condition
(another way)
0 k S l T 4 T T T T i,j 2 j , i 1 j , i 1 j , i j , 1 i j , 1 i− + + + + + − − + = j , 1 i o j , 1 i j , 1 i j , 1 i o T k lq 2 T l 2 T T k x T k q + − − + + = ⇒ − − = ∂ ∂ − = Ti,,j+1 Ti,,j-1 Ti+1,,j Ti,,j l qo W/m2 l/2Applying the finite difference equation at the boundary node (i, j)
B.C.