pdepe
Solves one-dimensional parabolic and elliptic partial differential equations.
Category: Mathematics > Numerical Integration and Differential Equations
Syntax
sol = pdepe(m, pdefun, icfun, bcfun, xmesh, tspan)
Solves the PDE system on the mesh xmesh at the times tspan.
sol = pdepe(m, pdefun, icfun, bcfun, xmesh, tspan, options)
Also applies options from odeset.
Description
The spatial derivatives are discretized on xmesh and the resulting system of ODEs is advanced in time. The heat equation u_t = u_xx corresponds to c = 1, f = dudx and s = 0.
Use pdeval to evaluate the solution between mesh points. Choose the mesh fine enough in regions where the solution changes quickly.
Input arguments
m- Symmetry:
0slab,1cylindrical,2spherical. pdefun- Handle
[c, f, s] = pdefun(x, t, u, dudx)definingc*u_t = x^(-m) * (x^m * f)_x + s. icfun- Handle
u0 = icfun(x)for the initial condition. bcfun- Handle
[pl, ql, pr, qr] = bcfun(xl, ul, xr, ur, t)for the conditionsp + q*f = 0at both ends. xmesh, tspan- Vectors of spatial points and output times, each with at least 3 and 2 entries respectively.
Output arguments
sol- Array of size
numel(tspan)-by-numel(xmesh)-by-npde:sol(i,j,k)is componentkat timetspan(i)and pointxmesh(j).
Example
Heat equation with fixed ends
m = 0;
pdefun = @(x, t, u, dudx) deal(1, dudx, 0);
icfun = @(x) sin(pi*x);
bcfun = @(xl, ul, xr, ur, t) deal(ul, 0, ur, 0);
x = linspace(0, 1, 11);
t = linspace(0, 0.1, 5);
sol = pdepe(m, pdefun, icfun, bcfun, x, t);
fprintf('%.3f %.3f\n', sol(end, 6, 1), exp(-pi^2*0.1))
Output
0.376 0.373