Skip to content
Brent$117.6Gas TTF$1,192USD453.87 ₸
MunaiHub
SimulationEquations and numerical methods Advanced 26 min read

Finite differences: from equations to computation

The finite-difference method replaces the derivatives in a differential equation with differences of the values of the unknown quantity at neighbouring points of the grid and at neighbouring moments of time. (A derivative is the rate at which a quantity changes. A difference is the change between two neighbouring values.) The equation turns into a system of algebraic equations (ordinary equations with no derivatives), the finite-difference scheme, which the computer solves. The theory of finite-difference schemes answers three questions. How far does the difference equation differ from the original one? This is the truncation error, the error made by replacing a derivative with a difference. Its order says how fast this error falls when the step gets smaller. Do the errors grow from step to step (stability)? Does the solution approach the exact one when the grid and the step are made smaller (convergence)?

Why it matters

A simulator does not solve the flow equations themselves. It solves their difference analogues, so every result of a model contains the error of the scheme. When you understand where this error comes from and how it falls as the grid is made finer, you can choose the cell size and the time step. You recognise numerical artefacts (effects that come from the method, not from the reservoir): a calculation that “falls apart”, oscillations, lag. And you design the convergence check so that it really separates the error of the scheme from the uncertainty of the data.

Quick refresher

  • A difference replaces a derivative with an error that the Taylor series shows. The forward and backward differences are of first order: half the step gives half the error. The central difference and the three-point second difference are of second order: the error becomes four times smaller.
  • The truncation error is the residual (the amount by which the equation fails to hold) that the exact solution gives when it is substituted into the difference equation. A scheme approximates the equation (it is consistent with it) if the residual tends to zero as the grid and the step are refined.
  • Stability is the property of not amplifying errors from step to step. Approximation together with stability gives convergence, and the error of the solution falls with the same order as the truncation error.
  • The von Neumann analysis splits the error into harmonics (waves of different lengths) and finds the amplification factor GG of each one over a step (the number by which that wave is multiplied in one step). A scheme is stable if ∣G∣≤1|G| \le 1 for all harmonics. For the explicit scheme of the pressure equation this gives r=ηΔt/Δx2≤1/2r = \eta\Delta t/\Delta x^2 \le 1/2.
  • The implicit scheme (first order in time) is stable at any step and does not oscillate. The Crank–Nicolson scheme is also stable and is more accurate (second order). But with a large step its fast components hardly decay and change sign at every step: after abrupt changes the solution “rings” (it keeps swinging up and down).
  • A convergence study separates the grid error and the step error. Extrapolation uses the results on several grids to predict the answer for an infinitely fine grid. At a fixed step it gives the answer for that step and not the exact solution, so we check the step separately.
Key relationships
pi+1−pi−12Δx=pi′+Δx26 pi′′′+O(Δx4)\frac{p_{i+1} - p_{i-1}}{2\Delta x} = p'_i + \frac{\Delta x^2}{6}\,p'''_i + O(\Delta x^4)

central difference: second order

pi+1−2pi+pi−1Δx2=pi′′+Δx212 pi(4)+O(Δx4)\frac{p_{i+1} - 2p_i + p_{i-1}}{\Delta x^2} = p''_i + \frac{\Delta x^2}{12}\,p^{(4)}_i + O(\Delta x^4)

three-point second difference: second order

pin+1−pinΔt=η[σ δ2pin+1+(1−σ) δ2pin]\frac{p_i^{n+1} - p_i^{n}}{\Delta t} = \eta\left[\sigma\,\delta^2 p_i^{n+1} + (1 - \sigma)\,\delta^2 p_i^{n}\right]

weighted scheme; δ2pi=(pi+1−2pi+pi−1)/Δx2\delta^2 p_i = (p_{i+1} - 2p_i + p_{i-1})/\Delta x^2; σ\sigma = 0 is explicit, 1 is implicit, ½ is Crank–Nicolson

G(ξ)=1−4(1−σ) rsin⁡2(ξ/2)1+4σrsin⁡2(ξ/2),r=η ΔtΔx2G(\xi) = \frac{1 - 4(1 - \sigma)\,r\sin^2(\xi/2)}{1 + 4\sigma r\sin^2(\xi/2)},\qquad r = \frac{\eta\,\Delta t}{\Delta x^2}

amplification factor of a harmonic with phase ξ\xi per cell; stability means ∣G∣≤1|G| \le 1

e≈Cx Δxp+Ct Δtqe \approx C_x\,\Delta x^{p} + C_t\,\Delta t^{q}

error model for a convergence study: pp and qq are the orders in space and in time

Common pitfalls
  • Taking the order of a scheme for a guarantee of accuracy: it says how fast the error falls when we refine the grid, not how large it is on the grid we chose.
  • Confusing the convergence of a scheme (the solution tends to the exact one as we refine) with the convergence of the iterations within a step (the equations of the step are solved to a given residual).
  • Judging stability from the first steps: an unstable component grows out of round-off errors (tiny errors from rounding numbers in the computer) and becomes visible only after tens of steps.
  • Using the Crank–Nicolson scheme with a large step right after a well is started or shut in: the pressure at the well will oscillate.
  • Checking convergence only in the grid at a fixed time step, or estimating the order from two calculations instead of three.

After this lesson you can

  • derive difference formulas for the first and second derivatives from the Taylor series, and find their truncation error and order
  • write the explicit scheme (flows from the pressures at the start of the step), the implicit scheme (flows from the pressures at the end) and the Crank–Nicolson scheme (flows from the average of the two) for the pressure equation as special cases of a weighted scheme (flows from a weighted mix of the two), and give the order of each in time and in space
  • tell approximation, stability and convergence apart, and explain why convergence needs the first two together
  • carry out a von Neumann stability analysis: find the amplification factor of a harmonic (the number by which a wave-shaped error is multiplied in one step), and from it the largest step of the explicit scheme and the properties of the implicit and Crank–Nicolson schemes
  • plan a convergence study in the grid and in the time step, estimate the observed order, and separate the grid error from the time-step error

From derivatives to differences

In a simulation model the pressure is known not everywhere but only at separate points, the cell centres, and only at separate moments of time. We say it is known on a grid in space and in time. Let pinp_i^n be the pressure at the point xix_i at the moment tnt^n. Neighbouring points are a step Δx\Delta x apart, and neighbouring moments are a step Δt\Delta t apart. A grid has no derivatives, only numbers at the nodes (the points of the grid). The finite-difference method replaces each derivative by a combination of these numbers, a finite difference. The set of nodes that enter a difference formula is called the stencil.

In the lesson Pressure equation for single-phase flow the equations of the cells were obtained in a different way, from the mass balance of a cell. For equal cells of a uniform formation both ways lead to the same result: the link coefficient divided by the storage capacity of the cell equals the hydraulic diffusivity divided by the square of the cell size. So everything the theory of finite-difference schemes says about error and stability also applies to the cell equations of a simulator.

The cell equation as a finite-difference scheme
S pin+1−pinΔt=a(pi+1−2pi+pi−1)⟺pin+1−pinΔt=η pi+1−2pi+pi−1Δx2S\,\frac{p_i^{n+1} - p_i^{n}}{\Delta t} = a\left(p_{i+1} - 2p_i + p_{i-1}\right)\quad\Longleftrightarrow\quad \frac{p_i^{n+1} - p_i^{n}}{\Delta t} = \eta\,\frac{p_{i+1} - 2p_i + p_{i-1}}{\Delta x^2}
where:
  • S=VpctS = V_p c_tstorage capacity of the cell, Vp=A Δx ϕV_p = A\,\Delta x\,\phi, m³/MPa
  • a=0.0853 kA/(μΔx)a = 0.0853\,kA/(\mu\Delta x)link coefficient of two equal neighbouring cells, m³/(d·MPa)
  • η=0.0853 k/(ϕμct)\eta = 0.0853\,k/(\phi\mu c_t)hydraulic diffusivity (how fast pressure changes spread through the formation); η/Δx2=a/S\eta/\Delta x^2 = a/S, m²/d
  • pin, pin+1p_i^{n},\ p_i^{n+1}pressure in cell ii at the start and at the end of the step, MPa
  • Δx, Δt, A\Delta x,\ \Delta t,\ Acell size, time step, face area, m, d, m²

Units: metric oilfield units: kk in mD, μ\mu in mPa·s, ctc_t in 1/MPa, pp in MPa, tt in d; 0.0853 is the constant of Darcy's law in these units (Rock permeability)

Holds when
  • Equal cells of a uniform formation, the linear pressure equation, an inner cell without a well.
  • The moment whose pressures give the right-hand side has not been chosen yet. The scheme depends on it (see below).

On the right is the central second difference multiplied by the diffusivity: the cell equation is a finite-difference scheme for the diffusivity equation. For a heterogeneous formation and cells of different sizes the coefficients change from cell to cell, but the structure is the same.

The Taylor series: truncation error and order

The Taylor series shows how far a difference is from a derivative. It expresses the value of a smooth function at a neighbouring point through the value and the derivatives at the given point.

The Taylor series for neighbouring nodes
pi±1=pi±Δx pi′+Δx22 pi′′±Δx36 pi′′′+Δx424 pi(4)±…p_{i\pm1} = p_i \pm \Delta x\,p'_i + \frac{\Delta x^2}{2}\,p''_i \pm \frac{\Delta x^3}{6}\,p'''_i + \frac{\Delta x^4}{24}\,p^{(4)}_i \pm \ldots
where:
  • pi, pi±1p_i,\ p_{i\pm1}values of the function at node ii and at the neighbouring nodes, MPa
  • pi′, pi′′, pi′′′, pi(4)p'_i,\ p''_i,\ p'''_i,\ p^{(4)}_ifirst to fourth derivatives with respect to xx at node ii, MPa/m, MPa/m², …
  • Δx\Delta xgrid step, m

Units: any consistent units

Holds when
  • The function is smooth: it has continuous derivatives of the needed order between the nodes.
  • The grid step is constant (a non-uniform grid is in the advanced section).

The upper signs are for node i+1i + 1, and the lower signs are for i−1i - 1. The smaller the step, the faster the terms of the series fall, and the smaller the part that we discard.

If we subtract pip_i and divide by the step, we get the forward difference. If we subtract the two expansions from each other, we get the central difference. If we add them, we get the second difference. The terms that remain after the derivative are the error of the formula.

Difference formulas and their error
pi+1−piΔx=pi′+Δx2 pi′′+O(Δx2)(forward)pi−pi−1Δx=pi′−Δx2 pi′′+O(Δx2)(backward)pi+1−pi−12Δx=pi′+Δx26 pi′′′+O(Δx4)(central)pi+1−2pi+pi−1Δx2=pi′′+Δx212 pi(4)+O(Δx4)(second difference)\begin{aligned} &\frac{p_{i+1} - p_i}{\Delta x} = p'_i + \frac{\Delta x}{2}\,p''_i + O(\Delta x^2) &&\text{(forward)}\\ &\frac{p_i - p_{i-1}}{\Delta x} = p'_i - \frac{\Delta x}{2}\,p''_i + O(\Delta x^2) &&\text{(backward)}\\ &\frac{p_{i+1} - p_{i-1}}{2\Delta x} = p'_i + \frac{\Delta x^2}{6}\,p'''_i + O(\Delta x^4) &&\text{(central)}\\ &\frac{p_{i+1} - 2p_i + p_{i-1}}{\Delta x^2} = p''_i + \frac{\Delta x^2}{12}\,p^{(4)}_i + O(\Delta x^4) &&\text{(second difference)} \end{aligned}
where:
  • O(Δxm)O(\Delta x^m)terms of order Δxm\Delta x^m: when the step is halved, they decrease by about 2m2^m times, —
  • pi′, pi′′, pi′′′, pi(4)p'_i,\ p''_i,\ p'''_i,\ p^{(4)}_iderivatives at node ii, MPa/m, MPa/m², …

Units: any consistent units

Holds when
  • A smooth function and a constant step.
  • The values at the nodes are exact (no noise or round-off).

When we subtract the expansions, the terms with even powers of the step cancel, and when we add them, the terms with odd powers cancel. So the error of the central difference and of the second difference starts with the second power of the step, while for the forward and backward differences it starts with the first power. The forward and backward differences are wrong by an amount proportional to the step and to the curvature of the function.

Truncation error (approximation error)
The difference between a difference formula and the derivative that it replaces, when the exact function is substituted (truncation error). Here we denote it by ψ\psi.
Order of accuracy
The exponent of the step in the leading term of the error: a formula has order mm if ψ=O(Δxm)\psi = O(\Delta x^m). When the step is halved, the error falls about 2m2^m times.
Leading term
The first non-vanishing term of the series in the error, for example Δx2p′′\tfrac{\Delta x}{2}p'' for the forward difference. It shows not only the order but also the sign of the error: for p′′<0p'' < 0 the forward difference underestimates the derivative.
Difference formulas for derivatives
Formula
forward, p′p'
Nodes
i, i+1i,\ i + 1
Leading term of the error
Δx2 p′′\tfrac{\Delta x}{2}\,p''
Order
1
Formula
backward, p′p'
Nodes
i−1, ii - 1,\ i
Leading term of the error
−Δx2 p′′-\tfrac{\Delta x}{2}\,p''
Order
1
Formula
central, p′p'
Nodes
i±1i \pm 1
Leading term of the error
Δx26 p′′′\tfrac{\Delta x^2}{6}\,p'''
Order
2
Formula
second difference, p′′p''
Nodes
i, i±1i,\ i \pm 1
Leading term of the error
Δx212 p(4)\tfrac{\Delta x^2}{12}\,p^{(4)}
Order
2

A uniform grid and a smooth function. Formulas in time are built in the same way: the difference (pn+1−pn)/Δt(p^{n+1} - p^n)/\Delta t is a forward difference if we attribute it to the moment tnt^n, and a central difference if we attribute it to the middle of the step.

Worked examplePressure derivatives near a well from three points
Given (assumed data)
Pressure profile (the well of the lesson Flow regimes)
p(r)−pwf=mln⁡(r/rw)p(r) - p_{wf} = m\ln(r/r_w); mm = 0.388 MPa = 388 kPa; rwr_w = 0.1 m
Point and steps
rr = 10 m; Δr\Delta r = 2 m and 1 m
Exact derivatives
p′=m/rp' = m/r = 38.8 kPa/m; p′′=−m/r2p'' = -m/r^2 = −3.88 kPa/m²
Solution
  1. Pressure differences for a step of 2 m: p(12)−p(10)=388ln⁡1.2=70.741p(12) - p(10) = 388\ln 1.2 = 70.741 kPa; p(10)−p(8)=388ln⁡1.25=86.580p(10) - p(8) = 388\ln 1.25 = 86.580 kPa.
  2. Forward difference: 70.741/2=35.3770.741/2 = 35.37 kPa/m, error −3.43-3.43 kPa/m (−8.8%). Backward: 86.580/2=43.2986.580/2 = 43.29 kPa/m, error +4.49+4.49 kPa/m. Central: (70.741+86.580)/4=39.33(70.741 + 86.580)/4 = 39.33 kPa/m, error +0.530+0.530 kPa/m (+1.37%).
  3. Step of 1 m: p(11)−p(10)=36.980p(11) - p(10) = 36.980 kPa, p(10)−p(9)=40.880p(10) - p(9) = 40.880 kPa. Forward: 36.98 kPa/m (error −1.82-1.82), backward: 40.88 (error +2.08+2.08), central: 38.93 kPa/m (error +0.130+0.130, 0.34%).
  4. How many times the errors fell when the step was halved: for the forward difference 3.43/1.82=1.93.43/1.82 = 1.9, first order; for the central difference 0.530/0.130=4.10.530/0.130 = 4.1, second order.
  5. Leading terms of the Taylor series for a step of 2 m: for the forward difference Δr2p′′=−3.88\tfrac{\Delta r}{2}p'' = -3.88 kPa/m, for the central difference Δr26p′′′=+0.517\tfrac{\Delta r^2}{6}p''' = +0.517 kPa/m (here p′′′=2m/r3p''' = 2m/r^3). They are close to the actual errors. The remainder comes from the next terms of the series.
  6. Second derivative from three points: for a step of 2 m (70.741−86.580)/22=−3.960(70.741 - 86.580)/2^2 = -3.960 kPa/m² (error 2.1%), for a step of 1 m (36.980−40.880)/12=−3.900(36.980 - 40.880)/1^2 = -3.900 kPa/m² (0.5%). The error also fell about four times.
Answer: With a step of 1 m the forward difference is wrong by 4.7%, and the central one by 0.34%. When the step was halved, the error of the first fell 1.9 times, and that of the second fell 4.1 times.

What it means. The central difference with a step of 2 m is more accurate than the forward difference with a step of 1 m: the gain from the higher order is larger than the gain from the smaller step. The leading term predicts the sign of the errors. The curvature of the profile is negative, so the forward difference underestimates the slope and the backward difference overestimates it. Near a well the pressure derivatives are large and grow fast towards the wellbore (the third derivative goes as 1/r31/r^3). So a uniform grid is inefficient here. We make the grid finer near a well (Grids in reservoir simulation models), and we move the pressure drop at the wellbore itself into the well model (Well model in a grid block). The data in this example are assumed for illustration.

Schemes for the pressure equation and their error

Take the one-dimensional linear pressure equation for a uniform formation, the diffusivity equation ∂p/∂t=η ∂2p/∂x2\partial p/\partial t = \eta\,\partial^2 p/\partial x^2 (Diffusivity equation). We replace the second derivative with respect to xx by a second difference. What remains is to decide the pressures of which moment to put into it. The lesson Pressure equation for single-phase flow covered the two extreme choices: the start of the step (the explicit scheme) and the end of the step (the implicit scheme). It is convenient to combine them in one weighted scheme: the right-hand side is a weighted average of the second differences at the start and at the end of the step.

The weighted scheme for the pressure equation
pin+1−pinΔt=η[σ pi+1n+1−2pin+1+pi−1n+1Δx2+(1−σ) pi+1n−2pin+pi−1nΔx2]\frac{p_i^{n+1} - p_i^{n}}{\Delta t} = \eta\left[\sigma\,\frac{p_{i+1}^{n+1} - 2p_i^{n+1} + p_{i-1}^{n+1}}{\Delta x^2} + (1 - \sigma)\,\frac{p_{i+1}^{n} - 2p_i^{n} + p_{i-1}^{n}}{\Delta x^2}\right]
where:
  • σ\sigmaweight of the end of the step: 0 is the explicit scheme, 1 is the implicit scheme, ½ is the Crank–Nicolson scheme, —
  • η\etahydraulic diffusivity, 0.0853 k/(ϕμct)0.0853\,k/(\phi\mu c_t), m²/d
  • pin, pin+1p_i^{n},\ p_i^{n+1}pressure at node (cell) ii at the start and at the end of the step, MPa
  • Δx, Δt\Delta x,\ \Delta tgrid step and time step, m, d

Units: metric oilfield units (any consistent units)

Holds when
  • A linear equation, a uniform formation, a uniform grid. For a heterogeneous formation the same is written for the cell equations with the coefficients aija_{ij} and SiS_i.
  • For σ>0\sigma > 0 each equation has three unknowns at the end of the step, and at each step we solve a tridiagonal system, as in the implicit scheme.

The weight σ\sigma sets the moment whose pressures give the flows during the step. For σ=12\sigma = \tfrac12 the flows are calculated from the average pressure of the step. This is the intermediate scheme that the lesson on the pressure equation mentions.

We find the truncation error of a scheme in the same way as for single formulas. We substitute the exact solution into it and expand all the values in a Taylor series around the middle of the step (the derivation is in the advanced section). The result is:

Truncation error of the weighted scheme
ψin=(12−σ)Δt ∂2p∂t2−η Δx212 ∂4p∂x4+O ⁣(Δt2+Δx4)\psi_i^{n} = \left(\tfrac12 - \sigma\right)\Delta t\,\frac{\partial^2 p}{\partial t^2} - \frac{\eta\,\Delta x^2}{12}\,\frac{\partial^4 p}{\partial x^4} + O\!\left(\Delta t^2 + \Delta x^4\right)
where:
  • ψin\psi_i^{n}truncation error: the left side of the scheme minus the right side when the exact solution is substituted, MPa/d
  • ∂2p/∂t2, ∂4p/∂x4\partial^2 p/\partial t^2,\ \partial^4 p/\partial x^4derivatives of the exact solution in the middle of the step, MPa/d², MPa/m⁴
  • σ, η, Δt, Δx\sigma,\ \eta,\ \Delta t,\ \Delta xweight, diffusivity, steps, —, m²/d, d, m

Units: any consistent units

Holds when
  • A smooth solution (far from sudden changes in how the wells are run, and from the wells themselves).
  • Constant coefficients, a uniform grid.

The term with Δt\Delta t vanishes only for σ=12\sigma = \tfrac12. So the explicit and implicit schemes are of first order in time and second order in space, and the Crank–Nicolson scheme is of second order in both. The error in space is the same for all three: it comes from the second difference.

Three schemes as special cases of the weighted scheme
Scheme
explicit
σ\sigma
0
Order in tt
1
Order in xx
2
Stability
for r≤1/2r \le 1/2
Scheme
implicit
σ\sigma
1
Order in tt
1
Order in xx
2
Stability
for any rr
Scheme
Crank–Nicolson
σ\sigma
½
Order in tt
2
Order in xx
2
Stability
for any rr

r=ηΔt/Δx2r = \eta\Delta t/\Delta x^2 is the mesh Fourier number (the step measured in units of the time that the pressure needs to level out over one cell). The stability conditions are derived below by the von Neumann analysis. For a non-uniform grid, for the explicit scheme it is more convenient to use the condition with the characteristic times of the cells from the lesson Pressure equation for single-phase flow.

Approximation, stability, convergence

Approximation (consistency)
The truncation error ψ\psi tends to zero when the steps Δx\Delta x and Δt\Delta t tend to zero. The scheme approximates exactly the equation that we need to solve.
Stability
Errors introduced at any step (in the initial data, by round-off, by an inexact solution of the equations of the step) do not grow without limit in the further calculation. Over the finite time of the calculation they stay smaller than their initial size multiplied by a constant number, however small the steps are (numerical stability).
Convergence
As the grid and the step are refined, the solution of the scheme tends to the exact solution of the equation at every point and at every moment.

The link between them is visible from the equation for the error of the solution, e=pexact−pe = p_{\text{exact}} - p. The exact solution satisfies the scheme with a residual ψ\psi, and the calculated one satisfies it without a residual. If we subtract one from the other, we get the same scheme for the error, but with a “source” ψ\psi at every step:

Accumulation of error in a stable scheme
en+1=A en+Δt B ψn,B=(I−σΔt L)−1,A=B(I+(1−σ)Δt L)∥en∥≤∥e0∥+tnmax⁡k∥ψk∥\begin{aligned} &e^{n+1} = \mathbf{A}\,e^{n} + \Delta t\,\mathbf{B}\,\psi^{n},\qquad \mathbf{B} = \left(\mathbf{I} - \sigma\Delta t\,\mathbf{L}\right)^{-1},\qquad \mathbf{A} = \mathbf{B}\left(\mathbf{I} + (1 - \sigma)\Delta t\,\mathbf{L}\right)\\ &\left\|e^{n}\right\| \le \left\|e^{0}\right\| + t^{n}\max_k\left\|\psi^{k}\right\| \end{aligned}
where:
  • en, ψne^{n},\ \psi^{n}vectors of the solution error and of the truncation error over all nodes at step nn, MPa, MPa/d
  • A\mathbf{A}operator of the step: what the scheme turns the error at the start of the step into, —
  • L\mathbf{L}matrix of second differences multiplied by the diffusivity, 1/d
  • I\mathbf{I}identity matrix, —
  • ∥⋅∥, tn\|\cdot\|,\ t^{n}norm of a vector (a measure of its size, for example the root-mean-square) and the time from the start of the calculation, —, d

Units: any consistent units

Holds when
  • A linear problem. The estimate on the right holds if ∥A∥≤1\|\mathbf{A}\| \le 1 (the scheme is stable) and ∥B∥≤1\|\mathbf{B}\| \le 1, which is the case for the weighted scheme for the pressure equation.
  • For an unstable scheme ∥A∥>1\|\mathbf{A}\| > 1, and the contribution of each step is multiplied by ∥A∥\|\mathbf{A}\| at all the following steps.

In a stable scheme the error after the time tnt^n is not larger than the initial error plus the time multiplied by the largest residual. The residual falls as we refine (approximation), so the error falls too (convergence), and with the same order.

This estimate illustrates the main theorem of the theory of finite-difference schemes. For a linear problem that is well posed (it has one solution that depends smoothly on the data), and for a scheme that approximates it, stability is necessary and sufficient for convergence (it is needed, and it is enough). This is the Lax equivalence theorem. Both halves matter. An unstable scheme does not converge even if it approximates the equation: round-off errors of the order of 10−1510^{-15} grow by a fixed factor at every step, and sooner or later they fill the whole result. A stable scheme without approximation may converge, but to the solution of a different equation (an example is in the advanced section).

Von Neumann stability analysis

How can we check that ∥A∥≤1\|\mathbf{A}\| \le 1 without computing the matrices? For a linear equation with constant coefficients on a uniform grid we can split the error into harmonics, which are sine waves of different wavelengths, and follow each one separately. The scheme turns a harmonic into the same harmonic multiplied by a number GG, the amplification factor. John von Neumann proposed the method in the 1940s. It is also called the method of harmonics or the spectral criterion of stability, a test that works on the separate wave components of the error (von Neumann stability analysis).

Let the error at node number jj be Gncos⁡(jξ)G^n\cos(j\xi), where ξ\xi is the phase shift of the harmonic from one node to the next. For small ξ\xi the harmonic is smooth (a long wave). For ξ=π\xi = \pi it is a “checkerboard”: neighbouring values are equal in size and opposite in sign, and a shorter wave cannot be drawn on the grid. The second difference of such a harmonic is the same harmonic multiplied by −4sin⁡2(ξ/2)/Δx2-4\sin^2(\xi/2)/\Delta x^2 (this follows from the formula for the sum of cosines). If we put the harmonic into the weighted scheme, we get:

Amplification factor of the weighted scheme
G(ξ)=1−4(1−σ) rsin⁡2(ξ/2)1+4σ rsin⁡2(ξ/2),r=η ΔtΔx2G(\xi) = \frac{1 - 4(1 - \sigma)\,r\sin^2(\xi/2)}{1 + 4\sigma\,r\sin^2(\xi/2)},\qquad r = \frac{\eta\,\Delta t}{\Delta x^2}
where:
  • G(ξ)G(\xi)how many times the amplitude of the harmonic changes over a step; G<0G < 0 means that the harmonic changes sign at every step, —
  • ξ\xiphase shift of the harmonic per cell, 0<ξ≤π0 < \xi \le \pi; the wavelength is 2πΔx/ξ2\pi\Delta x/\xi, rad
  • rrmesh Fourier number: the time step in units of the time that the pressure needs to level out over one cell, —
  • σ\sigmaweight of the scheme, —

Units: dimensionless

Holds when
  • A linear equation with constant coefficients and a uniform grid. Boundaries are not taken into account (an infinite or periodic grid).
  • For a heterogeneous formation we check the condition locally, with the local η\eta and Δx\Delta x. For a nonlinear equation we check it with the coefficients “frozen” at the step. The condition is then necessary but not always sufficient.

The exact solution reduces the same harmonic over a step by a factor of e−rξ2\e^{-r\xi^2}. A scheme is stable if ∣G∣≤1|G| \le 1 for all ξ\xi, and it is accurate for the harmonics for which GG is close to e−rξ2\e^{-r\xi^2}.

Stability conditions of the weighted scheme
σ=0:  r≤12;0<σ<12:  r≤12(1−2σ);σ≥12:  for any r\sigma = 0:\ \ r \le \tfrac12;\qquad 0 < \sigma < \tfrac12:\ \ r \le \frac{1}{2(1 - 2\sigma)};\qquad \sigma \ge \tfrac12:\ \ \text{for any } r
where:
  • rrmesh Fourier number ηΔt/Δx2\eta\Delta t/\Delta x^2, —
  • σ\sigmaweight of the scheme, —

Units: dimensionless

Holds when
  • They follow from G≥−1G \ge -1 for the shortest, checkerboard harmonic (ξ=π\xi = \pi). The condition G≤1G \le 1 always holds.
  • In two and three dimensions the explicit scheme needs rx+ry+rz≤12r_x + r_y + r_z \le \tfrac12, the same condition as for a uniform grid in the lesson on the pressure equation.

For the explicit scheme r≤12r \le \tfrac12 means Δt≤Δx2/(2η)\Delta t \le \Delta x^2/(2\eta), the limit from the lesson Pressure equation for single-phase flow. Schemes with σ≥12\sigma \ge \tfrac12 are stable at any step, but this does not mean that they damp fast harmonics well (more on this below, for the Crank–Nicolson scheme).

The analysis of harmonics links two views of stability from the earlier lessons. Each harmonic behaves like a separate “tank” with its own characteristic time τξ=Δx2/(4ηsin⁡2(ξ/2))\tau_\xi = \Delta x^2/(4\eta\sin^2(\xi/2)). An explicit step multiplies it by 1−Δt/τξ1 - \Delta t/\tau_\xi, exactly like the drawdown of one tank in the lesson on the simulation model, and it is stable for Δt≤2τξ\Delta t \le 2\tau_\xi. The “fastest” tank is the checkerboard harmonic with τπ=Δx2/(4η)\tau_\pi = \Delta x^2/(4\eta). From this we get Δt≤Δx2/(2η)\Delta t \le \Delta x^2/(2\eta), the same limit that the checkerboard pattern gave in the lesson on the pressure equation.

Amplification factor over one step for the explicit, implicit and Crank–Nicolson schemes at r ≈ 4, and the exact decay0.000.250.500.751.00−1.5−1.0−0.50.00.51.0Harmonic phase ξ/πAmplification factor GexactimplicitCrank–Nicolsonexplicitstability limit

A graph. The horizontal axis is the phase of the harmonic from 0 to π (in fractions of π). The vertical axis is the amplification factor from −1.5 to 1. The exact curve falls quickly from 1 almost to zero by 0.4π. The curve of the implicit scheme falls more slowly and comes to 0.06 at π. The curve of the Crank–Nicolson scheme first runs almost along the exact one, crosses zero near 0.23π and goes down to −0.78 at π. The curve of the explicit scheme falls steeply, crosses the dashed line at −1 at the same place, near 0.23π, and goes down out of the graph.

CalculatedThe amplification factor over one step for harmonics of different wavelengths, for r≈4r \approx 4 (cells of 250 m, a step of 30 days, hydraulic diffusivity 8412 m²/d), and the exact decay e−rξ2\e^{-r\xi^2}. The explicit scheme goes beyond the stability limit already for fairly long waves. The implicit scheme damps short waves, and damps long waves less than the exact solution does. In the Crank–Nicolson scheme short waves decay slowly and change sign.
Worked exampleAmplification factors of the three schemes on a grid with cells of 250 m
Given (assumed data)
Grid and rock (lesson Flow regimes)
Δx\Delta x = 250 m; η\eta = 8412 m²/d
Time steps
3, 6 and 30 d
Harmonics
a smooth one, ξ=π/8\xi = \pi/8 (a wave of 16 cells = 4 km), and the checkerboard one, ξ=π\xi = \pi
Solution
  1. The numbers r=ηΔt/Δx2r = \eta\Delta t/\Delta x^2: 0.4038, 0.8076 and 4.04. The limit of the explicit scheme is r≤0.5r \le 0.5, that is Δt≤Δx2/(2η)=3.71\Delta t \le \Delta x^2/(2\eta) = 3.71 d.
  2. The smooth harmonic, sin⁡2(π/16)=0.0381\sin^2(\pi/16) = 0.0381. Step of 3 d: explicit 0.9385, implicit 0.9421, Crank–Nicolson 0.9404; exactly, e−rξ2=0.9396\e^{-r\xi^2} = 0.9396. All three are close to the exact value.
  3. The checkerboard harmonic, sin⁡2(π/2)=1\sin^2(\pi/2) = 1. Step of 3 d: explicit 1−4⋅0.4038=−0.6151 - 4\cdot0.4038 = -0.615, which decays while changing sign; implicit 0.382; Crank–Nicolson 0.106.
  4. Step of 6 d: the smooth harmonic of the explicit scheme is 0.877 against the exact 0.883, still good. The checkerboard one is 1−4⋅0.8076=−2.231 - 4\cdot0.8076 = -2.23: in 10 steps it grows about 3000 times, and in 30 steps about 2.8·10¹⁰ times.
  5. Step of 30 d, implicit scheme: the smooth one is 0.619 against the exact 0.536, and the checkerboard one is 0.058, almost fully damped.
  6. Step of 30 d, Crank–Nicolson scheme: the smooth one is 0.530, almost exact. The checkerboard one is (1−2⋅4.04)/(1+2⋅4.04)=−0.78(1 - 2\cdot4.04)/(1 + 2\cdot4.04) = -0.78: after 5 steps 0.29 of its initial amplitude remains (the sign changes at every step), while in the exact solution it disappears in the very first step.
Answer: On this grid the explicit scheme is stable for steps up to 3.71 d. At 6 d the checkerboard harmonic grows 2.23 times per step. At a step of 30 d the implicit scheme damps the checkerboard harmonic (0.058), and the Crank–Nicolson scheme hardly does (−0.78), but it reproduces the smooth harmonic more accurately (0.530 against 0.619, with the exact 0.536).

What it means. The factors explain the behaviour of the schemes without a calculation over cells. Instability is ∣G∣>1|G| > 1 for short waves. The lag of the implicit scheme is its GG for long waves being larger than the exact one: the disturbance decays more slowly than it should. The “ringing” of the Crank–Nicolson scheme is a GG close to −1 for short waves. The initial data and the round-off errors contain all harmonics, so an unstable harmonic will show up sooner or later, even if we do not see it in the first steps. The data in this example are assumed for illustration.

The analysis of harmonics does not take boundaries and heterogeneity into account. Usually they make the limit a little less strict: in the strip of the lesson Pressure equation for single-phase flow the smallest characteristic time of the cells is 3.3 d, and the exact limit is about 4.1 d. So in practice we use the local condition for the smallest and most conductive cells. It is reliable, and we check it for each cell separately.

The Crank–Nicolson scheme

For σ=12\sigma = \tfrac12 the flows during the step are taken as the average of the flows calculated from the pressures at the start and at the end of the step. In effect, we calculate the integral over time by the trapezoid rule (the average of the two ends). This is the Crank–Nicolson scheme, proposed in 1947 for the heat conduction equation. In the notation of the cell equation:

The Crank–Nicolson scheme for the cell equation
Si pin+1−pinΔt=12∑jaij(pjn+1−pin+1)+12∑jaij(pjn−pin)−qiS_i\,\frac{p_i^{n+1} - p_i^{n}}{\Delta t} = \frac12\sum_j a_{ij}\left(p_j^{n+1} - p_i^{n+1}\right) + \frac12\sum_j a_{ij}\left(p_j^{n} - p_i^{n}\right) - q_i
where:
  • Si, aijS_i,\ a_{ij}storage capacity of the cell and the link coefficients with the neighbours, m³/MPa, m³/(d·MPa)
  • qiq_iwithdrawal by a well from the cell at reservoir conditions, m³/d
  • pn, pn+1p^{n},\ p^{n+1}pressures at the start and at the end of the step, MPa

Units: metric oilfield units, as in the lesson on the pressure equation

Holds when
  • A linear equation. The withdrawal qiq_i is constant during the step.
  • The system for the pressures at the end of the step is tridiagonal (in one dimension), with the diagonal Si/Δt+12∑jaijS_i/\Delta t + \tfrac12\sum_j a_{ij}.

The work per step is the same as for the implicit scheme, one system of equations, but the error in time is of second order. The scheme is stable at any step: ∣G∣≤1|G| \le 1 for all harmonics.

The weak point is visible in the amplification factor. For σ=12\sigma = \tfrac12 and the checkerboard harmonic, G=(1−2r)/(1+2r)G = (1 - 2r)/(1 + 2r). With a large step (r≫1r \gg 1) it tends to −1: short waves hardly decay and change sign at every step. While the solution is smooth, it has few short waves, and this goes unnoticed. But an abrupt change brings short waves into the solution. Examples are starting or shutting in a well, a change of rate, or a sharp initial pressure difference. Then decaying saw-tooth oscillations appear in the cells next to the place of the change. The implicit scheme damps such waves at once (G→0G \to 0). This property, the strong damping of the fastest components (those that change most quickly from cell to cell), is called L-stability.

Worked exampleOne step of 10 days with the Crank–Nicolson scheme on a strip of four cells
Given (assumed data)
Strip (lesson Pressure equation for single-phase flow)
SS = 316.875 m³/MPa; a12a_{12} = 68.24, a23a_{23} = 27.296, a34a_{34} = 28.433 m³/(d·MPa); withdrawal from cell 4 is 130 m³/d at reservoir conditions; initial pressure 20 MPa
Step
Δt\Delta t = 10 d, three times larger than the smallest characteristic time of the cells (3.3 d)
Solution
  1. At the start of the step the pressure is uniform and there are no flows. So for the pressure changes δi\delta_i the system is the same as for the implicit scheme, but with half the link coefficients: 12a\tfrac12 a = 34.120, 13.648 and 14.217. The diagonal is bi=S/Δt+12∑jaijb_i = S/\Delta t + \tfrac12\sum_j a_{ij} with S/Δt=31.6875S/\Delta t = 31.6875: 65.8075, 79.4555, 59.5525 and 45.9045. The right-hand side is (0; 0; 0; −130)(0;\ 0;\ 0;\ -130).
  2. Forward pass of the Thomas algorithm: e1=34.120/65.8075=0.5185e_1 = 34.120/65.8075 = 0.5185; w2=79.4555−34.120⋅0.5185=61.76w_2 = 79.4555 - 34.120\cdot0.5185 = 61.76, e2=13.648/61.76=0.2210e_2 = 13.648/61.76 = 0.2210.
  3. w3=59.5525−13.648⋅0.2210=56.54w_3 = 59.5525 - 13.648\cdot0.2210 = 56.54, e3=14.217/56.54=0.2515e_3 = 14.217/56.54 = 0.2515; w4=45.9045−14.217⋅0.2515=42.33w_4 = 45.9045 - 14.217\cdot0.2515 = 42.33.
  4. Backward pass: δ4=−130/42.33=−3.071\delta_4 = -130/42.33 = -3.071; δ3=0.2515⋅δ4=−0.772\delta_3 = 0.2515\cdot\delta_4 = -0.772; δ2=0.2210⋅δ3=−0.171\delta_2 = 0.2210\cdot\delta_3 = -0.171; δ1=0.5185⋅δ2=−0.089\delta_1 = 0.5185\cdot\delta_2 = -0.089 MPa.
  5. Pressures after 10 days: 19.91, 19.83, 19.23 and 16.93 MPa. Exact solution of the cell equations: 19.92, 19.82, 19.11 and 17.04 MPa. The implicit scheme with the same step gave 17.39 MPa in cell 4.
  6. Step of 20 d: the pressure in cell 3 from the Crank–Nicolson scheme deviates from the exact one alternately in opposite directions, by +0.24, −0.15 and +0.03 MPa after 20, 40 and 60 days. For the implicit scheme the deviations have one sign: +0.06, +0.11 and +0.08 MPa.
Answer: After 10 days, in the cell with the well, the Crank–Nicolson scheme gives 16.93 MPa against the exact 17.04 MPa: an error of −0.11 MPa, against +0.35 MPa for the implicit scheme with the same step.

What it means. The second order in time shows in the cell with the well: for the same work, one tridiagonal system per step, the error there is three times smaller. In the neighbouring cell 3 the picture is the opposite. Already after 10 days the Crank–Nicolson scheme is wrong by more than the implicit scheme (+0.12 against −0.06 MPa). With a step of 20 days the pressure in cell 3 “swings” around the exact solution, and its first deviations are larger than for the implicit scheme. Starting a well is an abrupt change, and the fast harmonics of this scheme decay slowly and change sign. The implicit scheme has a larger error in the cell with the well, but its errors have one sign and no oscillations. For forecasts in which the operating modes of the wells change often, this matters more. The data in this example are assumed for illustration.

Levelling of pressure in a closed strip after an abrupt pressure difference: the profile after 10 days from the exact solution, the implicit scheme and the Crank–Nicolson scheme050010001500200019.019.520.020.521.0Distance along the strip x, mPressure, MPaexact solutionimplicit schemeCrank–Nicolsoninitial

A graph of pressure along the strip from 0 to 2000 metres, from 18.8 to 21.2 MPa. A dashed step shows the initial distribution: 21 MPa to the left of the middle and 19 MPa to the right. The exact solution after 10 days is a smooth S-shaped curve from 20.97 to 19.03 MPa, passing through 20 MPa in the middle. The implicit scheme runs close to it. The broken line of the Crank–Nicolson scheme agrees with them near the ends, but in the two middle cells it gives 19.47 MPa on the left and 20.53 MPa on the right, a pressure difference of the opposite sign.

CalculatedA test problem: in a closed strip 2 km long, the pressure in the left half is 2 MPa higher than in the right half. The profile after 10 days, calculated in one step of 10 days on a grid of 20 cells of 100 m (r≈8.4r \approx 8.4). The implicit scheme gives a smooth profile. The Crank–Nicolson scheme “flips” the pressure difference in the two middle cells, and at the next step it will flip back.

There are several ways to remove the oscillations. The most reliable is to make two or three steps with the implicit scheme after every abrupt change, and only then to go over to σ=12\sigma = \tfrac12: the implicit steps damp the short waves. Reducing the step after a change in how the wells are run also helps. A weight a little above one half (for example, 0.55) weakens the “ringing”: with a large step the checkerboard harmonic is multiplied not by −1 but by about −(1−σ)/σ≈−0.82-(1 - \sigma)/\sigma \approx -0.82. It also keeps the error in time small, but it does not remove the oscillations completely. Reservoir simulators usually use the first-order implicit scheme in time. The multiphase equations are nonlinear, the operating modes of the wells change often, and reliability matters more than second order. They reach the needed accuracy by the choice of the step (IMPES and fully implicit schemes).

A convergence study for the grid and for the step

The lesson on grids describes the check of convergence in the grid: calculations on several grids, each twice as fine as the one before, the observed order (the order that the results actually show), and extrapolation to an infinitely fine grid. The theory of finite-difference schemes adds two things to it: what to expect from the observed order, and how not to confuse the grid error with the time-step error. For a smooth solution the error of a result is the sum of two parts:

Error model for a convergence study
e=R−Rexact≈Cx Δxp+Ct Δtqe = R - R_{\text{exact}} \approx C_x\,\Delta x^{p} + C_t\,\Delta t^{q}
where:
  • R, RexactR,\ R_{\text{exact}}result of the calculation (pressure, rate, breakthrough time) and its exact value, in units of the result
  • p, qp,\ qorders in space and in time: for the pressure equation pp = 2; qq = 1 for the implicit scheme and 2 for the Crank–Nicolson scheme, —
  • Cx, CtC_x,\ C_tcoefficients that depend on the solution (its derivatives) and on the scheme, but not on the steps, —

Units: in units of the result

Holds when
  • The steps are small enough for the leading terms of the error to dominate (the asymptotic range).
  • The solution is smooth. Near wells, at displacement fronts and at sharp boundaries of properties, the observed order is lower than the theoretical one.
  • The errors of the solution of the equations at each step (the tolerances of the iterations) are much smaller than the error of the scheme.

If we refine only the grid, the error tends not to zero but to CtΔtqC_t\Delta t^q. If we refine only the step, it tends to CxΔxpC_x\Delta x^p. So we check the step and the grid separately, or refine them together in a consistent way.

  • The grid at a fixed step. The differences of the results on three grids still show the order pp, because the constant part CtΔtqC_t\Delta t^q cancels in them. But the extrapolation gives the answer for this step, not the exact one.
  • The step on a fixed grid. The error falls to a “floor”, the grid error. It is useless to reduce the step further.
  • Consistent refinement. If the grid and the step are made finer together, with Δt∝Δx\Delta t \propto \Delta x, the implicit scheme finally converges with first order, because the error in time falls more slowly. To keep second order, we need a step Δt∝Δx2\Delta t \propto \Delta x^2 (as for the explicit scheme, but now for accuracy and not for stability) or a scheme of second order in time.
How to check the convergence of a calculation
  1. 1
    Choose the indicators

    Take the quantities for which the model is built: the bottomhole pressure, the cumulative production by a date, the water breakthrough time. Different indicators converge differently: pressures usually converge faster than the breakthrough time.

  2. 2
    Check the time step

    On the working grid, run calculations with steps Δt\Delta t, Δt/2\Delta t/2 and Δt/4\Delta t/4. The differences of the results show the order and the size of the step error. For first order, the error of the calculation with step Δt/2\Delta t/2 is about equal to the difference between its result and the result with step Δt\Delta t.

  3. 3
    Check the grid

    Use three grids, each twice as fine as the one before, either with a step whose error is already small or with a step reduced together with the cells. The observed order from the three grids and the extrapolation follow the formula of the lesson Grids in reservoir simulation models.

  4. 4
    Compare the order with the theory

    An observed order that differs noticeably from the theoretical one means that the grids are still coarse (not in the asymptotic range), the solution is not smooth, or there is a mistake in the calculation, for example in the transmissibilities or the wells.

  5. 5
    Compare the error with the purpose

    We compare the estimated error with the accuracy that the decision needs: with the difference between development options, and with the uncertainty of the input data.

Worked exampleA test problem: convergence in the grid and in the step
Given (assumed data)
Closed strip
length LL = 2000 m; the rock of the lesson Flow regimes, η\eta = 8412 m²/d
Initial disturbance
p−pavg=A0cos⁡(πx/L)p - p_{\text{avg}} = A_0\cos(\pi x/L), A0A_0 = 1 MPa: the left end is 1 MPa above the average, and the right end is below
We compare
the amplitude of the disturbance after 30 d on grids of 4, 8 and 16 cells
Solution
  1. Exact solution: the disturbance keeps its shape and decays at the rate λ=ηπ2/L2=0.020756\lambda = \eta\pi^2/L^2 = 0.020756 d⁻¹. After 30 days the amplitude is e−0.6227=0.53650\e^{-0.6227} = 0.53650 MPa. This is the slowest component of the levelling of pressure in a closed strip: any disturbance in the end decays by this law.
  2. The cell equations with impermeable ends keep the cosine shape exactly, and only the rate of decay changes: λN=(4η/Δx2)sin⁡2(π/(2N))\lambda_N = (4\eta/\Delta x^2)\sin^2(\pi/(2N)) = 0.019711, 0.020491 and 0.020690 d⁻¹ for NN = 4, 8 and 16. The grid error is 5.04, 1.28 and 0.32%. It becomes four times smaller each time the cells are halved.
  3. Implicit scheme, step of 3 d (10 steps): in a step the amplitude is multiplied by 1/(1+3λN)1/(1 + 3\lambda_N), and after 30 days A4A_4 = 0.56298, A8A_8 = 0.55069 and A16A_{16} = 0.54761 MPa.
  4. The changes with refinement are 0.01229 and 0.00308 MPa. The observed order is log⁡2(0.01229/0.00308)=2.0\log_2(0.01229/0.00308) = 2.0, second order, as for the second difference. Extrapolation (a prediction of the value for an infinitely fine grid) for pp = 2: A16+(A16−A8)/3=0.54658A_{16} + (A_{16} - A_8)/3 = 0.54658 MPa.
  5. But the exact amplitude is 0.53650 MPa: the extrapolated value is higher by 0.0101 MPa (1.9%). This is the error of the 3-day step: the grids converge to the solution with this step.
  6. The same three grids with a step of 1.5 d: 0.55836, 0.54582 and 0.54267 MPa; extrapolation 0.54162 MPa. The step error of the implicit scheme is of first order, so from the two steps we get 2⋅0.54162−0.54658=0.536662\cdot0.54162 - 0.54658 = 0.53666 MPa, which differs from the exact value by only 0.00016 MPa.
  7. The Crank–Nicolson scheme with a step of 3 d on the same grids: 0.55349, 0.54068 and 0.53746 MPa; extrapolation 0.53639 MPa, within 0.0001 MPa of the exact value. The error of its step is almost a hundred times smaller.
Answer: Three grids at a step of 3 d show second order and give 0.54658 MPa instead of the exact 0.53650 MPa. The remaining 0.0101 MPa is the step error. Taking the step into account (a second series of calculations with 1.5 d) brings the estimate to within 0.00016 MPa of the exact value.

What it means. A check “in the grid only” would look flawless here: the order is exactly second, the changes fall, and the extrapolation is stable. Yet the answer is wrong by almost 2%, exactly by the step error, which the grid does not see. A real model has no exact solution, so we check the step separately, as in step 6. Problems with a known solution, like this one, serve to check the schemes and the programs themselves. This is called verification, as opposed to the comparison of a model with field data (History matching). The data in this example are assumed for illustration.

Error of the amplitude in the test problem after 30 days against the time step0.313100.0010.010.1110100Time step Δt, dAbsolute error, kPaimplicit, 8 cellsgrid errorimplicit, slope 1Crank–Nicolson, slope 2

A graph on logarithmic axes. The horizontal axis is the time step from 0.3 to 10 days. The vertical axis is the absolute value of the error from 0.001 to 100 kPa. The line of the implicit scheme without the grid error runs from 19.6 kPa at a step of 6 days to 1.3 kPa at 0.375 days, with slope 1. The line of the Crank–Nicolson scheme lies two orders of magnitude lower and is steeper: from 0.43 to 0.0017 kPa, slope 2. The curve of the implicit scheme on a grid of 8 cells starts at 23.5 kPa and flattens out towards the horizontal dashed line at 4.3 kPa, the grid error.

CalculatedThe error of the amplitude in the test problem (after 30 days) against the time step. Without the grid error, the implicit scheme converges with first order (slope 1), and the Crank–Nicolson scheme with second order (slope 2). On a grid of 8 cells, reducing the step runs into the grid error, 4.3 kPa.

Terms and symbols

Finite-difference method
Replacing derivatives by differences of values at grid nodes. It turns a differential equation into a system of algebraic ones, a finite-difference scheme.
Stencil
The set of grid nodes (in space and time) that enter the difference formula of one equation.
Truncation error ψ\psi
The residual that the exact solution gives when it is substituted into the difference equation. Its leading term is proportional to a power of the step.
Order of accuracy
The exponent of the step in the leading term of the error. When the step is halved, the error falls about 2m2^m times.
Stability
The scheme does not amplify errors from step to step. Together with approximation it ensures convergence (the Lax equivalence theorem).
Amplification factor GG
How many times the scheme changes the amplitude of a harmonic over a step. Stability means ∣G∣≤1|G| \le 1 for all harmonics.
Mesh Fourier number rr
ηΔt/Δx2\eta\Delta t/\Delta x^2. The explicit scheme of the pressure equation is stable for r≤1/2r \le 1/2.
Weighted scheme
The right-hand side is a weighted average of the values at the start and at the end of the step, with the weight σ\sigma at the end: 0 is explicit, 1 is implicit, ½ is Crank–Nicolson.
Crank–Nicolson scheme
A scheme with weight ½: second order in time, stable at any step, but with a large step it damps fast components poorly.

Common mistakes and misconceptions

Wrong

“A scheme of second order is always more accurate than a scheme of first order.”

In fact

The order tells how fast the error falls as the step gets smaller. With a large step the Crank–Nicolson scheme gives oscillations after a well is started, which the implicit scheme does not have, and at displacement fronts the order of any scheme falls.

Wrong

“The first tens of steps look reasonable, so the scheme is stable.”

In fact

An unstable harmonic grows out of round-off errors: with a factor of −2.2 it grows three thousand times in 10 steps and tens of billions of times in 30. Meanwhile the smooth part of the solution may be calculated correctly right up to the “explosion”. We check the step against the stability condition.

Wrong

“The result stopped changing when we refined the grid, so it is exact.”

In fact

At a fixed step, the grids converge to the solution with that step. In the test problem of the lesson, the extrapolation over three grids gave second order and was still wrong by 0.010 MPa, which is the error of the 3-day step. We check the step separately.

Wrong

“The iterations converged at all steps, so the model has converged.”

In fact

The convergence of the iterations means that the difference equations are solved. How far these equations are from the differential ones is shown only by refining the grid and the step.

Wrong

“The smaller the step of numerical differentiation, the more accurate the derivative.”

In fact

Only for exact values. When the values have an error ε\varepsilon, an error of the order of ε/Δx\varepsilon/\Delta x is added to the error of the formula, and with a very small step the noise dominates. That is why the derivative of measured pressure is calculated from points spaced apart.

In depth: advanced detail

Derivation of the truncation error of the weighted scheme

We substitute the exact solution into the scheme and expand all the values in a Taylor series around the point (xi, tn+1/2)(x_i,\ t^{n+1/2}), the middle of the step. The difference in time is central with respect to the middle of the step, so (pn+1−pn)/Δt=∂tp+Δt224 ∂t3p+…(p^{n+1} - p^{n})/\Delta t = \partial_t p + \tfrac{\Delta t^2}{24}\,\partial_t^3 p + \ldots At each moment the second difference equals ∂x2p+Δx212 ∂x4p+…\partial_x^2 p + \tfrac{\Delta x^2}{12}\,\partial_x^4 p + \ldots, and the values at the start and at the end of the step differ from the values in the middle by ∓Δt2 ∂t\mp\tfrac{\Delta t}{2}\,\partial_t plus terms of the order of Δt2\Delta t^2.

Expansion of the weighted right-hand side
σ δ2pn+1+(1−σ) δ2pn=∂x2p+(σ−12)Δt ∂t∂x2p+Δx212 ∂x4p+O ⁣(Δt2+Δx2Δt+Δx4)\sigma\,\delta^2 p^{n+1} + (1 - \sigma)\,\delta^2 p^{n} = \partial_x^2 p + \left(\sigma - \tfrac12\right)\Delta t\,\partial_t\partial_x^2 p + \frac{\Delta x^2}{12}\,\partial_x^4 p + O\!\left(\Delta t^2 + \Delta x^2\Delta t + \Delta x^4\right)
where:
  • δ2p\delta^2 pthree-point second difference divided by Δx2\Delta x^2, MPa/m²
  • ∂t, ∂x\partial_t,\ \partial_xpartial derivatives with respect to time and the coordinate in the middle of the step, —

Units: any consistent units

Holds when
  • A smooth solution, constant coefficients, a uniform grid.

We multiply by η\eta and subtract from the difference in time. The exact solution satisfies ∂tp=η ∂x2p\partial_t p = \eta\,\partial_x^2 p, so the leading terms cancel, and η ∂t∂x2p=∂t2p\eta\,\partial_t\partial_x^2 p = \partial_t^2 p. What remains is ψ=(12−σ)Δt ∂t2p−ηΔx212∂x4p\psi = (\tfrac12 - \sigma)\Delta t\,\partial_t^2 p - \tfrac{\eta\Delta x^2}{12}\partial_x^4 p, the formula of the main section.

A non-uniform grid

Let the distances from node ii to its right and left neighbours be h+h_+ and h−h_-. Taylor expansions again give the generalisation of the three-point formula and its error:

The second difference on a non-uniform grid of nodes
2h++h−(pi+1−pih+−pi−pi−1h−)=pi′′+h+−h−3 pi′′′+O(h2)\frac{2}{h_+ + h_-}\left(\frac{p_{i+1} - p_i}{h_+} - \frac{p_i - p_{i-1}}{h_-}\right) = p''_i + \frac{h_+ - h_-}{3}\,p'''_i + O(h^2)
where:
  • h+, h−h_+,\ h_-distances to the right and left neighbouring nodes, m
  • hhcharacteristic step of the grid, m

Units: any consistent units

Holds when
  • A grid of nodes (values at points). For a block-centred grid the analysis is more complicated, but the practical conclusion is the same.
  • A smooth function.

If neighbouring steps differ by a fixed factor, the leading term is proportional to hh and the order falls to first. If the step changes smoothly, h+−h−h_+ - h_- is of the order of h2h^2, and second order is kept. Hence the rule: we change the sizes of neighbouring cells gradually and not abruptly (local grid refinement).

A scheme that converges to the wrong equation

We cannot take approximation for granted. A classic example is the DuFort–Frankel scheme. Take an explicit scheme with a central difference in time over two steps, (pin+1−pin−1)/(2Δt)(p_i^{n+1} - p_i^{n-1})/(2\Delta t). For the pressure equation it is unstable at any step. If in the second difference we replace 2pin2p_i^n by pin+1+pin−1p_i^{n+1} + p_i^{n-1}, the scheme stays explicit and becomes stable at any step. But the Taylor expansion adds to its error a term η (Δt/Δx)2 ∂t2p\eta\,(\Delta t/\Delta x)^2\,\partial_t^2 p. It vanishes only if the time step is reduced faster than the grid step. If we refine them proportionally, Δt/Δx=β\Delta t/\Delta x = \beta, the scheme converges to the solution of a different equation, ∂tp+ηβ2∂t2p=η ∂x2p\partial_t p + \eta\beta^2\partial_t^2 p = \eta\,\partial_x^2 p. This equation has an “inertial” term that does not exist in flow through porous rock. The conclusion: we check approximation for the way of refinement that is really used.

A two-dimensional grid: the five-point stencil and the numbering of cells

In two dimensions the second differences in xx and in yy add up, and the equation of cell (i,j)(i, j) contains the cell itself and its four neighbours that share a face: the five-point stencil. For the explicit scheme the analysis of harmonics gives G=1−4rxsin⁡2(ξ/2)−4rysin⁡2(ζ/2)G = 1 - 4r_x\sin^2(\xi/2) - 4r_y\sin^2(\zeta/2), with phases ξ\xi and ζ\zeta along the two axes. The worst case is the checkerboard harmonic along both axes, from which rx+ry≤12r_x + r_y \le \tfrac12.

To solve the implicit system, the cells are numbered with a single index. With the natural row-by-row numbering, cell (i,j)(i, j) gets the number m=(j−1)Nx+im = (j - 1)N_x + i, where NxN_x is the number of cells along xx. The neighbours in xx have the numbers m±1m \pm 1, and the neighbours in yy have m±Nxm \pm N_x. The matrix of the system has five non-zero diagonals: the main one, the two next to it, and two that are NxN_x places away. The width of this “band” is set by the number of cells in a row. So for direct elimination methods (they solve the system by elimination in a fixed number of operations) it pays to number the cells first along the short side of the model. For a model of 150 × 30 cells the band narrows from 150 to 30, and the amount of work of banded elimination, which is proportional to the square of the band width, falls about 25 times. How such systems with millions of unknowns are solved is in the lesson Solving systems of linear equations in simulators.

Connections to other topics

Check yourself

  1. 1

    A central difference with a step of 40 m is wrong by 0.6%. What error should we expect for a step of 10 m (a smooth function, exact values)?

    1. A.0.6%
    2. B.0.15%
    3. C.0.04%
    4. D.0.01%
    Show the answer

    Correct answer: C. 0.04%

    The central difference is of second order: the error is proportional to the square of the step. The step fell 4 times, so the error fell 16 times: 0.6/16≈0.040.6/16 \approx 0.04%. The option 0.15% would correspond to first order.

  2. 2

    A scheme with weight σ\sigma = 0.25 solves the pressure equation on a grid with cells of 100 m, with a hydraulic diffusivity of 20,000 m²/d. At what largest step is it stable, and how many times larger is this step than that of the explicit scheme?

    Show the answer

    The condition for 0<σ<120 < \sigma < \tfrac12 is r≤1/(2(1−2σ))=1/(2⋅0.5)=1r \le 1/(2(1 - 2\sigma)) = 1/(2\cdot0.5) = 1, that is Δt≤Δx2/η=10,000/20,000=0.5\Delta t \le \Delta x^2/\eta = 10{,}000/20{,}000 = 0.5 d. For the explicit scheme r≤0.5r \le 0.5, so Δt≤0.25\Delta t \le 0.25 d. The limit is twice as large, but the work per step is larger too: we have to solve a system of equations, as in the implicit scheme.

  3. 3

    Which scheme, with a large step after a well is started, gives decaying pressure oscillations in the cells next to the well?

    1. A.Implicit
    2. B.Crank–Nicolson
    3. C.Explicit with r<1/2r < 1/2
    4. D.None: all stable schemes are monotonic
    Show the answer

    Correct answer: B. Crank–Nicolson

    For the Crank–Nicolson scheme the amplification factor of the shortest harmonic, (1−2r)/(1+2r)(1 - 2r)/(1 + 2r), is close to −1 for r≫1r \gg 1: it hardly decays and changes sign at every step. Starting a well creates an abrupt change, rich in short harmonics. For the implicit scheme the factor 1/(1+4r)1/(1 + 4r) is positive and small. The explicit scheme with r<1/2r < 1/2 is not used with a large step. Its new cell pressure is a weighted average of the pressures of the cell itself and its neighbours, with non-negative weights (Pressure equation for single-phase flow), so the pressure changes monotonically.

  4. 4

    The bottomhole pressure was calculated on three grids, each twice as fine as the one before, with the same step of 5 d: 14.62, 14.95 and 15.03 MPa. What is the observed order, what is the extrapolated value, and what else must be checked?

    Show the answer

    The changes are 0.33 and 0.08 MPa, and the order is log⁡2(0.33/0.08)=log⁡24.1≈2.0\log_2(0.33/0.08) = \log_2 4.1 \approx 2.0, as for the second difference. The extrapolation is 15.03+0.08/3≈15.0615.03 + 0.08/3 \approx 15.06 MPa. But this is the value for a step of 5 d: the grids do not see the step error. We need calculations with a step of 2.5 d (and 1.25 d) on one of the grids to estimate it.

  5. 5

    A scheme approximates the linear pressure equation with the error O(Δt+Δx2)O(\Delta t + \Delta x^2) and is stable. What can we say about its solution as the grid and the step get smaller?

    1. A.It converges to the exact one with first order in time and second order in space
    2. B.It converges only for r≤1/2r \le 1/2
    3. C.It converges, but the order cannot be predicted
    4. D.It may not converge: another check is needed
    Show the answer

    Correct answer: A. It converges to the exact one with first order in time and second order in space

    By the Lax equivalence theorem, for a linear problem approximation and stability give convergence. The error of the solution is bounded by the calculation time multiplied by the largest truncation error (up to a constant factor), so it falls with the same orders. The condition r≤1/2r \le 1/2 belongs only to the explicit scheme. Here the question already says that the scheme is stable.

  6. 6

    Why may a convergence study only in the grid, with a fixed time step, be insufficient even if the observed order is “right”?

    Show the answer

    The error is the sum of a spatial part CxΔxpC_x\Delta x^p and a temporal part CtΔtqC_t\Delta t^q. At a fixed step the temporal part is constant. It cancels in the differences of the results on different grids, so the order comes out right, and the extrapolation converges to the solution with this step. In the test problem of the lesson an error of 0.010 MPa remained in this way, almost 2% of the amplitude. We check the step with a separate series of calculations.

Updated: 10 October 2026