Temperatura Burbuja y Rocio (MATLAB)

Descargar como docx, pdf o txt
Descargar como docx, pdf o txt
Está en la página 1de 8

clear all

% temperatura burbuja se desconoce T y Y,no se puede hallar P saturación

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] 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

T=sum(TsatiXi) temperatura supuesta para corregir

errorT=10 se quiere corregir el error de la suposición de temp.

while errorT > 0.00001


% calculo presion saturación con la nueva temp, se puede calcular Psat
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

%Calculo de la presión saturación (de la ecuación de fi y gamma)

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) relacionar la Psat calculada de la ecuación fi/gamma para


………………………………………hallar la Tcalculada y sacar el error

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

T=Tc

End %abrir ciclo despues de primera estimación T=sum

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)

%Y1=[0.1 0.9]% se cambia cuando se calcula el error


Y1=0

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

while errorg > 0.00001

%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

T=sum(TsatiYi) %estimación de temperatura

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)) %ecuacion gamma fi
end

Psatj=sum(YifiPPsatjgiPsati)

Tc=Bi(1)/(Ai(1)-log(Psatj))-Ci(1) %esta es la t calculada

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

%ya esta corregido g y t, entonces se puede concluir que la x opbtenida es


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

Y1=Y1+0.01

end

_________________________________________________________

%ELV PRESION
clear all
%equilibrio liquido vapor modelo NRTL metanol benceno

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]

% presion de burbuja
X1=0
while X1 <1
X2=1-X1
Xi=[X1 X2]
T= 60 %°C

fi=ones(1,NC)

% 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
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

También podría gustarte