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 Finite element method
Introduction to Finite Difference
Taylor series expansion
f 2 f (x ) 2 n f (x ) n x + 2 ++ n + f ( x + x ) = f ( x ) + x 2 n! x x
gradient curvature
Discretization
i +1, j 2 () 2 3 (x ) 3 + = i , j + x + 3 2 x i , j x i , j 2 x i , j 6
Representation of a Derivative
i +1, j 2 (x ) 2 3 (x ) 3 + = i , j + x + 3 2 x i , j x i , j 2 x i , j 6
i +1, j i , j 2 (x ) 3 (x ) 2 = 2 3 x x i , j x i , j 2 x i , j 6
Finite difference representation
Forward difference
i +1, j i , j + O(x ) = x x i , j
Backward Difference
i 1, j 2 ( x ) 2 3 (x ) 3 = i , j + (x ) + + 3 2 6 2 x i , j x i , j x i , j
i 1, j
2 (x ) 2 3 (x ) 3 = i , j x + 2 3 x i , j x i , j 2 x i , j 6
Backward difference
i , j i 1, j + O(x ) = x x i , j
Central difference
i +1, j 2 (x ) 2 3 (x ) 3 + = i , j + x + 2 3 x i , j x i , j 2 x i , j 6
i 1, j
2 (x ) 2 3 (x ) 3 = i , j x + 3 2 x i , j x i , j 2 x i , j 6
Subtracting,
i +1, j i 1, j + O(x ) 2 = 2x x i , j
Central difference
Forward, backward and central difference stencil
i +1, j i , j + O(x ) = x x i, j
i , j i 1, j = + O(x ) x x i , j
i +1, j i 1, j + O(x ) 2 = 2 x x i , j
Stencil in y direction
i , j+1 i , j + O(y) y = y i, j
i , j i , j1 = + O(y) y y i, j
i +1, j i 1, j 2 = + O ( y ) y 2y i, j
2nd Order and Mixed Derivative
2 i , j + i 1, j 2 2 = i +1, j + 0 (x ) 2 ) 2 x (x ) i, j
2 i , j + i , j1 2 2 2 = i , j+1 + 0 ( y ) ) 2 y ( y ) i, j
+ i 1, j1 i 1, j+1 i +1, j1 2 = i +1, j+1 xy 4xy i, j + O[(x ) 2 , (y) 2 ]
Boundary Consideration
What kind of differencing scheme is possible at the boundaries?
2 1 y = y + O(y) 1
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
Polynomial Approach
Assume
= a + by + cy
At grid point 1, 1 = a At grid point 2 where y = y,
2 = a + by + c(y)
At grid point 3 where y = 2y,
2 = a + b2y + c(2y) 2
Polynomial Approach (contd)
Solving these equations, Differentiation of gives
b= 31 + 4 2 3 2 y
= a + by + cy 2 = b + 2cy y y =b 1
31 + 4 2 3 = y 2y 1
At point 1 (boundary),
What is the order of approximation??
Order of Approximation
Taylor series gives,
2 y 2 3 y 3 ( y) = 1 + y+ y y 2 2 + y 3 6 + 1 1 1
Comparing with the polynomial expression , = a + by + cy 2 we can say that our polynomial is of O(y)3 1, 2, 3 can all be expressed in terms of the polynomial
31 + 4 2 3 O (y) 3 2 = = = O ( y ) y 2y y 1
Represents one-sided difference of 2nd order accuracy
FDM for 1D diffusion
Uses truncated Taylor series expansion to approximate the derivative of the DE 2 d Consider 1-D diffusion equation 2 +S = Expand in Taylor series about dx point 2
Subtracting these equations yields
FDM (contd)
Adding the equations
d 2 1 + 3 2 2 2 2 = 0 + ( x ) ) 2 dx (x ) 2
Dropping the truncated terms
d 1 + 3 2 2 = 2 dx 2 ( x ) 2
2
Second order truncation error S2 = S(2)
The final discretized equation
2 2 = + + S2 2 2 1 2 3 (x ) (x ) (x )
FDM (contd)
2 + S2 2 = + 2 2 1 2 3 (x ) ( x ) ( x )
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
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/m3. The boundary surface at x = 0 is maintained at a constant temperature To, 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/(m2.C), k = 18 W/(m.C), L = 0.01 m, T = 100C, To = 50C, and S = 7.2 x 107.
x To = 50 C 0 1 2 0.01 m x 3 4 T = 100 C 5
Solution
d 2T k 2 +S= 0 dx T ( x ) = To
B.C.
at x = 0 at x = L = 0.01m
dT ( x ) + hT = hT dx
2k k k T + T + Si T = 2 i 2 i 1 2 i +1 (x ) (x ) (x ) k 2k k + T T T = Si 2 i 1 2 i 2 i +1 (x ) (x ) (x ) (x ) 2 (L / 5) 2 Ti 1 2Ti + Ti +1 = Si = 16 Si = k k
Treatment of Boundary Condition
x/2 x To = 50 C 0 1 2 0.01 m x 3
cond conv
N=5
Ti 1 2Ti + Ti +1 = 16
Applicable to node 1-4
TN TN 1 x k h (TN T ) + S =0 x 2 (x ) 2 S N 2xh 2xh 2TN 1 2 + + T = 0 TN + k k k Applying it to 2T4 2.044T5 + 16 + 4.44 = 0 node 5
Treatment of Boundary Condition (Another Way)
x To = 50 C 0 1 2 0.01 m x 3 4 N=5 T
Ti 1 2Ti + Ti +1 = 16
Apply to node 5
T4 2T5 + T6 = 16
2T4 2 + T5 = 16 + k k 2T4 2.044T5 = 16 + 4.44
T6 T4 k h (T5 T ) = 0 B.C. gives 2x 2xh (T5 T ) + T4 T6 = k 2hx 2hx
T
Algebraic Equations
T0 2T1 + T2 = 16 2T1 + T2 = 16 50
T1 2T2 + T3 = 16
T2 2T3 + T4 = 16
T3 2T4 + T5 = 16
2T4 2.044T5 = 16 4.44
Can be solved by Thomas algorithm Matrix inversion as shown in next slide
Matrix Form
0 0 0 T1 66 2 1 1 2 1 T 16 0 0 2 0 1 2 1 0 T3 = 16 0 1 2 1 T4 16 0 20.44 0 0 2 2.044 0 T5
[A][x ] = [B] 1 [x ] = [A ] [B]
Prescribed Heat Flux
x/2 qo 0 X=0 1 x 2 3 N-1 N X=L qN
Energy balance gives,
T1 T0 1 q0 + k + xS0 = 0 x 2 TN 1 TN 1 qN + k + xS N = 0 x 2
FDM representation
Flux boundary,
(x ) 2 S0 2xq 0 2T1 2T0 + + =0 for i = 0 k k (x ) 2 S N 2xq N 2TN 1 2TN + + =0 for i = N k k
For insulated or symmetry boundary,
(x ) 2 S0 2T1 2T0 + =0 for i = 0 k (x ) 2 S N 2TN 1 2TN + =0 for i = N k
Unsteady Heat Conduction with FDM
Unsteady heat conduction in 1D with constant thermal conductivity
T 2T = 2 t x
n n
Expand the individual Tin +1 Tin 2 T t T + = 2 terms with Taylor series, t t i t i 2
T T 2 = x i
2
n i +1
2T + T (x ) 2
n i
n i 1
T (x ) 2 x 4 12 + i
4
Unsteady Heat Conduction (contd)
n n Tin +1 Tin (Tin 2 T + T i i 1 ) +1 = 2 t (x )
Explicit Solutions
n n Tin +1 Tin (Tin 2 T + T +1 i i 1 ) = t ( x ) 2
Tin +1
Tin
t n n n ( T 2 T + T + i +1 i i 1 ) 2 (x )
Find 1-D unsteady temperature distribution till steady state Tw = 30C 50 cm
x = 50 = 10cm 5
Tw = 100C
= 17 x10 2 cm 2 / s
t 1 ( x ) 2 2
will talk later
Initial temp Tin = 30C, t = 10 sec
Results
120 100 80
T(C)
60 40 20 0 0 1 2 3 4 5 6 7 8
20sec 90sec 260sec 360
Nodes
2D Steady State Heat Conduction
2D steady state with heat generation
2 T 2 T S( x , y) + 2 + =0 2 k x y
Ti +1, j 2Ti , j + Ti 1, j 2T 2 = 2 x ( x ) i, j
Ti , j+1 2Ti , j + Ti , j1 2T 2 = 2 y ( y ) i, j
Ti 1, j + Ti +1, j + Ti , j1 + Ti , j+1 4Ti , j +
where
Si , j l 2 k
=0
x = y = l
Flux Boundary Condition
Ti,,j+1 l Ti,,j qo W/m2 l/2 Ti,,j-1 Nodes (i,j) on a prescribed heat flux boundary
Ti +1, j Ti , j l Ti , j+1 Ti , j l Ti , j1 Ti , j 1 2 q 0l + k + kl +k + l Si , j = 0 2 l l 2 l 2
Ti+1,,j
After rearrangement
Ti , j+1 + 2Ti +1, j + Ti , j1 4Ti , j + l 2Si , j k + 2lq o =0 k
Flux Boundary Condition
(another way)
Ti,,j+1 l Ti,,j qo W/m2 l/2 Ti,,j-1 B.C.
Ti +1, j Ti 1, j T = k q o = k x 2l 2lq o Ti 1, j = + Ti +1, j k
Applying the finite difference equation at the boundary node (i, j)
Ti+1,,j
Ti 1, j + Ti +1, j + Ti , j+1 + Ti , j1 4Ti , j +
l 2 Si , j k
=0
Ti , j+1 + 2Ti +1, j + Ti , j1 4Ti , j +
l 2 Si , j k
2lq o =0 k
Convective Boundary Condition
Energy balance gives,
Ti 1, j Ti , j Ti , j+1 Ti , j l Ti +1, j Ti , j 3 l Ti , j1 Ti , j + kl + kl +k + hl(T Ti , j ) + l 2Si , j = 0 k 4 2 l l l 2 l
After rearrangement,
2hl 3 l2 2hl Ti , j1 + 2Ti 1, j + 2Ti , j+1 + Ti +1, j 6 + Si , j + T = 0 Ti , j + k k 2k
l Ti,,j+1 l Ti-1,,j l/2 Ti,,j-1 Ti+1,j Ti,,j Convection h,T
Insulated Boundary
T ( x ) = 100 cos
2b 100 Insulated T2 T1 0
86.66 T4 T3
50 T6 T5
x 6b
Maintained at zero temperature Node 1: Node 2: Node 3: Node 4: Node 5: Node 6: 2T2+2T3-4T1= 0 T1+2T4+100-4T2 = 0 T1+2T4+T5-4T3 = 0 T2+T3+T6+86.66-4T4 = 0 T3+2T6-4T5 = 0 T4+T5+50-4T6 = 0
3b Insulated
Matrix Form
2 0 0 0 T1 0 4 2 T 100 1 4 0 2 0 0 2 1 0 4 2 1 0 T3 0 = 0 1 1 4 0 1 T4 86.66 0 0 1 0 4 2 T5 0 T 50 0 0 0 1 1 4 6