Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

PROGRAMA UNIFAC

clc,clear,disp(' ')
disp(' Equilibrio Líquido - Vapor: etanol(1)-Agua(2) a 1 atm ')
disp(' ------------------------------------------------------ ')
%etanol
A=5.33675;B=1648.220;C=230.918;
%agua
A1=5.11564;B1=1687.537;C1=230.17;
syms T
x1=[0.01 0.02 0.04 0.06 0.08 0.1 0.15 0.2 0.25 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.95 0.999];
x2=1-x1;n=length(x1)
P=0.69;
%Determinación de las presiones de vapor
Pv1=10^(A-B/(T+C-273));Tb1=B/(A-log10(P))-C+273;
Pv2=10^((A1)-B1/(T+C1-273));Tb2=B1/(A1-log10(P))-C1+273;
%Determinación de los coeficientes de actividad en la fase líquida
disp(' Modelo termodinámico'),disp(' ')
%Determinación de las temperaturas de equilibrio
disp(' T ,ºC x1 x2 y1 Y2 Gama 1 Gama 2 yt');
disp(' -----------------------------------------------------------------------------')
for co = 1:n
x=[x1(co) x2(co)];
NSG=4;
Rk=[0.9011 0.6744 1.0000 0.9200];
Qk=[0.848 0.540 1.200 1.400];
v=[1 0;1 0;1 0;0 1];
a=[0 0 986.5 1318;0 0 986.5 1318;156.4 156.4 0 353.5;300.0 300.0 -229 0];
%Parte combinatorial
r=[0 0];q=r;
for i=1:2
for k=1:NSG
r(i)=v(k,i)*Rk(k)+r(i);
q(i)=v(k,i)*Qk(k)+q(i);
end
end
z=10;l=(z/2)*(r-q)-(r-[1 1]);
S1=0;S2=S1;S3=S2;
for i=1:2
S1=r(i)*x(i)+S1;
S2=q(i)*x(i)+S2;
S3=x(i)*l(i)+S3;
end
for i=1:2
phi(i)=r(i)*x(i)/S1;
theta(i)=q(i)*x(i)/S2;
LngC(i)=log(phi(i)/x(i))+(z/2)*q(i)*log(theta(i)/phi(i))+l(i)-phi(i)*S3/x(i);
end
% Parte Residual
for i=1:2
for k = 1:NSG
Xmi(k,i)=v(k,i)/sum(v(1:NSG,i));
end
end
for i=1:2
for k=1:NSG
Qmi(k,i)=Xmi(k,i)*Qk(k)/sum(Xmi(1:NSG,i)'.*Qk(1:NSG));
end
end
psi=exp(-a/T);
S=sym(zeros(1,NSG));Si=sym(zeros(NSG,2));
for c=1:2
for f=1:NSG
for i =1:NSG
S(i)=Qmi(i,c)*psi(f,i)/sum(Qmi(1:NSG,c).*psi(1:NSG,i))+S(i);
end
Si(f,c)=sum(S);
S=sym(zeros(1,NSG));
end
end
for i=1:2
for k=1:NSG
LnT(k,i)=Qk(k)*(1-log(sum(Qmi(1:NSG,i).*psi(1:NSG,k)))-Si(k,i));
end
end
Xm=v*x'/sum(v*x');
Qm=Xm.*Qk'/sum(Xm.*Qk');
S=sym(zeros(1,NSG));Si=sym(zeros(NSG,1));
for f=1:NSG
for i =1:NSG
S(i)=Qm(i)*psi(f,i)/sum(Qm(1:NSG).*psi(1:NSG,i))+S(i);
end
Si(f)=sum(S);
S=sym(zeros(1,NSG));
end
for k=1:NSG
LnTk(k)=Qk(k)*(1-log(sum(Qm(1:NSG).*psi(1:NSG,k)))-Si(k));
end
LngR=sym(zeros(1,2));
for i=1:2
for k=1:NSG
LngR(i)=LngR(i)+v(k,i)*(LnTk(k)-LnT(k,i));
end
end
gama(co,1:2)=exp(LngC+LngR);
% Determinación de la temperatura
y1(co)=x1(co)*gama(co,1)*Pv1/P;
y2(co)=x2(co)*gama(co,2)*Pv2/P;
end
for co=1:n
func(co)=y1(co)+y2(co)-1;
To=(Tb1+Tb2)/2;e=10^-4;distancia=1;
while distancia > e
dd=inline(func(co));fxi=dd(To);
derivada=diff(func(co),sym('T'));
aa=inline(derivada);Dxfxi=aa(To);
T_1=single(To-(fxi/Dxfxi));
distancia=single(abs(subs(func(co),sym('T'),T_1)));
To=T_1;
end
Tf(co)=T_1;t(co)=Tf(co);
Y1(co)=single(subs(y1(co),sym('T'),Tf(co)));
Y2(co)=single(subs(y2(co),sym('T'),Tf(co)));
G1(co)=single(subs(gama(co,1),Tf(co)));
G2(co)=single(subs(gama(co,2),Tf(co)));
Yt(co)=Y1(co)+Y2(co);
disp([t(co) x1(co) x2(co) Y1(co) Y2(co) G1(co) G2(co) Yt(co)])
end
subplot(1,2,1),plot(x1,Y1,'o')
axis([0 1 0 1],'square'),grid on,legend('L. Ref.','Puntos experimentales')
title('Diagrama de equilibrio etanol (1) - Agua (2) a 1 atm')
xlabel(' x, fracción molar de agua (líquido) ')
ylabel(' y, fracción molar de etanol (vapor) ')
subplot(1,2,2),plot(x1,t,'o',Y1,t,'ksquare')
grid on
legend('T-x exp.','T-y exp.')
title('Diagrama de fases etanol (1) - Agua (2) a 1 atm')
xlabel(' x,y fracción molar de etanol y el agua ')
ylabel(' T, ')

PROGRAMA WILSON:

clear all ,clc


syms T
disp('EQUILIBRIO LIQUIDO VAPOR EN UNA MEZCLA BINARIA ETANOL-AGUA');
disp('Sistema Isobarico:WILSON etanol - water')
X1=[0.0001,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];
X2=[0.9999,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1,0.0001];
a1=8.04494; a2=7.96681 ; %ingresar valor de VPA
b1=1554.3; b2=1668.21 ; %ingresar valor de VPB
c1=222.65; c2=228.0 ; %ingresar valor de VPC
v1=60.356;
v2=18.278;
d1=382.30;
d2=955.45;
disp(' La presion es constante 520 mmHg')
P=520; %El valor de la presion en mmHg
f1=10^(a1-b1/(c1+T));
f2=10^(a2-b2/(c2+T));
s=12;r=1;p=1;
while s>r
x1=X1(p);
x2=X2(p);
q=1;v=0;
tmin=50;
while v<0.997
T=tmin(q);
a12=(v2/v1)*exp(-(d1)/(1.987207*(T+273)));
a21=(v1/v2)*exp(-(d2)/(1.987207*(T+273)));
gam1=exp(-log(x1+a12*x2)+x2*(a12/(x1+a12*x2)-a21/(a21*x1+x2)));
gam2=exp(-log(x2+a21*x1)-x1*(a12/(x1+a12*x2)-a21/(a21*x1+x2)));
pvp1=eval(f1);
pvp2=eval(f2);
Y1(q+1)=x1*pvp1*gam1/P;
Y2(q+1)=x2*pvp2*gam2/P;
v(q+1)= Y1(q+1)+Y2(q+1);
tmin(q+1)=tmin(q)+0.05;
q=q+1;
end
t(p)=tmin(q);
y1(p)=Y1(q);
y2(p)=Y2(q);
p1(p)=pvp1;
p2(p)=pvp2;
u(p)=v(q);
g1(p)=gam1;
g2(p)=gam2;
r(p+1)=r(p)+1;
p=p+1;
end
disp(' x T pvp1 pvp2 P gamma1 gamma2 y1 y2
y1+y2')
for a=1:1:s-1;
fprintf('%0.1f %5.2f %5.3f %5.3f %5.1f %5.3f %5.3f %5.3f %5.3f
%5.2f\n',X1(a),t(a),p1(a),p2(a),P,g1(a),g2(a),y1(a),y2(a),u(a))
end
plot(X1,y1)
subplot(1,2,1),plot(X1,y1,'g',X1,y1,'r+',X1,X1,'k')
title('X1 vs Y1')
xlabel('X1')
ylabel('Y1')
subplot(1,2,2),plot(X1,t,'g',X1,t,'r+',y1,t,'k',y1,t,'b*')
title('X1,Y1 vs T')
xlabel('X1(*),Y1(+)')
ylabel('T')

You might also like