Solve 1-D parabolic and elliptic PDEs
solves a system of parabolic and elliptic PDEs with one spatial variable
x and time t. At least one equation must be
parabolic. The scalar sol = pdepe(m,pdefun,icfun,bcfun,xmesh,tspan)m represents the symmetry of the problem (slab,
cylindrical, or spherical). The equations being solved are coded in
pdefun, the initial value is coded in icfun, and the
boundary conditions are coded in bcfun. The ordinary differential
equations (ODEs) resulting from discretization in space are integrated to obtain approximate
solutions at the times specified in tspan. The pdepe
function returns values of the solution on a mesh provided in
xmesh.
[
also finds where functions of (t,u(x,t)), called event functions, are zero. In the output, sol,tsol,sole,te,ie] = pdepe(m,pdefun,icfun,bcfun,xmesh,tspan,options)te is
the time of the event, sole is the solution at the time of the event, and
ie is the index of the triggered event. tsol is a
column vector of times specified in tspan, prior to the first terminal
event.
For each event function, specify whether the integration is to terminate at a zero and
whether the direction of the zero-crossing matters. Do this by setting the
'Events' option of odeset to a function, such as
@myEventFcn, and creating a corresponding function:
[value,isterminal,direction] =
myEventFcn(m,t,xmesh,umesh).
The xmesh input contains the spatial mesh and umesh is
the solution at the mesh points.
If uji = sol(j,:,i) approximates component i of
the solution at time tspan(j) and mesh points xmesh,
then pdeval evaluates the approximation and its
partial derivative ∂ui/∂x at
the array of points xout and returns them in uout
and duoutdx: [uout,duoutdx] =
pdeval(m,xmesh,uji,xout). The pdeval function evaluates
the partial derivative ∂ui/∂x rather than the flux. The flux is continuous, but at a material
interface the partial derivative may have a jump.
The time integration is done with the ode15s solver. pdepe exploits the capabilities of
ode15s for solving the differential-algebraic equations that arise when
the PDE contains elliptic equations, and for handling Jacobians with a specified sparsity
pattern.
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.
[1] Skeel, R. D. and M. Berzins, "A Method for the Spatial Discretization of Parabolic Equations in One Space Variable," SIAM Journal on Scientific and Statistical Computing, Vol. 11, 1990, pp.1–32.