Hyperbolic PDEs

This section describes the solution of a hyperbolic PDE problem. The problem is solved using the PDE app and command-line functions.

Wave Equation

As an example of a hyperbolic PDE, let us solve the wave equation


for transverse vibrations of a membrane on a square with corners in (–1,–1), (–1,1), (1,–1), and (1,1). The membrane is fixed (u = 0) at the left and right sides, and is free (∂u/∂n = 0) at the upper and lower sides. Additionally, we need initial values for u(t0) and ∂u(t0)/∂t

The initial values need to match the boundary conditions for the solution to be well-behaved. If we start at t = 0,




are initial values that satisfy the boundary conditions. The reason for the arctan and exponential functions is to introduce more modes into the solution.

Using the PDE App

Use the PDE app in the generic scalar mode. Draw the square using the Rectangle/square option from the Draw menu or the button with the rectangle icon. Proceed to define the boundary conditions by clicking the ∂Ω button and then double-click the boundaries to define the boundary conditions.

Initialize the mesh by clicking the Δ button or by selecting Initialize mesh from the Mesh menu.

Also, define the hyperbolic PDE by opening the PDE Specification dialog box, selecting the hyperbolic PDE, and entering the appropriate coefficient values. The general hyperbolic PDE is described by


so for the wave equation you get c = 1, a = 0, f = 0, and d = 1.

Before solving the PDE, select Parameters from the Solve menu to open the Solve Parameters dialog box. As a list of times, enter linspace(0,5,31) and as initial values for u:


and for ∂u/∂t , enter


Finally, click the = button to compute the solution. The best plot for viewing the waves moving in the x and y directions is an animation of the whole sequence of solutions. Animation is a very real time and memory consuming feature, so you may have to cut down on the number of times at which to compute a solution. A good suggestion is to check the Plot in x-y grid option. Using an x-y grid can speed up the animation process significantly.

Wave Equation Using Command-Line Functions

This example shows how to solve the wave equation using command-line functions. It solves the equation with the preceding boundary conditions and the initial values, starting at time 0 and then every 0.05 seconds for five seconds.

The geometry is described in the file squareg.m and the boundary conditions in the file squareb3.m. The following sequence of commands then generates a solution and animates it. First, create a mesh and define the initial values and the times for which you want to solve the equation:

[p,e,t] = initmesh('squareg');

x = p(1,:)'; y = p(2,:)';

u0 = atan(cos(pi/2*x));
ut0 = 3*sin(pi*x).*exp(sin(pi/2*y));

n = 31; % number of frames in eventual animation
tlist = linspace(0,5,n); % list of times

You are now ready to solve the wave equation. The general form for the hyperbolic PDE is

$$d\frac{\partial^2 u}{\partial t^2} - \nabla\cdot(c\nabla u) + au = f,$$

so here you have d = 1, c = 1, a = 0, and f = 0:

d = 1;
c = 1;
a = 0;
f = 0;
428 successful steps
62 failed attempts
982 function evaluations
1 partial derivatives
142 LU decompositions
981 solutions of linear systems

To visualize the solution, you can animate it. Interpolate to a rectangular grid to speed up the plotting:

delta = -1:0.1:1;
[uxy,tn,a2,a3] = tri2grid(p,t,uu(:,1),delta,delta);
gp = [tn;a2;a3];

umax = max(max(uu));
umin = min(min(uu));

M = moviein(n);
for i=1:n,
    axis([-1 1 -1 1 umin umax]); caxis([umin umax]);
    M(:,i) = getframe;

You can find a complete solution of this problem, including animation, in pdedemo6. If you have lots of memory, you can try increasing n, the number of frames in the movie.

Was this topic helpful?