0% found this document useful (0 votes)
35 views5 pages

Optional (MATLAB)

This MATLAB code calculates the bubble point and dew point temperatures of a two-component mixture using the Peng-Robinson equation of state. It initializes parameters like the interaction coefficients Aij, Bij, and Cij. It then iteratively estimates the temperature by calculating vapor pressures until the difference between the estimated and calculated temperatures converges to within 0.00001. Plots of mole fraction vs. temperature are generated for the bubble point and dew point calculations.

Uploaded by

Sergio Luna
Copyright
© © All Rights Reserved
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)
35 views5 pages

Optional (MATLAB)

This MATLAB code calculates the bubble point and dew point temperatures of a two-component mixture using the Peng-Robinson equation of state. It initializes parameters like the interaction coefficients Aij, Bij, and Cij. It then iteratively estimates the temperature by calculating vapor pressures until the difference between the estimated and calculated temperatures converges to within 0.00001. Plots of mole fraction vs. temperature are generated for the bubble point and dew point calculations.

Uploaded by

Sergio Luna
Copyright
© © All Rights Reserved
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/ 5

%ELV TEMP

clear all

% temperatura burbuja
NC=2 % numero componentes

%PARAMETROS DE INTERACCION

Aij=[0 -0.3547 ;-2.8744 0]


Bij=[0 389.079 ;1603.93 0]
Cij=[0 0.4;0.4 0]

% constantes Antoine
Ai=[16.5938 13.8594]
Bi=[3644.3 2773.78]
Ci=[239.76 220.07]

P=100 %kPa
fi=ones(1, NC)
X1=0

while X1 <1

X2=1-X1
Xi=[X1 X2]

%estimar temperatura(supuesto)

for i=1:NC
Tsati(i)=Bi(i)/(Ai(i)-log(P))-Ci(i)
end

for i=1:NC
TsatiXi(i)=Tsati(i)*Xi(i)
end

T=sum(TsatiXi)

errorT=10

while errorT > 0.00001


% calculo presion saturacion
for i= 1:NC

Psati(i)=exp(Ai(i)- Bi(i)/(T+Ci(i)))

end

%calculo de gamma

for i =1:NC
for j=1:NC
Tij(i,j)=Aij(i,j)+Bij(i,j)/(T+273.15)
Gij(i,j)=exp(-Cij(i,j)*Tij(i,j))
end
end

for i =1:NC

for j=1:NC
TjiGjiXj(j)=Tij(j,i)*Gij(j,i)*Xi(j)

for k=1 : NC
TkjGkjXk(k)=Tij(k,j)*Gij(k,j)*Xi(k)
GkjXk(k)=Gij(k,j)*Xi(k)
GkiXk(k)=Gij(k,i)*Xi(k)
end
sumatoria(j)=((Xi(j)*Gij(i,j))/sum(GkjXk))*(Tij(i,j)-
sum(TkjGkjXk)/sum(GkjXk))
end

gi(i)=exp((sum(TjiGjiXj)/sum(GkiXk))+sum(sumatoria))
end

for i=1 :NC

XigiPsatifiPPsatj(i)=(Xi(i)*gi(i)*Psati(i))/(fi(i)*P*Psati(1))
end

Psatj=1/sum(XigiPsatifiPPsatj)

Tc=Bi(1)/(Ai(1)-log(Psatj))-Ci(1)

errorT=abs((T-Tc)/Tc)

T=Tc

end

for i =1 :NC
Yi(i)=(Xi(i)*gi(i)*Psati(i))/(fi(i)*P)
end

plot(Yi(1),T,'.')
hold on

X1=X1+0.01

end

%temperatura de rocio
P=100 %kPa
fi=ones(1, NC)

Y1=0

while Y1 <1
Y2=1-Y1

Yi=[Y1 Y2]
gi=ones(1,NC)

errorg=10

while errorg > 0.00001

%estimar temperatura(supuesto)

for i=1:NC
Tsati(i)=Bi(i)/(Ai(i)-log(P))-Ci(i)
end

for i=1:NC
TsatiYi(i)=Tsati(i)*Yi(i)
end

T=sum(TsatiYi)

errorT=10
while errorT > 0.00001
% calculo presion saturacion
for i= 1:NC
Psati(i)=exp(Ai(i)- Bi(i)/(T+Ci(i)))
end

for i=1 :NC


YifiPPsatjgiPsati(i)=(Yi(i)*fi(i)*P*Psati(1))/(gi(i)*Psati(i))
end

Psatj=sum(YifiPPsatjgiPsati)

Tc=Bi(1)/(Ai(1)-log(Psatj))-Ci(1)

errorT=abs((T-Tc)/Tc)

T=Tc

end

for i=1:NC
xi(i)=(Yi(i)*fi(i)*P)/(gi(i)*Psati(i))
end
for i =1 :NC
Xi(i)=xi(i)/sum(xi)
end

%calculo de gamma

for i =1:NC
for j=1:NC
Tij(i,j)=Aij(i,j)+Bij(i,j)/(T+273.15)
Gij(i,j)=exp(-Cij(i,j)*Tij(i,j))
end
end

for i =1:NC

for j=1:NC
TjiGjiXj(j)=Tij(j,i)*Gij(j,i)*Xi(j)

for k=1 : NC
TkjGkjXk(k)=Tij(k,j)*Gij(k,j)*Xi(k)
GkjXk(k)=Gij(k,j)*Xi(k)
GkiXk(k)=Gij(k,i)*Xi(k)
end
sumatoria(j)=((Xi(j)*Gij(i,j))/sum(GkjXk))*(Tij(i,j)-
sum(TkjGkjXk)/sum(GkjXk))
end

gic(i)=exp((sum(TjiGjiXj)/sum(GkiXk))+sum(sumatoria))
end

for i =1 :NC
errorgi(i)=abs((gi(i)-gic(i))/gic(i))
end

errorg=sum(errorgi)

gi=gic

end

plot(Xi(1),T,'.')
hold on

Y1=Y1+0.01

end

You might also like