0% found this document useful (0 votes)
137 views

Codes For PTE 508 Hw9

The document describes Matlab code for modeling pressure changes in a 2D reservoir over multiple time steps. It sets up and solves a sparse matrix representing a discretized diffusivity equation to calculate new pressure values. The code is run for 500 days in 10-day timesteps, with the pressure profile output for a 5x3 grid and optionally a 75x45 grid. Pressure initially decreases near the production well before reaching equilibrium across the reservoir over time.

Uploaded by

Richard Chan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Codes For PTE 508 Hw9

The document describes Matlab code for modeling pressure changes in a 2D reservoir over multiple time steps. It sets up and solves a sparse matrix representing a discretized diffusivity equation to calculate new pressure values. The code is run for 500 days in 10-day timesteps, with the pressure profile output for a 5x3 grid and optionally a 75x45 grid. Pressure initially decreases near the production well before reaching equilibrium across the reservoir over time.

Uploaded by

Richard Chan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Matlab Codes

function P_new=Two_DD(P_ini,nx,ny)
% PTE 508 Homework 9 Question 3
% Prepared by Richard Chandra Chan
% Creating a sparse matrix to solve new pressure values in a 2-D system
% from discretization of the 2-D diffusivity equations
clc %clear working screen
clf %clear figure window
format short
% Drainage area dimensions
Lx=5000;% in ft
Ly=3000;% in ft
del_z=50;% in ft
n_xy=nx*ny;
del_x=Lx/nx;
del_y=Ly/ny;
d_xy2=(del_x/del_y)^2;
% Properties
phi=0.15;
perm=50;% in mD
visc=2.5;% in cp
B=1;% in RB/STB
ct=1/10^5;% in psi^-1
% P_ini=3125;% initial pressure
% Time
del_t=10; % in days
% Well production rate
q_stb=100;% in STB/D at t=0
% Other constants
alpha=((158*phi*visc*ct)/perm)*((del_x)^2/del_t);
beta=(887.53*q_stb*B*visc*del_x)/(perm*del_z*del_y);
C_m=-2-2*d_xy2-alpha;
% Define S-, W-, C-, E-, and N- coefficient vectors, old pressure and d
% vectors
S_vec=d_xy2*ones(n_xy,1);
W_vec=ones(n_xy,1);
C_vec=C_m*ones(n_xy,1);
E_vec=ones(n_xy,1);
N_vec=d_xy2*ones(n_xy,1);
P_vec=P_ini*ones(n_xy,1);
d_vec=-alpha*P_vec;
% Defining boundary conditions
% At x=0, y=0 to Ly (West boundary)
i=1;
for j=1:ny
m=(j-1)*nx+i;
C_vec(m)=C_vec(m)+W_vec(m);
W_vec(m)=0;
end
% At x=Lx, y=0 to Ly (East boundary)
i=nx;
for j=1:ny
m=(j-1)*nx+i;
C_vec(m)=C_vec(m)+E_vec(m);
E_vec(m)=0;
end
% At y=0, x=0 to Lx (South boundary)
j=1;
for i=1:nx
m=(j-1)*nx+i;
C_vec(m)=C_vec(m)+S_vec(m);
S_vec(m)=0;
end
% At y=Ly, x=0 to Lx (North boundary)
j=ny;
for i=1:nx
m=(j-1)*nx+i;
C_vec(m)=C_vec(m)+N_vec(m);
N_vec(m)=0;

end
% Location of the well is at i=3, j=2 using the m=(j-1)*nx+i
w_l=(round(ny/2)-1)*nx+round(nx/2);
d_vec(w_l)=d_vec(w_l)+beta;
% Shift the S- and W- vectors before creating the sparse matrix
for m=1:(n_xy-nx)
S_vec(m)=S_vec(m+nx);
end
for m=2:n_xy
W_vec(m-1)=W_vec(m);
end
for m=n_xy-1:-1:1
E_vec(m+1)=E_vec(m);
end
for m=n_xy-nx:-1:1
N_vec(m+nx)=N_vec(m);
end
for m=1:nx
N_vec(m)=0;
end
% Constructing the sparse matrix
Sparse=spdiags([S_vec,W_vec,C_vec,E_vec,N_vec],[-nx -1 0 1 nx],n_xy,n_xy);
full(Sparse);
P_new=Sparse\d_vec;
p2d=reshape(P_new,nx,ny);
surf(p2d);
% This is only for the first time step
-----------------------------------------------------------------------------------------------function P_new=Two_DD_20(P_ini,nx,ny)
% PTE 508 Homework 9 Question 3
% Prepared by Richard Chandra Chan
% Creating a sparse matrix to solve new pressure values in a 2-D system
% from discretization of the 2-D diffusivity equations
clc %clear working screen
clf %clear figure window
format short
% Drainage area dimensions
Lx=5000;% in ft
Ly=3000;% in ft
del_z=50;% in ft
n_xy=nx*ny;
del_x=Lx/nx;
del_y=Ly/ny;
d_xy2=(del_x/del_y)^2;
% Properties
phi=0.15;
perm=50;% in mD
visc=2.5;% in cp
B=1;% in RB/STB
ct=1/10^5;% in psi^-1
% Time
del_t=10; % in days
% Well production rate
q_stb=100;% in STB/D at t=0
% Other constants
alpha=((158*phi*visc*ct)/perm)*((del_x)^2/del_t);
beta=(887.53*q_stb*B*visc*del_x)/(perm*del_z*del_y);
C_m=-2-2*d_xy2-alpha;
% Define S-, W-, C-, E-, and N- coefficient vectors, old pressure and d
% vectors
S_vec=d_xy2*ones(n_xy,1);
W_vec=ones(n_xy,1);
C_vec=C_m*ones(n_xy,1);
E_vec=ones(n_xy,1);
N_vec=d_xy2*ones(n_xy,1);
P_vec=Two_DD(3125,nx,ny);
d_vec=-alpha*P_vec;
% Defining boundary conditions
% At x=0, y=0 to Ly (West boundary)
i=1;

for j=1:ny
m=(j-1)*nx+i;
C_vec(m)=C_vec(m)+W_vec(m);
W_vec(m)=0;
end
% At x=Lx, y=0 to Ly (East boundary)
i=nx;
for j=1:ny
m=(j-1)*nx+i;
C_vec(m)=C_vec(m)+E_vec(m);
E_vec(m)=0;
end
% At y=0, x=0 to Lx (South boundary)
j=1;
for i=1:nx
m=(j-1)*nx+i;
C_vec(m)=C_vec(m)+S_vec(m);
S_vec(m)=0;
end
% At y=Ly, x=0 to Lx (North boundary)
j=ny;
for i=1:nx
m=(j-1)*nx+i;
C_vec(m)=C_vec(m)+N_vec(m);
N_vec(m)=0;
end
% Location of the well is at i=3, j=2 using the m=(j-1)*nx+i
w_l=(round(ny/2)-1)*nx+round(nx/2);
d_vec(w_l)=d_vec(w_l)+beta;
% Shift the S- and W- vectors before creating the sparse matrix
for m=1:(n_xy-nx)
S_vec(m)=S_vec(m+nx);
end
for m=2:n_xy
W_vec(m-1)=W_vec(m);
end
for m=n_xy-1:-1:1
E_vec(m+1)=E_vec(m);
end
for m=n_xy-nx:-1:1
N_vec(m+nx)=N_vec(m);
end
for m=1:nx
N_vec(m)=0;
end
% Constructing the sparse matrix
Sparse=spdiags([S_vec,W_vec,C_vec,E_vec,N_vec],[-nx -1 0 1 nx],n_xy,n_xy);
full(Sparse);
P_new=Sparse\d_vec;
p2d=reshape(P_new,nx,ny);
surf(p2d);
% This is only for the second time step

The only thing that changes from each time step is the value of d_vec which is determined using
the pressure information from the previous time step. The strategy that I used is to change the
pressure values vector while everything else remains the same (See the highlighted part above).
After creating the same function for the other time step,
So for t=10 to 500, the pressure profile at the 15 locations (5 by 3 system) is as follows:

a=5;% value of nx

b=3;% value of ny
p=[Two_DD(3125,a,b),Two_DD_20(3125,a,b),Two_DD_30(3125,a,b),Two_DD_40(3125,a,b),Two_DD_50(3125,a,
b),Two_DD_60(3125,a,b),Two_DD_70(3125,a,b),Two_DD_80(3125,a,b),Two_DD_90(3125,a,b),Two_DD_100(312
5,a,b),...
Two_DD_110(3125,a,b),Two_DD_120(3125,a,b),Two_DD_130(3125,a,b),Two_DD_140(3125,a,b),Two_DD_150(31
25,a,b),Two_DD_160(3125,a,b),Two_DD_170(3125,a,b),Two_DD_180(3125,a,b),Two_DD_190(3125,a,b),Two_D
D_200(3125,a,b),...
Two_DD_210(3125,a,b),Two_DD_220(3125,a,b),Two_DD_230(3125,a,b),Two_DD_240(3125,a,b),Two_DD_250(31
25,a,b),Two_DD_260(3125,a,b),Two_DD_270(3125,a,b),Two_DD_280(3125,a,b),Two_DD_290(3125,a,b),Two_D
D_300(3125,a,b),...
Two_DD_310(3125,a,b),Two_DD_320(3125,a,b),Two_DD_330(3125,a,b),Two_DD_340(3125,a,b),Two_DD_350(31
25,a,b),Two_DD_360(3125,a,b),Two_DD_370(3125,a,b),Two_DD_380(3125,a,b),Two_DD_390(3125,a,b),Two_D
D_400(3125,a,b),...
Two_DD_410(3125,a,b),Two_DD_420(3125,a,b),Two_DD_430(3125,a,b),Two_DD_440(3125,a,b),Two_DD_450(31
25,a,b),Two_DD_460(3125,a,b),Two_DD_470(3125,a,b),Two_DD_480(3125,a,b),Two_DD_490(3125,a,b),Two_D
D_500(3125,a,b)]

Optional

Change the values of a and b below for the 75x45 grid systems
a=75;% value of nx
b=45;% value of ny
p=[Two_DD(3125,a,b),Two_DD_20(3125,a,b),Two_DD_30(3125,a,b),Two_DD_40(3125,a,b),Two_DD_50(3125,a,
b),Two_DD_60(3125,a,b),Two_DD_70(3125,a,b),Two_DD_80(3125,a,b),Two_DD_90(3125,a,b),Two_DD_100(312
5,a,b),...
Two_DD_110(3125,a,b),Two_DD_120(3125,a,b),Two_DD_130(3125,a,b),Two_DD_140(3125,a,b),Two_DD_150(31
25,a,b),Two_DD_160(3125,a,b),Two_DD_170(3125,a,b),Two_DD_180(3125,a,b),Two_DD_190(3125,a,b),Two_D
D_200(3125,a,b),...
Two_DD_210(3125,a,b),Two_DD_220(3125,a,b),Two_DD_230(3125,a,b),Two_DD_240(3125,a,b),Two_DD_250(31
25,a,b),Two_DD_260(3125,a,b),Two_DD_270(3125,a,b),Two_DD_280(3125,a,b),Two_DD_290(3125,a,b),Two_D
D_300(3125,a,b),...
Two_DD_310(3125,a,b),Two_DD_320(3125,a,b),Two_DD_330(3125,a,b),Two_DD_340(3125,a,b),Two_DD_350(31
25,a,b),Two_DD_360(3125,a,b),Two_DD_370(3125,a,b),Two_DD_380(3125,a,b),Two_DD_390(3125,a,b),Two_D
D_400(3125,a,b),...
Two_DD_410(3125,a,b),Two_DD_420(3125,a,b),Two_DD_430(3125,a,b),Two_DD_440(3125,a,b),Two_DD_450(31
25,a,b),Two_DD_460(3125,a,b),Two_DD_470(3125,a,b),Two_DD_480(3125,a,b),Two_DD_490(3125,a,b),Two_D
D_500(3125,a,b)]

At t=100 days

3090
3080
3070
3060
3050
3040
3030
3020
3010
80

60
60

40
40

20

20
0

At t=200 days

3040
3030
3020
3010
3000
2990
2980
2970
60
2960
80

40
60

40

20
20

At t=300 days

2990
2980
2970
2960
2950
2940
2930
2920
2910
80

At t=400 days

60
40
60

40

20
20

2940
2930
2920
2910
2900
2890
2880
2870
2860
80

At t=500 days

60

40

20

20

40

60

2890
2880
2870
2860
2850
2840
2830
2820
2810
80

60

40

20

20

40

60

You might also like