Skip to content

Commit 687f534

Browse files
committed
Address review feedback: MathJax macros, figure improvements, grammar fixes
- Add MathJax macro definitions for HTML output in _quarto.yml - Regenerate stencil figures with legend explaining known/unknown values - Update figure captions to be more descriptive - Fix gendered pronoun in softeng2 appendix - Fix malformed figure captions in diffu_exer.qmd - Remove orphaned LaTeX label{} in diffu_app.qmd - Improve verbose phrasing in wave_app.qmd and nonlin_pde1D.qmd
1 parent 27f4a0e commit 687f534

13 files changed

Lines changed: 229 additions & 15 deletions

_quarto.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,93 @@ format:
4141
number-depth: 3
4242
crossref:
4343
chapters: true
44+
include-in-header:
45+
text: |
46+
<script>
47+
MathJax = {
48+
tex: {
49+
macros: {
50+
half: "\\frac{1}{2}",
51+
halfi: "{1/2}",
52+
tp: "\\thinspace .",
53+
uex: "u_{\\mbox{\\footnotesize e}}",
54+
uexd: ["u_{\\mbox{\\footnotesize e}, #1}", 1],
55+
vex: "v_{\\mbox{\\footnotesize e}}",
56+
Vex: "V_{\\mbox{\\footnotesize e}}",
57+
vexd: ["v_{\\mbox{\\footnotesize e}, #1}", 1],
58+
Aex: "A_{\\mbox{\\footnotesize e}}",
59+
wex: "w_{\\mbox{\\footnotesize e}}",
60+
Ddt: ["\\frac{D #1}{dt}", 1],
61+
E: ["\\hbox{E}\\lbrack #1 \\rbrack", 1],
62+
Var: ["\\hbox{Var}\\lbrack #1 \\rbrack", 1],
63+
Std: ["\\hbox{Std}\\lbrack #1 \\rbrack", 1],
64+
xpoint: "\\boldsymbol{x}",
65+
normalvec: "\\boldsymbol{n}",
66+
Oof: ["\\mathcal{O}(#1)", 1],
67+
x: "\\boldsymbol{x}",
68+
X: "\\boldsymbol{X}",
69+
uu: "\\boldsymbol{u}",
70+
vv: "\\boldsymbol{v}",
71+
w: "\\boldsymbol{w}",
72+
acc: "\\boldsymbol{a}",
73+
rpos: "\\boldsymbol{r}",
74+
V: "\\boldsymbol{V}",
75+
e: "\\boldsymbol{e}",
76+
f: "\\boldsymbol{f}",
77+
F: "\\boldsymbol{F}",
78+
stress: "\\boldsymbol{\\sigma}",
79+
strain: "\\boldsymbol{\\varepsilon}",
80+
stressc: "{\\sigma}",
81+
strainc: "{\\varepsilon}",
82+
I: "\\boldsymbol{I}",
83+
T: "\\boldsymbol{T}",
84+
U: "\\boldsymbol{U}",
85+
q: "\\boldsymbol{q}",
86+
g: "\\boldsymbol{g}",
87+
dfc: "\\alpha",
88+
ii: "\\boldsymbol{i}",
89+
jj: "\\boldsymbol{j}",
90+
kk: "\\boldsymbol{k}",
91+
ir: "\\boldsymbol{i}_r",
92+
ith: "\\boldsymbol{i}_{\\theta}",
93+
iz: "\\boldsymbol{i}_z",
94+
Ix: "\\mathcal{I}_x",
95+
Iy: "\\mathcal{I}_y",
96+
Iz: "\\mathcal{I}_z",
97+
It: "\\mathcal{I}_t",
98+
If: "\\mathcal{I}_s",
99+
Ifd: "{I_d}",
100+
Ifb: "{I_b}",
101+
setb: ["#1^0", 1],
102+
sete: ["#1^{-1}", 1],
103+
setl: ["#1^-", 1],
104+
setr: ["#1^+", 1],
105+
seti: ["#1^i", 1],
106+
sequencei: ["\\left\\{ {#1}_i \\right\\}_{i\\in\\If}", 1],
107+
sequencej: ["\\left\\{ {#1}_j \\right\\}_{j\\in\\If}", 1],
108+
stepzero: "*",
109+
stephalf: "***",
110+
stepone: "**",
111+
basphi: "\\varphi",
112+
baspsi: "\\psi",
113+
refphi: "\\tilde\\basphi",
114+
psib: "\\boldsymbol{\\psi}",
115+
sinL: ["\\sin\\left((#1+1)\\pi\\frac{x}{L}\\right)", 1],
116+
xno: ["x_{#1}", 1],
117+
Xno: ["X_{(#1)}", 1],
118+
yno: ["y_{#1}", 1],
119+
Yno: ["Y_{(#1)}", 1],
120+
xdno: ["\\boldsymbol{x}_{#1}", 1],
121+
dX: "\\, \\mathrm{d}X",
122+
dx: "\\, \\mathrm{d}x",
123+
ds: "\\, \\mathrm{d}s",
124+
Real: "\\mathbb{R}",
125+
Integerp: "\\mathbb{N}",
126+
Integer: "\\mathbb{Z}"
127+
}
128+
}
129+
};
130+
</script>
44131
pdf:
45132
documentclass: scrbook
46133
classoption:

chapters/appendices/softeng2/softeng2.qmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,7 @@ user will not notice a change to properties.
778778
779779
The only argument against direct attribute access in class `Mesh`
780780
is that the attributes are read-only so we could avoid offering
781-
a set function. Instead, we rely on the user that she does not
782-
assign new values to the attributes.
781+
a set function. Instead, we rely on the user not to assign new values to the attributes.
783782
:::
784783
785784
## Class Function

chapters/diffu/diffu_app.qmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,7 @@ governed by the [Cable equation](http://en.wikipedia.org/wiki/Cable_equation):
458458
$$
459459
c_m \frac{\partial V}{\partial t} =
460460
\frac{1}{r_l}\frac{\partial^2 V}{\partial x^2} - \frac{1}{r_m}V
461-
label{}
462-
$$
461+
$$ {#eq-diffu-app-cable}
463462
where $V(x,t)$ is the voltage to be determined,
464463
$c_m$ is capacitance of the neuronal fiber, while
465464
$r_l$ and $r_m$ are measures of the resistance.

chapters/diffu/diffu_exer.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,9 @@ time steps.
965965
966966
Running the `investigate` function, we get the following plots:
967967
968-
![FIGURE: [fig-diffu/welding_gamma0_2, width=800 frac=1]](fig/welding_gamma0_025){width="100%"}
968+
![Temperature distribution for $\gamma = 0.025$: the heat source moves very slowly on the diffusion time scale.](fig/welding_gamma0_025){width="100%"}
969969
970-
![FIGURE: [fig-diffu/welding_gamma5, width=800 frac=1]](fig/welding_gamma1){width="100%"}
970+
![Temperature distribution for $\gamma = 1$: the two scaling approaches give identical results.](fig/welding_gamma1){width="100%"}
971971
972972
![For $\gamma\ll 1$ as in $\gamma = 0.025$, the heat source moves very
973973
slowly on the diffusion time scale and has hardly entered the medium,

chapters/diffu/diffu_fd3.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ F_x = \frac{\dfc\Delta t}{\Delta x^2},\quad F_y = \frac{\dfc\Delta t}{\Delta y^2
6666
$$
6767
are the Fourier numbers in $x$ and $y$ direction, respectively.
6868
69-
![3x2 2D mesh.](fig/mesh3x2){#fig-diffu-2D-fig-mesh3x2 width="500px"}
69+
![A 2D mesh with $N_x=3$ and $N_y=2$ cells, showing interior and boundary points.](fig/mesh3x2){#fig-diffu-2D-fig-mesh3x2 width="500px"}
7070
7171
## Numbering of mesh points versus equations and unknowns {#sec-diffu-2D-numbering}
7272
@@ -262,7 +262,7 @@ p = (j-1)(N_x-1) + i,
262262
$$
263263
for $i=1,\ldots,N_x-1$, $j=1,\ldots,N_y-1$.
264264
265-
![4x3 2D mesh.](fig/mesh4x3){#fig-diffu-2D-fig-mesh4x3 width="700px"}
265+
![A 2D mesh with $N_x=4$ and $N_y=3$ cells, illustrating the unknown numbering scheme.](fig/mesh4x3){#fig-diffu-2D-fig-mesh4x3 width="700px"}
266266
267267
We can continue with illustrating a bit larger mesh, $N_x=4$ and $N_y=3$,
268268
see Figure @fig-diffu-2D-fig-mesh4x3. The corresponding coefficient matrix

chapters/nonlin/nonlin_pde1D.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ d_1 &= f(u^-_1)\tp
619619
Other entries are as in the $2\times 2$ system.
620620
621621
### Newton's method
622-
The Jacobian must be derived in order to use Newton's method. Here it means
622+
Using Newton's method requires deriving the Jacobian. Here it means
623623
that we need to differentiate $F(u)=A(u)u - b(u)$ with respect to
624624
the unknown parameters
625625
$u_0,u_1,\ldots,u_m$ ($m=N_x$ or $m=N_x-1$, depending on whether the
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#!/usr/bin/env python
2+
"""
3+
Generate stencil figures for the wave equation chapter.
4+
5+
This script generates three stencil diagrams:
6+
- stencil_n_interior.png: Standard 5-point stencil at interior point
7+
- stencil_n0_interior.png: Modified 4-point stencil for first time step
8+
- stencil_n_left.png: Modified stencil at left boundary (Neumann condition)
9+
10+
Each figure includes a legend explaining:
11+
- Filled blue circles: Known values (computed at previous time steps)
12+
- Empty black circle: Unknown value (to be computed)
13+
"""
14+
15+
import matplotlib.patches as mpatches
16+
import matplotlib.pyplot as plt
17+
18+
19+
def create_stencil_figure(
20+
known_points,
21+
unknown_point,
22+
title,
23+
filename,
24+
xlim=(0, 5),
25+
ylim=(0, 5),
26+
):
27+
"""
28+
Create a stencil figure with legend.
29+
30+
Parameters
31+
----------
32+
known_points : list of tuples
33+
List of (i, n) coordinates for known values
34+
unknown_point : tuple
35+
(i, n) coordinate for the unknown value
36+
title : str
37+
Figure title
38+
filename : str
39+
Output filename
40+
xlim, ylim : tuples
41+
Axis limits
42+
"""
43+
fig, ax = plt.subplots(figsize=(8, 6))
44+
45+
# Plot grid
46+
ax.set_xlim(xlim)
47+
ax.set_ylim(ylim)
48+
ax.set_xticks(range(xlim[0], xlim[1] + 1))
49+
ax.set_yticks(range(ylim[0], ylim[1] + 1))
50+
ax.grid(True, linestyle='--', alpha=0.5)
51+
ax.set_aspect('equal')
52+
53+
# Plot known points (filled blue circles)
54+
for i, n in known_points:
55+
circle = plt.Circle(
56+
(i, n), 0.15, fill=True, color='blue', linewidth=2
57+
)
58+
ax.add_patch(circle)
59+
60+
# Plot unknown point (empty black circle)
61+
i, n = unknown_point
62+
circle = plt.Circle(
63+
(i, n), 0.15, fill=False, color='black', linewidth=2
64+
)
65+
ax.add_patch(circle)
66+
67+
# Labels
68+
ax.set_xlabel('index i', fontsize=12)
69+
ax.set_ylabel('index n', fontsize=12)
70+
ax.set_title(title, fontsize=14)
71+
72+
# Create legend
73+
known_patch = mpatches.Patch(
74+
facecolor='blue', edgecolor='blue',
75+
label='Known (from previous time steps)'
76+
)
77+
unknown_patch = mpatches.Patch(
78+
facecolor='white', edgecolor='black',
79+
label='Unknown (to be computed)'
80+
)
81+
ax.legend(
82+
handles=[known_patch, unknown_patch],
83+
loc='upper right',
84+
fontsize=10,
85+
framealpha=0.9
86+
)
87+
88+
plt.tight_layout()
89+
plt.savefig(filename, dpi=150, bbox_inches='tight')
90+
plt.close()
91+
print(f"Generated: {filename}")
92+
93+
94+
def main():
95+
# Figure 1: Standard interior stencil (5 points)
96+
# Computing u[2]^3 from u[1]^2, u[2]^2, u[3]^2, u[2]^1
97+
create_stencil_figure(
98+
known_points=[(1, 2), (2, 2), (3, 2), (2, 1)],
99+
unknown_point=(2, 3),
100+
title='Stencil at interior point',
101+
filename='stencil_n_interior.png'
102+
)
103+
104+
# Figure 2: First time step stencil (4 points, no n-1 level)
105+
# Computing u[2]^1 from u[1]^0, u[2]^0, u[3]^0
106+
create_stencil_figure(
107+
known_points=[(1, 0), (2, 0), (3, 0)],
108+
unknown_point=(2, 1),
109+
title='Stencil at interior point (first time step)',
110+
filename='stencil_n0_interior.png'
111+
)
112+
113+
# Figure 3: Left boundary stencil (Neumann condition)
114+
# Computing u[0]^3 from u[0]^2, u[1]^2, u[0]^1
115+
create_stencil_figure(
116+
known_points=[(0, 2), (1, 2), (0, 1)],
117+
unknown_point=(0, 3),
118+
title='Stencil at boundary point (Neumann condition)',
119+
filename='stencil_n_left.png'
120+
)
121+
122+
print("\nAll stencil figures generated successfully!")
123+
print("\nLegend explanation:")
124+
print(" - Filled blue circles: Known values (computed at previous time steps)")
125+
print(" - Empty black circle: Unknown value (to be computed)")
126+
127+
128+
if __name__ == '__main__':
129+
main()
24.1 KB
Loading
23 KB
Loading
23.7 KB
Loading

0 commit comments

Comments
 (0)