Mathematics Previous page   Next Page

Example: Electrodynamics Problem

This example illustrates the solution of a system of partial differential equations. The problem is taken from electrodynamics. It has boundary layers at both ends of the interval, and the solution changes rapidly for small t.

The PDEs are

where f (y) = exp(5.73 y) minus exp (-11.46 y). The equations hold on an interval 0 less than or equal to x less than or equal to 1 for times t greater than or equal to 0.

The solution u satisfies the initial conditions

and boundary conditions

  1. Rewrite the PDE. In the form expected by pdepe, the equations are
  1. The boundary conditions on the partial derivatives of u have to be written in terms of the flux. In the form expected by pdepe, the left boundary condition is

and the right boundary condition is

  1. Code the PDE. After you rewrite the PDE in the form shown above, you can code it as a function that pdepe can use. The function must be of the form
  1. where c, f, and s correspond to the c, f, and s terms in Equation 5-3.

  1. Code the initial conditions function. The initial conditions function must be of the form
  1. The code below represents the initial conditions in the function pdex4ic.

  1. Code the boundary conditions function. The boundary conditions functions must be of the form
  1. The code below evaluates the components p(x,t,u) and q(x,t) (Equation 5-5) of the boundary conditions in the function pdex4bc.

  1. Select mesh points for the solution. The solution changes rapidly for small t. The program selects the step size in time to resolve this sharp change, but to see this behavior in the plots, output times must be selected accordingly. There are boundary layers in the solution at both ends of [0,1], so mesh points must be placed there to resolve these sharp changes. Often some experimentation is needed to select the mesh that reveals the behavior of the solution.
  2. Apply the PDE solver. The example calls pdepe with m = 0, the functions pdex4pde, pdex4ic, and pdex4bc, and the mesh defined by x and t at which pdepe is to evaluate the solution. The pdepe function returns the numerical solution in a three-dimensional array sol, where sol(i,j,k) approximates the kth component of the solution, u sub k, evaluated at t(i) and x(j).
  3. View the results. The surface plots show the behavior of the solution components.

Previous page  Evaluating the Solution at Specific Points Selected Bibliography Next page

© 1994-2005 The MathWorks, Inc.