Well Models For Production Optimization: Marte Arianson
Well Models For Production Optimization: Marte Arianson
Well Models For Production Optimization: Marte Arianson
Optimization
Marte Arianson
In coupled reservoir simulations a model of a reservoir and the production system are joined
together to obtain realistic responses. One way of performing production optimization is
to make use of a gas oil ratio (GOR) estimate when calculating the optimal ow rates.
Today this estimate is either not accurate enough or calculating it is a time consuming
process.
The thesis tries on an alternative online approach for estimating the GOR. It makes use of
basis functions in the form of polynomials and normalized radial basis functions together
with a recursive least squares (RLS) algorithm. This yields a simple and eective opti-
mization strategy.
When using a second order polynomial together with the fast convergent recursive least
squares algorithm one achieves a suitable t to the estimated production data. The algo-
rithm has not yet been tested together with a production optimization tool and it has not
been compared to the existing methods for estimating the GOR. Still it seems to have a
lot of potential and the RLS is fast, convergent and proper for the objective of this thesis.
I
II
Preface
This Master's thesis concludes my Master of Science with the Department of Engineering
Cybernetics at the Norwegian University of Science and Technology (NTNU).
During the course of this work I have had help from many people. My initial thanks
goes to my supervisor at NTNU professor Bjarne A. Foss for excellent guidance. Our
frequent meetings have been a great support and drive to me.
Special thanks are also due to my fabulous supervisors senior researcher Berit F. Lund
at Sintef and Olav Johan Horgen at FMC Technologies for valuable help and guidance and
for always being there on my disposal.
Finally I would like to thank my fellow Master's students at NTNU Jørn S. Nilsson and
Øyvind Breyholtz for instructive discussions and support throughout the semester.
Marte Arianson
Trondheim, June 2008
III
IV
Contents
1 Introduction 1
1.1 Aim and scope of the thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Hydrocarbon reservoirs 5
2.1 From reservoir uid to stock tank volumes . . . . . . . . . . . . . . . . . . . 5
3.3 Regressors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
V
VI CONTENTS
4 A case study 21
4.1 Presenting the hydrocarbon elds . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2.1 Regressors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.2.2 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.2.3 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2.4 Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.2.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5 Discussion 45
5.1 The ndings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6 Conclusion 51
7 Future work 53
A CD 57
Abbreviations
VII
VIII CONTENTS
List of Figures
1.1 A North Sea eld - example of wells and owlines Source: SPGMediaPLC
[2008] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Qg1 +Qg1 =Qg2 +Qg2 =Qgmax Source: Aasheim et al. [2004] . . . . . . . . . 2
2.1 1 m3 oil in the reservoir becomes approximately 60 m3 gas and 0.9 m3 oil
topside . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
IX
X LIST OF FIGURES
XI
XII LIST OF TABLES
Chapter 1
Introduction
In reservoir engineering it is common to simplify the behavior of ow lines, whereas produc-
tion optimization tools tend to simplify the reservoir behavior. This is often done by two
separate tools namely a reservoir simulator for the reservoir behaviour and a production
optimizer taking care of the ow lines and production network. The two can be coupled
to achieve a more complete model. In this coupling the production optimizer requires an
algorithm for ecient calculation of the gas oil ratio (GOR) to obtain realistic responses
from the reservoir simulator.
Figure 1.1 presents a typical subsea network. The gure illustrates the wells which produce
from the reservoir. They are gathered through manifolds, which may route each of the
wells to common gathering ow lines. The estimate of the GOR is one of the elements
called for when calculating the optimal ow rates. Today's calculations are either a time
consuming process or they yield inaccurate estimates. Hence there is a need for a simple,
online algorithm which can estimate the GOR in a more satisfactory manner.
Another use of the GOR estimate is in view of the marginal GOR (mGOR) ∂qgas /∂qoil .
The wells in a reservoir often have a common owline. The shared owline make the
wells compete for the capacity of the line. The optimal marginal GOR is when we have
maximum oil production for a given total gas capacity and the marginal GOR is the same
for all wells [Aasheim et al., 2004]. Hence the GOR gives an idea of which wells should
reduce their production and which wells should increase their production for maximum oil
2
Figure 1.1: A North Sea eld - example of wells and owlines Source: SPGMediaPLC
[2008]
Figure 1.2: Qg1 +Qg1 =Qg2 +Qg2 =Qgmax Source: Aasheim et al. [2004]
In this thesis a recursive least squares algorithm is used to t a nite impulse response (FIR)
model to the GOR. The model is either presented as a polynomial or as a normalized radial
basis function. The algorithm for estimating GOR will make the prevailing production
optimization software more ecient and hopefully more accurate in its calculations. It is
important to remember that the oil and gas ows used in the algorithm are not measured
directly and only represent the best possible estimates of the ows. Hence the GOR
estimate will only become as good an estimate as the calculated ow allows.
Chap. 1: Introduction 3
Maximising the utilization of the production systems and avoid losses are key aspects
in production optimization. FlowManager and GAP are examples of tools designed to
meet the challenges in production optimization taking care of issues like lift rates and well
routing. Both tools carry out the production optimization while at the same time honour-
ing the constraints of the system. In their calculations there is a need for an online estimate
of the GOR. Among other things the estimate is used for calculating the optimal ow rates.
With GAP the GOR estimate is calculated at dierent rates by perturbing ECLIPSE.
A good estimate calls for perturbing ECLIPSE at numerous rates for each simulation step.
This can be a highly time consuming process as ECLIPSE simulation may require as much
as three minutes per step.
FlowManager has three choices when estimating the GOR. It can use the same, prede-
ned GOR curve through the entire simulation. The second choice is assuming that the
GOR from ECLIPSE is rate independent. Finally it is possible to use a time and rate
dependent polynomial, but this option is not yet fully developed.
This thesis will base itself on the third option and focus on developing an eective algo-
rithm for proper updating of the GOR curve. As the other choices of GOR are suboptimal,
calculating the GOR as a polynomial or another suitable function is expected to improve
the estimate.
Discussion of the results are presented in Chapter 5, in Chapter 6 conclusions are drawn
and nally suggestions for future work are found in Chapter 7.
Chapter 2
Hydrocarbon reservoirs
Example To further illustrate the transformation from one to two phases; imagine a soft
drink bottle. When the bottle is unopened you will not be able to see the gas inside.
Even though you shake the bottle the gas will remain invisible since the pressure
remains the same. But when you unscrew the cap, the pressure drops and the gas
will immediately appear as bubbles in your soft drink.
In the primary reservoir production there is no signicant change in temperature, but there
is a substantial pressure drop near the well at about 100 bar. As the pressure drops, the
volume of the gas increases faster than the pressure drops.
Figure 2.1: 1 m3 oil in the reservoir becomes approximately 60 m3 gas and 0.9 m3 oil
topside
Rm3
VO
BO = (2.1)
VON Sm3
Sm3
VOGN
RS = (2.2)
VON Sm3
The RS diers from the regular GOR in that regular GOR is the ratio of produced gas
to produced oil where the gas consists of both initially dissolved gas and excess gas for
instance gas from a gas cap. BO , RS and GOR are all pressure dependent functions.
Chap. 2: Hydrocarbon reservoirs 7
To increase long term recovery from oil and gas elds, water and gas can be injected into
the reservoir to increase reservoir pressure. Water ooding is a frequently used technique
in the North-Sea [Zolotukhin and Ursin, 2000]. Articial lift methods, for instance a gas-
lift, are used to increase short term production [Schlumberger, 2003]. Such methods are,
however, quite complicated to implement. For instance, oil entrapment can occur when
heterogeneous formations are ooded with water. Another problem is gas and water coning
close to a well. This is due to the higher mobility of water and gas compared to oil, and
the coning eect can result in an increased gas-oil ratio (GOR), higher water cut (WC)
and a low oil production rate (gure of coning gas?) [Zolotukhin and Ursin, 2000].
To determine the ow rates of the three phases oil, gas and water in the pipes, well
tests are performed. Well tests involve routing one of the wells to an independent test
separator. With single rate well tests rates are measured for one set point while multirate
well tests measure rates for several set points.
The total amount of oil, gas and water which can be processed is constrained by the
capacity, typically the separator capacity, of the downstream processing system. Normally
some of these capacities are fully utilized. This makes it dicult to test wells since it
incurs costs because of reduced capacity during testing. It is worth mentioning that in
practice the oil recovery factor rarely exceeds 70 % and it may be as low as 5-10 %.
• There may be unmodelled disturbances and measured data may dier from the actual
8 2.2 A brief description of production optimization
production rates. For instance pipes may rust and wax can gather inside them and
hence become a disturbance.
• Lack of informative data. Multi rate well tests will for instance include more infor-
mation than data from normal production, but such tests are scarce.
To be able to perform a trustworthy model identication the data provided should be real
production data. On the other hand, today's comprehensive reservoir simulators are highly
credible and will probably produce quite realistic data. In case one does not have access to
real production data, synthetic data from a reservoir simulator could be applied for model
identication. If that is the case one should be careful when using it in a real production
environment and use real production data to validate and evaluate the model.
This thesis will use an empirical modelling approach. Hence, a suitable model structure
must be chosen. Thereafter model parameters are estimated and the model is validated.
Typically the data only cover parts of the operating conditions which are of interest to an
optimizer. This implies that model uncertainty diers in dierent parts of the operating
regime (i.e. dierent ow rates) for a well. We are seeking a static model suitable for daily
production optimization. This means that very fast dynamics, like impulses, and slow
varying dynamics should be ltered out before using them for estimation and validation.
Slow varying dynamics will be included by adjusting model parameters.
Chapter 3
The eld of system identication is far too broad to be completely covered in this thesis.
The author has focused on nonlinear, black-box modelling as an empirical approach has
been employed. For more theory on system identication, please inquire Ljung [1987] or
Sjöberg et al. [1995].
• A data set
• A model structure
There are several dierent model structures to choose from and some of them will be pre-
sented here. Before choosing a model structure, one has to look at the data and familiarize
oneself with it. As the choice of model structure is the most important and most demand-
ing choice, there is no point in just picking a model out of nowhere. If data is available
the choice of model structure should be based on prior knowledge from this data.
• White-box modelling is when one has physical insight and a priori knowledge about
the system.
10 3.2 The problem
• Black-box modelling has no reference to the physical background of the system, ei-
ther because the physical insight is not available or it is just not used. The model
structure chosen will be some standard models which one knows have been successful
previously.
• Grey-box modelling is the case when some physical insight is available, but there
are still a number of unknown, free parameters which are to be determined through
system identication. Most systems are to be put in this category.
Models can be either linear or nonlinear. A wise approach is to always try simple things
rst. So even if your system seems to be a nonlinear system, it might be sucient to
describe it with a simple, linear model. Nonlinear structures are much more complicated
than linear ones.
The vector ϕ(t) is called the regression vector and the clue is to nd the relationship
between the next output y(t) and the regression vector ϕ(t). A model has the general
structure
where θ is a nite parameter vector. The hat on y(t) is to emphasize that yb(t) is the best
guess of y(t) given ϕ(t, θ).
3.3 Regressors
3.3.1 Linear black-box models
There are several dierent linear black-box models to choose from, and the most common
can be summarized in the generalized model structure described in equation 3.3. Equation
3.3 and table 3.1 are previously presented in Ljung [1987].
Chap. 3: Nonlinear black-box modelling 11
B(q) C(q)
A(q)y(t) = u(t) + e(t) (3.3)
F (q) D(q)
The simplest model is the nite impulse response (FIR) model, where A = C = D = F = 1.
q is the shift operator, so for instance B(q) in the FIR model is a polynomial inq −1 .
Table 3.1: Special cases of equation 3.3: Common linear black-box models
To calculate the prediction the expression from equation 3.2 is used. The regressors in
ϕ(t, θ) can be chosen amongst
• u(t − k) [B]
• y(t − k) [A]
• ybu (t − k|θ) [F ]
A FIR model requires that the past inputs covers the whole dynamic response time. But
it also has the advantage of never being unstable in simulation. With the extra regressors
yielding an ARX model it becomes possible to cover slow responses with fewer regressors.
When the regressors include past predicted the exibility is increased but it may also in-
troduce instability and result in that convergence to a global minima cannot be guaranteed
[Sjöberg et al., 1994].
• NFIR
• NARX
12 3.4 Model structure
• NOE
• NARMAX
• NBJ
The most commonly used models are NFIR and NARX. As for linear models neither NFIR
nor NARX models have any estimated values in their regressors.
In the nonlinear case the prediction has a dierent structure than in the linear case
where gk is referred to as a basis function. Basis functions give a foundation for nonlinear
black-box model structures and there are a number of choices of these functions. This
thesis will only focus on a few basis functions and the author refers the reader to Ljung
[1987] and Sjöberg et al. [1995] for further reading on the subject.
The RBF oers a localization property. The γ values can be chosen to the areas on
Chap. 3: Nonlinear black-box modelling 13
the x axis where one wants to direct the focus. For instance areas with higher concentra-
tions of data points. The β value gives the steepness of the curve. With a large β value
the corresponding basis function will have its prevailing area in the close vicinity of the γ
while with a small β value the basis function will inuence a more extensive area. So the
closer the input is to the centre of the bell, the larger the response of the basis function or
node.
In normalized RBF (NRBF) networks the output activity is normalized by the total input
activity
Gk
gk (ϕ) = PN , N = number of nodes (3.8)
i=1 G k
In standard RBF nets the weights, which equals one in equation 3.7, determine how much
each node contribute to the output. With NRBF nets the roles are switched and the
activity of the nodes determine which weights contribute most to the output. NRBF
networks also improves its interpolation skills over standard RBF networks. Even in regions
where no nodes produce a strong response, the NRBF can generate a signicant output
value [Bugmann, 1998].
1
gk (ϕ) = (3.9)
1+ e−βk (ϕ−γk )
The most common sigmoid function has β = 1 and γ = 0 and has an S shape. The sigmoid
function has a localization property just like the radial function, where the β value gives
the steepness of the curve and the γ value gives the focus area on the x axis.
Polynomials
Polynomials are well known, simple functions and they take the shape of
N
X
gk (ϕ) = ϕk = 1 + ϕ + ϕ2 + ϕ3 + . . . + ϕN (3.10)
k=0
If a polynomial is used as basis function, one gets a linear regression model structure.
Wavelets
According to Kaiser [1994] wavelets are similar to windowed Fourier transform (WFT) and
can represent functions with discontinuities and local spikes, but they are better suited
than the WFT to zoom in on short lived frequency phenomena. Wavelets also have multi
resolution capabilities and they take the form
Neural networks
Neural nets are relatively young compared to other functions. They have good general
capabilities and are a popular choice of model structure. A neural network learns on
the gathered data and detects their underlying relationships - the more data, the better
[Sjöberg et al., 1994].
Neural networks can be used with a basis of polynomials (Taylor or Volterra expansion),
NARX-structure expansion or sigmoid-functions.
1
σ (x) = (3.13)
1 + e−x
Equation 3.13 gives a smooth, dierentiable model and yields, together with equation
3.12, a one hidden layer feedforward sigmoid neural net. Continuous functions with only
one input have no advantage in using more than one hidden layer. There exists a large
number of neural networks, feedforward is only one example and the only one which will
be mentioned here. For more information on neural networks, please read Sjöberg et al.
[1994].
B splines
B splines are piecewise polynomials where the connections have continuous derivatives.
They are nice, simple functions and they can be made as smooth as desired. A general
polynomial is shown in equation 3.10.
Chap. 3: Nonlinear black-box modelling 15
Models with too few parameters become inaccurate due to a large bias. A model with
a large bias does not have enough exibility. For instance tting a linear function to a set
of samples with the shape of a parabola will yield a large bias.
If a model has too many parameters it is inaccurate because of large variance in its predic-
tions. Such models are too sensitive to the details of the sample. Although an overtted
model may appear to be performing well, in reality it follows the data too closely and will
perform poorly on new data.
Identifying a good model therefore requires a model with not too few nor too many pa-
rameters. Hence a trade o between the bias and the variance must be found by tuning
the number of parameters [ACCESS].
In many cases it is useful to have an on-line model of the system available. Then the
algorithm is called a recursive algorithm, and the update is based only on measurements
made up until now. This section will give an introduction to recursive algorithms.
Presenting the weighted least squares criterion using the same notation as Ljung [1987]
t
X 2
β(t, k) y(k) − ϕT (k)θ
θb = arg min (3.14)
θ k=1
θbt = R̄−1 (t)f (t) (3.15)
t
X
R̄(t) = β(t, k)ψ(k)ψ T (k) (3.16)
k=1
Xt
f (t) = β(t, k)ψ(k)y(k) (3.17)
k=1
h i
θ(t) b − 1) + L(t) y(t) − ψ T (t)θ(t
b = θ(t b − 1) (3.19)
P (t − 1)ψ(t)
L(t) = (3.20)
λ(t) + ψ T (t)P (t − 1)ψ(t)
P (t − 1)ψ(t)ψ T (t)P (t − 1)
1
P (t) = P (t − 1) − (3.21)
λ(t) λ(t) + ψ T (t)P (t − 1)ψ(t)
Forgetting factor λ
The RLS makes use of a forgetting factor 0 < λ < 1. The smaller λ is, the smaller
contribution of previous samples. This makes the lter more sensitive the recent samples,
which means more uctuations in the lter co-ecients. The λ = 1 case is referred to
as the growing window RLS algorithm. Lambda is recommended to take on a value just
below 1, typically in the interval 0, 95 − 0, 99. One reason for this is that previous data
must not be assigned too little importance as the parameters are slowly varying. Another
reason is that if the process goes through a phase where nothing happens, that is yt and
ut and hence ψ is approximately zero, P(t) will grow exponentially [Henriksen, 1998].
Chap. 3: Nonlinear black-box modelling 17
θ(t)
b = θ(tb − 1) + γ(t)R−1 (t)ψ(t)(t) (3.23)
Depending on the underlying model structure and the choice of R(t) the equation above
corresponds to specic algorithms in the family of methods called recursive prediction error
methods [Ljung, 1987].
yb(t) = ϕT (t)θ(t
b − 1) (3.25)
b b − 1) + γ(t)R−1 (t)ϕ(t)(t)
θ(t) = θ(t (3.27)
In the RPLR ϕ contains entries constructed from using past models. The RLS method is
also a member of the RPLR family of algorithms [Ljung, 1987].
P (t − 1)ζ(t)
L(t) = (3.30)
λ(t) + ψ T (t)P (t − 1)ζ(t)
P (t − 1)ζ(t)ψ T (t)P (t − 1)
1
P (t) = P (t − 1) − (3.31)
λ(t) λ(t) + ψ T (t)P (t − 1)ζ(t)
The RIV method is quite analogous to that of RLS. For deeper insight into the RIV
method, please inquire Henriksen [1998] or Ljung [1987].
Kalman lter
The Kalman lter is an alternative to the forgetting factor methods. It is a state estimator
with a recursive nature and can all the same be used as a parameter estimator. The Kalman
lter has its strength in estimating the states from a series of measurements contaminated
18 3.6 Validating the model
with noise and is nice to use if certain parameters vary more than others as they can be
weighted separately [Henriksen, 1998]. Shown below are the system equations
where it is assumed that θ varies like a random walk and w and v are white and Gaussian.
When using the Kalman lter as a parameter estimator the equations may be presented
like this
h i
θ(t) b − 1) + L(t) y(t) − ψ T (t)θ(t
b = θ(t b − 1) (3.34)
P (t − 1)ψ(t)
L(t) = (3.35)
R2 (t) + ψ T (t)P (t − 1)ψ(t)
P (t − 1)ψ(t)ψ T (t)P (t − 1)
P (t) = P (t − 1) − + R1 (t) (3.36)
R2 (t) + ψ T (t)P (t − 1)ψ(t)
R1 = Ew(t)wT (t) (3.37)
T
R2 = Ev(t)v (t) (3.38)
If we are sure about the measurements the measurement error covariance R2 decreases
to zero and the gain L decreases and weights residual more than prediction. If we on the
other hand are sure about the predictions the prediction error covariance P decreases to
zero and L increases and weights prediction more than residual.
N
1 X
Jk (m) = |y(t) − ybk (t|m)|2 (3.39)
N
t=1
Chap. 3: Nonlinear black-box modelling 19
N
X
Jk (m) = |y(t) − ybk (t|m)| (3.40)
t=1
Yet another validation method is cross-validation. There are various types of cross-
validation. With holdout validation the data are never crossed over. A number of ob-
servations are removed from the initial sample and used as validation data. Normally
about a third of the initial sample is used for validation. Another variant is the leave-
one-out cross-validation. The advantage of this method is that there is no need to save
fresh data for the validation. A model is made up of the entire data set except for one
observation. This is done once for every N observations in the data set and in the end one
can sum up the N corresponding squared errors.
1. Familiarize with the data. This is an obvious step and can often be very revealing.
2. Try simple things rst. For instance one should try linear models rst; they may be
sucient.
3. Attain physical insight. This may give a clue of whether to turn a measurement into
a regressor.
A case study
Field A
Field A is a North Sea reservoir with an enormous gas cap. The eld spreads out over
a large area and has an oil layer which height varies from about 4 to about 30 meters,
and has a typical height of about 12 meters. A typical Field A well would go through a
short period of time before gas brakes through, the short period stretching from a couple
of weeks to months.
It is important to remember that the ow rates for oil an gas are estimated based on
the pressure and temperature of the three phase ow and the pressure drop across the
choke. Although there are three measurements the algorithm calculating ow can only
nd estimates for ow of oil and gas and not for the water cut (WC). Hence the WC holds
a xed value periodically.
• Well #1 - Well #1 has some variations in choke position. There is data from 103
days of production and the WC is constant for the entire period.
22 4.1 Presenting the hydrocarbon elds
• Well #2 - This well has production data from 127 days. The WC in this well not
constant.
• Well #3 - The well has a quite stable production rate with some variations among
other things there is some slugging towards the end. Production data from 275 days
is provided. The data from this well does not seem reliable and the algorithm will
not be applied to Well #3. A graphical representation of Well #3 is presented in
gure 4.1(c).
• Well #4 - Well #4 has production data from 89 days and has a close to constant
WC.
• Well #5 - The well has a low, stable production and production data from 68 days.
The WC holds a constant value throughout the entire production period.
Measurements have been made every ten minutes and so there is quite an amount of ob-
servations available from these wells.
Field B
Field B is also a North Sea reservoir. Field B only had one interesting , that is rate de-
pendent, well. This well develops a gas cone. It shuts down for short periods of time to
get rid of the gas cone. When it starts back up the GOR value is reduced, but it will only
develop another gas cone to produce more and more gas as time moves on. There is data
from 131 days for this well and measurements have been made every tenth minute. In
Field B as in Field A the ow rates for oil and gas are estimated rates.
Field C
The data from Field C is not gathered from a real reservoir; Field C is a simulated Eclipse
reservoir. The eld is in production for ten years and measurements are only available
every third to tenth day inconsequently. At the beginning of every January, the well is
closed for a duration of one month to let a possible gas cone back.
In all of the wells except from Well #1 the WC is signicantly higher than the oil rate.
In Well #1 the WC is higher than but still comparable to the oil ow rate. The gas rate
has been driven to a constant level for most wells except for Well #2. Some degree of
coning gas is helpful and often necessary to give the well a natural lift. In Well #2 the
uid becomes heavier and heavier and the gas cone does not yield a sucient lift. Hence
the well closes down after six years of production.
Chap. 4: A case study 23
The production data from each well is presented in gure 4.2. After familiarizing with
the wells in Field C it is evident that the data from the Eclipse simulations is not suitable
for the objective of this thesis.
The shape of the GOR plots can be explained by the well being placed close to the water
oil contact (WOC) and in the beginning the produced uid will contain large amounts of
water. After some time of producing lots of water the WOC will move downwards and
make room for more oil, hence the increasing oil prole in the beginning of some of the
plots. Most of the plots from the the data sets look like polynomials hence a solution
containing a polynomial is plausible.
4.2.1 Regressors
Recall from chapter 3 that there are several choices of regressors to choose from. We
have to nd a good compromise between the complexity of the model and its eciency
in describing the dynamics of the system. A good starting point would be a nonlinear -
nite impulse response (NFIR) model. This choice model guarantees stability. One input is
selected namely the one step delayed gas. Hence the regression vector ϕ(t) can be displayed.
4.2.2 Model
The choice of model and model structure is more complicated. With a look at the GOR
plots in gures 4.1 and 4.2 a polynomial shape seems to be a reasonable choice. Since
the nature of the GOR gives a decreasing oil rate with an increasing gas rate, an even
numbered polynomial basis function seems appropriate. According to the bias-variance
trade-o a polynomial with too many parameters will become too sensitive to the samples.
Hence a second order and a fourth order polynomial are selected.
The second choice in model structure is the NRBF which yields a radial-basis neural net-
work. With a normalized structure the functions gk ≥ 0 and the sum of the functions
equals 1. With gk as in equation 3.7 g (ϕ) will always be convex and the minimization will
attain a unique solution.
X
g (ϕ) = gk θk (4.4)
In standard RBF nets, the weights determine how much each hidden node contribute to
the output. In normalized RBF nets, see equation 3.7, the activity of the hidden nodes
determine which weights contribute most to the output. For instance, in the extreme case
where only one of the hidden nodes is active, then the output of the net becomes equal to
the weight corresponding to that hidden node, whatever its level of activity.
2
Gk = e−βk (ϕ−γk ) (4.5)
Gk
gk (ϕ) = PN , N = 2, 3, 4, 5, 6 (4.6)
i=1 Gk
A possible modication is to replace the constant θ with a linear function. These functions
help smooth the function when the node takes on a constant value and is an alternative
to increase the number of parameters or nodes.
This gives a nice touch to the model as the bias-variance trade o is still prevailing.
4.2.3 Algorithm
Because of the demand for an online algorithm, the optimization algorithm has to be recur-
sive. A well known algorithm is the recursive least squares (RLS) lter and its simplicity
in use and understanding is appealing. From chapter 3 we remember that by implement-
ing the RLS algorithm ensuers a robust and convex implementation and that the global
minimum will always be found with this strategy. Nonlinear minimization on the other
hand is not convex. It requires numerical techniques like Gauss-Newton for solving and
may converge very slowly or not at all and it may continually change directions. Further-
more, Ljung [1987] states that the least-squares algorithm is applicable for most reasonable
28 4.2 Choice of model and algorithm
nonlinear systems, making it a good idea to try using this scheme before employing some
nonlinear search algorithm.
A clue in system identication is not to estimate what we already know. With the linear
regression model using a polynomial basis function only one class of parameters θ needs
to be estimated. Using an NRBF we obtain two additional sets of parameters namely
the localization parameters γ and the scale parameters β. With a priori knowledge of the
distribution of the data these parameters can be selected beforehand. For online systems
some parameter selection technique should be employed. According to Sjöberg et al. [1995]
there are no well suited selection techniques for sigmoid functions while for the NRBF sev-
eral techniques exist. If such techniques are to be included in the RLS algorithm there will
be more parameters than regressors and linear regression will no longer be possible. Due
to the limited time scope of this thesis and the fact that data is available to us beforehand
no selection techniques will be implemented.
There are several versions of the RLS algorithm. We employ the matrix inversion ap-
proach introduced in chapter 3.
4.2.4 Validation
To be able to choose among the implemented models some kind of validation is necessary.
We have chosen the hold out validation technique. Ljung [1987] mentions that the sum and
the mean of the residuals some of the choices when it comes to evaluating models. Together
with summing up the prediction errors the hold out validation will give the foundation for
selecting the best possible model. The GOR data used in this thesis is rate and time
dependent and so dividing the data in two parts viewed in the light of time would be fu-
tile. Hence when estimating the models every second sample of data is saved for validation.
To validate the algorithm it should be compared to the prevailing techniques for esti-
mating the GOR. These are not available to us and such a validation should be performed
before implementing the new algorithm with the production optimization software it is
intended to work with.
4.2.5 Implementation
The algorithm is implemented in MATLAB. MATLAB is a high-level programming lan-
guage and numerical computing environment. It is a well known programming tool in
the control engineering society and allows for implementation of online algorithms. The
code has been produced entirely by the author except for some helpful methods already
implemented in MATLAB.
Chap. 4: A case study 29
The data production data is presented in Excel les and made available to MATLAB
through the function xlsread. A FIR model is estimated with the recursive function rarx.
rarx handles only single output models while multiinput models are made possible. It has
several options in algorithms. The algorithm selected is a recursive least squares algorithm
with forgetting factor λ, the value of λ chosen on behalf of the recommendations in chapter
3. Because of the large number of observations in the data sets λ should be quite close to
1 and it is chosen to λ = 0.9998. This will make the algorithm consider the approximately
last 5000 observations. For the polynomial basis functions where the data is divided into
batches λ can be smaller and is chosen to λ = 0.993 remembering about 140 batches of
data. The matrix P (0) is chosen to take on a value of 10 for each θ(0) as we do not trust
the initial guess of θk (0) = 0.
Polynomial
Figure 4.4(a) shows the results from matching the polynomials to the signal. It is obvious
from the gure that a polynomial with a degree higher than two is needed to be able to
adapt nicely to the main function. But it is also clear that a degree higher than three is
futile, see gure 4.4(b).
30 4.3 Test system: A random polynomial
Radial function
The match using NRBFs is shown in gure 4.3.1 and the results are not as satisfactory as
it was with the polynomials. The signal is not contaminated with noise and even so the
normalized radial functions can only trace and not adapt to the main function when it
has eight nodes. A reason for this can be that the localization parameters γ and the scale
parameters β are not optimal. This goes for both the NRBF and the sigmoid functions
as no explicit algorithm for selecting the parameters has been employed. With four nodes
the residual sum is decreased, but still not as low as for the three polynomials of highest
order.
Chap. 4: A case study 31
(a) Normalized radial function of 8th degree (b) Normalized radial function of 4th degree
P1 P2 P3 P4 P5 NRBF1 NRBF2
1342.9 714.3 29.9 31.2 31.1 425.8 178.5
Noise was added to the signal from the main function. The new, noisy signal can be seen
together with the noise free signal in gure 4.6. The same system identication as in the
previous section was tested on the noisy signal.
Polynomial
Figure 4.7(a) shows the results from matching the polynomials to the noisy signal. There
is a drop in the sum of the residuals when the polynomial increases from second to third
order and it is also clear from the gure that the three highest order polynomials give the
best t.
Radial function
With a noisy signal the normalized radial function actually seems to perform better than
with a noise free signal. Eight NRBF does not yield a very good t as can be seen in gure
4.11(a) while with four basis functions or nodes the adaptation is quite smooth.
P1 P2 P3 P4 P5 NRBF NRBF2
1242.7 652.7 100.1 70.2 59.2 423.2 70.2
Chap. 4: A case study 33
Polynomial
As in the above example cases a polynomial is implemented rst. In gure 4.10(a) the
polynomials are tted to the incomplete function shown in gure 4.9.
34 4.3 Test system: A random polynomial
The sum of the errors for the NRBFs are shown together with the sum of the polynomial
errors in table 4.2
Chap. 4: A case study 35
P1 P2 P3 P4 P5 NRBF NRBF2
936.4 689.7293 113.9 168.2 656.8 600.0 1599.9
(a) Estimating with second order polynomial (b) Estimating with fourth order polynomial
All of the second order polynomials except for a few are concave downwards. A shape
that is concave downwards is the natural curve behaviour for the GOR. When the gas
starts to cone towards the inlet of the well more gas will follow due to the higher mobility
36 4.4 The real case
of gas compared to oil and so the oil production will decrease. 2nd order polynomials
have a rigid structure and as they are restricted to one inection point they do not have
the freedom of a higher order polynomials. Since the fourth order polynomials are less
rigid they should be able to follow the data with more precision than the second order
polynomials. Remembering the bias-variance trade o, a higher order still is not always
better since the model might overt to the data. By looking at gure 4.12(b) we see that
some of the graphs match the data poorly and this is conrmed by the validation. The
estimation yields close to similar mean residual error and standard deviation for the second
and fourth order polynomials with the second order polynomial only slightly better and
the validation in gure 4.13 shows the same.
(a) Validating second order polynomial (b) Validating fourth order polynomial
(c) Second order polynomial: 1.Mean residual error (d) Fourth order polynomial: 1.Mean residual error
2.Standard deviation 2.Standard deviation
Figure 4.14 shows the estimation of the GOR in Well #1, Field B. With a 2nd order
polynomial all of the adapted curves are concave downwards while when using a 4th order
polynomial the curves all end with an upswing and hence an erroneous increasing oil ow
Chap. 4: A case study 37
rate. But when validating the estimated parameters we see that the 4th order polynomial
yields a smaller standard deviation and mean residual error. Although the dierence is
minimal it is still present.
(a) Approach 1: Estimating with second order poly- (b) Estimating with fourth order polynomial
nomial
(a) Validating second order polynomial (b) Validating fourth order polynomial
(c) Second order polynomial: 1.Mean residual error (d) Fourth order polynomial: 1.Mean residual error
2.Standard deviation 2.Standard deviation
From Field C Well #1 is presented and the linear regression using polynomials can be
viewed in gure 4.16. Previously it was stated that the wells in Field C were not proper
for testing the algorithm developed in the thesis. Still an example has been included.
Both the 2nd and 4th order polynomials have curves which are concave downwards. The
GOR reach the maximum gas ow qgas constraint qgas = 1 each year and after three years
the qgas takes on a constant value at its constraint over the remaining seven years. In gure
4.16 we see that the oil ow qoil has a decreasing rate, hence the vertical set of points at
qgas = 1. Since the goal for the Field C wells is to reach a certain gas constraint and stay
there a polynomial adaptation will not cover its behaviour in a correct manner.
By validating the two polynomial functions we see that the standard deviation is the same
for both 2nd and 4th order polynomial. The 4th order polynomial gives a slightly larger
residual error.
Chap. 4: A case study 39
(a) Approach 1: Estimating with second order poly- (b) Estimating with fourth order polynomial
nomial
(a) Validating second order polynomial (b) Validating fourth order polynomial
(c) Second order polynomial: 1.Mean error 2.Stan- (d) Fourth order polynomial: 1.Mean error 2.Stan-
dard deviation dard deviation
Consider the adaptation with NRBF to the GOR in Well #1, Field A, shown in g-
ure 4.18. The latest adaptation gives the most smooth curve tting and it is somehow not
very smooth until then. This is not what was expected from the exible NRBFs which
usually give nice ts.
Well #1 from Field B achieves a poorer adaptation using NRBF than Well #1 from the
rst eld. This might have been adjusted by selecting dierent values for the two additional
parameters γ and β . With this in mind the adaptation with the normalized radial functions
is still inadequate.
By visual inspection the estimation with NRBF to Well #1 in Field C is not very good.
This is not surprising as the observations reach their constraint in qgas after only three
years. Even in the rst three years the gas constraint is reached eventually.
The standard deviation from all of basis functions are gathered in table 4.6.
Chap. 4: A case study 41
Figure 4.18: Linear regression with NRBF to data from Well #1 in Field #1
Figure 4.19: Linear regression with NRBF to data from Well #1 in Field #2
Figure 4.20: Linear regression with NRBF to data from Well #1 in Field #3
44 4.4 The real case
Chapter 5
Discussion
By dening a function and developing an online algorithm that predicts the GOR, the
already existing tool FlowManager will hopefully become more ecient and precise in its
calculations. An attempt of creating such a procedure has been made in this thesis. Two
dierent models and model structures have been implemented together with a recursive
least squares algorithm.
As mentioned in the introduction the oil and gas ows used in the algorithm are not
measured directly and only represent the best possible estimates of the ows. Hence the
GOR estimate will only become as good an estimate as the calculated ow allows.
By visual inspection, examining the gures in chapter 4.4, the overall performance of
the 2nd order polynomial seems most proper. As close as all of the curves are concave
downwards and they seem to follow the data quite nice. The 4th order polynomials are
less predictable. For the rst well in Field A the 4th order t might be good for some of
the curves but then they oscillate too much for others. For the well in Field C all of the
curves end with an upswing when employing a 4th order polynomial. If we consider the
physics of the GOR, such behaviour is not realistic. Although the standard deviation is
small it is important to take the physical principles into consideration as well.
It can be argued that with the diminished standard deviation achieved when employ-
46 5.2 Alternative approaches
ing the NRBF the choice is in choosing the most proper basis function easy. But the
curves from the NRBF nets are bumpy until they smooth out with the nal graph. For
the well in Field B the NRBF net gives the impression of being a slow learner. Although
the two last graphs seem to yield nice ts to the data, the rst curve is close to linear and
do not represent the data properly. Hence, even though linear regression using 2nd order
polynomials which are more rigid and generate a larger standard deviation than that of
the NRBF nets, the 2nd order polynomial seem to be the best choice in basis function.
Although no other algorithm than the recursive least squares algorithm has been em-
ployed, it seems to be working just ne and there is no reason to exchange it with another
recursive procedure. The algorithm has not yet been coupled with a production optimiza-
tion tool for testing and evaluation. Not having been able to compare the estimates of the
existing approaches for estimating the GOR one cannot know for sure how much better
this approach is over the others.
When the basis function is a polynomial the data is windowed . This approach yields
smaller prediction error and standard deviation than minimizing over each of the data
points. It also makes it easier to employ a possible method for starting over when for in-
stance the choke shuts in. More on this method below. There are several ways of choosing
the size of the window. A GOR update is not needed more often than once a week, but
the window size is reduced to four days in the employed algorithm. During this period of
time the GOR can be thought of as stationary. Since the rate dependent GOR vary with
the choke position, if the choke is shut in the window size is reduced for that particular
batch, a curve is adapted and a new window is started. It can be argued that the window
should have a size of one week of observations since the update is needed weekly. A smaller
window gave better results. Hence why not make the window size even smaller? A smaller
window size gave faulty curves when estimating so this option was left behind.
A modication of this procedure could be to reset the parameters θ and forget all pre-
vious data when the well shuts in and start from scratch. A less extreme approach would
Chap. 5: Discussion 47
be to just make θ smaller to forget a larger quantity of data if the well shuts in. That
way the algorithm will not be completely blank when the well starts up again. This last
procedure was tested on one of the wells in Field A as those wells shut in from time to
time. As opposed to the regular value of λ = 0.993 the value was reduced to λ = 0.9 when
the wells shut in only remembering measurements from the last 10 windows when starting
back up. There was no dierence in the standard deviation, but with a more thorough
research of this approach it may improve the algorithm.
If the well experiences the phenomena of coning gas, shutting in the well will most likely
lead to the cone slowly withdrawing from the inlet of the well. Liquid uid of oil and
water will dominate the initial ow when the well re-opens and the shape of the GOR is
not similar to before the shut in. Even so the approach with not forgetting everything
the algorithm has learned up until a shut in seems like the most sensible solution as the
conditions in the well wont be completely altered.
Sigmoid function
When time yields an uneven spread of data, localization function like sigmoid functions
may be employed. For instance lets say that there are three clusters of data. The rst
cluster includes data from time t0 < t < t1 , the next data within the time span t1 < t < t2
and the last cluster of data arrives at t2 < t < t3 . Due to the forgetting factor λ in the
RLS the rst points will get minimal weight or they might even be ignored as time passes.
By introducing sigmoid functions this problem can be avoided.
1
σ1 = (5.1)
1 − ex−x0
1
σ2 = (5.2)
1 − e−x−x0
σ1 holds for x(t0 ) to x(t1 ) and σ2 holds for the rest of the observations. When applying
the RLS we can choose that the data aected by σ1 wont be forgotten, but the rest of the
data aected by σ2 will be treated as usual with the forgetting factor λ.
The downside to this procedure is that the conditions in the reservoir will change and
the old data will not be prevailing any more. The technique has been considered redun-
dant to implement on the production data used in this thesis however. Due to alternations
in the choke position and some infrequent shut ins a sucient amount of data points is
available for all the prevailing areas of the x axis.
y(t) − ψ T (t)θ(t
b − 1)
z2 = (5.3)
y(t)
Chap. 5: Discussion 49
Alternatively if the variance of the measured responses are proportional to the measured
value also here with dierent proportional constant the residual should become
y(t) − ψ T (t)θ(t
b − 1)
z3 = p (5.4)
y(t)
Conclusion
In this thesis the author has developed an algorithm for estimating and updating the GOR
for use in production optimization tools like FlowManager. The application has been tested
on production data from three wells.
Two types of basis functions namely polynomials and normalized radial basis functions
were adapted to the GOR by a recursive least squares algorithm. From validating the
model the normalized radial functions were the most suitable for adaptation and it seems
to have good potential, but from visual inspection the a second order polynomial had the
best match. Although the fourth order polynomial seems to have a good t to some of the
production data, when taking the physics of a GOR into consideration it is no longer ade-
quate. The recursive least squares algorithm has proven to be a fast convergent algorithm
suitable for the purpose of the thesis.
52
Chapter 7
Future work
Neither of the estimations that have been performed yield optimal responses. The plots are
not always a proper t and this goes for both of the choices in basis functions. This may
be corrected by adding constraints to the algorithm. Taking into consideration changes in
choke position and water cut should be employed. When the well shuts in to let a possible
gas cone back, it should be taken into account how many of the previous observations
should be considered. When separating the data into windows, the size of the window
could be altered. If new constraints and requirements are added to the algorithm, testing
the algorithm without dividing the observations into windows could be an option.
The algorithm will need adjustments before working together with a production optimiza-
tion tool. The author has developed the algorithm without considering the programming
language used by the production optimization software and it might need translation to
another language before it can communicate and co-exist with other software.
The normalized radial basis functions have been successful in other applications and their
potential should be explored some more. They may yield a better t than presented in
this thesis with the proper choice in localization parameters γ and scale parameters β. In
addition the possibility of employing B splines should be taken into consideration.
54
Robert Aasheim, Kari Brusdal, Are Mjaavatten, and Jan Hauge. Production optmization
on troll with a rate dependent gor model and gap. In SPE Oshore Bergen, 2004.
AI ACCESS. Glossary of data modeling. URL http://www.aiaccess.net/e_gm.htm.
Lennart Ljung. System Identication - Theory for the user. Prentice Hall PTR, 1987.
L.A. Saputelli, S. Mochizuki, L. Hutchins, R. Cramer, M.B. Anderson, J.B. Mueller, A. Es-
corcia, A.L. Harms, C.D. Sisk, S. Pennebaker, J.T. Han, A. Brown, C.S. Kabir, R.D.
Reese, G.J. Nunez, K.M. Landgren, C.J. McKie, and C. Airlie. Promoting real-time
optimization of hydrocarbon producing systems. In SPE Oshore Europe Aberdeen,
September 2003.
Jonas Sjöberg, Lennart Ljung, and Håkan Hjalmarsson. Neural networks in system iden-
tication. In IFAC SYSID94, volume 2, pages 4972, 1994.
Jonas Sjöberg, Quinghua Zhang, Lennart Ljung, Albert Beneviste, Bernard Delyon, Pierre-
Yves Glorennec, Håkan Hjalmarson, and Anatoli Juditsky. Nonlinear black-box modeling
in system identication: a unied overview. Automatica, 31(12):16911724, 1995.
SPGMediaPLC. Oshore technology, 2008. URL http://www.offshore-technology.com.
56 BIBLIOGRAPHY
CD
The appendix is in the form of a CD containing the Master's thesis in PDF format and
the m-les (MATLAB).