Vous êtes sur la page 1sur 4

%this program is to calculate

compressibility factor(z)by different


%methodes
clear,clc
%inputs
x=input('Mole fractions [ CO2 N2 C1 C2
C3 i-C4 n-C4 ] =');
p=input('initial reservoir pressure
(psia)=');
T=input('initial reservoir temperature
(degree F)=');
Tci=input('critical temperatures for
the components are');
Pci=input('critical pressures for the
components are');
Tpc=0;
Ppc=0;
for i=1:length(x)
Tpc=Tpc+(Tci(i)*x(i));
Ppc=Ppc+(Pci(i)*x(i));
end
%Tr is the psuedo reduced temperature
and P is the psuedo reduced pressure
Tr=(T+460)/Tpc;
t=1/Tr;
Pr=p/Ppc;
%Hall_Yarborough method
x1=-0.06125*Pr*t*exp(-1.2*(1-t)^2);
x2=14.76*t-9.76*(t)^2+4.58*(t)^3;
x3=90.7*t-242.2*(t)^2+42.4*(t)^3;
x4=2.18+2.82*t;
Y=0.0125*Pr*t*exp(-1.2*(1-t)^2);
error=1;
while error >10^(-12)
f=x1+(Y+Y^2+Y^3+Y^4)/((1-Y)^3)-
x2*(Y)^2+x3*Y^(x4);
fd=(1+4*Y+4*Y^2-4*Y^3+Y^4)/((1-
Y)^4)-2*(x2)*Y+x3*x4*(Y)^(x4-1);
Y1=Y-f/fd;
error=abs(Y1-Y);
Y=Y1;
end
z=((0.06125*Pr*t)/Y1)*exp(-1.2*(1-
t)^2);
str=['Compressiblity Factor Using Hall
Eq., Z = ',num2str(z)];
disp(str);
%Dranchuk_Abu Kassem Method
a1=0.3265;
a2=-1.07;
a3=-0.5339;
a4=0.01569;
a5=-0.05165;
a6=0.5475;
a7=-0.7361;
a8=0.1844;
a9=0.1056;
a10=0.6134;
a11=0.721;
r1=a1+a2/Tr+a3/((Tr)^3)+a4/(Tr^4)+a5/(
Tr^5);
r2=0.27*Pr/Tr;
r3=(a6+a7/Tr+a8/(Tr^2));
r4=a9*(a7/Tr+a8/(Tr^2));
r5=a10/Tr^3;
ro=0.27*Pr/Tr;
error=1;
while error >10^(-12)
f=r1*ro-r2/ro+r3*ro^2-
r4*ro^5+r5*(1+a11*ro^2)*exp(-
a11*ro^2)+1;
fd=r1+r2/ro^2+2*r3*ro-
5*r4*ro^4+2*r5*ro*exp(-
a11*ro^2)*((1+2*a11*ro^3)-
a11*(ro^2)*(1+a11*ro^2));
ro1=ro-f/fd;
error=abs(ro1-ro);
ro=ro1;
end
z1=0.27*Pr/(ro*Tr);
str=['Compressiblity Factor Using Abu
kassem equation, Z = ',num2str(z1)];
disp(str);
%Dranchuk_purvis_robinson Method
a1=0.31506237;
a2=-1.0467099;
a3=-0.57832720;
a4=0.53530771;
a5=-0.61232032;
a6=-0.10488813;
a7=0.68157001;
a8=0.68446549;
t1=a1+a2/Tr+a3/Tr^3;
t2=a4+a5/Tr;
t3=a5*a6/Tr;
t4=a7/Tr^3;
t5=0.27*Pr/Tr;
rho=0.27*Pr/Tr;
error=1;
syms r
f=1+t1*r+t2*r^2+t3*r^5+(t4*r^2*(1+a8*r
^2)*exp(-a8*r^2))-t5/r;
fd=diff(f,r);
while error >10^(-12)
f1=subs(f,r,rho);
fd1=subs(fd,r,rho);
rho1=rho-f1/fd1;
error=abs(rho1-rho);
rho=rho1;
end
z2=0.27*Pr/(rho*Tr);
str=['Compressiblity Factor Using
Robinson equation, Z = ',num2str(z2)];
disp(str);

Vous aimerez peut-être aussi