Mathematics Previous page   Next Page

MATLAB Partial Differential Equation Solver

This section describes:

The PDE Solver

The MATLAB PDE solver, pdepe, solves initial-boundary value problems for systems of parabolic and elliptic PDEs in the one space variable and time . There must be at least one parabolic equation in the system.

The pdepe solver converts the PDEs to ODEs using a second-order accurate spatial discretization based on a fixed set of nodes specified by the user. The discretization method is described in [9]. The time integration is done with ode15s. The pdepe solver exploits the capabilities of ode15s for solving the differential-algebraic equations that arise when Equation 5-3 contains elliptic equations, and for handling Jacobians with a specified sparsity pattern. ode15s changes both the time step and the formula dynamically.

After discretization, elliptic equations give rise to algebraic equations. If the elements of the initial conditions vector that correspond to elliptic equations are not "consistent" with the discretization, pdepe tries to adjust them before beginning the time integration. For this reason, the solution returned for the initial time may have a discretization error comparable to that at any other time. If the mesh is sufficiently fine, pdepe can find consistent initial conditions close to the given ones. If pdepe displays a message that it has difficulty finding consistent initial conditions, try refining the mesh. No adjustment is necessary for elements of the initial conditions vector that correspond to parabolic equations.

PDE Solver Basic Syntax

The basic syntax of the solver is

The input arguments are:

m

Specifies the symmetry of the problem. m can be 0 = slab, 1 = cylindrical, or 2 = spherical. It corresponds to m in Equation 5-3.

pdefun
Function that defines the components of the PDE. It computes the terms c, f, and s in Equation 5-3, and has the form
  • [c,f,s] = pdefun(x,t,u,dudx)
    
where x and t are scalars, and u and dudx are vectors that approximate the solution u and its partial derivative with respect to x. c, f, and s are column vectors. c stores the diagonal elements of the matrix c.
icfun
Function that evaluates the initial conditions. It has the form
  • u = icfun(x)
    
When called with an argument x, icfun evaluates and returns the initial values of the solution components at x in the column vector u.
bcfun
Function that evaluates the terms p and q of the boundary conditions. It has the form
  • [pl,ql,pr,qr] = bcfun(xl,ul,xr,ur,t)
    

where ul is the approximate solution at the left boundary x l = a and ur is the approximate solution at the right boundary x r = b. pl and ql are column vectors corresponding to p and the diagonal of q evaluated at xl. Similarly, pr and qr correspond to xr. When m greater than 0 and a = 0, boundedness of the solution near x = 0 requires that the flux f vanish at a = 0. pdepe imposes this boundary condition automatically and it ignores values returned in pl and ql.

xmesh
Vector [x0, x1, ..., xn] specifying the points at which a numerical solution is requested for every value in tspan. x0 and xn correspond to a and b, respectively.

Second-order approximation to the solution is made on the mesh specified in xmesh. Generally, it is best to use closely spaced mesh points where the solution changes rapidly. pdepe does not select the mesh in x automatically. You must provide an appropriate fixed mesh in xmesh. The cost depends strongly on the length of xmesh. When m greater than 0, it is not necessary to use a fine mesh near x = 0 to account for the coordinate singularity.

The elements of xmesh must satisfy x0 < x1 < ... < xn. The length of xmesh must be  3.
tspan

Vector [t0, t1, ..., tf] specifying the points at which a solution is requested for every value in xmesh. t0 and tf correspond to t sub 0 and t sub f, respectively.

pdepe performs the time integration with an ODE solver that selects both the time step and formula dynamically. The solutions at the points specified in tspan are obtained using the natural continuous extension of the integration formulas. The elements of tspan merely specify where you want answers and the cost depends weakly on the length of tspan.

The elements of tspan must satisfy t0 < t1 < ... < tf. The length of tspan must be 3.

The output argument sol is a three-dimensional array, such that:

Additional PDE Solver Arguments

For more advanced applications, you can also specify as input arguments solver options and additional parameters that are passed to the PDE functions.

options
Structure of optional parameters that change the default integration properties. This is the seventh input argument.
  • sol = pdepe(m,pdefun,icfun,bcfun,...
                xmesh,tspan,options)
    
See Changing PDE Integration Properties for more information.


Previous page  Introduction to PDE Problems Solving PDE Problems Next page

© 1994-2005 The MathWorks, Inc.