Mathematics    

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 .

The PDEs are

where

. The equations hold on an interval for times .

The solution 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 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 , , and terms in Equation 14-4.

  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 and (Equation 14-6) of the boundary conditions in the function pdex4bc.

  1. Select mesh points for the solution. The solution changes rapidly for small . 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, , evaluated at t(i) and x(j).
  3. View the results. The surface plots show the behavior of the solution components.

  Changing PDE Integration Properties Selected Bibliography