# 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
u i,j+1
Level (j+1/2)th
u i,j+1/2
jth level

u i, 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

ui1, j  2ui, j  ui1' j   ui1, j1  2ui, j1  ui1, j1   (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)

j  u i+1.(1) Talking about the truncation error of this scheme.j  u i .1  rui 1. it can be observed from the equation (3. 0 Putting all values of i = 1. care is still to be taken that ‘r’ . Thus LHS contains unknowns whereas all values in RHS are known with i = 1. 0  rui 1. u i‐1.j+1  u i.j  Unknown Values  2+ (j+1)th level  2‐ jth level  u i‐1. 0  (2  2r )ui ..M . j  u i+1.1  ui 1. u21…….4) consists of the values of u at ( j + 1 )th level whereas RHS contains values at jth level. Scheme given by equation (3..3) that  t  2 the TE is o   ox  which is definitely less then the Explicit Scheme given in lecture 2. uN1 which can be solved by any iterative/direct scheme. we get  rui 1.. However.j  Known Values  Fig.2…….2 …….4) is called Crank Nicolson scheme which is an implicit scheme. 2  4  Another advantage of this scheme is that this scheme is unconditionally convergent and stable.N. Thus the restriction on r<1/2 is not to be satisfied. Also i = 0 and i = N+1 defines the boundary.4). Now putting j = 0 in equation (3. r  ( x ) 2 LHS of equation (3. t with.1  ( 2  2r )ui . .N and j = 1. The computational molecules of this scheme is as shown in Fig(1). we get a system of N linear algebraic equations in N unknowns u11.2 ….

0)  sin 2 Using the Crank Nicholson scheme . j 1  2. j  ui1' j   ui1.Cs. (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. j 1  (2  2r )ui . j  rui 1.cannot taken as too large. j t  1 2(x) 2   ui1.   Example 1:‐  Solve the Heat Conduction Equation u  2 u  0  x  1 .1 and ∆t = 0.C. j 1  u i . j  (2  2r )ui . j 1  rui 1. obtain the solution for one time level and compare it with the Explicit solution. j r  t x  2 with 3x Initial condition is: u ( x. j 1  ui 1.choosing ∆x = 0. u ( x. As per derivation of the derivative in terms of FD.0025 so that r = 1/4. One can observe that the shape of the coefficient matrix is tridiagonal.0)  sin (2)  2 . u = 0 at x = 0 and x at x = 1 . Solution:       Crank Nicolson Finite-Difference representation of the given equation is: u i .t  0 t t 2 u 0 subject to B. j  2ui.for all t 3x and I. j 1  ui1. both ∆t and ∆x are t quite small and r so obviously r cannot be too large. therefore efficient solver of tridiagonal system can be used to save computational time. 2  rui 1. j 1  2ui.

0  2.1  0. 0  2.1  0. 0  1.25u 7 .25u 5. 0  rui 1.. 0  1. 0  1.25u 2.25u 3. 0  0.25u 5. 0  0. 0  0. 0  1.25u 2. j  u N ... 0  2.5u 7 . 0  2. 0  1.5u1.1  0.5u1.2. 0  1. j  0 and    0 .1  0. N  10  x  N .1  ( 2  2r )ui .25u 8.25u8. 0  0.25u 2.1  0. j  u N .25u 5.25u 4.1  0. 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 .5u 2.5u 5.1  0.H.5u 9.25u 4. 0  0. The corresponding equations are: 2.25u 9. 0 (4) Now substituting i = 1.1  rui 1.0  0.5u 6..5u8.1  0.25u 3.1  0. 0  2.5u 6 . 0  0..25u8.5u 7 . j  0  u N 1.S by Backward Difference u N 1.25u 7 .1  0.25u1.5u 3.1  0.1  0. 0  ( 2  2r )ui . 0  2. j Replacing L. j  u10 j  u9. 0  1.25u1.9 in equation (4).5u 2.1  0.1  0.  u  Boundary conditions are: u 0. 0  0.25u 7 .25u 4 .1  0. 0  0.5u 4. 0  0.5u 5. 0  2..25u10 .5u 3. j (3) x Substituting j = 0 in equation (1)  rui 1.25u 6.25u 9.5u 9.25u 6.25u 6.25u 6.25u8. 0  0.25u 4. 0  0.1  ui 1.25u 5.with the help of equation (3) we have 10 equations in 10 unknowns..25u 6.25u 3. 0 (5)  with the help of equation (3) .. 0  1.1  0. we get 9 equations in 10 unknowns.25u 3.1  0. So.1  0. 0  1.25u 2.75u 9.1  1. 0  0.25u10 . 0  2... 0  0. 0  0.5u 4. 0  0. 0  2.25u 8.5u8. 0  0.25u 4. the last equation (5) becomes-  0.25u 5.

0575 . Take  x  h  .C  is   u=x(1‐x)    when t=0 &   0  x  1   Solve this equation by Crank‐Nicolson Scheme .1 X=0.0164 .0722 Comparison between the results obtained by Crank-Nicolson and Explicit methods: 0.0  x  1. x  1.0657 .04 0.0740 .0722 .1 X=0.03 0.t) 0.06 Explicit 0.01 0 0 0.0740 j=1 0 .  Solution:   . X= 0.0411 .2 0.25 .1 X=0. t  0                                                                                                    (1)  t x u 1 B. t>0      (ii)       u.07 C-N 0.0247 .05 u(x.C   (i) u=0 at x=0.0493 .1 X=0.0247 . X=0.0411 .0164 .0656 .02 0.4 0.1 X=0.1 X=0.0329 .0575 . employing central‐difference for the boundary  conditions.0082 .0493 .6 0.1  & r=0.1 j=0 0 .8 1 x   Example 2:  Consider the PDE as follows: u  2u    x 2 .1 X=0.0329 .1 X=0. t  0   x 2 I.08 0.1 X=0.0082 .

21.025iu i 1.3.4. j 1  ( 2  .24.16.e. j  u9..5.0  u (0. u1. j  irhui 1. u2... j 1  u 9. j  .      0  x  1    u0.25   u6.0  u (0.C is  :    u=0 at x=0 for  t   u 0. j 1  2.0  0. j 1  ..5u10 . j     Putting  r=.1u10.. j  ui 1.0  u (0. j 1 ui 1.25u11.we get   . 0)  0. u4. j 1  ui ..25u 9.025iu i 1. j      k 2  h2 h2     irhui 1.0  0.. 0)  0. u7. j  hu10..C at x=1 is:   u t 2   Now apply central difference formula here..u 0. j  (2  2irh)ui . . j  u11. j (4)                                                                                                                                             Put i=10 in equation (2)  (5)   .25 and h=.1.0  u (0.0  0..n  0   u 1 nd  2  B.5u10 .  true for all values of j                                   (3)  u11.05i )ui . 2  u 0.0  0 Now Ist  B.0  u (0. j      .. j  . u8. j  u9.025iu i 1. j ih  ui1.09. j 1  ui .  i=10  u11. j                  2h 2 At  x=1  i . j  1..05i )ui . u9. j 1  2ui . j  2ui . 0)  0.16 u3. j 1  . j  ui 1. j 1  irhui 1. j  u9.1 .25u11. 0)  0. j 1  .025iui 1. j   hu10.1  u 0 .. j  ui 1.24. j 1  (2  2irh)ui . j  . 0)  0.0)=x(1‐x).C is  u(x. j  ui 1. u10.2. j                                                                  . j  . u5..25u 9.. we get  ui 1. j  ( 2  .21. j ( 2)                      I.0  u (0. j   hui .. j 1  ui 1.0  0. j 1  .. j 1  irhui1.09..3  . 0)  0.1u10 .Here we approximate the given equation by C‐N Scheme as  ui .

j  and  u11.35u7  0.2.025u 2  0.525u10 . u5  u5. u9  u9.1  0.4u8  0. we get  2.0355 2nd time level  Substitute i =1.5u9  2.175u6  2.2370   u7  u7.               we get   .2.475u10 .1u3  2.3.075u 4  0.05u1  2.2085 u 4  u 4.1u5  0.045   After solving  these equations.4185  0.1  0.1755   Put j = 0 in equation (6):   0.2u7  2.1  0.15u5  2.1u 2  0. u6  u6.45u9  0.1  0.2u9  0.1  0.477  0.225u10  0.125u 4  2.478  0.316  0. u3  u3.05u1  0.4975  0.1590.319  0.1  0. we get  . j                                                                                                     (6)            At Ist time level:   Putting  i=1. j 1  .125u6  0.075u 2  2.1  .…………9 & j=0 in (2). j 1  from equation (5) .2475.2065.05u3  0.using equation (3) and equation (4). j 1  2.4165  0.175u8  0.1795  0.………. j  1.25u5  0.15u3  0.0895.525u10  0.20u 4  0.2380. we get  u1  u1.1563.Now eliminate  u11.225u8  2.0892 u10  u10.9 & j =1 in equation (2).1  0.1  .5u 9. u8  u8.5u 9. u 2  u 2.3u6  0.1  .15u7  0.

we get  u1  u1. u  2  u 2. X=0. u6  u6.2450.1580. u9  u9.05u3  0.1 X=0.1 X=0.125u6  0.0890.2032 . 2  .471  0.025u 2  0.2360 .2360.1u3  2.0569   .2475 .2070 u 4  u 4.4155  0.4096  0.15u3  .1 X=0.09696 After solving  these equation. 2  .1 X=0. 2  .05u1  0.3092  0.225u10  0. u3  u3. 2  .2u 4  0. 2  .1 X=0.1 X=0. 2.0569 Thus.1785  0.1u5  0.1u 2  0.1580 . 2  .225u8  2.05u1  2.15u7  0. u8  u8.075u 2  2.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.2u7  2.30u6  0.2070 .35u7  0.075u 4  0.0355 j=2 0 .5u9  2.20u9  0. u5  u5  .0890 .175u6  2.2065 .0895 . 2  . 2  .1563 .2380 .1 j=1 0 .1536.175u8  0.2032.0892 .2370 .4925  0.45u9  0.1 X=0.125u 4  2.1536 .525u10  .1 X=0.0969 u10  u10.2340 .317  0.25u5  0.0969 . 2  .1 X=0. 2  .1590 .15u5  2.2340   u7  u7 .2450 .474  0.1814          Put j =1 in equation (6)  .2085 .40u8  0.

.