Diffusion in multi-dimensions

Diffusion in multi-dimensions#

Sometimes it can be useful to mix explicit and implicit methods. In 1D, the Crank-Nicholson method is

Tin+1Tin=α[12(Ti1n+12Tin+1+Ti+1n+1)+12(Ti1n2Tin+Ti+1n)]

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 Δ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

Tt=2Tx2+2Ty2.

The idea is to split the update into two half timesteps:

Ti,jn+1/2=Ti,jn+α2(Ti1,jn+1/22Ti,jn+1/2+Ti+1,jn+1/2+Ti,j1n2Ti,jn+Ti,j+1n)
Ti,jn+1=Ti,jn+1/2+α2(Ti1,jn+1/22Ti,jn+1/2+Ti+1,jn+1/2+Ti,j1n+12Ti,jn+1+Ti,j+1n+1)

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.

[Solution]