# Overview

- Method of Manufactured Solutions (MMS) is a useful tool for code verification (making sure that your mathematical model is being properly solved).
- MMS works by assuming a solution, substituting it into the PDE, and obtaining a "forcing term".
- The modified PDE (with forcing term added) is then solved numerically; the result can be compared to the assumed solution.
- By checking the norm of the error on successively finer grids you can verify your code obtains the theoretical convergence rate (i.e. that you don't have any code bugs).

[](---)
MMS Example:

PDE:  $$-\nabla \cdot \nabla u = 0$$

Assumed solution:  $$u = \sin(\alpha\pi x)$$

Forcing function:  $$f = \alpha^2 \pi^2 \sin (\alpha \pi x)$$

Need to solve:  $$-\nabla \cdot \nabla u - f = 0$$

[](---)
# Error Analysis

- To compare two solutions (or a solution and an analytical solution) $$f_1$$ and $$f_2$$, the following expressions are frequently used:
$$$
||f_1-f_2||^2_{L_2(\Omega)} = \int_{\Omega} (f_1-f_2)^2 \;\text{d}\Omega
\\
||f_1-f_2||^2_{H_{1,\text{semi}}(\Omega)} = \int_{\Omega} \left|\nabla \left(f_1-f_2\right)\right|^2 \;\text{d}\Omega
$$$
- From finite element theory, we know the convergence rates of these quantities on successively refined grids.
- They can be computed in a MOOSE-based application by utilizing the `ElementL2Error` or `ElementH1SemiError` `Postprocessors`, respectively, and specifying the analytical solution with `Functions`.

[Example 14](/wiki/MooseExamples/Example_14/)