You are on page 1of 7

The following function thomas23 calculates the pressure distribution at t=10 days.

function x=thomas23(n,P0)
% Thomas algorithm for solving tri-diagonal matrix
% Prepared by Richard Chandra Chan for PTE 508 HW#7
% State the properties of 1-D porous medium system
phi=0.2; % Porosity
k=100; % Permeability in md
mu=10; % Viscosity in cp
c_t=1.5/10^5; % Total compressibility in psi^-1
L=10000; % Length of system in ft
dy=100; % Length of the drainage areas in the y direction in ft
dz=50; % Length of the drainage areas in the z diretion in ft
% 1-D system uses block-centered configuration
dx=L/n; % Length of one interval
dt=10; % Time step in days
% well information
q_p=20; % rB/d
% Definition of beta
beta=(158*phi*mu*c_t)/k;
% Definition of zeta
zeta=2+(beta*(((dx)^2)/dt));
% Definition of alpha
alpha=(887.53*q_p*mu)/(k*dy*dz);
% Defining the a, b, and c vectors
a=[0;ones(n-1,1)];
b=[1-zeta;repmat(-zeta,n-2,1);1-zeta];
c=[ones(n-1,1);0];
% At t=10 days, previous time is at t=0 days where pressure at all locations
is at 3000 psia
v=repmat((2-zeta)*P0,n,1);
s=(n-1)/2;
v_w=[zeros(s,1);alpha*dx;zeros(s,1)];
d=v+v_w;
w(1)=c(1)/b(1);
g(1)=d(1)/b(1);
for z=2:n-1
w(z)=c(z)/(b(z)-a(z)*w(z-1));
end
for z=2:n
g(z)=(d(z)-a(z)*g(z-1))/(b(z)-a(z)*w(z-1));
end
x(n)=g(n);
for k=n-1:-1:1
x(k)=g(k)-w(k)*x(k+1);
end
x=x';

The following function thomas24 calculates the pressure distribution at t=20 days.
function x=thomas24(n,P0)
% Thomas algorithm for solving tri-diagonal matrix
% Prepared by Richard Chandra Chan for PTE 508 HW#7
% State the properties of 1-D porous medium system

phi=0.2; % Porosity
k=100; % Permeability in md
mu=10; % Viscosity in cp
c_t=1.5/10^5; % Total compressibility in psi^-1
L=10000; % Length of system in ft
dy=100; % Length of the drainage areas in the y direction in ft
dz=50; % Length of the drainage areas in the z diretion in ft
% 1-D system uses block-centered configuration
dx=L/n; % Length of one interval
dt=10; % Time step in days
% well information
q_p=20; % rB/d
% Definition of beta
beta=(158*phi*mu*c_t)/k;
% Definition of zeta
zeta=2+(beta*(((dx)^2)/dt));
% Definition of alpha
alpha=(887.53*q_p*mu)/(k*dy*dz);
% Defining the a, b, and c vectors
a=[0;ones(n-1,1)];
b=[1-zeta;repmat(-zeta,n-2,1);1-zeta];
c=[ones(n-1,1);0];
% At t=20 days, previous time is at t=10 days
P_ten=thomas23(n,P0);
v=(2-zeta)*P_ten;
s=(n-1)/2;
v_w=[zeros(s,1);alpha*dx;zeros(s,1)];
d=v+v_w;
w(1)=c(1)/b(1);
g(1)=d(1)/b(1);
for z=2:n-1
w(z)=c(z)/(b(z)-a(z)*w(z-1));
end
for z=2:n
g(z)=(d(z)-a(z)*g(z-1))/(b(z)-a(z)*w(z-1));
end
x(n)=g(n);
for k=n-1:-1:1
x(k)=g(k)-w(k)*x(k+1);
end
x=x';

The following function thomas25 calculates the pressure distribution at t=30 days.
function x=thomas25(n,P0)
% Thomas algorithm for solving tri-diagonal matrix
% Prepared by Richard Chandra Chan for PTE 508 HW#7
% State the properties of 1-D porous medium system
phi=0.2; % Porosity
k=100; % Permeability in md
mu=10; % Viscosity in cp
c_t=1.5/10^5; % Total compressibility in psi^-1
L=10000; % Length of system in ft
dy=100; % Length of the drainage areas in the y direction in ft
dz=50; % Length of the drainage areas in the z diretion in ft
% 1-D system uses block-centered configuration

dx=L/n; % Length of one interval


dt=10; % Time step in days
% well information
q_p=20; % rB/d
% Definition of beta
beta=(158*phi*mu*c_t)/k;
% Definition of zeta
zeta=2+(beta*(((dx)^2)/dt));
% Definition of alpha
alpha=(887.53*q_p*mu)/(k*dy*dz);
% Defining the a, b, and c vectors
a=[0;ones(n-1,1)];
b=[1-zeta;repmat(-zeta,n-2,1);1-zeta];
c=[ones(n-1,1);0];
% At t=30 days, previous time is at t=20 days
P_twenty=thomas24(n,P0);
v=(2-zeta)*P_twenty;
s=(n-1)/2;
v_w=[zeros(s,1);alpha*dx;zeros(s,1)];
d=v+v_w;
w(1)=c(1)/b(1);
g(1)=d(1)/b(1);
for z=2:n-1
w(z)=c(z)/(b(z)-a(z)*w(z-1));
end
for z=2:n
g(z)=(d(z)-a(z)*g(z-1))/(b(z)-a(z)*w(z-1));
end
x(n)=g(n);
for k=n-1:-1:1
x(k)=g(k)-w(k)*x(k+1);
end
x=x';

The following function thomas26 calculates the pressure distribution at t=40 days.
function x=thomas26(n,P0)
% Thomas algorithm for solving tri-diagonal matrix
% Prepared by Richard Chandra Chan for PTE 508 HW#7
% State the properties of 1-D porous medium system
phi=0.2; % Porosity
k=100; % Permeability in md
mu=10; % Viscosity in cp
c_t=1.5/10^5; % Total compressibility in psi^-1
L=10000; % Length of system in ft
dy=100; % Length of the drainage areas in the y direction in ft
dz=50; % Length of the drainage areas in the z diretion in ft
% 1-D system uses block-centered configuration
dx=L/n; % Length of one interval
dt=10; % Time step in days
% well information
q_p=20; % rB/d
% Definition of beta
beta=(158*phi*mu*c_t)/k;
% Definition of zeta
zeta=2+(beta*(((dx)^2)/dt));

% Definition of alpha
alpha=(887.53*q_p*mu)/(k*dy*dz);
% Defining the a, b, and c vectors
a=[0;ones(n-1,1)];
b=[1-zeta;repmat(-zeta,n-2,1);1-zeta];
c=[ones(n-1,1);0];
% At t=40 days, previous time is at t=30 days
P_thirty=thomas25(n,P0);
v=(2-zeta)*P_thirty;
s=(n-1)/2;
v_w=[zeros(s,1);alpha*dx;zeros(s,1)];
d=v+v_w;
w(1)=c(1)/b(1);
g(1)=d(1)/b(1);
for z=2:n-1
w(z)=c(z)/(b(z)-a(z)*w(z-1));
end
for z=2:n
g(z)=(d(z)-a(z)*g(z-1))/(b(z)-a(z)*w(z-1));
end
x(n)=g(n);
for k=n-1:-1:1
x(k)=g(k)-w(k)*x(k+1);
end
x=x';

The following function thomas27 calculates the pressure distribution at t=50 days.
function x=thomas27(n,P0)
% Thomas algorithm for solving tri-diagonal matrix
% Prepared by Richard Chandra Chan for PTE 508 HW#7
% State the properties of 1-D porous medium system
phi=0.2; % Porosity
k=100; % Permeability in md
mu=10; % Viscosity in cp
c_t=1.5/10^5; % Total compressibility in psi^-1
L=10000; % Length of system in ft
dy=100; % Length of the drainage areas in the y direction in ft
dz=50; % Length of the drainage areas in the z diretion in ft
% 1-D system uses block-centered configuration
dx=L/n; % Length of one interval
dt=10; % Time step in days
% well information
q_p=20; % rB/d
% Definition of beta
beta=(158*phi*mu*c_t)/k;
% Definition of zeta
zeta=2+(beta*(((dx)^2)/dt));
% Definition of alpha
alpha=(887.53*q_p*mu)/(k*dy*dz);
% Defining the a, b, and c vectors
a=[0;ones(n-1,1)];
b=[1-zeta;repmat(-zeta,n-2,1);1-zeta];
c=[ones(n-1,1);0];
% At t=50 days, previous time is at t=40 days
P_forty=thomas26(n,P0);
v=(2-zeta)*P_forty;

s=(n-1)/2;
v_w=[zeros(s,1);alpha*dx;zeros(s,1)];
d=v+v_w;
w(1)=c(1)/b(1);
g(1)=d(1)/b(1);
for z=2:n-1
w(z)=c(z)/(b(z)-a(z)*w(z-1));
end
for z=2:n
g(z)=(d(z)-a(z)*g(z-1))/(b(z)-a(z)*w(z-1));
end
x(n)=g(n);
for k=n-1:-1:1
x(k)=g(k)-w(k)*x(k+1);
end
x=x';

For generating the output in question 3(c) at the various time:


% Pressure value of Pi for i=1 to 9 at t=10 days
x_10days=thomas23(9,3000);
P_10days=x_10days'
% Pressure value of Pi for i=1 to 9 at t=20 days
x_20days=thomas24(9,3000);
P_20days=x_20days'
% Pressure value of Pi for i=1 to 9 at t=30 days
x_30days=thomas25(9,3000);
P_30days=x_30days'
% Pressure value of Pi for i=1 to 9 at t=40 days
x_40days=thomas26(9,3000);
P_40days=x_40days'
% Pressure value of Pi for i=1 to 9 at t=50 days
x_50days=thomas27(9,3000);
P_50days=x_50days'

Results are as follows:


>> output2
P_10days =
1.0e+003 *
3.0000

2.9999

P_20days =
1.0e+003 *

2.9991

2.9933

2.9480

2.9933

2.9991

2.9999

3.0000

2.9999

2.9995

2.9971

2.9827

2.9066

2.9827

2.9971

2.9995

2.9999

2.9939

2.9701

2.8726

2.9701

2.9939

2.9988

2.9998

2.9896

2.9565

2.8437

2.9565

2.9896

2.9977

2.9995

2.9845

2.9425

2.8186

2.9425

2.9845

2.9962

2.9990

P_30days =
1.0e+003 *
2.9998

2.9988

P_40days =
1.0e+003 *
2.9995

2.9977

P_50days =
1.0e+003 *
2.9990

2.9962

The graph in question 3(d) can be generated using the following code:
n=9;
% Pressure distribution at t=0 day
P22=repmat(3000,9,1);
x22=P22';
% Pressure distribution at t=10 days
x23=thomas23(9,3000);
% Pressure distribution at t=20 days
x24=thomas24(9,3000);
% Pressure distribution at t=30 days
x25=thomas25(9,3000);
% Pressure distribution at t=40 days
x26=thomas26(9,3000);
% Pressure distribution at t=50 days
x27=thomas27(9,3000);
L=10000;
s=(L/(2*n)):(L/n):((17*L)/(2*n));
plot(s',x22,'y',s',x23,'b',s',x24,'r',s',x25,'g',s',x26,'k',s',x27,'m');
hleg=legend('t=0day','t=10days','t=20days','t=30days','t=40days','t=50days','
Location','NorthEastOutside');
set(hleg,'FontAngle','italic');
xlabel('x(ft)');
ylabel('P(psia)');

Results:

3000
t=0day
t=10days
t=20days
t=30days
t=40days
t=50days

2980
2960
2940

P(psia)

2920
2900
2880
2860
2840
2820
2800

2000

4000

6000
x(ft)

8000

10000

You might also like