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 of each one over a step (the number by which that wave is multiplied in one step). A scheme is stable if for all harmonics. For the explicit scheme of the pressure equation this gives .
- 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.
central difference: second order
three-point second difference: second order
weighted scheme; ; = 0 is explicit, 1 is implicit, ½ is Crank–Nicolson
amplification factor of a harmonic with phase per cell; stability means
error model for a convergence study: and are the orders in space and in time
- 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 be the pressure at the point at the moment . Neighbouring points are a step apart, and neighbouring moments are a step 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.
- storage capacity of the cell, , m³/MPa
- link coefficient of two equal neighbouring cells, m³/(d·MPa)
- hydraulic diffusivity (how fast pressure changes spread through the formation); , m²/d
- pressure in cell at the start and at the end of the step, MPa
- cell size, time step, face area, m, d, m²
Units: metric oilfield units: in mD, in mPa·s, in 1/MPa, in MPa, in d; 0.0853 is the constant of Darcy's law in these units (Rock permeability)
- 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.
- values of the function at node and at the neighbouring nodes, MPa
- first to fourth derivatives with respect to at node , MPa/m, MPa/m², …
- grid step, m
Units: any consistent units
- 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 , and the lower signs are for . The smaller the step, the faster the terms of the series fall, and the smaller the part that we discard.
If we subtract 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.
- terms of order : when the step is halved, they decrease by about times, —
- derivatives at node , MPa/m, MPa/m², …
Units: any consistent units
- 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 .
- Order of accuracy
- The exponent of the step in the leading term of the error: a formula has order if . When the step is halved, the error falls about times.
- Leading term
- The first non-vanishing term of the series in the error, for example for the forward difference. It shows not only the order but also the sign of the error: for the forward difference underestimates the derivative.
- Formula
- forward,
- Nodes
- Leading term of the error
- Order
- 1
- Formula
- backward,
- Nodes
- Leading term of the error
- Order
- 1
- Formula
- central,
- Nodes
- Leading term of the error
- Order
- 2
- Formula
- second difference,
- Nodes
- Leading term of the error
- Order
- 2
| Formula | Nodes | Leading term of the error | Order |
|---|---|---|---|
| forward, | 1 | ||
| backward, | 1 | ||
| central, | 2 | ||
| second difference, | 2 |
A uniform grid and a smooth function. Formulas in time are built in the same way: the difference is a forward difference if we attribute it to the moment , and a central difference if we attribute it to the middle of the step.
- Pressure profile (the well of the lesson Flow regimes)
- ; = 0.388 MPa = 388 kPa; = 0.1 m
- Point and steps
- = 10 m; = 2 m and 1 m
- Exact derivatives
- = 38.8 kPa/m; = −3.88 kPa/m²
- Pressure differences for a step of 2 m: kPa; kPa.
- Forward difference: kPa/m, error kPa/m (−8.8%). Backward: kPa/m, error kPa/m. Central: kPa/m, error kPa/m (+1.37%).
- Step of 1 m: kPa, kPa. Forward: 36.98 kPa/m (error ), backward: 40.88 (error ), central: 38.93 kPa/m (error , 0.34%).
- How many times the errors fell when the step was halved: for the forward difference , first order; for the central difference , second order.
- Leading terms of the Taylor series for a step of 2 m: for the forward difference kPa/m, for the central difference kPa/m (here ). They are close to the actual errors. The remainder comes from the next terms of the series.
- Second derivative from three points: for a step of 2 m kPa/m² (error 2.1%), for a step of 1 m kPa/m² (0.5%). The error also fell about four 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 ). 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 (Diffusivity equation). We replace the second derivative with respect to 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.
- weight of the end of the step: 0 is the explicit scheme, 1 is the implicit scheme, ½ is the Crank–Nicolson scheme, —
- hydraulic diffusivity, , m²/d
- pressure at node (cell) at the start and at the end of the step, MPa
- grid step and time step, m, d
Units: metric oilfield units (any consistent units)
- A linear equation, a uniform formation, a uniform grid. For a heterogeneous formation the same is written for the cell equations with the coefficients and .
- For 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 sets the moment whose pressures give the flows during the step. For 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: the left side of the scheme minus the right side when the exact solution is substituted, MPa/d
- derivatives of the exact solution in the middle of the step, MPa/d², MPa/m⁴
- weight, diffusivity, steps, —, m²/d, d, m
Units: any consistent units
- 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 vanishes only for . 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.
- Scheme
- explicit
- 0
- Order in
- 1
- Order in
- 2
- Stability
- for
- Scheme
- implicit
- 1
- Order in
- 1
- Order in
- 2
- Stability
- for any
- Scheme
- Crank–Nicolson
- ½
- Order in
- 2
- Order in
- 2
- Stability
- for any
| Scheme | Order in | Order in | Stability | |
|---|---|---|---|---|
| explicit | 0 | 1 | 2 | for |
| implicit | 1 | 1 | 2 | for any |
| Crank–Nicolson | ½ | 2 | 2 | for any |
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 tends to zero when the steps and 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, . The exact solution satisfies the scheme with a residual , 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” at every step:
- vectors of the solution error and of the truncation error over all nodes at step , MPa, MPa/d
- operator of the step: what the scheme turns the error at the start of the step into, —
- matrix of second differences multiplied by the diffusivity, 1/d
- identity matrix, —
- 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
- A linear problem. The estimate on the right holds if (the scheme is stable) and , which is the case for the weighted scheme for the pressure equation.
- For an unstable scheme , and the contribution of each step is multiplied by at all the following steps.
In a stable scheme the error after the time 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 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 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 , 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 be , where is the phase shift of the harmonic from one node to the next. For small the harmonic is smooth (a long wave). For 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 (this follows from the formula for the sum of cosines). If we put the harmonic into the weighted scheme, we get:
- how many times the amplitude of the harmonic changes over a step; means that the harmonic changes sign at every step, —
- phase shift of the harmonic per cell, ; the wavelength is , rad
- mesh Fourier number: the time step in units of the time that the pressure needs to level out over one cell, —
- weight of the scheme, —
Units: dimensionless
- 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 and . 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 . A scheme is stable if for all , and it is accurate for the harmonics for which is close to .
- mesh Fourier number , —
- weight of the scheme, —
Units: dimensionless
- They follow from for the shortest, checkerboard harmonic (). The condition always holds.
- In two and three dimensions the explicit scheme needs , the same condition as for a uniform grid in the lesson on the pressure equation.
For the explicit scheme means , the limit from the lesson Pressure equation for single-phase flow. Schemes with 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 . An explicit step multiplies it by , exactly like the drawdown of one tank in the lesson on the simulation model, and it is stable for . The “fastest” tank is the checkerboard harmonic with . From this we get , the same limit that the checkerboard pattern gave in the lesson on the pressure equation.
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.
- Grid and rock (lesson Flow regimes)
- = 250 m; = 8412 m²/d
- Time steps
- 3, 6 and 30 d
- Harmonics
- a smooth one, (a wave of 16 cells = 4 km), and the checkerboard one,
- The numbers : 0.4038, 0.8076 and 4.04. The limit of the explicit scheme is , that is d.
- The smooth harmonic, . Step of 3 d: explicit 0.9385, implicit 0.9421, Crank–Nicolson 0.9404; exactly, . All three are close to the exact value.
- The checkerboard harmonic, . Step of 3 d: explicit , which decays while changing sign; implicit 0.382; Crank–Nicolson 0.106.
- 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 : in 10 steps it grows about 3000 times, and in 30 steps about 2.8·10¹⁰ times.
- 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.
- Step of 30 d, Crank–Nicolson scheme: the smooth one is 0.530, almost exact. The checkerboard one is : 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.
What it means. The factors explain the behaviour of the schemes without a calculation over cells. Instability is for short waves. The lag of the implicit scheme is its 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 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 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:
- storage capacity of the cell and the link coefficients with the neighbours, m³/MPa, m³/(d·MPa)
- withdrawal by a well from the cell at reservoir conditions, m³/d
- pressures at the start and at the end of the step, MPa
Units: metric oilfield units, as in the lesson on the pressure equation
- A linear equation. The withdrawal is constant during the step.
- The system for the pressures at the end of the step is tridiagonal (in one dimension), with the diagonal .
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: for all harmonics.
The weak point is visible in the amplification factor. For and the checkerboard harmonic, . With a large step () 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 (). This property, the strong damping of the fastest components (those that change most quickly from cell to cell), is called L-stability.
- Strip (lesson Pressure equation for single-phase flow)
- = 316.875 m³/MPa; = 68.24, = 27.296, = 28.433 m³/(d·MPa); withdrawal from cell 4 is 130 m³/d at reservoir conditions; initial pressure 20 MPa
- Step
- = 10 d, three times larger than the smallest characteristic time of the cells (3.3 d)
- At the start of the step the pressure is uniform and there are no flows. So for the pressure changes the system is the same as for the implicit scheme, but with half the link coefficients: = 34.120, 13.648 and 14.217. The diagonal is with : 65.8075, 79.4555, 59.5525 and 45.9045. The right-hand side is .
- Forward pass of the Thomas algorithm: ; , .
- , ; .
- Backward pass: ; ; ; MPa.
- 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.
- 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.
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.
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.
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 : 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 . 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:
- result of the calculation (pressure, rate, breakthrough time) and its exact value, in units of the result
- orders in space and in time: for the pressure equation = 2; = 1 for the implicit scheme and 2 for the Crank–Nicolson scheme, —
- coefficients that depend on the solution (its derivatives) and on the scheme, but not on the steps, —
Units: in units of the result
- 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 . If we refine only the step, it tends to . 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 , because the constant part 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 , the implicit scheme finally converges with first order, because the error in time falls more slowly. To keep second order, we need a step (as for the explicit scheme, but now for accuracy and not for stability) or a scheme of second order in time.
- 1Choose 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.
- 2Check the time step
On the working grid, run calculations with steps , and . 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 is about equal to the difference between its result and the result with step .
- 3Check 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.
- 4Compare 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.
- 5Compare 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.
- Closed strip
- length = 2000 m; the rock of the lesson Flow regimes, = 8412 m²/d
- Initial disturbance
- , = 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
- Exact solution: the disturbance keeps its shape and decays at the rate d⁻¹. After 30 days the amplitude is MPa. This is the slowest component of the levelling of pressure in a closed strip: any disturbance in the end decays by this law.
- The cell equations with impermeable ends keep the cosine shape exactly, and only the rate of decay changes: = 0.019711, 0.020491 and 0.020690 d⁻¹ for = 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.
- Implicit scheme, step of 3 d (10 steps): in a step the amplitude is multiplied by , and after 30 days = 0.56298, = 0.55069 and = 0.54761 MPa.
- The changes with refinement are 0.01229 and 0.00308 MPa. The observed order is , second order, as for the second difference. Extrapolation (a prediction of the value for an infinitely fine grid) for = 2: MPa.
- 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.
- 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 MPa, which differs from the exact value by only 0.00016 MPa.
- 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.
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.
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.
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
- 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 times.
- Stability
- The scheme does not amplify errors from step to step. Together with approximation it ensures convergence (the Lax equivalence theorem).
- Amplification factor
- How many times the scheme changes the amplitude of a harmonic over a step. Stability means for all harmonics.
- Mesh Fourier number
- . The explicit scheme of the pressure equation is stable for .
- 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 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
“A scheme of second order is always more accurate than a scheme of first order.”
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.
“The first tens of steps look reasonable, so the scheme is stable.”
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.
“The result stopped changing when we refined the grid, so it is exact.”
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.
“The iterations converged at all steps, so the model has converged.”
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.
“The smaller the step of numerical differentiation, the more accurate the derivative.”
Only for exact values. When the values have an error , an error of the order of 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 , the middle of the step. The difference in time is central with respect to the middle of the step, so At each moment the second difference equals , and the values at the start and at the end of the step differ from the values in the middle by plus terms of the order of .
- three-point second difference divided by , MPa/m²
- partial derivatives with respect to time and the coordinate in the middle of the step, —
Units: any consistent units
- A smooth solution, constant coefficients, a uniform grid.
We multiply by and subtract from the difference in time. The exact solution satisfies , so the leading terms cancel, and . What remains is , the formula of the main section.
A non-uniform grid
Let the distances from node to its right and left neighbours be and . Taylor expansions again give the generalisation of the three-point formula and its error:
- distances to the right and left neighbouring nodes, m
- characteristic step of the grid, m
Units: any consistent units
- 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 and the order falls to first. If the step changes smoothly, is of the order of , 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, . For the pressure equation it is unstable at any step. If in the second difference we replace by , the scheme stays explicit and becomes stable at any step. But the Taylor expansion adds to its error a term . It vanishes only if the time step is reduced faster than the grid step. If we refine them proportionally, , the scheme converges to the solution of a different equation, . 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 and in add up, and the equation of cell 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 , with phases and along the two axes. The worst case is the checkerboard harmonic along both axes, from which .
To solve the implicit system, the cells are numbered with a single index. With the natural row-by-row numbering, cell gets the number , where is the number of cells along . The neighbours in have the numbers , and the neighbours in have . The matrix of the system has five non-zero diagonals: the main one, the two next to it, and two that are 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
- Pressure equation for single-phase flow — the cell equations, the explicit and implicit schemes, the largest step and the Thomas algorithm.
- What a reservoir simulation model is and why it is needed — the explicit and implicit step for one “tank”, the simplest case of the analysis of harmonics.
- Grids in reservoir simulation models — the check of convergence in the grid and the extrapolation to an infinitely fine grid; numerical diffusion of the upstream scheme.
- Diffusivity equation — the diffusivity equation as the model equation for finite-difference schemes.
- Two-phase flow equations — the pressure and saturation equations to which the same schemes are applied.
- IMPES and fully implicit schemes — schemes for multiphase nonlinear equations, Newton iterations and the choice of the step.
- Solving systems of linear equations in simulators — how the sparse systems that implicit schemes give are solved.
- Numerical dispersion — the error of schemes for the transport of saturation, and the smearing of fronts.
- Diagnosis with the pressure derivative — numerical differentiation of noisy measurements.
Check yourself
- 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)?
- A.0.6%
- B.0.15%
- C.0.04%
- 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: %. The option 0.15% would correspond to first order.
- 2
A scheme with weight = 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 is , that is d. For the explicit scheme , so 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
Which scheme, with a large step after a well is started, gives decaying pressure oscillations in the cells next to the well?
- A.Implicit
- B.Crank–Nicolson
- C.Explicit with
- 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, , is close to −1 for : 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 is positive and small. The explicit scheme with 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
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 , as for the second difference. The extrapolation is 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
A scheme approximates the linear pressure equation with the error and is stable. What can we say about its solution as the grid and the step get smaller?
- A.It converges to the exact one with first order in time and second order in space
- B.It converges only for
- C.It converges, but the order cannot be predicted
- 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 belongs only to the explicit scheme. Here the question already says that the scheme is stable.
- 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 and a temporal part . 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