Crank Nicolson Scheme: X U C T U
Crank Nicolson Scheme: X U C T U
Due to some limitations over Explicit Scheme, mainly regarding convergence and stability,
another schemes were developed which have less truncation error and which are
unconditionally convergent and stable. Crank and Nicolson in the year 1947 proposed a scheme
by introducing a fictitious time level at ( j
1
) as shown in fig(3)
2
ui,j+1
(j+1)th level
Level(j+1/2)th
ui,j+1/2
jth level
ui,j
ith level
fig(3)
and then discretizing the given PDE
u
2u
c2 2
t
x
(3.1)
at (i, j+1/2)
2u
u
c 2 2
t i , j 1
x i , j 1
2
(3.2)
Replacing the first order derivative by Central Difference and the second order derivative by the
average at ( i, j )th and ( i, j+1)th levels,giving
ui , j 1 ui , j
1
ui1, j 2ui, j ui1' j ui1, j1 2ui, j1 ui1, j1
2
t
2
(
x
)
2.
2
(3.3)
(3.4)
with, r
t
( x ) 2
LHS of equation (3.4) consists of the values of u at ( j + 1 )th level whereas RHS contains values
at jth level. Thus LHS contains unknowns whereas all values in RHS are known with i = 1,2
.. ,N and j = 1,2 ,M . Also i = 0 and i = N+1 defines the boundary.
Now putting j = 0 in equation (3.4), we get
ui1,j+1
ui,j
ui+1,j
(j+1)th level
2+
jthlevel
ui1,j
ui,j
UnknownValues
ui+1,j
KnownValues
Fig.(1)
Talking about the truncation error of this scheme, it can be observed from the equation (3.3) that
t
2
the TE is o ox which is definitely less then the Explicit Scheme given in lecture 2.
4
2
Another advantage of this scheme is that this scheme is unconditionally convergent and stable.
Thus the restriction on r<1/2 is not to be satisfied. However, care is still to be taken that r
cannot taken as too large. As per derivation of the derivative in terms of FD, both t and x are
quite small and
t
(x) 2
The only disadvantage with this scheme is that the equations are to be solved simultaneously at
every time level which is time consuming. One can observe that the shape of the coefficient
matrix is tridiagonal, therefore efficient solver of tridiagonal system can be used to save
computational time.
t t 2
subject to B.Cs.
0 x 1 ,t 0
u = 0 at x = 0 and
u ( x,0) sin
and I.C.
u
0
x
at x = 1 ,for all t
3x
2
Using the Crank Nicholson scheme ,choosing x = 0.1 and t = 0.0025 so that r = 1/4, obtain
the solution for one time level and compare it with the Explicit solution.
Solution:
Crank Nicolson Finite-Difference representation of the given equation is:
u i , j 1 u i , j
1
ui1, j 2ui, j ui1' j ui1, j 1 2ui, j 1 ui1, j 1
t
2(x) 2
2.
2
r t x
u ( x,0) sin
3x
2
(2)
u
0 ; N 10
x N , j
u N 1, j u N , j
x
0 u N 1, j u N , j u10 j u9, j
(3)
(4)
Now substituting i = 1,2,.........,9 in equation (4), we get 9 equations in 10 unknowns. So,with the
help of equation (3) we have 10 equations in 10 unknowns.
The corresponding equations are:
(5)
with the help of equation (3) , the last equation (5) becomes-
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i = 10
X= 0.
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
j=0
.0082
.0164
.0247
.0329
.0411
.0493
.0575
.0657
.0740
.0740
j=1
.0082
.0164
.0247
.0329
.0411
.0493
.0575
.0656
.0722
.0722
0.08
0.07
C-N
Explicit
0.06
u(x,t)
0.05
0.04
0.03
0.02
0.01
0
0.2
0.4
0.6
0.8
Example2:ConsiderthePDEasfollows:
u
2u
x 2 ;0 x 1, t 0 (1)
t
x
B.C(i)u=0atx=0,t>0(ii)
u 1
u; x 1, t 0
x 2
I.Cisu=x(1x)whent=0& 0 x 1
SolvethisequationbyCrankNicolsonScheme,employingcentraldifferencefortheboundary
conditions.Take x h .1 &r=0.25.
Solution:
HereweapproximatethegivenequationbyCNSchemeas
ui , j 1 ui , j
k
2
h2
h2
(2 2irh)ui , j irhui 1, j
Puttingr=.25andh=.1,weget
.025iu i 1, j 1 ( 2 .05i )ui , j 1 .025iui 1, j 1 .025iu i 1, j ( 2 .05i )ui , j .025iu i 1, j
( 2)
I.Cisu(x,0)=x(1x); 0 x 1
u0,0 u (0, 0)
0,
u6,0 0.24,
u7,0 0.21,
u8,0 0.16,
u9,0 0.09,
u10,0 0
NowIstB.Cis:u=0atx=0fort
2 B.Catx=1is:
u 1
u
t
2
Nowapplycentraldifferenceformulahere,weget
ui 1, j ui 1, j
2h
1
ui , j ui 1, j ui 1, j hui , j
2
Atx=1i.e.i=10
(4)
Puti=10inequation(2)
(5)
.25u 9, j 1 2.5u10 , j 1 .25u11, j 1 .25u 9, j 1.5u10 , j .25u11, j
AtIsttimelevel:Puttingi=1,2,3,9&j=0in(2),weget
2.05u1 0.025u 2
0.05u1
0.1795
2.1u 2 0.05u3
0.319
0.4185
0.1u5
0.478
0.4975
2.3u6 0.15u7
0.477
2.4u8 0.2u9
0.4165
0.316
Putj=0inequation(6):
u1 u1,1 0.0895,
u 2 u 2,1 .1590,
u3 u3,1 0.2085
u 4 u 4,1 0.2380,
u5 u5,1 .2475,
u6 u6,1 0.2370
u7 u7,1 0.2065,
u8 u8,1 .1563,
u9 u9,1 0.0892
2ndtimelevel
Substitutei=1,2,,9&j=1inequation(2),weget
2.05u1 0.025u 2
0.1785
0.317
.075u 4
0.4155
2.2u 4 0.1u5
0.474
0.4925
0.471
0.4096
0.3092
Putj=1inequation(6)
u1 u1, 2 .0890,
u 2 u 2, 2 .1580,
u3 u3, 2 .2070
u 4 u 4, 2 .2360,
u5 u5 , 2 .2450,
u8 u8, 2 .1536,
u6 u6, 2 .2340
u7 u7 , 2 .2032,
u9 u9, 2 .0969
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i = 10
X= 0.
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
X=0.1
j=1
.0895
.1590
.2085
.2380
.2475
.2370
.2065
.1563
.0892
.0355
j=2
.0890
.1580
.2070
.2360
.2450
.2340
.2032
.1536
.0969
.0569