Subido por Sergio Luna

Anuncio
```%Fugacidad en fase vapor.
clear all
NC=2
Tcr=[521.64 562.05] %K
Pcr=[8097 4895] % kPa
R= 8.314 % kJ/kmolK
P=100 %kPa
T=80+273.15
Yi=[0.3 0.7]
for i=1:NC
ai(i)=(0.42748*(R^2)*(Tcr(i)^2.5))/Pcr(i)
bi(i)=(0.08664*R*Tcr(i))/(8*Pcr(i))
end
for i=1:NC
for j=1:NC
YiYjaiaj(j)=Yi(i)*Yi(j)*ai(i)^0.5*ai(j)^0.5
end
end
for i=1:NC
Yibi(i)=Yi(i)*bi(i)
end
b=sum(Yibi)
videal=(R*T)/P
%definici&oacute;n del m&eacute;todo de bisecci&oacute;n.
M=zeros(2,4) definir matriz para los c&aacute;lculos -evaluaci&oacute;n del signo
M(1,1)=0.8*videal un valor por debajo del buscado
M(1,3)=1.2*videal un valor por encima del buscado
M(2,2)=10 definir f(v1) en posici&oacute;n 2*2
while abs(M(2,2))&gt; 0.00001
M(1,2)=P-(R*T)/(M(1,1)-b)+a/(M(1,1)*(M(1,1)+b)*T^0.5) igualar a cero ec de RW
M(1,4)=P-(R*T)/(M(1,3)-b)+a/(M(1,3)*(M(1,3)+b)*T^0.5) reemplazar v2 en f(v2)
M(2,1)=(M(1,1)+M(1,3))/2 segunda fila---suma para seguir calculando—cambio --------------------------------------de v1
M(2,2)=P-(R*T)/(M(2,1)-b)+a/(M(2,1)*(M(2,1)+b)*T^0.5) evaluar nuevo valor de
………………………………………………………………….f(v1)
if sign(M(1,2))==sign(M(2,2)) condici&oacute;n para saber valor de v2 en segunda fila
M(2,3)=M(1,3)
else
M(2,3)=M(1,1)
end
M(2,4)=P-(R*T)/(M(2,3)-b)+a/(M(2,3)*(M(2,3)+b)*T^0.5) se define f(v2) en 2 pos.
M(1,1)=M(2,1)
M(1,2)=M(2,2)
M(1,3)=M(2,3)
M(1,4)=M(2,4)
end
v=M(2,1) este es el calculado en v1
for j=1:NC
Yjaj(j)=Yi(j)*ai(j)^0.5 abrir termino de ec. Larga RW
end
for i=1 :NC
fi(i)=exp(log(v/(v-b))+bi(i)/(v-b)+((2*sum(Yjaj)*ai(i)^0.5)/(R*b*T^1.5)(a*bi(i))/(R*b^2*T^1.5))*log(v/(v+b))-(a*bi(i))/(R*T^1.5*b*(v+b))-log((P*v)/(R*T)))
end
%Temperatura de burbuja con calculo de gama
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]
Tcr=[521.64 562.05] %K
Pcr=[8097 4895] % kPa
R= 8.314 % kJ/kmolK
P=1000 %kPa
X1=0
while X1 &lt;1
X2=1-X1
Xi=[X1 X2]
fi=ones(1, NC) aqu&iacute; se supone el fi ideal
errorf=10
while errorf &gt;0.0001
%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 &gt; 0.00001
% calculo presion saturacion
for i= 1:NC
Psati(i)=exp(Ai(i)- Bi(i)/(T+Ci(i)))
end
%calculo de gamma gamma de coeficiente
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
T=T+273.15
for i=1:NC
ai(i)=(0.42748*(R^2)*(Tcr(i)^2.5))/Pcr(i)
bi(i)=(0.08664*R*Tcr(i))/(8*Pcr(i))
end
for i=1:NC
for j=1:NC
YiYjaiaj(j)=Yi(i)*Yi(j)*ai(i)^0.5*ai(j)^0.5
end
end
for i=1:NC
Yibi(i)=Yi(i)*bi(i)
end
b=sum(Yibi)
videal=(R*T)/P
M=zeros(2,4)
M(1,1)=0.8*videal
M(1,3)=1.2*videal
M(2,2)=10
while abs(M(2,2))&gt; 0.00001
M(1,2)=P-(R*T)/(M(1,1)-b)+a/(M(1,1)*(M(1,1)+b)*T^0.5)
M(1,4)=P-(R*T)/(M(1,3)-b)+a/(M(1,3)*(M(1,3)+b)*T^0.5)
M(2,1)=(M(1,1)+M(1,3))/2
M(2,2)=P-(R*T)/(M(2,1)-b)+a/(M(2,1)*(M(2,1)+b)*T^0.5)
if sign(M(1,2))==sign(M(2,2))
M(2,3)=M(1,3)
else
M(2,3)=M(1,1)
end
M(2,4)=P-(R*T)/(M(2,3)-b)+a/(M(2,3)*(M(2,3)+b)*T^0.5)
M(1,1)=M(2,1)
M(1,2)=M(2,2)
M(1,3)=M(2,3)
M(1,4)=M(2,4)
end
v=M(2,1)
for j=1:NC
Yjaj(j)=Yi(j)*ai(j)^0.5
end
for i=1 :NC
fic(i)=exp(log(v/(v-b))+bi(i)/(v-b)+((2*sum(Yjaj)*ai(i)^0.5)/(R*b*T^1.5)(a*bi(i))/(R*b^2*T^1.5))*log(v/(v+b))-(a*bi(i))/(R*T^1.5*b*(v+b))-log((P*v)/(R*T)))
end
for i=1:NC
errorfi(i)=abs((fi(i)-fic(i))/fic(i))
end
errorf=sum(errorfi)
fi=fic
end
plot(Yi(1),T,'.')
hold on
X1=X1+0.01
end
```