6.1. The Crank-Nicholson Scheme for linear advection#
Until now, all schemes have time step limitations in the form of the CFL condition \(c\Delta t/\Delta x \leq 1\). One way to overcome that limitation is to use implicit schemes, where the spatial derivatives are evaluated at \(t^{n+1}\). One such scheme is the Crank-Nicholson scheme, which was, originally designed to solve the diffusion equation (heat conduction). Here, we show the Crank-Nicolson scheme for linear advection:
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.
6.1.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
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.
6.1.2. Application: propagation of top hat function#
To test the scheme, we are going to apply it to the propagation of the top hat signal.
The Crank-Nicholson scheme is implemented in the following Python function:
In the next code snippet, we set the discretization parameters and integrate the initial condition with the Crank-Nicholson scheme:
Number of time steps = 30
Number of grid points = 100
Time step = 0.010000
Grid size = 0.010000
CFL number = 0.750000
The solution at the end of the integration is shown below:
 
The unconditional stability of the implicit Crank-Nicholson scheme is its great advantage, but it’s use in the advection equation has unwanted consequences in the form of dispersion and errors in the phase speed. The comparison with the Leapfrog scheme shows that the scheme, although unconditionally stable still suffers from dispersive behaviour.
From (6.5), we can write
or
Substituting (6.5), we obtain the following expression for the phase speed \(c_F\) of the numerical solution
For shortwaves in the numerical solution, e.g. the \(2\Delta x\) wavelength, we have \(k = \pi/\Delta x\) and \(\theta = \tan^{-1} (\sigma/2 \sin \pi)=0\), which means the shortwave is stationary. For large wavelength, we have \(k \Delta x \ll 1\) and
For small \(\Delta t\), we’ll have \(\theta = \frac{ak \Delta t}{2} \) and \(a_F = a\). But for large \(\Delta t\), it will be \(\theta = \pi/2\) and \(a_F = \pi/\Delta t \lambda\), which is independent of \(a\).
Therefore, either for shortwave components or long wavelengths we will have errors in the phase speed of the numerical solution that make the use of the Crank-Nicholson scheme dubious for the linear advection problem.
