Skip to content

Commit 1da012f

Browse files
ggormanclaude
andcommitted
Add ABC methods (PML, Higdon, HABC), EM chapter, and fix Devito solvers
Major additions: - Implement split-field PML (Grote-Sim), second-order Higdon ABC (P=2), and Hybrid ABC with weighted absorption layer in abc_methods.py - Add electromagnetics chapter (Maxwell equations, Yee scheme, verification, GPR and waveguide applications) - Add tested book snippets for all ABC methods Fixes and improvements: - Fix sigma_max default to theory-derived 3c/W instead of hardcoded 50 - Replace linear damping ramp with polynomial d^3 in wave1D_features - Add dtype parameter to all Devito solvers for FP64 support - Standardize LaTeX notation (\hbox→\text, font-size removal) - Tighten test tolerances to match O(dx^2) theory - Add elliptic spatial convergence test and Pint unit checks - Update .gitignore for TeX artifacts and review documents All 579 tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8ff9db8 commit 1da012f

58 files changed

Lines changed: 4417 additions & 478 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ doc/pub/
5353
/_book/
5454
**/*.quarto_ipynb
5555

56+
# Root-level TeX artifacts (Quarto/Pandoc intermediates)
57+
/*.tex
58+
59+
# Quarto HTML render artifacts
60+
**/*_files/
61+
62+
# Review and planning documents
63+
book-review.md
64+
codex-review.md
65+
codex-reviewer.md
66+
review.md
67+
review-2.md
68+
review-3.md
69+
review-4.md
70+
ianmgdev_review.txt
71+
*.docx
72+
Proposed Extension Roadmap*.md
73+
5674
# Coverage
5775
.coverage
5876
coverage.xml

.typos.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ strang = "strang"
88
Strang = "Strang"
99
# Variable name for "p at iteration n" in Jacobi iteration
1010
pn = "pn"
11+
# Journal abbreviation: "J. Comput. Phys."
12+
Comput = "Comput"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.PHONY: pdf html all preview clean test test-devito test-no-devito lint format check help
44

55
# Default target
6-
all: pdf
6+
all: pdf html
77

88
# Build targets
99
pdf:

chapters/advec/advec.qmd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ u(x,0) = Ae^{-\half\left(\frac{x-L/10}{\sigma}\right)^2},
456456
$$
457457
$$
458458
u(x,0) = A\cos\left(\frac{5\pi}{L}\left( x - \frac{L}{10}\right)\right),\quad
459-
x < \frac{L}{5} \hbox{ else } 0\tp
459+
x < \frac{L}{5} \text{ else } 0\tp
460460
$$ {#eq-advec-1D-case_gaussian}
461461
The parameter $A$ is the maximum value of the initial condition.
462462
@@ -723,16 +723,16 @@ A general solution may be viewed as a collection of long and
723723
short waves with different amplitudes. Algebraically, the work
724724
simplifies if we introduce the complex Fourier component
725725
$$
726-
u(x,t)=\Aex e^{ikx},
726+
u(x,t)=A_{\text{e}} e^{ikx},
727727
$$
728728
with
729729
$$
730-
\Aex=Be^{-ikv\Delta t} = Be^{-iCk\Delta x}\tp
730+
A_{\text{e}}=Be^{-ikv\Delta t} = Be^{-iCk\Delta x}\tp
731731
$$
732-
Note that $|\Aex| \leq 1$.
732+
Note that $|A_{\text{e}}| \leq 1$.
733733
734734
It turns out that many schemes also allow a Fourier wave component as
735-
solution, and we can use the numerically computed values of $\Aex$
735+
solution, and we can use the numerically computed values of $A_{\text{e}}$
736736
(denoted $A$) to learn about the
737737
quality of the scheme. Hence, to analyze the difference scheme we have just
738738
implemented, we look at how it treats the Fourier component
@@ -862,7 +862,7 @@ A = -iC\sin p \pm \sqrt{1-C^2\sin^2 p},
862862
$$
863863
and is to be compared to the exact amplification factor
864864
$$
865-
\Aex = e^{-ikv\Delta t} = e^{-ikC\Delta x} = e^{-iCp}\tp
865+
A_{\text{e}} = e^{-ikv\Delta t} = e^{-ikC\Delta x} = e^{-iCp}\tp
866866
$$
867867
Section @sec-advec-1D-disprel compares numerical amplification factors
868868
of many schemes with the exact expression.
@@ -995,7 +995,7 @@ is constant:
995995
\end{align*}
996996
as long as $u(0)=u(L)=0$. We can therefore use the property
997997
$$
998-
\int_0^L u(x,t)dx = \hbox{const}
998+
\int_0^L u(x,t)dx = \text{const}
999999
$$
10001000
as a partial verification during the simulation. Now, any numerical method
10011001
with $C\neq 1$ will deviate from the constant, expected value, so
@@ -1469,7 +1469,7 @@ reason why this model problem has been so successful in designing and
14691469
investigating numerical methods for mixed convection/advection and
14701470
diffusion. The exact solution reads
14711471
$$
1472-
\uex (x) = \frac{e^{x/\epsilon} - 1}{e^{1/\epsilon} - 1}\tp
1472+
u_{\text{e}} (x) = \frac{e^{x/\epsilon} - 1}{e^{1/\epsilon} - 1}\tp
14731473
$$
14741474
The forthcoming plots illustrate this function for various values of
14751475
$\epsilon$.

chapters/advec/advec_devito_exercises.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ plt.loglog(sizes_lf, err_lf, 'g-^', label=f'Lax-Friedrichs (rate={rate_lf:.2f})'
170170
# Reference slopes
171171
h = np.array(sizes_up)
172172
plt.loglog(h, err_up[0]*(h[0]/h), 'k--', alpha=0.5, label='O(h)')
173-
plt.loglog(h, err_lw[0]*(h[0]/h)**2, 'k:', alpha=0.5, label='O(h²)')
173+
plt.loglog(h, err_lw[0]*(h[0]/h)**2, 'k:', alpha=0.5, label='O(h^2)')
174174

175175
plt.xlabel('Grid points')
176176
plt.ylabel('L2 Error')

chapters/appendices/formulas/formulas.qmd

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,69 +57,69 @@ derivative at the point $t_{n+\theta}=\theta t_{n+1} + (1-\theta) t_{n}$.
5757
5858
$$
5959
\begin{split}
60-
\uex'(t_n) &=
61-
[D_t\uex]^n + R^n = \frac{\uex^{n+\half} - \uex^{n-\half}}{\Delta t} +R^n,\\
62-
R^n &= -\frac{1}{24}\uex'''(t_n)\Delta t^2 + {\cal O}(\Delta t^4)
60+
u_{\text{e}}'(t_n) &=
61+
[D_tu_{\text{e}}]^n + R^n = \frac{u_{\text{e}}^{n+\half} - u_{\text{e}}^{n-\half}}{\Delta t} +R^n,\\
62+
R^n &= -\frac{1}{24}u_{\text{e}}'''(t_n)\Delta t^2 + \Oof{\Delta t^4}
6363
\end{split}
6464
$$
6565
$$
6666
\begin{split}
67-
\uex'(t_n) &=
68-
[D_{2t}\uex]^n +R^n = \frac{\uex^{n+1} - \uex^{n-1}}{2\Delta t} +
67+
u_{\text{e}}'(t_n) &=
68+
[D_{2t}u_{\text{e}}]^n +R^n = \frac{u_{\text{e}}^{n+1} - u_{\text{e}}^{n-1}}{2\Delta t} +
6969
R^n,\\
70-
R^n &= -\frac{1}{6}\uex'''(t_n)\Delta t^2 + {\cal O}(\Delta t^4)
70+
R^n &= -\frac{1}{6}u_{\text{e}}'''(t_n)\Delta t^2 + \Oof{\Delta t^4}
7171
\end{split}
7272
$$
7373
$$
7474
\begin{split}
75-
\uex'(t_n) &=
76-
[D_t^-\uex]^n +R^n = \frac{\uex^{n} - \uex^{n-1}}{\Delta t}
75+
u_{\text{e}}'(t_n) &=
76+
[D_t^-u_{\text{e}}]^n +R^n = \frac{u_{\text{e}}^{n} - u_{\text{e}}^{n-1}}{\Delta t}
7777
+R^n,\\
78-
R^n &= -\half\uex''(t_n)\Delta t + {\cal O}(\Delta t^2)
78+
R^n &= -\half u_{\text{e}}''(t_n)\Delta t + \Oof{\Delta t^2}
7979
\end{split}
8080
$$
8181
$$
8282
\begin{split}
83-
\uex'(t_n) &=
84-
[D_t^+\uex]^n +R^n = \frac{\uex^{n+1} - \uex^{n}}{\Delta t}
83+
u_{\text{e}}'(t_n) &=
84+
[D_t^+u_{\text{e}}]^n +R^n = \frac{u_{\text{e}}^{n+1} - u_{\text{e}}^{n}}{\Delta t}
8585
+R^n,\\
86-
R^n &= \half\uex''(t_n)\Delta t + {\cal O}(\Delta t^2)
86+
R^n &= \half u_{\text{e}}''(t_n)\Delta t + \Oof{\Delta t^2}
8787
\end{split}
8888
$$
8989
$$
9090
\begin{split}
91-
\uex'(t_{n+\theta}) &=
92-
[\bar D_t\uex]^{n+\theta} +R^{n+\theta} = \frac{\uex^{n+1} - \uex^{n}}{\Delta t}
91+
u_{\text{e}}'(t_{n+\theta}) &=
92+
[\bar D_tu_{\text{e}}]^{n+\theta} +R^{n+\theta} = \frac{u_{\text{e}}^{n+1} - u_{\text{e}}^{n}}{\Delta t}
9393
+R^{n+\theta},\\
94-
R^{n+\theta} &= -\half(1-2\theta)\uex''(t_{n+\theta})\Delta t +
95-
\frac{1}{6}((1 - \theta)^3 - \theta^3)\uex'''(t_{n+\theta})\Delta t^2 +
94+
R^{n+\theta} &= -\half(1-2\theta)u_{\text{e}}''(t_{n+\theta})\Delta t +
95+
\frac{1}{6}((1 - \theta)^3 - \theta^3)u_{\text{e}}'''(t_{n+\theta})\Delta t^2 +
9696
\\
97-
&\quad {\cal O}(\Delta t^3)
97+
&\quad \Oof{\Delta t^3}
9898
\end{split}
9999
$$
100100
$$
101101
\begin{split}
102-
\uex'(t_n) &=
103-
[D_t^{2-}\uex]^n +R^n = \frac{3\uex^{n} - 4\uex^{n-1} + \uex^{n-2}}{2\Delta t}
102+
u_{\text{e}}'(t_n) &=
103+
[D_t^{2-}u_{\text{e}}]^n +R^n = \frac{3u_{\text{e}}^{n} - 4u_{\text{e}}^{n-1} + u_{\text{e}}^{n-2}}{2\Delta t}
104104
+R^n,\\
105-
R^n &= \frac{1}{3}\uex'''(t_n)\Delta t^2 + {\cal O}(\Delta t^3)
105+
R^n &= \frac{1}{3}u_{\text{e}}'''(t_n)\Delta t^2 + \Oof{\Delta t^3}
106106
\end{split}
107107
$$
108108
$$
109109
\begin{split}
110-
\uex''(t_n) &=
111-
[D_tD_t \uex]^n +R^n = \frac{\uex^{n+1} - 2\uex^{n} + \uex^{n-1}}{\Delta t^2}
110+
u_{\text{e}}''(t_n) &=
111+
[D_tD_t u_{\text{e}}]^n +R^n = \frac{u_{\text{e}}^{n+1} - 2u_{\text{e}}^{n} + u_{\text{e}}^{n-1}}{\Delta t^2}
112112
+R^n,\\
113-
R^n &= -\frac{1}{12}\uex''''(t_n)\Delta t^2 + {\cal O}(\Delta t^4)
113+
R^n &= -\frac{1}{12}u_{\text{e}}''''(t_n)\Delta t^2 + \Oof{\Delta t^4}
114114
\end{split}
115115
$$ {#eq-form-trunc-fd1-center}
116116
117117
$$
118118
\begin{split}
119-
\uex(t_{n+\theta}) &= [\overline{\uex}^{t,\theta}]^{n+\theta} +R^{n+\theta}
120-
= \theta \uex^{n+1} + (1-\theta)\uex^n +R^{n+\theta},\\
121-
R^{n+\theta} &= -\half\uex''(t_{n+\theta})\Delta t^2\theta (1-\theta) +
122-
{\cal O}(\Delta t^3)\tp
119+
u_{\text{e}}(t_{n+\theta}) &= [\overline{u_{\text{e}}}^{t,\theta}]^{n+\theta} +R^{n+\theta}
120+
= \theta u_{\text{e}}^{n+1} + (1-\theta)u_{\text{e}}^n +R^{n+\theta},\\
121+
R^{n+\theta} &= -\half u_{\text{e}}''(t_{n+\theta})\Delta t^2\theta (1-\theta) +
122+
\Oof{\Delta t^3}\tp
123123
\end{split}
124124
$$ {#eq-form-trunc-avg-theta}
125125

chapters/appendices/softeng2/softeng2.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ $$
1616
u_t(x,0) = V(t),\quad x\in [0,L]
1717
$$
1818
$$
19-
u(0,t) = U_0(t)\hbox{ or } u_x(0,t)=0,\quad t\in (0,T]
19+
u(0,t) = U_0(t)\text{ or } u_x(0,t)=0,\quad t\in (0,T]
2020
$$
2121
$$
22-
u(L,t) = U_L(t)\hbox{ or } u_x(L,t)=0,\quad t\in (0,T]
22+
u(L,t) = U_L(t)\text{ or } u_x(L,t)=0,\quad t\in (0,T]
2323
$$ {#eq-wave-pde2-software-ueq2}
2424
We allow variable wave velocity $c^2(x)=q(x)$, and Dirichlet or homogeneous
2525
Neumann conditions at the boundaries.

0 commit comments

Comments
 (0)