You are on page 1of 2

% Vapor Pressure calculations based on EoS

% Inputs:
% P
= Vapor pressure [Pa]
% T
= temperature [K]
% pc
= critical pressure of all components (n x 1 column
vector)[Pa]
% Tc
= critical temperature of all components (n x 1 column
vector)[K]
% Outputs:
% V
= molar volume [m3/mol]
% Z
= compressibility factor
% phi = fugacity coefficient
%------------------------------------------------------------------%
1:CO2
2:Nonane
3:Acetone
4:Amonia
5:Toluene
%------------------------------------------------------------------Pc=[7388400 2309700 4800000 11279800 4109000];
% Pa
Tc=[304.15 594.55 508.15 405.55 591.79];
% Kelin
% m = [ m1 m2 m3 n1 ]
m =[0.6026 -1.017 2.031 0.177
0.7319 -1.605 3.2628 -0.0324
0.6660 -1.249 2.5711 0.079
0.635 -1.127 2.298 0.129
0.6359 -1.118 2.2887 0.0603];
R = 8.314; % m3 Pa/(mol K) = J/mol-K
% Intial Guess
T = input('T(kelvin)=');
P(1)= input('P(Pascal)=');
for i=1:5
for j=1:10
% Calculation of Parameters of a,b
Tr(i) = T/Tc(i);
alfa(i)=(1+m(i,1)*(1-Tr(i)^0.5)+m(i,2)*(1Tr(i)^0.5)^2+m(i,3)*(1-Tr(i)^0.5)^3);
beta(i)=(1+m(i,4)*(1-Tr(i)))^2;
ac(i) = 0.51301*(R^2)*(Tc(i)^2)/Pc(i);
bc(i) = 0.058743*R*Tc(i)/Pc(i);
a(i)
= alfa(i)*ac(i);
b(i)
= beta(i)*bc(i);
% Obtain volumes(v) in a given T and guessed P
% A v^3 -RT/P v^2 + (a/P-b^2-3bRT/P)v - (ab/P+2b^2RT/P)=0
v =[1 (R*T/P(j)) ((a(i)/P(j))-b(i)^2-3*b(i)*R*T/P(j))
((a(i)*b(i)/P(j))+2*b(i)^2*R*T/P(j))];
V = roots(v);
Vl = max(V);
Vg = min(V);
Zl =(Vl+2*b(i))/(Vl-b(i))-(a(i)/(R*T))/(Vl+b(i));
Zg =(Vg+2*b(i))/(Vg-b(i))-(a(i)/(R*T))/(Vg+b(i));

% Calculation of Fugacity Coefficeint of Liquid and Gas


PhiL=exp(3*log(Vl/(Vl-b(i)))(a(i)/(b(i)*R*T))*log((Vl+b(i))/Vl)-log(Zl)+Zl-1)
Phig=exp(3*log(Vg/(Vg-b(i)))(a(i)/(b(i)*R*T))*log((Vg+b(i))/Vg)-log(Zg)+Zg-1)
if PhiL==Phig;
disp(P(j));
else
P(j+1)=P(j)*(PhiL./Phig);
end
end
end

You might also like