Abstract
Diffusion is one of the simplest non-equilibrium processes. It describes the transport of heat and the time evolution of differences in substance concentrations. In this chapter, the one-dimensional diffusion equation 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, 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.
Access provided by Autonomous University of Puebla. Download chapter PDF
Similar content being viewed by others
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
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)
where the source term S(r) accounts for creation or destruction of particles due to for instance chemical reactions. In Cartesian coordinates we have
In the limit of small h this turns into the differential form of the conservation law
or after division by h 3
Within the framework of linear response theory the flux is proportional to the gradient of f (Fig. 19.2),
Together we obtain the diffusion equation
which in the special case of constant D simplifies to
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
to obtain the semi-discrete diffusion equation
or in matrix notation
with the tridiagonal matrix
Boundary conditions can be taken into account by introducing extra boundary points x 0,x M+1 (Fig. 19.3).
2.1 Explicit Euler (Forward Time Centered Space) Scheme
A simple Euler step (Sect. 12.3) makes the approximation
For homogeneous boundary conditions f=0 this becomes in matrix form
with the tridiagonal matrix
where α is the Courant number for diffusion
The eigenvalues of M are (compare (18.30))
and hence the eigenvalues of A are given by
The algorithm is stable if
which holds if
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
The algorithm is stable for
The dispersion relation follows from inserting a plane wave ansatz
For α>1/4 the right hand side changes sign at
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
are large, except for very small k.
2.2 Implicit Euler (Backward Time Centered Space) Scheme
Next we use the backward difference
to obtain the implicit method
or in matrix notation
which can be solved formally by
The eigenvalues of A are
and the eigenvalues of A −1
The implicit method is unconditionally stable since
The dispersion relation of the implicit scheme follows from
There is no singularity and ω is purely imaginary. Still, deviations from the exact expression are large (Fig. 19.5 on page 357).
Formally a matrix inversion is necessary. Numerically it is much more efficient to solve the tridiagonal system of equations (page 69).
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
This approximation is second order both in time and space and becomes in matrix notation
which can be solved by
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
Since αμ<0 it follows
and hence
On the other hand we have
This shows that the Crank-Nicolson method is stable [251]. The dispersion follows from
For α>1/2 there is a sign change of the right hand side at
The imaginary part of ω has a singularity at k c and ω is complex valued for k>k c (Fig. 19.6 on page 359).
2.4 Error Order Analysis
Taylor series gives for the exact solution
whereas for the explicit method
and for the implicit method
The Crank-Nicolson method has higher accuracy in Δt:
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
or in matrix form
This can be combined with the Crank-Nicolson scheme to obtain
or
3 Split-Operator Method for Multidimensions
The simplest discretization of the Laplace operator in 3 dimensions is given by
where
etc. denote the discretized second derivatives. Generalization of the Crank-Nicolson method for the 3-dimensional problem gives
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
and rearrange the factors to obtain
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 i≠j commute. For instance
The Taylor series of (19.58) and (19.61) coincide up to second order with respect to αM i :
Hence we have
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.
References
Y.A. Cengel, Heat transfer—A Practical Approach, 2nd edn. (McGraw-Hill, New York, 2003), p. 26. ISBN 0072458933, 9780072458930
J. Crank, P. Nicolson, Proc. Camb. Philol. Soc. 43, 50 (1947)
A. Fick, Philos. Mag. 10, 30 (1855)
C.A.J. Fletcher, Computational Techniques for Fluid Dynamics, vol. I, 2nd edn. (Springer, Berlin, 1991)
J. Fourier, The Analytical Theory of Heat (Cambridge University Press, Cambridge, 1878), reissued by Cambridge University Press, 2009. ISBN 978-1-108-00178-6
J.W. Thomas, Numerical Partial Differential Equations: Finite Difference Methods. Texts in Applied Mathematics, vol. 22 (Springer, Berlin, 1995)
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2013 Springer International Publishing Switzerland
About this chapter
Cite this chapter
Scherer, P.O.J. (2013). Diffusion. In: Computational Physics. Graduate Texts in Physics. Springer, Heidelberg. https://doi.org/10.1007/978-3-319-00401-3_19
Download citation
DOI: https://doi.org/10.1007/978-3-319-00401-3_19
Publisher Name: Springer, Heidelberg
Print ISBN: 978-3-319-00400-6
Online ISBN: 978-3-319-00401-3
eBook Packages: Physics and AstronomyPhysics and Astronomy (R0)