Mathematics    

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 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 14-4 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 14-4.

pdefun
Function that defines the components of the PDE. It computes the terms , , and in Equation 14-4, 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 and its partial derivative with respect to . c, f, and s are column vectors. c stores the diagonal elements of the matrix .
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 and 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 and ur is the approximate solution at the right boundary . pl and ql are column vectors corresponding to and the diagonal of evaluated at xl. Similarly, pr and qr correspond to xr. When and , boundedness of the solution near requires that the flux vanish at . 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 and , 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 automatically. You must provide an appropriate fixed mesh in xmesh. The cost depends strongly on the length of xmesh. When , it is not necessary to use a fine mesh near 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 and , 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.
p1,p2...
Parameters that the solver passes to pdefun, icfun, and bcfun.
  • sol = pdepe(m,pdefun,icfun,bcfun,xmesh,tspan,...
                options,p1,p2...)
    
The solver passes any input parameters that follow the options argument to pdefun, icfun, and bcfun every time it calls them. Use options = [] as a placeholder if you set no options. In the pdefun argument list, parameters follow x, t, u, and dudx.
  • f = pdefun(x,t,u,dudx,p1,p2,...)
    
In the icfun argument list, parameters follow x.
  • res = icfun(x,p1,p2,...)
    
In the bcfun argument list, parameters follow xl, ul, xr, ur, and t.
  • res = bcfun(xl,ul,xr,ur,t,p1,p2,...)
    

See the pdex3 demo for an example.


  Introduction to PDE Problems Solving PDE Problems