This chapter is concerned with the numerical solution of partial differential equations.
2Background to the Problems
The definition of a partial differential equation problem includes not only the equation itself but also the domain of interest and appropriate subsidiary conditions. Indeed, partial differential equations are usually classified as elliptic, hyperbolic or parabolic according to the form of the equation and the form of the subsidiary conditions which must be assigned to produce a well-posed problem. The routines in this chapter will often call upon routines from other chapters, such as Chapter F04 (Simultaneous Linear Equations) and Chapter D02 (Ordinary Differential Equations). Other chapters also contain relevant routines, in particular Chapter D06 (Mesh Generation) and Chapter F11 (Large Scale Linear Systems).
The classification of partial differential equations is easily described in the case of linear equations of the second order in two independent variables, i.e., equations of the form
where , , , , , and are functions of and only. Equation (1) is called elliptic, hyperbolic or parabolic according to whether is positive, negative or zero, respectively. Useful definitions of the concepts of elliptic, hyperbolic and parabolic character can also be given for differential equations in more than two independent variables, for systems and for nonlinear differential equations.
For elliptic equations, of which Laplace's equation
is the simplest example of second order, the subsidiary conditions take the form of boundary conditions, i.e., conditions which provide information about the solution at all points of a closed boundary. For example, if equation (2) holds in a plane domain bounded by a contour , a solution may be sought subject to the condition
where is a given function. The condition (3) is known as a Dirichlet boundary condition. Equally common is the Neumann boundary condition
which is one form of a more general condition
where denotes the derivative of normal to the contour , and and are given functions. Provided that and satisfy certain restrictions, condition (5) yields a well-posed boundary value problem for Laplace's equation. In the case of the Neumann problem, one further piece of information, e.g., the value of at a particular point, is necessary for uniqueness of the solution. Boundary conditions similar to the above are applicable to more general second-order elliptic equations, whilst two such conditions are required for equations of fourth order.
For hyperbolic equations, the wave equation
is the simplest example of second order. It is equivalent to a first-order system
The subsidiary conditions may take the form of initial conditions, i.e., conditions which provide information about the solution at points on a suitable open boundary. For example, if equation (6) is satisfied for , a solution may be sought such that
where and are given functions. This is an example of an initial value problem, sometimes known as Cauchy's problem.
For parabolic equations, of which the heat conduction equation
is the simplest example, the subsidiary conditions always include some of initial type and may also include some of boundary type. For example, if equation (9) is satisfied for and , a solution may be sought such that
This is an example of a mixed initial/boundary value problem.
For all types of partial differential equations, finite difference methods (see Mitchell and Griffiths (1980)) and finite element methods (see Wait and Mitchell (1985)) are the most common means of
solution. The use of finite difference methods features prominently in this chapter, however, the use of finite element methods is sufficiently large in scope to warrant a separate library of routines for their implementation. NAG no longer provides a companion finite element library, but there are several such specialist libraries available, including ParaFEM.
Some of the utility routines in this chapter are concerned with the solution of the large sparse systems of equations which arise from finite difference and finite element methods. Further routines for this purpose are provided in Chapter F11.
Alternative methods of solution are often suitable for special classes of problems. For example, the method of characteristics is the most common for hyperbolic equations involving time and one space dimension (see Smith (1985)). The method of lines (see Mikhlin and Smolitsky (1967)) may be used to reduce a parabolic equation to a (stiff) system of ordinary differential equations, which may be solved by means of routines from Chapter D02 (Ordinary Differential Equations). Similarly, integral equation or boundary element methods (see Jaswon and Symm (1977)) are frequently used for elliptic equations. Typically, in the latter case, the solution of a boundary value problem is represented in terms of certain boundary functions by an integral expression which satisfies the differential equation throughout the relevant domain. The boundary functions are obtained by applying the given boundary conditions to this representation. Implementation of this method necessitates discretization of only the boundary of the domain, the dimensionality of the problem thus being effectively reduced by one. The boundary conditions yield a full system of simultaneous equations, as opposed to the sparse systems yielded by finite difference and finite element methods, but the full system is usually of much lower order. Solution of this system yields the boundary functions, from which the solution of the problem may be obtained, by quadrature, as and where required.
3Recommendations on Choice and Use of Available Routines
The choice of routine will depend first of all upon the type of partial differential equation to be solved. At present no special allowances are made for problems with boundary singularities such as may arise at corners of domains or at points where boundary conditions change. For such problems results should be treated with caution. The choice of routine may also depend on whether or not it is to be used in a multithreaded environment.
You may wish to construct your own partial differential equation solution software for problems not solvable by the routines described in Section 3.2 to Section 3.8 below. In such cases you can employ appropriate routines from the Linear Algebra Chapters to solve the resulting linear systems; see Section 3.10 for further details.
3.1Thread Safe Routines
Some of the routines in this chapter come in pairs, with each routine in the pair having exactly the same functionality, except that one of them has additional arguments in order to make it safe for use in multithreaded applications. The routine that is safe for use in multithreaded applications has an ‘a’ as the last character in the name, in place of the usual ‘f’. An example of such a pair is d03pcaandd03pcf.
For some routines there is no thread safe alternative and if this is the case it is clearly stated in the routine document.
The routine d03eaf solves Laplace's equation in two dimensions, equation (2), by an integral equation method. This routine is applicable to an arbitrary domain bounded internally or externally by one or more closed contours, when the value of either the unknown function or its normal derivative is given at each point of the boundary.
The routines d03ebfandd03ecf solve a system of simultaneous algebraic equations of five-point and seven-point molecule form (see Mikhlin and Smolitsky (1967)) on two-dimensional and three-dimensional topologically-rectangular meshes respectively, using Stone's Strongly Implicit Procedure (SIP). These routines, which make repeated calls of the utility routines d03uafandd03ubf respectively, may be used to solve any boundary value problem whose finite difference representation takes the appropriate form.
The routine d03edf solves a system of seven-point difference equations in a rectangular grid (in two dimensions), using the multigrid iterative method. The equations are supplied by you, and the seven-point form allows cross-derivative terms to be represented (see Mitchell and Griffiths (1980)). The method is particularly efficient for large systems of equations with diagonal dominance and should be preferred to d03ebf whenever it is appropriate for the solution of the problem.
The routine d03eef discretizes a second-order equation on a two-dimensional rectangular region using finite differences and a seven-point molecule. The routine allows for cross-derivative terms, Dirichlet, Neumann or mixed boundary conditions, and either central or upwind differences. The resulting seven-diagonal difference equations are in a form suitable for passing directly to the multigrid routine d03edf, although other solution methods could just as easily be used.
The routine d03faf, based on the routine HW3CRT from FISHPACK (see Swarztrauber and Sweet (1979)), solves the Helmholtz equation in a three-dimensional cuboidal region, with any combination of Dirichlet, Neumann or periodic boundary conditions. The method used is based on the fast Fourier transform algorithm, and is likely to be particularly efficient on vector-processing machines.
Equations may include nonlinear terms but the true derivative should occur linearly and equations should usually contain a second-order space derivative . There are certain restrictions on the coefficients to try to ensure that the problems posed can be solved by the above routines.
The method of solution is to discretize the space derivatives using finite differences or collocation, and to solve the resulting system of ordinary differential equations using a ‘stiff’ solver.
The parameter allows the routine to handle different coordinate systems easily (Cartesian, cylindrical polars and spherical polars). d03pcf/d03pca uses a finite differences spatial discretization and d03pdf/d03pda uses a collocation spatial discretization.
d03phf/d03phaandd03pjf/d03pja are similar to d03pcf/d03pcaandd03pdf/d03pda respectively, except that they provide scope for coupled differential-algebraic systems. This extended functionality allows for the solution of more complex and more general problems, e.g., periodic boundary conditions and integro-differential equations.
d03ppf/d03ppa is similar to d03phf/d03pha but allows remeshing to take place in the spatial direction. This facility can be very useful when the nature of the solution in the spatial direction varies considerably over time.
For parabolic systems in two space dimensions see Section 3.7.
for the value of a European or American, put or call stock option. The parameters , and may each be either constant or time-dependent. The values of the Greeks are also returned.
In certain cases an analytic solution of the Black–Scholes equation is available. In these cases the solution may be computed by d03ndf. More generally, Chapter S contains a set of option pricing routines that evaluate the closed form solutions or approximations to the equations that define mathematical models for the prices of selected financial option contracts, including the Black–Scholes equation (s30aaf).
3.6First-order Systems in One Space Dimension
There are three routines available for solving systems of first-order partial differential equations:
Equations may include nonlinear terms but the time derivative should occur linearly. There are certain restrictions on the coefficients to ensure that the problems posed can be solved by the above routines.
The method of solution is to discretize the space derivatives using the Keller box scheme and to solve the resulting system of ordinary differential equations using a ‘stiff’ solver.
d03pkf is similar to d03pef except that it provides scope for coupled differential algebraic systems. This extended functionality allows for the solution of more complex problems.
d03prf is similar to d03pkf but allows remeshing to take place in the spatial direction. This facility can be very useful when the nature of the solution in the spatial direction varies considerably over time.
d03pef,d03pkford03prf may also be used to solve systems of higher or mixed order partial differential equations which have been reduced to first-order. Note that in general these routines are unsuitable for hyperbolic first-order equations, for which an appropriate upwind discretization scheme should be used (see Section 3.8 for example).
3.7Second-order Systems in Two Space Dimensions
There are two routines available for solving nonlinear second-order time-dependent systems in two space dimensions:
These routines are formally applicable to the general nonlinear system
where , , . However, they should not be used to solve purely hyperbolic systems, or time-independent problems.
d03raf solves the nonlinear system in a rectangular domain, while d03rbf solves in a rectilinear region, i.e., a domain bounded by perpendicular straight lines.
Both routines use the method of lines and solve the resulting system of ordinary differential equations using a backward differentiation formula (BDF) method, modified Newton method, and BiCGSTAB iterative linear solver. Local uniform grid refinement is used to improve accuracy.
Utility routine d03rzf may be used in conjunction with d03rbf to check the user-supplied initial mesh, and extract mesh coordinate data.
There are three routines available for solving systems of convection-diffusion equations with optional source terms:
Equations may include nonlinear terms but the time derivative should occur linearly. There are certain restrictions on the coefficients to ensure that the problems posed can be solved by the above routines, in particular the system must be posed in conservative form (see below). The routines may also be used to solve hyperbolic convection-only systems.
Convection terms are discretized using an upwind scheme involving a numerical flux function based on the solution of a Riemann problem at each mesh point (see LeVeque (1990)); and diffusion and source terms are discretized using central differences. The resulting system of ordinary differential equations is solved using a ‘stiff’ solver. In the case of Euler equations for a perfect gas various approximate and exact Riemann solvers are provided in d03puf,d03pvf,d03pwfandd03pxf. These routines may be used in conjunction with d03pff,d03plfandd03psf.
d03plf is similar to d03pff except that it provides scope for coupled differential algebraic systems. This extended functionality allows for the solution of more complex problems.
d03psf is similar to d03plf but allows remeshing to take place in the spatial direction. This facility can be very useful when the nature of the solution in the spatial direction varies considerably over time.
3.9Automatic Mesh Generation
The routine d03maf places a triangular mesh over a given two-dimensional region. The region may have any shape and may include holes. It may also be used in conjunction with routines from the NAG Finite Element Library. A wider range of mesh generation routines are available in Chapter D06.
d03uaf (d03ubf) calculates, by the Strongly Implicit Procedure, an approximate correction to a current estimate of the solution of a system of simultaneous algebraic equations for which the iterative update matrix is of five (seven) point molecule form on a two- (three-) dimensional topologically-rectangular mesh.
Routines are available in the Linear Algebra Chapters for the direct and iterative solution of linear equations. Here we point to some of the routines that may be of use in solving the linear systems that arise from finite difference or finite element approximations to partial differential equation solutions. Chapters F01, F04, F07, F08 and F11 should be consulted for further information and for the appropriate routine documents. Decision trees for the solution of linear systems are given in Section 4 in the F04 Chapter Introduction.
The following routines allow the direct solution of symmetric positive definite systems:
( the description of f11jbf explains how f11jaf should be called to obtain a direct method)
and the following routines allow the iterative solution of symmetric positive definite and symmetric-indefinite systems: