Construction of High-Order Adaptive Implicit …...CONSTRUCTION OF HIGH-ORDER ADAPTIVE IMPLICIT...
Transcript of Construction of High-Order Adaptive Implicit …...CONSTRUCTION OF HIGH-ORDER ADAPTIVE IMPLICIT...
CONSTRUCTION OF HIGH-ORDER ADAPTIVE
IMPLICIT METHODS FOR RESERVOIR
SIMULATION
A REPORT
SUBMITTED TO THE DEPARTMENT OF
ENERGY RESOURCES ENGINEERING
OF STANFORD UNIVERSITY
IN PARTIAL FULFILLMENT OF THE REQUIREMENTS
FOR THE DEGREE OF MASTER OF SCIENCE
By
Romain de Loubens
June 2007
I certify that I have read this report and that in my
opinion it is fully adequate, in scope and in quality, as
partial fulfillment of the degree of Master of Science in
Petroleum Engineering.
Hamdi Tchelepi(Principal advisor)
ii
Abstract
The objective of this work is to construct high-order extensions of the Adaptive Implicit
Method (AIM) for Reservoir Simulation. The numerical methods under investigation are
mainly applied to the transport equation describing the flow of one or two phases in a
porous medium. The Method of Lines (MOL) offers a flexible and computationally efficient
framework for general convection-diffusion problems. The convective term can be treated
by high-resolution shock-capturing schemes, that are widely used today for the simulation
of hyperbolic systems. Moreover, high-order time integration is typically carried out by one-
step Runge-Kutta or Linear Multistep methods. A prototype program was developed to test
various combinations of space-time discretizations formulated as MOL schemes. Numerical
experiments in one dimension show a substantial reduction of the numerical dispersion in
comparison with first-order methods. These high-resolution MOL schemes constitute the
basic framework for the derivation of high-order AIM. A detailed analysis of the standard
AIM scheme reveals an inconsistency at the transition between implicit and explicit regions.
The discretization errors are usually comparable to the numerical dispersion. As a result,
small “kinks” can be observed in the solution profile. But in most situations, the standard
AIM scheme is convergent, and it satisfies strong monotonicity properties. In the context
of high-order AIM, it is important to combine implicit and explicit time integration in a
consistent manner. We propose a consistency fix that preserves the accuracy at the I-
E boundaries, and allows us to construct fully high-order AIM. However, the positivity
restriction in the implicit regions can be quite severe, even if the implicit time integration
is unconditionally stable. This difficulty is overcome by applying artificial viscosity in the
implicit regions, which eliminates spurious oscillations and allows for larger time steps.
iii
Acknowledgements
I would like to express my gratitude to my research and academic advisor Dr. Hamdi
Tchelepi. His encouragement, intelligence and guidance were deeply appreciated throughout
the course of this research. My appreciation also goes to Dr. Amir Riaz for his valuable
advice and friendly support.
This work was prepared with the support of the Stanford University Petroleum Research
Institute programs on Reservoir Simulation & Advanced Wells (SUPRI-B & SUPRI-HW).
This research was also supported by the Global Climate and Energy Project (GCEP) at
Stanford University. Both of these contributions are gratefully acknowledged.
Finally I would like to thank all of my colleagues and friends for their help and support within
and outside my academic life. Very special thanks also go to my family who continuously
supported me from France.
iv
Contents
Abstract iii
Acknowledgements iv
Table of Contents v
List of Figures viii
1 Introduction 1
2 High-order spatial discretizations 3
2.1 Mathematical model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Flux limiting schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 ENO and WENO schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Central Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Other discretizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3 Method of Lines and time integration 12
3.1 MOL framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 One-step methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 Linear Multistep methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.4 Positivity property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.5 Other time integration methods . . . . . . . . . . . . . . . . . . . . . . . . . 22
4 Numerical analysis of standard AIM 24
4.1 Local inconsistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2 Linear error analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
v
4.3 Monotonicity properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.3.1 Positivity and the maximum principle . . . . . . . . . . . . . . . . . . 34
4.3.2 TVD property in the linear homogeneous case . . . . . . . . . . . . . 37
4.3.3 TVD property in the quasi-linear homogeneous case . . . . . . . . . . 41
4.3.4 TVD property in the heterogeneous case . . . . . . . . . . . . . . . . 47
4.4 Consistency fix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5 Construction of high-order AIM 52
5.1 Requirements and methodology . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.2 AIM with high-order spatial accuracy . . . . . . . . . . . . . . . . . . . . . . 54
5.2.1 Numerical formulation . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.2.2 Numerical tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.3 Fully high-order AIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.3.1 Numerical formulation . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.3.2 Numerical tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.4 High-order AIM with artificial viscosity . . . . . . . . . . . . . . . . . . . . . 71
6 Conclusions 74
List of acronyms 76
Bibliography 77
A Validation of high-order MOL schemes 80
A.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
A.2 Code description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
A.2.1 Main routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
A.2.2 Routine CalcSw MOC . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
A.2.3 Routine CalcSw MOL . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
A.2.4 Routine CalcFlux . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
A.3 Numerical tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
A.3.1 eCRK2-CS2 scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
A.3.2 BE-FL2 scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
A.3.3 TRK2-ENO2 scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
A.3.4 BDF2-WENO2 scheme . . . . . . . . . . . . . . . . . . . . . . . . . . 88
vi
A.3.5 DIRK3-ENO3 scheme . . . . . . . . . . . . . . . . . . . . . . . . . . 89
A.3.6 IRK2-WENO2 scheme . . . . . . . . . . . . . . . . . . . . . . . . . . 90
A.3.7 Concluding remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
B Linear stability of the BDF2 scheme 94
C Matlab code for 1D numerical tests 97
C.1 Main routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
C.2 MOC routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
C.3 MOL routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
C.4 Numerical flux routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
C.5 AIM-STD routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
C.6 AIM-BE routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
C.7 AIM-BE/TRK2 routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
C.8 AIM-TRK2 routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
C.9 AIM-CRK2 routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
C.10 AIM-IRK2 routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
C.11 AIM-DIRK3 routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
D Matlab code for 2D numerical tests 127
D.1 Main routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
D.2 Residual-Jacobian routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
D.3 Fractional flow routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
vii
List of Figures
3.1 Linear advection test with the TRK2 method . . . . . . . . . . . . . . . . . 20
3.2 Linear advection test with the IRK2 method . . . . . . . . . . . . . . . . . . 20
3.3 Linear advection test with the DIRK3 method . . . . . . . . . . . . . . . . . 21
3.4 Linear advection test with the BDF2 method . . . . . . . . . . . . . . . . . . 21
4.1 Schematic of an implicit-explicit (I-E) boundary . . . . . . . . . . . . . . . . 25
4.2 Propagation of a discretization error at an I-E boundary . . . . . . . . . . . 30
4.3 Refining study in the case of a fixed I-E boundary . . . . . . . . . . . . . . . 32
4.4 Solution and error profiles for a fixed I-E boundary . . . . . . . . . . . . . . 33
4.5 Solution profiles for a moving I-E boundary . . . . . . . . . . . . . . . . . . 34
4.6 Test of AIM-STD in the linear case (contact discontinuity) . . . . . . . . . . 40
4.7 Test of AIM-STD in the linear case (sine wave) . . . . . . . . . . . . . . . . 41
4.8 Test of AIM-STD in the quasi-linear homogeneous case . . . . . . . . . . . . 44
4.9 Test of AIM-STD in the quasi-linear heterogeneous case . . . . . . . . . . . . 48
5.1 Test of the AIM-STD-FL2 scheme . . . . . . . . . . . . . . . . . . . . . . . . 56
5.2 Test of the AIM-BE-FL2 scheme . . . . . . . . . . . . . . . . . . . . . . . . 57
5.3 Test of the AIM-BE/TRK2-FL2 scheme . . . . . . . . . . . . . . . . . . . . 58
5.4 Test of the AIM-CRK2-WENO2 scheme . . . . . . . . . . . . . . . . . . . . 62
5.5 Reference solution in a quarter five-spot . . . . . . . . . . . . . . . . . . . . 64
5.6 Miscible flow solution using the BE-UW1 scheme . . . . . . . . . . . . . . . 67
5.7 Miscible flow solution using the AIM-TRK2-WENO2 scheme . . . . . . . . . 68
5.8 Fractional flow curves and reference solution . . . . . . . . . . . . . . . . . . 70
5.9 Immiscible flow solution using the AIM-TRK2-WENO2 scheme . . . . . . . 71
5.10 Test of the TRK2-WENO2 scheme with artificial viscosity . . . . . . . . . . 73
viii
A.1 Test results with the eCRK2-CS2 scheme . . . . . . . . . . . . . . . . . . . . 86
A.2 Test results with the BE-FL2 scheme . . . . . . . . . . . . . . . . . . . . . . 87
A.3 Test results with the TRK2-ENO2 scheme . . . . . . . . . . . . . . . . . . . 88
A.4 Test results with the BDF2-WENO2 scheme . . . . . . . . . . . . . . . . . . 89
A.5 Test results with the DIRK3-ENO3 scheme . . . . . . . . . . . . . . . . . . . 90
A.6 Test results with the IRK2-WENO2 scheme . . . . . . . . . . . . . . . . . . 91
B.1 Modulus of λ+ (left) and λ− (right) . . . . . . . . . . . . . . . . . . . . . . . 96
ix
Chapter 1
Introduction
The success of the Adaptive Implicit Method (AIM) in Reservoir Simulation is mostly due to
its increased efficiency compared to the Implicit Pressure and Explicit Saturation (IMPES) or
the Fully Implicit (FIM) formulations. The basic idea of an AIM formulation is to treat some
of the unknowns implicitly and the other ones explicitly. The choice of the implicit variables
is usually based on linearized stability criteria (see [8] and [26]). Sometimes the user can also
specify the percentage of blocks that should be treated implicitly, which gives control over
the computational cost of the simulation. In practice, AIM has been successfully applied to a
wide range of problems, ranging from simple Black-Oil models to complex compositional flow
problems (see [6], [28] and [31]). In most cases, AIM appears to be much more efficient than
IMPES or FIM (see [29]). Indeed, the time step restriction of an IMPES formulation can
be very severe for instance in the near-wellbore region, where the grid is usually refined and
the velocity is high. But in the case of AIM, the near-wellbore grid blocks are automatically
treated implicitly, and thus the time step size can be much larger. On the other hand,
the computational cost of FIM may be very high for large scale compositional simulations,
which require the inversion of large systems of equations. For these large scale problems, the
computational effort in AIM is often reduced substantially because only the blocks where
the stability condition is violated are solved implicitly.
However, the standard AIM discretization is only first-order accurate. Therefore we propose
to investigate high-order extensions of this method, aiming to increase the resolution and
lower the computational cost. High-order methods are of particular interest to simulate
complex flow patterns, such as viscous fingering and density driven instabilities, which may
occur for instance during the injection of supercritical CO2 in a deep saline aquifer. Moreover,
1
2 CHAPTER 1. INTRODUCTION
high-order methods are generally more efficient than first-order methods because a coarser
grid can be used for the same level of accuracy.
High-resolution Method of Lines (MOL) schemes are constructed from highly accurate spa-
tial and temporal discretizations. In Chapter 2, we present high-order numerical fluxes,
including flux limiting, ENO and Central schemes. In Chapter 3, we introduce high-order
time integration methods, such as Runge-Kutta and Linear Multistep methods. These highly
accurate space and time discretizations lead to high-resolution MOL schemes, which serve
as a framework for high-order AIM.
A detailed numerical analysis of standard AIM is given in Chapter 4. Our analysis reveals
an inconsistency at the implicit-explicit boundaries. The propagation of these discretization
errors is studied through a linear error analysis. We also prove several important results
regarding the monotonicity properties of standard AIM. These results are confirmed by nu-
merical experiments. Chapter 4 concludes with a consistency fix that preserves the accuracy
at the I-E boundaries.
In Chapter 5, we propose a methodology to construct AIM formulations based on highly
accurate MOL schemes. Fully high-order AIM schemes are derived, and numerical results are
provided for one-dimensional and two-dimensional problems of interest. Finally, we present
an artificial viscosity approach to eliminate the spurious oscillations due to the violation of
the monotonicity restriction in the implicit regions. Our conclusions are given in Chapter 6.
Chapter 2
High-order spatial discretizations
2.1 Mathematical model
We are interested in solving the following nonlinear convection-diffusion equation describing
the transport of an incompressible fluid (e.g., water) in a porous medium:
∂(φSw)
∂t+ ∇ · (fwut) = ∇ · (hw∇Sw) , (2.1)
where Sw is the water saturation, ut the total velocity, fw the fractional flow of water (which
may include gravity effects), and hw a diffusivity coefficient that accounts for capillary effects.
In general, both fw and hw are strongly nonlinear functions of Sw.
When viscous forces dominate, capillary effects can be neglected, which is mostly valid at the
field scale. However, at smaller scales these effects need to be modelled in order to capture
the correct shape of the saturation front. In this case, the diffusive term can be discretized
with central differences (of order two or higher if necessary). Implicit treatment is often
required because explicit discretizations lead to a severe time step restriction of the form
∆t ≤ α∆x2, where α is a physical parameter and ∆x the smallest grid size.
The nonlinear convective term requires a more sophisticated treatment because the local
direction of propagation must be taken into account, and the nonlinearity may cause discon-
tinuities to appear in the solution profile even for a smooth initial condition. A great deal of
effort has been devoted through the last two decades to the development of high-resolution
shock-capturing schemes for hyperbolic conservation laws. In the following sections, three
important types of flux discretizations are introduced, namely the flux limiting, ENO and
3
4 CHAPTER 2. HIGH-ORDER SPATIAL DISCRETIZATIONS
Central schemes. These numerical schemes are of special interest to us because of their semi-
discrete conservative forms, non-oscillatory properties and computational efficiency. For the
presentation of these schemes, we will consider the one-dimensional version of (2.1) in the
homogeneous case without diffusion, which we write in dimensionless form as
∂s
∂t+
∂f(s)
∂x= 0 , (2.2)
where s is the conserved quantity and f the flux function. As we will see in the next
chapter, within the MOL framework, multidimensional extensions of those algorithms are
straightforward.
2.2 Flux limiting schemes
Flux limiting methods were developed in the context of Total Variation Diminishing (TVD)
schemes. The total variation of a numerical approximation s = (si)i∈Z is defined as
TV(s) =∑
i∈Z
|si+1 − si| , (2.3)
and a numerical scheme is said to be TVD if
TV(sn+1) ≤ TV(sn) . (2.4)
A wide class of high-order TVD schemes are derived from the “modified flux” and “flux
limiting” methods (see [7]). The basic idea of the modified flux approach is to apply a first-
order scheme to the modified equation of order two associated with this scheme, but with a
viscous term of opposite sign (i.e., with an anti-diffusive term). Meanwhile, the flux limiting
approach consists in adding a nonlinear antidiffusion term to a first-order numerical flux,
or equivalently, a diffusive term to the second-order Lax-Wendroff scheme. To illustrate the
idea of flux limiters let us consider the linear advection equation, assuming that the flow is
left to right:
∂s
∂t+
∂s
∂x= 0 . (2.5)
Applying the first-order Upwind scheme we obtain
2.2. FLUX LIMITING SCHEMES 5
sn+1i = sn
i − ν ∆sni− 1
2
, (2.6)
while the Lax-Wendroff scheme yields
sn+1i = sn
i − ν
2
(
∆sni− 1
2
+ ∆sni+ 1
2
)
+ν2
2(∆sn
i+ 1
2
− ∆sni− 1
2
) . (2.7)
In the above equations, ν is the Courant number given by ν = ∆t/∆x, and the operator ∆
is defined by ∆si+ 1
2
= si+1 − si (hence, ∆si− 1
2
= si − si−1). Rewriting (2.7) as
sn+1i = sn
i − ν ∆sni− 1
2
− 1
2ν (1 − ν) (∆sn
i+ 1
2
− ∆sni− 1
2
) , (2.8)
we observe that the Lax-Wendroff scheme amounts to adding an antidiffusion term to the
Upwind scheme. This term makes the Lax-Wendroff scheme second-order accurate but it
is also known to create spurious oscillations in the presence of sharp gradients. In order to
obtain a second-order TVD scheme, one can impose a “limiter” to this antidiffusion term.
This procedure should be applied mostly in the regions of steep concavity change, i.e., where
the value of the second derivative is large. Hence the flux limiter is a function of the ratio
of two consecutive gradients. Applying this idea to (2.8) leads to
sn+1i = sn
i − ν ∆sni− 1
2
− 1
2ν (1 − ν) (φn
i+ 1
2
∆sni+ 1
2
− φni− 1
2
∆sni− 1
2
) , (2.9)
where φ is the flux limiter function, i.e.,
φni+ 1
2
= φ(rni+ 1
2
), rni+ 1
2
= ∆sni− 1
2
/∆sni+ 1
2
. (2.10)
One can show that under the following conditions on the limiter function:
φ(r) = 0 if r ≤ 0 ,
0 ≤ φ(r) ≤ min(2, 2r) if r > 0 ,
φ(1) = 1 ,
(2.11)
the scheme (2.9) is TVD. Common examples of flux limiters are given in [7], for instance:
- φ(r) = max{0, min(r, 1)} (Minmod)
- φ(r) = max{0, min(2r, 1), min(2r, 1)} (Superbee)
- φ(r) = max{0, min(1
2(1 + r), 2r, 2)} (Monotonized Center)
6 CHAPTER 2. HIGH-ORDER SPATIAL DISCRETIZATIONS
- φ(r) =r + |r|1 + r
(Van Leer) .
An important drawback of these TVD schemes is that they become first-order accurate near
nonsonic extrema, i.e., where ∆si− 1
2
∆si+ 1
2
< 0 and f ′(si) 6= 0. In addition, these TVD
schemes are formulated as direct space-time discretizations (DST schemes). Hence highly
accurate time integration is achieved by replacing the high-order time derivatives with high-
order spatial derivatives. But this procedure depends on the particular form of the PDE and
can become very complex for multidimensional problems. Moreover the notion of a TVD
scheme is only well-defined in one dimension.
Flux limiting schemes can also be formulated in a semi-discrete conservative form. For
example, the flux limiting discretization based on the midpoint flux leads to
d
dtsi(t) = −
Fi+ 1
2
(t) − Fi− 1
2
(t)
∆x, (2.12)
where Fi+ 1
2
is the numerical flux defined by
Fi+ 1
2
(t) = f(si(t)) +1
2φi+ 1
2
(t) [f(si+1(t)) − f(si(t))] . (2.13)
Here the flux limiter φ depends on the ratio of successive flux differences:
φi+ 1
2
= φ(ri+ 1
2
), ri+ 1
2
= ∆fi− 1
2
/∆fi+ 1
2
. (2.14)
In smooth regions this flux approximation becomes equivalent to the midpoint or two-point
upstream weighting scheme, hence it is second-order accurate.
2.3 ENO and WENO schemes
Essentially non-oscillatory (ENO) schemes are high-order shock-capturing schemes for sys-
tems of conservation laws. They belong to the class of semi-discrete conservative schemes
described by (2.12). In their original form, ENO schemes were based on the cell averages
(see [5]), but more recently a flux based approach was developed (see [27]). The flux ap-
proach has become more popular because it is computationally more efficient, especially for
multidimensional problems. ENO schemes usually employ an adaptive upwind-biased stencil
to construct a polynomial approximation of the local flux function. The derivation of these
schemes is based on the existence of a primitive function h implicitly defined by
2.3. ENO AND WENO SCHEMES 7
f(u(x)) =1
∆x
∫ x+∆x/2
x−∆x/2
h(ξ) dξ . (2.15)
By differentiation of (2.15) we have
f(u(x))x =h(x + ∆x/2) − h(x − ∆x/2)
∆x, (2.16)
so the numerical flux can be obtained from a polynomial reconstruction of h evaluated at
x = xi+ 1
2
. In fact, a non-oscillatory polynomial interpolant is calculated for a primitive H
of h. The polynomial is constructed from the table of divided differences of H which is
initialized by (2.15):
H(xi+1/2) − H(xi−1/2)
∆x= f(ui) . (2.17)
The details of the algorithm can be found in [23]. Once the r-th order polynomial interpo-
lation Qr is constructed, the numerical flux is given by
fi+1/2 =dQr
dx
∣
∣
∣
x=xi+1/2
. (2.18)
This algorithm is called the ENO-Roe scheme. It is r-th order accurate, except near sonic
points where the sign of f ′(s) changes. In fact, the ENO-Roe scheme can lead to entropy
violating solutions, e.g., stationary expansion waves with a jump discontinuity. This problem
can be avoided by applying the so-called entropy fix, which amounts to a local splitting of
the flux function:
f±(s) =1
2(f(s) ± αi+ 1
2
s) , αi+ 1
2
= maxsi≤s≤si+1
|f ′(s)| . (2.19)
Note that this splitting of f ensures that df+/ds > 0 and df−/ds < 0.
Below we give the tables of coefficients for the calculation of fi+1/2 based on different stencils.
For r = 2 the index k refers to the 2-point stencil Sk = (xi+k−1, xi+k), while for r = 3, it refers
to the 3-point stencil Sk = (xi+k−2, xi+k−1, xi+k). Note that the formulas are symmetric with
respect to xi+1/2 and also that the sum of each row is equal to 1.
8 CHAPTER 2. HIGH-ORDER SPATIAL DISCRETIZATIONS
k fi−1 fi fi+1 fi+2
0 -1/2 3/2 0 0
1 0 1/2 1/2 0
2 0 0 3/2 -1/2
k fi−2 fi−1 fi fi+1 fi+2 fi+3
0 1/3 -7/6 11/6 0 0 0
1 0 -1/6 5/6 1/3 0 0
2 0 0 1/3 5/6 -1/6 0
3 0 0 0 11/6 -7/6 1/3
Table 2.1: Stencil weights for the 2nd-order (r = 2) and 3rd-order (r = 3) ENO schemes. For
r = 2, the integer k corresponds to the stencil Sk = (xi+k−1, xi+k), while for r = 3, it corresponds
to Sk = (xi+k−2, xi+k−1, xi+k) .
The idea of weighted ENO schemes (WENO) is to compute the numerical flux as a linear
combination of each local stencil, rather than using the smoothest stencil only. The weights of
each stencil are calculated from a smoothness indicator, so that the contribution of a smooth
stencil is higher than that of a stencil in a steep region of the solution. Additional restrictions
are imposed in order to obtain the optimal accuracy in smooth regions. The smoothness
indicators are defined to preserve the non-oscillatory property near discontinuities or sharp
gradients. In particular, the weight assigned to a nonsmooth stencil should be close to zero.
One possibility is to define the smoothness indicator ISk of a given stencil Sk using the L2-
norm of the derivatives of the local polynomial reconstruction (see [13] for more details). In
general the weight of Sk is given by
ωk =αk
α0 + · · · + αr−1
, αk =Cr
k
(ǫ + ISk)p, (2.20)
where Crk is the optimal weight associated with Sk, ǫ is a small parameter to prevent any
division by zero, and p a tuning parameter (generally taken equal to 2).
For example, the second-order WENO flux written for f ′ > 0 reads
fi+ 1
2
= (ω0)i+ 1
2
[
−1
2fi−1 +
3
2fi
]
+ (ω1)i+ 1
2
[
1
2fi +
1
2fi+1
]
, (2.21)
where (ω0)i+ 1
2
, (ω1)i+ 1
2
are the weights associated with the stencils (i − 1, i) and (i, i + 1)
respectively. These weights are computed according to (2.20) with the following smoothness
indicators:
(IS0)i+ 1
2
= (fi − fi−1)2 , (IS1)i+ 1
2
= (fi+1 − fi)2 . (2.22)
2.4. CENTRAL SCHEMES 9
The first advantage of the WENO approach is a higher accuracy in the smooth regions.
Indeed, for the same degree r of the polynomial reconstruction, the basic ENO-Roe scheme
is of order r, whereas the WENO scheme is of order 2r− 1 (note that 2r− 1 points are used
in the numerical flux calculation instead of r). In addition, WENO schemes are more robust
than ENO schemes since the risk of choosing the wrong stencil due to rounding errors is
eliminated. Finally, the computational cost of WENO schemes can be significantly reduced
on vectorial computers. Indeed, as opposed to ENO schemes, WENO schemes do not require
the use of logical statements.
2.4 Central Schemes
High-order central schemes can be seen as natural extensions of the first-order Lax-Friedrichs
scheme given by
sn+1i =
1
2(sn
i+1 + sni−1) −
∆t
2∆x
(
f(sni+1) − f(sn
i−1))
. (2.23)
This scheme simply uses central differences, therefore it is very efficient. However, it suffers
from excessive numerical dissipation. In order to achieve higher levels of accuracy, central
schemes use high-order piecewise polynomial reconstructions based on the cell averages,
which are evolved exactly in time and projected back onto the grid. The non-oscillatory
behavior results from the use of nonlinear slope limiters.
To illustrate the derivation of central schemes, we present the second-order central scheme
originally developed by Nessyahu and Tadmor (called the NT scheme, see [16]). First the
piecewise linear reconstruction of the numerical solution at t = tn is given by
s(x, tn) =∑
i
[sni + (sx)
ni (x − xi)] χi(x) , (2.24)
where sni is the cell average on the interval Ki = [xi−1/2, xi+1/2], χi(x) is the characteristic
function of Ki and (sx)ni is a reconstructed slope. The latter is based on the adjacent cell
averages, for instance
(sx)i = MM
(
θsn
i+1 − sni
∆x,sn
i+1 − sni−1
2∆x, θ
sni − sn
i−1
∆x
)
, (2.25)
where θ is a parameter and MM is the Min-Mod function:
10 CHAPTER 2. HIGH-ORDER SPATIAL DISCRETIZATIONS
MM(x1, . . . , xn) =
mini(xi) if xi > 0,∀i
maxi(xi) if xi < 0,∀i
0 otherwise.
(2.26)
From the integral formulation of (2.2) on Ki+ 1
2
× [tn, tn+1], we have
sn+1i+ 1
2
=1
∆x
∫
Ki+1
2
s(x, tn) dx − 1
∆x
∫ tn+1
tn[f(s(xi+1, t)) − f(s(xi, t))] dt . (2.27)
Using the midpoint rule for the flux integrals, we get
sn+1i+1/2 =
1
2(sn
i + sni+1) +
∆x
8
(
(sx)ni − (sx)
ni+1
)
− ∆t
∆x
(
f(sn+ 1
2
i+1 ) − f(sn+ 1
2
i ))
, (2.28)
where the mid-values sn+ 1
2
i are provided by the predictor step
sn+ 1
2
i = sni − ∆t
2(fx)
ni . (2.29)
Here (fx)ni is a reconstructed slope computed like (sx)
ni . Note that the average is obtained
on a staggered grid, and also that the cell averages and pointwise values can be identified
because this scheme is of order 2.
The NT scheme was improved by Kurganov and Tadmor [17] by using the local speed of
propagation to compute the cell averages on variable size intervals. They also proposed a
semi-discrete version derived by taking the limit when ∆t → 0 of their fully discrete scheme.
This leads to the conservative form (2.12) where
Fi+ 1
2
(t) =1
2
[
f(s+i+ 1
2
(t)) + f(s−i+ 1
2
(t))]
−ai+ 1
2
(t)
2
[
s+i+ 1
2
(t) − s−i+ 1
2
(t)]
, (2.30)
and
s+i+ 1
2
(t) = si+1(t) −∆x
2(sx)i+1(t), s−
i+ 1
2
(t) = si(t) +∆x
2(sx)i(t) . (2.31)
The main advantage of Central schemes over high-order Upwind schemes (such as ENO
or WENO) is their simplicity and computational efficiency. Although not presented here,
higher order Central schemes are available, including in multi-dimensions (see [14] and [15]).
2.5. OTHER DISCRETIZATIONS 11
2.5 Other discretizations
A number of other spatial discretizations can be found in the literature of hyperbolic systems.
For instance, we refer to the family of Godunov schemes, compact WENO schemes (see for
example [18]) and spectral methods. But in general these numerical schemes do not have a
conservative semi-discrete form, hence they are not adequate for the purpose of this study.
The next chapter presents high-order time integration methods that can be applied in a
Method of Lines (MOL) framework. Using a highly accurate time integration is just as
important as using a high-resolution numerical flux in order to obtain a fully high-order
method. In addition, the time integration is critical in Reservoir Simulation practice, because
we need implicit methods that are highly stable and robust even for very large time steps.
Chapter 3
Method of Lines and time integration
3.1 MOL framework
The idea of the Method of Lines is to transform the PDE (2.1) into a system of first-order
ODE’s. The general formulation can be written as
ds
dt(t) = L(t, s(t)) , (3.1)
where s is the vector of unknowns at each grid block center and L represents the discretized
spatial operator. To keep the presentation simple, we will ignore the explicit time dependence
of this operator, although it may appear for instance when dealing with source terms. In
the previous chapter, we introduced the notion of a conservative semi-discrete scheme for
the one-dimensional transport equation (see (2.12)). This semi-discrete form corresponds to
the MOL formulation (3.1) where the operator L is given componentwise by
Li(s) = − 1
∆x(Fi+ 1
2
(s) − Fi− 1
2
(s)) . (3.2)
Here the numerical flux Fi+ 1
2
is defined for instance by a flux limiting, ENO or Central
discretization. As opposed to DST schemes, MOL schemes are easy to extend to general
convection-diffusion-reaction equations and to multidimensional problems. Moreover, high-
order time accuracy is achieved independently of the discrete spatial operator, and one can
take advantage of the most efficient ODE solvers for various physical problems. In the
example below, we illustrate the MOL treatment of the convection-diffusion equation (2.1)
in two dimensions on a uniform cartesian grid. Using a ENO discretization for the convective
12
3.2. ONE-STEP METHODS 13
term and central differences for the diffusive term we obtain
φi,jdsi,j
dt(t) = Li,j(s(t)) , (3.3)
where
Li,j(s) = − 1
∆x
[
fxi+ 1
2,j(s) − fx
i− 1
2,j(s)]
− 1
∆y
[
f y
i,j+ 1
2
(s) − f y
i,j− 1
2
(s)]
(3.4)
+1
∆x
[
Qxi+ 1
2,j(s) − Qx
i− 1
2,j(s)]
+1
∆y
[
Qy
i,j+ 1
2
(s) − Qy
i,j− 1
2
(s)]
.
Here fxi+ 1
2,j
is constructed according to the one-dimensional ENO-Roe algorithm along the
j-th slice in y, and similarly for f y
i,j+ 1
2
, along the i-th slice in x. The diffusive term in x is
given for instance by
Qxi+ 1
2,j(s) = (hw)i+ 1
2,j
si+1,j − si,j
∆x, (3.5)
and a similar expression holds for Qy
i,j+ 1
2
.
In the following sections, we give a brief overview of the most common time integration
schemes, with the view of applying them to our general transport equation. Detailed refer-
ences on the topic can be found in [11] and [12].
3.2 One-step methods
In one-step methods the numerical solution at t = tn+1 is calculated from the last approxi-
mation at t = tn only. The most common one-step methods are given by the Runge-Kutta
(RK) schemes, which admit the following general form:
sn+1 = sn + ∆tk∑
i=1
biL(s(i)) , (3.6)
s(i) = sn + ∆tk∑
j=1
aijL(s(j)) , i = 1, . . . , k . (3.7)
Here k is the number of stages, and s(i) is the approximation at the intermediate time
t(i) = tn + ci∆t. A compact notation for RK schemes is given by the Butcher array
14 CHAPTER 3. METHOD OF LINES AND TIME INTEGRATION
c A
bT
where c = (c1, . . . , ck)T , b = (b1, . . . , bk)
T and A = (aij)1≤i,j≤k. If aij = 0 for j ≥ i, the
method is explicit, and therefore it is computationally very efficient. On the other hand,
implicit methods generally require the solution of km × km systems of nonlinear algebraic
equations (here m is the number of discretization nodes), but they have better stability
properties. The stability of RK schemes can be studied through the function
R(z) = 1 + zbT (I − zA)−1e , (3.8)
where e = (1, . . . , 1)T . This function is derived from the linear scalar case s′(t) = λs(t) which
gives sn+1 = R(λ∆t)sn. The stability condition of a given RK scheme can be visualized by
plotting the stability region S = {z ∈ C, |R(z)| ≤ 1} in the complex plane.
An important advantage of RK methods is that they satisfy the conservation property, i.e.,
if vTL(s) = 0 for a constant vector v and for all s, then vT sn+1 = vT sn. In particular,
this guarantees that for any discrete spatial operator written in conservative form, the time
integration, and thus the overall scheme, is mass conservative (in this case the components
of v are given by the grid block sizes).
Classical second-order RK schemes are given by the explicit trapezoidal rule
sn+1 = sn +∆t
2L(sn) +
∆t
2L(sn + ∆tL(sn)) , (3.9)
and the explicit midpoint rule
sn+1 = sn + ∆tL(sn +∆t
2L(sn)) . (3.10)
An example of a TVD third-order explicit RK method is given by:
s(1) = sn + ∆tL(sn) ,
s(2) =3
4sn +
1
4s(1) +
∆t
4L(s(1)) ,
sn+1 =1
3sn +
2
3s(2) +
2∆t
3L(s(2)) .
(3.11)
The trapezoidal and midpoint rules also admit second-order implicit versions, respectively
given by
3.2. ONE-STEP METHODS 15
sn+1 = sn +∆t
2L(sn) +
∆t
2L(sn+1) , (3.12)
and
sn+1 = sn + ∆tL(1
2(sn + sn+1)
)
. (3.13)
Below we give another example of a second-order implicit RK scheme:
sn+1 = sn + b1∆tL(s(1)) + b2∆tL(s(2))
s(1) = sn + a11∆tL(s(1)) + (c1 − a11)∆tL(s(2))
s(2) = sn + b1∆tL(s(1)) + b2∆tL(s(2)) ,
(3.14)
where a11, b1, b2 are parameters that satisfy the order 2 conditions:
b1 + b2 = 1, b1 =1
2(1 − c1). (3.15)
For the particular choice a11 = 5/12, c1 = 1/3 we obtain the Radau scheme (collocation
method) which is third-order accurate. Otherwise, if we impose 0 ≤ c1 ≤ 1/2 and a11 ≥ b1
then we obtain an ANf (0)-stable method, which is a particular form of stability related
to the contractivity property (see [2]). This RK scheme can have good stability properties
but it requires the solution of a 2m × 2m system, as opposed to an m × m system for the
trapezoidal and midpoint rules.
Higher order implicit methods are generally too costly in practice unless they admit a partic-
ular form where the matrix A is lower diagonal, i.e., Aij = 0 for j > i. In this case, we need
to solve k successive systems of m equations rather than one simultaneous system of mk
equations. Such methods are known as Diagonally Implicit Runge-Kutta schemes (DIRK).
A common example is given by
sn+1 = sn +∆t
2L(s(1)) +
∆t
2L(s(2))
s(1) = sn + γ∆tL(s(1))
s(2) = sn + (1 − 2γ)∆tL(s(1)) + γ∆tL(s(2)) ,
(3.16)
where γ is a positive parameter. The above method is unconditionally stable for γ > 1/4,
third-order accurate if γ = 1/2 ±√
3/6 and second-order accurate otherwise.
16 CHAPTER 3. METHOD OF LINES AND TIME INTEGRATION
3.3 Linear Multistep methods
The idea of Linear Multistep methods is to use information not only from the last approx-
imation sn, but also from previous time steps. The general formalism of such methods is
described by
k∑
i=0
aisn+i = ∆t
k∑
i=0
biL(sn+i) . (3.17)
The above formula means that the approximation sn+k is computed from sn,. . . ,sn+k−1. For
consistency, we need to impose
k∑
i=0
ai = 0 , (3.18)
which also guarantees the conservation property like in the case of RK methods (this is easily
shown recursively). Order conditions for high-order Linear Multistep methods can also be
derived analytically. As for stability properties, they can be studied through characteristic
polynomials (see [11] for more details).
The clear advantage of Linear Multistep methods over RK schemes is their computational
efficiency, since they require fewer function evaluations in the explicit case and smaller sys-
tems to invert in the implicit case. However, a special starting procedure is required to
initialize this type of time integration scheme because of the dependency on multiple previ-
ous time steps. Moreover, the application of these methods with variable time steps is not
as straightforward as in the case of RK methods.
General families of Linear Multistep methods are given by the Adams methods for which
ak = 1, ak−1 = −1, and ai = 0 (i < k − 1), and the implicit Backward Differentiation
Formula (BDF) for which βk = 1 and βi = 0 (i < k). A classical example is given by the
second-order BDF method which is a 3-level scheme:
3
2sn+2 − 2sn+1 +
1
2sn = ∆tL(sn+2) , (3.19)
and its explicit counterpart obtained by extrapolation of the right-hand side:
3
2sn+2 − 2sn+1 +
1
2sn = 2∆tL(sn+1) − ∆tL(sn) . (3.20)
3.3. LINEAR MULTISTEP METHODS 17
An example of a multi-level scheme with adaptive time stepping is discussed in [3]. Applied
to the one-dimensional transport equation, it reads:
(1 + β)δts
n+1i
∆tn+1− β
δtsni
∆tn= − 1
∆x
{
θ∆fn+1i + (1 − θ + φ)∆fn
i − φ∆fn−1i
}
. (3.21)
In the above equation, δtsni = sn
i − sn−1i and ∆fi = fi+ 1
2
− fi− 1
2
, where fi+ 1
2
is a high-order
numerical flux (e.g., WENO). Here the consistency condition (3.18) still holds. So like in the
case of a uniform time step size, mass conservation is guaranteed as long as the initialization
procedure conserves mass.
In order to ensure second-order accuracy in time, the parameter β must satisfy
β =(2θ − 1)∆tn+1 + 2φ∆tn
∆tn + ∆tn+1. (3.22)
Let us derive this condition for the case φ = 0. For a second-order numerical flux we can
write
1
∆x
[
fni+ 1
2
− fni− 1
2
]
= [f(s)x]ni + O(∆x2) , (3.23)
and the same Taylor series expansion can be written at the time level n + 1. So
1
∆x
{
θ∆fn+1i + (1 − θ)∆fn
i
}
= θ [f(s)x]n+1i + (1 − θ) [f(s)x]
ni + O(∆x2)
= [f(s)x]ni + θ∆tn+1 [f(s)xt]
ni + O(∆x2) . (3.24)
For the time derivatives, denoting h = max(∆tn, ∆tn+1), we can write
sn+1i − sn
i
∆tn+1= (st)
ni +
∆tn+1
2(stt)
ni + O(h2) , (3.25)
and similarly
sni − sn−1
i
∆tn= (st)
ni − ∆tn
2(stt)
ni + O(h2) , (3.26)
so that
(1 + β)δts
n+1i
∆tn+1− β
δtsni
∆tn= (st)
ni +
(
(1 + β)∆tn+1
2+ β
∆tn
2
)
(stt)ni + O(h2) . (3.27)
18 CHAPTER 3. METHOD OF LINES AND TIME INTEGRATION
Adding (3.24) and (3.27) and noting that st = −f(s)x, we obtain the truncation error
E = θ∆tn+1 [f(s)xt]ni +
(
(1 + β)∆tn+1
2+ β
∆tn
2
)
(stt)ni + O(∆x2) + O(h2) . (3.28)
Since f(s)xt = −stt, the second-order condition is
θ∆tn+1 = (1 + β)∆tn+1
2+ β
∆tn
2, (3.29)
which reduces to (3.22), as desired.
For β 6= 0, (3.21) is a three-level scheme. If θ = 1 and φ = 0 it gives a more general
version of the second-order BDF scheme allowing variable time steps. On the other hand,
if β = φ = 0, we obtain the classical θ-scheme and the order condition (3.22) imposes that
θ = 1/2. This corresponds to the Crank-Nicolson scheme, which can actually be used to
initialize the three-level scheme.
3.4 Positivity property
Different monotonicity properties can be associated with a numerical approximation, such as
the maximum principle, positivity, contractivity, non-oscillatory and TVD properties. In this
section, we focus our attention on the positivity property which is important when dealing
with component concentrations or phase saturations. The ODE system (3.1) is said to be
positive if for any positive initial condition, the solution remains positive at all times:
s(0) ≥ 0 ⇒ s(t) ≥ 0 , ∀t > 0 . (3.30)
The spatial discretizations introduced in the previous chapter generally lead to a positive
ODE system. But positivity must be preserved by the time integration as well. Otherwise,
the MOL scheme is likely to produce negative values and spurious oscillations, even if the
spatial discretization is non-oscillatory. Our objective is to test the positivity property for
the various implicit methods presented earlier in this chapter.
Our test problem is the linear advection equation discretized in space by the first-order
Upwind scheme. In this case, assuming periodic boundary conditions, the discrete spatial
operator is given by the matrix
3.4. POSITIVITY PROPERTY 19
Λ =1
∆x
−1 0 . . . 0 1
1. . . . . . . . . 0
0. . . . . . . . .
......
. . . . . . . . ....
0 . . . . . . 1 −1
. (3.31)
The corresponding ODE system is clearly positive because all the off-diagonal entries of Λ
are positive. In the linear case, any RK scheme reads
sn+1 = R(∆tΛ)sn , (3.32)
where R is the associated stability function. From this form follows the stability condition
λk∆t ∈ S for all the eigenvalues λk of Λ, where S is the stability region of R. For this
particular problem with Λ given by (3.31), all the implicit RK schemes introduced previously
are unconditionally stable. Indeed, it can be shown that all the eigenvalues of Λ have negative
real parts, while the half complex plane ℜ(z) < 0 is contained in the stability region. So in
theory, arbitrary time step sizes can be used.
For our test problem we can rewrite the implicit trapezoidal rule (3.12) as
sn+1 = (Id − ∆t
2Λ)−1(Id +
∆t
2Λ)sn , (3.33)
and the midpoint rule (3.13) as
sn+1 =
[
Id + ∆tΛ(Id − ∆t
2Λ)−1
]
sn . (3.34)
It is easy to check that in this particular case the two methods are equivalent (noting that
(Id + ∆t2Λ) and (Id − ∆t
2Λ)−1 commute). The IRK2 method (3.14) leads to
sn+1 = [Id − ∆tΛ(b2Id + b1(c1 − a11)∆tΛΘ)]−1 [Id + b1∆tΛΘ] sn , (3.35)
where Θ = (Id − a11∆tΛ)−1, while the DIRK method (3.16) gives
sn+1 =
[
Id +∆t
2ΛΘ (2Id + (1 − 2γ)∆tΛΘ)
]
sn , (3.36)
where Θ = (Id − γ∆tΛ)−1.
20 CHAPTER 3. METHOD OF LINES AND TIME INTEGRATION
Finally we want to test the implicit BDF2 scheme (3.19). Although it is not a one-step
method, it is useful to rewrite it in matrix form:
sn+1 = (3
2Id − ∆tΛ)−1(2sn − 1
2sn−1) . (3.37)
Figures (3.1), (3.2), (3.3) and (3.4) show the simulation results obtained with the sharp
initial profile s(x, 0) = [sin(πx)]100.
The abbreviated names TRK2, IRK2, DIRK3 and BDF2 refer to the implicit methods (3.33),
(3.35), (3.36) and (3.37) respectively. For the DIRK3 scheme we used γ = 1/2+√
3/6, while
for the IRK2 scheme we used a11 = 5/12, c1 = 1/3, b1 = 3/4 and b2 = 1/4. For each implicit
scheme, the numerical solution was calculated with CFL = 2 and CFL = 6.
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
u
CFL=2 TRK2MOC
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
u
CFL=6 TRK2MOC
Figure 3.1: Linear advection test with the TRK2 method
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
u
CFL=2 IRK2MOC
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
u
CFL=6 IRK2MOC
Figure 3.2: Linear advection test with the IRK2 method
3.4. POSITIVITY PROPERTY 21
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
uCFL=2 DIRK3
MOC
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
u
CFL=6 DIRK3MOC
Figure 3.3: Linear advection test with the DIRK3 method
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
u
CFL=2 BDF2MOC
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
u
CFL=6 BDF2MOC
Figure 3.4: Linear advection test with the BDF2 method
For CFL = 2, the positivity of the solution is respected, except for the BDF2 scheme which
already produces negative values. For CFL = 6 we observe that all the methods become
oscillatory or non-positive, but not to the same degree. In particular the IRK2 method
violates the positivity property very slightly and does not show any oscillations. Meanwhile,
all the other methods are clearly non-positive and oscillatory. In fact, the positivity limit for
the DIRK3 and IRK2 methods depends on the choice of the scheme coefficients. For instance,
by choosing a value of γ close to 1/4 we can improve the positivity restriction of the DIRK3
method for this particular problem. More importantly, the monotonicity restrictions of a
given method depend on the problem it is applied to. For instance, these implicit methods
would have different positivity restrictions if they were applied to a nonlinear transport
equation.
22 CHAPTER 3. METHOD OF LINES AND TIME INTEGRATION
Theoretical results about the positivity and contractivity properties of Runge-Kutta and
Linear Multistep methods can be found in [9], [10] and [11]. The most important result
is due to Bolley & Crouzeix (1978) who showed that there is an order barrier of one for
unconditional linear positivity. In other words, any implicit Runge-Kutta or Linear Multistep
method of order higher than two has a time step restriction for positivity. Among the time
integration methods presented, only the Backward-Euler scheme is unconditionally positive
because it is first-order accurate. This result is very important in the context of this study
because we need to develop high-order methods for physical problems where the positivity
of the solution must be preserved.
3.5 Other time integration methods
Below we provide a non-exhaustive list of additional time integration methods that are
commonly found in the literature of ODE systems and generally proven to be highly efficient.
First, we refer to [11] for Rosenbrock methods, which are linearly implicit Runge-Kutta type
methods. These methods can be very efficient for stiff problems, however they are not strictly
mass conservative.
In [20], a highly efficient explicit time marching algorithm based on the stability interval of
Chebyshev polynomials is described. But this method is only advantageous for parabolic
problems since the stability interval is maximized along the real axis.
Recently, a new type of time integration method was introduced, which can violate the order
one barrier for unconditional contractivity (a property closely related to positivity). These
schemes, called diagonally split Runge-Kutta methods, are obtained as the limit of relaxation
iterations of continuous extensions of RK methods (see [2] and [1]). However they have been
developed for dissipative ODE systems arising from the discretization of parabolic equations.
Moreover, these schemes are not strictly mass conservative.
Finally, a new approach called Multi-Adaptive Galerkin method was recently introduced
by Anders Logg (see [19]). This approach seems very promising because it allows to use
adaptive local time steps, however it is not directly applicable to high-order AIM.
In Appendix A, we present different high-order MOL schemes obtained by combining high-
order time integration methods with high resolution numerical fluxes. Some test results
are provided for the linear and quasi-linear cases. These numerical tests validate the MOL
3.5. OTHER TIME INTEGRATION METHODS 23
framework for the construction of high-order AIM. In particular, we observe a substantial
reduction of the numerical dispersion compared to first-order methods. But before discussing
high-order AIM extensions in more details, we present a numerical analysis of the standard
AIM discretization. The main objective of the next chapter is to understand the numerical
implications of combining implicit and explicit time integration methods, from the standpoint
of accuracy, stability and monotonicity properties.
Chapter 4
Numerical analysis of standard AIM
In this chapter, we focus our attention on the numerical behavior of the standard AIM
discretization. First, we show that there is a local inconsistency at the transition between
implicit and explicit regions. Then we perform a linear error analysis and deduce some impor-
tant convergence properties. We also provide a series of results regarding the monotonicity
properties of standard AIM, with a particular emphasis on the TVD property. Finally, we
propose a consistency fix based on explicit predictors applied in the explicit regions, which
will be useful for the construction of high-order AIM.
4.1 Local inconsistency
The one-dimensional Buckley-Leverett problem without gravity and capillarity is described
by (2.2). For simplicity we also assume that f ′(s) ≥ 0. The initial and boundary conditions
are given by
s(x, 0) = swc , s(0, t) = swi , (4.1)
where swc is the connate water saturation and swi the inlet saturation. Let us consider the
standard AIM discretization of (2.2) on a uniform grid of size m. We assume for clarity that
the region to the left of block (i0) is implicit, whereas the region to the right of it, including
the block (i0) itself, is explicit (cf. figure 4.1). Thus the number of implicit nodes is given
by p = i0 − 1 and the number of explicit nodes by q = m − i0 + 1. In terms of terminology,
any boundary between an implicit and an explicit region will be called an I-E boundary.
24
4.1. LOCAL INCONSISTENCY 25
EXPLICITIMPLICIT
i0 − 2 i0 − 1 i0 i0 + 1
Figure 4.1: Schematic of an implicit-explicit (I-E) boundary
For this configuration, the standard AIM scheme reads:
0 =sn+1
i − sni
∆t+
1
∆x
[
f(sn+1i ) − f(sn+1
i−1 )]
, i < i0 , (4.2)
0 =sn+1
i − sni
∆t+
1
∆x
[
f(sni ) − f(sn+1
i−1 )]
, i = i0 , (4.3)
0 =sn+1
i − sni
∆t+
1
∆x
[
f(sni ) − f(sn
i−1)]
, i > i0 . (4.4)
The numerical schemes in the implicit and explicit regions are respectively the Backward
Euler and Forward Euler methods with single-point upstream weighting of the flux. They
both have a leading truncation error of O(∆x)+O(∆t). Using this standard scheme, a local
inconsistency arises at the transition between the implicit and explicit regions, i.e., at the
interface between the blocks (i0 − 1) and (i0). Here, information propagates from left to
right so the inconsistency occurs for block (i0) where the ingoing and outgoing fluxes are
evaluated at different time levels. The truncation error at this location is derived below
using Taylor series expansions. We denote by s the exact solution to the IBVP (2.2)-(4.1).
Let fni = f(sn
i ), and let (f ′)ni , (f ′′)n
i be similar notations for the derivatives. We have
sni0
= sn+1i0
− ∆t(st)n+1i0
+1
2∆t2(stt)
n+1i0
+ O(∆t3) , (4.5)
and
sn+1i0−1 = sn+1
i0− ∆x(sx)
n+1i0
+1
2∆x2(sxx)
n+1i0
+ O(∆x3) . (4.6)
It follows that
fni0− fn+1
i0
∆t= −
[
stf′]n+1
i0+
∆t
2
[
sttf′ + (st)
2f ′′]n+1
i0+ O(∆t2) , (4.7)
26 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
and
fn+1i0−1 − fn+1
i0
∆x= −
[
sxf′]n+1
i0+
∆x
2
[
sxxf′ + (sx)
2f ′′]n+1
i0+ O(∆x2) . (4.8)
From (4.5) we also have
sn+1i0
− sni0
∆t= (st)
n+1i0
− ∆t
2(stt)
n+1i0
+ O(∆t2) . (4.9)
Multiplying (4.7) by ∆t/∆x and then subtracting (4.8), it yields
fni0− fn+1
i0−1
∆x= −∆t
∆x[stf
′]n+1i0
+ [sxf′]n+1
i0+ O(∆x) + O(∆t2/∆x) . (4.10)
Finally, adding up (4.9) and (4.10) we obtain the truncation error
Eni0
= (st)n+1i0
− ∆t
∆x[f(s)t]
n+1i0
+ [f(s)x]n+1i0
+ O(∆x) + O(∆t) + O(∆t2/∆x) , (4.11)
which can be simplified by canceling out the first and third terms:
Eni0
= −∆t
∆x[f(s)t]
n+1i0
+ O(∆x) + O(∆t) + O(∆t2/∆x) . (4.12)
The above equation indicates that the standard AIM discretization is inconsistent at the
transition from an implicit to an explicit region. Similarly, it is inconsistent at the transition
from an explicit to an implicit region. Hence the standard AIM discretization is inconsistent
at every I-E boundary.
At this point it is important to recall that by construction the standard AIM scheme is
stable, so we do not expect the discretization errors at the various I-E boundaries to be
amplified with time. Nevertheless, the accuracy of the scheme may be affected by these
errors. Moreover, convergence is not guaranteed a priori because the Lax equivalence theorem
does not apply. In the following section, we present a linear error analysis that will allow us
to understand how these discretization errors propagate and also to prove convergence for a
particular case.
4.2 Linear error analysis
To conduct this analysis we assume that f(s) = s and that the location of the I-E boundary
remains fixed in time (i.e., i0 is fixed). Let εni = sn
i − s(xi, tn) denote the numerical error at
4.2. LINEAR ERROR ANALYSIS 27
every grid node. Substituting sni = sn
i + εni into (4.2), (4.3), (4.4), and neglecting the terms
of order two or higher, we get:
εn+1i − εn
i
∆t+
1
∆x
(
εn+1i − εn+1
i−1
)
= 0 , i < i0 , (4.13)
εn+1i − εn
i
∆t+
1
∆x
(
εni − εn+1
i−1
)
=∆t
∆x(st)
n+1i , i = i0 , (4.14)
εn+1i − εn
i
∆t+
1
∆x
(
εni − εn
i−1
)
= 0 , i > i0 , (4.15)
and due to the inlet condition we have εn0 = 0 for all n. Multiplying through by ∆t and
denoting the CFL number by λ =∆t
∆x, we obtain
(1 + λ)εn+1i − λεn+1
i−1 = εni , i < i0 , (4.16)
εn+1i − λεn+1
i−1 = (1 − λ)εni + λ∆t(st)
n+1i , i = i0 , (4.17)
εn+1i = (1 − λ)εn
i + λεni−1 , i > i0 , (4.18)
which can be written in matrix form as
AE (n+1) = BE (n) + S(n+1) . (4.19)
Here E is the error vector, A and B are m×m matrices with non zero entries only on their
main diagonal and first off-diagonal, and S is a source term due to the discretization error
at the I-E boundary:
S(n+1)i =
{
0 i 6= i0
λ∆t(st)n+1i i = i0 .
(4.20)
The matrix A can be written in the following form:
A =
(
A1 0
A2 Iq
)
, (4.21)
where Iq is the q × q identity matrix, A1 the p × p bidiagonal matrix given by
28 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
A1 =
1 + λ 0 0 . . .
−λ 1 + λ. . . . . .
0. . . . . . . . .
.... . . . . . . . .
, (4.22)
and A2 is a q × p matrix with only one non-zero element in the top right corner, equal to
−λ. Since det(A) > 0, A is invertible, and we have
A−1 =
(
A−11 0
−A2A−11 Iq
)
, (4.23)
with
A−11 =
α 0 0 . . . 0
λα2 α. . . . . .
...
λ2α3 λα2 . . . . . . 0...
. . . . . . . . . 0
λp−1αp . . . λ2α3 λα2 α
, (4.24)
where α = 1/(1 + λ). Similarly, we can write B as
B =
(
Ip 0
0 B1
)
, (4.25)
where B1 is the q × q bidiagonal matrix
B1 =
1 − λ 0 0 . . .
λ 1 − λ. . . . . .
0. . . . . . . . .
.... . . . . . . . .
. (4.26)
So finally
A−1B =
(
A−11 0
−A2A−11 Iq
)(
Ip 0
0 B1
)
=
(
A−11 0
−A2A−11 B1
)
, (4.27)
where all the sub-matrices A−11 , A2 and B1 are known. In this simple case, A−1B has only
two distinct eigenvalues, namely
4.2. LINEAR ERROR ANALYSIS 29
µ1 = 1 − λ, µ2 =1
1 + λ. (4.28)
Since 0 < λ < 1 (CFL condition), we have 0 < µ1 < 1 and 0 < µ2 < 1, so ρ(A−1B) < 1. As
expected, the spectral radius of the standard AIM operator is less than one, which implies
stability. But as mentioned earlier, this is not sufficient to deduce convergence.
Let Tf denote the final time and N the total number of time steps (i.e., Tf = N∆t). Since
E (0) = 0, we can compute the error at the final time as follows:
E (1) = S(1)
E (2) = MS(1) + S(2)
E (3) = M2S(1) + MS(2) + S(3)
...
E (N) =N∑
k=1
MN−kS(k) , (4.29)
where S(n) = A−1S(n), and M = A−1B. In order to analyze the convergence properties, we
need to compute the matrix-vector products in (4.29). They are simply obtained from the
i0-th column of MN−k (1 ≤ k ≤ N) because only the i0-th component of S(k) is not zero.
Denoting by (e1, . . . , em) the canonical basis in Rm where m is the number of blocks, we can
show that for n ≤ m − i0
Mn · ei0 =n∑
k=0
Ckn λk(1 − λ)n−kei0+k . (4.30)
This identity means that each individual error term arising at an I-E boundary is convected
with a positive unit speed while being diffused with time (see figure 4.2). A proof of this
result is obtained by mathematical induction. It is clearly true for n = 0, and from (4.26)
we can easily check that for k < m − i0
M · ei0+k = (1 − λ)ei0+k + λei0+k+1 . (4.31)
It follows that for n < m − i0, we have
30 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
Mn+1 · ei0 =n∑
k=0
Ckn λk(1 − λ)n−kM · ei0+k (4.32)
=n∑
k=0
Ckn λk(1 − λ)n+1−kei0+k +
n∑
k=0
Ckn λk+1(1 − λ)n−kei0+k+1 (4.33)
= (1 − λ)n+1ei0 + λn+1ei0+n+1 +n∑
k=1
(Ckn + Ck−1
n )λk(1 − λ)n+1−kei0+k (4.34)
=n+1∑
k=0
Ckn+1 λk(1 − λ)n+1−kei0+k , (4.35)
which completes the proof by induction. Note that the last line was obtained by applying
Pascal’s rule: Ckn + Ck−1
n = Ckn+1.
For n > m − i0, the error term has already reached the right end of the domain. Using the
identity M · em = (1 − λ)em, we can show in a similar way that
Mn · ei0 =
m−i0∑
k=0
Ckn λk(1 − λ)n−kei0+k . (4.36)
0 1 2 3 4 50
0.5
1
1.5
2
2.5
3x 10
−4
x
err
or
T=0.25T=0.75T=1.25T=1.75
Figure 4.2: Propagation of a discretization error arising at an I-E boundary. The inconsistency at
the I-E boundary creates a new error “pulse” at each time step. This plot shows the time evolution
of this pulse, as predicted by equation (4.30).
4.2. LINEAR ERROR ANALYSIS 31
Moreover it is easy to see from (4.23) that S(n) = A−1S(n) = S(n). Hence using (4.29),
(4.30), (4.36), and noting ln = min(n, m − i0), we have
E (N) =N−1∑
n=0
MnS(N−n) =N−1∑
n=0
(
ln∑
k=0
Ckn λk(1 − λ)n−kei0+k
)
λ∆t(st)N−ni0
=
lN−1∑
k=0
(
N−1∑
n=k
Ckn λk+1(1 − λ)n−k∆t(st)
N−ni0
)
ei0+k . (4.37)
It follows that for k ≤ lN−1
∣
∣εNi0+k
∣
∣ =∣
∣(E (N), ei0+k)∣
∣ ≤ λk+1K∆t
N−1∑
n=k
Ckn (1 − λ)n−k , (4.38)
where K is an upper bound for st over the interval [0, Tf ]. Since 0 < λ < 1 we can write
N−1∑
n=k
Ckn (1 − λ)n−k ≤ 1
k!
∞∑
n=k
[n(n − 1) . . . (n − k + 1)] (1 − λ)n−k . (4.39)
The series expansion on the right-hand side of (4.39) corresponds to the k-th derivative of
f(z) =∞∑
n=0
zn =1
1 − z, (4.40)
evaluated at z = 1 − λ. Indeed z 7→ f(z) is C∞ on the open interval ] − 1, 1[ and
f (k)(z) =∞∑
n=k
[n(n − 1) . . . (n − k + 1)] zn−k =k!
(1 − z)k+1. (4.41)
Thus for k ≤ lN−1 we obtain
∣
∣εNi0+k
∣
∣ ≤ λk+1K∆t1
k!
k!
λk+1= K∆t . (4.42)
This upper bound is independent of k, and since all the other components of E (N) are zero,
we have
‖E (N)‖∞≤ KTf
N. (4.43)
The right-hand side goes to zero as N → ∞ (or equivalently, ∆t → 0), hence the scheme is
convergent with respect to the infinite norm. In figure 4.3 we show a refining study using the
32 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
initial saturation profile s(x, 0) = e−x2
(x > 0) and swi = 1. The final error E (N) is plotted
for increasing values of N . As expected, if the grid and the time step size are refined by a
factor of two, the total amplitude of the error is also divided by two.
0 1 2 3 4 50
0.02
0.04
0.06
0.08
0.1
0.12
x
err
or
N=20N=40N=80N=160
Figure 4.3: Refining study in the case of a fixed I-E boundary. As predicted by our analysis, the
amplitude of the final error goes to zero as the mesh and time step sizes are refined.
In figure 4.4 we show a numerical experiment with standard AIM in the linear case. Like in
our previous study, the I-E boundary is fixed. The solution and error profiles are computed
for the initial condition s(x, 0) = e−x2
and the inlet condition s(0, t) = 1. The mesh size
is m = 50 and the I-E boundary is located at x = 2.5. The standard AIM scheme (AIM-
STD-UW1) is compared against the implicit single-point upstream weighting scheme (BE-
UW1). In the solution profile of standard AIM we observe a small “kink” just after the I-E
boundary. In the error profile we see that the amplitude of this “kink” is about the same
as the numerical dispersion, dominated here by second-order dissipative terms. Hence this
result is in agreement with our linear error analysis (also see figure 4.3 for a comparison of
the error profile without numerical dissipation).
4.2. LINEAR ERROR ANALYSIS 33
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
x
Sw
MOCBE−UW1AIM−STD−UW1
"kink" at the I−E boundary
0 1 2 3 4 5
−0.15
−0.1
−0.05
0
0.05
0.1
0.15
xe
rro
r
BE−UW1AIM−STD−UW1
Figure 4.4: Solution and error profiles for a fixed I-E boundary. In each plot, standard AIM is
compared against the fully implicit solution. In the error profile, it appears that the amplitude of
the “kink” is comparable to the numerical dissipation.
If the I-E boundary is allowed to move with time, then the discretization errors may create
an even larger “kink”. Indeed, we can move the I-E boundary with a unit speed, so that
each new error source term is added to the location where the total error is already maximal.
In this type of experiment, we are trying to maximize the total amplitude of the error, so
we expect a larger effect than in the case of a fixed I-E boundary. But again, the numerical
dissipation causes the error source terms to spread with time. So when the grid is refined,
the maximum norm of the final error still goes to zero. However, as shown in figure 4.5, if
the mesh is refined by a factor of ten, the total error is only divided by four or five. Note that
we do not have any theoretical proof of convergence for the case of a moving I-E boundary.
But in this particular experiment, the numerical solution seems to be convergent, at a very
slow rate (lower than one).
34 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
x
Sw
MOCAIM−STD−UW1
0 1 2 3 4 5
0
0.2
0.4
0.6
0.8
1
xS
w
MOCAIM−STD−UW1
Figure 4.5: Solution profiles for a moving I-E boundary. In the left plot, the grid size is m = 50,
while in the right plot, m = 500. Even though the grid size ratio equals ten, in this case the
amplitude of the “kink” is not reduced by a factor of ten.
4.3 Monotonicity properties
The objective of this section is to analyze some important monotonicity properties (positivity,
maximum principle, total variation) for the standard AIM discretization. In this study we
consider the configuration shown on figure 4.1 (only one I-E boundary) with a Dirichlet
condition at the inlet.
4.3.1 Positivity and the maximum principle
In the linear homogeneous case, the numerical approximation at tn+1 is given by
s(n+1) = (A−1B)s(n) + (λswi)A−1e1 , (4.44)
where e1 = (1, 0, . . . , 0)T and A−1, A−1B are given by (4.23), (4.27). We note that A−1 ≥ 0
and A−1B ≥ 0 (component-wise inequalities), i.e., A and B−1A are monotone. So if s(n) ≥ 0
we have
4.3. MONOTONICITY PROPERTIES 35
(A−1B)s(n) ≥ 0, (λswi)A−1e1 ≥ 0 ⇒ s(n+1) ≥ 0 . (4.45)
The above result shows the linear positivity of the standard AIM scheme. Actually this
scheme satisfies the maximum principle, which is an even stronger monotonicity property.
Indeed, if s(n) ≤ C1e (component-wise inequality with e = (1, . . . , 1)T ) and swi ≤ C1 for
some arbitrary constant C1, then
s(n+1) ≤ C1(A−1B)e + λC1 A−1e1 = C1
[
(A−1B)e + λA−1e1
]
. (4.46)
But for consistency we should have
(A−1B)e + λA−1e1 = e . (4.47)
To check this equality we need to compute the row sums of A−1B and the first column of
A−1. Letting v = (A−1B)e+λA−1e1, it follows from (4.23), (4.24) and (4.27) that for i ≤ p
vi =i∑
j=1
λj−1αj + λ(λi−1αi) , (4.48)
where α = 1/(1 + λ). Hence
vi =1
1 + λ
i−1∑
j=0
(
λ
1 + λ
)j
+
(
λ
1 + λ
)i
=1
1 + λ
1 − (λ/(1 + λ))i
1 − λ/(1 + λ)+
(
λ
1 + λ
)i
, (4.49)
and after simplification we obtain vi = 1, as desired. Similarly, using the exact forms of A2
and B1 in (4.27), we can easily derive that vi = 1 for i > p. So the equality (4.47) holds
and finally (4.46) implies that s(n+1) ≤ C1e. Similarly if s(n) ≥ C2e and swi ≥ C2 we obtain
s(n+1) ≥ C2e. Therefore the standard AIM approximation satisfies the maximum principle
in the linear case.
In the quasi-linear case, the set of equations (4.4), (4.3) and (4.2) can be rewritten in compact
form as follows:
G(sn, sn+1) = 0 , (4.50)
36 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
where G : R2m → Rm is a continuously differentiable function. It is also assumed that the
problem is well-posed, i.e., that (4.50) has a unique solution for a given sn. Let R2m have
coordinates (x1, . . . , xm, y1, . . . , ym), then DY G can be written under the form (4.21) with
A1 =
1 + νn+11 0 0 . . .
−νn+11 1 + νn+1
2. . . . . .
0. . . . . . 0
.... . . −νn+1
p−1 1 + νn+1p
, (4.51)
where νn+1i = λf ′(sn+1
i ). The only non-zero element of A2 (in the right top corner) is now
equal to −νn+1p . Similarly, −DXG can be written in the form (4.25) where
B1 =
1 − νnp+1 0 0 . . .
νnp+1 1 − νn
p+2. . . . . .
0. . . . . . 0
.... . . νn
m−1 1 − νnm
. (4.52)
Like in the linear case, the matrix A1 is invertible and the coefficients of its inverse are given
by
αi,j =
0, j > i
1/(1 + νn+1i ), j = i
∏ik=j νn+1
k /∏i
k=j(1 + νn+1k ), j < i .
(4.53)
From the implicit value theorem, since DY G is invertible, there exists a function φ defined
in a neighborhood of sn such that G(s, φ(s)) = 0 and
sn+1 = φ(sn) . (4.54)
Moreover, the derivatives of φ at s = sn are given by
Dφ(sn) = −[
DY G(sn, sn+1)]−1
DXG(sn, sn+1) . (4.55)
Thus, the Jacobian matrix Dφ has the same form as the standard AIM operator in the linear
case, given by (4.27). From (4.53) and (4.52), it is easy to see that A−11 ≥ 0, and that under
the CFL condition for the explicit blocks, B1 ≥ 0 as well. Therefore Dφ(sn) ≥ 0 and the
scheme (4.54) is monotone. In particular, if sa ≤ sb then φ(sa) ≤ φ(sb). But this property is
4.3. MONOTONICITY PROPERTIES 37
only valid locally because φ is defined in a neighborhood of sn. So this monotonicity result
is not sufficient to deduce the maximum principle.
In spite of the monotonicity of the AIM operator, there is no guarantee that standard AIM is
oscillation-free. In fact, a scheme may even satisfy the maximum principle and still produce
localized overshoots or undershoots. Hence in the following subsections we analyze the total
variation of the standard AIM discretization.
4.3.2 TVD property in the linear homogeneous case
In the linear homogeneous case we have
(1 + λ)sn+1i − λsn+1
i−1 = sni , i = 1, . . . , p , (4.56)
sn+1i − λsn+1
i−1 = (1 − λ)sni , i = p + 1 , (4.57)
sn+1i = (1 − λ)sn
i + λsni−1 , i = p + 2, . . . ,m . (4.58)
By subtracting each equation from the next one, we obtain
(1 + λ)[sn+1i − sn+1
i−1 ] = λ[sn+1i−1 − sn+1
i−2 ] + [sni − sn
i−1] , i = 1, . . . , p , (4.59)
[sn+1p+1 − sn+1
p ] = (1 − λ)[snp+1 − sn
p ] + λ[sn+1p − sn+1
p−1 ] + λ[sn+1p − sn
p ] , (4.60)
[sn+1p+2 − sn+1
p+1 ] = (1 − λ)[snp+2 − sn
p+1] + λ[snp+1 − sn
p ] − λ[sn+1p − sn
p ] , (4.61)
[sn+1i − sn+1
i−1 ] = (1 − λ)[sni − sn
i−1] + λ[sni−1 − sn
i−2] , i = p + 3, . . . ,m . (4.62)
In the above equations, we have sn0 = sn
−1 = swi for all n because of the Dirichlet condition
at the inlet (note that for i = 1, this amounts to subtracting swi from both sides of the
equation). We note that if [sn+1p+2 −sn+1
p+1 ] and [sn+1p+1 −sn+1
p ] have the same sign, then the terms
±λ[sn+1p − sn
p ] cancel out, and
|sn+1p+1 − sn+1
p | + |sn+1p+2 − sn+1
p+1 | = ±[snp+1 − sn
p ] ± λ[sn+1p − sn+1
p−1 ] ± (1 − λ)[snp+2 − sn
p+1] . (4.63)
Otherwise, using [sn+1p − sn
p ] = −λ[sn+1p − sn+1
p−1 ], we have
[sn+1p+1 − sn+1
p ] = (1 − λ)[snp+1 − sn
p ] + λ(1 − λ)[sn+1p − sn+1
p−1 ] , (4.64)
[sn+1p+2 − sn+1
p+1 ] = (1 − λ)[snp+2 − sn
p+1] + λ[snp+1 − sn
p ] + λ2[sn+1p − sn+1
p−1 ] , (4.65)
38 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
so that
|sn+1p+1 − sn+1
p | + |sn+1p+2 − sn+1
p+1 | = ± (1 − 2λ)[snp+1 − sn
p ] ± λ(1 − 2λ)[sn+1p − sn+1
p−1 ]
∓ (1 − λ)[snp+2 − sn
p+1] . (4.66)
In both cases (4.63) and (4.66), if 0 < λ < 1 (which implies |1 − 2λ| ≤ 1), it follows from
the triangular inequality that
|sn+1p+1 − sn+1
p | + |sn+1p+2 − sn+1
p+1 | ≤ |snp+1 − sn
p | + λ|sn+1p − sn+1
p−1 | + (1 − λ)|snp+2 − sn
p+1| . (4.67)
Additionally, from (4.59) and (4.62) we have
(1 + λ)
p∑
i=1
|sn+1i − sn+1
i−1 | ≤ λ
p∑
i=2
|sn+1i−1 − sn+1
i−2 | +p∑
i=1
|sni − sn
i−1| , (4.68)
m∑
i=p+3
|sn+1i − sn+1
i−1 | ≤ (1 − λ)m∑
i=p+3
|sni − sn
i−1| + λm∑
i=p+3
|sni−1 − sn
i−2| , (4.69)
and after simplification, we get
p∑
i=1
|sn+1i − sn+1
i−1 | ≤p∑
i=1
|sni − sn
i−1| − λ|sn+1p − sn+1
p−1 | , (4.70)
m∑
i=p+3
|sn+1i − sn+1
i−1 | ≤m∑
i=p+3
|sni − sn
i−1| + λ|snp+2 − sn
p+1| − λ|snm − sn
m−1| . (4.71)
Summing the three inequalities (4.67), (4.70), and (4.71) above we obtain
m∑
i=1
|sn+1i − sn+1
i−1 | ≤m∑
i=1
|sni − sn
i−1| − λ|snm − sn
m−1| . (4.72)
Therefore TV (sn+1) ≤ TV (sn), i.e., the standard AIM discretization is TVD. We can also
show this result for the transition from an explicit to an implicit region. We have
sn+1i = (1 − λ)sn
i + λsni−1 , i = 1, . . . , p , (4.73)
(1 + λ)sn+1i = sn
i + λsni−1 , i = p + 1 , (4.74)
(1 + λ)sn+1i = sn
i + λsn+1i−1 , i = p + 2, . . . ,m , (4.75)
4.3. MONOTONICITY PROPERTIES 39
which leads to
[sn+1i − sn+1
i−1 ] = (1 − λ)[sni − sn
i−1] + λ[sni−1 − sn
i−2] , i = 1, . . . , p , (4.76)
[sn+1p+1 − sn+1
p ] = (1 − λ)[snp+1 − sn
p ] + λ[snp − sn
p−1] − λ[sn+1p+1 − sn
p+1] , (4.77)
(1 + λ)[sn+1p+2 − sn+1
p+1 ] = [snp+2 − sn
p+1] + λ[snp+1 − sn
p ] + λ[sn+1p+1 − sn
p+1] , (4.78)
(1 + λ)[sn+1i − sn+1
i−1 ] = [sni − sn
i−1] + λ[sn+1i−1 − sn+1
i−2 ] , i = p + 3, . . . ,m . (4.79)
From (4.76) and (4.79) it follows that
p∑
i=1
|sn+1i − sn+1
i−1 | ≤p∑
i=1
|sni − sn
i−1| − λ|snp − sn
p−1| , (4.80)
m∑
i=p+3
|sn+1i − sn+1
i−1 | ≤m∑
i=p+3
|sni − sn
i−1| + λ|sn+1p+2 − sn+1
p+1 | − λ|sn+1m − sn+1
m−1| . (4.81)
When [sn+1p+1 − sn+1
p ][sn+1p+2 − sn+1
p+1 ] > 0, we have
|sn+1p+1 − sn+1
p | + (1 + λ)|sn+1p+2 − sn+1
p+1 | = ±[snp+1 − sn
p ] ± λ[snp − sn
p−1] ± [snp+2 − sn
p+1] . (4.82)
Otherwise, using [sn+1p+1 − sn
p+1] = − λ1+λ
[snp+1 − sn
p ] (derived from (4.74)), we obtain
|sn+1p+1 − sn+1
p | + (1 + λ)|sn+1p+2 − sn+1
p+1 | = ± (1 − 2λ)[snp+1 − sn
p ] ± λ[snp − sn
p−1]
∓ [snp+2 − sn
p+1] ±2λ2
1 + λ[sn
p+1 − snp ]
= ± 1 − λ
1 + λ[sn
p+1 − snp ] ± λ[sn
p − snp−1]
∓ [snp+2 − sn
p+1] , (4.83)
In both cases (4.82) and (4.83), since 0 < λ < 1, we have
|sn+1p+1 − sn+1
p | + (1 + λ)|sn+1p+2 − sn+1
p+1 | ≤ |snp+1 − sn
p | + λ|snp − sn
p−1| + |snp+2 − sn
p+1| . (4.84)
Finally, summing (4.84) with (4.80) and (4.81) we obtain
40 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
m∑
i=1
|sn+1i − sn+1
i−1 | ≤m∑
i=1
|sni − sn
i−1| − λ|sn+1m − sn+1
m−1| , (4.85)
which implies that TV (sn+1) ≤ TV (sn).
Figures 4.6 and 4.7 show numerical results of standard AIM applied to the linear advection
problem in the homogeneous case. In the first case the initial condition is a jump disconti-
nuity, while in the second case it corresponds to a sine wave. For each figure, the left plot
corresponds to a situation where there is only one I-E boundary moving with a unit speed.
This I-E boundary is located near the jump discontinuity in the first case and at the maxi-
mum of the sine wave in the other case. As expected from the above results, the numerical
solution satisfies the TVD property. The right plots of each figure present analogous results
when every other block is implicit, i.e., there is an I-E boundary at each cell interface. Even
in this situation, the TVD property is preserved.
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
Sw
MOCFE−UW1AIM−STD−UW1
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
Sw
MOCFE−UW1AIM−STD−UW1
Figure 4.6: Test of AIM-STD in the linear case (contact discontinuity). In the left plot, the I-E
boundary moves with the front, while in the right plot, there is an I-E boundary at every other block.
In both cases, the monotonicity of the solution is preserved.
4.3. MONOTONICITY PROPERTIES 41
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
x
Sw
MOCFE−UW1AIM−STD−UW1
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
xS
w
MOCFE−UW1AIM−STD−UW1
Figure 4.7: Test of AIM-STD in the linear case (sine wave). In the left plot, the I-E boundary
moves with the maximum of the wave, while in the right plot, there is an I-E boundary at every
other block. In both cases, the monotonicity of the solution is preserved.
4.3.3 TVD property in the quasi-linear homogeneous case
In this subsection we consider the quasi-linear homogeneous case with f ′ ≥ 0. For a transition
from implicit to explicit cells, we have
[sn+1i − sn+1
i−1 ] = [sni − sn
i−1] − λ[fn+1i − fn+1
i−1 ] + λ[fn+1i−1 − fn+1
i−2 ] , i = 1, . . . , p , (4.86)
[sn+1p+1 − sn+1
p ] = [snp+1 − sn
p ] − λ[fnp+1 − fn
p ] + λ[fn+1p − fn+1
p−1 ] + λ[fn+1p − fn
p ] , (4.87)
[sn+1p+2 − sn+1
p+1 ] = [snp+2 − sn
p+1] − λ[fnp+2 − fn
p+1] + λ[fnp+1 − fn
p ] − λ[fn+1p − fn
p ] , (4.88)
[sn+1i − sn+1
i−1 ] = [sni − sn
i−1] − λ[fni − fn
i−1] + λ[fni−1 − fn
i−2] , i = p + 3, . . . ,m . (4.89)
From the mean value theorem we can write
λ[fni − fn
i−1] = νni− 1
2
[sni − sn
i−1] , (4.90)
where νni− 1
2
= λf ′(sni−1 + θn
i− 1
2
∆sni− 1
2
), 0 ≤ θni− 1
2
≤ 1, and similarly
λ[fn+1p − fn
p ] = νn+ 1
2p [sn+1
p − snp ] , (4.91)
42 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
where νn+ 1
2p = λf ′(sn
p + θn+ 1
2p δts
np ), 0 ≤ θ
n+ 1
2p ≤ 1. It follows that
(1 + νn+1i− 1
2
)[sn+1i − sn+1
i−1 ] = [sni − sn
i−1] + νn+1i− 3
2
[sn+1i−1 − sn+1
i−2 ] , i = 1, . . . , p , (4.92)
[sn+1p+1 − sn+1
p ] = (1 − νnp+ 1
2
)[snp+1 − sn
p ] + νn+1p− 1
2
[sn+1p − sn+1
p−1 ] + νn+ 1
2p [sn+1
p − snp ] , (4.93)
[sn+1p+2 − sn+1
p+1 ] = (1 − νnp+ 3
2
)[snp+2 − sn
p+1] + νnp+ 1
2
[snp+1 − sn
p ] − νn+ 1
2p [sn+1
p − snp ] , (4.94)
[sn+1i − sn+1
i−1 ] = (1 − νni− 1
2
)[sni − sn
i−1] + νni− 3
2
[sni−1 − sn
i−2] , i = p + 3, . . . ,m . (4.95)
From (4.92) and (4.95) we have
p∑
i=1
(1 + νn+1i− 1
2
)|sn+1i − sn+1
i−1 | ≤p∑
i=1
|sni − sn
i−1| +p∑
i=2
νn+1i− 3
2
|sn+1i−1 − sn+1
i−2 | , (4.96)
m∑
i=p+3
|sn+1i − sn+1
i−1 | ≤m∑
i=p+3
(1 − νni− 1
2
)|sni − sn
i−1| +m∑
i=p+3
νni− 3
2
|sni−1 − sn
i−2| . (4.97)
For the second inequality above we used the fact that the CFL condition is satisfied for each
explicit block:
maxs∈[sn
i−1,sn
i ]|f ′(s)| ∆t
∆x≤ 1 ⇒ νn
i− 1
2
≤ 1 , i = p + 1, . . . ,m . (4.98)
After rearrangement of (4.96) and (4.97) we obtain
p∑
i=1
|sn+1i − sn+1
i−1 | ≤p∑
i=1
|sni − sn
i−1| − νn+1p− 1
2
|sn+1p − sn+1
p−1 | , (4.99)
m∑
i=p+3
|sn+1i − sn+1
i−1 | ≤m∑
i=p+3
|sni − sn
i−1| + νnp+ 3
2
|snp+2 − sn
p+1| − νnm− 1
2
|snm − sn
m−1| . (4.100)
If [sn+1p+2 − sn+1
p+1 ][sn+1p+1 − sn+1
p ] ≥ 0 then (4.93) and (4.94) give
|sn+1p+1 − sn+1
p | + |sn+1p+2 − sn+1
p+1 | = ±[snp+1 − sn
p ] ± (1 − νnp+ 3
2
)[snp+2 − sn
p+1] ± νn+1p− 1
2
[sn+1p − sn+1
p−1 ]
≤ |snp+1 − sn
p | + (1 − νnp+ 3
2
)|snp+2 − sn
p+1| + νn+1p− 1
2
|sn+1p − sn+1
p−1 | .(4.101)
4.3. MONOTONICITY PROPERTIES 43
Otherwise, substituting [sn+1p − sn
p ] = −νn+1p− 1
2
[sn+1p − sn+1
p−1 ] in (4.93) and (4.94) we obtain
[sn+1p+1 − sn+1
p ] = (1 − νnp+ 1
2
)[snp+1 − sn
p ] + νn+1p− 1
2
(1 − νn+ 1
2p )[sn+1
p − sn+1p−1 ] , (4.102)
[sn+1p+2 − sn+1
p+1 ] = (1 − νnp+ 3
2
)[snp+2 − sn
p+1] + νnp+ 1
2
[snp+1 − sn
p ] + νn+1p− 1
2
νn+ 1
2p [sn+1
p − sn+1p−1 ] .
(4.103)
So if [sn+1p+2 − sn+1
p+1 ][sn+1p+1 − sn+1
p ] < 0, we have
|sn+1p+1 − sn+1
p | + |sn+1p+2 − sn+1
p+1 | = ± (1 − 2νnp+ 1
2
)[snp+1 − sn
p ] ∓ (1 − νnp+ 3
2
)[snp+2 − sn
p+1]
± νn+1p− 1
2
(1 − 2νn+ 1
2p )[sn+1
p − sn+1p−1 ] ,
and according to (4.98), νnp+ 1
2
≤ 1 and νnp+ 3
2
≤ 1, thus
|sn+1p+1 − sn+1
p | + |sn+1p+2 − sn+1
p+1 | ≤|snp+1 − sn
p | + (1 − νnp+ 3
2
)|snp+2 − sn
p+1|
+ νn+1p− 1
2
|1 − 2νn+ 1
2p ||sn+1
p − sn+1p−1 | . (4.104)
When the inequality (4.101) holds, by summing it with (4.99) and (4.100) we obtain
m∑
i=1
|sn+1i − sn+1
i−1 | ≤m∑
i=1
|sni − sn
i−1| − νnm− 1
2
|snm − sn
m−1| , (4.105)
which shows that the scheme is TVD. But (4.104) suggests that this inequality is not nec-
essarily true. This would imply that, as opposed to the linear case, the standard AIM
dicretization for the quasi-linear case is not always TVD.
In fact, figure 4.8 shows an example where (4.101) is not satisfied, resulting into oscillatory
behavior. This particular simulation of the Buckley-Leverett problem was run with a maxi-
mum CFL number of 3. The right plot shows the solution profile at different time steps. We
observe bounded oscillations near the leading edge, due to the transition from an implicit
region to an explicit region. These oscillations are damped by the numerical diffusion, but
new overshoots can appear at each time step. Therefore this particular oscillatory behavior
does not amplify, nor does it die away. It simply moves with the saturation front and remains
bounded.
44 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
To understand the origin of these oscillations, let us analyze the situation shown in the left
plot of figure 4.8, where the numerical solution is plotted at the end of two successive time
steps. At t = tn the solution is monotonically decreasing and since (4.98) holds, all the
blocks to the right of block p are chosen to be explicit for the next time step. In particular,
for the first explicit block we have νnp+1/2 ≤ 1, but it turns out that (a posteriori) ν
n+1/2p > 1.
More precisely, we can check on the fractional flow curve that νnp+1/2 ≈ 1 and ν
n+1/2p ≈ 2.5.
Since [sn+1p − sn+1
p−1 ] < 0, it follows from (4.102) that [sn+1p+1 − sn+1
p ] > 0, as observed in the
solution profile at t = tn+1. Hence our previous analysis explains the creation of oscillations.
Recalling that the standard AIM disretization is locally conservative, we can simply interpret
this phenomenon in terms of mass conservation. Indeed the mass flowing through the I-E
boundary at the leading edge is entirely accumulated in the first explicit block because the
outgoing flux from this block is almost zero. As a result, for a large enough time step the
mass accumulated in this particular block can lead to a significant overshoot. Note that this
particular issue at the I-E boundary is not related to the inconsistency that was discussed
earlier. In fact, this behavior can arise even for a method that is consistent at the I-E
boundaries.
0.5 0.55 0.6 0.65 0.70
0.1
0.2
0.3
0.4
0.5
x
Sw
IMPLICIT EXPLICITp−1 p p+1 p+2
AIM−STD, t=tn
AIM−STD, t=tn+1
MOC
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
x
Sw
MOCAIM−STD−UW1
Figure 4.8: Test of AIM-STD in the quasi-linear homogeneous case. The left plot shows the
standard AIM solution at two successive time steps when the monotonicity condition (4.106) is
violated. The time evolution of this oscillatory behavior can be observed in the right plot for a
Buckley-Leverett problem.
4.3. MONOTONICITY PROPERTIES 45
It follows from (4.104) that a sufficient condition to guarantee (4.101) is that νn+ 1
2p ≤ 1. This
condition is satisfied if we impose the following CFL-like condition on the first explicit block
(in addition to the classical CFL condition):
maxs∈[sn
p ,sn+1p ]
|f ′(s)| ∆t
∆x≤ 1 . (4.106)
This additional restriction is natural because the ingoing flux for the first explicit block is
calculated implicitly. However, (4.106) cannot be verified a priori since the value sn+1p is
computed implicitly (i.e., not known at the beginning of the time step).
In practice the oscillatory behavior can be avoided by using the maximum wave speed every-
where, i.e., max[0,1] |f ′(s)|, to determine which blocks should be explicit. But this approach
does not take full advantage of AIM because some blocks end up being solved implicitly
although they could be treated explicitly. For instance, in the homogeneous case using a
uniform grid this method would be either fully explicit or fully implicit. Oscillations can also
be avoided by forcing the maximum saturation change to remain below a given threshold,
but, of course, this can limit the allowable time step size. To benefit as much as possible
from the AIM formulation, we recommend evaluating the local gradients everywhere in or-
der to avoid the presence of an I-E boundary in a steep region. This approach increases the
computational cost, but it can be implemented quite efficiently.
A similar analysis can be conducted in the case of a transition from an explicit to an implicit
region. Then we have
[sn+1i − sn+1
i−1 ] = (1 − νni− 1
2
)[sni − sn
i−1] + νni− 3
2
[sni−1 − sn
i−2] , i = 1, . . . , p , (4.107)
[sn+1p+1 − sn+1
p ] = (1 − νnp+ 1
2
)[snp+1 − sn
p ] + νnp− 1
2
[snp − sn
p−1] − νn+ 1
2
p+1 [sn+1p+1 − sn
p+1] , (4.108)
(1 + νn+1p+ 3
2
)[sn+1p+2 − sn+1
p+1 ] = [snp+2 − sn
p+1] + νnp+ 1
2
[snp+1 − sn
p ] + νn+ 1
2
p+1 [sn+1p+1 − sn
p+1] , (4.109)
(1 + νn+1i− 1
2
)[sn+1i − sn+1
i−1 ] = [sni − sn
i−1] + νn+1i− 3
2
[sn+1i−1 − sn+1
i−2 ] , i = p + 3, . . . ,m . (4.110)
From (4.107) and (4.110) we obtain
46 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
p∑
i=1
|sn+1i − sn+1
i−1 | ≤p∑
i=1
|sni − sn
i−1| − νnp− 1
2
|snp − sn
p−1| , (4.111)
m∑
i=p+3
|sn+1i − sn+1
i−1 | ≤m∑
i=p+3
|sni − sn
i−1| + νn+1p+ 3
2
|sn+1p+2 − sn+1
p+1 | − νn+1m− 1
2
|sn+1m − sn+1
m−1| . (4.112)
If [sn+1p+2 − sn+1
p+1 ][sn+1p+1 − sn+1
p ] ≥ 0, we have
|sn+1p+1 − sn+1
p | + (1 + νn+1p+ 3
2
)|sn+1p+2 − sn+1
p+1 | = ±[snp+1 − sn
p ] ± [snp+2 − sn
p+1] ± νnp− 1
2
[snp − sn
p−1]
≤ |snp+1 − sn
p | + |snp+2 − sn
p+1| + νnp− 1
2
|snp − sn
p−1| .(4.113)
In this case, summing (4.111), (4.112) and (4.113), we conclude that the scheme is TVD.
Otherwise, the following expression is derived from the mass conservation in block (p + 1):
[sn+1p+1 − sn
p+1] = −νnp+ 1
2
[snp+1 − sn
p ] − νn+ 1
2
p+1 [sn+1p+1 − sn
p+1]
⇒ [sn+1p+1 − sn
p+1] = −νnp+ 1
2
[snp+1 − sn
p ]/(1 + νn+ 1
2
p+1 ) . (4.114)
Substituting this expression in (4.108) and (4.109), for [sn+1p+2 − sn+1
p+1 ][sn+1p+1 − sn+1
p ] < 0, one
gets
|sn+1p+1 − sn+1
p | + (1 + νn+1p+ 3
2
)|sn+1p+2 − sn+1
p+1 | = ±(
1 − 2νnp+ 1
2
/(1 + νn+ 1
2
p+1 ))
[snp+1 − sn
p ]
± νnp− 1
2
[snp − sn
p−1] ∓ [snp+2 − sn
p+1] .
Therefore
|sn+1p+1 − sn+1
p | + (1 + νn+1p+ 3
2
)|sn+1p+2 − sn+1
p+1 | ≤|1 − 2νnp+ 1
2
/(1 + νn+ 1
2
p+1 )||snp+1 − sn
p |
+ νnp− 1
2
|snp − sn
p−1| + |snp+2 − sn
p+1| . (4.115)
To conclude that the scheme is also TVD in this case, we need to show that νnp+ 1
2
≤ 1+νn+ 1
2
p+1 .
Note that in general νnp+ 1
2
> 1 because the (p + 1)-th block is implicit. From (4.114) this is
equivalent to showing that |sn+1p+1−sn
p+1| ≤ |snp+1−sn
p |. Below we give a proof by contradiction.
4.3. MONOTONICITY PROPERTIES 47
Let us assume for instance that snp ≤ sn
p+1. If we had |sn+1p+1 − sn
p+1| > |snp+1 − sn
p |, then either
sn+1p+1 < sn
p or sn+1p+1 > 2sn
p+1 − snp . In the first case, since f ′ ≥ 0 we would have fn+1
p+1 ≤ fnp and
thus sn+1p+1 = sn
p+1 − λ[fn+1p+1 − fn
p ] > snp+1 ≥ sn
p , which is a contradiction. In the second case,
sn+1p+1 > 2sn
p+1 − snp implies sn+1
p+1 > snp , which in turn implies sn+1
p+1 = snp+1 − λ[fn+1
p+1 − fnp ] <
snp+1 ≤ 2sn
p+1 − snp , hence the contradiction.
We also obtain contradictions in the case snp > sn
p+1, so we conclude that the inequality
|sn+1p+1 − sn
p+1| ≤ |snp+1 − sn
p | is always true, which implies that νnp+ 1
2
≤ 1 + νn+ 1
2
p+1 , as claimed.
In conclusion, the inequality (4.113) is always true, i.e., the discretization is always TVD
across an explicit-implicit boundary, as opposed to an implicit-explicit boundary. This result
is expected because our interpretation in terms of mass accumulation is only valid at the
transition between implicit and explicit blocks. For an explicit-implicit boundary, the mass
accumulation over one time step in the first implicit block cannot exceed the mass difference
with the upstream block (i.e., the last explicit block), which guarantees that the TVD
property is preserved.
Note that we can also give a direct proof of |sn+1p+1 − sn
p+1| ≤ |snp+1 − sn
p | by introducing
g(x) = x + λf(x). Then we have g(sn+1p+1 ) = g(sn
p) + snp+1 − sn
p , and since f ′ ≥ 0, g is strictly
increasing, thus invertible, and its inverse is also strictly increasing. If snp+1 ≤ sn
p it follows
that
sn+1p+1 = g−1(g(sn
p) + snp+1 − sn
p ) ≤ g−1(g(snp)) = sn
p , (4.116)
and thus sn+1p+1 = sn
p+1 − λ[fn+1p+1 − fn
p ] ≥ snp+1 because fn+1
p+1 ≤ fnp . Hence we have shown that
snp+1 ≤ sn+1
p+1 ≤ snp . Similarly, if sn
p+1 ≥ snp we obtain that sn
p ≤ sn+1p+1 ≤ sn
p+1, which completes
the proof.
4.3.4 TVD property in the heterogeneous case
In the heterogeneous case, the classical CFL condition becomes
maxs∈[sn
i−1,sn
i ]|f ′(s)| ∆t
φi∆x≤ 1 , (4.117)
where φi is the porosity in the i-th block. As before, even if this condition is met in all the
explicit blocks, the TVD property is not guaranteed. At the transition from an implicit to
an explicit region, we need an additional condition like (4.106), namely:
48 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
maxs∈[sn
p ,sn+1p ]
|f ′(s)| ∆t
φp+1∆x≤ 1 . (4.118)
Here φp+1 is the porosity in the first explicit block, which also appears in the CFL condition
satisfied by this block (take i = p + 1 in (4.117)). So the presence of heterogeneities does
not increase the risk of violating (4.118). But the heterogeneous case is more likely to create
more oscillations than the homogeneous case, because the number of I-E boundaries generally
increases and the change in saturation in the last implicit block is more likely to be large.
Finally we note that the standard AIM discretization is still TVD in the non-homogeneous
linear case because f ′(s) = 1, for which the additional condition (4.118) is automatically
satisfied.
Figure 4.9 shows the simulation of a Buckley-Leverett problem in the heterogeneous case
using the standard AIM scheme. Here the porosity values were randomly sampled from a
log-normal distribution, as shown in the left plot. The reference solution was computed fully
implicitly on a fine grid. In this case, standard AIM produces a large overshoot near the lead-
ing edge. This non-monotonic behavior is similar to what we observed in the homogeneous
case.
0 0.2 0.4 0.6 0.8 10
2
4
6
8
10
12
xD
No
rma
lize
d p
oro
sity (
φ/φ m
)
Coarse scaleFine scale
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
ReferenceAIM−STD−UW1
Figure 4.9: Test of AIM-STD in the quasi-linear heterogeneous case. The left plot shows the
log-normal porosity distribution used for the fine scale (reference) and coarse scale simulations. In
the right plot, the standard AIM solution is compared against the reference solution. We observe a
large overshoot near the leading edge, due to the violation of (4.118).
4.4. CONSISTENCY FIX 49
4.4 Consistency fix
Referring again to figure 4.1, the most natural approach to preserve the consistency at the
I-E boundary would be to evaluate the ingoing flux of the first explicit block at the old time
level. In other words, for block (i0) we would use fni0−1 instead of fn+1
i0−1 in (4.3). But this
approach clearly leads to a mass balance error. Indeed, the fluxes from (i0 − 1) to (i0) and
from (i0) to (i0 − 1) do not exactly match because one is evaluated at tn and the other one
at tn+1. One could still conserve mass by distributing this error to the other blocks, but
this procedure would be unreliable in practice, and it cannot be generalized to high-order
schemes.
Another way to preserve both consistency and mass conservation at the I-E boundary is to
evaluate the numerical flux as a weighted average of intermediate time levels, using the same
weights everywhere. For instance, we can use the time levels n and n+1, with the respective
weights θ and 1 − θ, where θ is a parameter between 0 and 1. Hence in the implicit region
we apply
sn+1i = sn
i − ∆t
∆x
{
θ(fn+1i − fn+1
i−1 ) + (1 − θ)(fni − fn
i−1)}
, (4.119)
while in the explicit region we have
sn+1i = sn
i − ∆t
∆x
{
θ(f ∗i − f ∗
i−1) + (1 − θ)(fni − fn
i−1)}
, (4.120)
where f ∗i is evaluated with an explicit predictor of sn+1
i . For an explicit block that has an
implicit block to its left, the scheme would be:
sn+1i = sn
i − ∆t
∆x
{
θ(f ∗i − fn+1
i−1 ) + (1 − θ)(fni − fn
i−1)}
, (4.121)
and a similar “hybrid” scheme would be applied to an implicit block that has an explicit
block to its left. As a predictor, we can simply use
s∗i = sni − ∆t
∆x(fn
i − fni−1) . (4.122)
The resulting scheme is clearly conservative and consistent, including at the I-E boundaries.
The leading terms of the truncation errors in the explicit and implicit regions are the same,
and are given by
50 CHAPTER 4. NUMERICAL ANALYSIS OF STANDARD AIM
Eni =
[
(1
2− θ)∆t − ∆x
2
]
(sxx)ni , (4.123)
whereas for an explicit block that has an implicit block to its left we have
Eni =
[
(1
2− θ)∆t − ∆x
2− θ∆t
∆x(∆t − ∆x)
]
(sxx)ni . (4.124)
As expected, for θ = 1/2 in (4.123), the scheme is second-order accurate in time (Crank-
Nicolson). Also, for a fully explicit version, when θ = 0 and ∆t = ∆x, we find that the
scheme is second-order accurate (in fact it even reproduces exactly the solution). In general,
(4.123) suggests that in the explicit regions, where ∆t ≤ ∆x, our modified AIM scheme has
more numerical dispersion than the standard AIM scheme, whereas in the implicit regions
the numerical dispersion would be reduced.
In order to analyze the stability and oscillatory properties of this scheme in the implicit
regions for the linear case, let us write (4.119) as follows:
(1 + θλ)sn+1i − θλsn+1
i−1 = (1 − (1 − θ)λ)sni + (1 − θ)λsn
i−1 , (4.125)
where λ = ∆t/∆x. A Von Neumann analysis shows that the amplification factor is
|G(φ)| =[1 − (1 − θ)λ(1 − cos φ)] − i(1 − θ)λ sin φ
[1 + θλ(1 − cos φ)] + iθλ sin φ, (4.126)
where φ = k∆x. It is straightforward to show that the condition |G(φ)| ≤ 1 for all φ ∈ R
is equivalent to (1 − 2θ)λ ≤ 1. So the scheme is unconditionally stable for θ ≥ 1/2, while
for θ < 1/2, the stability condition is λ < 1/(1 − 2θ). On the other hand, one can show
that this scheme is TVD (Total Variation Diminishing) for λ < 1/(1 − θ). So by fixing the
inconsistency, we introduced a more restrictive CFL condition (note that the standard AIM
scheme is unconditionally TVD in the implicit regions because it corresponds to the case
θ = 1).
In the explicit regions, we can write (4.120) as follows:
sn+1i = sn
i − λ(sni − sn
i−1) + θλ2(sni − 2sn
i−1 + sni−2) , (4.127)
so the maximum principle is satisfied if and only if the following inequalities hold:
0 ≤ θλ2 ≤ 1 , 0 ≤ λ(1 − 2θλ) ≤ 1 , 0 ≤ θλ2 − λ + 1 ≤ 1 . (4.128)
4.4. CONSISTENCY FIX 51
Hence we obtain the conditions:
λ ≤ 1
2θ, if
1
4≤ θ ≤ 1, (4.129)
λ ≤ 1
2θ−
√1 − 4θ
2θ, if 0 ≤ θ <
1
4. (4.130)
Again, for θ > 1/2, the CFL condition becomes more restrictive than for the explicit Upwind
scheme. If for instance we choose θ = 0.9, then we can use CFL numbers up to 10 in the
implicit region and CFL numbers up to 5/9 in the explicit region. So the inconsistency can
be fixed, but under more restrictive CFL conditions. Note however that a different choice
for the predictor may improve the CFL limits.
We conclude this section with a useful interpretation of our consistency fix. Note that
(4.119), (4.120) and (4.121) amount to applying
sn+1i = sn
i − ∆t
∆x
{
θ(f n+1i − f n+1
i−1 ) + (1 − θ)(fni − fn
i−1)}
. (4.131)
Here n + 1 refers to the new time level. More precisely we have
f n+1i = f(sn+1
i ), where sn+1i =
{
sn+1i if (i) is implicit,
sni − ∆t
∆x(fn
i − fni−1) otherwise.
(4.132)
Hence we are applying the implicit θ-scheme everywhere, except that for the flux component
that depends on the new time level, we use an explicit predictor at every explicit node. As we
will see in the next chapter, this idea can be generalized to derive high-order AIM schemes.
Chapter 5
Construction of high-order AIM
5.1 Requirements and methodology
We recall that a numerical method is said to be adaptive implicit if any individual variable in
a block can be treated either implicitly or explicitly, in such a way that the implicit variables
are decoupled from the explicit ones. In this last chapter, our objective is to construct a
class of adaptive implicit methods satisfying the following requirements:
• Second or higher order of accuracy, both in time and space
• Unconditional stability in the implicit regions
• Local mass conservation
Note that the first condition implies that the scheme must be consistent at the I-E boundaries
because as demonstrated earlier, a local inconsistency would lead to a first-order error.
Therefore we need to combine high-order implicit and explicit time integration schemes in a
fully consistent manner. Here we do not impose any conditions regarding the positivity or
other monotonicity properties of the method. These properties will be discussed further in
this chapter.
Our general methodology for the construction of high-order AIM is based on: (1) using
a high-order MOL scheme as a basic framework, and (2) applying the consistency fix to
preserve the accuracy at the I-E boundaries.
Based on the implicit MOL schemes presented in Appendix A, AIM versions of those schemes
were implemented in our Matlab code (they will be presented in the next sections). Below is
52
5.1. REQUIREMENTS AND METHODOLOGY 53
a list of the first-order and high-order AIM schemes available, with their abbreviated names
in parenthesis:
- Standard AIM scheme (AIM-STD),
- AIM based on Backward Euler (AIM-BE),
- AIM based on Trapezoidal Runge-Kutta of order 2 (AIM-TRK2),
- AIM based on Centered Runge-Kutta of order 2 (AIM-CRK2),
- AIM based on Implicit Runge-Kutta of order 2 (AIM-IRK2),
- AIM based on DIRK scheme of order 3 (AIM-DIRK3),
- AIM based on BDF scheme of order 2 (AIM-BDF2).
Like the implicit MOL schemes, these AIM schemes can be combined with any type of
spatial discretization. The naming convention is the same as previously - for example the
AIM-TRK2-WENO2 scheme combines the AIM version of the implicit trapezoidal rule with
the second-order WENO flux. The implementation of these AIM schemes requires the rou-
tine CalcMaxSpeed, in which the local CFL numbers are evaluated for each grid block and
then used to determine the implicit blocks. Finally, given the purpose of this code, our im-
plementation was kept as simple as possible, making it flexible and easy to understand. For
example, the equations for the implicit and explicit blocks are assembled and solved together,
although they could be decoupled to gain efficiency (which is usually the main goal of AIM).
But we recall that the objective of this simple 1D code is primarily to test the accuracy of
high-order AIM. This is why we did not try to optimize the memory management, nor to
minimize the computational cost.
The next sections are organized as follows. First we present an extension of standard AIM
with high-order spatial accuracy, and we apply our consistency fix to improve the accuracy
at the I-E boundaries. Then we derive a class of fully high-order (i.e., both in space and
time) AIM schemes. Finally we investigate the possibility of improving the monotonicity
restrictions by applying artificial viscosity.
54 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
5.2 AIM with high-order spatial accuracy
5.2.1 Numerical formulation
Given a high-order numerical flux Fi+ 1
2
, we define the following scheme based on AIM-STD:
sn+1i = sn
i − ∆t
∆x
(
F n∗i+ 1
2
− F n∗i− 1
2
)
, (5.1)
where
F n∗i+ 1
2
= Fi+ 1
2
(sn∗), sn∗i =
{
sn+1i if (i) is implicit
sni otherwise.
(5.2)
This scheme can be seen as an extension of standard AIM because the time integration
schemes in the explicit and implicit regions are, respectively, Forward Euler and Backward
Euler. As required, it is mass conservative and unconditionally stable in the implicit regions.
Due to the Backward Euler method it is also unconditionally TVD or non-oscillatory, de-
pending on the spatial discretization. Although globally first-order accurate, this scheme is
expected to be less dispersive than standard AIM because of its higher spatial resolution.
But it is important to recognize that due to the low-order time resolution, there is no point
in applying a numerical flux that is more than second-order accurate.
Below we propose another adaptive implicit approach that is not only highly accurate in
space, but also consistent at the I-E boundaries. The idea is to use the Backward Euler
method as a time integration framework for both the implicit and explicit regions. To
illustrate this consistency fix, let us consider a boundary between an implicit block (i) and
an explicit block (i + 1). For a second-order accurate numerical flux, the stencil generally
consists of the four nodes (i−1), (i), (i+1) and (i+2). Here the blocks (i+1) and (i+2) are
labeled as explicit, so we are not allowed to use implicit values. Instead we propose to use
explicit predictors, i.e., the numerical flux corresponding to t = tn+1 is evaluated as follows:
F n+1i+ 1
2
= Fi+ 1
2
(sn+1i−1 , sn+1
i , s∗i+1, s∗i+2) , (5.3)
where the superscript n + 1 refers to the time level n + 1 and (∗) to a predictor for tn+1.
This approach leads to the following scheme (AIM-BE):
sn+1i = sn
i − ∆t
∆x
(
F n+1i+ 1
2
− F n+1i− 1
2
)
, (5.4)
5.2. AIM WITH HIGH-ORDER SPATIAL ACCURACY 55
where
F n+1i+ 1
2
= Fi+ 1
2
(sn+1), sn+1i =
{
sn+1i if (i) is implicit
s∗i otherwise.(5.5)
The predictor s∗i of sn+1i must be explicit and at least first-order accurate. It can be given for
instance by (4.122). This AIM-BE scheme benefits from the high-order numerical flux more
than AIM-STD because the time integration is consistent at the I-E boundaries (a proof
is given in the next section). Meanwhile it remains unconditionally non-oscillatory in the
implicit regions. Note that this property was not required in our introductory discussion,
but it is highly desirable in practice. The only drawback of this consistency fix is that the
maximum CFL number in the explicit regions is 1/2 instead of 1 (cf. section 4.4).
Finally, another option is to define a hybrid scheme using Backward Euler in the implicit
regions and a high-order time integration method in the explicit regions. For example, using
the trapezoidal rule in the explicit regions, we obtain the following scheme (AIM-BE/TRK2):
sn+1i = sn
i − ∆t
2∆x
(
F n+1i+ 1
2
− F n+1i− 1
2
)
− ∆t
2∆x
(
F n∗i+ 1
2
− F n∗i− 1
2
)
, (5.6)
where F n+1i+ 1
2
and F n∗i+ 1
2
are defined like in (5.2) and (5.5). The advantage of this approach
is to achieve second-order accuracy in the explicit regions, while unconditional positivity is
maintained in the implicit regions. This scheme is not consistent at the I-E boundaries but
the discretization errors at the I-E boundaries are smaller than in the case of AIM-STD.
Indeed, there is only a discrepancy of half a time step between the flux evaluations in the
implicit and explicit regions, instead of a full time step discrepancy. Moreover, the CFL
condition in the explicit regions is given by CFL≤ 1, which is less restrictive than in the
case of AIM-BE. So besides improving accuracy, this approach appears like a reasonable
compromise between AIM-STD and AIM-BE.
5.2.2 Numerical tests
Figures 5.1, 5.2 and 5.3 below show the results of 1D simulations using the AIM-STD-FL2,
AIM-BE-FL2 and AIM-BETRK2-FL2 schemes, which correspond respectively to (5.1), (5.4)
and (5.6), with a second-order accurate flux limiting spatial discretization. This test is a
Buckley-Leverett problem with a mobility ratio M = 5, and the numerical solutions are
56 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
plotted at 0.3 PVI (Pore Volume Injected). In each figure, the exact solution (MOC) and
the standard AIM solution (AIM-STD-UW1) are also plotted for comparison.
As expected, the AIM-STD-FL2, AIM-BE-FL2 and AIM-BE/TRK2-FL2 schemes are more
accurate than standard AIM. However, only the spatial resolution is improved, i.e., the time
integration remains first-order accurate, so the gain in accuracy is relatively small.
In the case of AIM-STD-FL2, we observe a substantial loss of accuracy across the I-E bound-
ary. This behavior is related to the local inconsistency discussed earlier, which is still present
in this extension of standard AIM. But due to its higher spatial resolution, the AIM-STD-
FL2 scheme produces even larger “kinks” than standard AIM. This clearly shows that there
is no benefit of using a high-order numerical flux when the time integration is not consistent
across the I-E boundaries.
0 0.2 0.4 0.6 0.8 10.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
xD
Sw
MOCAIM−STD−UW1AIM−STD−FL2
Figure 5.1: Test of the AIM-STD-FL2 scheme against standard AIM. For this Buckley-Leverett
problem, the mobility ratio is M = 5. Due to the inconsistency in the time integration, both the
AIM-STD-UW1 and AIM-STD-FL2 schemes produce a “kink” at the I-E boundary. But this “kink”
is larger for the AIM-STD-FL2 scheme because of the high-order spatial discretization.
5.2. AIM WITH HIGH-ORDER SPATIAL ACCURACY 57
As opposed to AIM-STD-FL2, the AIM-BE-FL2 scheme does not create any artificial kinks
at the I-E boundaries. Indeed, the AIM-BE method is fully consistent, which is a clear
advantage over AIM-STD. But the CFL restriction for the explicit blocks is more severe,
hence a larger number of implicit blocks is required.
0 0.2 0.4 0.6 0.8 10.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
xD
Sw
MOCAIM−STD−UW1AIM−BE−FL2
Figure 5.2: Test of the AIM-BE-FL2 scheme against standard AIM. For this Buckley-Leverett
problem, the mobility ratio is M = 5. This AIM-BE-FL2 scheme is consistent at the I-E boundaries,
but the CFL restriction in the explicit regions is more severe.
In spite of a very small “kink” at the I-E boundary, the AIM-BE/TRK2-FL2 scheme produces
a slightly more accurate solution than AIM-BE-FL2. In particular, the loss of accuracy across
the I-E boundary is even smaller than in the case of standard AIM. These observations
confirm the properties of the AIM-BE/TRK2 method, as discussed in 5.2.1. Moreover,
this method requires fewer implicit blocks than AIM-BE (because the stability condition is
CFL≤ 1 instead of CFL≤ 1/2), so we conclude that it is more efficient.
58 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
0 0.2 0.4 0.6 0.8 10.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
xD
Sw
MOCAIM−STD−UW1AIM−BE/TRK2−FL2
Figure 5.3: Test of the AIM-BE/TRK2-FL2 scheme against standard AIM. For this Buckley-
Leverett problem, the mobility ratio is M = 5. This AIM-BE/TRK2 method only produces a slight
“kink” at the I-E boundaries, while the CFL condition in the explicit regions remains the same as
in the standard AIM case.
5.3 Fully high-order AIM
5.3.1 Numerical formulation
In order to meet all the requirements listed in section 5.1, we still need to achieve high-order
time accuracy. To illustrate the construction of fully high-order AIM, we first introduce a
family of second-order AIM schemes based on the implicit trapezoidal rule:
sn+1i = sn
i − ∆t
2∆x
(
F ni+ 1
2
− F ni− 1
2
)
− ∆t
2∆x
(
F n+1i+ 1
2
− F n+1i− 1
2
)
F n+1i+ 1
2
= Fi+ 1
2
(sn+1), sn+1i =
{
sn+1i if (i) is implicit
s∗i otherwise.
(5.7)
As before, Fi+ 1
2
is a second-order numerical flux, n + 1 refers to the time level n + 1 and
s∗i is an explicit predictor of sn+1i . Since a high-order numerical flux is available, instead of
(4.122) we can use
5.3. FULLY HIGH-ORDER AIM 59
s∗i = sni − ∆t
∆x(F n
i+ 1
2
− F ni− 1
2
) . (5.8)
At this point, we would like to make sure that all our requirements are met. First, our
AIM-TRK2 scheme is written in conservative form, hence it conserves mass. Besides, it is
unconditionally stable in the implicit regions since the underlying MOL scheme satisfies this
property. Finally, provided that a second-order accurate numerical flux and the predictor
(5.8) are applied, this scheme is fully second-order accurate in the implicit and explicit regions
because it amounts to the classical implicit and explicit trapezoidal rules. Therefore, the
only thing left to check is the order of accuracy near the I-E boundaries. For this purpose, we
consider the configuration depicted in figure 4.1, and we propose to evaluate the truncation
error for block (i). Assuming that information propagates from left to right, i.e., f ′ ≥ 0, we
have
Fi+ 1
2
(s) = F (si−1, si, si+1) ,
Fi− 1
2
(s) = F (si−2, si−1, si) .(5.9)
Here the numerical flux function depends on three variables, i.e., F ≡ F (u, v, w). Let s be
the exact solution, sni = s(xi, t
n), then by definition the truncation error is given by
Eni =
sn+1i − sn
i
∆t+
1
2∆x
[
F ni+ 1
2
− F ni− 1
2
]
+1
2∆x
[
F n+1i+ 1
2
− F n+1i− 1
2
]
. (5.10)
Applying the predictor (5.8) we have
s∗i = sni − ∆t
(
[f(s)x]ni + O(∆x2)
)
= sni + ∆t(st)
ni + O(∆t∆x2)
⇒ s∗i = sn+1i − 1
2∆t2(stt)
ni + O(∆t3) + O(∆t∆x2) , (5.11)
and in particular, s∗i = sn+1i + O(∆t2). Since F n+1
i− 1
2
= F (sn+1i−2 , sn+1
i−1 , s∗i ) we can write
F n+1i− 1
2
= F n+1i− 1
2
+(∂F
∂w
)n+1
i− 1
2
(s∗i − sn+1i ) + O(∆t4) , (5.12)
and similarly, from F n+1i+ 1
2
= F (sn+1i−1 , s∗i , s
∗i+1) it follows that
F n+1i+ 1
2
= F n+1i+ 1
2
+(∂F
∂v
)n+1
i+ 1
2
(s∗i − sn+1i ) +
(∂F
∂w
)n+1
i+ 1
2
(s∗i+1 − sn+1i+1 ) + O(∆t4) . (5.13)
60 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
Combining (5.12) and (5.13) we obtain
F n+1i+ 1
2
− F n+1i− 1
2
∆x=
F n+1i+ 1
2
− F n+1i− 1
2
∆x+
1
∆x
{(∂F
∂v
)n+1
i+ 1
2
(s∗i − sn+1i ) (5.14)
+(∂F
∂w
)n+1
i+ 1
2
(s∗i+1 − sn+1i+1 ) −
(∂F
∂w
)n+1
i− 1
2
(s∗i − sn+1i )
}
+ O(∆t4/∆x) . (5.15)
Since (5.11) is valid for blocks (i) and (i+1), the term within brackets is O(∆t2). Therefore
Eni =
sn+1i − sn
i
∆t+
1
2∆x
[
F ni+ 1
2
− F ni− 1
2
]
+1
2∆x
[
F n+1i+ 1
2
− F n+1i− 1
2
]
+ O(∆t2/∆x) . (5.16)
We recognize this expression as the truncation error of the implicit trapezoidal rule, plus
an error term due to the substitution of implicit values by explicit predictors. As shown in
section 3.3, the implicit trapezoidal rule is second-order accurate in time. Since we also have
second-order accuracy in space, it yields
Eni = O(∆t2) + O(∆x2) + O(∆t2/∆x) . (5.17)
This result shows that for ∆t = O(∆x) the scheme is consistent at the I-E boundaries. But
while the scheme is second-order accurate in the explicit and implicit regions, the order of
accuracy at the I-E boundaries reduces to one. In general this order reduction only occurs
locally at a few locations, so the global order of the scheme still equals two. Otherwise, if
the total number of I-E boundaries is significant compared to the number of grid blocks,
the accuracy can be maintained by using a second-order predictor (note that (5.8) is second-
order accurate in space but only first-order accurate in time), which leads to a slightly higher
computational cost.
Remark: by applying the same analysis in the explicit region, the term within brackets of
(5.14) would have 6 derivatives of F , which can be paired up so that this term becomes
O(∆t2∆x) instead of O(∆t2). Thus the final truncation error is Eni = O(∆t2) + O(∆x2).
This result is expected because the scheme in the explicit region amounts to the explicit
trapezoidal rule which is known to be second-order accurate.
Similarly, we can derive a family of second-order AIM schemes based on the implicit midpoint
rule. In this case n + 1/2 refers to the time level n + 1/2:
5.3. FULLY HIGH-ORDER AIM 61
sn+1i = sn
i − ∆t
∆x
(
Fn+1/2
i+ 1
2
− Fn+1/2
i− 1
2
)
Fn+1/2
i+ 1
2
= Fi+ 1
2
(sn+1/2), sn+1/2i =
{
12(sn
i + sn+1i ) if (i) is implicit
12(sn
i + s∗i ) otherwise.
(5.18)
If we choose the predictor (5.8), then we can check that the time integration method in the
explicit regions corresponds to the explicit midpoint rule which is second-order accurate.
The different remarks made for the AIM-TRK2 scheme are still valid for this AIM-CRK2
scheme.
The same methodology can be applied to derive higher order AIM schemes. Below we give
the general formulation of a third-order AIM scheme based on the DIRK3 method (using
γ = 1/2 +√
3/6):
sn+1i = sn
i − ∆t2∆x
(
F(1)
i+ 1
2
− F(1)
i− 1
2
)
− ∆t2∆x
(
F(2)
i+ 1
2
− F(2)
i− 1
2
)
s(1)i = sn
i − γ ∆t∆x
(
F(1)
i+ 1
2
− F(1)
i− 1
2
)
s(2)i = sn
i − (1 − 2γ) ∆t∆x
(
F(1)
i+ 1
2
− F(1)
i− 1
2
)
− γ ∆t∆x
(
F(2)
i+ 1
2
− F(2)
i− 1
2
)
(5.19)
where
F(1)
i+ 1
2
= Fi+ 1
2
(s(1)), s(1)i =
{
s(1)i if (i) is implicit
s∗,(1)i otherwise,
(5.20)
and a similar definition holds for F(2)
i+ 1
2
. Here we apply a third-order numerical flux, such
as ENO3, and s∗,(1), s∗,(2) are explicit predictors of order two, respectively for the times
t(1) = tn + γ∆t and t(2) = tn + (1 − γ)∆t.
The high-order AIM schemes presented above require the following three-step approach:
(1) Apply a predictor step in the explicit blocks
(2) Assemble and solve the system for the implicit blocks
(3) Update the solution in the explicit blocks
In terms of computational time, steps (1) and (3) are cheap, whereas step (2) is generally
expensive because it requires the solution of a system of nonlinear equations. For this
purpose, we can apply the Newton-Raphson method. Note that there are mainly two factors
that explain the additional computational cost of high-order AIM compared to standard
62 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
AIM. First, the high-order time integration method may require the solution of several
systems of nonlinear equations in the same time step (e.g., in DIRK3), or to solve a larger
system if the sub-steps of the time integration are coupled (e.g., in IRK2). Secondly, for
each Newton step, the Jacobian has a larger band width than in the first-order case because
the high-order spatial discretization leads to a larger numerical stencil, especially for multi-
dimensional problems.
5.3.2 Numerical tests
1D Buckley-Leverett problem
This first test problem is the same as that presented in Appendix A. Figure 5.4 shows two
numerical solutions computed with the second-order accurate AIM-CRK2-WENO2 scheme.
The left and right plots corresponds respectively to CFL < 2 and CFL > 2. In the first
case, the numerical solution is very accurate, even near the leading edge, and there is no
kink at the I-E boundaries. But for CFL > 2, overshoots are produced just behind the
saturation front. This result is expected because the implicit trapezoidal rule is known to
become oscillatory for CFL > 2.
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
CFL=1.5
EXPLICIT IMPLICIT EXPLICIT
MOCAIM−STD−UW1AIM−CRK2−WENO2
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
CFL=2.5
EXPLICIT IMPLICIT EXPLICIT
MOCAIM−STD−UW1AIM−CRK2−WENO2
Figure 5.4: Test of the AIM-CRK2-WENO2 scheme. For CFL<2 the AIM-CRK2 method pro-
duces very accurate results, but for CFL>2 the monotonicity restriction is violated.
5.3. FULLY HIGH-ORDER AIM 63
2D miscible flow problem
For this test problem, we consider the incompressible single-phase flow of two components in
a porous medium. The medium is assumed to be homogeneous, diffusion and gravity effects
are neglected, and the fluid viscosity is constant. The problem geometry corresponds to a
quarter five-spot pattern, i.e., there is one injector (rate +q) and one producer (rate −q)
located at (x, y) = (0, 0) and (x, y) = (L,L). No-flow conditions are imposed along the four
edges of the square. The mathematical statement of this problem is the following:
∇ · v = q , v = − 1
µK · ∇p (5.21)
φ∂c
∂t+ ∇ · (cv) = 0 (5.22)
The two unknowns of the problem are the pressure p and the miscible component concen-
tration c. The pressure and the velocity field are constant in time so they are solved only
once at the beginning of the simulation, as opposed to the concentration, which satisfies a
time dependent PDE. The initial concentration is taken to be uniform, i.e., c(x, y, 0) = c0,
and the boundary condition is given by v · n = 0. Assuming that the permeability tensor is
diagonal in the (x, y) coordinate system, this condition is equivalent to ∂p/∂n = 0. We also
need a boundary condition for the concentration because our high-order flux discretization
uses a 4-point stencil (i.e., it does not only use the upstream concentration). By symmetry
of the five spot pattern, we simply have ∂c/∂n = 0.
In figure 5.5 we show a reference solution computed on a 50 × 50 grid using the forward
Euler scheme. The left contour plot represents the pressure solution and the right contour
plot the concentration profile calculated at Tf = 2x106 s. For this simulation, the injection
rate is qw = 10−3 m3/s, the length of the square is L = 100 m, the reservoir depth h = 1 m,
the viscosity µ = 1 cp, the porosity φ = 0.3, and the permeability tensor is diagonal with
kx = ky = 100 md. The final time corresponds to 2/3 pore volumes injected (PVI).
Note that an analytical solution is also available for the potential (or normalized pressure),
which is given by
Φ(x, y) = ln
(
1 − cn2(x)cn2(y)
cn2(x) + cn2(y)
)
, (5.23)
where cn is the elliptic cosine function of modulus k = 1/√
2 (see [21], [22] for details).
64 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
−2
−1.5
−1
−0.5
0
0.5
1
1.5
2
x 107
20 40 60 80
20
40
60
80
x
y
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
20 40 60 80
20
40
60
80
x
yFigure 5.5: Reference solution in a quarter five-spot. The left plot shows the pressure map with
the velocity field. In the right plot, the saturation profile is given for PVI = 2/3.
Our high-order AIM implementation is based on the implicit Θ-Scheme. Thus the residual
takes the following form:
Rn+1i,j = Vp[c
n+1i,j − cn
i,j] + θ∆t([
(Hx)n+1i+ 1
2,j− (Hx)n+1
i− 1
2,j
]
+[
(Hy)n+1i,j+ 1
2
− (Hy)n+1i,j− 1
2
])
+ (1 − θ)∆t([
(Hx)ni+ 1
2,j− (Hx)n
i− 1
2,j
]
+[
(Hy)ni,j+ 1
2
− (Hy)ni,j− 1
2
])
+ θ∆t(qwc )n+1
i,j + (1 − θ)∆t(qwc )n
i,j , (5.24)
where Vp is the block pore volume, i.e., Vp = φh∆x∆y, and qwc is the injection or production
rate of the miscible component. It is given by (qwc )i,j = −qwcinj in the injection block,
(qwc )i,j = qwci,j in the production block, and (qw
c )i,j = 0 in all the other blocks. The convective
fluxes Hx, Hy are defined as follows:
(Hx)i+ 1
2,j = h∆y ui+ 1
2,jF
xi+ 1
2,j
, (Hy)i,j+ 1
2
= h∆x vi,j+ 1
2
F y
i,j+ 1
2
, (5.25)
where u and v are the x and y components of the velocity field, and F xi+ 1
2,j
(resp. F y
i,j+ 1
2
) is a
high-order numerical flux evaluated along the j-th one-dimensional slice in x (resp. the i-th
one-dimensional slice in y).
The choice of the explicit blocks is based on the local CFL condition:
5.3. FULLY HIGH-ORDER AIM 65
(
ui+ 1
2,j
φ∆x+
vi,j+ 1
2
φ∆y
)
∆t ≤ γ , (5.26)
where γ is a threshold value. The above condition is easy to derive for the case θ = 0
(Forward Euler scheme), for which the theoretical threshold is γ = 1. This condition can
be applied similarly for θ > 0. In particular, for θ = 1/2, which corresponds to the explicit
trapezoidal rule, it can be shown that the theoretical threshold is still equal to one. But
in light of the results shown in section 4.5 for the 1D case, when θ > 1/2 we recommend
using the more conservative value γ = 1/2. Note that the condition (5.26) guarantees both
stability and positivity in the explicit regions; however, we must bring a special attention to
the first and last blocks where a source term or sink term is present. Below we provide a
detailed analysis for the (1, 1) block where a source term is present, assuming that this block
is treated implicitly. If the WENO2 flux is used, we have
F x3
2,1
= F (c0,1, c1,1, c2,1) ≈ c1,1 , (5.27)
because c0,1 = c1,1 and thus, referring to formula (2.21), (ω0) 3
2,1 ≈ 1, (ω1) 3
2,1 ≈ 0. Similarly
we have
F y
1, 32
= F (c1,0, c1,1, c1,2) ≈ c1,1 , (5.28)
therefore, accounting for the no-flow boundary conditions, the equation for block (1, 1) sim-
plifies to
0 = Vp[cn+11,1 − cn
1,1] + θ∆t(
h∆y ucn+11,1 + h∆x vcn+1
1,1
)
+ (1 − θ)∆t(
h∆y ucn1,1 + h∆x vcn
1,1
)
− ∆tqwcinj , (5.29)
where u = u 3
2,1 and v = v1, 3
2
. After rearrangement we obtain
cn+11,1 =
[
1 − (1 − θ)∆t( uφ∆x
+ vφ∆y
)]
cn1,1 + ∆tqwcinj
1 + θ∆t( uφ∆x
+ vφ∆y
), (5.30)
where qw = qw/Vp. But since the velocity field is locally conservative we have
66 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
u
φ∆x+
v
φ∆y= qw . (5.31)
After substitution it yields
cn+11,1 =
[1 − (1 − θ)∆tqw] cn1,1 + ∆tqwcinj
1 + θ∆tqw, (5.32)
therefore, for a constant time step size we have
cn+11,1 =
[
1 −(
1 − (1 − θ)∆tqw
1 + θ∆tqw
)n+1]
cinj +
(
1 − (1 − θ)∆tqw
1 + θ∆tqw
)n+1
c01,1 . (5.33)
It follows that the scheme is stable if and only if
∣
∣
∣
1 − (1 − θ)∆tqw
1 + θ∆tqw
∣
∣
∣ < 1 . (5.34)
The above condition is always satisfied if θ ≥ 1/2, while for θ < 1/2 it amounts to
qw∆t
Vp
<2
1 − 2θ. (5.35)
The maximum principle is guaranteed under the more restrictive condition (valid for any
value of θ):
qw∆t
Vp
<1
1 − θ. (5.36)
This result is consistent with our previous analysis of positivity for the implicit trapezoidal
rule, i.e., even though this method is unconditionally stable, it has a CFL restriction of 2
for positivity. Finally we can check that as expected, by substituting cn1,1 = cinj in (5.32), we
obtain cn+11,1 = cinj.
In summary, denoting by NImp the total number of implicit blocks, the discretization (5.24)
allows us to apply the following time integration schemes:
- TRK2/eTRK2 by choosing θ = 1/2 and NImp = 0 or NImp = nxny,
- BE/FE by choosing θ = 1 or θ = 0 and NImp = 0 or NImp = nxny,
- AIM-BE by choosing θ = 1 and NImp according to (5.26),
5.3. FULLY HIGH-ORDER AIM 67
- AIM-TRK2 by choosing θ = 1/2 and NImp according to (5.26).
The solutions reported in figures 5.6 and 5.7 below were computed with the Backward
Euler scheme and the second-order accurate AIM-TRK2-WENO2 scheme, respectively. The
simulation parameters are the same as those of the reference solution given in figure 5.5, but
the grid size is only 25 × 25. In figure 5.7, the left plot represents the distribution of the
implicit blocks (in black) once the maximum time step is reached, which corresponds here
to a maximum CFL number around 3. Meanwhile the right plot shows the contour lines of
the concentration profile computed at the final time. As expected, our second-order AIM
scheme reduces the smearing of the front substantially, because it is less dissipative that the
fully implicit method. Moreover, although the theoretical positivity limit for the trapezoidal
Runge-Kutta method is exceeded, there are no visible overshoots or undershoots.
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
20 40 60 80
20
40
60
80
x
y
Figure 5.6: Miscible flow solution using the BE-UW1 scheme. For this coarse scale simulation, the
fully implicit method leads to a large amount of numerical dispersion, as suggested by the smearing
of the front.
In terms of computational cost, the AIM-TRK2 method is more efficient than its fully
explicit or fully implicit counterparts (at least for this particular problem). It is clearly more
efficient than the implicit trapezoidal rule because the number of unknowns is considerably
reduced, while the time step restriction for positivity is the same and the second-order
68 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
accuracy is maintained (as shown in section 5.4). Less evidently, the AIM-TRK2 method
can be slightly more efficient than the explicit trapezoidal rule, but only if the number of
implicit blocks is low. Then there is only a small additional cost for solving the near-wellbore
regions implicitly, and the maximum time step size can be at least doubled while maintaining
second-order accuracy. But in general, due to the positivity restriction of high-order implicit
methods, the advantage of high-order AIM over the explicit methods is much lower than
in the first-order case (we recall that the standard AIM has no positivity restriction in the
implicit regions). In fact, in many instances, the AIM-TRK2 approach turns out to be
less efficient than second-order explicit methods. But a higher positivity restriction in the
implicit regions can be achieved by using other implicit methods such as IRK2 or DIRK3,
or, as will be shown later, by applying artificial viscosity.
grid number in x
grid
num
ber
in y
5 10 15 20 25
5
10
15
20
25
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
20 40 60 80
20
40
60
80
x
y
Figure 5.7: Miscible flow solution using the AIM-TRK2-WENO2 scheme. This second-order
accurate AIM scheme substantially improves the resolution of the miscible front. In the left plot,
we see that the implicit blocks (in black) are located near the injector and the producer.
2D Buckley-Leverett problem with gravity
In this case, we consider a 2D immiscible, incompressible flow in a homogeneous porous
medium, with gravity effects along the vertical y-axis. Capillary effects are neglected and it
is assumed that a constant and uniform velocity field is imposed along the direction θ = π/4.
5.3. FULLY HIGH-ORDER AIM 69
The mathematical formulation of this problem is
φ∂s
∂t+
∂f(s)
∂x+
∂g(s)
∂y= 0, s(x, y, 0) = s0(x, y) . (5.37)
Here the initial saturation s0 is taken equal to one inside a circle, and zero outside it. The
flux functions f and g correspond to the fractional flow curves in the x and y directions.
These curves are given in the left plot of figure 5.8. The gravity effect in the y direction
leads to a local minimum in the g function curve. In the right plot we present a reference
solution computed using Forward Euler on a 70× 70 grid, until the final time Tf = 3x105 s.
The simulation parameters are given by u = v = 10−5 for the velocity field, G = 5.0 for the
gravity number, M = 1.0 for the mobility ratio, L = 100 m, φ = 0.3. The initial saturation
was taken equal to one inside the circle of center (L/2, L/2) and radius L/4.
Applying the AIM scheme based on the implicit trapezoidal rule leads to the following
residual expression:
Rn+1i,j =[sn+1
i,j − sni,j] +
∆t
2φ∆x
(
f n+1i+ 1
2,j− f n+1
i− 1
2,j
)
+∆t
2φ∆x
(
fni+ 1
2,j− fn
i− 1
2,j
)
+∆t
2φ∆y
(
gn+1i,j+ 1
2
− gn+1i,j− 1
2
)
+∆t
2φ∆y
(
gni,j+ 1
2
− gni,j− 1
2
)
. (5.38)
Similarly, we could use the AIM scheme based on the implicit midpoint rule:
Rn+1i,j = [sn+1
i,j − sni,j] +
∆t
φ∆x
(
fn+1/2
i+ 1
2,j
− fn+1/2
i− 1
2,j
)
+∆t
φ∆y
(
gn+1/2
i,j+ 1
2
− gn+1/2
i,j− 1
2
)
. (5.39)
Here fi+ 1
2,j, gi,j+ 1
2
are high-order numerical fluxes computed along 1D slices in x and y
respectively. Importantly, in the y-direction we need a numerical flux that can account for
varying local flow directions. Hence we implemented the second-order WENO2 scheme with
local flux splitting (see section 2.3).
70 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
0 0.2 0.4 0.6 0.8 1−0.4
−0.2
0
0.2
0.4
0.6
0.8
1
Sw
Fra
ctio
nal f
low
fwg
w
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
20 40 60 80
20
40
60
80
xy
Figure 5.8: Fractional flow curves and reference solution. The left plot shows the fractional flow
curves in the x and y directions. The presence of a local minimum in the y direction is due to the
gravity effect. The right plot shows a fine scale reference solution. The evolution of the saturation
plume is governed by the combined effects of convection in the 45o direction, and of gravity in the
vertical direction.
Figure 5.9 below shows simulation results obtained with the AIM-TRK2-WENO2 scheme.
The parameters are identical to those of the reference solution, except for the grid size which
is only 35 × 35. Here, the maximum time step size was chosen to be four times larger than
in the case of the Forward Euler simulation. Since the grid size was divided by two in both
directions, it means that the maximum CFL number is twice as large. The left plot represents
the distribution of implicit blocks (in black) during the last time step. In the right plot, we
reported the contour lines of the saturation profile at the final time. This solution compares
fairly well with the reference solution. Like in the miscible case problem, the AIM-TRK2
scheme is quite efficient for this two-dimensional problem because the number of implicit
blocks is small. But there is no significant gain in computational time compared to the
explicit method, unless a larger time step can be used without violating the monotonicity
restriction in the implicit regions.
5.4. HIGH-ORDER AIM WITH ARTIFICIAL VISCOSITY 71
grid number in x
grid
num
ber
in y
10 20 30
5
10
15
20
25
30
35
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
20 40 60 80
20
40
60
80
xy
Figure 5.9: Immiscible flow solution using the AIM-TRK2-WENO2 scheme. The saturation
profile in the right plot is close to the fine scale reference. The left plot shows the distribution of
the implicit blocks (in black).
5.4 High-order AIM with artificial viscosity
The artificial viscosity method is a general approach that helps prevent the creation of
spurious oscillations. It was first introduced by Richtmeyer and Von Neumann, and it is still
widely used today in Computational Fluid Dynamics (see for example [24]). The idea is to
introduce a viscous term in specific regions, e.g., near a shock wave or near a steep gradient,
where the oscillatory behavior is likely to occur. Meanwhile, the propagation speed must be
conserved, and the spatial extension of the discontinuity is required to remain on the order
of a few grid blocks at all times. Applied to (2.2), this approach leads to
∂s
∂t+
∂f(s)
∂x= ν0∆x
∂
∂x
(
Q(s)∂s
∂x
)
, (5.40)
where Q(s) is a viscous coefficient, which is nonzero only in the non-smooth regions. These
regions can be determined by evaluating the local gradients of the solution. On the discrete
level we modify the numerical flux, wherever it applies, as follows:
Fi+ 1
2
= Fi+ 1
2
− qi+ 1
2
. (5.41)
Here qi+ 1
2
is an artificial diffusive flux that depends on the function Q(s). From (5.41), all
72 CHAPTER 5. CONSTRUCTION OF HIGH-ORDER AIM
the artificial diffusive terms cancel out, so the scheme is still conservative. The choice of the
implementation is determined by the parameter viscoption, which can take the following
values:
- viscoption=0: artificial viscosity is turned off,
- viscoption=1: Q(s) = 1, qi+ 1
2
= ν0(si+1 − si),
- viscoption=2: Q(s) = f ′(s), qi+ 1
2
= ν0(fi+1 − fi),
- viscoption=3: Q(s) = [f ′(s)]2, qi+ 1
2
= ν0(f′
i+ 1
2
)2(si+1 − si).
In our implementation, the diffusive flux contributions are solved implicitly, and the flux
derivatives are modified accordingly. As a result, there is no stability restriction associated
with the application of artificial diffusion.
The second option can naturally be used only if f ′ ≥ 0. In this case, we can check that it
has the desired diffusive effect. To see that, we can rewrite
∂
∂x
(
Q(s)∂s
∂x
)
=∂2f(s)
∂x2= f ′′(s)
(
∂s
∂x
)2
+ f ′(s)∂2s
∂x2. (5.42)
Assuming that the saturation profile is decreasing, and that the fractional flow curve has a
single inflection point, we have:
- for the saturations above the inflection point, f ′′(s) ≤ 0, sxx ≤ 0 ⇒ ∂2f/∂x2 ≤ 0,
- for the saturations below the inflection point, f ′′(s) ≥ 0, sxx ≥ 0 ⇒ ∂2f/∂x2 ≥ 0.
Hence in this case the right-hand side of (5.40) is clearly dissipative, i.e., it has a negative
contribution in the upstream part of the front and a positive contribution in the downstream
part of it.
In figure 5.10, we show a simulation result for the TRK2-WENO2 scheme applied with a
CFL number close to 2.5. In the case without artificial diffusion, we observe a non-monotonic
behavior near the leading edge due to the violation of the monotonicity restriction, given
by CFL < 2. By adding the right amount of artificial viscosity, here taking ν0 = 0.2, we
overcome this nonphysical behavior, and we obtain a very satisfactory resolution near the
shock.
5.4. HIGH-ORDER AIM WITH ARTIFICIAL VISCOSITY 73
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
TRK2−WENO2 (ν0=0.0)
TRK2−WENO2 (ν0=0.2)
MOC
Figure 5.10: Test of the TRK2-WENO2 scheme with artificial viscosity. Here a nonlinear diffu-
sive term (using viscoption=1) is applied in the steep-gradient region. For large CFL numbers,
this method prevents the creation of spurious oscillations. Thus the monotonicity restriction of the
TRK2 method is improved significantly.
Chapter 6
Conclusions
Our analysis of the standard AIM formulation revealed a local inconsistency at the implicit-
explicit (I-E) boundaries. The discretization errors can lead to undesirable “kinks” in the
solution profile, but in general they are only of the order of the numerical dispersion. More-
over, the convergence and monotonicity properties of the solution are preserved, except in
specific situations that can be avoided in practice.
The construction of high-order AIM can be based on highly accurate MOL schemes. The
MOL framework offers a lot of flexibility, e.g., for multidimensional extensions and for the
treatment of diffusive or reactive terms. We apply high-resolution non-oscillatory shock
capturing schemes to the nonlinear convective term, which is hyperbolic in nature. For the
time integration, we use high-order methods such as Runge-Kutta schemes. The combination
of these highly accurate space-time discretizations leads to a substantial reduction of the
numerical dispersion compared to first-order methods.
In order to derive fully high-order AIM, the accuracy at the I-E boundaries must be preserved.
Using explicit predictors, the time integration in the explicit regions can be based on the
same time levels as in the implicit regions. Hence the consistency at the I-E boundaries
is maintained. Moreover, our high-order AIM schemes are still locally conservative and
unconditionally stable in the implicit regions.
However, the high-order implicit time integration leads to severe positivity restrictions on the
time step size. In fact, only first-order methods like Backward Euler can be unconditionally
positive. Therefore, we propose using artificial viscosity in the implicit regions in order to
remove spurious oscillations. But we also need to investigate further what optimal time
integration method, with respect to positivity, should be employed. Finally, a practical
74
75
approach for a wide range of applications consists of applying Backward Euler in the implicit
regions and a high-order time integration method in the explicit regions.
List of acronyms
AIM: Adaptive Implicit Method
MOL: Method Of Lines
MOC: Method Of Characteristics
TVD: Total Variation Diminishing
BE: first-order Backward Euler scheme
FE: first-order Forward Euler scheme
TRK2: second-order Trapezoidal Runge-Kutta scheme
CRK2: second-order Centered Runge-Kutta scheme
IRK2: second-order Implicit Runge-Kutta scheme
DIRK3: third-order Diagonally Implicit Runge-Kutta scheme
BDF2: second-order Backward Differentiation Formula
UW1: first-order single-point Upstream Weighting scheme
FL2: second-order Flux Limiting scheme
CS2: second-order Central Scheme
(W)ENO: (Weighted) Essentially Non-Oscillatory scheme
76
Bibliography
[1] A. Bellen, Z. Jackiewicz, and M. Zennaro. Contractivity of Waveform Relaxation Runge-
Kutta Iterations and Related Limit Methods for Dissipative Systems in the Maximum
Norm. SIAM Journal on Numerical Analysis, 31:499–523, 1994.
[2] A. Bellen and L. Torelli. Unconditional Contractivity in the Maximum Norm of Diago-
nally Split Runge-Kutta Methods. SIAM Journal on Numerical Analysis, 34:528–543,
1997.
[3] A. Cadiou and C. Tenaud. Implicit WENO shock capturing scheme for unsteady flows.
Application to one-dimensional Euler equations. International Journal for Numerical
Methods in Fluids, 45:197–229, 2004.
[4] W. Dai and P.R. Woodward. A High-Order Iterative Implicit-Explicit Hybrid Scheme
for Magnetohydrodynamics. SIAM J. Sci. Comput., 19:1827–1846, 1998.
[5] B. Engquist, S. Osher, and S.R. Chakravarthy. Uniformly High Order Accurate Essen-
tially Non-oscillatory Schemes. Journal of Computational Physics, 71:231–303, 1987.
[6] P.A. Forsyth and P.H. Sammon. Practical Considerations for Adaptive Implicit Methods
in Reservoir Simulation. Journal of Computational Physics, 62:265–281, 1986.
[7] E. Godlewski and P.A. Raviart. Numerical Approximation of Hyperbolic Systems of
Conservation Laws. Springer Verlag, 1991.
[8] J. Grabenstetter, Y.K. Li, D.A. Collins, and L.X. Nghiem. Stability-Based Switch-
ing Criterion for Adaptive-Implicit Compositional Reservoir Simulation. SPE, (21225),
1991.
77
78 BIBLIOGRAPHY
[9] Z. Horvath. Positivity of Runge-Kutta and diagonally split Runge-Kutta methods.
Applied Numerical Mathematics, 28:309–326, 1998.
[10] Z. Horvath. On the positivity step size threshold of Runge-Kutta methods. Applied
Numerical Mathematics, 53:341–356, 2005.
[11] W. Hundsdorfer and J.G. Verwer. Numerical Solution of Time-Dependent Advection-
Diffusion-Reaction Equations. Springer, 2003.
[12] A. Iserles. Numerical Analysis of Differential Equations. Cambridge University Press,
1996.
[13] G.S. Jiang and C.W. Shu. Efficient Implementation of Weighted ENO Schemes. Journal
of Computational Physics, 126:202–228, 1996.
[14] G.S. Jiang and E. Tadmor. Nonoscillatory central schemes for muldimensional hyper-
bolic conservation laws. SIAM J. Sci. Comput., 19:1892–1917, 1998.
[15] A. Kurganov and D. Levy. A third-order semidiscrete central scheme for conservation
laws and convection-diffusion equations. SIAM J. Sci. Comput., 22:1461–1488, 2000.
[16] A. Kurganov and E. Tadmor. Non-Oscillatory central differencing for hyperbolic con-
sevation laws. Journal of Computational Physics, 87:408–463, 1990.
[17] A. Kurganov and E. Tadmor. New high resolution central schemes for non linear con-
servation laws and convection diffusion equations. Journal of Computational Physics,
160:241–282, 2000.
[18] D. Levy, G. Puppo, and G. Russo. Compact Central WENO Schemes for multidimen-
sional conservation laws. SIAM J. Sci. Comput., 22:656–672, 1999.
[19] A. Logg. Multi-adaptive Galerkin Methods for ODEs, I. SIAM J. Sci. Comput., 24:1879–
1902, 2002.
[20] A.A. Medovikov. High order explicit methods for parabolic equations. BIT, 38:372–390,
1998.
[21] H.J. Morel-Seytoux. Analytical-numerical method in waterflooding predictions. SPE,
(985), 1965.
BIBLIOGRAPHY 79
[22] H.J. Morel-Seytoux. Unit mobility ratio displacement calculations for pattern floods in
homogeneous medium. SPE, (1359), 1966.
[23] S. Osher and R. Fedkiw. Level Set Methods and Dynamic Implicit Surfaces. Springer,
2003.
[24] R.D. Richtmyer and K.W. Morton. Difference Methods for Initial Value Problems.
Krieger, 1967.
[25] B. Rubin and M.J. Blunt. High-Order Implicit Flux Limiting Schemes for Black-Oil
Simulation. SPE, (21222), 1991.
[26] T.F. Russell. Stability Analysis and Switching Criteria for Adaptive Implicit Methods
Based on the CFL condition. SPE, (18416), 1989.
[27] C.W. Shu and S. Osher. Efficient implementation of essentially non-oscillatory shock
capturing schemes. Journal of Computational Physics, 83:32–78, 1989.
[28] G.W. Thomas and D.H. Turnau. Reservoir Simulation Using an Adaptive Implicit
Method. SPE, (10120), 1983.
[29] G.W. Thomas and D.H. Turnau. The Mathematical Basis of the Adaptive Implicit
Method. SPE, (25245), 1993.
[30] M. Wilcoxson and V. Manousiouthakis. On an Implicit ENO Scheme. Journal of
Computational Physics, 115:376–389, 1994.
[31] L.C. Young and T.F. Russell. Implementation of an Adaptive Implicit Method. SPE,
(25245), 1993.
Appendix A
Validation of high-order MOL
schemes
A.1 Objectives
Our goal is to test and compare various high-order MOL schemes, with a particular emphasis
on implicit methods. In particular, we need to (1) verify the accuracy of high-order MOL
schemes, (2) validate their shock-capturing behavior, (3) test their stability and monotonicity
properties.
For this purpose, we wrote a program in Matlab that allows for different combinations of high-
order spatial discretizations and time integration methods. This code can be run to solve the
transport equation (2.2) on the semi-line x > 0 for different flux functions and different sets
of initial and boundary conditions. The problem is solved on a uniform cartesian grid, using a
constant time step, or adaptive time stepping. The numerical solution can be compared with
the analytical solution computed by the Method of Characteristics (MOC). In the following
section, we describe the main components of our code. The commented source code is given
in Appendix C.
80
A.2. CODE DESCRIPTION 81
A.2 Code description
A.2.1 Main routine
This routine defines all the simulation parameters, i.e., fluid properties, initial and boundary
conditions, cartesian grid, time stepping and Newton parameters. These parameters are
stored in the arrays pFluid, pIBC, pGrid, pTime and pNewton.
The fluid properties are used by the subroutine fw of sw to compute the flux function
(fractional flow of water) given by
f(s) =krw(s)
krw(s) + kro(s)/M, (A.1)
where M is the viscosity ratio and krw, kro the relative permeabilities, which are calculated
according to the Honarpour correlation:
krw(s) = k0rw
(
s − swr
1 − swr − sor
)nw
, (A.2)
kro(s) = k0ro
(
1 − s − sor
1 − swr − sor
)no
. (A.3)
Here swr, sor are the residual saturations, k0rw, k0
ro the end-point relative permeabilities and
nw, no are empirical exponents.
In the current implementation, only Dirichlet conditions can be imposed at the inlet and
outlet boundaries:
s(0, t) = swi , s(∞, t) = swc . (A.4)
The initial condition is given by a uniform value, i.e., s(x, 0) = swc (connate water satura-
tion). In the case of linear advection (i.e., for swr = sor = 0, nw = no = 1 and Mk0rw/k0
ro = 1),
we can also use a smooth profile:
s(x, 0) =
{
swc + (swi − swc) exp(
1δ2 − 1
δ2−x2
)
, 0 < x < δ ,
swc , x > δ ,(A.5)
where the parameter δ determines the sharpness of this initial front.
The one-dimensional cartesian grid is always uniform, hence the node locations are simply
given by
82 APPENDIX A. VALIDATION OF HIGH-ORDER MOL SCHEMES
xk = xmin + (k − 1
2)xmax − xmin
m, k = 1, . . . ,m , (A.6)
where m is the number of grid blocks. Because of the boundary conditions, we need some
ghost cells at the inlet and outlet boundaries. Hence a total of r ghost cells are added to
the left of the first cell and to the right of the last cell, where r is the order of the spatial
discretization.
Regarding the time stepping, the user can specify the initial time step as well as the minimum
and maximum allowed step sizes. The adaptive time stepping algorithm is based on the
values of the desired (∆sd) and actual (∆sa) change in saturation over one time step:
∆tn+1 =(1 + ω)∆sd
∆sa + ω∆sd∆tn , (A.7)
where ω is a tuning parameter between 0 and 1.
In the case of implicit methods, the nonlinear system of equations is solved with the Newton-
Raphson method. The user must specify the absolute tolerance and the maximum number
of iterations. Internally, we apply relaxation for the first three iterations in order to improve
the convergence.
After the definition of the different simulation parameters, the subroutines CalcSw MOC and
CalcSw MOL can be called to solve the problem analytically and numerically. These subrou-
tines are described below.
A.2.2 Routine CalcSw MOC
This routine calculates the exact solution of the initial-boundary-value problem using the
Method of Characteristics. In the case of linear advection, the solution is merely obtained by
translation of the initial condition. For the nonlinear Buckley-Leverett problem, we assume
that the flux function has only one inflection point and that f ′ ≥ 0. Then the analytical
solution consists of a rarefaction wave and/or a shock wave. For the MOC calculation, we
need the subroutines dfw dsw, d2fw dsw to evaluate the first and second derivatives of the
flux function.
This routine can also compute the analytical solution in the following inhomogeneous case:
φn∂s
∂t+
∂f(s)
∂x= 0, φn(x) =
{
φ1n, 0 ≤ x ≤ x∗
φ2n, x∗ < x ≤ 1
(A.8)
A.2. CODE DESCRIPTION 83
The above equation is written in dimensionless form and φn is a normalized porosity (actual
porosity divided by the average porosity). The solution in the linear case for an arbitrary
initial condition s(x, 0) = s0(x) is given by
s(x, t) =
s0(x − tφ1
n), x ≤ x∗
s0(x∗ + φ2
n(x−x∗)−tφ1
n), x∗ < x ≤ x∗ + t
φ2n
s0(x − tφ2
n), x > x∗ + t
φ2n
(A.9)
In the quasi-linear case we can derive the solution of the Riemann problem. For swi > swc,
and under certain assumptions on the flux function, the solution consists of a rarefaction and
a shock wave. Let v1s , v2
s be the shock velocities in the regions x ≤ x∗ and x > x∗ (obtained
from the Rankine-Hugoniot relationship, in particular φ1nv
1s = φ2
nv2s) and let t∗ = x∗/v1
s .
Then the solution for t ≤ t∗ is
s(x, t) =
{
(f ′)−1(φ1nxt
), x ≤ v1st
swc, x > v1st
(A.10)
while for t > t∗ it is given by
s(x, t) =
(f ′)−1(φ1nxt
), x ≤ x∗
(f ′)−1(φ1nx∗+φ2
n(x−x∗)t
), x∗ < x ≤ x∗ + v2s(t − t∗)
swc, x > x∗ + v2s(t − t∗)
(A.11)
A.2.3 Routine CalcSw MOL
This routine calculates a numerical solution of the initial-boundary-value problem using a
MOL scheme. For the time integration, the following methods are implemented:
- forward/backward Euler (FE/BE),
- explicit/implicit midpoint rule (eCRK2/CRK2),
- explicit/implicit trapezoidal rule (eTRK2/TRK2),
- second-order BDF scheme (BDF2),
- second-order implicit RK scheme (IRK2),
- third-order DIRK scheme (DIRK3).
84 APPENDIX A. VALIDATION OF HIGH-ORDER MOL SCHEMES
For each MOL scheme listed above, a specific subroutine (e.g., CalcSw MOL FE) is provided.
Note that the implicit trapezoidal rule is implemented as a special case of the implicit Θ-
Scheme. For the spatial discretization, a string argument is passed to the MOL routine in
order to specify which numerical flux should be used.
A.2.4 Routine CalcFlux
This routine evaluates the numerical flux at every inter-cell boundary for a specific type of
spatial discretization. The list of the numerical fluxes available is given below:
- first-order Upwind scheme (UW1),
- second-order flux limiting scheme (FL2),
- second-order (W)ENO scheme ((W)ENO2),
- second-order central scheme (CS2),
- third-order ENO scheme (ENO3).
The first-order Upwind scheme will generally be used as a reference for comparison with
high-order numerical fluxes. The routine CalcFlux can also return the derivatives of the
numerical flux. These derivatives are required to assemble the Jacobian matrix in the case
of implicit methods.
The flux limiting scheme implemented in this routine is given by (2.13). It uses the Van
Leer limiter which has the advantage of being smooth everywhere except near r = 0. For
the (W)ENO2, ENO3 and CS2 schemes, we refer to the discretizations presented in the first
chapter of this report.
A.3 Numerical tests
The first test problem is the linear advection problem with the initial condition (A.5). The
simulation parameters are given by swr = sor = 0, nw = no = 1, Mk0rw/k0
ro = 1, swc = 0.1,
swi = 0.9, and δ = 0.2. The solution is computed on a uniform cartesian grid with m = 50
nodes, until the injection of half a pore volume (i.e., for a dimensionless time of 0.5).
A.3. NUMERICAL TESTS 85
The second test problem is the quasi-linear Buckley-Leverett problem with a uniform initial
saturation and the boundary conditions (A.4). In this case, the simulation parameters are
swr = 0.1, sor = 0.2, k0rw = k0
ro = 1, nw = no = 2, M = 2, swc = 0.1 and swi = 1.0. The
solution is computed on a uniform cartesian grid with m = 50 nodes, until the injection of
0.3 pore volumes.
Since the exact solution of the first test problem is smooth for all t > 0, we will use it to
verify the order of accuracy of the MOL scheme. Meanwhile, the solution of the second
test problem consists of a smooth region (rarefaction wave) and a jump discontinuity (shock
wave). Thus we will be able to validate the shock-capturing property of the scheme and to
assess the accuracy in the smooth region. Finally, the stability and monotonicity restrictions
will be tested on each problem and when available, theoretical results will be provided.
A.3.1 eCRK2-CS2 scheme
The MOL scheme obtained by combining the explicit midpoint rule with the central flux
discretization (2.30) leads to a second-order accurate scheme. The left and right plots of
figure A.1 show the numerical solution for the linear advection and the Buckley-Leverett
problems respectively. In both cases, the CFL number is close to 1/2. These results can
be compared with the first-order explicit Upwind scheme (FE-UW1) and the exact MOC
solution.
In the linear case, the central scheme is clearly more accurate than the Upwind scheme.
By refining the grid and keeping the CFL number constant, we can verify that the order of
convergence for the eCRK2-CS2 scheme is two, as opposed to one for the FE-UW1 scheme.
In the nonlinear case we observe a substantial reduction of the numerical dispersion in the
smooth region. The resolution decreases near the jump discontinuity, but it is still higher
than that of the Upwind scheme. More importantly, the shock-capturing property of the
eCRK2-CS2 scheme is confirmed because the speed and the overall shape of the leading
shock are properly resolved. Finally, the non-oscillatory behavior of the solution is preserved
as long as the CFL number remains below 1/2 (detailed results about the monotonicity
properties of explicit central schemes can be found in [17]).
86 APPENDIX A. VALIDATION OF HIGH-ORDER MOL SCHEMES
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCFE−UW1eCRK2−CS2
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCFE−UW1eCRK2−CS2
Figure A.1: Test results with the eCRK2-CS2 scheme: linear advection (left), Buckley-Leverett
problem (right). In both cases, the eCRK2-CS2 scheme is compared against the explicit single-point
upstream weighting scheme (FE-UW1).
A.3.2 BE-FL2 scheme
The BE-FL2 scheme combines the second-order accurate flux limiting scheme with the first-
order accurate Backward Euler method. Figure A.2 shows numerical solutions calculated
with CFL = 3/2. For comparison, we provide the solution of the first-order implicit Upwind
scheme (BE-UW1).
Due to its higher spatial resolution, the BE-FL2 scheme is less dissipative than the BE-
UW1 scheme, both in the linear and nonlinear cases. The leading shock of the Buckley-
Leverett profile is properly resolved but the smearing of the front is quite significant. In
fact, there is a substantial loss of overall accuracy compared to the FE-UW1 and eCRK2-
CS2 schemes presented earlier. This is because implicit methods generally lead to more
numerical dispersion than explicit methods. But implicit methods can have much better
stability properties. Here the BE-FL2 is unconditionally stable, while the eCRK2-CS2 and
FE-UW1 schemes have CFL restrictions of 1/2 and 1, respectively (so they would blow up
with CFL = 3/2). In addition, the Backward-Euler method guarantees that the BE-FL2
scheme is unconditionally TVD under the restrictions (2.11) on the flux limiter (a proof is
given by Rubin and Blunt in [25]).
A.3. NUMERICAL TESTS 87
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1BE−FL2
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1BE−FL2
Figure A.2: Test results with the BE-FL2 scheme: linear advection (left), Buckley-Leverett prob-
lem (right). In both cases, the BE-FL2 scheme is compared against the implicit single-point up-
stream weighting scheme (BE-UW1).
A.3.3 TRK2-ENO2 scheme
The implicit Θ-scheme can be combined with the second-order ENO flux as follows:
sn+1i = sn
i − ∆t
∆x
{
θ(fn+1i+ 1
2
− fn+1i− 1
2
) + (1 − θ)(fni+ 1
2
− fni− 1
2
)}
, (A.12)
where fi+ 1
2
is the ENO2 flux. For θ = 1/2 we obtain the TRK2-ENO2 scheme which
is second-order accurate in time because the time integration corresponds to the implicit
trapezoidal rule. For all other values of θ, this method is only first-order accurate in time.
In particular, θ = 1 gives the Backward-Euler scheme. In figure A.3 we present the numerical
solutions computed with θ = 1/2 (TRK2-ENO2 scheme) for CFL = 3/2. Again, the result
of the BE-UW1 scheme is shown for comparison.
As expected, the TRK2-ENO2 scheme produces the most accurate solutions for both test
problems. In particular, the leading shock of the Buckley-Leverett profile is resolved very
accurately compared to the other methods. Even though (A.12) is unconditionally stable
for θ ≥ 1/2, it has a non-oscillatory restriction given by
∆t
∆x≤ λ0
1 − θ, (A.13)
88 APPENDIX A. VALIDATION OF HIGH-ORDER MOL SCHEMES
where λ0 is the non-oscillatory limit of the explicit ENO scheme. A proof of this result
is given in [30]. As a consequence, the non-oscillatory limit of the TRK2-ENO2 scheme is
only twice that of the explicit scheme. Meanwhile, like the BE-FL2 scheme, the BE-ENO2
scheme is unconditionally non-oscillatory.
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1TRK2−ENO2
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1TRK2−ENO2
Figure A.3: Test results with the TRK2-ENO2 scheme: linear advection (left), Buckley-Leverett
problem (right). In both cases, the TRK2-ENO2 scheme is compared against the implicit single-
point upstream weighting scheme (BE-UW1).
A.3.4 BDF2-WENO2 scheme
Here we apply the WENO2 flux given by (2.21) along with the BDF2 scheme for time
integration. As a result, we achieve an overall accuracy of order two. Figure A.4 shows the
simulation results for the BDF2-WENO2 and BE-UW1 schemes using CFL = 3/2.
In the linear case the BDF2-WENO2 scheme clearly violates the monotonicity of the solution,
while in the nonlinear case, it leads to overshoots just ahead of the leading shock. However, if
we use smaller CFL numbers, the BDF2-WENO2 scheme becomes non-oscillatory and more
accurate than the BE-UW1 scheme. Like the implicit one-step methods tested previously,
the BDF2 scheme is unconditionally stable. In Appendix B, we derive a formal proof of
the unconditional stability for the linear case. As shown by our numerical tests, in spite
of its good stability properties, the BDF2 scheme has a severe non-oscillatory restriction.
Theoretical results actually indicate that the nonlinear positivity restriction is CFL ≤ 1/2
A.3. NUMERICAL TESTS 89
(see [11] for instance).
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1BDF2−WENO2
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1BDF2−WENO2
Figure A.4: Test results with the BDF2-WENO2 scheme: linear advection (left), Buckley-Leverett
problem (right). In both cases, the BDF2-WENO2 scheme is compared against the implicit single-
point upstream weighting scheme (BE-UW1).
A.3.5 DIRK3-ENO3 scheme
This MOL scheme is constructed with the third-order ENO scheme for the spatial operator,
and the DIRK3 method using γ = 1/2 +√
3/6 for the time integration. Hence it has an
overall order of accuracy equal to three. The numerical approximations presented in figure
A.5 were calculated for CFL = 3/2.
This scheme produces highly accurate solutions both in the linear and nonlinear cases. How-
ever, in the linear case the non-negativity of the solution is slightly violated. This DIRK3
method is unconditionally stable but it seems to have a quite severe positivity restriction on
the time step size.
90 APPENDIX A. VALIDATION OF HIGH-ORDER MOL SCHEMES
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1DIRK3−ENO3
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1DIRK3−ENO3
Figure A.5: Test results with the DIRK3-ENO3 scheme: linear advection (left), Buckley-Leverett
problem (right). In both cases, the DIRK3-ENO3 scheme is compared against the first-order implicit
single-point upstream weighting scheme (BE-UW1).
A.3.6 IRK2-WENO2 scheme
This implicit MOL scheme combines the IRK2 time integration method with the WENO2
flux. Here the choice of the coefficients for the IRK2 method corresponds to the Radau
scheme. Hence the resulting MOL scheme is third-order accurate in time and second-order
accurate in space. The numerical solutions of the IRK2-WENO2 and BE-UW1 schemes are
reported in figure A.6. Like previously we used CFL = 3/2 for both test problems.
We observe in both cases that the IRK2-WENO2 scheme produces highly accurate solutions
and that the positivity is preserved. Nevertheless, in accordance with the theorem due to
Bolley and Crouzeix, the positivity of the solution becomes violated if we keep increasing the
CFL number. Using the stability function approach for one-step methods, it can be shown
that this IRK2 scheme is unconditionally stable. As far as positivity is concerned, we can
infer from our results that this method has a higher positivity limit than the TRK2, BDF2
or DIRK3 methods.
A.3. NUMERICAL TESTS 91
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1IRK2−WENO2
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
xD
Sw
MOCBE−UW1IRK2−WENO2
Figure A.6: Test results with the IRK2-WENO2 scheme: linear advection (left), Buckley-Leverett
problem (right). In both cases, the IRK2-WENO2 scheme is compared against the first-order im-
plicit single-point upstream weighting scheme (BE-UW1).
A.3.7 Concluding remarks
In the table below we summarize the non-oscillatory limits of the various implicit methods
tested previously. This non-oscillatory limit corresponds to the maximum CFL number that
yields an oscillation-free solution, i.e., without any localized overshoots or undershoots. Note
that in general, the non-oscillatory limit is more restrictive than the positivity limit, but they
are often equal (cf. linear case). The values reported in Table A.1 are based on numerical
experiments conducted in the linear and nonlinear cases. To allow a better comparison of
the different methods, the same numerical flux (UW1) was applied in each case.
In the linear case, the non-oscillatory limit always corresponds to a global overshoot or under-
shoot, i.e., saturation values lower than swc or larger than swi. Meanwhile, in the nonlinear
case, the non-oscillatory condition is usually violated locally, e.g., there is a localized over-
shoot just ahead of the leading edge. Hence the non-oscillatory limits can be measured very
precisely in the linear case (by just comparing the solution at each node with the min./max.
values allowed), whereas the values reported in the nonlinear case are only based on a visual
assessment of the difference between the numerical and analytical solutions.
92 APPENDIX A. VALIDATION OF HIGH-ORDER MOL SCHEMES
Method Max. CFL Max. CFL
(linear case) (nonlinear case)
BE ∞ ∞BDF2 0.5 2.0
TRK2 2.0 3.0
CRK2 2.0 3.0
IRK2 3.0 8.0
DIRK3 2.2 4.5
Table A.1: Non-oscillatory limits of implicit time integration methods. The values reported in the
linear case correspond to the maximum CFL number for which the maximum principle is satisfied,
which can be verified exactly. In the quasi-linear case, these CFL values are based on the observation
of a local overshoot in the solution profile.
The linear non-oscillatory limits for the BE, BDF2, TRK2 and CRK2 methods match the
theoretical linear positivity limits exactly. As for the IRK2 and DIRK3 methods, we have no
theoretical results available to compare with. But we can infer that their non-oscillatory and
positivity limits are higher than for the other high-order methods. This result was already
suggested by our numerical tests of high-order MOL schemes. Interestingly, the different
implicit methods always behave better in the nonlinear case. The non-oscillatory restriction
is improved substantially, especially for the BDF2 and IRK2 methods. In fact, since the
characteristic speed is not constant, the linear non-oscillatory condition can be violated
locally without leading to overshoots or undershoots. In general the degree of oscillatory
behavior also differs from one scheme to another. For instance, the IRK2 scheme has a
non-oscillatory limit of 3 in the linear case, but the deterioration of the numerical solution
is not severe as we go above this limit, whereas for the TRK2 and CRK2 methods, CFL
numbers just above 2 can lead to highly oscillatory solutions.
We also observe that the monotonicity properties generally deteriorate when a higher-order
flux discretization is applied. For instance, the non-oscillatory limit for the DIRK3-ENO3
scheme is lower than for the DIRK3-UW1 scheme (see subsection A.3.5). Indeed, these
high-order numerical fluxes are not strictly TVD, as opposed to the basic first-order Upwind
flux, and the ODE system itself may be slightly oscillatory (but these high-order spatial
discretizations are still said to be non-oscillatory because the oscillations remain bounded by
O(∆xr) where r is the order of accuracy). This remark confirms the point we made earlier
A.3. NUMERICAL TESTS 93
in section 3.4 about the dependency of the positivity restriction upon the spatial operator.
In conclusion, it is important to keep in mind that the monotonicity properties of a MOL
scheme depend both on the flux discretization and the time integration method. But mono-
tonicity results for the time integration method are generally difficult to derive. Theoretical
results are available for RK methods in the case of positive, dissipative ODE systems (see
[1] for the definition of a dissipative ODE system). In this case, the time step threshold for
positivity is given by H = R(A, b)/ρ where ρ is a measure of dissipation and R(A, b) is the
positivity radius, which only depends on the coefficients of the RK method. For example, we
have R(A, b) = 1/(1− θ) for the implicit Θ-scheme. We can also deduce from our numerical
experiments in the linear case that R(A, b) ≈ 3 for the IRK2 method and R(A, b) ≈ 2.2 for
the DIRK3 method. Nevertheless, because of the hyperbolic nature of the transport equa-
tion, the semi-discrete scheme is generally not dissipative. More general results for positive
ODE systems can be found in [9] but their practical value is not established.
Appendix B
Linear stability of the BDF2 scheme
Here we perform a Von Neuman analysis of the scheme (3.17) when φ = 0, θ = 1 and β = 1/2
(constant time step). In the linear case, applying the single-point upstream weighting scheme,
(3.19) becomes
3
2
sn+1i − sn
i
∆t− 1
2
sni − sn−1
i
∆t= −sn+1
i − sn+1i−1
∆x, (B.1)
or equivalently,
3
2
sn+1i − sn
i
∆t− 1
2
sni − vn
i
∆t= −sn+1
i − sn+1i−1
∆x, (B.2)
vn+1i = sn
i . (B.3)
The form above is required because (B.1) is a three-level formula. A detailed description of
the Von Neuman analysis for Multi-Level schemes can be found in [24].
Let un(x) = (sn(x), vn(x))T , where sn(x), vn(x) are the approximations to s(x, n∆t),
s(x, (n − 1)∆t) respectively. Then (B.2), (B.3) can be written as
(B1,0T0 + B1,−1T−1)un+1(x) = B0,0T0 un(x) , (B.4)
where Tβ is the translation operator defined by Tβu(x) = u(x + β∆x) and B1,0, B1,−1, B0,1
are the 2 by 2 matrices given by
94
95
B1,0 =
[
32
+ c 0
0 1
]
(B.5)
B1,−1 =
[
−c 0
0 0
]
(B.6)
B0,1 =
[
2 −12
1 0
]
(B.7)
where c = ∆t/∆x. Applying the Fourier transform to (B.4) we obtain
H1un+1(k) = H0u
n(k) , (B.8)
where H0 = B0,0 and H1 = B1,0 + B1,−1e−ik∆x. Hence the amplification matrix is given by
G(∆t, k) = (H1)−1H0 =
[
43+2c(1−e−iβ)
−13+2c(1−e−iβ)
1 0
]
, (B.9)
where β = k∆x. The eigenvalues of G are
λ± =2 ± z0
3 + 2c(1 − e−iβ), (B.10)
where z0 is a complex root of ∆ = 1 − 2c(1 − e−iβ). Figure B.1 shows the values of |λ±|for 0 < β < 2π and 0 < c < 3. It appears that λ+ is always bounded by 1, whereas λ+
is bounded by 1/2. So assuming that these bounds are valid for larger CFL numbers (as
suggested by the plots), then the BDF scheme (B.1) is unconditionally stable. For a rigorous
proof of this statement, we can use (B.10) to obtain
|λ±|2 =4 ± 4ℜ(z0) + |z0|2|3 + 2c(1 − e−iβ)|2 =
4 +√
δ ± 2√
2√
1 − 2c(1 − cos β) +√
δ
9 + 4c(3 + 2c)(1 − cos β), (B.11)
where δ = (1 − 2c(1 − cos β))2 + 4c2 sin2 β, and then it is possible to show that |λ±| < 1 for
any 0 < β < 2π and any c > 0.
96 APPENDIX B. LINEAR STABILITY OF THE BDF2 SCHEME
0
5
10 01
23
0.2
0.4
0.6
0.8
1
c = ∆t/∆x
β = k∆x
0
5
10 01
23
0.2
0.3
0.4
0.5
c = ∆t/∆x
β = k∆x
Figure B.1: Modulus of λ+ (left) and λ− (right)
Appendix C
Matlab code for 1D numerical tests
C.1 Main routine
% This is the main program where we define the simulation
% parameters and call the MOL scheme to solve the scalar
% 1D transport equation.
%-------------------------------------------------------------
clear all, close all
% global variables (for external use)
global pFluid
global pIBC
global viscoption
global nu0
%-------------------------------------------------------------
% Fluid parameters
%-------------------------------------------------------------
swr = 0.1; % irreducible water saturation
sor = 0.2; % residual oil saturation
krw0 = 1.0; % end point rel. perm. for water
kro0 = 1.0; % end point rel. perm. for oil
nw = 2.0; % water exponent
no = 2.0; % oil exponent
M = 5.0; % mobility ratio
pFluid = [swr, sor, krw0, kro0, nw, no, M];
%-------------------------------------------------------------
% Parameters for initial & boundary conditions
%-------------------------------------------------------------
swc = 0.1; % connate water saturation
swi = 1.0; % injected water saturation
xfi = 0.0; % initial water front position (linear case)
pIBC = [swc, swi, xfi];
%-------------------------------------------------------------
% Grid parameters
97
98 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
%-------------------------------------------------------------
x_min = 0.0; % minimum grid position
x_max = 1.0; % maximum grid position
nx = 50; % number of grid nodes
pGrid = [x_min, x_max, nx];
%-------------------------------------------------------------
% Time stepping parameters
%-------------------------------------------------------------
tf = 0.3; % final time
dt0 = 0.005; % initial time step size
dtMin = 0.002; % minimum time step size
dtMax = 0.01; % maximum time step size
dtTune = .9; % tuning parameter for adaptive time stepping
dSwOpt = .4; % optimal saturation change per time step
pTime = [tf, dt0, dtMin, dtMax, dtTune, dSwOpt];
%-------------------------------------------------------------
% Newton descent parameters
%-------------------------------------------------------------
tol = 1.e-8; % absolute tolerance for the residual
iterMax = 15; % maximum number of Newton iterations
pNewton = [tol, iterMax];
%-------------------------------------------------------------
% Plot the fractional flow curve and its derivative
%-------------------------------------------------------------
sw = linspace(0,1,100);
figure(1), plot(sw, fw_of_sw(sw), ’b’, sw, dfw_dsw(sw), ’r’)
%-------------------------------------------------------------
% Compute the exact solution
%-------------------------------------------------------------
ny = 200; dy = (x_max-x_min)/ny;
y = linspace(x_min+dy/2, x_max-dy/2, ny);
sw = CalcSw_MOC(y, tf, pFluid, pIBC);
figure(2), plot(y, sw, ’k-’), axis([x_min x_max 0.1 0.8])
xlabel(’x_D’,’FontSize’,20), ylabel(’S_w’,’FontSize’,20)
%-------------------------------------------------------------
% Compute the MOL solution for various discretizations
%-------------------------------------------------------------
dx = (x_max-x_min)/nx;
x = linspace(x_min+dx/2, x_max-dx/2, nx);
viscoption = 0; % option for artificial viscosity
nu0 = 0.e-1; % viscous coefficient
%-----------------------
% 1st-order Upwind flux
%-----------------------
pScheme = {’AIM-STD’,’UW1’,1};
[s,CPU_TOTAL] = CalcSw_MOL(pGrid,pTime,pFluid,pIBC,pNewton,pScheme);
figure(2), hold on, plot(x, s(2:nx+1), ’b--’)
%-----------------------
% 2nd-order limited flux
%-----------------------
C.2. MOC ROUTINE 99
pScheme = {’AIM-BE-TRK2’,’FL2’,2};
[s,CPU_TOTAL] = CalcSw_MOL(pGrid,pTime,pFluid,pIBC,pNewton,pScheme);
figure(2), hold on, plot(x, s(3:nx+2), ’co-’)
%-----------------------
% 2nd-order ENO flux
%-----------------------
pScheme = {’TRK2’,’ENO2’,2};
[s,CPU_TOTAL] = CalcSw_MOL(pGrid,pTime,pFluid,pIBC,pNewton,pScheme);
figure(2), hold on, plot(x, s(3:nx+2), ’g+-’)
%-----------------------
% 2nd-order WENO flux
%-----------------------
pScheme = {’AIM-BE’,’WENO2’,2};
[s,CPU_TOTAL] = CalcSw_MOL(pGrid,pTime,pFluid,pIBC,pNewton,pScheme);
figure(2), hold on, plot(x, s(3:nx+2), ’r--’)
%------------------------
% 2nd-order Central flux
%------------------------
pScheme = {’eCRK2’,’CS2’,2};
[s,CPU_TOTAL] = CalcSw_MOL(pGrid,pTime,pFluid,pIBC,pNewton,pScheme);
figure(2), hold on, plot(x, s(3:nx+2), ’m+-’)
%-----------------------
% 3rd-order ENO flux
%-----------------------
pScheme = {’DIRK3’,’ENO3’,3};
[s,CPU_TOTAL] = CalcSw_MOL(pGrid,pTime,pFluid,pIBC,pNewton,pScheme);
figure(2), hold on, plot(x, s(4:nx+3), ’c+-’)
h = legend(’MOC’,’AIM-STD-UW1’,’AIM-BE/TRK2-FL2’);
set(h,’FontSize’,20)
C.2 MOC routine
function [sw] = CalcSw_MOC(x, t, pFluid, pIBC)
%-------------------------------------------------------------
% This function calculates the solution of the 1D scalar IBVP
% PDE : s_t + f(s)_x = 0,
% IC : s(x,0)=s0(x),
% BC’s: s(0,t)=swi,
% s_x(L,t)=0,
% using the method of characteristics.
%-------------------------------------------------------------
% Input Arguments
%----------------
% x := array of grid points
% t := final time for the IBVP
% pFluid := fluid parameters (used to evaluate f(s))
% pIBC := initial and boundary condition parameters
100 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
%-------------------------------------------------------------
% Output Arguments
%-----------------
% s := array of saturation values
%-------------------------------------------------------------
global swc
global xsi
swr = pFluid(1);
sor = pFluid(2);
swc = pIBC(1);
swi = pIBC(2);
xfi = pIBC(3);
if (xfi>0) % smooth initial data (only for linear advection)
sw = swc + (swi-swc)*(exp(1/(xfi^2) - 1./...
(xfi^2-(x-t).^2)).*(t<x & x<xfi+t) + (x<=t));
else % jump discontinuity between swi and swc (Riemann problem)
if (swi<swc)
error(’Injected water saturation must be higher than connate water saturation’)
end
swi = min(swi, 1-sor);
swc = max(swc, swr);
% Compute inflexion point
swInf = fzero(@d2fw_dsw, .5*(swr+1-sor));
% Treat each case separately
if (swc > swInf) % rarefaction [swi->swc]
vi = dfw_dsw(swi);
vs = dfw_dsw(swc);
for i = 1:max(size(x,1), size(x,2))
if (x(i) <= vi*t)
sw(i) = swi;
elseif (x(i) <= vs*t)
if (i>1)
sw_guess = sw(i-1);
else
sw_guess = 1-sor-0.05; % i=1 and vi may be zero
end
xsi = x(i)/t;
sw(i) = fzero(@f_raref, sw_guess);
else
sw(i) = swc;
end
end
else
%--compute tangent point
sw_guess = .5*(swInf + (1-sor));
swt = fzero(@f_tangentShock, sw_guess);
C.3. MOL ROUTINE 101
if (swt > swi) % shock [swi->swc]
vs = (fw_of_sw(swi)-fw_of_sw(swc))/(swi-swc);
sw = swc + (swi-swc)*(x < vs*t);
else % rarefaction [swi->swt] + shock [swt->swc]
vi = dfw_dsw(swi);
vs = dfw_dsw(swt);
for i = 1:max(size(x,1), size(x,2))
if (x(i) <= vi*t)
sw(i) = swi;
elseif (x(i) < vs*t)
if (i>1)
sw_guess = sw(i-1);
else
sw_guess = 1-sor-0.05; % i=1 and vi may be zero
end
xsi = x(i)/t;
sw(i) = fzero(@f_raref, sw_guess);
else
sw(i) = swc;
end
end
end
end
end
return
%===================================================================
function [res] = f_tangentShock(s)
%===================================================================
global swc
res = fw_of_sw(s) - fw_of_sw(swc) - dfw_dsw(s)*(s - swc);
return
%===================================================================
function [res] = f_raref(s)
%===================================================================
global xsi
res = dfw_dsw(s) - xsi;
return
C.3 MOL routine
function [s, CPU_TOTAL] = CalcSw_MOL(pGrid, pTime, pFluid, pIBC,...
pNewton, pScheme)
%---------------------------------------------------------------------
% This function calculates the MOL solution of the 1D scalar IBVP
% PDE : s_t + f(s)_x = 0,
% IC : s(x,0)=s0(x),
102 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
% BC’s: s(0,t)=swi,
% s_x(L,t)=0,
% using the time integration and the flux discretization specified
% in pScheme.
%---------------------------------------------------------------------
% Input Arguments
%----------------
% pGrid := grid parameters [x_min, x_max, nx]
% pTime := time parameters [tf, dt0, dtMin, dtMax, dtTune, dSwOpt]
% pFluid := fluid parameters [swr, sor, M, nw, no]
% pIBC := initial & boundary condition parameters [swc, swi, xfi]
% pNewton := Newton descent parameters [tol, iterMax]
% pScheme := numerical scheme parameters {TimeScheme, NumFlux, m}
%---------------------------------------------------------------------
% Output Arguments
%-----------------
% s := saturation values at the final time
% CPU_TOTAL := CPU time (in seconds) used for the simulation
%---------------------------------------------------------------------
% Initialization
NumFlux = pScheme{2};
m = pScheme{3};
nx = pGrid(3);
dx = (pGrid(2)-pGrid(1))/nx;
x = linspace(pGrid(1)+dx/2, pGrid(2)-dx/2, nx);
nxd = nx + 2*m;
s = zeros(nxd,1);
flux = zeros(nxd,1);
fluxDeriv = zeros(nxd,2*m);
I = (m+1:m+nx); % index of cell centers
J = (m:m+nx); % index of cell boundaries
t = 0; nt = 0;
dt = pTime(2);
dt_dx = dt/dx;
if (pIBC(3)>0)
s(I) = pIBC(1) + (pIBC(2)-pIBC(1))*exp(1/pIBC(3)^2-1./...
(pIBC(3)^2-x.^2)).*(x<pIBC(3));
else
s(I) = pIBC(1);
end
s(1:m) = pIBC(2);
s(m+nx+1:nxd) = pIBC(1);
s1 = s; s2 = s;
% Simulation
disp([10,10,’Start simulation with ’,pScheme{1},’-’,pScheme{2},’...’])
CPU_INIT = cputime;
if (strcmp(pScheme(1),’FE’))
CalcSw_MOL_FE
elseif (strcmp(pScheme(1),’BE’))
C.4. NUMERICAL FLUX ROUTINE 103
CalcSw_MOL_BE
elseif (strcmp(pScheme(1),’eCRK2’))
CalcSw_MOL_eCRK2
elseif (strcmp(pScheme(1),’CRK2’))
CalcSw_MOL_CRK2
elseif (strcmp(pScheme(1),’eTRK2’))
CalcSw_MOL_eTRK2
elseif (strcmp(pScheme(1),’TRK2’))
CalcSw_MOL_TRK2
elseif (strcmp(pScheme(1),’IRK2’))
CalcSw_MOL_IRK2
elseif (strcmp(pScheme(1),’BDF2’))
CalcSw_MOL_BDF2
elseif (strcmp(pScheme(1),’DIRK3’))
CalcSw_MOL_DIRK3
elseif (strcmp(pScheme(1),’DSRK2’))
CalcSw_MOL_DSRK2
elseif (strcmp(pScheme(1),’AIM-STD’))
CalcSw_MOL_AIM_STD
elseif (strcmp(pScheme(1),’AIM-BE’))
CalcSw_MOL_AIM_BE
elseif (strcmp(pScheme(1),’AIM-CRK2’))
CalcSw_MOL_AIM_CRK2
elseif (strcmp(pScheme(1),’AIM-TRK2’))
CalcSw_MOL_AIM_TRK2
elseif (strcmp(pScheme(1),’AIM-IRK2’))
CalcSw_MOL_AIM_IRK2
elseif (strcmp(pScheme(1),’AIM-BDF2’))
CalcSw_MOL_AIM_BDF2
elseif (strcmp(pScheme(1),’AIM-DIRK3’))
CalcSw_MOL_AIM_DIRK3
elseif (strcmp(pScheme(1),’AIM-BE-TRK2’))
CalcSw_MOL_AIM_BE_TRK2
else
error(’Unknown MOL scheme’)
end
CPU_TOTAL = cputime - CPU_INIT;
disp([10,’End of simulation with ’,pScheme{1},’-’,pScheme{2},’.’])
disp([10,’Total CPU time used: ’, int2str(CPU_TOTAL)])
C.4 Numerical flux routine
function [flux, fluxDeriv] = CalcFlux(nx, s, NumFlux, m)
%----------------------------------------------------------
% This function computes the numerical fluxes for a given
% saturation profile ’s’, over a uniform grid of size ’nx’.
% The algorithm for the flux discretization is specified by
%’NumFlux’ (=’FL2’,’ENO2’, ’WENO2’ or ’CS2’).
104 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
%----------------------------------------------------------
% Input Arguments
%----------------
% nx := size of the uniform cartesian grid
% s := array of saturation values at block centers
% NumFlux := string specifying the numerical flux
% m := order of the numerical flux
%----------------------------------------------------------
% Output Arguments
%-----------------
% flux := array of numerical fluxes
% fluxDeriv := array of numerical flux derivatives
%----------------------------------------------------------
global viscoption
global nu0
% Common initializations
nxd = nx + 2*m;
I = (m+1:m+nx); % index of cell centers
J = (m:m+nx); % index of cell boundaries
flux = zeros(nxd,1);
f = fw_of_sw(s);
if (nargout>1)
fluxDeriv = zeros(nxd,2*m);
dfds = dfw_dsw(s);
end
%**************************************************************
if(strcmp(NumFlux,’UW1’))% 1st-order Upwind scheme
%**************************************************************
flux(J) = f(J); % assuming f’>0
if (nargout>1)
fluxDeriv(J,1) = dfds(J);
end
%**************************************************************
elseif(strcmp(NumFlux,’FL2’))% 2nd-order flux limiting scheme
%**************************************************************
% initializations
df = zeros(nxd-1,1);
rdf = zeros(nxd,1);
phi = zeros(nxd,1);
dphidr = zeros(nxd,1);
% numerical flux
eps = 1.e-6;
df = f(2:nxd) - f(1:nxd-1);
rdf(J) = df(J-1)./(df(J)+eps);
phi(J) = (rdf(J)+abs(rdf(J)))./(1+abs(rdf(J)));
flux(J) = f(J) + .5*phi(J).*df(J);
% derivative of numerical flux
if (nargout>1)
dphidr(J) = 2*(rdf(J)>0)./(1+abs(rdf(J))).^2;
%-- dflux_{j+1/2}/ds_{j-1}
C.4. NUMERICAL FLUX ROUTINE 105
fluxDeriv(J,1) = -.5*dphidr(J).*dfds(J-1);
%-- dflux_{j+1/2}/ds_{j}
fluxDeriv(J,2) = .5*(2-phi(J)+dphidr(J).*...
(f(J+1)-f(J-1))./(df(J)+eps)).*dfds(J);
%-- dflux_{j+1/2}/ds_{j+1}
fluxDeriv(J,3) = .5*(phi(J)-dphidr(J).*rdf(J)).*dfds(J+1);
end
%**************************************************************
elseif(strcmp(NumFlux,’ENO2’))% 2nd-order ENO scheme
%**************************************************************
% initializations
ds = zeros(nxd-1,1);
df = zeros(nxd-1,1);
kmin1 = zeros(nxd,1);
kmin2 = zeros(nxd,1);
% numerical flux
ds = s(2:nxd)-s(1:nxd-1);
df = f(2:nxd)-f(1:nxd-1);
kmin1(J) = J’ +(df(J).*ds(J) < 0);
kmin2(J) = kmin1(J)-(abs(df(kmin1(J)))>abs(df(kmin1(J)-1)));
for j = J
if (kmin2(j) == j) % stencil (j,j+1)
flux(j) = .5*(f(j) + f(j+1));
if (nargout>1)
fluxDeriv(j,2) = .5*dfds(j);
fluxDeriv(j,3) = .5*dfds(j+1);
end
elseif (kmin2(j) == j-1) % stencil (j-1,j)
flux(j) = -.5*f(j-1) + 1.5*f(j);
if (nargout>1)
fluxDeriv(j,1) = -.5*dfds(j-1);
fluxDeriv(j,2) = 1.5*dfds(j);
end
else % stencil (j+1,j+2)
flux(j) = 1.5*f(j+1) - .5*f(j+2);
if (nargout>1)
fluxDeriv(j,3) = 1.5*dfds(j+1);
fluxDeriv(j,4) = -.5*dfds(j+2);
end
end
end
%**************************************************************
elseif(strcmp(NumFlux,’WENO2’))% 2nd-order WENO scheme
%**************************************************************
eps = 1.e-6;
% initializations
df = zeros(nxd-1,1); invdf2 = zeros(nxd-1,1); dfinvdf2 = zeros(nxd-1,1);
alpha0 = zeros(nxd,1); alpha1 = zeros(nxd,1); omega0 = zeros(nxd,1);
dalpha0ds = zeros(nxd,3); dalpha1ds = zeros(nxd,3); domega0ds = zeros(nxd,3);
% numerical flux
106 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
df = f(2:nxd)-f(1:nxd-1); invdf2 = 1./(df.^2+eps);
alpha0(J) = (1/3)*invdf2(J-1).^2;
alpha1(J) = (2/3)*invdf2(J).^2;
omega0(J) = alpha0(J)./(alpha0(J)+alpha1(J));
flux(J) = .5*(omega0(J).*(-f(J-1)+3*f(J)) +...
(1-omega0(J)).*(f(J)+f(J+1)));
% derivative of numerical flux
if (nargout>1)
dfinvdf2 = df.*(invdf2.^3);
dalpha0ds(J,1) = (4/3)*dfinvdf2(J-1).*dfds(J-1);
dalpha0ds(J,2) =-(4/3)*dfinvdf2(J-1).*dfds(J);
dalpha1ds(J,2) = (8/3)*dfinvdf2(J).*dfds(J);
dalpha1ds(J,3) =-(8/3)*dfinvdf2(J).*dfds(J+1);
for k=1:3
domega0ds(J,k) = (alpha1(J).*dalpha0ds(J,k) - ...
alpha0(J).*dalpha1ds(J,k))./(alpha0(J)+alpha1(J)).^2;
end
%-- dflux_{j+1/2}/ds_{j-1}
fluxDeriv(J,1) = -.5*omega0(J).*dfds(J-1) - ...
.5*domega0ds(J,1).*(df(J)-df(J-1));
%-- dflux_{j+1/2}/ds_{j}
fluxDeriv(J,2) = .5*(1+2*omega0(J)).*dfds(J) - ...
.5*domega0ds(J,2).*(df(J)-df(J-1));
%-- dflux_{j+1/2}/ds_{j+1}
fluxDeriv(J,3) = .5*(1-omega0(J)).*dfds(J+1) - ...
.5*domega0ds(J,3).*(df(J)-df(J-1));
end
%**************************************************************
elseif(strcmp(NumFlux,’sWENO2’))% split WENO2 scheme
%**************************************************************
eps = 1.e-6; a = 3.5; %max(abs(dfds));
% initializations
g = zeros(nxd,1); dg = zeros(nxd-1,1);
invdg2 = zeros(nxd-1,1); dginvdg2 = zeros(nxd-1,1);
alpha0 = zeros(nxd,1); alpha1 = zeros(nxd,1); omega0 = zeros(nxd,1);
dalpha0ds = zeros(nxd,3); dalpha1ds = zeros(nxd,3); domega0ds = zeros(nxd,3);
% positive part of numerical flux
g = .5*(f + a*s); dg = g(2:nxd)-g(1:nxd-1); invdg2 = 1./(dg.^2+eps);
alpha0(J) = (1/3)*invdg2(J-1).^2;
alpha1(J) = (2/3)*invdg2(J).^2;
omega0(J) = alpha0(J)./(alpha0(J)+alpha1(J));
flux(J) = .5*(omega0(J).*(-g(J-1)+3*g(J)) + (1-omega0(J)).*(g(J)+g(J+1)));
% derivative
if (nargout>1)
dgds = .5*(dfds + a); dginvdg2 = dg.*(invdg2.^3);
dalpha0ds(J,1) = (4/3)*dginvdg2(J-1).*dgds(J-1);
dalpha0ds(J,2) =-(4/3)*dginvdg2(J-1).*dgds(J);
dalpha1ds(J,2) = (8/3)*dginvdg2(J).*dgds(J);
dalpha1ds(J,3) =-(8/3)*dginvdg2(J).*dgds(J+1);
for k=1:3
C.4. NUMERICAL FLUX ROUTINE 107
domega0ds(J,k) = (alpha1(J).*dalpha0ds(J,k) - ...
alpha0(J).*dalpha1ds(J,k))./(alpha0(J)+alpha1(J)).^2;
end
%-- dflux_{j+1/2}/ds_{j-1}
fluxDeriv(J,1) = -.5*omega0(J).*dgds(J-1) - ...
.5*domega0ds(J,1).*(dg(J)-dg(J-1));
%-- dflux_{j+1/2}/ds_{j}
fluxDeriv(J,2) = .5*(1+2*omega0(J)).*dgds(J) - ...
.5*domega0ds(J,2).*(dg(J)-dg(J-1));
%-- dflux_{j+1/2}/ds_{j+1}
fluxDeriv(J,3) = .5*(1-omega0(J)).*dgds(J+1) - ...
.5*domega0ds(J,3).*(dg(J)-dg(J-1));
end
% negative part of numerical flux
g = .5*(f - a*s); dg = g(2:nxd)-g(1:nxd-1); invdg2 = 1./(dg.^2+eps);
alpha0(J) = (1/3)*invdg2(J+1).^2;
alpha1(J) = (2/3)*invdg2(J).^2;
omega0(J) = alpha0(J)./(alpha0(J)+alpha1(J));
flux(J) = flux(J) + .5*(omega0(J).*(-g(J+2)+3*g(J+1)) + (1-omega0(J)).*(g(J)+g(J+1)));
% derivative
if (nargout>1)
dgds = .5*(dfds - a); dginvdg2 = dg.*(invdg2.^3);
dalpha0ds(J,1) =-(4/3)*dginvdg2(J+1).*dgds(J+2);
dalpha0ds(J,2) = (4/3)*dginvdg2(J+1).*dgds(J+1);
dalpha1ds(J,2) =-(8/3)*dginvdg2(J).*dgds(J+1);
dalpha1ds(J,3) = (8/3)*dginvdg2(J).*dgds(J);
for k=1:3
domega0ds(J,k) = (alpha1(J).*dalpha0ds(J,k) - ...
alpha0(J).*dalpha1ds(J,k))./(alpha0(J)+alpha1(J)).^2;
end
%-- dflux_{j+1/2}/ds_{j+2}
fluxDeriv(J,4) = -.5*omega0(J).*dgds(J+2) - ...
.5*domega0ds(J,1).*(dg(J+1)-dg(J));
%-- dflux_{j+1/2}/ds_{j+1}
fluxDeriv(J,3) = fluxDeriv(J,3) + .5*(1+2*omega0(J)).*dgds(J+1) - ...
.5*domega0ds(J,2).*(dg(J+1)-dg(J));
%-- dflux_{j+1/2}/ds_{j}
fluxDeriv(J,2) = fluxDeriv(J,2) + .5*(1-omega0(J)).*dgds(J) - ...
.5*domega0ds(J,3).*(dg(J+1)-dg(J));
end
%**************************************************************
elseif(strcmp(NumFlux,’CS2’))% 2nd-order Central scheme
%**************************************************************
% initializations
ds = zeros(nxd-1,1);
dsx = zeros(nxd,1);
sL = zeros(nxd,1);
sR = zeros(nxd,1);
fL = zeros(nxd,1);
fR = zeros(nxd,1);
108 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
a = zeros(nxd,1);
dfLdsL = zeros(nxd,1);
dfRdsR = zeros(nxd,1);
dsLds = zeros(nxd,4);
dsRds = zeros(nxd,4);
dads = zeros(nxd,4);
% numerical flux
ds = s(2:nxd)-s(1:nxd-1);
for i=2:nxd-1
dsx(i) = MinMod(ds(i), .5*(ds(i-1)+ds(i)), ds(i-1));
end
sL(J) = s(J)+.5*dsx(J);
sR(J) = s(J+1)-.5*dsx(J+1);
fL(J) = fw_of_sw(sL(J));
fR(J) = fw_of_sw(sR(J));
dfLdsL(J) = dfw_dsw(sL(J));
dfRdsR(J) = dfw_dsw(sR(J));
% a(J) = max(abs(dfLdsL(J)), abs(dfRdsR(J))); % convex case only
a(J) = dfw_dsw(.5*(sL(J)+sR(J))); % case where fw’>0 always
flux(J) = .5*(fR(J)+fL(J)) - .5*a(J).*(sR(J)-sL(J));
% derivative of numerical flux
if (nargout>1)
dsLds(J,2) = 1; % neglect second-order
dsRds(J,3) = 1; % terms from dsx
% dads(J,2) = .5*(dfRdsR(J)-dfLdsL(J))./(sR(J)-sL(J)+eps);
% dads(J,3) = dads(J,2);
% fluxDeriv(J,1) = .5*(dfLdsL(J)+a(J)).*dsLds(J,1) - ...
% .5*(sR(J)-sL(J)).*dads(J,1);
% fluxDeriv(J,2) = .5*(dfLdsL(J)+a(J)).*dsLds(J,2) + ...
% .5*(dfRdsR(J)-a(J)).*dsRds(J,2) - .5*(sR(J)-sL(J)).*dads(J,2);
% fluxDeriv(J,3) = .5*(dfLdsL(J)+a(J)).*dsLds(J,3) ...
% + .5*(dfRdsR(J)-a(J)).*dsRds(J,3) - .5*(sR(J)-sL(J)).*dads(J,3);
% fluxDeriv(J,4) = .5*(dfRdsR(J)-a(J)).*dsRds(J,4) - ...
% .5*(sR(J)-sL(J)).*dads(J,4);
fluxDeriv(J,2) = .5*(dfLdsL(J)+a(J)).*dsLds(J,2) + ...
.5*(dfRdsR(J)-a(J)).*dsRds(J,2) - .25*(dfRdsR(J)-dfLdsL(J));
fluxDeriv(J,3) = .5*(dfLdsL(J)+a(J)).*dsLds(J,3) ...
+ .5*(dfRdsR(J)-a(J)).*dsRds(J,3) - .25*(dfRdsR(J)-dfLdsL(J));
end
%**************************************************************
elseif(strcmp(NumFlux,’ENO3’))% 3rd-order ENO scheme
%**************************************************************
% initializations
ds = zeros(nxd-1,1);
df = zeros(nxd-1,1);
d2f = zeros(nxd-1,1);
kmin1 = zeros(nxd,1);
kmin2 = zeros(nxd,1);
kmin3 = zeros(nxd,1);
C.4. NUMERICAL FLUX ROUTINE 109
% numerical flux
ds = s(2:nxd)-s(1:nxd-1);
df = f(2:nxd)-f(1:nxd-1);
d2f(2:nxd-1) = df(2:nxd-1) - df(1:nxd-2);
kmin1(J) = J’ +(df(J).*ds(J) < 0);
kmin2(J) = kmin1(J)-(abs(df(kmin1(J)))>abs(df(kmin1(J)-1)));
kmin3(J) = kmin2(J)-(abs(d2f(kmin2(J)+1))>abs(d2f(kmin2(J))));
for j = J
if (kmin3(j) == j-2) % stencil (j-2,j-1,j)
flux(j) = (2*f(j-2)-7*f(j-1)+11*f(j))/6;
if (nargout>1)
fluxDeriv(j,1) = 2*dfds(j-2)/6;
fluxDeriv(j,2) =-7*dfds(j-1)/6;
fluxDeriv(j,3) = 11*dfds(j)/6;
end
elseif (kmin3(j) == j-1) % stencil (j-1,j,j+1)
flux(j) = (-f(j-1)+5*f(j)+2*f(j+1))/6;
if (nargout>1)
fluxDeriv(j,2) =-dfds(j-1)/6;
fluxDeriv(j,3) = 5*dfds(j)/6;
fluxDeriv(j,4) = 2*dfds(j+1)/6;
end
elseif (kmin3(j) == j) % stencil (j,j+1,j+2)
flux(j) = (2*f(j)+5*f(j+1)-f(j+2))/6;
if (nargout>1)
fluxDeriv(j,3) = 2*dfds(j)/6;
fluxDeriv(j,4) = 5*dfds(j+1)/6;
fluxDeriv(j,5) =-dfds(j+2)/6;
end
else % stencil (j+1,j+2,j+3)
flux(j) = (11*f(j+1)-7*f(j+2)+2*f(j+3))/6;
if (nargout>1)
fluxDeriv(j,4) = 11*dfds(j+1)/6;
fluxDeriv(j,5) =-7*dfds(j+2)/6;
fluxDeriv(j,6) = 2*dfds(j+3)/6;
end
end
end
else
error(’Unknown numerical flux type’)
end
%******************************************************
% Artificial viscosity
%******************************************************
% option 1: s_t + [f(s)]_x = nu*Dx*[s_x]_x
% option 2: s_t + [f(s)]_x = nu*Dx*[f’(s)*s_x]_x
% option 3: s_t + [f(s)]_x = nu*Dx*[(f’(s)^2)*s_x]_x
% option 4: s_t + [f(s)]_x = nu*Dx*[2*f(s)*f’(s)*s_x]_x
% option 5: s_t + [f(s)]_x = nu*Dx*[(f(s)_x)^2]_x
110 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
%******************************************************
if (viscoption==1)
% nu(J,1) = nu0*(dfds_old(J)>dfds_old(J+1));
nu(J,1) = nu0*(dfds(J)>dfds(J+1));
flux(J) = flux(J) - nu(J).*(s(J+1)-s(J));
if (nargout>1)
fluxDeriv(J,m) = fluxDeriv(J,m) + nu(J);
fluxDeriv(J,m+1) = fluxDeriv(J,m+1) - nu(J);
end
elseif (viscoption==2)
% nu(J,1) = nu0*(dfds_old(J)>dfds_old(J+1));
nu(J,1) = nu0*(dfds(J)>dfds(J+1));
% vs = 1.95; nu(J,1) = nu0*(dfds_old(J)>vs);
% nu(J+1,1) = nu0;
flux(J) = flux(J) - nu(J).*(f(J+1)-f(J));
if (nargout>1)
fluxDeriv(J,m) = fluxDeriv(J,m) + nu(J).*dfds(J);
fluxDeriv(J,m+1) = fluxDeriv(J,m+1) - nu(J).*dfds(J+1);
end
elseif (viscoption==3)
% nu(J,1) = nu0*(dfds_old(J)>dfds_old(J+1));
nu(J,1) = nu0*(dfds(J)>dfds(J+1));
% nu(J+1,1) = nu0;
flux(J) = flux(J) - .5*nu(J).*(dfds(J)+dfds(J+1)).*(f(J+1)-f(J));
if (nargout>1)
d2fds = d2fw_dsw(s);
fluxDeriv(J,m) = fluxDeriv(J,m) - .5*nu(J).*(d2fds(J).*(f(J+1)-f(J))-(dfds(J)+dfds(J+1)).*dfds(J));
fluxDeriv(J,m+1) = fluxDeriv(J,m+1) - .5*nu(J).*(d2fds(J+1).*(f(J+1)-f(J))+(dfds(J)+dfds(J+1)).*dfds(J+1));
end
elseif (viscoption==4)
% nu(J,1) = nu0*(dfds_old(J)>dfds_old(J+1));
% nu(J,1) = nu0*(dfds(J)>dfds(J+1));
nu(J+1,1) = nu0;
flux(J) = flux(J) - nu(J).*(f(J+1).^2-f(J).^2);
if (nargout>1)
fluxDeriv(J,m) = fluxDeriv(J,m) + 2*nu(J).*f(J).*dfds(J);
fluxDeriv(J,m+1) = fluxDeriv(J,m+1) - 2*nu(J).*f(J+1).*dfds(J+1);
end
elseif (viscoption==5)
% nu(J,1) = nu0*(dfds_old(J)>dfds_old(J+1));
nu(J,1) = nu0*(dfds(J)>dfds(J+1));
flux(J) = flux(J) - nu(J).*(f(J+1)-f(J)).^2;
if (nargout>1)
fluxDeriv(J,m) = fluxDeriv(J,m) + 2*nu(J).*(f(J+1)-f(J)).*dfds(J);
fluxDeriv(J,m+1) = fluxDeriv(J,m+1) - 2*nu(J).*(f(J+1)-f(J)).*dfds(J+1);
end
end
%================================================================
function res = MinMod(a,b,c)
C.5. AIM-STD ROUTINE 111
%================================================================
m = min([a,b,c]);
M = max([a,b,c]);
if(m>0)
res = m;
elseif(M<0)
res = M;
else
res = 0;
end
C.5 AIM-STD routine
%*********************************%
% Standard AIM scheme (AIM-STD) %
%*********************************%
% Max. CFL number:
%-----------------
% - used as a switching criterion for implicit blocks
% - always between 0 and 1
cfl = 0.99;
% Time loop
while(1)
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
%--Implicit/explicit blocks
vmax = CalcMaxSpeed(s, nx, m);
kImp = 0; K = 0;
for i = I
if (vmax(i)*dt_dx > cfl)
kImp = kImp+1;
K(kImp) = i;
end
end
disp([’Number of implicit cells: ’,int2str(kImp)])
%--Initialization
[flux, fluxDeriv] = CalcFlux(nx, s, NumFlux, m);
L0 = dt_dx*(flux(I)-flux(I-1)); R = L0;
norm2 = norm(R,2); iter = 0;
%--Newton loop
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%----Jacobian
112 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
DR = eye(nxd,nxd);
if (kImp>0)
for i=K
for k=-m:1:m-1
tmp = dt_dx*fluxDeriv(i+k,m-k);
DR(i+k,i) = DR(i+k,i) + tmp;
DR(i+k+1,i) = DR(i+k+1,i) - tmp;
end
end
end
DR_sparse = sparse(DR(I,I));
%----Update
delta_s = -(DR_sparse\R);
r = 1-(iter<=2)/(iter+1)^2;
s1(I) = s1(I) + r*delta_s;
if (kImp>0)
s2(K) = s1(K);
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
end
R = s1(I)-s(I) + dt_dx*(flux(I)-flux(I-1));
%----Check convergence
norm2 = norm(R,2);
if (norm2 < pNewton(1))
break;
elseif (iter > pNewton(2))
% error(’Maximum number of iterations exceeded’)
disp(’Reduce time step...’)
dt = dt/2; dt_dx = dt/dx;
if (dt<pTime(3))
error(’Time step too small’)
else
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
end
s1 = s; [flux, fluxDeriv] = CalcFlux(nx, s, NumFlux, m);
L0 = L0/2; R = L0; norm2 = norm(R,2); iter = 0;
end
end % end of Newton loop
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Final step
ds_max = norm(s1(I)-s(I), inf);
s = s1; s2 = s;
%--Time stepping
t = t + dt; nt = nt + 1;
if (t >= pTime(1))
break;
end
C.6. AIM-BE ROUTINE 113
dt = dt*(1 + pTime(5))*pTime(6)/(ds_max + pTime(5)*pTime(6));
dt = min(pTime(4), max(pTime(3), dt));
if (t+dt > pTime(1))
dt = pTime(1) - t;
end
dt_dx = dt/dx;
end % end of time loop
C.6 AIM-BE routine
%***********************************************%
% AIM based on Backward-Euler scheme (AIM-BE) %
%***********************************************%
% Max. CFL number:
%-----------------
% - used as a switching criterion for implicit blocks
% - always between 0 and 1
cfl = 0.5;
% Time loop
while(1)
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
%--Implicit/explicit blocks
vmax = CalcMaxSpeed(s, nx, m);
kImp = 0; K = 0;
for i = I
if (vmax(i)*dt_dx > cfl)
kImp = kImp+1;
K(kImp) = i;
end
end
disp([’Number of implicit cells: ’,int2str(kImp)])
%--Initialization
flux = CalcFlux(nx, s, NumFlux, m);
L0 = dt_dx*(flux(I)-flux(I-1));
s1(I) = s(I) - L0; s2 = s1;
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
R = -L0 + dt_dx*(flux(I)-flux(I-1));
norm2 = norm(R,2); iter = 0;
%--Newton loop
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%----Jacobian
114 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
DR = eye(nxd,nxd);
if (kImp>0)
for i=K
for k=-m:1:m-1
tmp = dt_dx*fluxDeriv(i+k,m-k);
DR(i+k,i) = DR(i+k,i) + tmp;
DR(i+k+1,i) = DR(i+k+1,i) - tmp;
end
end
end
DR_sparse = sparse(DR(I,I));
%----Update
delta_s = -(DR_sparse\R);
r = 1-(iter<=2)/(iter+1)^2;
s1(I) = s1(I) + r*delta_s;
if (kImp>0)
s2(K) = s1(K);
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
end
R = s1(I)-s(I) + dt_dx*(flux(I)-flux(I-1));
%----Check convergence
norm2 = norm(R,2);
if (norm2 < pNewton(1))
break;
elseif (iter > pNewton(2))
% error(’Maximum number of iterations exceeded’)
disp(’Reduce time step...’)
dt = dt/2; dt_dx = dt/dx;
if (dt<pTime(3))
error(’Time step too small’)
else
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
end
L0 = L0/2; s1(I) = s(I) - L0; s2 = s1;
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
R = -L0 + dt_dx*(flux(I)-flux(I-1));
norm2 = norm(R,2); iter = 0;
end
end % end of Newton loop
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Final step
ds_max = norm(s1(I)-s(I), inf);
s(I) = s1(I);
%--Time stepping
t = t + dt; nt = nt + 1;
if (t >= pTime(1))
C.7. AIM-BE/TRK2 ROUTINE 115
break;
end
dt = dt*(1 + pTime(5))*pTime(6)/(ds_max + pTime(5)*pTime(6));
dt = min(pTime(4), max(pTime(3), dt));
if (t+dt > pTime(1))
disp(K); dt = pTime(1) - t;
end
dt_dx = dt/dx;
end % end of time loop
C.7 AIM-BE/TRK2 routine
%**************************************************************%
% AIM based on Backward-Euler/Trapezoidal rule (AIM-BE/TRK2) %
%**************************************************************%
% Max. CFL number:
%-----------------
% - used as a switching criterion for implicit blocks
% - always between 0 and 1
cfl = 0.99;
% Need additional arrays
s3 = s; flux1 = flux; flux2 = flux;
fluxDeriv1 = fluxDeriv; fluxDeriv2 = fluxDeriv;
% Time loop
while(1)
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
%--Implicit/explicit blocks
vmax = CalcMaxSpeed(s, nx, m);
kImp = 0; K = 0;
for i = I
if (vmax(i)*dt_dx > cfl)
kImp = kImp+1;
K(kImp) = i;
end
end
disp([’Number of implicit cells: ’,int2str(kImp)])
%--Initialization
flux = CalcFlux(nx, s, NumFlux, m);
L0 = dt_dx*(flux(I)-flux(I-1));
s3(I) = s(I) - L0; s1 = s3; s2 = s;
if (kImp>0)
s2(K) = s3(K);
end
[flux1, fluxDeriv1] = CalcFlux(nx, s1, NumFlux, m);
116 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
[flux2, fluxDeriv2] = CalcFlux(nx, s2, NumFlux, m);
R = -L0 + .5*dt_dx*(flux1(I)-flux1(I-1) + flux2(I)-flux2(I-1));
norm2 = norm(R,2); iter = 0;
%--Newton loop
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%----Jacobian
DR = eye(nxd,nxd);
if (kImp>0)
for i=K
for k=-m:1:m-1
tmp = .5*dt_dx*(fluxDeriv1(i+k,m-k)+fluxDeriv2(i+k,m-k));
DR(i+k,i) = DR(i+k,i) + tmp;
DR(i+k+1,i) = DR(i+k+1,i) - tmp;
end
end
end
DR_sparse = sparse(DR(I,I));
%----Update
delta_s = -(DR_sparse\R);
r = 1-(iter<=2)/(iter+1)^2;
s3(I) = s3(I) + r*delta_s;
if (kImp>0)
s1(K) = s3(K); s2(K) = s3(K);
[flux1, fluxDeriv1] = CalcFlux(nx, s1, NumFlux, m);
[flux2, fluxDeriv2] = CalcFlux(nx, s2, NumFlux, m);
end
R = s3(I)-s(I) + .5*dt_dx*(flux1(I)-flux1(I-1) + flux2(I)-flux2(I-1));
%----Check convergence
norm2 = norm(R,2);
if (norm2 < pNewton(1))
break;
elseif (iter > pNewton(2))
% error(’Maximum number of iterations exceeded’)
disp(’Reduce time step...’)
dt = .5*dt; dt_dx = .5*dt_dx;
if (dt<pTime(3))
error(’Time step too small’)
else
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
end
L0 = L0/2; s3(I) = s(I) - L0; s1 = s3; s2 = s;
if (kImp>0)
s2(K) = s3(K);
end
C.8. AIM-TRK2 ROUTINE 117
[flux1, fluxDeriv1] = CalcFlux(nx, s1, NumFlux, m);
[flux2, fluxDeriv2] = CalcFlux(nx, s2, NumFlux, m);
R = -L0 + .5*dt_dx*(flux1(I)-flux1(I-1) + flux2(I)-flux2(I-1));
norm2 = norm(R,2); iter = 0;
end
end % end of Newton loop
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Final step
ds_max = norm(s3(I)-s(I), inf);
s(I) = s3(I);
%--Time stepping
t = t + dt; nt = nt + 1;
if (t >= pTime(1))
break;
end
dt = dt*(1 + pTime(5))*pTime(6)/(ds_max + pTime(5)*pTime(6));
dt = min(pTime(4), max(pTime(3), dt));
if (t+dt > pTime(1))
disp(K); dt = pTime(1) - t;
end
dt_dx = dt/dx;
end % end of time loop
C.8 AIM-TRK2 routine
%*****************************************************%
% AIM based on implicit trapezoidal rule (AIM-TRK2) %
%*****************************************************%
% Max. CFL number:
%-----------------
% - used as a switching criterion for implicit blocks
% - always between 0 and 1
cfl = 0.9;
% Time loop
while(1)
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
%--Implicit/explicit blocks
vmax = CalcMaxSpeed(s, nx, m);
kImp = 0; K = 0;
for i = I
if (vmax(i)*dt_dx > cfl)
kImp = kImp+1;
K(kImp) = i;
end
118 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
end
disp([’Number of implicit cells: ’,int2str(kImp)]), K
%--Initialization
flux = CalcFlux(nx, s, NumFlux, m);
L0 = dt_dx*(flux(I)-flux(I-1));
s1(I) = s1(I) - L0; s2 = s1;
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
R = -.5*L0 + .5*dt_dx*(flux(I)-flux(I-1));
norm2 = norm(R,2); iter = 0;
%--Newton loop
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%----Jacobian
DR = eye(nxd,nxd);
if (kImp>0)
for i=K
for k=-m:1:m-1
tmp = .5*dt_dx*fluxDeriv(i+k,m-k);
DR(i+k,i) = DR(i+k,i) + tmp;
DR(i+k+1,i) = DR(i+k+1,i) - tmp;
end
end
end
DR_sparse = sparse(DR(I,I));
%----Update
delta_s = -(DR_sparse\R);
r = 1-(iter<=2)/(iter+1)^2;
s1(I) = s1(I) + r*delta_s;
if (kImp>0)
s2(K) = s1(K);
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
end
R = s1(I)-s(I) + .5*L0 + .5*dt_dx*(flux(I)-flux(I-1));
%----Check convergence
norm2 = norm(R,2);
if (norm2 < pNewton(1))
break;
elseif (iter > pNewton(2))
% error(’Maximum number of iterations exceeded’)
disp(’Reduce time step...’)
dt = dt/2; dt_dx = dt/dx;
if (dt<pTime(3))
error(’Time step too small’)
else
C.9. AIM-CRK2 ROUTINE 119
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
end
L0 = L0/2; s1(I) = s(I) - L0; s2 = s1;
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
R = -.5*L0 + .5*dt_dx*(flux(I)-flux(I-1));
norm2 = norm(R,2); iter = 0;
end
end % end of Newton loop
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Final step
ds_max = norm(s1(I)-s(I), inf);
s(I) = s1(I);
%--Time stepping
t = t + dt; nt = nt + 1;
if (t >= pTime(1))
break;
end
dt = dt*(1 + pTime(5))*pTime(6)/(ds_max + pTime(5)*pTime(6));
dt = min(pTime(4), max(pTime(3), dt));
if (t+dt > pTime(1))
dt = pTime(1) - t;
end
dt_dx = dt/dx;
end % end of time loop
C.9 AIM-CRK2 routine
%**************************************************%
% AIM based on implicit midpoint rule (AIM-CRK2) %
%**************************************************%
% Max. CFL number:
%-----------------
% - used as a switching criterion for implicit blocks
% - always between 0 and 1
cfl = 0.9;
% Time loop
while(1)
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
%--Implicit/explicit blocks
vmax = CalcMaxSpeed(s, nx, m);
kImp = 0; K = 0;
for i = I
if (vmax(i)*dt_dx > cfl)
kImp = kImp+1;
120 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
K(kImp) = i;
end
end
disp([’Number of implicit cells: ’,int2str(kImp)])
%--Initialization
s1 = s; s2 = s;
flux = CalcFlux(nx, s1, NumFlux, m);
L0 = dt_dx*(flux(I)-flux(I-1));
s1(I) = s(I) - L0; s2(I) = s(I) - .5*L0;
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
R = -L0 + dt_dx*(flux(I)-flux(I-1));
norm2 = norm(R,2); iter = 0;
%--Newton loop
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%----Jacobian
DR = eye(nxd,nxd);
if (kImp>0)
for i=K
for k=-m:1:m-1
tmp = .5*dt_dx*fluxDeriv(i+k,m-k);
DR(i+k,i) = DR(i+k,i) + tmp;
DR(i+k+1,i) = DR(i+k+1,i) - tmp;
end
end
end
DR_sparse = sparse(DR(I,I));
%----Update
delta_s = -(DR_sparse\R);
r = 1-(iter<=2)/(iter+1)^2;
s1(I) = s1(I) + r*delta_s;
if (kImp>0)
s2(K) = .5*(s(K)+s1(K));
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
end
R = s1(I)-s(I) + dt_dx*(flux(I)-flux(I-1));
%----Check convergence
norm2 = norm(R,2);
if (norm2 < pNewton(1))
break;
elseif (iter > pNewton(2))
% error(’Maximum number of iterations exceeded’)
disp(’Reduce time step...’)
dt = dt/2; dt_dx = dt/dx;
C.10. AIM-IRK2 ROUTINE 121
if (dt<pTime(3))
error(’Time step too small’)
else
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
end
L0 = L0/2; s1(I) = s(I) - L0; s2(I) = s(I) - .5*L0;
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
R = -L0 + dt_dx*(flux(I)-flux(I-1));
norm2 = norm(R,2); iter = 0;
end
end % end of Newton loop
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Final step
ds_max = norm(s1(I)-s(I), inf);
s(I) = s1(I);
%--Time stepping
t = t + dt; nt = nt + 1;
if (t >= pTime(1))
break;
end
dt = dt*(1 + pTime(5))*pTime(6)/(ds_max + pTime(5)*pTime(6));
dt = min(pTime(4), max(pTime(3), dt));
if (t+dt > pTime(1))
dt = pTime(1) - t;
end
dt_dx = dt/dx;
end % end of time loop
C.10 AIM-IRK2 routine
%***************************************%
% AIM based on IRK2 scheme (AIM-IRK2) %
%***************************************%
% Max. CFL number:
%-----------------
% - used as a switching criterion for implicit blocks
% - always between 0 and 1
cfl = 0.9;
c1 = 1/3;
a11 = 5/12;
b1 = 1/(2*(1-c1));
b2 = 1-b1;
% Time loop
while(1)
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
122 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
%--Implicit/explicit blocks
vmax = CalcMaxSpeed(s, nx, m);
kImp = 0; K = 0;
for i = I
if (vmax(i)*dt_dx > cfl)
kImp = kImp+1;
K(kImp) = i;
end
end
disp([’Number of implicit cells: ’,int2str(kImp)])
%--Initialization
[flux, fluxDeriv] = CalcFlux(nx, s, NumFlux, m);
L0 = dt_dx*(flux(I)-flux(I-1));
s1(I) = s(I)-c1*L0; s2(I) = s(I)-L0; y = [s1(I); s2(I)];
[flux1, fluxDeriv1] = CalcFlux(nx, s1, NumFlux, m);
[flux2, fluxDeriv2] = CalcFlux(nx, s2, NumFlux, m);
R1 = -c1*L0 + a11*dt_dx*(flux1(I)-flux1(I-1)) +...
(c1-a11)*dt_dx*(flux2(I)-flux2(I-1));
R2 = -L0 + b1*dt_dx*(flux1(I)-flux1(I-1)) +...
b2*dt_dx*(flux2(I)-flux2(I-1));
R = [R1; R2]; norm2 = norm(R,2); iter = 0;
%--Newton loop
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%----Jacobian
DR1 = zeros(nxd,nxd);
DR2 = zeros(nxd,nxd);
if (kImp>0)
for i=K
for k=-m:1:m-1
tmp = dt_dx*fluxDeriv1(i+k,m-k);
DR1(i+k,i) = DR1(i+k,i) + tmp;
DR1(i+k+1,i) = DR1(i+k+1,i) - tmp;
tmp = dt_dx*fluxDeriv2(i+k,m-k);
DR2(i+k,i) = DR2(i+k,i) + tmp;
DR2(i+k+1,i) = DR2(i+k+1,i) - tmp;
end
end
end
DR = eye(2*nx) + [a11*DR1(I,I) (c1-a11)*DR2(I,I);...
b1*DR1(I,I) b2*DR2(I,I)];
DR_sparse = sparse(DR);
%----Update
delta_y = -(DR_sparse\R);
C.10. AIM-IRK2 ROUTINE 123
r = 1-(iter<=2)/(iter+1)^2;
y = y + r*delta_y;
if (kImp>0)
s1(K) = y(K-m);
s2(K) = y(nx+K-m);
[flux1, fluxDeriv1] = CalcFlux(nx, s1, NumFlux, m);
[flux2, fluxDeriv2] = CalcFlux(nx, s2, NumFlux, m);
end
R1 = s1(I)-s(I) + a11*dt_dx*(flux1(I)-flux1(I-1)) +...
(c1-a11)*dt_dx*(flux2(I)-flux2(I-1));
R2 = s2(I)-s(I) + b1*dt_dx*(flux1(I)-flux1(I-1)) +...
b2*dt_dx*(flux2(I)-flux2(I-1));
R = [R1; R2];
%----Check convergence
norm2 = norm(R,2);
if (norm2 < pNewton(1))
break;
elseif (iter > pNewton(2))
% error(’Maximum number of iterations exceeded’)
disp(’Reduce time step...’)
dt = dt/2; dt_dx = dt/dx;
if (dt<pTime(3))
error(’Time step too small’)
else
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
end
L0 = L0/2; s1(I) = s(I)-c1*L0; s2(I) = s(I)-L0;
[flux1, fluxDeriv1] = CalcFlux(nx, s1, NumFlux, m);
[flux2, fluxDeriv2] = CalcFlux(nx, s2, NumFlux, m);
R1 = -c1*L0 + a11*dt_dx*(flux1(I)-flux1(I-1)) +...
(c1-a11)*dt_dx*(flux2(I)-flux2(I-1));
R2 = -L0 + b1*dt_dx*(flux1(I)-flux1(I-1)) +...
b2*dt_dx*(flux2(I)-flux2(I-1));
y = [s1(I); s2(I)]; R = [R1; R2];
norm2 = norm(R,2); iter = 0;
end
end % end of Newton loop
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Final step
ds_max = norm(y(nx+I-m)-s(I), inf);
s(I) = y(nx+I-m);
%--Time stepping
t = t + dt; nt = nt + 1;
if (t >= pTime(1))
break;
end
dt = dt*(1 + pTime(5))*pTime(6)/(ds_max + pTime(5)*pTime(6));
124 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
dt = min(pTime(4), max(pTime(3), dt));
if (t+dt > pTime(1))
dt = pTime(1) - t;
end
dt_dx = dt/dx;
end % end of time loop
C.11 AIM-DIRK3 routine
%****************************************%
% AIM based on DIRK scheme (AIM-DIRK3) %
%****************************************%
% Max. CFL number:
%-----------------
% - used as a switching criterion for implicit blocks
% - always between 0 and 1
cfl = 0.9;
gamma = 1/2 + sqrt(3)/6;
% Time loop
while(1)
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
%--Implicit/explicit blocks
vmax = CalcMaxSpeed(s, nx, m);
kImp = 0; K = 0;
for i = I
if (vmax(i)*dt_dx > cfl)
kImp = kImp+1;
K(kImp) = i;
end
end
disp([’Number of implicit cells: ’,int2str(kImp)])
%--Initialization of stage 1
flux = CalcFlux(nx, s, NumFlux, m);
L0 = dt_dx*(flux(I)-flux(I-1));
s1(I) = s(I)-gamma*L0; s2 = s1;
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
R = -gamma*L0 + gamma*dt_dx*(flux(I)-flux(I-1));
norm2 = norm(R,2); iter = 0;
%--Newton loop 1
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%----Jacobian
C.11. AIM-DIRK3 ROUTINE 125
DR = eye(nxd,nxd);
if (kImp>0)
for i=K
for k=-m:1:m-1
tmp = gamma*dt_dx*fluxDeriv(i+k,m-k);
DR(i+k,i) = DR(i+k,i) + tmp;
DR(i+k+1,i) = DR(i+k+1,i) - tmp;
end
end
end
DR_sparse = sparse(DR(I,I));
%----Update
delta_s = -(DR_sparse\R);
r = 1-(iter<=2)/(iter+1)^2;
s1(I) = s1(I) + r*delta_s;
if (kImp>0)
s2(K) = s1(K);
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
end
R = s1(I)-s(I) + gamma*dt_dx*(flux(I)-flux(I-1));
%----Check convergence
norm2 = norm(R,2);
if (norm2 < pNewton(1))
break;
elseif (iter > pNewton(2))
error(’Maximum number of iterations exceeded’)
end
end % end of Newton loop 1
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Initialization of stage 2
L1 = dt_dx*(flux(I)-flux(I-1));
% s2(I) = s(I) - (1-gamma)*L0;
% flux = CalcFlux(nx, s2, NumFlux, m);
% L2 = dt_dx*(flux(I)-flux(I-1));
% s1(I) = s(I) - (1-2*gamma)*L1 - gamma*L2; s2 = s1;
s1(I) = s(I)-(1-gamma)*L0; s2 = s1;
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
% R = -gamma*L2 + gamma*dt_dx*(flux(I)-flux(I-1));
R = -(1-gamma)*L0 + (1-2*gamma)*L1 + gamma*dt_dx*(flux(I)-flux(I-1));
norm2 = norm(R,2); iter = 0;
%--Newton loop 2
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%----Jacobian
126 APPENDIX C. MATLAB CODE FOR 1D NUMERICAL TESTS
DR = eye(nxd,nxd);
if (kImp>0)
for i=K
for k=-m:1:m-1
tmp = gamma*dt_dx*fluxDeriv(i+k,m-k);
DR(i+k,i) = DR(i+k,i) + tmp;
DR(i+k+1,i) = DR(i+k+1,i) - tmp;
end
end
end
DR_sparse = sparse(DR(I,I));
%----Update
delta_s = -(DR_sparse\R);
r = 1-(iter<=2)/(iter+1)^2;
s1(I) = s1(I) + r*delta_s;
if (kImp>0)
s2(K) = s1(K);
[flux, fluxDeriv] = CalcFlux(nx, s2, NumFlux, m);
end
R = s1(I)-s(I) + (1-2*gamma)*L1 + gamma*dt_dx*(flux(I)-flux(I-1));
%----Check convergence
norm2 = norm(R,2);
if (norm2 < pNewton(1))
break;
elseif (iter > pNewton(2))
error(’Maximum number of iterations exceeded’)
end
end % end of Newton loop 2
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Final step
s1(I) = s(I) - .5*L1 - .5*dt_dx*(flux(I)-flux(I-1));
ds_max = norm(s1(I)-s(I), inf);
s(I) = s1(I);
%--Time stepping
t = t + dt; nt = nt + 1;
if (t >= pTime(1))
break;
end
dt = dt*(1 + pTime(5))*pTime(6)/(ds_max + pTime(5)*pTime(6));
dt = min(pTime(4), max(pTime(3), dt));
if (t+dt > pTime(1))
dt = pTime(1) - t;
end
dt_dx = dt/dx;
end % end of time loop
Appendix D
Matlab code for 2D numerical tests
D.1 Main routine
%**************************************************************************
%* Incompressible 2D flow in homogeneous porous media *
%**************************************************************************
%* 1. Miscible case: | 2. Immiscible case: *
%* - no diffusion, no gravity | - gravity in y *
%* - constant viscosity | - constant velocity field *
%* - quarter five spot geometry | - no capillarity *
%**************************************************************************
clear all, close all
global pFluid
% Reservoir properties
L = 100; % length in x and y [m]
H = 1; % depth [m]
kx = 1e-13; % permeability in x [m^2]
ky = kx; % permeability in y [m^2]
phi = 0.3; % porosity
c0 = 1; % initial concentration
qw = 0.e-3; % well rate [m^3/s]
cw = 1; % injected fluid concentration
% Fluid properties
miscible = 0; % flag=1/0 for miscible/immiscible
mu = 1e-3; % fluid viscosity [Pa.s]
swr = 0.0; % irreducible water saturation
sor = 0.0; % residual oil saturation
krw0 = 1.0; % end point rel. perm. for water
kro0 = 1.0; % end point rel. perm. for oil
nw = 2.0; % water exponent
no = 2.0; % oil exponent
127
128 APPENDIX D. MATLAB CODE FOR 2D NUMERICAL TESTS
M = 1.0; % mobility ratio
G = 5.0; % gravity number
pFluid = [swr, sor, krw0, kro0, nw, no, M, G];
% Grid
nx = 35; ny = 35;
dx = L/nx; dy = L/ny;
I = (1:nx); J = (1:ny);
x = linspace(dx/2,L-dx/2,nx);
y = linspace(dy/2,L-dy/2,ny);
Vp = phi*dx*dy*H;
% Scheme parameters
theta = 1/2; AIM = 1; m = 2;
NumFx = ’WENO2’; ix = 0;
NumFy = ’sWENO2’; iy = 1;
Ib = (m:nx+m); Jb = (m:ny+m);
% Time stepping
tf = 3.0e5; % final time
dt0 = 100; % initial time step size
dtMin = 1; % minimum time step size
dtMax = 15000; % maximum time step size
eta = .9; % increasing factor for next step
dc_opt = 0.9; % optimal change in c per time step
cfl = 0.5;
% Newton parameters
tol = 1.e-8; % absolute tolerance for the residual
iterMax = 15; % maximum number of Newton iterations
%=======================================================
% F L O W %
%=======================================================
if (miscible==1) % solve Laplace’s equation for pressure
Tx = kx*dy*H/(mu*dx);
Ty = ky*dx*H/(mu*dy);
diagA = zeros(nx*ny, 5);
p = zeros(nx*ny, 1); b = zeros(nx*ny, 1);
vx = zeros(nx+1,ny); vy = zeros(nx,ny+1);
for j = 1 : ny % loop in x-direction
for i = 1 : nx-1
n_cell = (j-1)*nx + i;
diagA(n_cell, 3) = diagA(n_cell, 3) - Tx;
diagA(n_cell+1, 4) = Tx; diagA(n_cell, 2) = Tx;
diagA(n_cell+1, 3) = diagA(n_cell+1, 3) - Tx;
end
end
for i = 1 : nx % loop in y-direction
for j = 1 : ny-1
D.1. MAIN ROUTINE 129
n_cell = (j-1)*nx + i;
diagA(n_cell, 3) = diagA(n_cell, 3) - Ty;
diagA(n_cell+nx, 5) = Ty; diagA(n_cell, 1) = Ty;
diagA(n_cell+nx, 3) = diagA(n_cell+nx, 3) - Ty;
end
end
spdiagA = spdiags(diagA, [-nx,-1,0,1,nx], nx*ny, nx*ny);
b(1) = b(1) - qw; b(nx*ny) = b(nx*ny) + qw;
p = spdiagA\b; p2D = reshape(p,nx,ny);
for i = 1 : nx-1
vx(i+1,:) = kx*(p2D(i,:)-p2D(i+1,:))/(mu*dx);
end
for j = 1 : ny-1
vy(:,j+1) = ky*(p2D(:,j)-p2D(:,j+1))/(mu*dy);
end
vxc = zeros(nx,ny); vyc = zeros(nx,ny);
for i = 1 : nx
for j = 1 : ny
vxc(i,j) = .5*(vx(i,j)+vx(i+1,j));
vyc(i,j) = .5*(vy(i,j)+vy(i,j+1));
end
end
else % assume constant velocity field in direction theta=pi/4
vx = ones(nx+1,ny)*1.e-5; vy = ones(nx,ny+1)*1.e-5;
end
%=======================================================
% T R A N S P O R T %
%=======================================================
% Jacobian related arrays
kx = 1; ky = 1;
for k=-2*m:-m-1
nd(k+2*m+1) = (k+m)*nx;
ndy(ky) = k+2*m+1; ky=ky+1;
end
for k=-m:m
nd(k+2*m+1) = k;
ndx(kx) = k+2*m+1; kx=kx+1;
end
ndy(ky) = 2*m+1; ky=ky+1;
for k=m+1:2*m
nd(k+2*m+1) = (k-m)*nx;
ndy(ky) = k+2*m+1; ky=ky+1;
end
ndxl = ndx(2:2*m+1); ndxr = ndx(1:2*m);
ndyl = ndy(2:2*m+1); ndyr = ndy(1:2*m);
% Initial condition
if (miscible==1)
c = c0*ones(nx+2*m,ny+2*m);
130 APPENDIX D. MATLAB CODE FOR 2D NUMERICAL TESTS
else
c = zeros(nx+2*m,ny+2*m);
for i =I
for j=J
c(i+m,j+m) = c0*((x(i)-L/2)^2+(y(j)-L/2)^2 < (L/4)^2);
end
end
end
% Time loop
t = 0; dt = dt0; nt = 1; c1 = c;
while(1)
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
%--Implicit/explicit blocks
isImp = zeros(nx,ny); nImp = 0;
if ((AIM==1)&(theta>0))
if (miscible==1)
for i=I
for j=J
locCFL(i,j) = (vx(i+1,j)/dx+vy(i,j+1)/dy)*dt/phi;
if (locCFL(i,j) > cfl)
isImp(i,j) = 1; nImp = nImp+1;
end
end
end
locCFL(1,1)
if (isImp(1,1)==0)
isImp(1,1) = 1; nImp = nImp+1;
end
if (isImp(nx,ny)==0)
isImp(nx,ny) = 1; nImp = nImp+1;
end
else
for i=I
for j=J
cL_x = 0.5*(c(i+m-1,j+m) + c(i+m,j+m) );
cR_x = 0.5*(c(i+m,j+m) + c(i+m+1,j+m));
cL_y = 0.5*(c(i+m,j+m-1) + c(i+m,j+m) );
cR_y = 0.5*(c(i+m,j+m) + c(i+m,j+m+1));
vxm = max(abs(dfw_dsw(cL_x)*vx(i,j)), abs(dfw_dsw(cR_x)*vx(i+1,j)));
vym = max(abs(dgw_dsw(cL_y)*vy(i,j)), abs(dgw_dsw(cR_y)*vy(i,j+1)));
locCFL(i,j) = (vxm/dx+vym/dy)*dt/phi;
if (locCFL(i,j) > cfl)
isImp(i,j) = 1; nImp = nImp+1;
end
end
end
max(max(locCFL))
end
D.1. MAIN ROUTINE 131
elseif(theta>0)% fully implicit
isImp = ones(nx,ny); nImp = nx*ny;
end
disp([10,’Number of implicit cells = ’,num2str(nImp)])
figure(3), mesh(x,y,c(I+m,J+m)’), view(60,30)
figure(5), imagesc((~isImp)’), xlabel(’x’,’FontSize’,14), ylabel(’y’,’FontSize’,14)
colormap(gray), set(gca,’YDir’, ’normal’,’XtickLabel’,[],’YtickLabel’,[])
set(gca,’Xtick’,[.5:1:nx-.5],’Ytick’,[.5:1:ny-.5]), grid on, axis square
pause
%--Initialization
R0 = zeros(nx*ny,1); DR = zeros(nx*ny,4*m+1);
%%--initial guess (Forward Euler solution)
for j=J
[flux] = CalcFlux(nx, c(:,j+m), NumFx, m, ix);
flux(Ib) = H*dy*vx(:,j).*flux(Ib);
R0((j-1)*nx+I) = dt*(flux(I+m)-flux(I+m-1));
end
for i=I
[flux] = CalcFlux(ny, c(i+m,:)’, NumFy, m, iy);
flux(Jb) = H*dx*vy(i,:)’.*flux(Jb);
R0(i:nx:nx*ny) = R0(i:nx:nx*ny) + dt*(flux(J+m)-flux(J+m-1));
end
R0(1) = R0(1) - dt*qw*cw;
R0(nx*ny) = R0(nx*ny) + dt*qw*c1(nx+m,ny+m);
c1(I+m,J+m) = c(I+m,J+m) - reshape(R0,nx,ny)/Vp;
% c1(I,J) = min(max(c1(I,J),0),1);
if (miscible==1)
for k = 1:m
c1(I+m,k) = c1(I+m,m+1);
c1(I+m,ny+m+k) = c1(I+m,ny+m);
c1(k,J+m) = c1(m+1,J+m);
c1(nx+m+k,J+m) = c1(nx+m,J+m);
end
end
c2 = c1;
%%--initial residual and Jacobian
CalcRJ; norm2 = norm(R,2); iter = 0;
%--Newton loop
while(1)
disp([’iteration ’,int2str(iter),’: res = ’,num2str(norm2)])
iter = iter + 1;
%%--Solve linearized system
DR_sp = spdiags(DR, nd, nx*ny, nx*ny);
dc = -(DR_sp\R);
r = 1-(iter<=0)/(iter+1)^2; dc1 = r*reshape(dc,nx,ny);
c1(I+m,J+m) = c1(I+m,J+m) + dc1;
%%--Apply BC’s (dc/dn=0)
if (miscible==1)
132 APPENDIX D. MATLAB CODE FOR 2D NUMERICAL TESTS
for k = 1:m
c1(I+m,k) = c1(I+m,m+1);
c1(I+m,ny+m+k) = c1(I+m,ny+m);
c1(k,J+m) = c1(m+1,J+m);
c1(nx+m+k,J+m) = c1(nx+m,J+m);
end
end
%%--Update residual and Jacobian
if (nImp>0)
c2(I+m,J+m) = c2(I+m,J+m) + isImp(I,J).*dc1(I,J);
if (miscible==1)
for k = 1:m
c2(I+m,k) = c2(I+m,m+1);
c2(I+m,ny+m+k) = c2(I+m,ny+m);
c2(k,J+m) = c2(m+1,J+m);
c2(nx+m+k,J+m) = c2(nx+m,J+m);
end
end
end
CalcRJ;
%%--Check convergence
norm2 = norm(R,2);
if (norm2 < tol*Vp)
break;
elseif (iter > iterMax)
disp(’Reduce time step...’)
dt = dt/2;
if (dt < dtMin)
error(’Time step too small’)
else
disp([10,’time = ’,num2str(t),’ PVI, ’,’Dt = ’, num2str(dt)])
end
c1(I+m,J+m) = c(I+m,J+m) - reshape(R0/2,nx,ny)/Vp;
% c1(I,J) = min(max(c1(I,J),0),1);
if (miscible==1)
for k = 1:m
c1(I+m,k) = c1(I+m,m+1);
c1(I+m,ny+m+k) = c1(I+m,ny+m);
c1(k,J+m) = c1(m+1,J+m);
c1(nx+m+k,J+m) = c1(nx+m,J+m);
end
end
c2 = c1; CalcRJ; norm2 = norm(R,2); iter = 0;
end
end % end of Newton loop
disp([’Converged in ’,int2str(iter),’ iterations, res = ’,num2str(norm2)])
%--Final step
dc_max = max(reshape(abs(c1(I,J)-c(I,J)),nx*ny,1)); c = c1;
D.2. RESIDUAL-JACOBIAN ROUTINE 133
%--Time stepping
t = t + dt; nt = nt + 1;
if (t >= tf)
break;
end
dt = dt*(1+eta)*dc_opt/(dc_max + eta*dc_opt);
dt = min(dtMax, max(dtMin, dt));
if (t+dt > tf)
dt = tf - t;
end
end % end of time loop
% Plot results
if (miscible==1) % miscible case
figure(1), mesh(x, y, p2D(:,:)’), zlabel(’pressure (Pa)’, ’FontSize’, 14)
xlabel(’x’, ’FontSize’, 14), ylabel(’y’, ’FontSize’, 14)
figure(2), contour(x(2:nx-1), y(2:nx-1), p2D(2:nx-1,2:ny-1)’, nx-1)
% hold on, quiver(x(2:nx-1), y(2:ny-1), vxc(2:nx-1,2:ny-1)’, vyc(2:nx-1,2:ny-1)’)
xlabel(’x’, ’FontSize’, 14), ylabel(’y’, ’FontSize’, 14), axis square
else % immiscible case
sw = linspace(0,1,100);
figure(1), plot(sw, fw_of_sw(sw), sw, dfw_dsw(sw)), xlabel(’S_w’, ’FontSize’, 14)
h = legend(’f_w’,’df_w/dS_w’); set(h, ’FontSize’, 20)
figure(2), plot(sw, gw_of_sw(sw), sw, dgw_dsw(sw)), xlabel(’S_w’, ’FontSize’, 14)
h = legend(’g_w’,’dg_w/dS_w’); set(h, ’FontSize’, 20);
end
figure(3), mesh(x,y,c(I+m,J+m)’)
xlabel(’x’,’FontSize’,14),ylabel(’y’,’FontSize’,14)
figure(4), contour(c(I+m,J+m)’, [.05:.05:.95]), colorbar, axis square
xlabel(’x’,’FontSize’,14),ylabel(’y’,’FontSize’,14)
D.2 Residual-Jacobian routine
% This routine computes the residual and the Jacobian for a velocity field
% (vx,vy) and a concentration profile c2. For efficiency there is no
% function call required here, i.e., the script "CalcRJ" is executed
% directly from the Solver_2d routine.
R = (1-theta)*R0; DR = zeros(nx*ny, 4*m+1);
%%--Accumulation terms
R = R + Vp*reshape(c1(I+m,J+m)-c(I+m,J+m),nx*ny,1);
DR(:,2*m+1) = Vp;
if (theta>0)
%%--Flux terms in x
for j=J
[flux, fluxDeriv] = CalcFlux(nx, c2(:,j+m), NumFx, m, ix);
flux(Ib) = H*dy*vx(:,j).*flux(Ib);
for k=1:2*m
134 APPENDIX D. MATLAB CODE FOR 2D NUMERICAL TESTS
fluxDeriv(Ib,k) = H*dy*vx(:,j).*fluxDeriv(Ib,k);
end
R((j-1)*nx+I) = R((j-1)*nx+I) + theta*dt*(flux(I+m)-flux(I+m-1));
for i=I
if (isImp(i,j)==1)
n_cell = (j-1)*nx + i;
for k=1:2*m
tmp = theta*dt*fluxDeriv(i+2*m-k,k);
DR(n_cell,ndxl(k)) = DR(n_cell,ndxl(k)) + tmp;
DR(n_cell,ndxr(k)) = DR(n_cell,ndxr(k)) - tmp;
end
end
end
%%%%--BC’s at x=0 and x=L (dc/dn=0)
if (miscible==1)
if (isImp(1,j)==1)
n_cell = (j-1)*nx + 1;
for i=-m+1:0
for k=1:i+m
tmp = theta*dt*fluxDeriv(i+2*m-k,k);
DR(n_cell,ndxl(k+1-i)) = DR(n_cell,ndxl(k+1-i)) + tmp;
DR(n_cell,ndxr(k+1-i)) = DR(n_cell,ndxr(k+1-i)) - tmp;
end
end
end
if (isImp(nx,j)==1)
n_cell = j*nx;
for i=nx+1:nx+m
for k=i-nx+m:2*m
tmp = theta*dt*fluxDeriv(i+2*m-k,k);
DR(n_cell,ndxl(k+nx-i)) = DR(n_cell,ndxl(k+nx-i)) + tmp;
DR(n_cell,ndxr(k+nx-i)) = DR(n_cell,ndxr(k+nx-i)) - tmp;
end
end
end
end
end
%%--Flux terms in y
for i=I
[flux, fluxDeriv] = CalcFlux(ny, c2(i+m,:)’, NumFy, m, iy);
flux(Jb) = H*dx*vy(i,:)’.*flux(Jb);
for k=1:2*m
fluxDeriv(Jb,k) = H*dx*vy(i,:)’.*fluxDeriv(Jb,k);
end
R(i:nx:nx*ny) = R(i:nx:nx*ny) + theta*dt*(flux(J+m)-flux(J+m-1));
for j=J
if (isImp(i,j)==1)
n_cell = (j-1)*nx + i;
for k=1:2*m
tmp = theta*dt*fluxDeriv(j+2*m-k,k);
D.3. FRACTIONAL FLOW ROUTINES 135
DR(n_cell,ndyl(k)) = DR(n_cell,ndyl(k)) + tmp;
DR(n_cell,ndyr(k)) = DR(n_cell,ndyr(k)) - tmp;
end
end
end
%%%%--BC’s at y=0 and y=L (dc/dn=0)
if (miscible==1)
if (isImp(i,1)==1)
n_cell = i;
for j=-m+1:0
for k=1:j+m
tmp = theta*dt*fluxDeriv(j+2*m-k,k);
DR(n_cell,ndxl(k+1-j)) = DR(n_cell,ndxl(k+1-j)) + tmp;
DR(n_cell,ndxr(k+1-j)) = DR(n_cell,ndxr(k+1-j)) - tmp;
end
end
end
if (isImp(i,ny)==1)
n_cell = (ny-1)*nx + i;
for j=ny+1:ny+m
for k=j-ny+m:2*m
tmp = theta*dt*fluxDeriv(j+2*m-k,k);
DR(n_cell,ndxl(k+ny-j)) = DR(n_cell,ndxl(k+ny-j)) + tmp;
DR(n_cell,ndxr(k+ny-j)) = DR(n_cell,ndxr(k+ny-j)) - tmp;
end
end
end
end
end
%%--Source/sink terms
R(1) = R(1) - theta*dt*qw*cw;
R(nx*ny) = R(nx*ny) + theta*dt*qw*c1(nx+m,ny+m);
DR(nx*ny,2*m+1) = DR(nx*ny,2*m+1) + theta*dt*qw;
end
D.3 Fractional flow routines
function [res] = fw_of_sw(sw)
global pFluid
swr = pFluid(1);
sor = pFluid(2);
krw0= pFluid(3);
kro0= pFluid(4);
nw = pFluid(5);
no = pFluid(6);
M = pFluid(7);
136 APPENDIX D. MATLAB CODE FOR 2D NUMERICAL TESTS
for i = 1 : max(size(sw,1), size(sw,2))
if (sw(i) < swr)
res(i,1) = 0;
elseif (sw(i) < 1-sor)
sws = (sw(i)-swr)/(1-swr-sor);
krw = krw0*sws^nw;
kro = kro0*(1-sws)^no;
res(i,1) = krw/(krw+kro/M);
else
res(i,1) = 1;
end
end
return
function [res] = gw_of_sw(sw)
global pFluid
swr = pFluid(1);
sor = pFluid(2);
M = pFluid(7);
G = pFluid(8);
for i = 1 : max(size(sw,1), size(sw,2))
if (sw(i) < swr)
res(i,1) = 0;
elseif (sw(i) < 1-sor)
sws = (sw(i)-swr)/(1-swr-sor);
krw = sws^2; kro = (1-sws)^2;
res(i,1) = (1 - G*kro)*krw/(krw + kro/M);
else
res(i,1) = 1;
end
end
return
function [res] = dfw_dsw(sw)
global pFluid
swr = pFluid(1);
sor = pFluid(2);
krw0= pFluid(3);
kro0= pFluid(4);
nw = pFluid(5);
no = pFluid(6);
M = pFluid(7);
for i = 1 : max(size(sw,1), size(sw,2))
if (sw(i) < swr)
res(i,1) = 0;
elseif (sw(i) <= 1-sor)
D.3. FRACTIONAL FLOW ROUTINES 137
sws = (sw(i)-swr)/(1-swr-sor);
krw = krw0*sws^nw;
kro = kro0*(1-sws)^no;
dkrw = krw0*nw*sws^(nw-1);
dkro = -kro0*no*(1-sws)^(no-1);
res(i,1) = (kro*dkrw-krw*dkro)/(krw+kro/M)^2/(1-swr-sor)/M;
else
res(i,1) = 0;
end
end
return
function [res] = dgw_dsw(sw)
global pFluid
swr = pFluid(1);
sor = pFluid(2);
M = pFluid(7);
G = pFluid(8);
for i = 1 : max(size(sw,1), size(sw,2))
if (sw(i) < swr)
res(i,1) = 0;
elseif (sw(i) < 1-sor)
sws = (sw(i)-swr)/(1-swr-sor);
krw = sws^2; kro = (1-sws)^2;
fw = krw/(krw + kro/M);
dfw = (2/M)*sws*(1-sws)/(krw + kro/M)^2;
res(i,1) = ((1-G*kro)*dfw + 2*G*(1-sws)*fw)/(1-swr-sor);
else
res(i,1) = 0;
end
end
return