@@ -39,6 +39,7 @@ in the forthcoming text by finite difference methods.
3939label{wave:string}
4040idx{waves!on a string}
4141idx{wave equation!1D}
42+ idx{wave! velocity}
4243
4344We begin our study of wave equations by simulating one-dimensional
4445waves on a string, say on a guitar or violin.
@@ -107,6 +108,8 @@ idx{mesh!finite differences}
107108===== Discretizing the domain =====
108109label{wave:string:mesh}
109110
111+ idx{mesh! uniform}
112+
110113The temporal domain $[0,T]$ is represented by a finite number of mesh points
111114
112115!bt
@@ -156,6 +159,9 @@ develop algebraic equations for computing the mesh function.
156159===== Fulfilling the equation at the mesh points =====
157160label{wave:string:samplingPDE}
158161
162+ idx{PDE! algebraic version}
163+ idx{finite difference scheme}
164+
159165In the finite difference method, we relax
160166the condition that (ref{wave:pde1}) holds at all points in
161167the space-time domain $(0,L)\times (0,T]$ to the requirement that the PDE is
@@ -222,14 +228,18 @@ label{wave:pde1:step3a}
222228
223229=== Interpretation of the equation as a stencil ===
224230
231+ idx{finite difference scheme}
232+ idx{difference equations}
233+ idx{sampling (a PDE)}
234+
225235A characteristic feature of (ref{wave:pde1:step3b}) is that it
226236involves $u$ values from neighboring points only: $u_i^{n+1}$,
227237$u^n_{i\pm 1}$, $u^n_i$, and $u^{n-1}_i$. The circles in Figure
228238ref{wave:pde1:fig:mesh} illustrate such neighboring mesh points that
229239contribute to an algebraic equation. In this particular case, we have
230240sampled the PDE at the point $(2,2)$ and constructed
231- (ref{wave:pde1:step3b}), which then involves a coupling of $u_nm1^1 $,
232- $u_n^2 $, $u_nm1 ^2$, $u_3^2 $, and $u_nm1^3 $. The term *stencil* is often
241+ (ref{wave:pde1:step3b}), which then involves a coupling of $u_1^2 $,
242+ $u_2^3 $, $u_2 ^2$, $u_2^1 $, and $u_3^2 $. The term *stencil* is often
233243used about the algebraic equation at a mesh point, and the geometry of
234244a typical stencil is illustrated in Figure
235245ref{wave:pde1:fig:mesh}. One also often refers to the algebraic
@@ -269,6 +279,8 @@ The other initial condition can be computed by
269279===== Formulating a recursive algorithm =====
270280label{wave:string:alg}
271281
282+ idx{wave equation! 1D, discrete}
283+
272284We assume that $u^n_i$ and $u^{n-1}_i$ are available for
273285$i=0,\ldots,N_x$. The only unknown quantity in
274286(ref{wave:pde1:step3b}) is therefore $u^{n+1}_i$, which we now can
@@ -333,18 +345,18 @@ label{wave:pde1:step4:1}
333345\end{equation}
334346!et
335347Figure ref{wave:pde1:fig:stencil:u1} illustrates how (ref{wave:pde1:step4:1})
336- connects four instead of five points: $u^1_2$, $u_n ^0$, $u_nm1 ^0$, and $u_3^0$.
348+ connects four instead of five points: $u^1_2$, $u_1 ^0$, $u_2 ^0$, and $u_3^0$.
337349
338350FIGURE: [mov-wave/D_stencil_gpl/stencil_n0_interior, width=500] Modified stencil for the first time step. label{wave:pde1:fig:stencil:u1}
339351
340352We can now summarize the computational algorithm:
341353
342354 o Compute $u^0_i=I(x_i)$ for $i=0,\ldots,N_x$
343- o Compute $u^1_i$ by (ref{wave:pde1:step4:1}) and set $u_i^1=0$
344- for the boundary points $i=0$ and $i=N_x$, for $n=1,2,\ldots,N-1 $,
355+ o Compute $u^1_i$ by (ref{wave:pde1:step4:1}) for $i=1,2,\ldots,N_x-1$ and set $u_i^1=0$
356+ for the boundary points given by $i=0$ and $i=N_x$,
345357 o For each time level $n=1,2,\ldots,N_t-1$
346358 o apply (ref{wave:pde1:step4}) to find $u^{n+1}_i$ for $i=1,\ldots,N_x-1$
347- o set $u^{n+1}_i=0$ for the boundary points $i=0$, $i=N_x$.
359+ o set $u^{n+1}_i=0$ for the boundary points having $i=0$, $i=N_x$.
348360
349361The algorithm essentially consists of moving a finite difference
350362stencil through all the mesh points, which can be seen as an animation
@@ -369,10 +381,6 @@ memory at as few time levels as possible.
369381In a Python implementation of this algorithm, we use the array
370382elements `u[i]` to store $u^{n+1}_i$, `u_n[i]` to store $u^n_i$, and
371383`u_nm1[i]` to store $u^{n-1}_i$.
372- Our naming convention is to use `u` for the
373- unknown new spatial field to be computed and have all previous time
374- levels in a list `u_n` that we index as `u_n`, `u_nm1`, `u_n[-2]`
375- and so on. For the wave equation, `u_n` has just length 2.
376384
377385The following Python snippet realizes the steps in the computational
378386algorithm.
@@ -413,6 +421,8 @@ for n in range(1, Nt):
413421
414422======= Verification =======
415423
424+ idx{source term}
425+
416426Before implementing the algorithm, it is convenient to add a source
417427term to the PDE (ref{wave:pde1}), since that gives us more freedom in
418428finding test problems for verification. Physically, a source term acts
@@ -484,6 +494,8 @@ label{wave:pde2:step3c}
484494===== Using an analytical solution of physical significance =====
485495label{wave:pde2:fd:standing:waves}
486496
497+ idx{verification! convergence rates}
498+
487499Many wave problems feature sinusoidal oscillations in time
488500and space. For example, the original PDE problem
489501(ref{wave:pde1})-(ref{wave:pde1:bc:L}) allows an exact solution
@@ -539,6 +551,8 @@ label{wave:pde2:fd:MMS}
539551
540552=== Specifying the solution and computing corresponding data ===
541553
554+ idx{manufactured solution}
555+
542556One problem with the exact solution (ref{wave:pde2:test:ue}) is
543557that it requires a simplification ($V=0, f=0$) of the implemented problem
544558(ref{wave:pde2})-(ref{wave:pde2:bc:L}). An advantage of using
@@ -569,6 +583,9 @@ u_t(x,0) &= V(x) = x(L-x)\tp
569583
570584=== Defining a single discretization parameter ===
571585
586+ idx{verification! convergence rates}
587+ idx{discretization parameter}
588+
572589To verify the code, we compute the convergence rates in a series of
573590simulations, letting each simulation use a finer mesh than the
574591previous one. Such empirical estimation of convergence rates relies on
@@ -609,8 +626,8 @@ C_t h^r + C_x\left(\frac{c}{C}\right)^r h^r
609626We choose an initial discretization parameter $h_0$ and run
610627experiments with decreasing $h$: $h_i=2^{-i}h_0$, $i=1,2,\ldots,m$.
611628Halving $h$ in each experiment is not necessary, but it is a common
612- choice. For each experiment we must record $E$ and $h$. A standard
613- choice of error measure is the $\ell^2$ or $\ell^\infty$ norm of the
629+ choice. For each experiment we must record $E$ and $h$. Standard
630+ choices of error measure are the $\ell^2$ and $\ell^\infty$ norms of the
614631error mesh function $e^n_i$:
615632
616633!bt
@@ -619,7 +636,7 @@ E &= ||e^n_i||_{\ell^2} = \left( \Delta t\Delta x
619636\sum_{n=0}^{N_t}\sum_{i=0}^{N_x}
620637(e^n_i)^2\right)^{\half},\quad e^n_i = \uex(x_i,t_n)-u^n_i,
621638label{wave:pde2:fd:MMS:E:l2}\\
622- E &= ||e^n_i||_{\ell^\infty} = \max_{i,n} |e^i_n |\tp
639+ E &= ||e^n_i||_{\ell^\infty} = \max_{i,n} |e^n_i |\tp
623640label{wave:pde2:fd:MMS:E:linf}
624641\end{align}
625642!et
@@ -641,12 +658,12 @@ E &= ||e^n_i||_{\ell^2} = \left( \Delta x\sum_{i=0}^{N_x}
641658E &= ||e^n_i||_{\ell^\infty} = \max_{0\leq i\leq N_x} |e^{n}_i|\tp
642659\end{align}
643660!et
644- The important issue is that our error measure $E$ must be one number
645- that represents the error in the simulation.
661+ The important point is that the error measure ($E$) for the simulation is represented by a single number.
646662
647663=== Computing rates ===
648664
649- Let $E_i$ be the error measure in experiment (mesh) number $i$ and
665+ Let $E_i$ be the error measure in experiment (mesh) number $i$
666+ (not to be confused with the spatial index $i$) and
650667let $h_i$ be the corresponding discretization parameter ($h$).
651668With the error model $E_i = Dh_i^r$, we can
652669estimate $r$ by comparing two consecutive
@@ -714,8 +731,7 @@ and $V(x)={\half}x(L-x)$.
714731
715732To realize that the chosen $\uex$ is also an exact
716733solution of the discrete equations,
717- we first remind ourselves that $t_n=n\Delta t$ before we
718- establish that
734+ we first remind ourselves that $t_n=n\Delta t$ so that
719735
720736!bt
721737\begin{align}
0 commit comments