clear all % equilibrio liquido liquido isopropil/propanol/glicerol NC=3 gij=[0 9862.2 51.9; 9248.1 0 2395.7; 1259.2 2457.2 0]% J/molK se leyeron aij=[0 0.3 0.3; 0.3 0 0.3; 0.3 0.3 0] % alfa estas se leyeron del archivo R=8.314 % J/molK T=298.15 %K Zi=[0.157 0.558 0.265] valores que estén en tabla, donde beta no sea cero Ki=[80 0.02 2] % supuesto para corregir errorK=10 while errorK >0.0001 LF=0.5 % supuesto para corregir errorLF=10 while errorLF > 0.0001 % plantear ecuación de equilibrio igualada a f(i) sin derivar for i =1 :NC Fi(i)=(Zi(i)*(Ki(i)-1))/((Ki(i)-1)*LF+1) end F=sum(Fi) % plantear ecuación de equilibrio igualada a f(i) DERIVADA for i =1 :NC dFi(i)=-(Zi(i)*(Ki(i)-1)^2)/((Ki(i)-1)*LF+1)^2 end dF=sum(dFi) LFc=LF-F/dF se calcula LF paras luego corregir errorLF= abs((LF-LFc)/LFc) LF=LFc end se tiene un LF corregfido para un k malo---corregir k for i= 1:NC xia(i)=(Zi(i)*Ki(i))/((Ki(i)-1)*LF+1) se pone minúscula para normalizar luego xib(i)=(Zi(i))/((Ki(i)-1)*LF+1) hay una x para cada compuesto Alpha/beta end for i=1:NC Xia(i)=xia(i)/sum(xia) normalización Xib(i)=xib(i)/sum(xib) end %Parametros de interaccion se calcula normal con NRTL for i =1 :NC for j=1:NC Tij(i,j)= gij(i,j)/(R*T) Gij(i,j)= exp(-aij(i,j)*Tij(i,j)) end end for i =1: NC for j =1: NC TjiGjiXj(j)=Tij(j,i)*Gij(j,i)*Xia(j) for k=1: NC GkjXk(k)=Gij(k,j)*Xia(k) TkjGkjXk(k)=Tij(k,j)*Gij(k,j)*Xia(k) GkiXk(k)=Gij(k,i)*Xia(k) end sumatoria(j)=(Xia(j)*Gij(i,j)/sum(GkjXk))*(Tij(i,j)-(sum(TkjGkjXk)/sum(GkjXk))) gia(i)=exp((sum(TjiGjiXj)/sum(GkiXk)+sum(sumatoria))) end end for i =1: NC for j =1: NC TjiGjiXj(j)=Tij(j,i)*Gij(j,i)*Xib(j) for k=1: NC GkjXk(k)=Gij(k,j)*Xib(k) TkjGkjXk(k)=Tij(k,j)*Gij(k,j)*Xib(k) GkiXk(k)=Gij(k,i)*Xib(k) end sumatoria(j)=(Xib(j)*Gij(i,j)/sum(GkjXk))*(Tij(i,j)-(sum(TkjGkjXk)/sum(GkjXk))) gib(i)=exp((sum(TjiGjiXj)/sum(GkiXk)+sum(sumatoria))) end end for i=1:NC Kic(i)=gib(i)/gia(i) end se calcula la k para compararla for i=1:NC errorKi(i)= abs((Ki(i)-Kic(i))/Kic(i)) end errorK=sum(errorKi) Ki=Kic end xx=[0 0.5] yy=[0 (3/4)^0.5] plot(xx,yy) hold on xx=[0.5 1] yy=[(3/4)^0.5 0] plot(xx,yy) hold on xxa=Xia(1)+0.5*Xia(3) yya=Xia(3)*(3/4)^0.5 xxb=Xib(1)+0.5*Xib(3) yyb=Xib(3)*(3/4)^0.5 xx=[xxa xxb] yy=[yya yyb] plot(xx,yy) hold on