Abstract
The simplest approach to discretize a differential equation replaces differential quotients by quotients of finite differences. For the space variables this method works best on a regular grid. Finite volume methods, which are very popular in computational fluid dynamics, take averages over small control volumes and can be easily used with irregular grids. Finite elements and finite volumes belong to the general class of finite element methods which are prominent in the engineering sciences and use an expansion in piecewise polynomials with small support. Spectral methods, on the other hand, expand the solution as a linear combination of global basis functions. A general concept is the method of weighted residuals. Most popular is Galerkin’s method. The simpler point collocation and sub-domain collocation methods fulfill the differential equation only at certain points or averaged over certain control volumes. The more demanding least-squares method has become popular in computational fluid dynamics and computational electrodynamics.
If the Green’s function is available for a problem, the method of boundary elements is an interesting alternative. It reduces the dimensionality and is, for instance, very popular in chemical physics to solve the Poisson-Boltzmann equation.
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.
Many processes in science and technology can be described by differential equations involving the rate of changes in time or space of a continuous variable, the unknown function. While the simplest differential equations can be solved exactly, a numerical treatment is necessary in most cases and the equations have to be discretized to turn them into a finite system of equations which can be solved by computers [6, 155, 200]. In this chapter we discuss different methods to discretize differential equations. The simplest approach is the method of finite differences, which replaces the differential quotients by difference quotients (Chap. 3). It is often used for the discretization of time. Finite difference methods for the space variables work best on a regular grid. Finite volume methods are very popular in computational fluid dynamics. They take averages over small control volumes and can be easily used with irregular grids. Finite differences and finite volumes belong to the general class of finite element methods which are prominent in the engineering sciences and use an expansion in piecewise polynomials with small support. Spectral methods, on the other hand, expand the solution as a linear combination of global basis functions like polynomials or trigonometric functions. A general concept for the discretization of differential equations is the method of weighted residuals which minimizes the weighted residual of a numerical solution. Most popular is Galerkin’s method which uses the expansion functions also as weight functions. Simpler are the point collocation and sub-domain collocation methods which fulfill the differential equation only at certain points or averaged over certain control volumes. More demanding is the least-squares method which has become popular in computational fluid dynamics and computational electrodynamics. The least-square integral provides a measure for the quality of the solution which can be used for adaptive grid size control.
If the Green’s function is available for a problem, the method of boundary elements is an interesting alternative. It reduces the dimensionality and is, for instance, very popular in chemical physics to solve the Poisson-Boltzmann equation.
1 Classification of Differential Equations
An ordinary differential equation (ODE) is a differential equation for a function of one single variable, like Newton’s law for the motion of a body under the influence of a force field
a typical initial value problem where the solution in the domain t 0≤t≤T is determined by position and velocity at the initial time
Such equations of motion are discussed in Chap. 12. They also appear if the spatial derivatives of a partial differential equation have been discretized. Usually this kind of equation is solved by numerical integration over finite time steps Δt=t n+1−t n . Boundary value problems, on the other hand, require certain boundary conditionsFootnote 1 to be fulfilled, for instance the linearized Poisson-Boltzmann equation in one dimension (Chap. 17)
where the value of the potential is prescribed on the boundary of the domain x 0≤x≤x 1
Partial differential equations (PDE) finally involve partial derivatives with respect to at least two different variables, in many cases time and spatial coordinates.
1.1 Linear Second Order PDE
A very important class are second order linear partial differential equations of the general form
where the coefficients a ij ,b i ,c,d are functions of the variables x 1…x N but do not depend on the function f itself. The equation is classified according to the eigenvalues of the coefficient matrix a ij as [141]
-
elliptical if all eigenvalues are positive or all eigenvalues are negative, like for the Poisson equation (Chap. 17)
$$\begin{aligned} \biggl(\frac{\partial^{2}}{\partial x^{2}}+\frac{\partial^{2}}{\partial y^{2}}+\frac{\partial^{2}}{\partial z^{2}} \biggr) \varPhi(x,y,z)=-\frac{1}{\varepsilon}\rho(x,y,z) \end{aligned}$$(11.6) -
hyperbolic if one eigenvalue is negative and all the other eigenvalues are positive or vice versa, for example the wave equation in one spatial dimension (Chap. 18)
$$\begin{aligned} \frac{\partial^{2}}{\partial t^{2}}f-c^{2}\frac{\partial^{2}}{\partial x^{2}}f=0 \end{aligned}$$(11.7) -
parabolic if at least one eigenvalue is zero, like for the diffusion equation (Chap. 19)
$$\begin{aligned} \frac{\partial}{\partial t}f(x,y,z,t)-D \biggl(\frac{\partial ^{2}}{\partial x^{2}}+\frac{\partial^{2}}{\partial y^{2}}+ \frac{\partial^{2}}{\partial z^{2}} \biggr)f(x,y,z,t)=S(x,y,z,t) \end{aligned}$$(11.8) -
ultra-hyperbolic if there is no zero eigenvalue and more than one positive as well as more than one negative eigenvalue. Obviously the dimension then must be 4 at least.
1.2 Conservation Laws
One of the simplest first order partial differential equations is the advection equation
which describes transport of a conserved quantity with density f (for instance mass, number of particles, charge etc.) in a medium streaming with velocity u. This is a special case of the class of conservation laws (also called continuity equations)
which are very common in physics. Here J describes the corresponding flux and g is an additional source (or sink) term. For instance the advection-diffusion equation (also known as convection equation) has this form which describes quite general transport processes:
where one contribution to the flux
is proportional to the gradient of the concentration C (Fick’s first law) and the second part depends on the velocity field u of a streaming medium. The source term S represents the effect of chemical reactions. Equation (11.11) is also similar to the drift-diffusion equation in semiconductor physics and closely related to the Navier Stokes equations which are based on the Cauchy momentum equation [1]
where σ denotes the stress tensor. Equation (11.10) is the strong or differential form of the conservation law. The requirements on the smoothness of the solution are reduced by using the integral form which is obtained with the help of Gauss’ theorem
An alternative integral form results from Galerkin’s [98] method of weighted residuals which introduces a weight function w(x) and considers the equation
or after applying Gauss’ theorem
The so called weak form of the conservation law states that this equation holds for arbitrary weight functions w.
2 Finite Differences
The simplest method to discretize a differential equation is to introduce a grid of equidistant points and to discretize the differential operators by finite differences (FDM) as described in Chap. 3. For instance, in one dimension the first and second derivatives can be discretized by
These expressions are not well defined at the boundaries of the grid m=1,M unless the boundary conditions are taken into account. For instance, in case of a Dirichlet problem f 0 and f M+1 are given boundary values and
Other kinds of boundary conditions can be treated in a similar way.
2.1 Finite Differences in Time
Time derivatives can be treated similarly using an independent time grid
and finite differences like the first order forward difference quotient
or the symmetric difference quotient
to obtain a system of equations for the function values at the grid points \(f_{m}^{n}\). For instance for the diffusion equation in one spatial dimension
the simplest discretization is the FTCS (forward in time, centered in space) scheme
which can be written in matrix notation as
with
2.2 Stability Analysis
Fully discretized linear differential equations provide an iterative algorithm of the typeFootnote 2
which propagates numerical errors according to
Errors are amplified exponentially if the absolute value of at least one eigenvalue of A is larger than one. The algorithm is stable if all eigenvalues of A are smaller than one in absolute value (Sect. 1.4). If the eigenvalue problem is difficult to solve, the von Neumann analysis is helpful which decomposes the errors into a Fourier series and considers the Fourier components individually by setting
and calculating the amplification factor
The algorithm is stable if |g(k)|≤1 for all k.
Example
For the discretized diffusion equation (11.28) we find
hence stability requires
2.3 Method of Lines
Alternatively time can be considered as a continuous variable. The discrete values of the function then are functions of time (so called lines)
and a set of ordinary differential equations has to be solved. For instance for diffusion in one dimension (11.27) the equations
which can be written in matrix notation as
or briefly
Several methods to integrate such a semi-discretized equation will be discussed in Chap. 12. If eigenvectors and eigenvalues of A are easy available, an eigenvector expansion can be used.
2.4 Eigenvector Expansion
A homogeneous system
where the matrix A is obtained from discretizing the spatial derivatives, can be solved by an eigenvector expansion. From the eigenvalue problem
we obtain the eigenvalues λ and eigenvectors f λ which provide the particular solutions:
These can be used to expand the general solution
The coefficients C λ follow from the initial values by solving the linear equations
If the differential equation is second order in time
the particular solutions are
and the eigenvector expansion is
The coefficients C λ± follow from the initial amplitudes and velocities
For a first order inhomogeneous system
the expansion coefficients have to be time dependent
and satisfy
After taking the scalar product with f μ Footnote 3
can be solved by a simple time integration. For a second order system
we introduce the first time derivative as a new variable
to obtain a first order system of double dimension
where eigenvectors and eigenvalues can be found from those of A (11.45)
Insertion of
gives
and taking the scalar product with one of the left-eigenvectors we end up with
3 Finite Volumes
Whereas the finite differences method uses function values
at the grid points
the finite volume method (FVM) [79] averages function values and derivatives over small control volumes V r which are disjoint and span the domain V (Fig. 11.1)
The averages are
or in the simple case of cubic control volumes of equal size h 3
Such average values have to be related to discrete function values by numerical integration (Chap. 4). The midpoint rule (4.17), for instance replaces the average by the central value
whereas the trapezoidal rule (4.13) implies the average over the eight corners of the cube
In (11.73) the function values refer to a dual grid [79] centered around the vertices of the original grid (11.68) (Fig. 11.2),
The average gradient can be rewritten using the generalized Stokes’ theorem as
For a cubic grid we have to integrate over the six faces of the control volume
The integrals have to be evaluated numerically. Applying as the simplest approximation the midpoint rule (4.17)
this becomes
which involves symmetric difference quotients. However, the function values in (11.78) refer neither to the original nor to the dual grid. Therefore we interpolate (Fig. 11.3)
or
The finite volume method is capable of treating discontinuities and is very flexible concerning the size and shape of the control volumes.
3.1 Discretization of fluxes
Integration of (11.10) over a control volume and application of Gauss’ theorem gives the integral form of the conservation law
which involves the flux J of some property like particle concentration, mass, energy or momentum density or the flux of an electromagnetic field. The total flux through a control volume is given by the surface integral
which in the special case of a cubic volume element of size h 3 becomes the sum over the six faces of the cube (Fig. 11.4)
The surface integral can be evaluated numerically (Chap. 4). Using the midpoint approximation (11.77) we obtain
The trapezoidal rule (4.13) introduces an average over the four corners (Fig. 11.3)
which replaces the flux values in (11.85) by the averages
One advantage of the finite volume method is that the flux is strictly conserved.
4 Weighted Residual Based Methods
A general method to discretize partial differential equations is to approximate the solution within a finite dimensional space of trial functions.Footnote 4 The partial differential equation is turned into a finite system of equations or a finite system of ordinary differential equations if time is treated as a continuous variable. This is the basis of spectral methods which make use of polynomials or Fourier series but also of the very successful finite element methods. Even finite difference methods and finite volume methods can be formulated as weighted residual based methods.
Consider a differential equationFootnote 5 on the domain V which is written symbolically with the differential operator \(\mathcal{T}\)
and corresponding boundary conditions which are expressed with a boundary operator \(\mathcal{B}\) Footnote 6
The basic principle to obtain an approximate solution \(\tilde{u}(\mathbf {r})\) is to choose a linear combination of expansion functions N i (r) i=1…r as a trial function which fulfills the boundary conditionsFootnote 7
In general (11.92) is not an exact solution and the residual
will not be zero throughout the whole domain V. The function \(\tilde{u}\) has to be determined such that the residual becomes “small” in a certain sense. To that end weight functionsFootnote 8 w j j=1…r are chosen to define the weighted residuals
The optimal parameters u i are then obtained from the solution of the equations
In the special case of a linear differential operator these equations are linear
Several strategies are available to choose suitable weight functions.
4.1 Point Collocation Method
The collocation method uses the weight functions w j (r)=δ(r−r j ), with certain collocation points r j ∈V. The approximation \(\tilde{u}\) obeys the differential equation at the collocation points
and for a linear differential operator
The point collocation method is simple to use, especially for nonlinear problems. Instead of using trial functions satisfying the boundary conditions, extra collocation points on the boundary can be added (mixed collocation method).
4.2 Sub-domain Method
This approach uses weight functions which are the characteristic functions of a set of control volumes V i which are disjoint and span the whole domain similar as for the finite volume method
The residuals then are integrals over the control volumes and
respectively
4.3 Least Squares Method
Least squares methods have become popular for first order systems of differential equations in computational fluid dynamics and computational electrodynamics [30, 140].
The L2-norm of the residual (11.94) is given by the integral
It is minimized by solving the equations
which is equivalent to choosing the weight functions
or for a linear differential operator simply
Advantages of the least squares method are that boundary conditions can be incorporated into the residual and that S provides a measure for the quality of the solution which can be used for adaptive grid size control. On the other hand S involves a differential operator of higher order and therefore much smoother trial functions are necessary.
4.4 Galerkin Method
Galerkin’s widely used method [87, 98] chooses the basis functions as weight functions
and solves the following system of equations
or in the simpler linear case
5 Spectral and Pseudo-spectral Methods
Spectral methods use basis functions which are nonzero over the whole domain, the trial functions being mostly polynomials or Fourier sums [35]. They can be used to solve ordinary as well as partial differential equations. The combination of a spectral method with the point collocation method is also known as pseudo-spectral method.
5.1 Fourier Pseudo-spectral Methods
Linear differential operators become diagonal in Fourier space. Combination of Fourier series expansion and point collocation leads to equations involving a discrete Fourier transformation, which can be performed very efficiently with the Fast Fourier Transform methods.
For simplicity we consider only the one-dimensional case. We choose equidistant collocation points
and expansion functions
For a linear differential operator
and the condition on the residual becomes
or
which is nothing but a discrete Fourier back transformation (Sect. 7.2, (7.19)) which can be inverted to give
Instead of exponential expansion functions, sine and cosine functions can be used to satisfy certain boundary conditions, for instance to solve the Poisson equation within a cube (Sect. 17.1.2).
5.2 Example: Polynomial Approximation
Let us consider the initial value problem (Fig. 11.5)
with the well known solution
We choose a polynomial trial function with the proper initial value
The residual is
5.2.1 Point Collocation Method
For our example we need two collocation points to obtain two equations for the two unknowns u 1,2. We choose \(x_{1}=0,x_{2}=\frac{1}{2}\). Then we have to solve the equations
which gives
5.2.2 Sub-domain Method
We need two sub-domains to obtain two equations for the two unknowns u 1,2. We choose \(V_{1}=\{x,0<x<\frac{1}{2}\}\), \(V_{2}=\{x,\frac{1}{2}<x<1\}\). Integration gives
5.2.3 Galerkin Method
Galerkin’s method uses the weight functions w 1(x)=x,w 2(x)=x 2. The equations
have the solution
5.2.4 Least Squares Method
The integral of the squared residual
is minimized by solving
which gives
6 Finite Elements
The method of finite elements (FEM) is a very flexible method to discretize partial differential equations [84, 210]. It is rather dominant in a variety of engineering sciences. Usually the expansion functions N i are chosen to have compact support. The integration volume is divided into disjoint sub-volumes
The N i (x) are piecewise continuous polynomials which are nonzero only inside V i and a few neighbor cells.
6.1 One-Dimensional Elements
In one dimension the domain is an interval V={x;a≤x≤b} and the sub-volumes are small sub-intervals V i ={x;x i ≤x≤x i+1}. The one-dimensional mesh is the set of nodes {a=x 0,x 1…x r =b}. Piecewise linear basis functions (Fig. 11.6) are in the 1-dimensional case given by
and the derivatives are (except at the nodes x i )
6.2 Two- and Three-Dimensional Elements
In two dimensions the mesh is defined by a finite number of points (x i ,y i )∈V (the nodes of the mesh). There is considerable freedom in the choice of these points and they need not be equally spaced.
6.2.1 Triangulation
The nodes can be regarded as forming the vertices of a triangulationFootnote 9 of the domain V (Fig. 11.7).
The piecewise linear basis function in one dimension (11.139) can be generalized to the two-dimensional case by constructing functions N i (x,y) which are zero at all nodes except (x i ,y i )
These functions are linear over each triangle which contains the vertex i and can be combined as the sum of small pyramids (Fig. 11.8). Let one of the triangles be denoted by its three vertices as T ijk .Footnote 10 The corresponding linear function then is
where the coefficients follow from the conditions
as
with
which, apart from sign, is the area of the triangle T ijk . The basis function N i now is given by
In three dimensions we consider tetrahedrons (Fig. 11.9) instead of triangles. The corresponding linear function of three arguments has the form
and from the conditions n i,j,k,l (x i ,y i ,z i )=1 and n i,j,k,l =0 on all other nodes we find (an algebra program is helpful at that point)
where V ijkl is, apart from sign, the volume of the tetrahedron
6.2.2 Rectangular Elements
For a rectangular grid rectangular elements offer a practical alternative to triangles. Since equations for four nodes have to be fulfilled, the basic element needs four parameters, which is the case for a bilinear expression. Let us denote one of the rectangles which contains the vertex i as R i,j,k,l . The other three edges are
where b x =±h x ,b y =±h y corresponding to the four rectangles with the common vertex i (Fig. 11.10).
The bilinear function (Fig. 11.11) corresponding to R ijkl is
It has to fulfill
from which we find
The basis function centered at node i then is
Generalization to a three-dimensional grid is straightforward (Fig. 11.12). We denote one of the eight cuboids containing the node (x i ,y i ,z i ) as \(C_{i,j_{1}\dots j_{7}}\) with \((x_{j_{1}},y_{j_{1}},z_{j_{1}})=(x_{i}+b_{x},y_{i},z_{i})\dots (x_{j_{7}},y_{j_{7}},z_{j_{7}})=(x_{i}+b_{x},y_{i}+b_{y},z_{i}+b_{z})\). The corresponding trilinear function is
6.3 One-Dimensional Galerkin FEM
As an example we consider the one-dimensional linear differential equation (11.5)
in the domain 0≤x≤1 with boundary conditions
We use the basis functions from (11.139) on a one-dimensional grid with
and apply the Galerkin method [88]. The boundary conditions require
The weighted residual is
First we integrate
Integration of the first derivative gives
For the second derivative partial integration gives
where the first two summands are zero due to the boundary conditions. Since \(N_{i}\mbox{ and }N_{i}'\) are nonzero only for x i−1<x<x i+1 we find
Integration of the last term in (11.160) gives
Applying the trapezoidal ruleFootnote 11 for both integrals we find
The discretized equation finally reads
which can be written in matrix notation as
where the matrix A is tridiagonal as a consequence of the compact support of the basis functions
For equally spaced nodes h i =h i−1=h and after division by h (11.167) reduces to a system of equations where the derivatives are replaced by finite differences (11.20)
and the function u is replaced by a certain average
The corresponding matrix in (11.169) is the so called mass matrix. Within the framework of the finite differences method the last expression equals
hence replacing it by u j (this is called mass lumping) introduces an error of the order O(h 2).
7 Boundary Element Method
The boundary element method (BEM) [18, 276] is a method for linear partial differential equations which can be brought into boundary integral formFootnote 12 like Laplace’s equation (Chap. 17)Footnote 13
for which the fundamental solution
is given by
We apply Gauss’s theorem to the expression [277]
Integration over a volume V gives
This integral equation determines the potential self-consistently by its value and normal derivative on the surface of the cavity. It can be solved numerically by dividing the surface into a finite number of boundary elements. The resulting system of linear equations often has smaller dimension than corresponding finite element approaches. However, the coefficient matrix is in general full and not necessarily symmetric.
Notes
- 1.
Dirichlet b.c. concern the function values, Neumann b.c. the derivative, Robin b.c. a linear combination of both, Cauchy b.c. the function value and the normal derivative and mixed b.c. have different character on different parts of the boundary.
- 2.
Differential equations which are higher order in time can be always brought to first order by introducing the time derivatives as additional variables.
- 3.
If A is not Hermitian we have to distinguish left- and right-eigenvectors.
- 4.
Also called expansion functions.
- 5.
Generalization to systems of equations is straightforward.
- 6.
One or more linear differential operators, usually a combination of the function and its first derivatives.
- 7.
This requirement can be replaced by additional equations for the u i , for instance with the tau method [195].
- 8.
Also called test functions.
- 9.
The triangulation is not determined uniquely by the nodes.
- 10.
The order of the indices does matter.
- 11.
Higher accuracy can be achieved, for instance, by Gaussian integration.
- 12.
This is only possible if the fundamental solution or Green’s function is available.
- 13.
The minus sign is traditionally used.
References
D.J. Acheson, Elementary Fluid Dynamics (Oxford University Press, London, 1990)
W. Ames, Numerical Methods for Partial Differential Equations (Academic Press, San Diego, 1992)
G. Beer, I. Smith, C. Duenser, The Boundary Element Method with Programming: For Engineers and Scientists (Springer, Berlin, 2008)
P. Bochev, M. Gunzburger, Least Squares Finite Element Methods (Springer, Berlin, 2009)
J.P. Boyd, Chebyshev and Fourier Spectral Methods (Dover, New York, 2001)
R. Eymard, T. Galloue, R. Herbin, Finite volume methods, in Handbook of Numerical Analysis, vol. 7, ed. by P.G. Ciarlet, J.L. Lions (Elsevier, Amsterdam, 2000), pp. 713–1020
J. Fish, T. Belytschko, A First Course in Finite Elements (Wiley, New York, 2007)
C.A.J. Fletcher, Computational Galerkin Methods (Springer, Berlin, 1984)
C.A.J. Fletcher, Computational Techniques for Fluid Dynamics, vol. I, 2nd edn. (Springer, Berlin, 1991)
B.G. Galerkin, On electrical circuits for the approximate solution of the Laplace equation. Vestnik Inzh. 19, 897–908 (1915)
B.-n. Jiang, The Least-Squares Finite Element Method (Springer, Berlin, 1998)
F. John, Duke Math. J. 4, 300 (1938)
H.P. Langtangen, Computational Partial Differential Equations: Numerical Methods and Diffpack Programming (Springer, Berlin, 2003)
E.L. Ortiz, SIAM J. Numer. Anal. 6, 480 (1969)
J. Peiro, S. Sherwin, in Handbook of Materials Modeling, vol. 1, ed. by S. Yip (Springer, Berlin, 2005), pp. 1–32
S.S. Rao, The Finite Element Method in Engineering (Elsevier, Amsterdam, 2011)
L.C. Wrobel, M.H. Aliabadi, The Boundary Element Method (Wiley, New York, 2002)
G. Wunsch, Feldtheorie (VEB Technik, Berlin, 1973)
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). Discretization of Differential Equations. In: Computational Physics. Graduate Texts in Physics. Springer, Heidelberg. https://doi.org/10.1007/978-3-319-00401-3_11
Download citation
DOI: https://doi.org/10.1007/978-3-319-00401-3_11
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)