0% found this document useful (0 votes)
101 views43 pages

31-Explicit and Crank-Nicolson Methods For Solution of Heat Equations-14!11!2022

Uploaded by

Omkar Dake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views43 pages

31-Explicit and Crank-Nicolson Methods For Solution of Heat Equations-14!11!2022

Uploaded by

Omkar Dake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

BCHE201L: Computational Methods in Chemical Engineering

Dr. Shishir Kumar Behera


School of Chemical Engineering (SCHEME)
VIT Vellore
Parabolic Equations

HEAT-CONDUCTION EQUATION

• Heat balance for the differential element in the long,


thin insulated rod.
• Heat balance also considers the amount of heat stored in
the element over a unit time period Dt
• Input - Output = Storage

Dr. S. K. Behera BCHE201L Computational Methods in Chemical Engineering 2


• Substituting Fourier’s law of heat conduction,

result in

• Parabolic equations can be solved by substituting finite


divided differences for the partial derivatives.
• While elliptic equations were bounded in all relevant
dimensions, parabolic PDEs are temporally open-ended.

Dr. S. K. Behera BCHE201L Computational Methods in Chemical Engineering 3


Parabolic Equations
A second order linear PDE (2 - independen t variable s x , y )
A u xx  B u xy  C u yy  D  0,
A, B, and C are functions of x and y
D is a function of x, y, u, u x , and u y

is parabolic if B 2  4 AC  0

4
Parabolic Problems

 T ( x, t )  2 T ( x, t )
Heat Equation : 
t x 2
T (0, t )  T (1, t )  0
T ( x,0)  sin( x )

* Parabolic problem ( B 2  4 AC  0)
* Boundary conditions are needed to uniquely specify a solution.

5
Solution of the Heat Equation
• Two solution techniques to the Parabolic Equation
(Heat Equation) are presented:
1. Explicit Method:
Simple, Stability Problems.
2. Crank-Nicolson Method:
Involves the solution of a Tridiagonal system of
equations, Stable.

6
Explicit Method

T ( x, t )  2T ( x, t )

t x 2
T ( x, t  k )  T ( x, t ) T ( x  h, t )  2T ( x, t )  T ( x  h, t )

k h2
T ( x, t  k )  T ( x, t )  2 T ( x  h, t )  2T ( x, t )  T ( x  h, t ) 
k
h
k
Define   2
h
T ( x, t  k )   T ( x  h, t )  (1  2  ) T ( x, t )   T ( x  h, t )

7
Explicit Method
How do we compute?

T ( x, t  k )   T ( x  h, t )  (1  2  ) T ( x, t )   T ( x  h, t )
means

T(x,t+k)

T(x-h,t) T(x,t) T(x+h,t)

8
Convergence and Stability of the Solution

• Convergence
The solutions converge means that the solution
obtained using the finite difference method approaches
the true solution as the steps x and t approach zero.

• Stability:
An algorithm is stable if the errors at each stage of the
computation are not magnified as the computation
progresses.

9
Convergence and Stability of the Solution

T ( x, t  k ) can be computed directly using :


T ( x, t  k )   T ( x  h, t )  (1  2  ) T ( x, t )   T ( x  h, t )

Can be unstable errors are magnified 


1 h2
To guarantee stability, (1  2  )  0     k 
2 2
This means that k is much smaller th an h
This makes it slow.

10
Example 1:
Solve the PDE :
 2u(x,t) u(x,t)
 0
 x
2
t
u(0, t )  u(1, t )  0
u( x,0)  sin( x )

Use h  0.25, k  0.25 to find u( x, t ) for x  [0,1], t  [0,1]


k
  2 4
h

11
 2 u ( x, t )  u ( x, t )
 0
x 2
t
u ( x  h , t )  2u ( x , t )  u ( x  h , t ) u ( x , t  k )  u ( x , t )
2
 0
h k
16u( x  h, t )  2u( x, t )  u( x  h, t )   4u( x, t  k )  u( x, t )   0

u ( x , t  k )  4 u ( x  h, t )  7 u ( x , t )  4 u ( x  h, t )

12
u( x, t  k )  4 u( x  h, t )  7 u( x, t )  4 u( x  h, t )

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0

13
u(0.25,0.25)  4 u(0,0)  7 u(0.25,0)  4 u(0.5,0)
 0  7 sin( / 4)  4 sin( / 2)  0.9497

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0.5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0

u( x, t  k )  4 u( x  h, t )  7 u( x, t )  4 u( x  h, t )
14
u(0.5,0.25)  4 u(0.25,0)  7 u(0.5,0)  4 u(0.75,0)
 4 sin( / 4)  7 sin( / 2)  4 sin( 3 / 4)  0.1716

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0

15
Remarks

The obtained results are probably not accurate


because : 1  2  7

For accurate results : 1  2  0


h 2 (0.25) 2
One needs to select k    0.03125
2 2
k
For example, choose k  0.025, then   2  0.4
h

16
u( x, t  k )  0.4 u( x  h, t )  0.2 u( x, t )  0.4 u( x  h, t )

t=0.10 0 0

t=0.075 0 0

t=0.05 0 0
t=0.025 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0

17
u(0.25,0.025)  0.4 u(0,0)  0.2 u(0.25,0)  0.4 u(0.5,0)
 0  0.2 sin( / 4)  0.4 sin( / 2)  0.5414

t=0.10 0 0

t=0.075 0 0

t=0.05 0 0
t=0.025 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0

18
u(0.5,0.025)  0.4 u(0.25,0)  0.2 u(0.5,0)  0.4 u(0.75,0)
 0.4 sin( / 4)  0.2 sin( / 2)  0.4 sin( 3 / 4)  0.7657

t=0.10 0 0

t=0.075 0 0

t=0.05 0 0
t=0.025 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0

Repeat the procedure to find the values at other points

19
Practice Problem
Solve the heat equation subject to the conditions u(x,0)
= x2(25-x2), u(0,t) = u(5,t) = 0. With h = 1 and k = 0.5, compute
the value of uij for i = 0,1,2,3,4,5 and j = 0,1,2 using Explicit
formula.

20
Crank-Nicolson Method

• This method involves solving a Trigonal system of linear

equations.

• The method is stable (No magnification of error)

• We can use larger h, k (compared to the explicit method)

21
Crank-Nicolson Method

22
Crank-Nicolson Method
 2 u ( x, t )  u( x, t )
Heat Equat ion :  becomes
x 2
t

u ( x  h , t )  2u ( x , t )  u ( x  h , t ) u ( x , t )  u ( x , t  k )
2

h k
k
2
u( x  h, t )  2u( x, t )  u( x  h, t )   u( x, t )  u( x, t  k )
h
k k k
 2 u( x  h, t )  (1  2 2 ) u( x, t )  2 u( x  h, t )  u( x, t  k )
h h h

23
Crank-Nicolson Method
k
Define   2 then Heat equation becomes :
h
  u( x  h, t )  (1  2 ) u( x, t )   u( x  h, t )  u( x, t  k )

u(x-h,t) u(x,t) u(x+h,t)

u(x,t - k)

24
Crank-Nicolson Method
The equation :
  u( x  h, t )  (1  2 ) u( x, t )   u( x  h, t )  u( x, t  k )
can be rewritten as :
  ui 1, j  (1  2 ) ui , j   ui 1, j  ui , j 1
and can be expanded as a system of equations (fix j  1) :
  u0,1  (1  2 ) u1,1   u2,1  u1,0
  u1,1  (1  2 ) u2,1   u3,1  u2,0
  u2,1  (1  2 ) u3,1   u4,1  u3,0
  u3,1  (1  2 ) u4,1   u5,1  u4,0

25
Crank-Nicolson Method
  u( x  h, t )  (1  2 ) u( x, t )   u( x  h, t )  u( x, t  k )
can be expressed as a Tridiagona l system of equations :
1  2    u1,1   u1,0   u0,1 
   1  2   u   u 
   2,1    2, 0 
   1  2    u3,1   u3,0 
  u  u   u 
   1  2   4,1   4,0 5,1 

where u1,0 , u2,0 , u3,0 , and u4,0 are the initial temperatu re values
at x  x0  h, x0  2h, x0  3h, and x0  4h
u0,1 and u5,1 are the boundary values at x  x0 and x0  5h

26
Crank-Nicolson Method
The solution of the tridiagon al system produces :
The temperatu re values u1,1, u2,1, u3,1, and u4,1 at t  t0  k
To compute the temperatu re values at t  t0  2k
Solve a second tridiagon al system of equations ( j  2)
1  2    u1,2   u1,1   u0,2 
   1  2   u   u 
   2, 2    2,1 
   1  2   u3,2   u3,1 
     
   1  2   u
 4,2   4,1u   u5, 2 

To compute u1,2 , u2,2 , u3,2 , and u4,2


Repeat the above step to compute temperatu re values at t0  3k , etc.
27
Example 2
Solve the PDE :
 2u( x, t ) u( x, t )
 0
 x
2
t
u(0, t )  u(1, t )  0
u( x,0)  sin( x )

Solve using Crank - Nicolson method


Use h  0.25, k  0.25 to find u( x, t ) for x  [0,1], t  [0,1]

28
 2 u ( x, t )  u ( x, t )
 0
x 2
t
u ( x  h , t )  2u ( x , t )  u ( x  h , t ) u ( x , t )  u ( x , t  k )
2

h k
16u( x  h, t )  2u( x, t )  u( x  h, t )   4u( x, t )  u( x, t  k )   0
k
Define   2  4
h
 4 u ( x  h, t )  9 u ( x , t )  4 u ( x  h, t )  u ( x , t  k )
 4 ui 1, j  9 ui , j  4 ui 1, j  ui , j 1

29
 4u0,1  9u1,1  4u2,1  u1,0  9u1,1  4u2,1  sin( / 4)
 4u1,1  9u2,1  4u3,1  u2,0  4u1,1  9u2,1  4u3,1  sin( / 2)
 4u2,1  9u3,1  4u4,1  u3,0   4u2,1  9u3,1  sin( 3 / 4)

u1,4 u2,4 u3,4


t4=1.0 0 0
u1,3 u2,3 u3,3
t3=0.75 0 0
u1,2 u2,2 u3,2
t2=0.5 0 0
u1,1 u2,1 u3,1
t1=0.25 0 0

t0=0 0 0
Sin(0.25π) Sin(0.5π) Sin(0.75π)
x0=0.0 x1=0.25 x2=0.5 x3=0.75 x4=1.0

30
Solution of First Row at t2= 0.25 sec

The Solution of the PDE at t1  0.25 sec is the solution


of the following tridiagon al system of equations :
 9 4   u1,1  sin( 0.25 )
 4 9  4 u    sin( 0.5 ) 
   2,1   
  4 9  u3,1  sin( 0.75 )
 u1,1   0.21151 
  
 u2,1   0.29912 
 
u3,1   0.21151 

31
Second Row at t2= 0.5 sec
 4u0,2  9u1,2  4u2,2  u1,1  9u1,2  4u2,2  0.21151
 4u1,2  9u2,2  4u3,2  u2,1  4u1,2  9u2,2  4u3,2  0.29912
 4u2,2  9u3,2  4u4,2  u3,1   4u2,2  9u3,2  0.21151
u1,4 u2,4 u3,4
t4=1.0 0 0
u1,3 u2,3 u3,3
t3=0.75 0 0
u1,2 u2,2 u3,2
t2=0.5 0 0
u1,1 u2,1 u3,1
t1=0.25 0 0

t0=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)
x0=0.0 x1=0.25 x2=0.5 x3=0.75 x4=1.0

32
Solution of Second Row at t2= 0.5 sec

The Solution of the PDE at t2  0.5 sec is the solution


of the following tridiagon al system of equations :
 9 4   u1,2   u1,1   0.21151 
 4 9  4 u   u   0.29912 
   2,2   2,1   
  4 9  u3,2  u3,1   0.21151 
 u1,2  0.063267 
  
 u2,2   0.089473 
 
u3,2  0.063267 

33
Solution of Row 3 at t3= 0.75 sec

The Solution of the PDE at t3  0.75 sec is the solution


of the following tridiagon al system of equations :
 9 4   u1,3   u1,2  0.063267 
 4 9  4 u   u   0.089473 
   2,3   2, 2   
  4 9  u3,3  u3,2  0.063267 
 u1,3  0.018924 
 
 u2,3   0.026763 
 
u3,3  0.018924 

34
Solution of Row 4 at t4= 1 sec

The Solution of the PDE at t4  1 sec is the solution


of the following tridiagon al system of equations :
 9 4   u1,4   u1,3  0.018924 
 4 9  4 u   u   0.026763 
   2, 4   2,3   
  4 9  u3,4  u3,3  0.018924 
 u1,4  0.0056606 
 
 u2,4   0.0080053 
 
u3,4  0.0056606 

35
Remarks
The Explicit Method:
• One needs to select small k to ensure stability.
• Computation per point is very simple but many points are needed.

Cranks Nicolson:
• Requires the solution of a Tridiagonal system.
• Stable (Larger k can be used).

36
Practice Problem
Solve the heat equation subject to the conditions u(x,0)
= 0, u(0,t) = 0 and u(1,t) = t. With h = 0.25 and k = 0.0625,
compute the value of u(0.5, 0.125) using Crank-Nicolson formula.

37
A SIMPLE IMPLICIT METHOD
• Implicit methods overcome both these difficulties at the
expense of somewhat more complicated algorithms.

38
Comparison

• In implicit methods, the spatial derivative is approximated at an advanced time level l +1.
For example, the second derivative would be approximated by

39
A SIMPLE IMPLICIT METHOD
The fundamental difference between explicit and implicit
approximations is depicted here. For the explicit form,
we approximate the spatial derivative at time level l
(Fig.a). Recall that when we substituted this
approximation into the partial differential equation, we
obtained a difference equation with a single unknown
Til+1 .Thus, we can solve “explicitly” for this unknown. In
implicit methods, the spatial derivative is approximated
at an advanced time level l+1. For example, the second.
derivative would be approximated by (Fig. b).

Computational molecules demonstrating the fundamental


differences between (a) explicit and (b) implicit methods.

You might also like