10.2. The Crank-Nicholson Scheme for diffusion#
The Crank-Nicholson scheme was originally designed to solve the diffusion equation (heat conduction)
The scheme is a modification of the FTCS (Forward in time, centered in space) scheme. It uses the forward approximation to the time derivative at \(t^n\) and the average of the centred approximations of the space derivative at \(t^n\) and \(t^{n+1}\).
Another way of looking at (6.3) is that the left hand side (LHS) is a centred approximation of the time derivative at \(t^{n+1/2}\) and the averaging of the spatial derivatives provides an estimate of the spatial derivative at \(t^{n+1/2}\).
The use of the terms at \(t^{n+1}\) poses a complication because these are not known at time \(t^n\). Therefore, the scheme is not an explicit time marching scheme as we have seen so far, but one where the solution is implicit in the scheme itself, hence the designation of implicit scheme. To obtain the unknown values at \(t^{n+1}\), a linear system of equations must be solved.
We can expand (6.3) to obtain
that is a linear system of equations
To find the matrices, you can first insert \(m=0\) into the equation. This will give you the first row in \(A\) and \(B\), respectively. You will find the second row by inserting \(m=1\) and so forth until the last row is found by inserting \(m=L\).
The matrices \(A\) and \(B\) below, represents a case of Dirichlet boundary conditions, \(u(0,t)=u_0^n=0\) and \(u(L,t)=u_L^n=0\). This is why the matrices do not include a first column for \(u_0^{n+1}\) or a last column for \(u_L^{n+1}\).
If you choose boundary conditions where \(u(0,t)\neq 0\) and \(u(L,t)\neq 0\), you will need to consider what value they take, and extend the matrices A and B with one column for \(u_0\) and one for \(u_L\) at either side of the matrices.
In the case \(A\) and \(B\) are tridiagonal, as above, the solution of the linear system (6.4) is expedite. In other cases, iterative methods must be used.
10.2.1. Consistency, stability and convergence#
The scheme has a truncation error \(O(\Delta t^2,\Delta x^2)\), since the spatial derivatives are approximated by a centred formula and the time derivative also, at \(t^{n+1/2}\). The stability of the scheme can be determined by the usual method of assuming a solution of the form \(B^n e^{ikm\Delta x}\) and noting that
and
we arrive at the following amplification factor:
whose norm \(|G|\) is
The scheme is, therefore, unconditionally stable and doesn’t suffer from CFL limitations, unlike the previous explicit schemes.
