Finite Difference Computing with PDEs

A Devito Approach

Authors

Hans Petter Langtangen

Svein Linge

Published

January 29, 2026

Welcome

This book teaches finite difference methods for solving partial differential equations, featuring Devito for high-performance PDE solvers.

Download PDF version

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

CC BY 4.0

CC BY 4.0

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:

  1. Introduction to Devito - Grid, Function, TimeFunction, Operator, and boundary conditions
  2. Wave Equations - 1D/2D wave propagation, sources, absorbing boundaries
  3. Diffusion Equations - Heat equation, stability analysis, 2D extension
  4. Advection Equations - Upwind schemes, Lax-Wendroff, CFL condition
  5. 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.