Keywords

5.1 Introduction

In computational engineering and physics, ordinary or partial differential equations that govern the evolution of state variables, such as pressure, temperature, velocity, or displacement, are discretized for implementation and resolution on finite-digitized arithmetic computer. The challenge of verification is to assess the extent to which approximate solutions of the discretized equations converge to the exact solution of the continuous equations. In addition to assessing how “closely” discrete solutions estimate the continuous solution, it is often important to verify that the observed rate-of-convergence matches the theoretical order of accuracy of the numerical method or solver. Simply speaking, verification is the first “V” of Verification and Validation (V&V) for predictions of numerical simulations [1].

Code and calculation (or solution) verification is defined as a scientifically rigorous and quantitative process for assessing the mathematical consistency between continuum and discrete variants of partial differential equations [2]. Verification involves comparing numerical solutions obtained on successively refined meshes (or grids) to an exact solution or “reference.” The main difficulty is that the exact solution of continuous equations is not always known and available to define this reference. These exact solutions can be derived analytically only in a few cases that feature “smooth” dynamics, linearized operators, simple geometries, or combinations of the above. Well-known examples include the single degree-of-freedom harmonic oscillator, linear vibration of simple structural components, Poiseuille flow of 2D incompressible fluids, and the 1D Riemann problem for ideal gases. These are problems that have been extensively studied and for which exact or highly-accurate solutions of the continuous equations can be obtained. Exact solutions can also be produced with the technique of manufactured solutions [3]. The overall number of problems that offer closed-form solutions is, unfortunately, limited.

In general one talks of code verification when the solution of the continuous equations can be derived in closed form, which provides an exact reference to which the discrete solutions are compared. By “closed form,” we mean either analytical formulae or simplified representations that can be accurately evaluated, e.g., reduction from a partial differential equation to an ordinary differential equation. If the system of equations and its initial and boundary conditions are complicated, then a continuous solution cannot be derived analytically and one then talks of solution verification. In this latter case no exact reference is available to calculate the solution error due to discretization, which makes verification quite challenging.

The discussion presented herein offers a brief overview of technology applicable to code and solution verification alike. The only difference between the two cases is the availability (for code verification) or not (for solution verification) of a reference solution. The dominant paradigm for code and solution verification is that the numerical method provides discrete solutions that converge to the (possibly unknown) continuous solution with a specific rate-of-convergence (or order of accuracy). For example, a finite element analysis featuring quadratic shape functions should yield discrete solutions that converge with a rate of p = 2 when the mesh is refined. Common practice is to generate several discrete solutions from successively refined meshes, estimate an extrapolation of the continuous solution, verify the rate-of-convergence, and estimate bounds of numerical uncertainty. Discussion is restricted to well-established techniques and does not address recent developments that might challenge boundaries of the current state-of-the-practice. For a partial account of such developments see, for example, Refs. [4,5,6,7,8,9,10].

Successes of verification include the development of a formalism to study the convergence of discrete solutions for a wide range of applications, from linear, non-dissipative, elliptic equations to non-linear, shocked, hyperbolic equations. It means that the convergence, for example, of solutions for the resonant frequencies of a modal analysis can be studied with the same tools as the convergence of solutions for a blast wave propagating in ideal gases. The failures of verification are embodied by the many restrictions imposed on the way an analysis is typically carried out. These include restricting the studies to scalar quantities, further restricting them to spatial-only convergence, and not always accounting for how discrete solutions are constructed by the numerical methods and the specific properties that result.

5.2 The Consistency and Convergence of Modified Equations

Numerical methods, such as finite element and finite volume methods, solve conservation laws that balance the rate-of-change in time of state variables, gradient of their fluxes, and source terms. Without loss of generality these contributions can be written in a one-dimensional, Cartesian coordinate system as:

$$ \frac{\partial {y}^{Exact}\left(x;t\right)}{\partial t}+\frac{\partial \mathrm{F}\left({y}^{Exact}\left(x;t\right)\right)}{\partial x}=S\left(x;t\right), $$
(5.1)

where y Exact (x; t) is the exact solution, F(•) denotes the flux operator, and S(x; t) is a source or forcing function that drives the dynamics of the system. These generic functions depend on space and time, labeled x and t, respectively. When solving systems of Eq. (5.1) with a numerical method, one seeks the best-possible approximation of the continuous, exact, and often unknown solution, y Exact.

The numerical method discretizes the continuous Eq. (5.1) on a computational mesh to yield a discrete solution y k n = y(k⋅Δx; n⋅Δt) where Δx and Δt are spatial and temporal resolutions. The approximation y k n is obtained by solving a discretized system of equations that resembles, for example, something like:

$$ \frac{y_k^{n+1}-{y}_k^n}{\Delta t}+\frac{F_{k+1/2}^n-{F}_{k-1/2}^n}{\Delta x}={S}_k^n. $$
(5.2)

It is emphasized that Eq. (5.2) suggests a hypothetical discretization scheme (not necessarily the one used) where the temporal differentiation operator (∂•/∂t) is approximated by a forward Euler difference and the spatial differentiation operator (∂•/∂x) is approximated by central differences. The discrete values y k n, F k n and S k n can be obtained from finite difference, finite volume, or finite element approximations.

One observes that the discretized Eq. (5.2) seems “similar” to the original, continuous Eq. (5.1). The similarity, however, is misleading. Contrary to common belief the discrete solution y k n does not approximate the continuous solution y Exact of Eq. (5.1). Using the technique known as Modified Equation Analysis (MEA), see References [11, 12], it can be shown that the approximation y k n converges to the solution of a modified equation that takes a form such as:

$$ \begin{aligned}[b]\frac{\partial {y}^{MEA}\left(x;t\right)}{\partial t}+\frac{\partial \mathrm{F}\left({y}^{MEA}\left(x;t\right)\right)}{\partial x} &=S\left(x;t\right) \\ & \quad +\left(\frac{\partial^2{y}^{MEA}\left(x;t\right)}{\partial {t}^2}\cdot \Delta t+\frac{\partial^3{y}^{MEA}\left(x;t\right)}{\partial {t}^3}\cdot \Delta {x}^2+...\right).\end{aligned} $$
(5.3)

Note that this example is conceptual and the correct form of the modified equation depends on properties of the original Eq. (5.1) and numerical method (5.2) implemented for its resolution. What is important to the discussion is that the continuous solution y MEA of the modified Eq. (5.3) is different from y Exact as long as the spatial and temporal resolutions remain finite (as long as Δx ≠ 0, Δt ≠ 0). The Lax equivalence theorem of Ref. [13] details conditions under which the discrete approximation y k n is consistent with, and converges to, the continuous solution y Exact. Figure 5.1 illustrates these essential concepts.

Fig. 5.1
figure 1

The concepts of consistency and convergence of numerical solutions

Terms shown between parentheses in the right-hand side of the modified Eq. (5.3) represent an infinite series expansion that characterizes the truncation error of the numerical method or solver. Truncation is what explains the difference between the continuous solutions y MEA and y Exact. This is why it is essential to establish that the solution y MEA of the modified Eq. (5.3) is consistent with the exact solution y Exact of the original Eq. (5.1), as indicated in Fig. 5.1. Likewise one needs to understand the behavior of truncation error, that is, the extent to which the discrete solution y k n converges to the exact solution y Exact.

In addition to defining the concept of modified equation, Eq. (5.3) also illustrates the order of accuracy of a numerical method. The leading-order term of spatial truncation, for example, is proportional to Δx 2, which means that the solver is 2nd-order accurate. Performing a mesh refinement should yield a truncation error between discrete solutions y k n and the exact-but-unknown solution y Exact that converges at a quadratic rate. Likewise Eq. (5.3) suggests that the solver is 1st-order accurate in time since the leading-order term of temporal truncation is proportional to Δt. The next section discusses this asymptotic convergence.

5.3 The Regime of Asymptotic Convergence of Discrete Solutions

Because truncation error is often the main mechanism by which discrete solutions y k n differ from the exact solution y Exact, understanding its behavior is key to assess the numerical performance of simulation software. Verifying the quality of discrete solutions hinges on the regime of asymptotic convergence.

Different choices of discretization variables, such as Δx or Δt, induce different types and magnitudes of error. Plotting the solution error ||y Exact − y k n || as a function of mesh size Δx gives a conceptual illustration of the main three regimes of the discretization. By definition the asymptotic regime is the region where truncation dominates the overall production of numerical error. Figure 5.2 provides a simplified illustration of these regimes. They are color-coded such that red is the regime where discretization is inappropriate, green denotes the regime of asymptotic convergence, and grey is where round-off error accumulates.

Fig. 5.2
figure 2

The three regimes of solution error as a function of spatial discretization

Going from right (larger values of Δx) to left (smaller values of Δx) in Fig. 5.2, the first domain shown in red is where the choice of element or cell size is not even appropriate to solve the discrete equations. This would be, for example, the case when elements are too coarse to resolve important geometrical features of a contact condition between components, or a numerical stability criterion is violated. Although it could be argued that discrete solutions should not be computed in this regime, the fact is undeniable that meshes analyzed in practical situations are often significantly under-resolved.

The second region shown in green is where truncation dominates the overall error: it is the regime of asymptotic convergence. Because truncation error dominates, the accuracy of a discrete solution y k can be improved simply by performing the calculation with a smaller element size. We have just described the basic principle of conducting a mesh or grid refinement study.

Our conceptual illustration assumes that truncation error within the regime of asymptotic convergence is dominated by a single effect proportional to Δx p, which appears as a straight line of slope p on the log-log representation of Fig. 5.2. The functional form of a typical modified equation, suggested in Eq. (5.3), motivates this assumption. It is also the reason why the behavior of truncation error is usually studied by formulating a simple model such as:

$$ \varepsilon \left(\Delta x\right)=\left\Vert {y}^{Exact}-{y}_k^n\left(\Delta x\right)\right\Vert \approx \beta \cdot \Delta {x}^p+\mathrm{H}.\mathrm{O}.\mathrm{T}., $$
(5.4)

where ε(Δx) denotes the difference, estimated in the sense of a user-defined norm ||•||, between the exact solution y Exact of the continuous Eq. (5.1) and the discrete solution y k n (Δx) obtained by executing the simulation code with mesh or grid size Δx. The pre-factor β represents a (constant) regression coefficient. The exponent p characterizes the rate at which the solution error decreases as the level of resolution is increased, that is, as Δx ➔ 0. It should match the theoretical order of accuracy of the numerical method. For example, a finite element calculation that uses linear shell elements should exhibit the rate of p = 1. Likewise the second-order accurate Gudonov scheme of a fluid dynamics solver should feature p = 2 for a laminar-like flow that does not develop a discontinuity (or shock).

The last region of Fig. 5.2 shown in grey is a limiting case for asymptotic convergence due to the fact that, with finite arithmetic implemented in a computer code, round-off errors eventually start to grow as Δx ➔ 0. Round-off could then accumulate to the point where it supplants truncation as the dominant mechanism that produces numerical error.

Understanding asymptotic convergence is important for two reasons. First, the formulae discussed in this manuscript, which provide the foundation of verification, are valid only within the regime of asymptotic convergence. Second, verifying that a discretization used in a calculation leads to a discrete solution in the asymptotic regime provides a strategy to reduce truncation error. If the error is too large for the application and needs to be reduced, performing the simulation with a smaller element or cell size automatically reduces it. This is, however, true only within the regime of asymptotic convergence.

5.4 State-of-the-Practice of Code and Solution Verification

This section summarizes the formalism and main equations used to study the convergence of discrete solutions. The discussion focuses on the state-of-the-practice in computational engineering and physics without paying tribute to some of the more advanced techniques. References [5, 9, 10] to list only a few, discuss issues that extend beyond the limited scope of this section.

The distinction needs to be emphasized between code verification, where the exact solution y Exact of the continuous Eq. (5.1) is known analytically, or provided by an approximate yet highly accurate solution procedure, and solution verification where y Exact is unknown. In the case of code verification, the error ε(Δx) in the left-hand side of Eq. (5.4) can be computed given knowledge of the exact solution y Exact and a discrete solution y k n (Δx) obtained with the discretization size Δx. These exact and discrete solutions can be any scalar quantities, curves, or multi-dimensional fields. The unknowns of Eq. (5.4) are the parameters (β; p). Two discrete solutions, one obtained with a “coarse” mesh of size Δx C and another one obtained with a “fine” mesh of size Δx F , where Δx C  = R·Δx F (and R > 1), suffice to estimate β and p.

We now proceed to discuss the general case of solution verification where the difficulty is that the exact solution y Exact of the continuous Eq. (5.1) is unknown. The challenge is that the procedure described in the previous paragraph cannot be implemented since the error ε(Δx) cannot be explicitly computed. The starting point is to postulate an equation, referred to as an Ansatz model of numerical error, which describes how the error behaves in the regime of asymptotic convergence. The state-of-the-practice is to specialize Eq. (5.4) to scalar quantities such that is can be written as:

$$ \varepsilon \left(\Delta x\right)={y}^{Reference}-{y}_k^n\left(\Delta x\right)\approx \beta \cdot \Delta {x}^p, $$
(5.5)

where the unknown is the triplet of quantities (y Reference; β; p). The main difference with code verification defined in Eq. (5.4) is that the exact-but-unknown solution y Exact is replaced by a reference y Reference that becomes a third unknown of the Ansatz model. Equation (5.5) also assumes that, first, the convergence of discrete solutions y k n (Δx) towards the reference solution is monotonic and, second, the higher-order terms of the modified equation can be neglected. References [9, 10] address the case of non-monotonic convergence.

Because the formulation (5.5) features three unknowns, a minimum of three equations is required to solve it. These are provided by discrete solutions obtained from a coarse-mesh calculation (with element or cell size Δx C ), a medium-mesh calculation (Δx M ), and a fine-mesh calculation (Δx F ). These are written as:

$$ \begin{array}{l}{y}^{Reference}-{y}_k^n\left(\Delta {x}_C\right)=\beta \cdot \Delta {x}_C^p\\ {}{y}^{Reference}-{y}_k^n\left(\Delta {x}_M\right)=\beta \cdot \Delta {x}_M^p.\\ {}{y}^{Reference}-{y}_k^n\left(\Delta {x}_F\right)=\beta \cdot \Delta {x}_F^p\end{array} $$
(5.6)

The system of Eq. (5.6) can be solved for the triplet of unknowns (y Reference; β; p) by combining the equations to eliminate two of the three unknowns. The value of the rate-of-convergence p, for example, is obtained by solving the following nonlinear equation:

$$ p\cdot \log \left({R}_{MF}\right)+ \log \left(1-{R}_{CM}^p\right)- \log \left(1-{R}_{MF}^p\right)= \log \left(\frac{y_k^n\left(\Delta {x}_M\right)-{y}_k^n\left(\Delta {x}_C\right)}{y_k^n\left(\Delta {x}_F\right)-{y}_k^n\left(\Delta {x}_M\right)}\right), $$
(5.7)

where R CM and R MF are the successive mesh refinement ratios defined as:

$$ {R}_{CM}=\frac{\Delta {x}_C}{\Delta {x}_M}\kern0.75em \mathrm{and}\kern0.75em {R}_{MF}=\frac{\Delta {x}_M}{\Delta {x}_F}. $$
(5.8)

There is no closed-form solution to the nonlinear Eq. (5.7) when the refinement ratios RCM and RMF are different. The value of exponent p must be obtained through numerical optimization. With a constant mesh refinement ratio, which means that R CM  = R MF  = R, however, Eq. (5.7) is solved as:

$$ p=\frac{ \log \left(\dfrac{y_k^n\left(\Delta {x}_M\right)-{y}_k^n\left(\Delta {x}_C\right)}{y_k^n\left(\Delta {x}_F\right)-{y}_k^n\left(\Delta {x}_M\right)}\right)}{ \log (R)}. $$
(5.9)

The next step is to extrapolate the discrete solutions y k n (Δx C ), y k n (Δx M ) and y k n (Δx F ) to a reference y Reference that approximates the exact-but-unknown solution y Exact. This is referred to as Richardson’s extrapolation. Any combination of two meshes (coarse-medium or medium-fine) provides the same value for y Reference:

$$ {y}^{Reference}{=y}_k^n\left(\Delta {x}_F\right)+\frac{y_k^n\left(\Delta {x}_F\right)-{y}_k^n\left(\Delta {x}_M\right)}{R^p-1}{=y}_k^n\left(\Delta {x}_M\right)+\frac{y_k^n\left(\Delta {x}_M\right)-{y}_k^n\left(\Delta {x}_C\right)}{R^p-1}, $$
(5.10)

where the convergence rate p is the value obtained from Eq. (5.9). The regression coefficient β can be back-calculated from any one of Eq. (5.6):

$$ \beta =\frac{y_k^n\left(\Delta {x}_C\right)-{y}_k^n\left(\Delta {x}_M\right)}{\Delta {x}_M^p\cdot \left({R}^p-1\right)}=\frac{y_k^n\left(\Delta {x}_M\right)-{y}_k^n\left(\Delta {x}_F\right)}{\Delta {x}_F^p\cdot \left({R}^p-1\right)}=\frac{y_k^n\left(\Delta {x}_C\right)-{y}_k^n\left(\Delta {x}_F\right)}{\Delta {x}_F^p\cdot \left({R}^{2p}-1\right)}. $$
(5.11)

In summary, Eqs. (5.7)–(5.11) provide expressions for the triplet of unknowns (y Reference; β; p) in the case of either a variable or constant mesh refinement ratio. This formalism is applicable to code and solution verification alike, with the difference that the former case assumes knowledge of the exact solution y Exact, which reduces the unknowns of the Ansatz model to the pair (β; p). Clearly this analysis technique is appropriate only to the extent that assumptions upon which it relies are satisfied. There are four essential assumptions summarized to conclude the discussion. (1) The mesh sizes used (Δx C , Δx M and Δx F ) provide discrete solutions located in the regime of asymptotic convergence. (2) The analysis is restricted to scalar quantities. (3) Because it is unknown, the exact solution y Exact of the continuous equations is replaced by a to-be-estimated reference y Reference. (4) Convergence of the discrete solutions y k n (Δx) is monotonic.

5.5 The Bounds of Numerical Uncertainty

When the exact solution y Exact of a system of partial or ordinary differential equations is unknown, the error |y Exact − y k n (Δx)| or ||y Exact − y k n (Δx)|| with which a discrete solution y k n (Δx) is calculated becomes an uncertainty. This uncertainty cannot be explicitly computed since the exact solution is unknown and the approximation provided by the reference solution y Reference is itself uncertain. The best that one can achieve, therefore, is an upper bound U(Δx) of truncation error such that:

$$ \left|\frac{y^{Exact}-{y}_k^n\left(\Delta x\right)}{y_k^n\left(\Delta x\right)}\right|\le U\left(\Delta x\right). $$
(5.12)

References [14, 15] derive such an upper bound and illustrate how it can be used to select an appropriate mesh size for the prediction of resonant dynamics of a wind turbine blade. The result is given as:

$$ U\left(\Delta x\right)=\frac{1}{R^p-1}\cdot \left|\frac{y_k^n\left(\Delta x\right)-{y}_k^n\left(R\cdot \Delta x\right)}{y_k^n\left(\Delta x\right)}\right|, $$
(5.13)

where R denotes the refinement ratio used between two successive calculations. By analogy with previous notation, the mesh size R·∆x represents a coarse resolution (previously denoted as ∆x C ) and Eq. (5.13) defines the upper bound of truncation error for a fine-resolution (previously denoted as ∆x M ) prediction.

The significance of the upper bound (5.13) is to indicate where the exact-but-unknown solution y Exact might be located relative to the prediction y k n (Δx) obtained at mesh resolution Δx. It is analogous to the Grid Convergence Index (GCI) proposed by Patrick Roache in 1994 to report the results of grid convergence studies in computational fluid dynamics [16]. The definition (5.13) does not, however, suffer from the disadvantage of having to select a somewhat arbitrary “factor-of-safety” F S that appears in the GCI:

$$ GCI\left(\Delta x\right)=\frac{F_S}{R^p-1}\cdot \left|\frac{y_k^n\left(\Delta x\right)-{y}_k^n\left(R\cdot \Delta x\right)}{y_k^n\left(\Delta x\right)}\right|, $$
(5.14)

where the value of F S depends on the application, characteristics of the code used and smoothness of the solution. Values F S  = 1.25 and 3.0 have been proposed for various applications in computational fluid dynamics and solid mechanics [2]. Some practitioners advocate to make the factor-of-safety variable to account for better or worse-than-expected convergence. Reference [17], for example, offers a definition that increases the upper bound if the observed rate-of-convergence is worse than anticipated:

$$ {F}_S=\frac{R^{p^{Theory}}-1}{R^p-1}, $$
(5.15)

where p Theory and p denote the theoretical and observed (in Eq. (5.7) or (5.9)) rates-of-convergence.

A small value of the upper bound U(Δx), or the GCI, indicates that, first, the discrete solution obtained at mesh resolution Δx is converging to the exact-but-unknown solution y Exact and, second, Richardson’s extrapolation y Reference is a reasonably accurate estimation of y Exact. What one considers “small enough” is subjective, usually, U(Δx) = 10% or less.

5.6 An Application of Solution Verification to a One-dimensional Advection Solver

An example is discussed to illustrate how solution verification is conducted in practice. Simplicity of our example should not obscure that the procedure would be similar for a real-world application in computational physics or engineering. Reference [14], for example, shows an application to wind turbine blade vibration using a finite element model.

The example is an advection equation solved in one-dimensional, Cartesian coordinates with a diffusion term added in the right-hand side:

$$ \frac{\partial \psi \left(x;t\right)}{\partial t}+\alpha \cdot \frac{\partial \psi \left(x;t\right)}{\partial x}=\beta \cdot \frac{\partial^2\psi \left(x;t\right)}{\partial {x}^2}+S\left(x;t\right), $$
(5.16)

where the computational domain is defined as −1 ≤ x ≤ +1. The initial (at t = 0) and boundary (at x = ±1) conditions are defined below. With the absence of a source function, that is, S(x;t) = 0 in Eq. (5.16), the waveform Ψ(x;t) is simply advected (or translated) at constant velocity α across the computational domain. The coefficient β controls the amount of diffusion added to the solution. The solution Ψ(x;t) is continuous, meaning that no discontinuity (or shock) or instability develops as time progresses.

An upwind scheme, which is 1st-order accurate, is selected to discretize the advection operator while central differences, which are 2nd-order accurate, are used for the diffusion term. These choices are written as:

$$ \begin{array}{c}\dfrac{\partial \psi \left(x;t\right)}{\partial t}\approx \dfrac{1}{\Delta t}\cdot \left({\psi}_k^{n+1}-{\psi}_k^n\right),\kern0.75em \dfrac{\partial \psi \left(x;t\right)}{\partial x}\approx \dfrac{1}{\Delta x}\cdot \left({\psi}_{k+1}^n-{\psi}_k^n\right).\\[12pt] {}\dfrac{\partial^2\psi \left(x;t\right)}{\partial {x}^2}\approx \dfrac{1}{\Delta {x}^2}\cdot \left({\psi}_{k+1}^n-2{\psi}_k^n+{\psi}_{k-1}^n\right)\end{array} $$
(5.17)

The resulting finite volume scheme is fully explicit and implemented in a Matlab™ simulation code as:

$$ {\psi}_k^{n+1}={\psi}_k^n+\frac{\alpha \cdot \Delta t}{\Delta x}\cdot \left({\psi}_{k+1}^n-{\psi}_k^n\right)+\frac{\beta \cdot \Delta t}{\Delta {x}^2}\cdot \left({\psi}_{k+1}^n-2{\psi}_k^n+{\psi}_{k-1}^n\right)+{S}_k^n, $$
(5.18)

where Ψ k n denotes the discretized zone-averaged solution at location x = k·Δx and time t = n·Δt:

$$ {\psi}_k^n=\underset{x=\left(k-\frac{1}{2}\right)\Delta x}{\overset{x=\left(k+\frac{1}{2}\right)\Delta x}{\int }}\psi \left(x;n\cdot \Delta t\right)\cdot dx. $$
(5.19)

Modified equation analysis provides the continuous equation that the discrete solution Ψ k n attempts to approximate. The derivations (not shown) indicate that it consists of the original Eq. (5.16) augmented with an infinite number of terms that represent the truncation error introduced by the particular choice of discretization scheme (5.17). The leading-order terms of the modified equation are:

$$ \begin{array}{c}\dfrac{\partial \psi }{\partial t}+\alpha \cdot \dfrac{\partial \psi }{\partial x}=\beta \cdot \dfrac{\partial^2\psi }{\partial {x}^2}+S+\dfrac{\alpha \Delta x}{2}\cdot \left(1- CFL\right)\cdot \dfrac{\partial^2\psi }{\partial {x}^2}-\dfrac{\alpha \Delta {x}^2}{6}\cdot \left(1-{CFL}^2\right)\cdot \dfrac{\partial^3\psi }{\partial {x}^3},\\[9pt] {}+\dfrac{\beta \Delta t}{2}\cdot \left(\alpha \dfrac{\partial^3\psi }{\partial {x}^3}-\beta \dfrac{\partial^4\psi }{\partial {x}^4}\right)-\dfrac{\beta \Delta {t}^2}{3}\cdot \left({\alpha}^2\dfrac{\partial^4\psi }{\partial {x}^4}-\alpha \dfrac{\partial^5\psi }{\partial {x}^5}+\dfrac{\beta^2}{2}\dfrac{\partial^6\psi }{\partial {x}^6}\right)+...\end{array} $$
(5.20)

with the Courant number defined as CFL = α·Δt/Δx. The fully explicit numerical scheme of Eq. (5.18) is stable only if the time-space discretization (Δt; Δx) satisfies CFL < 1. The modified equation clearly indicates that the proposed numerical method is 1st-order accurate in both time and space since the leading terms of truncation error are proportional to Δt (for the temporal error) and Δx (for the spatial error).

We now assume that modified equation analysis cannot be carried out. This is usually the case for real-world applications that feature multiple dimensions, large numbers of state variables, coupled mechanics or physics, and nonlinear governing equations, which makes it intractable to derive the modified equation. When confronted with this situation, the behavior of truncation error is studied through mesh refinement.

The exact solution of the homogeneous variant of Eq. (5.16), for which S(x;t) = 0, is:

$$ {\psi}^{Exact}\left(x;t\right)={\psi}_0\cdot {e}^{+\lambda t}\cdot \sin \left( kx+\omega t\right), $$
(5.21)

where the constants are defined as ω = −α·k and λ = −β·k 2. In the numerical application discussed next, the coefficients are defined as α = 0.2, β = 0.002, Ψ o  = 1 and k = 15. In addition, the initial and boundary conditions are defined to guarantee that S(x; t) remains equal to zero at all locations and instants with:

$$ \begin{array}{c}{\psi}^{Exact}\left(x;t=0\right)={\psi}_0\cdot \sin (kx)\\ {}{\psi}^{Exact}\left(x=-1;t\right)={\psi}_0\cdot {e}^{-\beta {k}^2t}\cdot \sin \left(-k\left(\alpha t+1\right)\right), \\ {}\kern0.75em {\psi}^{Exact}\left(x=+1;t\right)={\psi}_0\cdot {e}^{-\beta {k}^2t}\cdot \sin \left(-k\left(\alpha t-1\right)\right).\end{array} $$
(5.22)

Figure 5.3 illustrates exact solutions Ψ Exact (x;t) at times t = 0 (initial condition) and t = 1. The two physical effects can be observed with, first, advection that translates the solution across the domain (from the red curve to the blue curve) and, second, diffusion that removes energy from the solution, which tends to “spread” the waveform spatially and reduces its amplitude.

Fig. 5.3
figure 3

Exact solutions Ψ Exact at times t = 0 (red curve) and t = 1 (blue curve)

Table 5.1 defines six discrete solutions used to execute a mesh refinement study. The refinement ratio is uniform and equal to R = 2. Settings selected for these runs satisfy the stability criterion (CFL < 1), even for the most refined discretization with 3040 zones. Figure 5.4 illustrates the discrete solutions (color lines) and compares them to the exact solution (black dashed line) at t = 1. The figure clearly indicates that the discrete solutions converge to the exact solution (5.21) without, however, revealing at which rate.

Table 5.1 Definition of settings used to generate six discrete solutions Ψ k n
Fig. 5.4
figure 4

Comparison of discrete Ψ k n (color lines) and exact Ψ Exact (black dashed line) solutions

Formal verification is carried out next. Code verification could be performed using the entire solution field by studying the behavior of truncation error ||Ψ Exact − Ψ k n|| since the exact solution is analytically known as shown in Eqs. (5.21) and (5.22). It is not, however, what is illustrated here. The exact solution is not used and solution verification is performed instead. To simplify the discussion, it is applied to peak values extracted from the discrete solutions at the final simulation time of t = 1, that is:

$$ {{}_{Max}\psi}_k^n=\underset{-1\le x\le +1}{ \max }{\psi}_k^n\left(x;1\right). $$
(5.23)

The objectives of the analysis are to, first, verify if the peak values pictured in Fig. 5.4 converge with a 1st-order rate when the computational mesh is refined, as they should according to the modified Eq. (5.20); and, second, quantify the solution uncertainty at any level of mesh resolution.

Even though it would be possible to use triplets of discrete solutions to estimate the rate-of-convergence using Eq. (5.9) with R = 2, the behavior of truncation error is studied by simultaneously processing the six discrete solutions and solving Eq. (5.7) using a nonlinear optimization solver. It gives:

$$ \left|{}_{Max}{\psi}^{Reference}{-}_{Max}{\psi}_k^n\left(\Delta x\right)\right|=3.454\cdot \Delta {x}^{0.998}, $$
(5.24)

with Max Ψ Reference = 0.634. The observed convergence rate of p = 0.998 clearly indicates 1st-order spatial convergence, which matches expectation given the theoretical properties of the numerical solver (5.18).

Table 5.2 lists the bounds of solution uncertainty U(Δx) for the four finest levels of resolution. The fourth column gives the upper bounds as percentages of discrete solutions, as defined in Eq. (5.13), and the fifth column gives them in absolute magnitudes, that is, Max Ψ k n (Δx)·U(Δx). These discrete solutions, all obtained with a minimum of 380 computational zones, feature less than 10% numerical uncertainty due to truncation error. Another factor, that Table 5.2 does not show, is time-to-solution. If an overall level of 10% error is admissible to predict the peak value, one might decide to pursue simulations using the 380-zone discretization because its solution can be computed faster than using a finer level of mesh resolution.

Table 5.2 Bounds of solution uncertainty U(Δx) at different mesh resolutions

Figure 5.5 summarizes the results by illustrating the discrete solutions (blue squares), which are the peak values Max Ψ k n (Δx) obtained at different resolutions Δx, and their bounds of uncertainty (vertical green lines), which are the upper bounds U(Δx) that result from mesh-induced truncation error. Note that the figure uses a log-log scale on its horizontal (mesh sizes) and vertical (solutions) axes. The red dashed line represents the 1st-order trend with which discrete solutions converge. The horizontal black dashed line indicates the extrapolated solution Max Ψ Reference, which is the best estimate of the value that the numerical solver would converge to if a calculation could be performed at infinite resolution, that is, as Δx ➔ 0.

Fig. 5.5
figure 5

Convergence of discrete solutions Max Ψ k n and their bounds of truncation error U(Δx)

5.7 Conclusion

Verifying that a simulation code is free of programming mistakes, and the numerical methods that it implements deliver convergence properties which match theory, are essential activities to establish the quality of numerical solutions. Simply speaking, it is the first “V” of the Verification and Validation of numerical simulations. The discipline of code and solution verification in computational engineering and physics develops tools to assess the sources and severity of discretization and numerical errors. The discussion offered in this manuscript outlines simple procedures to evaluate the regime of asymptotic convergence, estimate a rate-of-convergence based on mesh (or grid) refinement, extrapolate discrete solutions, and develop bounds of numerical uncertainty due to discretization-induced truncation error.

Much of verification, however, remains incomplete. A non-exhaustive list of topics that warrant further research includes: extending the state-of-the-practice of verification to non-scalar quantities (curves, images, multiple-dimensional fields), developing technology to study the coupling between temporal and spatial discretization, defining a “reference” mesh for the estimation of solution error, and developing methods to verify the numerical quality of calculations which feature adaptive mesh refinement. It is our hope that computational engineers and physicists, while increasingly relying on modeling and simulation, will recognize the importance that numerical issues play in model validation and become advocates for best practices in the discipline of code and solution verification.