Finite Difference Computing with PDEs
A Devito Approach
Welcome
This book teaches finite difference methods for solving partial differential equations, featuring Devito for high-performance PDE solvers.
About this Edition
This is an adaptation of Finite Difference Computing with PDEs: A Modern Software Approach by Hans Petter Langtangen and Svein Linge (Springer, 2017). This Devito edition features:
- Devito - A domain-specific language for symbolic PDE specification and automatic code generation
- Quarto - Modern scientific publishing for web and PDF output
- Modern Python - Type hints, testing, and CI/CD practices
Adapted by Gerard J. Gorman (Imperial College London).
License
This work is licensed under CC BY 4.0, the same license as the original work.
What is Devito?
Devito allows you to write PDEs symbolically and automatically generates optimized finite difference code:
from devito import Grid, TimeFunction, Eq, Operator, solve, Constant
grid = Grid(shape=(101,), extent=(1.0,))
u = TimeFunction(name='u', grid=grid, time_order=2, space_order=2)
c = Constant(name='c') # wave speed
# Write the wave equation symbolically: u_tt = c^2 * u_xx
pde = Eq(u.dt2, c**2 * u.dx2)
# Solve for u at the next time step
update = Eq(u.forward, solve(pde, u.forward))
# Devito generates optimized C code
op = Operator([update])
op.apply(time_M=100, dt=0.001, c=1.0)Book Structure
The book covers:
- Introduction to Devito - Grid, Function, TimeFunction, Operator, and boundary conditions
- Wave Equations - 1D/2D wave propagation, sources, absorbing boundaries
- Diffusion Equations - Heat equation, stability analysis, 2D extension
- Advection Equations - Upwind schemes, Lax-Wendroff, CFL condition
- Nonlinear Problems - Operator splitting, Burgers’ equation, Picard iteration
Plus appendices on finite difference formulas, truncation error analysis, and software engineering.
Getting Started
git clone https://github.com/devitocodes/devito_book.git
cd devito_book
pip install -e ".[devito]"See the GitHub repository for full installation instructions.