pdepe_test


pdepe_test, MATLAB programs which illustrate how to use the MATLAB command pdepe(), which can solve initial boundary value problems (IBVP's) in one spatial dimension.

Example of a 1D Initial Boundary Value Problem:

The classic example of such a problem is the time-dependent heat equation posed on a line segment [a,b]:

        ODE: d/dt u(x,t) - d/dx a(x,t) d/dx u(x,t) = f(x,t)
        IC:  u(x,0) = u0(x)
        BC:  u(a,t) = g(t)
             u(b,t) = h(t)
      
Here,

A solution to this 1D boundary value problem is a formula for u(x,t), or, more realistically, a table of values for u(x,t) at selected times and points. For the heat equation, there are many procedures for coming up with a table of good approximations to the solution. The advantage of using MATLAB's pdepe() is that it can provide this solution automatically, that is, your only work is to provide the information that defines the problem. You hand this information to pdepe(), and it hands you back the solution.

1D Initial Boundary Value Problems that PDEPE Can Solve:

The simplest version of the pdepe() command has the form:

        sol = pdepe ( m, pdefun, icfun, bcfun, xmesh, tspan )
      
The input parameters have the following meanings: and the output is:

The pdepe() function thinks of the equation to be solved as

        c() * du/dt = 1/x^m d/dx ( x^m f() ) + s()
      
The variable u may be a scalar or a vector. If u is a vector, then so are the quantities c(), f(), and s().

In the typical case, c() is 1, and m is 0. Moreover, c(), f() and s() are functions of x, t, u, and du/dx. That means that a simple version of the heat equation such as:

        ut - d/dx ( sin(x) * du/dx ) = x^2
      
can be put into the pdepe() format by prescribing:
        c = 1.0;
        f = sin(x) * dudx;
        s = x^2;
      

The pdefun() function must have the form:

        [ c, f, s ] = pdefun ( x, t, u, dudx )
      
Here, the input is The output to be computed by pdefun() is a set of three items, which are scalar if u() is a scalar, or column vectors if u() is a vector:

The icfun() function must have the form:

        u = icfun ( x )
      
Here, the input is and the output is

The pdepe() function models the boundary conditions as:

        pl ( x, t, u ) + ql ( x, t, u ) * f ( x, t, u, dudx ) = 0  at x = xl;
        pr ( x, t, u ) + qr ( x, t, u ) * f ( x, t, u, dudx ) = 0  at x = xr.
      
The pl/pr functions take care of Dirichlet boundary conditions, while the ql/qr functions take care of flux or Neumann conditions. For example, to impose the condition:
        u(xl) = 7
        2 * u(xr) + sin ( xr ) * dudx ( xr ) = sqrt ( t )
      
assuming that f(x,t,u,dudx) is defined to be dudx, we simply set:
        pl = ur - 7.0;
        ql = 0.0;
        pr = 2.0 * ur - sqrt ( t );
        qr = sin ( xr );
      

The bcfun() function must have the form:

        [ pl, ql, pr, qr ] = bcfun ( xl, ul, xr, ur, t )
      
Here, the input is and the output is

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

PDEPE is available in a MATLAB version.

Related Data and Programs:

BVP4C, MATLAB programs which illustrate how to use the MATLAB command bvp4c(), which can solve boundary value problems (BVP's) in one spatial dimension.

Reference:

Examples and Tests:

Example 1 is a version of the heat equation.

Example 2 is a version of the convection-diffusion equation, with a variable coefficient.

Example 3 is a nonlinear predator prey system for the two variables [u,v].

Example 4 is a system of convection-diffusion equations with variable coefficient.

You can go up one level to the MATLAB source codes.


Last revised on 06 September 2013.