This is our first PDE having a second derivative in time. As in the advection equation, u(x,t)=ϕ(x−ct) is a solution of (12.4.1), but now so is u(x,t)=ϕ(x+ct) for any twice-differentiable ϕ (see Exercise 2). Thus, the wave equation supports advection in both directions simultaneously.
We will use x∈[0,1] and t>0 as the domain. Because u has two derivatives in t and in x, we need two boundary conditions. We will use the Dirichlet conditions
This equation can be rearranged to solve for Ui,j+1 in terms of values at time levels j and j−1. Rather than pursue this method, however, we will turn to the method of lines.
In order to be compatible with the standard IVP solvers that we have encountered, we must recast (12.4.1) as a first-order system in time. Using our typical methodology, we would define y=ut and derive
This second form is appealing in part because it’s equivalent to Maxwell’s equations for electromagnetism. In the Maxwell form we typically replace the velocity initial condition in (12.4.3) with a condition on z, which may be physically more relevant in some applications:
Because waves travel in both directions, there is no preferred upwind direction. This makes a centered finite difference in space appropriate. Before application of the boundary conditions, semidiscretization of (12.4.6) leads to
The boundary conditions (12.4.2) suggest that we should remove both of the end values of u from the discretization, but retain all of the z values. We use w(t) to denote the vector of all the unknowns in the semidiscretization. When computing w′(t), we extract the u and z components, and we use dedicated functions for padding with the zero end values or chopping off the zeros as necessary.
An interesting situation is when the wave speed c changes discontinuously, as when light passes from one material into another. For this we must replace the term c2 in (12.4.8) with the matrix diag(c2(x0),…,c2(xm)).
⌨ Suppose the wave equation has homogeneous Neumann conditions on u at each boundary instead of Dirichlet conditions. Using the Maxwell formulation (12.4.6), we have zt=c2ux, so z is constant in time at each boundary. Therefore, the endpoint values of z can be taken from the initial condition and removed from the ODE, while the entire u vector is now part of the ODE.
Modify Demo 12.4.1 to solve the PDE there with Neumann instead of Dirichlet conditions, and make an animation or space-time portrait of the solution. In what major way is it different from the Dirichlet case?
⌨ The equations ut=zx−σu, zt=c2uxx model electromagnetism in an imperfect conductor. Repeat Demo 12.4.2 with σ(x)=2+2sign(x). (This causes waves in the half-domain x>0 to decay in time.)
The nonlinear sine–Gordon equationutt−uxx=sinu has interesting solutions.
(a) ✍ Write the equation as a first-order system in the variables u and v=ut.
(b) ⌨ Assume periodic end conditions on [−10,10] and discretize at m=200 points. Let u(x,0)=πe−x2 and ut(x,0)=0. Solve the system using RK4 between t=0 and t=50, and make a plot or animation of the solution.
The deflections of a stiff beam, such as a ruler, are governed by the PDE utt=−uxxxx.
(a) ✍ Show that the beam PDE is equivalent to the first-order system
(b) ⌨ Assuming periodic end conditions on [−1,1], use m=100, let u(x,0)=exp(−24x2), v(x,0)=0, and simulate the solution of the beam equation for 0≤t≤1 using Function 6.7.2 with n=100 time steps. Make a plot or animation of the solution.