Skip to content

Commit 087844f

Browse files
committed
Update documentation for Quarto/Devito focus
- Rewrite README.md to highlight Devito DSL and modern tooling - Update index.qmd with Devito introduction and code example - Update CLAUDE.md with Devito patterns and project structure - Update _quarto.yml source URLs to point to devitocodes repo - Remove devito-plan.md (completed development roadmap) - Remove issues.md (conversion tracking no longer needed)
1 parent a187f35 commit 087844f

File tree

6 files changed

+187
-3621
lines changed

6 files changed

+187
-3621
lines changed

CLAUDE.md

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
This is the source repository for *Finite Difference Computing with PDEs - A Modern Software Approach* by Hans Petter Langtangen and Svein Linge. The book teaches finite difference methods for solving PDEs through Python implementations.
7+
This is the source repository for *Finite Difference Computing with PDEs - A Modern Software Approach* by Hans Petter Langtangen and Svein Linge. The book teaches finite difference methods for solving PDEs using [Devito](https://www.devitoproject.org/), a domain-specific language for symbolic PDE specification.
8+
9+
### Key Technologies
10+
11+
- **Devito** - DSL for symbolic PDE specification and automatic code generation
12+
- **Quarto** - Scientific publishing system for HTML and PDF output
13+
- **SymPy** - Symbolic mathematics for derivations and verification
814

915
## Build Commands
1016

@@ -19,36 +25,62 @@ quarto preview # Live preview with hot reload
1925
### Run Tests
2026

2127
```bash
22-
pytest src/ # Run all tests
23-
pytest src/vib/vib.py -v # Run tests in specific file
24-
python -m pytest --tb=short # With short traceback
28+
pytest tests/ -v # Run all tests
29+
pytest tests/ -v -m "not devito" # Skip Devito tests
30+
pytest tests/ -v -m devito # Devito tests only
2531
```
2632

2733
### Linting
2834

2935
```bash
3036
ruff check src/ # Check for linting errors
3137
isort --check-only src/ # Check import ordering
32-
isort src/ # Fix import ordering
3338
pre-commit run --all-files # Run all pre-commit hooks
34-
pre-commit run --hook-stage manual # Run auto-fix hooks
3539
```
3640

3741
## Architecture
3842

3943
### Directory Structure
4044

4145
- `chapters/` - Quarto source files organized by topic:
42-
- `vib/` - Vibration ODEs
43-
- `wave/` - Wave equations
44-
- `diffu/` - Diffusion equations
45-
- `advec/` - Advection equations
46-
- `nonlin/` - Nonlinear problems
46+
- `devito_intro/` - Introduction to Devito DSL
47+
- `wave/` - Wave equations (includes Devito solvers)
48+
- `diffu/` - Diffusion equations (includes Devito solvers)
49+
- `advec/` - Advection equations (includes Devito solvers)
50+
- `nonlin/` - Nonlinear problems (includes Devito solvers)
4751
- `appendices/` - Truncation errors, formulas, software engineering
48-
- `src/` - Python source code organized by chapter
52+
- `src/` - Python source code:
53+
- `wave/` - Wave equation solvers (wave1D_devito.py, wave2D_devito.py)
54+
- `diffu/` - Diffusion solvers (diffu1D_devito.py, diffu2D_devito.py)
55+
- `advec/` - Advection solvers (advec1D_devito.py)
56+
- `nonlin/` - Nonlinear solvers (nonlin1D_devito.py)
57+
- `operators.py` - FD operators with symbolic derivation
58+
- `verification.py` - Symbolic verification utilities
59+
- `tests/` - Pytest test suite
4960
- `_book/` - Generated output (PDF, HTML)
5061
- `_quarto.yml` - Book configuration
5162

63+
### Devito Patterns
64+
65+
When writing Devito code, follow these patterns:
66+
67+
```python
68+
from devito import Grid, TimeFunction, Eq, Operator
69+
70+
# 1. Create a grid
71+
grid = Grid(shape=(nx,), extent=(L,))
72+
73+
# 2. Create fields
74+
u = TimeFunction(name='u', grid=grid, time_order=2, space_order=2)
75+
76+
# 3. Write equations symbolically
77+
eq = Eq(u.forward, 2*u - u.backward + (c*dt)**2 * u.dx2)
78+
79+
# 4. Create and apply operator
80+
op = Operator([eq])
81+
op.apply(time_M=nt, dt=dt)
82+
```
83+
5284
### Quarto Document Format
5385

5486
The book uses [Quarto](https://quarto.org/) for scientific publishing. Key syntax:
@@ -59,10 +91,6 @@ The book uses [Quarto](https://quarto.org/) for scientific publishing. Key synta
5991
- `{{< include file.qmd >}}` - Include another file
6092
- `{=latex}` blocks for raw LaTeX when needed
6193

62-
### Code Organization Pattern
63-
64-
Each chapter's Python code lives in `src/CHAPTER/` and can be included in QMD files using fenced code blocks or Quarto includes.
65-
6694
## Pre-commit Hooks
6795

6896
Pre-commit hooks run automatically on commit:
@@ -75,28 +103,18 @@ Pre-commit hooks run automatically on commit:
75103

76104
## Key Dependencies
77105

106+
- **devito** - PDE solver DSL (optional, for running solvers)
78107
- **quarto** - Document generation from .qmd files
79-
- **numpy, scipy, matplotlib, sympy** - Scientific Python stack for examples
80-
- **pdflatex** - LaTeX compilation (requires TeX Live installation)
108+
- **numpy, scipy, matplotlib, sympy** - Scientific Python stack
109+
- **pdflatex** - LaTeX compilation (requires TeX Live)
81110

82111
## Build Output
83112

84113
- `_book/Finite-Difference-Computing-with-PDEs.pdf` - Generated book PDF
85114

86115
## Quarto Equation Labeling Guidelines
87116

88-
**Known Bug (GitHub Issue #2275)**: Quarto's `{#eq-label}` syntax cannot label individual lines within `\begin{align}` environments. This causes "macro parameter character #" LaTeX errors.
89-
90-
### What Fails
91-
92-
```markdown
93-
$$
94-
\begin{align}
95-
a &= 0+1 {#eq-first} <!-- causes LaTeX error -->
96-
b &= 2+3 {#eq-second}
97-
\end{align}
98-
$$
99-
```
117+
**Known Bug (GitHub Issue #2275)**: Quarto's `{#eq-label}` syntax cannot label individual lines within `\begin{align}` environments.
100118

101119
### Working Patterns
102120

@@ -110,36 +128,14 @@ b &= 2+3
110128
$$ {#eq-block}
111129
```
112130
113-
**Multiple separate equations** - use separate `$$` blocks:
114-
```markdown
115-
$$
116-
a = 0+1
117-
$$ {#eq-first}
118-
$$
119-
b = 2+3
120-
$$ {#eq-second}
121-
```
122-
123131
**Individual line labels in align** - use pure AMS LaTeX syntax:
124132
```latex
125133
\begin{align}
126134
a &= 0+1 \label{eq:first} \\
127135
b &= 2+3 \label{eq:second}
128136
\end{align}
129-
130-
See Equation \eqref{eq:first} for details.
131137
```
132138
133-
### Best Practices
134-
135-
- **Never mix Quarto `{#eq-}` and AMS `\label{}` syntax** in the same equation
136-
- Use `\begin{equation}...\end{equation}` for single numbered equations
137-
- Use `\begin{align}...\end{align}` with `\label{}` for multiple aligned, individually-numbered equations
138-
- Use `\begin{aligned}...\end{aligned}` inside `\begin{equation}` for aligned equations sharing one number
139-
- Add `*` (e.g., `\begin{align*}`) to suppress all numbering
140-
- Reference with `\eqref{label}` for parenthesized numbers, `\ref{label}` for plain numbers
141-
- For Quarto cross-refs, use `@eq-label` syntax with label placed after `$$`
142-
143139
### Cross-Reference Prefixes
144140
145141
| Type | Prefix | Example |
@@ -148,5 +144,3 @@ See Equation \eqref{eq:first} for details.
148144
| Equation | `@eq-` | `@eq-vib-ode1-step4` |
149145
| Figure | `@fig-` | `@fig-vib-phase` |
150146
| Table | `@tbl-` | `@tbl-trunc-fd1` |
151-
152-
Reference: [NMFS-OpenSci Quarto-AMS Math Guide](https://nmfs-opensci.github.io/quarto-amsmath)

0 commit comments

Comments
 (0)