Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Diffusion is one of the simplest non-equilibrium processes. It describes the transport of heat [52, 95] and the time evolution of differences in substance concentrations [82]. In this chapter, the one-dimensional diffusion equation

$$\begin{aligned} \frac{\partial}{\partial t}f(t,x)= D\frac{\partial^{2}}{\partial x^{2}}f(t,x)+S(t,x) \end{aligned}$$
(19.1)

is semi-discretized with finite differences. The time integration is performed with three different Euler methods. The explicit Euler method is conditionally stable only for small Courant number \(\alpha =\frac{D\Delta t}{\Delta x^{2}}< 1/2\), which makes very small time steps necessary. The fully implicit method is unconditionally stable but its dispersion deviates largely from the exact expression. The Crank-Nicolson method is also unconditionally stable. However, it is more accurate and its dispersion relation is closer to the exact one. Extension to more than one dimension is easily possible, but the numerical effort increases drastically as there is no formulation involving simple tridiagonal matrices like in one dimension. The split operator approximation uses the one-dimensional method independently for each dimension. It is very efficient with almost no loss in accuracy. In a computer experiment the different schemes are compared for diffusion in two dimensions.

1 Particle Flux and Concentration Changes

Let f(x,t) denote the concentration of a particle species and J the corresponding flux of particles. Consider a small cube with volume h 3 (Fig. 19.1). The change of the number of particles within this volume is given by the integral form of the conservation law (11.10)

$$\begin{aligned} \frac{\partial}{\partial t}\int_{V}dV\, f(\mathbf {r},t)+ \oint_{\partial V}\mathbf {J}(\mathbf {r},t)\,d\mathbf {A}=\int_{V}dV\,S(\mathbf {r},t) \end{aligned}$$
(19.2)

where the source term S(r) accounts for creation or destruction of particles due to for instance chemical reactions. In Cartesian coordinates we have

$$\begin{aligned} \begin{aligned}[b] &\int_{x-h/2}^{x+h/2}dx'\int_{y-h/2}^{y+h/2}dy'\int_{z-h/2}^{z+h/2}dz' \, \biggl(\frac{\partial}{\partial t}f\bigl(x',y',z',t \bigr)-S\bigl(x',y',z',t\bigr) \biggr) \\ &\quad {}+\int_{x-h/2}^{x+h/2}dx'\int _{y-h/2}^{y+h/2}dy'\biggl(J_{z} \biggl(x',y',z-\frac{h}{2}\biggr)-J_{z} \biggl(x',y',z+\frac{h}{2} \biggr)\biggr) \\ &\quad {} +\int_{x-h/2}^{x+h/2}dx'\int _{z-h/2}^{z+h/2}dz' \biggl(J_{y} \biggl(x',y-\frac{h}{2},z'\biggr)-J_{y} \biggl(x',y+\frac{h}{2},z' \biggr)\biggr) \\ &\quad {}+\int_{z-h/2}^{z+h/2}dz'\int _{y-h/2}^{y+h/2}dy' \biggl(J_{z}\biggl(x- \frac{h}{2},y',z'\biggr)-J_{z}\biggl(x+\frac{h}{2},y',z' \biggr)\biggr )=0. \end{aligned} \end{aligned}$$
(19.3)

In the limit of small h this turns into the differential form of the conservation law

$$\begin{aligned} h^{3} \biggl(\frac{\partial}{\partial t}f(x,y,z,t)-S(x,y,z,t) \biggr)+h^{2} \biggl(h\frac{\partial J_{x}}{\partial x}+h\frac{\partial J_{y}}{\partial y}+h \frac{\partial J_{z}}{\partial z} \biggr)=0 \end{aligned}$$
(19.4)

or after division by h 3

$$\begin{aligned} \frac{\partial}{\partial t}f(\mathbf {r},t)=-\operatorname{div} \mathbf {J}(\mathbf {r},t)+S(\mathbf {r},t). \end{aligned}$$
(19.5)

Within the framework of linear response theory the flux is proportional to the gradient of f (Fig. 19.2),

$$\begin{aligned} \mathbf{J}=-D\operatorname{grad}f. \end{aligned}$$
(19.6)

Together we obtain the diffusion equation

$$\begin{aligned} \frac{\partial f}{\partial t}=\operatorname{div}(D\operatorname{grad}f)+S \end{aligned}$$
(19.7)

which in the special case of constant D simplifies to

$$\begin{aligned} \frac{\partial f}{\partial t}=D\Delta f+S. \end{aligned}$$
(19.8)
Fig. 19.1
figure 1

Flux through a volume element

Fig. 19.2
figure 2

Diffusion due to a concentration gradient

2 Diffusion in One Dimension

We will use the finite differences method which works well if the diffusion constant D is constant in time and space. We begin with diffusion in one dimension and use regular grids t n =nΔt, x m =mΔx, \(f_{m}^{n}=f(t_{n},x_{m})\) and the discretized second derivative

$$\begin{aligned} \frac{\partial^{2}f}{\partial x^{2}}=\frac{f(x+\Delta x)+f(x-\Delta x)-2f(x)}{\Delta x^{2}}+O\bigl(\Delta x^{2}\bigr) \end{aligned}$$
(19.9)

to obtain the semi-discrete diffusion equation

$$\begin{aligned} \dot{f}(t,x_{m})=\frac{D}{\Delta x^{2}} \bigl (f(t,x_{m+1})+f(t,x_{m-1})-2f(t,x_{m}) \bigr)+S(t,x_{m}) \end{aligned}$$
(19.10)

or in matrix notation

$$\begin{aligned} \dot{\mathbf {f}}(t)=\frac{D}{\Delta x^{2}}M\mathbf {f}(t)+\mathbf {S}(t) \end{aligned}$$
(19.11)

with the tridiagonal matrix

$$\begin{aligned} M= \left( \begin{array}{ccccc} -2 & 1\\ 1 & -2 & 1\\ & \ddots& \ddots& \ddots\\ & & 1 & -2 & 1\\ & & & 1 & -2 \end{array} \right). \end{aligned}$$
(19.12)

Boundary conditions can be taken into account by introducing extra boundary points x 0,x M+1 (Fig. 19.3).

Fig. 19.3
figure 3

(Boundary conditions for 1-dimensional diffusion)  Additional boundary points x 0,x M+1 are used to realize the boundary conditions. (a) Dirichlet boundary conditions: the function values at the boundary are given f(t,x 0)=ξ 0(t), \(\frac{\partial^{2}}{\partial x^{2}}f(x_{1})=\frac{1}{\Delta x^{2}} (f(x_{2})-2f(x_{1})+\xi_{0}(t) )\) or f(t,x M+1)=ξ M+1(t), \(\frac{\partial^{2}}{\partial x^{2}}f(x_{M})=\frac{1}{\Delta x^{2}} (f(x_{M-1})-2f(x_{M})+\xi _{M+1}(t))\). (b) Neumann boundary conditions: the flux through the boundary is given, hence the derivative \(\frac{\partial f}{\partial x}\) at the boundary \(f(t,x_{0})=f(t,x_{2})+2\frac{\Delta x}{D}J_{1}(t)\), \(\frac{\partial^{2}}{\partial x^{2}}f(x_{1})=\frac{1}{\Delta x^{2}} (2f(x_{2})-2f(x_{1})+2\frac{\Delta x}{D}J_{1}(t) )\) or \(f(t,x_{M+1})=f(t,x_{M-1})-\frac{2\Delta x}{D}J_{M}(t)\), \(\frac{\partial^{2}}{\partial x^{2}}f(x_{M})=\frac{1}{\Delta x^{2}} (2f(x_{M-1})-2f(x_{M})-\frac{2\Delta x}{D}J_{M}(t))\). (cNo-flow boundary conditions: there is no flux through the boundary, hence the derivative \(\frac{\partial f}{\partial x}=0\) at the boundary f(t,x 0)=f(t,x 2), \(\frac{\partial^{2}}{\partial x^{2}}f(x_{1})=\frac{1}{\Delta x^{2}} (2f(x_{2})-2f(x_{1}))\) or f(t,x M )=f(t,x M−2), \(\frac{\partial^{2}}{\partial x^{2}}f(x_{M})=\frac{1}{\Delta x^{2}} (2f(x_{M-1})-2f(x_{M}) )\)

2.1 Explicit Euler (Forward Time Centered Space) Scheme

A simple Euler step (Sect. 12.3) makes the approximation

$$\begin{aligned} f_{m}^{n+1}-f_{m}^{n}= \dot{f}(t_{n},x_{m})\Delta t=D\frac{\Delta t}{\Delta x^{2}} \bigl(f_{m+1}^{n}+f_{m-1}^{n}-2f_{m}^{n} \bigr)+S_{m}^{n}\Delta t. \end{aligned}$$
(19.13)

For homogeneous boundary conditions f=0 this becomes in matrix form

$$\begin{aligned} \left( \begin{array}{c} f_{1}^{n+1}\\ \vdots\\ f_{M}^{n+1} \end{array} \right)=A \left( \begin{array}{c} f_{1}^{n}\\ \vdots\\ f_{M}^{n} \end{array} \right)+ \left( \begin{array}{c} S_{1}^{n}\Delta t\\ \vdots\\ S_{M}^{n}\Delta t \end{array} \right) \end{aligned}$$
(19.14)

with the tridiagonal matrix

$$\begin{aligned} A= \left( \begin{array}{ccccc} 1-2D\frac{\Delta t}{\Delta x^{2}} & D\frac{\Delta t}{\Delta x^{2}}\\ D\frac{\Delta t}{\Delta x^{2}} & 1-2D\frac{\Delta t}{\Delta x^{2}}\\ & \ddots& \ddots& \ddots\\ & & D\frac{\Delta t}{\Delta x^{2}} & 1-2D\frac{\Delta t}{\Delta x^{2}} & D\frac{\Delta t}{\Delta x^{2}}\\ & & & D\frac{\Delta t}{\Delta x^{2}} & 1-2D\frac{\Delta t}{\Delta x^{2}} \end{array} \right)=1+\alpha M \end{aligned}$$
(19.15)

where α is the Courant number for diffusion

$$\begin{aligned} \alpha=D\frac{\Delta t}{\Delta x^{2}}. \end{aligned}$$
(19.16)

The eigenvalues of M are (compare (18.30))

$$\begin{aligned} \lambda=-4\sin^{2}\biggl(\frac{k\Delta x}{2}\biggr) \quad \mbox{with }k \Delta x=\frac{\pi}{M+1},\frac{2\pi}{M+1},\ldots,\frac{M\pi}{M+1} \end{aligned}$$
(19.17)

and hence the eigenvalues of A are given by

$$\begin{aligned} 1+\alpha\lambda=1-4\alpha\sin^{2}\frac{k\Delta x}{2}. \end{aligned}$$
(19.18)

The algorithm is stable if

$$\begin{aligned} |1+\alpha\lambda|<1\quad\mbox{for all }\lambda \end{aligned}$$
(19.19)

which holds if

$$\begin{aligned} -1<1-4\alpha\sin^{2}\frac{k\Delta x}{2}<1. \end{aligned}$$
(19.20)

The maximum of the sine function is \(\sin(\frac{M\pi}{2(M+1)})\approx1\). Hence the right hand inequation is satisfied and from the left one we have

$$\begin{aligned} -1<1-4\alpha. \end{aligned}$$
(19.21)

The algorithm is stable for

$$\begin{aligned} \alpha=D\frac{\Delta t}{\Delta x^{2}}<\frac{1}{2}. \end{aligned}$$
(19.22)

The dispersion relation follows from inserting a plane wave ansatz

$$\begin{aligned} \mathrm {e}^{\mathrm {i}\omega\Delta t}=1-4\alpha\sin^{2} \biggl(\frac{k\Delta x}{2} \biggr). \end{aligned}$$
(19.23)

For α>1/4 the right hand side changes sign at

$$\begin{aligned} k_{c}\Delta x=2\operatorname{arcsin}\sqrt{\frac{1}{4\alpha}}. \end{aligned}$$
(19.24)

The imaginary part of ω has a singularity at k c and the real part has a finite value of π for k>k c (Fig. 19.4 on page 356). Deviations from the exact dispersion

$$\begin{aligned} \omega=\mathrm {i}k^{2} \end{aligned}$$
(19.25)

are large, except for very small k.

Fig. 19.4
figure 4

(Dispersion of the explicit Euler method)  The dispersion of the explicit method is shown for different values of the Courant number α and compared to the exact dispersion (dashed curve). The imaginary part of ω shows a singularity for α>1/4. Above the singularity ω is complex valued

2.2 Implicit Euler (Backward Time Centered Space) Scheme

Next we use the backward difference

$$\begin{aligned} f_{m}^{n+1}-f_{m}^{n} =& \dot{f}(t_{n+1},x_{m})\Delta t \\ =& D\frac{\partial^{2}f}{\partial x^{2}}(t_{n+1},x_{m})\Delta t+S(t_{n+1},x_{m}) \Delta t \end{aligned}$$
(19.26)

to obtain the implicit method

$$\begin{aligned} f_{m}^{n+1}-\alpha\bigl(f_{m+1}^{n+1}+f_{m-1}^{n+1}-2f_{m}^{n+1} \bigr)=f_{m}^{n}+S_{m}^{n+1}\Delta t \end{aligned}$$
(19.27)

or in matrix notation

$$\begin{aligned} A\mathbf {f}_{n+1}=\mathbf {f}_{n}+\mathbf {S}_{n+1}\Delta t \quad \mbox{with }A=1-\alpha M \end{aligned}$$
(19.28)

which can be solved formally by

$$\begin{aligned} \mathbf {f}_{n+1}=A^{-1}\mathbf {f}_{n}+A^{-1} \mathbf {S}_{n+1}\Delta t. \end{aligned}$$
(19.29)

The eigenvalues of A are

$$\begin{aligned} \lambda(A)=1+4\alpha\sin^{2}\frac{k\Delta x}{2}>1 \end{aligned}$$
(19.30)

and the eigenvalues of A −1

$$\begin{aligned} \lambda\bigl(A^{-1}\bigr)=\lambda(A)^{-1}= \frac{1}{1+4\alpha\sin^{2}\frac{k\Delta x}{2}}. \end{aligned}$$
(19.31)

The implicit method is unconditionally stable since

$$\begin{aligned} \bigl|\lambda\bigl(A^{-1}\bigr)\bigr|<1. \end{aligned}$$
(19.32)

The dispersion relation of the implicit scheme follows from

$$\begin{aligned} \mathrm {e}^{\mathrm {i}\omega\Delta t}=\frac{1}{1+4\alpha\sin^{2} (\frac{k\Delta x}{2} )}. \end{aligned}$$
(19.33)

There is no singularity and ω is purely imaginary. Still, deviations from the exact expression are large (Fig. 19.5 on page 357).

Fig. 19.5
figure 5

(Dispersion of the implicit Euler method)  The dispersion of the fully implicit method is shown for two different values of the Courant number α and compared to the exact dispersion (dashed curve)

Formally a matrix inversion is necessary. Numerically it is much more efficient to solve the tridiagonal system of equations (page 69).

$$\begin{aligned} (1-\alpha M)f(t_{n+1})=f(t_{n})+S(t_{n+1})\Delta t. \end{aligned}$$
(19.34)

2.3 Crank-Nicolson Method

The Crank-Nicolson method [65] which is often used for diffusion problems, combines implicit and explicit methods. It uses the Heun method (Sect. 12.5) for the time integration

$$\begin{aligned} f_{m}^{n+1}-f_{m}^{n} =&\frac{\Delta t}{2} \biggl(\frac{\partial f}{\partial t}(t_{n+1},x_{m})+\frac{\partial f}{\partial t}(t_{n},x_{m}) \biggr) \end{aligned}$$
(19.35)
$$\begin{aligned} =&D\frac{\Delta t}{2} \biggl(\frac{\partial^{2}f}{\partial x^{2}}(t_{n+1},x_{m})+ \frac{\partial^{2}f}{\partial x^{2}}(t_{n},x_{m}) \biggr) \\ &{} + \bigl(S(t_{n},x_{m})+S(t_{n+1},x_{m}) \bigr)\frac{\Delta t}{2} \end{aligned}$$
(19.36)
$$\begin{aligned} =& D\frac{\Delta t}{2} \biggl(\frac {f_{m+1}^{n}+f_{m-1}^{n}-2f_{m}^{n}}{\Delta x^{2}}+\frac {f_{m}^{n+1}+f_{m-1}^{n+1}-2f_{m}^{n+1}}{\Delta x^{2}} \biggr) \\ &{} + \frac{S_{m}^{n}+S_{m}^{n+1}}{2}\Delta t. \end{aligned}$$
(19.37)

This approximation is second order both in time and space and becomes in matrix notation

$$\begin{aligned} \biggl(1-\frac{\alpha}{2}M\biggr)\mathbf {f}_{n+1}=\biggl(1+ \frac{\alpha}{2}M\biggr)\mathbf {f}_{n}+\frac{\mathbf {S}_{n}+\mathbf {S}_{n+1}}{2}\Delta t \end{aligned}$$
(19.38)

which can be solved by

$$\begin{aligned} \mathbf {f}_{n+1}= \biggl(1-\frac{\alpha}{2}M\biggr)^{-1} \biggl(1+\frac{\alpha}{2}M\biggr)\mathbf {f}_{n} +\biggl(1- \frac{\alpha}{2}M\biggr)^{-1}\frac{\mathbf {S}_{n}+\mathbf {S}_{n+1}}{2}\Delta t. \end{aligned}$$
(19.39)

Again it is numerically much more efficient to solve the tridiagonal system of equations (19.38) than to calculate the inverse matrix.

The eigenvalues of this method are

$$\begin{aligned} \lambda=\frac{1+\frac{\alpha}{2}\mu}{1-\frac{\alpha}{2}\mu} \quad \mbox{with }\mu=-4\sin^{2} \frac{k\Delta x}{2}\in[-4,0]. \end{aligned}$$
(19.40)

Since αμ<0 it follows

$$\begin{aligned} 1+\frac{\alpha}{2}\mu<1-\frac{\alpha}{2}\mu \end{aligned}$$
(19.41)

and hence

$$\begin{aligned} \lambda<1. \end{aligned}$$
(19.42)

On the other hand we have

$$\begin{aligned} 1>-1& \end{aligned}$$
(19.43)
$$\begin{aligned} 1+\frac{\alpha}{2}\mu>-1+\frac{\alpha}{2}\mu& \end{aligned}$$
(19.44)
$$\begin{aligned} \lambda>-1.& \end{aligned}$$
(19.45)

This shows that the Crank-Nicolson method is stable [251]. The dispersion follows from

$$\begin{aligned} \mathrm {e}^{\mathrm {i}\omega\Delta t}=\frac{1-2\alpha\sin^{2} (\frac{k\Delta x}{2} )}{1+2\alpha\sin^{2} (\frac{k\Delta x}{2} )}. \end{aligned}$$
(19.46)

For α>1/2 there is a sign change of the right hand side at

$$\begin{aligned} k_{c}\Delta x=2\mbox{arcsin}\sqrt{\frac{1}{2\alpha}}. \end{aligned}$$
(19.47)

The imaginary part of ω has a singularity at k c and ω is complex valued for k>k c (Fig. 19.6 on page 359).

Fig. 19.6
figure 6

(Dispersion of the Crank-Nicolson method)  The dispersion of the Crank-Nicolson method is shown for different values of the Courant number α and compared to the exact dispersion (dashed curve). The imaginary part of ω shows a singularity for α>1/2. Above the singularity ω is complex valued. The exact dispersion is approached quite closely for α≈1/2

2.4 Error Order Analysis

Taylor series gives for the exact solution

$$\begin{aligned} \Delta f_{\mathit{exact}} =& \Delta t\dot{f}(t,x)+\frac{\Delta t^{2}}{2}\ddot{f}(t,x)+ \frac{\Delta t^{3}}{6}\frac{\partial^{3}}{\partial t^{3}}f(t,x)+\cdots \\ =& \Delta t \bigl[Df''(t,x)+S(t,x) \bigr] \\ &{} + \frac{\Delta t^{2}}{2} \bigl[D\dot{f}''(t,x)+\dot{S}(t,x) \bigr]+\cdots \end{aligned}$$
(19.48)

whereas for the explicit method

$$\begin{aligned} \Delta f_{\mathit{expl}} =& \alpha Mf(t,x)+S(t,x)\Delta t \\ =& D\frac{\Delta t}{\Delta x^{2}} \bigl(f(t,x+\Delta x)+f(t,x-\Delta x)-2f(t,x) \bigr)+S(t,x) \Delta t \\ =& D\frac{\Delta t}{\Delta x^{2}} \biggl(\Delta x^{2}f''(t,x)+ \frac{\Delta x^{4}}{12}f''''(t,x)+ \cdots\biggr)+S(t,x)\Delta t \\ =& \Delta f_{\mathit{exact}}+\frac{D\Delta t\Delta x^{2}}{12}f''''(t,x)- \frac{\Delta t^{2}}{2}\ddot{f}(t,x)+\cdots \end{aligned}$$
(19.49)

and for the implicit method

$$\begin{aligned} \Delta f_{\mathit{impl}} =& \alpha Mf(t+\Delta t,x)+S(t+\Delta t,x)\Delta t \\ =& D\frac{\Delta t}{\Delta x^{2}} \bigl(f(t+\Delta t,x+\Delta x)+f(t+\Delta t,x-\Delta x)-2f(t+\Delta t,x) \bigr) \\ &{} +S(t+\Delta t,x)\Delta t \\ =& D\frac{\Delta t}{\Delta x^{2}} \biggl(\Delta x^{2}f''(t,x)+ \frac{\Delta x^{4}}{12}f''''(t,x)+ \cdots\biggr) \\ &{} +S(t,x)\Delta t+D\frac{\Delta t^{2}}{\Delta x^{2}} \biggl(\Delta x^{2} \dot{f}''(t,x)+\frac{\Delta x^{4}}{12}\dot{f}''''(t,x)+ \cdots\biggr) \\ &{} +\dot{S}(t,x)\Delta t^{2} \\ =& \Delta f_{\mathit{exact}}+D\frac{\Delta t\Delta x^{2}}{12}f''''(t,x)+ \frac{1}{2}\Delta t^{2}\ddot{f}(t,x)+\cdots. \end{aligned}$$
(19.50)

The Crank-Nicolson method has higher accuracy in Δt:

$$\begin{aligned} \Delta f_{\mathit{CN}}=\frac{\Delta f_{\mathit{expl}}+\Delta f_{\mathit{impl}}}{2}=\frac{D\Delta t\Delta x^{2}}{12}f''''(t,x)- \frac{\Delta t^{3}}{6}\frac{\partial^{3}f}{\partial t^{3}}+\cdots. \end{aligned}$$
(19.51)

2.5 Finite Element Discretization

In one dimension discretization with finite differences is very similar to discretization with finite elements, if Galerkin’s method is applied on a regular grid (Chap. 11). The only difference is the non-diagonal form of the mass-matrix which has to be applied to the time derivative [88]. Implementation of the discretization scheme (11.170) is straightforward. The semi-discrete diffusion equation becomes

$$\begin{aligned} \begin{aligned}[b] & \frac{\partial}{\partial t} \biggl(\frac{1}{6}f(t,x_{m-1})+ \frac{2}{3}f(t,x_{m})+\frac{1}{6}f(t,x_{m+1}) \biggr) \\ & \quad =\frac{D}{\Delta x^{2}} \bigl(f(t,x_{m+1})+f(t,x_{m-1})-2f(t,x_{m}) \bigr)+S(t,x_{m}) \end{aligned} \end{aligned}$$
(19.52)

or in matrix form

$$\begin{aligned} \biggl(1+\frac{1}{6}M \biggr)\dot{\mathbf {f}}(t)=\frac{D}{\Delta x^{2}}M \mathbf {f}(t)+\mathbf {S}(t). \end{aligned}$$
(19.53)

This can be combined with the Crank-Nicolson scheme to obtain

$$\begin{aligned} \biggl(1+\frac{1}{6}M \biggr) (\mathbf {f}_{n+1}- \mathbf {f}_{n} )= \biggl(\frac{\alpha}{2}M\mathbf {f}_{n}+ \frac{\alpha}{2}M\mathbf {f}_{n+1} \biggr)+\frac{\Delta t}{2} ( \mathbf {S}_{n}+\mathbf {S}_{n+1} ) \end{aligned}$$
(19.54)

or

$$\begin{aligned} \biggl[1+ \biggl(\frac{1}{6}-\frac{\alpha}{2} \biggr)M \biggr] \mathbf {f}_{n+1}= \biggl[1+ \biggl(\frac{1}{6}+\frac{\alpha}{2} \biggr)M \biggr]\mathbf {f}_{n}+\frac{\Delta t}{2} (\mathbf {S}_{n}+ \mathbf {S}_{n+1} ). \end{aligned}$$
(19.55)

3 Split-Operator Method for Multidimensions

The simplest discretization of the Laplace operator in 3 dimensions is given by

$$\begin{aligned} \Delta f =& \biggl(\frac{\partial^{2}}{\partial x^{2}}+\frac{\partial ^{2}}{\partial y^{2}}+\frac{\partial^{2}}{\partial z^{2}} \biggr)f(t,x,y,z) \\ =& \frac{1}{\Delta x^{2}}(M_{x}+M_{y}+M_{z})f(t,x,y,z) \end{aligned}$$
(19.56)

where

$$\begin{aligned} \frac{1}{\Delta x^{2}}M_{x}f(t,x,y,z)=\frac{f(t,x+\Delta x,y,z)+f(t,x-\Delta x,y,z)-2f(t,x,y,z)}{\Delta x^{2}} \end{aligned}$$
(19.57)

etc. denote the discretized second derivatives. Generalization of the Crank-Nicolson method for the 3-dimensional problem gives

$$\begin{aligned} f(t_{n+1})=\biggl(1-\frac{\alpha}{2}M_{x}- \frac{\alpha}{2}M_{y}-\frac{\alpha}{2}M_{z} \biggr)^{-1}\biggl(1+\frac{\alpha}{2}M_{x}+ \frac{\alpha}{2}M_{y}+\frac{\alpha}{2}M_{z}\biggr)f(t). \end{aligned}$$
(19.58)

But now the matrices representing the operators M x , M y , M z are not tridiagonal. To keep the advantages of tridiagonal matrices we use the approximations

$$\begin{aligned} \biggl(1+\frac{\alpha}{2}M_{x}+\frac{\alpha}{2}M_{y}+ \frac{\alpha}{2}M_{z}\biggr) \approx&\biggl(1+\frac{\alpha}{2}M_{x} \biggr) \biggl(1+\frac{\alpha}{2}M_{y}\biggr) \biggl(1+ \frac{\alpha}{2}M_{z}\biggr) \\ \end{aligned}$$
(19.59)
$$\begin{aligned} \biggl(1-\frac{\alpha}{2}M_{x}-\frac{\alpha}{2}M_{y}- \frac{\alpha}{2}M_{z}\biggr) \approx&\biggl(1-\frac{\alpha}{2}M_{x} \biggr) \biggl(1-\frac{\alpha}{2}M_{y}\biggr) \biggl(1- \frac{\alpha}{2}M_{z}\biggr) \end{aligned}$$
(19.60)

and rearrange the factors to obtain

$$\begin{aligned} f(t_{n+1}) =&\biggl(1-\frac{\alpha}{2}M_{x} \biggr)^{-1}\biggl(1+\frac{\alpha}{2}M_{x}\biggr) \biggl(1- \frac{\alpha}{2}M_{y}\biggr)^{-1}\biggl(1+ \frac{\alpha}{2}M_{y}\biggr) \\ &{} \times \biggl(1-\frac{\alpha}{2}M_{z} \biggr)^{-1}\biggl(1+\frac{\alpha}{2}M_{z}\biggr) f(t_{n}) \end{aligned}$$
(19.61)

which represents successive application of the 1-dimensional scheme for the three directions separately. The last step was possible since the operators M i and M j for different directions ij commute. For instance

$$\begin{aligned} M_{x}M_{y}f =& M_{x} \bigl(f(x,y+\Delta x)+f(x,y-\Delta x)-2f(x,y) \bigr) \\ =& \bigl(f(x+\Delta x,y+\Delta y)+f(x-\Delta x,y+\Delta x) \\ &{} -2f(x,y+\Delta x)+f(x+\Delta x,y-\Delta x) \\ &{} +f(x-\Delta x,y-\Delta x)-2f(x,y-\Delta x) \\ &{} -2f(x+\Delta x,y)-2f(x-\Delta x,y)+4f(x,y) \bigr) \\ =&M_{y}M_{x}f. \end{aligned}$$
(19.62)

The Taylor series of (19.58) and (19.61) coincide up to second order with respect to αM i :

$$\begin{aligned} &\biggl(1-\frac{\alpha}{2}M_{x}-\frac{\alpha}{2}M_{y}- \frac{\alpha}{2}M_{z}\biggr)^{-1}\biggl(1+ \frac{\alpha}{2}M_{x}+\frac{\alpha}{2}M_{y}+ \frac{\alpha}{2}M_{z}\biggr) \\ &\quad =1+\alpha(M_{x}+M_{y}+M_{z})+ \frac{\alpha^{2}}{2}(M_{x}+M_{y}+M_{z})^{2}+O \bigl(\alpha^{3}\bigr) \end{aligned}$$
(19.63)
$$\begin{aligned} &\biggl(1-\frac{\alpha}{2}M_{x}\biggr)^{-1}\biggl(1+ \frac{\alpha}{2}M_{x}\biggr) \biggl(1-\frac{\alpha}{2}M_{y} \biggr)^{-1}\biggl(1+\frac{\alpha}{2}M_{y}\biggr) \\ &\qquad {}\times \biggl(1-\frac{\alpha}{2}M_{z}\biggr)^{-1}\biggl(1+\frac{\alpha}{2}M_{z}\biggr) \\ &\quad =\biggl(1+\alpha M_{x}+\frac{\alpha^{2}M_{x}^{2}}{2}\biggr) \biggl (1+\alpha M_{y}+\frac{\alpha^{2}M_{y}^{2}}{2}\biggr) \biggl(1+\alpha M_{z}+ \frac{\alpha^{2}M_{z}^{2}}{2}\biggr)+O\bigl(\alpha^{3}\bigr) \\ &\quad =1+\alpha(M_{x}+M_{y}+M_{z})+ \frac{\alpha^{2}}{2}(M_{x}+M_{y}+M_{z})^{2}+O \bigl(\alpha^{3}\bigr). \end{aligned}$$
(19.64)

Hence we have

$$\begin{aligned} f_{n+1} =&\biggl(1+D\Delta t\biggl(\Delta+\frac{\Delta x^{2}}{12} \Delta^{2}+\cdots\biggr)+\frac{D^{2}\Delta t^{2}}{2}\bigl(\Delta^{2}+ \cdots\bigr)\biggr)f_{n} \\ &{} +\biggl(1+\frac{D\Delta t}{2}\Delta+\cdots\biggr)\frac {S_{n+1}+S_{n}}{2}\Delta t \\ =&f_{n}+\Delta t(D\Delta f_{n}+S_{n})+ \frac{\Delta t^{2}}{2}\bigl(D^{2}\Delta^{2}+D\Delta S_{n}+\dot{S}_{n}\bigr) \\ &{} +O\bigl(\Delta t\Delta x^{2},\Delta t^{3}\bigr) \end{aligned}$$
(19.65)

and the error order is conserved by the split operator method.

4 Problems

Problem 19.1

(Diffusion in 2 dimensions)

In this computer experiment we solve the diffusion equation on a two dimensional grid for

  • an initial distribution f(t=0,x,y)=δ x,0 δ y,0

  • a constant source f(t=0)=0, S(t,x,y)=δ x,0 δ y,0

Compare implicit, explicit and Crank-Nicolson method.