Finite Difference Methods for The Heat Equation
Rajen Kumar Sinha
Department of Mathematics
IIT Guwahati
Rajen Kumar Sinha MA573
Model Problem
Consider one-dimensional heat equation of the form
∂U ∂2U
= x ∈ (0, 1), t > 0
∂t ∂x 2
U(0, t) = U(1, t) = 0, t > 0 (Boundary conditions)
U(x, 0) = f (x), 0 ≤ x ≤ 1. (Initial condition)
Set xi = ih, (i = 0, 1, 2, . . .) and
tj = jk, (j = 0, 1, 2, . . .).
Let Uij be the true value of the
solution at the grid-point (xi , tj ).
Let uij denote finite difference
approximation to the true solution
at (xi , tj ).
uij ≈ Ui,j = U(xi , tj ).
Rajen Kumar Sinha MA573
Schmidt’s explicit scheme: Using forward time and central space (FTCS)
∂2U
schemes to approximate ∂U∂t = ∂x 2 at the grid-point (xi , tj ).
∂2U
∂U ui,j+1 − ui,j ui−1,j − 2ui,j + ui+1,j
≈ , ≈ ,
∂t (xi ,tj ) k ∂x 2 (xi ,tj ) h2
ui,j+1 − ui,j ui−1,j − 2ui,j + ui+1,j
=
k h2
k
=⇒ ui,j+1 = ui,j + 2 (ui−1,j − 2ui,j + ui+1,j )
h
k
=⇒ ui,j+1 = ui,j + r (ui−1,j − 2ui,j + ui+1,j ), r= ,
h2
=⇒ ui,j+1 = rui−1,j + (1 − 2r )ui,j + rui+1,j ,
FACT:
• It is a two-level explicit scheme.
• This scheme is conditionally stable (0 < r ≤ 12 ).
• The local truncation error is O(h2 ) + O(k).
Rajen Kumar Sinha MA573
(Computational stencil)
(Schmidt’s explicit scheme)
Rajen Kumar Sinha MA573
Example:
Ut = Uxx , 0 < x < 1, t > 0
U(0, t) = 0, U(1, t) = 10, t > 0
U(x, 0) = 10, 0 ≤ x ≤ 1
Choose h and k such that r = 1/2.
1
u1,1 = (u0,0 + u2,0 ) = 10
2
1
u2,1 = (u1,0 + u3,0 ) = 10
2
1
u1,2 = (u0,1 + u2,1 ) = 5
2
1
u2,2 = (u1,1 + u3,1 ) = 10
2
Rajen Kumar Sinha MA573
Euler’s implicit scheme: Use backward in time and central in space
(BTCS) schemes at the point (xi , tj ) to have
2
∂U ui,j − ui,j−1 ∂ U ui−1,j − 2ui,j + ui+1,j
≈ , 2
≈ ,
∂t (xi ,tj ) k ∂x (xi ,tj ) h2
to obtain
ui,j − ui,j−1 ui−1,j − 2ui,j + ui+1,j
=
k h2
k
=⇒ ui,j = ui,j−1 + r (ui−1,j − 2ui,j + ui+1,j ), r= ,
h2
=⇒ −rui−1,j + (1 + 2r )ui,j − rui+1,j = ui,j−1
FACT:
• It is a two-level implicit scheme.
• At each time level, we are required to solve a linear system.
• This scheme is unconditionally stable (no restriction on r ).
• The local truncation error is O(h2 ) + O(k).
Rajen Kumar Sinha MA573
(Computational stencil)
Rajen Kumar Sinha MA573
Example:
Ut = Uxx , 0 < x < 1, t > 0
U(0, t) = 0, U(1, t) = 10, t > 0
U(x, 0) = 10, 0 ≤ x ≤ 1
Choose h and k such that r = 1/2.
1 1
− u0,1 + 2u1,1 − u2,1 = u1,0
2 2
1
=⇒ 2u1,1 − u2,1 = 10
2
1 1
− u1,1 + 2u2,1 − u3,1 = u2,0
2 2
1
=⇒ − u1,1 + 2u2,1 = 15
2
Rajen Kumar Sinha MA573
Crank-Nicolson scheme:
∂U ui,j+1 − ui,j
≈ ,
∂t (xi ,tj+1/2 ) k
2
∂ U 1 (ui−1,j+1 − 2ui,j+1 + ui+1,j+1 )
≈
∂x 2 (xi ,tj+1/2 ) 2 h2
(ui−1,j − 2ui,j + ui+1,j )
+ ,
h2
ui,j+1 − ui,j 1 ui−1,j+1 − 2ui,j+1 + ui+1,j+1 ui−1,j − 2ui,j + ui+1,j
= + .
k 2 h2 h2
=⇒ −rui−1,j+1 +(2+2r )ui,j+1 −rui+1,j+1 = rui−1,j +(2−2r )ui,j +rui+1,j ,
k
where r = h2 .
FACT:
• It is a two-level implicit scheme.
• At each time level, we are required to solve a linear system.
• This scheme is unconditionally stable (no restriction on r ).
• The local truncation error is O(h2 ) + O(k 2 ).
Rajen Kumar Sinha MA573
(Crank-Nicolson scheme) (Computational stencil)
Rajen Kumar Sinha MA573
Richardson’s scheme: An application of central in time and central in
space (CTCS) approximation i.e.,
2
∂U ui,j+1 − ui,j−1 ∂ U ui−1,j − 2ui,j + ui+1,j
≈ , ≈ ,
∂t (xi ,tj ) 2k ∂x 2 (xi ,tj ) h2
to obtain the resulting scheme
ui,j+1 − ui,j−1 ui−1,j − 2ui,j + ui+1,j
= (1)
2k h2
FACT:
• It is a three-level explicit scheme.
• This scheme is unstable (hence not recommended).
• The local truncation error is O(h2 ) + O(k 2 ).
Rajen Kumar Sinha MA573
DuFort-Frankel explicit scheme: A modification of (1) is as follows:
ui,j−1 + ui,j+1
ui,j = .
2
(ui,j−1 +ui,j+1 )
ui,j+1 − ui,j−1 ui−1,j − 2 2 + ui+1,j
=
2k h2
k
=⇒ ui,j+1 − ui,j−1 = 2r {ui−1,j − (ui,j−1 + ui,j+1 ) + ui+1,j }, r =
h2
=⇒ (1 + 2r )ui,j+1 = (1 − 2r )ui,j−1 + 2r (ui−1,j + ui+1,j )
(1 − 2r ) 2r
=⇒ ui,j+1 = ui,j−1 + (ui−1,j + ui+1,j )
(1 + 2r ) (1 + 2r )
FACT:
• It is a three-level explicit scheme.
• This scheme is unconditionally stable.
• The local truncation error is O(h2 ) + O(k 2 ).
Rajen Kumar Sinha MA573
(Computational stencil)
*** Ends ***
Rajen Kumar Sinha MA573