D03 – Partial Differential Equations

This chapter is concerned with the numerical solution of partial differential equations.

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 $a$, $b$, $c$, $d$, $e$, $f$ and $g$ are functions of $x$ and $y$ only. Equation (1) is called elliptic, hyperbolic or parabolic according to whether $ac-{b}^{2}$ 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.

$$a{u}_{xx}+2b{u}_{xy}+c{u}_{yy}+d{u}_{x}+e{u}_{y}+fu+g=0\text{,}$$ | (1) |

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 $D$ bounded by a contour $C$, a solution $u$ may be sought subject to the condition

where $f$ 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 ${u}^{\prime}$ denotes the derivative of $u$ normal to the contour $C$, and $f$ and $g$ are given functions. Provided that $f$ and $g$ 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 $u$ 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.

$${u}_{xx}+{u}_{yy}=0$$ | (2) |

$$u=f\text{\hspace{1em} on \hspace{1em}}C\text{,}$$ | (3) |

$${u}^{\prime}=g\text{\hspace{1em} on \hspace{1em}}C\text{,}$$ | (4) |

$${u}^{\prime}+fu=g\text{\hspace{1em} on \hspace{1em}}C\text{,}$$ | (5) |

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 $t>0$, a solution $u$ may be sought such that

where $f$ and $g$ are given functions. This is an example of an **initial value problem**, sometimes known as Cauchy's problem.

$${u}_{tt}-{u}_{xx}=0$$ | (6) |

$${u}_{t}-{v}_{x}=0\text{, \hspace{1em}}{v}_{t}-{u}_{x}=0\text{.}$$ | (7) |

$$u\left(x,0\right)=f\left(x\right),\text{\hspace{1em}}{u}_{t}\left(x,0\right)=g\left(x\right)\text{,}$$ | (8) |

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 $t>0$ and $0<x<1$, a solution $u$ may be sought such that

and

This is an example of a mixed **initial/boundary value problem**.

$${u}_{t}-{u}_{xx}=0$$ | (9) |

$$u\left(x,0\right)=f\left(x\right),\text{\hspace{1em}}0<x<1\text{,}$$ | (10) |

$$u\left(0,t\right)=0,\text{\hspace{1em}}u\left(1,t\right)=1,\text{\hspace{1em}}t>0\text{.}$$ | (11) |

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 and such methods obviously feature prominently
either in this chapter or in the companion NAG Finite Element Library.
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.

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.

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 parameters in order to make it safe for use in multithreaded applications. The routine that is safe for use in multithreaded applicatons has an ‘A’ as the last character in the name, in place of the usual ‘F’. An example of such a pair is D03PCA and D03PCF.

All ‘F’ routines not scheduled for withdrawal from the Library and where there is no ‘A’ version of that routine are threadsafe provided that the implementation as a whole is considered threadsafe (refer to the Users' Note for your implementation).

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 $u$ or its normal derivative ${u}^{\prime}$ is given at each point of the boundary.

The routines D03EBF and D03ECF 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 D03UAF and D03UBF 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.

See Section 3.8.

There are five routines available for solving general parabolic equations in one space dimension:

Equations may include nonlinear terms but the true derivative ${u}_{t}$ should occur linearly and equations should usually contain a second-order space derivative ${u}_{xx}$. 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.

D03PCF/D03PCA and D03PDF/D03PDA can solve a system of parabolic equations of the form

where $i=1,2,\dots ,n$, $a\le x\le b$, $t\ge {t}_{0}$.

$$\sum _{j=1}^{n}{P}_{ij}\left(x,t,U,{U}_{x}\right)\frac{\partial {U}_{j}}{\partial t}+{Q}_{i}\left(x,t,U,{U}_{x}\right)={x}^{-m}\frac{\partial}{\partial x}\left({x}^{m}{R}_{i}\left(x,t,U,{U}_{x}\right)\right)\text{,}$$ |

The parameter $m$ 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/D03PHA and D03PJF/D03PJA are similar to D03PCF/D03PCA and D03PDF/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.

D03NCF solves the Black–Scholes equation

for the value $f$ of a European or American, put or call stock option. The parameters $r$, $q$ and $\sigma $ may each be either constant or time-dependent. The values of the Greeks are also returned.

$$\frac{\partial f}{\partial t}+\left(r-q\right)S\frac{\partial f}{\partial S}+\frac{{\sigma}^{2}{S}^{2}}{2}\frac{{\partial}^{2}f}{\partial {S}^{2}}=rf$$ |

$${S}_{\mathrm{min}}<S<{S}_{\mathrm{max}}\text{, \hspace{1em}}{t}_{\mathrm{min}}<t<{t}_{\mathrm{max}}\text{,}$$ |

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).

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.

D03PEF is designed to solve a system of the form

where $i=1,2,\dots ,n$, $a\le x\le b$, $t\ge {t}_{0}$.

$$\sum _{j=1}^{n}{P}_{ij}\left(x,t,U,{U}_{x}\right)\frac{\partial {U}_{j}}{\partial t}+{Q}_{i}\left(x,t,U,{U}_{x}\right)=0\text{,}$$ |

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, D03PKF or D03PRF 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).

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 $j=1,2,\dots ,\mathbf{NPDE}$, $\left(x,y\right)\in \Omega $, ${t}_{0}\le t\le {t}_{\mathrm{out}}$. However, they should not be used to solve purely hyperbolic systems, or time-independent problems.

$${F}_{j}\left(t,x,y,u,{u}_{t},{u}_{x},{u}_{y},{u}_{xx},{u}_{xy},{u}_{yy}\right)=0\text{,}$$ |

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 routines D03RYF and 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, D03PWF and D03PXF. These routines may be used in conjunction with D03PFF, D03PLF and D03PSF.

D03PFF is designed to solve systems of the form

$$\sum _{j=1}^{n}{P}_{ij}\left(x,t,U\right)\frac{\partial {U}_{j}}{\partial t}+\frac{\partial}{\partial x}{F}_{i}\left(x,t,U\right)={C}_{i}\left(x,t,U\right)\frac{\partial}{\partial x}{D}_{i}\left(x,t,U,{U}_{x}\right)+{S}_{i}\left(x,t,U\right)\text{,}$$ |

$$\sum _{j=1}^{n}{P}_{ij}\left(x,t,U\right)\frac{\partial {U}_{j}}{\partial t}+\frac{\partial {F}_{i}\left(x,t,U\right)}{\partial x}=0\text{,}$$ |

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.

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:

Band | F07HDF (DPBTRF) and F07HEF (DPBTRS) |

Variable band (skyline) | F01MCF and F04MCF |

Tridiagonal | F07JAF (DPTSV), F07JDF (DPTTRF) and F07JEF (DPTTRS) |

Sparse | ${\mathbf{F11JAF}}{}^{*}$ and F11JBF |

Sparse | F11GDF, F11GEF, F11GFF, F11JAF, F11JCF and F11JEF. |

The latter two routines above are black box routines which include Incomplete Cholesky, SSOR or Jacobi preconditioning.

The following routines allow the direct solution of nonsymmetric systems:

and the following routines allow the iterative solution of nonsymmetric systems:

Band | F07BDF (DGBTRF) and F07BEF (DGBTRS) |

Almost block-diagonal | F01LHF and F04LHF |

Tridiagonal | F01LEF, F04LEF or F07CAF (DGTSV) |

Sparse | F01BRF (and F01BSF) and F04AXF |

Sparse | F11BDF, F11BEF, F11BFF, F11DAF, F11DCF and F11DEF. |

The latter two routines above are black box routines which include incomplete $LU$, SSOR and Jacobi preconditioning.

The routines D03PYF and D03PZF use linear interpolation to compute the solution to a parabolic problem and its first derivative at the user-specified points. D03PZF may be used in conjunction with D03PCF/D03PCA, D03PEF, D03PHF/D03PHA, D03PKF, D03PPF/D03PPA and D03PRF. D03PYF may be used in conjunction with D03PDF/D03PDA and D03PJF/D03PJA.

D03RYF and D03RZF are utility routines for use in conjunction with D03RBF. They can be called to check the user-specified initial mesh and to extract mesh coordinate data.

Does PDE have a time derivative? | _ yes |
Does PDE have second derivatives? | _ yes |
see Tree 4 Parabolic branch | ||||

| | no | |
|||||||

| | Is PDE hyperbolic? | _ yes |
see Tree 3 Hyperbolic branch | |||||

| | no | |
|||||||

| | 1 space dimension? | _ yes |
Does PDE have coupled ODEs? | _ yes |
Is a remeshing process required? | _ yes |
D03PRF | |

| | | | | | no | |
|||||

| | | | | | D03PKF | |||||

| | | | no | |
||||||

| | | | D03PEF | ||||||

| | no | |
|||||||

| | N/A | |||||||

no | |
||||||||

see Tree 2 Elliptic branch |

2 space dimensions? | _ yes |
Is the domain arbitrary? | _ yes |
D03EAF | ||

| | no | |
|||||

| | Is the domain topologically rectangular? | _ yes |
Do you want to use a multigrid scheme? | _ yes |
D03EDF with D03EEF | |

| | | | no | |
||||

| | | | D03EBF or D03UAF | ||||

| | no | |
|||||

| | D03EAF | |||||

no | |
||||||

3 space dimensions? | _ yes |
Is the domain topologically equivalent to a brick? | _ yes |
Is the PDE the Helmholtz equation? | _ yes |
D03FAF |

| | | | no | |
||||

| | | | D03ECF or D03UBF | ||||

| | no | |
|||||

| | N/A | |||||

no | |
||||||

N/A |

1 space dimension? | _ yes |
Does PDE have coupled ODEs? | _ yes |
Is a remeshing process required? | _ yes |
D03PSF |

| | | | no | |
||||

| | | | D03PLF | ||||

| | no | |
|||||

| | D03PFF | |||||

no | |
||||||

N/A |

1 space dimension? | _ yes |
Is PDE the Black–Scholes equations? | _ yes |
D03NCF or D03NDF | ||||

| | no | |
|||||||

| | Is PDE in conservative form? | _ yes |
Does PDE have coupled ODEs? | _ yes |
Is a remeshing process required? | _ yes |
D03PSF | |

| | | | | | no | |
|||||

| | | | | | D03PLF | |||||

| | | | no | |
||||||

| | | | D03PFF | ||||||

| | no | |
|||||||

| | see Tree 5 Branch for parabolic PDE in non-conservative form | |||||||

no | |
||||||||

2 space dimensions? | _ yes |
Is the domain rectangular? | _ yes |
D03RAF | ||||

| | no | |
|||||||

| | Is the domain rectilinear? | _ yes |
D03RBF | |||||

| | no | |
|||||||

| | N/A | |||||||

no | |
||||||||

N/A |

Do you want to use finite differences? | _ yes |
Does PDE have coupled ODEs? | _ yes |
Is a remeshing process required? | _ yes |
D03PPF |

| | | | no | |
||||

| | | | D03PHF | ||||

| | no | |
|||||

| | D03PCF | |||||

no | |
||||||

Do you want to use Chebyshev collocation? | _ yes |
Does PDE have coupled ODEs? | _ yes |
D03PJF | ||

| | no | |
|||||

| | D03PDF | |||||

no | |
||||||

N/A |

D53PCK | nagf_pde_1d_parab_remesh_fd_dummy_odedef See the description of the argument ODEDEF in D03PHF/D03PHA, D03PJF/D03PJA and D03PPF/D03PPA. |

D03PCK | nagf_pde_1d_parab_remesh_fd_dummy_odedef_old See the description of the argument ODEDEF in D03PHF/D03PHA, D03PJF/D03PJA and D03PPF/D03PPA. |

D53PCL | nagf_pde_1d_parab_remesh_fd_dummy_monitf See the description of the argument MONITF in D03PPA. |

D03PCL | nagf_pde_1d_parab_remesh_fd_dummy_monitf_old See the description of the argument MONITF in D03PPF. |

D03PEK | nagf_pde_1d_parab_dae_keller_remesh_fd_dummy_odedef See the description of the argument ODEDEF in D03PKF, D03PLF, D03PRF and D03PSF. |

D03PEL | nagf_pde_1d_parab_dae_keller_remesh_fd_dummy_monitf See the description of the argument MONITF in D03PRF and D03PSF. |

D03PFP | nagf_pde_1d_parab_convdiff_sample_pdedef See the description of the argument PDEDEF in D03PFF. |

D03PLP | nagf_pde_1d_parab_convdiff_dae_sample_pdedef See the description of the argument PDEDEF in D03PLF and D03PSF. |

The following lists all those routines that have been withdrawn since Mark 17 of the Library or are scheduled for withdrawal at one of the next two marks.

WithdrawnRoutine | Mark ofWithdrawal | Replacement Routine(s) |

D03PAF | 17 | D03PCF/D03PCA |

D03PBF | 17 | D03PCF/D03PCA |

D03PGF | 17 | D03PCF/D03PCA |

Ames W F (1977) *Nonlinear Partial Differential Equations in Engineering* (2nd Edition) Academic Press

Berzins M (1990) Developments in the NAG Library software for parabolic equations *Scientific Software Systems* (eds J C Mason and M G Cox) 59–72 Chapman and Hall

Jaswon M A and Symm G T (1977) *Integral Equation Methods in Potential Theory and Elastostatics* Academic Press

LeVeque R J (1990) *Numerical Methods for Conservation Laws* Birkhäuser Verlag

Mikhlin S G and Smolitsky K L (1967) *Approximate Methods for the Solution of Differential and Integral Equations* Elsevier

Mitchell A R and Griffiths D F (1980) *The Finite Difference Method in Partial Differential Equations* Wiley

Pennington S V and Berzins M (1994) New NAG Library software for first-order partial differential equations *ACM Trans. Math. Softw.* **20** 63–99

Richtmyer R D and Morton K W (1967) *Difference Methods for Initial-value Problems* (2nd Edition) Interscience

Smith G D (1985) *Numerical Solution of Partial Differential Equations: Finite Difference Methods* (3rd Edition) Oxford University Press

Swarztrauber P N and Sweet R A (1979) Efficient Fortran subprograms for the solution of separable elliptic partial differential equations *ACM Trans. Math. Software* **5** 352–364

Wait R and Mitchell A R (1985) *Finite Element Analysis and Application* Wiley