Find a topic
Read the subject in depth
Each volume develops its arguments in sequence, with worked problems and links to experiments.
Spatial discretisation and field equations
Derive a discrete field problem from a continuous equation, choose appropriate boundary data and test the convergence of quantities a measurement could resolve.
How the course fits together
- Chapters 1–4
Turn flux balance on a cell into neighbouring unknowns. The weak form imposes the same balance against test functions. Check whether face fluxes cancel, then add storage to predict a field evolving in time.
- Chapters 5–8
Track the numerical speed of waves and verify a discretisation using a known manufactured field. Interfaces require matching flux, and a tensor coefficient makes the flux direction depend on material orientation.
- Chapters 9–12
Advection, pressure constraints and widely separated mesh scales require different discretisations and solvers. End by defining the particular output whose error matters and weighting residuals accordingly.
Chapters
- Flux differences for an elliptic balance
Assemble a conservative boundary-value problem from face fluxes, trace the effect of boundary conditions and establish a discrete energy identity.
- Weak forms and finite elements
Derive a variational statement by integration by parts, assemble element matrices for a one-dimensional rod and explain what the Galerkin solution minimises.
- Finite volumes and moving fronts
Derive an upwind transport update by conservation, interpret the Courant number as a fraction of cell contents and determine what conservation says about front speed.
- Time-dependent diffusion
Derive the diffusion time-step restriction from two independent arguments and compare explicit and implicit decay of spatial modes.
- Wave speeds and numerical dispersion
Derive the leapfrog dispersion relation, use the Courant condition to distinguish boundedness from accurate travel time and initialise a standing-wave calculation consistently.
- Verification, refinement and local error
Use a manufactured solution to verify an implementation, estimate observed convergence and identify when adaptivity is needed for the physical quantity of interest.
- Interfaces, contact resistance and Robin data
Derive a face flux that transports the same heat through two different materials and through a convective boundary.
- Anisotropic diffusion and mesh alignment
Relate a diffusion tensor to principal directions and test whether a face-flux approximation can represent a rotated material.
- Cell Péclet number and monotonicity
Derive the sign restriction for centred transport, identify a numerical boundary layer and quantify the diffusion introduced by upwinding.
- Incompressibility and discrete pressure modes
Derive the velocity–pressure block system and use a periodic mesh to detect a pressure pattern that exerts no discrete force.
- Multigrid and coarse-grid correction
Combine smoothing with a coarse residual equation and compute which components a two-grid correction can remove exactly.
- Adjoints and errors in a chosen output
Weight equation residuals by the response of a chosen observation and distinguish algebraic error from mesh error.
Further chapters and interactive tutorials
- Pure flux boundaries, compatibility and the missing constant
If a steady diffusion equation prescribes only fluxes, a solver can return a singular-matrix warning for two different physical reasons. Derive the mass balance and the nullspace separately, then decide when choosing a reference value resolves the problem.
- Building a local residual estimator and refining where it matters
A finite-element solution can satisfy the assembled equations to machine precision while still missing curvature between nodes. Integrate the residual of the computed field by parts on each element and use the resulting cell and interface terms to decide where to spend the next degrees of freedom.
- What a periodic grid does to a decaying Fourier mode
A periodic diffusion solver predicts the shape of a sampled wave while its amplitude decays too slowly. Fourier analysis separates spatial differentiation error, an unresolved physical mode and errors caused by the time integrator.
- Why two finite-element wave solvers propagate the same mode at different speeds
Build the element mass matrix by integrating shape functions and track the effect of diagonal lumping on the wave spectrum.
- Moving a cell average without inventing or losing material
Derive a conservative transport step from cell overlap and measure how a monotone scheme spreads a pulse despite conserving its total mass exactly.
- When diffusion destabilises a uniform state
Two scalar signals on a ring respond locally to each other and exchange signal with their neighbours. A single well-mixed cell returns to its reference state after a small disturbance. Can coupled cells amplify a spatial pattern? Derive a condition for this surprising outcome and test how faithfully a finite grid represents its wavelength.
Computational notebooks
Run the Python calculations in your browser and compare the figures with the derivations.
Problem sheets
Sheets 1–6 accompany the first twelve chapters. The final projects bring several methods together. Attempt each stage before opening its worked solution.
- Flux balances and virtual workFor chapters 1 and 2
Choose the correct conductance at an interface, test pure-flux compatibility and assemble a rod with unequal stiffnesses.
- Fronts and diffusive modesFor chapters 3 and 4
Track conservation on a periodic mesh, distinguish shocks from expanding fans and choose a time step for an explicit diffusion solver.
- Wave resolution and verificationFor chapters 5 and 6
Prescribe the first time level of a vibrating string, measure a convergence order and decide what a residual reveals under grid refinement.
- Material interfaces and anisotropyFor chapters 7 and 8
Recover face temperatures and fluxes, and use a linear temperature field to test a rotated conductivity tensor.
- Transport weights and pressure spacesFor chapters 9 and 10
Locate the onset of a sign error and test which discrete pressure differences actually drive a velocity.
- Transfers and observation errorFor chapters 11 and 12
Track which error can survive a grid transfer and compute an exact adjoint correction for a nonsymmetric system.
- Project · Verify a heat solver before interpreting its temperature
A laboratory plate can be heated internally and cooled at its boundary. Check global feasibility, the spatial error between nodes and the wavelength-dependent decay of periodic modes.
- Resolve an outflow layer by fitting the numerical face flux
A dilute solute moves down a channel and diffuses against its mean flow. Fixed concentrations at the ends generate a thin downstream layer. Construct the cell flux directly from the differential equation, then ask how a solver can return nearly the right total throughput while still predicting an impossible local concentration.
Final synthesis problem · Decide if another grid refinement answers the engineering question
Applied study
Discretise a boundary-value problem and separate mesh error from solver and sampling errors.
Replace a continuum balance by nodal equations
Suppose a scalar diffuses along a unit interval, with a fixed value at each end. The steady balance is \(-u''=f\) for constant unit diffusivity. At equally spaced interior nodes \(x_i=ih\), approximate the derivative at each face by the difference between its neighbouring values divided by \(h\). Subtracting the outgoing and incoming diffusive fluxes and dividing by cell width gives
The endpoints are known, leaving \(N-1\) interior unknowns for \(N\) intervals. Each interior flux appears once with each sign in neighbouring balances. Summing balances therefore leaves the net boundary flux and the total source. With variable diffusivity \(D\), multiply each face gradient by its face value of \(D\) before taking the difference.
Find the error made by a single stencil
Insert the exact values \(u(x_i-h)\) and \(u(x_i+h)\), expand both in Taylor series and add them. Odd terms cancel. The central second difference satisfies \(\delta_{xx}u=u''+h^2u^{(4)}/12+O(h^4)\) for sufficiently smooth \(u\). This local consistency calculation predicts the scale of the defect when the exact solution is inserted in the discrete equations.
Write the discrete problem \(A_hu_h=f_h\) and define \(\tau_h=A_hu_\star-f_h\) using exact nodal values \(u_\star\). Then \(A_h(u_\star-u_h)=\tau_h\). A stability bound on \(A_h^{-1}\), uniform in mesh size in the chosen norm, turns second-order consistency into second-order solution error. A tight iterative solve reduces the residual of \(A_hu_h=f_h\), but leaves \(\tau_h\) in place.
Use an exact sine mode to predict the discrete amplitude
Prescribe \(u(0)=u(1)=0\) and \(f(x)=\pi^2\sin(\pi x)\). The exact solution is
For its grid samples \(s_i=\sin(\pi ih)\), the sine addition formula yields
with \(\lambda_h=4\sin^2(\pi h/2)/h^2\). The right-hand side is \(\pi^2s\), so the discrete solution has the same nodal shape and amplitude \(\pi^2/\lambda_h\).
With four intervals, \(\lambda_h=64\sin^2(\pi/8)=9.3726\) and the numerical midspan value is 1.0530. The exact value is 1. The sign makes sense: the discrete stiffness of this mode is below \(\pi^2\), so the same load produces a larger amplitude. Expansion gives \(\pi^2/\lambda_h=1+\pi^2h^2/12+O(h^4)\), predicting a fourfold error reduction on refinement.
Problem class
Test a polynomial before trusting the mesh
Keep the homogeneous end values and choose \(u_\star=x(1-x)\). Derive \(f\), then predict the nodal error for any uniform mesh in exact arithmetic. Would this make a good test for measuring convergence order?
Show the calculation
Since \(u_\star''=-2\), use \(f=2\). The centred second difference of any quadratic equals its exact second derivative. The nodal vector therefore solves the discrete equations exactly. It is a useful stencil consistency check, but its zero leading error prevents a meaningful order measurement from a ratio of errors.
Manufacture a source for variable diffusion
On the unit square let \(D(x)=1+x\), \(u_\star=\sin(ax)\sin(ay)\), and \(a=m\pi\) for positive integer \(m\), using metre coordinates. What forcing makes \(-\nabla\cdot(D\nabla u)+2u=f\) hold with zero boundary values?
Show the calculation
Apply the product rule,
Here \(\Delta u_\star=-2a^2u_\star\) and \(D'=1\). Thus \(f=[2(1+x)a^2+2]u_\star-a\cos(ax)\sin(ay)\). Each boundary has a zero sine factor. Omitting \(D'u_x\) would produce a continuous modelling error that persists even when the mesh is refined.
OneSimulation laboratory
Measure spatial convergence on a known field
Compare recorded OneSimulation runs on this page. To test your own inputs, download the Python model and run the model in an activated OneSimulation environment.
The script solves the steady equation \(-\nabla\!\cdot[(1+x)\nabla u]+2u=f\) on the unit square by conservative flux differences and Jacobi-preconditioned CG. Set \(u=\sin(m\pi x)\sin(m\pi y)\) and obtain the source by substitution. The boundary values are zero on all four sides. Compare the maximum error at grid nodes with the solver’s relative residual. Refine both axes together, then raise the sine mode on the same 48-cell mesh to see how wavelength affects the error. Download the Python experiment · OneSimulation reaction–diffusion refinement study.
python partial-differential-equations.py
python partial-differential-equations.py --cells 48
python partial-differential-equations.py --cells 96
python partial-differential-equations.py --cells 48 --mode 2
| Cells per axis, mode | Interior unknowns | Max. nodal error | Relative residual |
|---|---|---|---|
| 24, 1 | 529 | 1.33345 × 10⁻³ | 9.79 × 10⁻¹¹ |
| 48, 1 | 2,209 | 3.33763 × 10⁻⁴ | 7.14 × 10⁻¹¹ |
| 96, 1 | 9,025 | 8.34283 × 10⁻⁵ | 4.21 × 10⁻¹¹ |
| 48, 2 | 2,209 | 1.41546 × 10⁻³ | 8.89 × 10⁻¹¹ |

At mode one the error falls by factors close to four while the number of interior unknowns roughly quadruples. On the same 48-cell mesh, mode two has half as many intervals per wavelength and a larger error. Both modes have small algebraic residuals. Mesh convergence is a property of the resolved field and its discretisation.
Change parameters · Change the laboratory inputs
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Problem sheet 3 · Predict the error before making a finer grid
Advanced study across the subject
Each sequence connects the course to detailed chapters in neighbouring subjects. The complete course PDF includes their derivations, examples and exercises.
Boundary data, uniqueness and singular sources
Derive the continuous problem before assembling a discrete row. Test what happens to uniqueness, source flux and interface voltage under a change of boundary data.
Heat, momentum and wave transport
Test the same spatial method on diffusion, a propagating pulse and an elastic mode. Compare dissipation, dispersion and boundary residuals on a common footing.
A worked application in field physics
Discretise Gauss’s law across a spatially varying dielectric and compare the calculated field, voltage and stored energy with an integral solution.
Further reading
Compare stability and consistency for diffusion and advection using the same mesh. Use the accompanying examples to identify which discretisations preserve qualitative features of a solution. Randall J. LeVeque · Finite Difference Methods for Ordinary and Partial Differential Equations
Chapters 11–13 develop diffusion, advection and two-dimensional problems. Compare the largest operator eigenvalues before choosing an explicit time step. Driscoll and Braun · Fundamentals of Numerical Computation