You are on page 1of 20

Petroleum Engineering

School of Engineering and Physical Sciences

THIRD YEAR ASSIGNMENT REPORT


ADVANCED FLUID MECHANICS and MODELLING

STUDENT ID: H00177742

STUDENT NAME: Soltanova Aida

Assignment Title: NUMERICAL SOLUTION TO DIFFUSION EQUATION – PROBLEM 3F

Date of submission: 26.04.2016

Demonstrator: Fuad Hasanov

1
Contents

1. Introduction………………………………...........………………………................3
2. Mathematical Background………………………….….......................................4
3. First Part Analysis……………………………………...................…...................5
4. Second Part Analysis……………………………………...................…..............6
5. Description of coding steps…………..........................................……..............17
6. Conclusion……………………………..........................................……..............19

2
Introduction

The report is aimed to illustrate the reservoir simulation process based on two given
wells. The solution method is clearly examined in the light of solution errors with
different grid numbers. Furthermore, the minimal distance is also defined in which the
wells do not interact each other based on drainage area intersections. The report also
covers the analysis of how different permeability, porosity and compressibility values
affect the reservoir behavior. Finally, the speed of calculation, stability and accuracy are
discussed with the help of Matlab tools.

Simulation process is inalienable section of the reservoir engineering in predicting the


field performance through the long field life. What makes the simulation process so vital
in engineering is its availability of running many times at low expense at short time
interval and allowing the selection of an optimal set of production scheme for the field.

Simulation is realized by constructing and operating the new model which represents
the real reservoir behaviors under actual operating conditions. The model may be based
on physical laboratory experiments or mathematical (numerical solution) equations. This
report illustrates the way of numerical solution to Darcy’s equation at steady state in
order to simulate the flow in reservoir under given conditions and parameters. The set of
equations will be solved by Matlab program and 3D reservoir profile will be obtained in
the end which is the great tool to analyze the pressure distribution over the reservoir
and the well locations. Special reservoir data with two wells is summarized in Table 1
below.

Table 1. Reservoir data

Porosity 12 %
Permeability 70 md
Compressibility 2*10-9 Pa-1
Viscosity 4 cp
Reservoir dimensions 400x400 m
Wellbore pressure for both well 700 psi

What makes the reservoir simulation different for two wells instead of single one is
superposition principle. In the current reservoir, the assumption is made that there is no
any fault over the given reservoir area (400mx400m), hence no need to care of
boundary effects and imaginary wells. However, when more than one well is operating
over the reservoir, each well creates individual pressure drops and those driving forces
start to move towards the reservoir boundaries. So, for the special well, pressure drop is
just sum of two terms: drop caused by itself and another well. Figure 1 below
summarizes those pressure drop effects.

3
Figure 1. Superposition principle

Mathematical Background

Starting point to generate the program is three dimensional transient form of Darcy’s
equation.

However, to simplify the process, it is assumed to have two dimensional steady state
flows through the reservoir and Darcy’s equation is reduced into the following form.

For more simplification, D values are replaced by given parameters and lead to the final
equation below.

4
First Part Analysis

In the first part of the problem, homogenous reservoir is assumed to have the same
pressures in all boundaries except the left boundary in which the pressure is gradually
decreasing. The code was generated and gave the following plot. What is important
here is to observe the superposition effect. Although the three boundary pressures were
kept initially constant, due to pressure drop in left boundary they are also affected after
some time elapse and the reservoir becomes finite acting. It is highly worth to analyze
how the process speed depends on grid size. It may easily be observed that how how
the program speeds up when the grid numbers are decreased from 40x20 to 20x10
(Figure 2 and 3 respectively). However, as comparison of two graphs below shows, in
the case of less grid numbers, the simulation is less accurate and rough.

Figure 2. Homogenous reservoir simulation (grid number=40x20)

5
Figure 3. Homogenous reservoir simulation (grid number=20x10)

Second Part Analysis

The core idea is to define the pressure values at any point in the reservoir based on the
Darcy’s equation, and then plot those values together to see how the pressure is
distributing. To solve this equation for each individual point will give plenty number of
equations and unknowns, so the best way to arrange them is to use the matrix
approach. So, three set of matrix is used in coding. First two matrixes are to collect the
respective equations’ solutions while the last one/array C is the multiplication of array A
and B and generates the graph.

One of the core ability of matlab simulation is to have the flexibility of cell numbers (‘nx’
and ‘ny’ in the code). So that having more grids gives less uncertainty and plots the
graph with smoother surface. Figure 4 and 5 illustrate the same well simulation with
40x20 and 80x40 grids respectively.

6
Figure 4. Simulation of 2 wells (grid number=40x20)

7
Figure 5. Simulation of 2 wells (grid number=80x40)

As can be seen above, more cells create much smoother surface and gives better
reservoir imagination. However, much higher grids (greater than 80) make the matlab
process slow down. Another strong tool to analyze the effect of grid numbers over the
simulation process is to generate the cross section of the wells through the reservoir.
Those cross sections are plotted with the help of ‘solution_p’ function in matlab and
excel program. So that, in matlab desktop, there is ‘solution_p’ function which covers all
pressure values depending on different grid numbers. In the case of 40x20 size, as both
wells are located in 20 m from ‘y’ axis, pressure values corresponding to ‘20’ is copied
and the pressure distribution graph is plotted with the help of excel (Graph 1).

8
Picture 1. Matlab desktop/’solution_p’ function

3000 Pressure distribution


2500
Predicted pressure (psi)

2000

1500

1000

500

0
0 50 100 150 200
Position (meter)

Graph 1. Pressure distribution (grid number=40x20)

Then, grid numbers are changed to 80x40 in matlab spreadsheet to observe the same
relationship with fine grids. Now, the wells are located in 40 m from ‘y’ axis, so the
corresponding pressure values are taken from ‘solution_p’ matrix again.

9
3500 Pressure distribution with fine and coarse grids
3000

Predicted pressure (psi)


2500

2000

1500

1000

500

0
0 50 100 150 200 250
Position (meter)

Graph 2. Pressure distribution (grid number=40x20(red) and 80x40(blue))

As mentioned above, the second issue to discuss is to define the minimum distance
between the wells at which they will not interact each other. In fact, as there is no
certain mathematical way to calculate this distance, the only solution is to guess the any
value and check the validity. The first guess may be 200x30 and 200x320 coordinates
(with meter) for well 1 and 2 respectively. 3D and 2D cross section are as below.
% Set the location of the well bore (m)
x_well(1)=200;
y_well(1)=30;

x_well(2)=200;
y_well(2)=320;

10
3000 Pressure distribution
2500 d

predicted pressure (psi)


2000

1500

1000

500

0
0 50 100 150 200
Position (m)

Graph 3. Pressure distribution for 200x30 and 200x320 well coordinates

Figure 6. Simulation for 200x30 and 200x320 well coordinates

Pressure decline between the regions of two wells are easily seen, so those coordinates
are not away from each other enough and needs new guess that the wells are more

11
apart from each other. Next guess is 200x30 and 200x350 coordinates (with meter) for
well 1 and 2 wells respectively and this distance produce the following pressure
distribution.

3000
Pressure distribution
2500
predicted pressure (psi)

2000

1500

1000

500

0
0 50 100 150 200
position (m)

Graph 4. Pressure distribution for 200x30 and 200x350 well coordinates

12
Figure 7. Simulation for 200x30 and 200x350 well coordinates

Now, it is obvious how the pressure in the region between two wells is almost equal to
that of boundary pressure. This means that region is not disturbed by well
superposition. So, the minimum distance should be less than 320 meter and greater
than 290 meter.

The following issue to analyze is the effect of permeability, porosity and compressibility
values over the reservoir behavior. Those parameters are reservoir properties and do
not depend on the well location at all. Those three parameters and fluid viscosity are
introduced into the coding as diffusivity equation:

This value is introduced into the coding as follows:


phi=0.12;
permeabilityx=70*10^-15;
permeabilityy=70*10^-15;
compressibility=2*10^-9; %[Pa^-1]
viscosity=4*0.001; %[Pa*s]

13
Dx=permeabilityx/(phi*compressibility*viscosity);
Dy=permeabilityy/(phi*compressibility*viscosity);

The key point that affect the simulation is whether the reservoir is homogeneous (equal
permeability and porosity towards all directions) or not. In the current problem, the
reservoir is given as homogenous, however, in reality, vertical permeability may be
greater or less than that of horizontal permeability. the case of greater permeability in ‘y’
direction than ‘x’ direction causes more pressure drop through ‘y’ direction and leads to
the following graphs.
% Diffusion coefficients
Dx=0.0072; % m2/s
Dy=0.072; % m2/s

Figure 8. Heterogeneous Reservoir Simulation with greater permeability with y direction

In contrast, for the case of greater permeability in ‘x’ direction, additional pressure drop
appears through ‘x’ direction due to more friction caused by viscous fluid.

14
Figure 9. Heterogeneous Reservoir Simulation with greater permeability with x direction

The following graph perfectly illustrates the additional pressure drop through ‘y’ direction
in the former case due to heterogeneity. These differences may be explained by friction
forces; low permeability means more restriction to flow, hence more friction and drag
forces through the flow direction.

3500 Pressure distribution


3000 Delta P caused by
hetereogeneity
Predicted pressure (psi)

2500

2000
Dx>Dy
1500
Dy>Dx
1000

500

0
0 50 100 150 200 250
Position (m)

15
Graph 5. Pressure differences due to heterogeneity

Furthermore, Matlab has the ability to count the time that run for process calculations
which is great tool to improve the coding. This is done by “Run and Time” command
which is in “Editor” table. The command gives the following table with time summary for
each function. In this case, self time is time that spent for every small function, while
total time is time required for whole process to end. For the current case, total time is
0.39 second.

16
Description of Coding Steps

Following section illustrates how to introduce the grid numbers, graph dimensions and
well pressures. How Matlab will use those values is that the block length is divided by
nx and ny grids respectively to define the dimension of one single block. This will help to
define the distances between wells at any locations.
nx=40;
ny=20;

block_length=400;
block_width=400;

side_pressure=3000;
well_pressure(1)=700;
well_pressure(2)=700;

Following section introduces the well locations through the reservoirs. In the problem
statement, well locations were required to be in the centre of the reservoir symmetrically
from all directions. As the total block dimension is 400 meter, both wells must be located
200 meter apart from ‘y’ axis. Both well bores must lie on the same line with 200 meter
‘x’ coordinates while well 1 is 100 m apart from right boundary and well 2 is also 100
meter apart from left boundary. The distance between wells is 200 meter initially.
x_well(1)=200;
y_well(1)=100;

x_well(2)=200;
y_well(2)=300;

As explained above, the following part shows the diffusivity coefficient which covers
permeability, porosity, compressibility and compressibility.
phi=0.12;
permeabilityx=70*10^-15;
permeabilityy=70*10^-15;
compressibility=2*10^-9; %[Pa^-1]
viscosity=4*0.001; %[Pa*s]

Dx=permeabilityx/(phi*compressibility*viscosity);
Dy=permeabilityy/(phi*compressibility*viscosity);

These are even more important parts of the coding that defines well coordinates by
dividing the well distance from boundary into total length of blocks between boundary
and well.
% Defining the i,j co-ordinates for the given well bore

17
i_well = int16(x_well/block_length*nx);
j_well = int16(y_well/block_width*ny);

% Checking of validation of numbers


if j_well<=0 j_well=1; end
if j_well>=ny j_well=ny;end

if i_well<=0 i_well=1; end


if i_well>=nx i_well=nx;end

The function below is to automatically adjust the size of matrix. It incurs the cost of
memory allocation just one and guarantee that the matrix values will be set by columns
in right order.
% Pre-allocating the matrix A and B.
array_size=nx*ny;
array_A=zeros(array_size);
array_B=zeros(array_size,1);

The core part of coding is the following loop. As mentioned earlier, there are plenty set
of equations to solve. First of all, ‘k’ counter is introduced in order to count every
equation. Then, matrix indexes are introduced with the raw and column order carefully.
Following this, boundary values are checked for array B and A, in turn. Finally, all
calculated values are set in matrixes.
k=1; % use the counter for each equation
for i=1:nx
for j=1:ny
% introducing the matrix indexes
ij=index(i,j,nx,ny);
ip1=index(i+1,j,nx,ny);
im1=index(i-1,j,nx,ny);
jp1=index(i,j+1,nx,ny);
jm1=index(i,j-1,nx,ny);

% checking the boundary values for array B first


bv=0;
if j==ny
bv=-TopBoundary*ky+bv; % Any j+1 will give the top boudnary
end
if i==nx
bv=-RightBoundary*kx+bv; % Any i+1 will give the right boundary
end
if j==1
bv=-BaseBoundary*ky+bv; % Any j-1 will give the base boundary
end
if i==1
bv=-LeftBoundary*kx+bv; % Any i-1 will give the left boundary
end

18
% set the coefficients in the A array
if i<nx
array_A(k,ip1)=kx;
end
if i>1
array_A(k,im1)=kx;
end
if j>1
array_A(k,jm1)=ky;
end
if j<ny
array_A(k,jp1)=ky;
end

% introduce the coefficient and boundary value


array_A(k,ij)=-2*(kx+ky);
array_B(k)=bv;

% well boundary checking


for w=1:2
if i==i_well(w) && j==j_well(w)
array_A(k,ij)=1; % Make the coefficient 1
array_A(k,ip1)=0;
array_A(k,im1)=0;
array_A(k,jp1)=0;
array_A(k,jm1)=0;
array_B(k)=WellBoundary(w); % give the array value
end
end

k=k+1;
end
end

Finally, array C is arranged which consists of one column and is multiplication of arrays
A and B. Then, ‘solution_p’ function is ordered and the graph is plotted.
array_C=(array_A^-1)*array_B;
solution_p=zeros(ny,nx);
for i=1:nx
for j=1:ny
k=nx*(j-1)+i;
solution_p(ny-j+1,i)=array_C(k);
end
end
createfigure(solution_p)

Conclusion

To sum up, Matlab is the brilliant tool to realize the reservoir simulations analyze any
effects in detail. However, the current project is just the simplified reservoir problem and
things go different in real situation. For instance, a plenty number of wells may be

19
required to be simulated simultaneously which will speed the Matlab calculations down.
To avoid such problems and speed up the Matlab working, a number of tips may be
followed. First of all, grid numbers should be clearly defined; higher grid values (>150)
slows the process significantly while lower values decrease the accuracy. Following
this, using small functions instead of scripts fasters the process (in the current case, the
code was generated in four scripts, however may be written in one scripts with short
functions). Additionally, to decrease the first time run cost, the code should be splitted
into simple and cohesive functions. Furthermore, using the matrix or arrays instead of
writing loop-based code and preallocating the maximum amount of space required for
an array instead of continuously resizing the arrays save Matlab working time and
increase the speed significantly. Finally, the most vital comment on speeding the
program up is to use “;” symbol. To explain how this symbol affects the calculation
speed, it is worth to compare run times. For instance, in the case of using “;” symbol,
the same function works during 0.341 second while this time is 0.698 second without
this symbol. Even in the case of higher grid numbers, total time may be reduced 70-80
times by using the symbol.

20

You might also like