Diffusion in multi-dimensions#
Sometimes it can be useful to mix explicit and implicit methods. In 1D, the Crank-Nicholson method is
where on the right-hand side we take the average of the explicit and implicit updates. This method is described as semi-implicit. Also stable for any \(\Delta t\), the advantage of Crank-Nicholson over the fully-implicit method is that it is second order in time instead of first order.
The alternating-direction implicit scheme is a way to solve the 2D diffusion equation
The idea is to split the update into two half timesteps:
In the first step we treat the \(x\)-direction update implicitly and the \(y\)-direction explicitly, and then alternate for the second step.
Exercise: 2D diffusion
Implement this scheme to solve for the time evolution of the temperature profile in a 2D square box that is at \(T=0\) initially. One side of the box is held at \(T=1\) for \(t>0\), the other sides are kept at \(T=0\).