Temperatura Burbuja y Rocio (MATLAB)
Temperatura Burbuja y Rocio (MATLAB)
Temperatura Burbuja y Rocio (MATLAB)
%PARAMETROS DE INTERACCION
% 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] se cambia luego de hallar la P calculada
%estimar temperatura(supuesto)
for i=1:NC
Tsati(i)=Bi(i)/(Ai(i)-log(P))-Ci(i) despeje de la ecuación de Psat
end
for i=1:NC
TsatiXi(i)=Tsati(i)*Xi(i)
end
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
XigiPsatifiPPsatj(i)=(Xi(i)*gi(i)*Psati(i))/(fi(i)*P*Psati(1))
end
Psatj=1/sum(XigiPsatifiPPsatj)
errorT=abs((T-Tc)/Tc)
T=Tc
for i =1 :NC
Yi(i)=(Xi(i)*gi(i)*Psati(i))/(fi(i)*P) con los valores corregidos, hallar Yi
end
plot(Yi(1),T,'.')
hold on
X1=X1+0.01
end
%temperatura de rocio
P=100 %kPa
fi=ones(1, NC)
while Y1 <1
Y2=1-Y1
Yi=[Y1 Y2]
gi=ones(1,NC) %cuando se corrige el error este se debe cambiar y deja de ser supuesto
errorg=10
%estimar temperatura(supuesto)
for i=1:NC
Tsati(i)=Bi(i)/(Ai(i)-log(P))-Ci(i) %se usa la P del problema
end
for i=1:NC
TsatiYi(i)=Tsati(i)*Yi(i)
end
errorT=10
while errorT > 0.00001
Psatj=sum(YifiPPsatjgiPsati)
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) %este x es el normalizado
end
%calculo de gamma se debe tener en cuenta que g se estimo antes, esta es la corrección
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
Y1=Y1+0.01
end
_________________________________________________________
%ELV PRESION
clear all
%equilibrio liquido vapor modelo NRTL metanol benceno
% presion de burbuja
X1=0
while X1 <1
X2=1-X1
Xi=[X1 X2]
T= 60 %°C
fi=ones(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
XigiPsatifi(i)=(Xi(i)*gi(i)*Psati(i))/fi(i)
end
P=sum(XigiPsatifi)
for i =1 :NC
Yi(i)=(Xi(i)*gi(i)*Psati(i))/(fi(i)*P)
end
plot(Yi(1),P,'.')
hold on
X1=X1+0.01
end
% presion de rocio
T= 60 %°C
fi=ones(1,NC)
Y1=0
while Y1 <1
Y2=1-Y1
Yi=[Y1 Y2]
for i= 1:NC
Psati(i)=exp(Ai(i)- Bi(i)/(T+Ci(i)))
end
gi=ones(1,NC)
errorg=10
while errorg > 0.00001
for i =1 :NC
YifigiPsati(i)=(Yi(i)*fi(i))/(gi(i)*Psati(i))
end
P=1/sum(YifigiPsati)
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
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),P,'.')
hold on
Y1=Y1+0.01
end