Crank Nicolson Scheme
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
                                                                 1
by introducing a fictitious time level at ( j                     ) as shown in fig(3)
                                                                 2
                                                                                                   (j+1)th level
                                                                             ui,j+1
                        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                            at (i, j+1/2)                                                    (3.1)
                t     x
    u                     2u 
                  c 2  2                                                                                      (3.2)
    t  i , j  1         x  i , j  1
                   2                      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
           t
                    
                      2(
                         1
                         x ) 2
                                
                                ui1, j  2ui, j  ui1' j   ui1, j1  2ui, j1  ui1, j1                    (3.3)
      2.
           2
which gives on rearranging:
   ru i 1, j 1  ( 2  2r )ui , j 1  ui 1, j 1  rui 1, j  ( 2  2r )ui , j  rui 1, j                       (3.4)
                  t
   with, r 
                ( 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
 rui 1,1  ( 2  2r )ui ,1  ui 1,1  rui 1, 0  (2  2r )ui , 0  rui 1, 0
Putting all values of i = 1,2..,N, we get a system of N linear algebraic equations in N
unknowns u11, u21. uN1 which can be solved by any iterative/direct scheme.
Scheme given by equation (3.4) is called Crank Nicolson scheme which is an implicit scheme.
The computational molecules of this scheme is as shown in Fig(1).
                  ui1,j+1                        ui,j            ui+1,j     UnknownValues
                                                 2+                                 (j+1)th level
                                               2
                                                                                   jthlevel
                  ui1,j                     ui,j                 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.
                       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
                                     t
quite small and           r                  so obviously r cannot be too large.
                                    (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.
Example1:Solve the Heat Conduction Equation
                      u  2 u
                                            0  x  1 ,t  0
                      t t 2
                                                              u
                                                                 0
subject to B.Cs.             u = 0 at x = 0 and               x    at x = 1 ,for all t
                                               3x
        and I.C.             u ( x,0)  sin
                                                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
           t
                     
                         1
                       2(x) 2
                                                                                                   
                               ui1, j  2ui, j  ui1' j   ui1, j 1  2ui, j 1  ui1, j 1 
       2.
           2
 rui 1, j 1  (2  2r )ui , j 1  ui 1, j 1  rui 1, j  (2  2r )ui , j  rui 1, j
           r  t x 
                            2
with
                                                  3x
Initial condition is:           u ( x,0)  sin                                                      (2)
                                                   2
                                                           u 
Boundary conditions are: u 0, j  0 and                         0 ; N  10
                                                           x  N , j
Replacing L.H.S by Backward Difference
u N 1, j  u N , j
                       0  u N 1, j  u N , j  u10 j  u9, j                       (3)
       x
Substituting j = 0 in equation (1)
 rui 1,1  ( 2  2r )ui ,1  ui 1,1  rui 1, 0  ( 2  2r )ui , 0  rui 1, 0
                                                                                            (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:
                       2.5u1,1  0.25u 2,1  1.5u1,0  0.25u 2, 0
 0.25u1, 0  2.5u 2,1  0.25u 3,1  0.25u1, 0  1.5u 2, 0  0.25u 3, 0
    0.25u 2, 0  2.5u 3,1  0.25u 4,1  0.25u 2, 0  1.5u 3, 0  0.25u 4, 0
    0.25u 3, 0  2.5u 4,1  0.25u 5,1  0.25u 3, 0  1.5u 4, 0  0.25u 5, 0
  0.25u 4, 0  2.5u 5,1  0.25u 6,1  0.25u 4 , 0  1.5u 5, 0  0.25u 6, 0
  0.25u 5, 0  2.5u 6,1  0.25u 7 ,1  0.25u 5, 0  1.5u 6 , 0  0.25u 4, 0
  0.25u 6, 0  2.5u 7 ,1  0.25u 8,1  0.25u 6, 0  1.5u 7 , 0  0.25u 5, 0
  0.25u 7 , 0  2.5u8,1  0.25u 9,1  0.25u 7 , 0  1.5u8, 0  0.25u 6, 0
 0.25u8, 0  2.5u 9,1  0.25u10 ,1  0.25u 8, 0  1.5u 9, 0  0.25u10 , 0                        (5)
with the help of equation (3) , the last equation (5) becomes-
               0.25u8, 0  2.25u 9,1  0.25u8, 0  1.75u 9, 0
On solving this system of equation we get values at the first time level as follows:
      i=0             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            0            .0082        .0164        .0247        .0329       .0411        .0493        .0575        .0657        .0740       .0740
j=1            0            .0082        .0164        .0247        .0329       .0411        .0493        .0575        .0656        .0722       .0722
      Comparison between the results obtained by Crank-Nicolson and Explicit methods:
               0.08
               0.07
                                 C-N
               0.06
                                 Explicit
               0.05
      u(x,t)
               0.04
               0.03
               0.02
               0.01
                   0
                       0      0.2           0.4        0.6          0.8           1
                                                  x
      Example2:ConsiderthePDEasfollows:
          u     2u
             x 2 ;0  x  1, t  0 (1)
          t    x
                                                         u 1
      B.C(i)u=0atx=0,t>0(ii)              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       ih  ui1, j 1  2ui , j 1  ui 1, j 1 ui 1, j  2ui , j  ui 1, j         
                                                                                                                k                2               h2                                  h2                                              
 irhui 1, j 1  (2  2irh)ui , j 1  irhui1, j 1  irhui 1, j                            (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,                        u1,0  u (0.1, 0)  0.09,                                   u2,0  u (0.2, 0)  0.16
u3,0  u (0.3, 0)  0.21,                               u4,0  u (0.4, 0)  0.24,                                     u5,0  u (0.5, 0)  0.25                                                                                                                                                                
u6,0  0.24,                                            u7,0  0.21,                                                u8,0  0.16,
u9,0  0.09,                                            u10,0  0
NowIstB.Cis:u=0atx=0fort
 u 0,1  u 0 , 2  u 0,3  .......... ..........u 0,n  0 
                                  u 1
    nd
2 B.Catx=1is:                   u
                                  t  2 
Nowapplycentraldifferenceformulahere,weget
ui 1, j  ui 1, j          1
                               ui , j  ui 1, j  ui 1, j   hui , j 
         2h                  2
Atx=1i.e.i=10
u11, j  u9, j   hu10, j  u11, j  u9, j  hu10, j  u9, j  .1u10, j ;trueforallvaluesofj
                                                                                                                       (3)
u11, j 1  u 9, j  .1u10 , j                                                                                                                                    (4)
                                         Puti=10inequation(2)
                                                                                                                                   (5)
 .25u 9, j 1  2.5u10 , j 1  .25u11, j 1  .25u 9, j  1.5u10 , j  .25u11, j 
Noweliminate u11, j and u11, j 1 fromequation(5),usingequation(3)andequation(4),
weget
 .5u 9, j 1  2.525u10 , j 1  .5u 9, j  1.475u10 , j 
                                                                                                                                          (6)
AtIsttimelevel:Puttingi=1,2,3,9&j=0in(2),weget
    2.05u1  0.025u 2                                                                                                                                            0.1795
 0.05u1           2.1u 2  0.05u3                                                                                                                              0.319
              0.075u 2  2.15u3  0.075u 4                                                                                                                       0.4185
                                 0.1u3  2.20u 4                0.1u5                                                                                          0.478
                                              0.125u 4  2.25u5  0.125u6                                                                                       0.4975
                                                               0.15u5            2.3u6  0.15u7                                                                0.477
                                                                             0.175u6  2.35u7  0.175u8                                                         0.4165
                                                                                               0.2u7           2.4u8  0.2u9                                   0.316
                                                                                                             0.225u8  2.45u9  0.225u10  0.1755
Putj=0inequation(6):
 0.5u9  2.525u10  0.045 
Aftersolvingtheseequations,weget
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
u10  u10,1  0.0355
2ndtimelevel
Substitutei=1,2,,9&j=1inequation(2),weget
           2.05u1  0.025u 2                                                                                       0.1785
       0.05u1  2.1u 2  0.05u3                                                                                   0.317
                    0.075u 2  2.15u3      .075u 4                                                               0.4155
                                0.1u3      2.2u 4  0.1u5                                                       0.474
                                          0.125u 4  2.25u5  0.125u6                                             0.4925
                                                     0.15u5  2.30u6  0.15u7                                     0.471
                                                                 0.175u6  2.35u7  0.175u8                       0.4096
                                                                                0.2u7  2.40u8  0.20u9           0.3092
                                                                                      0.225u8  2.45u9  0.225u10  0.1814
      
      Putj=1inequation(6)
       .5u9  2.525u10  .09696
      Aftersolvingtheseequation,weget
      u1  u1, 2  .0890,      u 2  u 2, 2  .1580,     u3  u3, 2  .2070
      u 4  u 4, 2  .2360,    u5  u5 , 2  .2450,      u6  u6, 2  .2340                                                                               
      u7  u7 , 2  .2032,     u8  u8, 2  .1536,        u9  u9, 2  .0969
      u10  u10, 2  .0569
      Thus,the values at first and second time level are:
             i=0      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          0         .0895     .1590     .2085        .2380   .2475    .2370      .2065    .1563   .0892   .0355
j=2          0         .0890     .1580     .2070        .2360   .2450    .2340      .2032    .1536   .0969   .0569