Wave equations¶
Linear wave equation in 1D¶
The standard, linear wave equation in 1D for a function u(x,t) reads
where c is the constant wave velocity of the physical medium in [0,L]. The equation can also be more compactly written as
Centered, second-order finite differences are a natural choice for discretizing the derivatives, leading to
Inserting the exact solution ue(x,t) in (723) makes this function fulfill the equation if we add the term R:
Our purpose is to calculate the truncation error R. From (670)-(671) we have that
when we use a notation taking into account that ue is a function of two variables and that derivatives must be partial derivatives. The notation ue,tt means ∂2ue/∂t2.
The same formula may also be applied to the x-derivative term:
Equation (724) now becomes
Because ue fulfills the partial differential equation (PDE) (722), the first, third, and fifth term cancel out, and we are left with
showing that the scheme (723) is of second order in the time and space mesh spacing.
Finding correction terms¶
Can we add correction terms to the PDE and increase the order of Rni in (725)? The starting point is
From the previous analysis we simply get (725) again, but now with C:
The idea is to let Cni cancel the Δt2 and Δx2 terms to make Rni=O(Δt4,Δx4):
Essentially, it means that we add a new term
to the right-hand side of the PDE. We must either discretize these 4th-order derivatives directly or rewrite them in terms of lower-order derivatives with the aid of the PDE. The latter approach is more feasible. From the PDE we have the operator equality
so
Assuming u is smooth enough, so that uxxtt=uttxx, these relations lead to
A natural discretization is
Writing out [DxDxDtDtu]ni as [DxDx(DtDtu)]ni gives
Now the unknown values un+1i+1, un+1i, and un+1i−1 are coupled, and we must solve a tridiagonal system to find them. This is in principle straightforward, but it results in an implicit finite difference schemes, while we had a convenient explicit scheme without the correction terms.
Extension to variable coefficients¶
Now we address the variable coefficient version of the linear 1D wave equation,
or written more compactly as
The discrete counterpart to this equation, using arithmetic mean for λ and centered differences, reads
The truncation error is the residual R in the equation
The difficulty with (730) is how to compute the truncation error of the term [Dx¯λxDxue]ni.
We start by writing out the outer operator:
With the aid of (658)-(659) and (674)-(675) we have
where we have introduced the short form
Similarly, we find that
Inserting these expressions in the outer operator (731) results in
The reason for {\mathcal{O}(\Delta x^4)} in the remainder is that there are coefficients in front of this term, say H\Delta x^4, and the subtraction and division by \Delta x results in [D_x H]^n_i\Delta x^4.
We can now use (658)-(659) to express the D_x operator in [D_x \lambda {u_{\small\mbox{e}, x}}]^n_i as a derivative and a truncation error:
Expressions like [D_x G]^n_i\Delta x^2 can be treated in an identical way,
There will be a number of terms with the \Delta x^2 factor. We lump these now into {\mathcal{O}(\Delta x^2)}. The result of the truncation error analysis of the spatial derivative is therefore summarized as
After having treated the [D_tD_t{u_{\small\mbox{e}}}]^n_i term as well, we achieve
The main conclusion is that the scheme is of second-order in time and space also in this variable coefficient case. The key ingredients for second order are the centered differences and the arithmetic mean for \lambda: all those building blocks feature second-order accuracy.
1D wave equation on a staggered mesh¶
Linear wave equation in 2D/3D¶
The two-dimensional extension of (721) takes the form
where now c(x,y) is the constant wave velocity of the physical medium [0,L]\times [0,H]. In the compact notation, the PDE (732) can be written
in 2D, while the 3D version reads
for (x,y,z)\in (0, L)\times (0,H)\times (0,B) and t\in (0,T].
Approximating the second-order derivatives by the standard formulas (670)-(671) yields the scheme
The truncation error is found from
The calculations from the 1D case can be repeated to the terms in the y and z directions. Collecting terms that fulfill the PDE, we end up with