MMS: 2D Steady-State Heat Conduction

Category: V&V and Quality Assurance | Revised 2026-10-01
CAE visualization for mms heat 2d theory - technical simulation diagram
MMS: 2D Steady-State Heat Conduction

Concept: decide the answer first

Overview

🙋

I want to verify my own heat-conduction solver, but there are no analytical solutions for complex shapes and boundary conditions. What can I do?

🎓

Make up the answer yourself — that's the method of manufactured solutions (MMS). Choose a smooth function such as T = cos(πx/3)·sin(πy) as 'the answer'. Substituting it into the conduction equation gives the source q and boundary conditions needed to produce it. Feed those to the solver, and compare the computed temperature with the chosen answer. If the error falls at the theoretical rate as the grid is refined, the code is correctly implemented.

Equation and manufactured solution

$$ -\nabla\cdot(k\nabla T) = q, \qquad T_{MS} = \cos\!\left(\frac{\pi x}{a}\right)\sin(\pi y) \ \Rightarrow\ q = \left(\frac{\pi^2}{a^2} + \pi^2\right)T_{MS} $$

Unit square with conductivity $k = 1$. At $x = 0$, $y = 0$ and $y = 1$ the manufactured values are imposed as temperatures; at $x = 1$ the heat flux derived from the manufactured solution (a Neumann condition) is imposed. $a$ changes the solution's shape.

Order of convergence

$$ p = \frac{\ln(e_{2h}/e_h)}{\ln 2} $$

$e_h$ is the error at grid spacing $h$. The five-point central-difference scheme is second-order, so $p$ should approach 2. Mistakes in boundary conditions or source implementation make $p$ fall below the theoretical value.

Two ways to write the boundary condition

$$ \left.\frac{\partial T}{\partial x}\right|_{x=1} = g(y):\quad \frac{T_{N+1} - T_{N-1}}{2h} = g\ \ (\text{2nd order}), \qquad \frac{T_N - T_{N-1}}{h} = g\ \ (\text{1st order}) $$

The left form uses a ghost node outside the boundary (second order); the right uses a one-sided difference (first order). The right form is planted as a 'bug' to see whether MMS finds it.

Coffee Break Trivia

Building the problem from the answer

The manufactured-solution idea circulated among numerical analysts from the 1980s, but Roache and colleagues systematised it as a code-verification method, spreading it through a 1998 book and early-2000s papers. Its breakthrough was removing the barrier 'no analytical solution, so no verification' by working backwards. Many commercial and research codes now publish MMS verification results, and ASME V&V 10 and 20 treat it as a central code-verification method.

Worked examples

Example 1: convergence of the correct implementation

DivisionsMax error (a = 2)OrderMax error (a = 3)Order
85.93×10⁻³—8.27×10⁻³—
161.49×10⁻³1.992.07×10⁻³2.00
323.74×10⁻⁴2.005.16×10⁻⁴2.00
649.34×10⁻⁵2.001.29×10⁻⁴2.00

With either manufactured solution, error drops to a quarter with each halving — the theoretical second-order convergence.

Example 2: a boundary-condition bug

Divisionsa = 2 (zero boundary curvature)Ordera = 3 (non-zero boundary curvature)Order
85.97×10⁻³—5.77×10⁻³—
161.50×10⁻³2.004.13×10⁻³0.48
323.74×10⁻⁴2.002.39×10⁻³0.79
649.35×10⁻⁵2.001.28×10⁻³0.90
🙋

With a = 2 it looks second-order even though there's a bug!

🎓

That's the MMS trap. The one-sided difference error is proportional to the second derivative (curvature) of temperature at the boundary. cos(πx/2) has exactly zero curvature at x = 1, so the bug's error vanishes and hides. With a = 3 curvature remains at the boundary, the order goes 0.48 → 0.79 → 0.90 toward 1, and the first-order bug is plain. Choose manufactured solutions so every term is non-zero and nothing takes special values at boundaries — the standard practice is somewhat 'irregular' functions mixing trigonometric, exponential and polynomial parts.

How to run MMS

Procedure

  1. Choose a smooth manufactured solution for which no term (diffusion, advection, nonlinear terms, boundary derivatives) vanishes.
  2. Derive sources and boundary conditions with symbolic software to avoid hand errors.
  3. Solve on three or four grid levels and compute errors and orders.
  4. Check the order approaches the theoretical value; if not, isolate terms and boundary conditions one at a time.
Coffee Break Trivia

“Small error, wrong order”

An MMS run showed error below 0.1% and was declared a pass — yet the order later turned out to be 1. Error magnitude can be driven down arbitrarily by refinement, so it isn't proof of correctness; a first-order bug still shrinks with refinement, just more slowly than theory. Real problems often can't afford such fine grids, and then the bug affects results. What MMS must look at is not the size of the error but how it decreases with refinement — the order.

Common mistakes

Mistakes and fixes

MistakeEffectFix
Overly simple manufactured solutionBugs hideExercise every term
Judging by error sizeLow-order bugs missedJudge by order
Deriving sources by handDerivation errors mistaken for bugsUse symbolic derivation
Orders from coarse grids onlyNot in the asymptotic rangeUse 3–4 levels to see the trend
Not verifying boundary conditionsBoundary bugs remainTest each boundary type
🙋

I'd like to know more about MMS and convergence orders.

🎓

The overall idea is in MMS overview, order assessment in convergence-rate assessment, deriving sources in MMS source terms, code verification as a whole in code verification, and numerical-error estimation for real problems in Roache's GCI. Try order calculations with the Richardson extrapolation tool and 2D conduction with the 2D heat conduction tool.

Related Simulators

Experience the theory through interactive simulators in this field

All Simulators

Related fields

Structural AnalysisFluid AnalysisThermal Analysis
Rate this article
Thank you for your feedback!
Helpful
More details
Report error
Helpful
0
More details
0
Report error
0