0% found this document useful (0 votes)
20 views

Unifaq Laboratorio: 'Ingrese El Numero de Iteraciones N '

This MATLAB code simulates vapor-liquid equilibrium for a binary mixture using the UNIFAQ method. It takes in a number of iterations n, calculates vapor pressures and temperatures for ethanol and water using Antoine constants, estimates vapor and liquid phase compositions using activity coefficient models, and iterates to solve for the temperature that satisfies vapor-liquid equilibrium at a set pressure for varying mixture compositions. Graphs of composition vs vapor/liquid amounts and temperature are plotted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Unifaq Laboratorio: 'Ingrese El Numero de Iteraciones N '

This MATLAB code simulates vapor-liquid equilibrium for a binary mixture using the UNIFAQ method. It takes in a number of iterations n, calculates vapor pressures and temperatures for ethanol and water using Antoine constants, estimates vapor and liquid phase compositions using activity coefficient models, and iterates to solve for the temperature that satisfies vapor-liquid equilibrium at a set pressure for varying mixture compositions. Graphs of composition vs vapor/liquid amounts and temperature are plotted.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Unifaq laboratorio

clc,clear,clf
n=input('ingrese el numero de iteraciones n=');
x1=[linspace(0.0001,0.5,(8*n)/10)
linspace(0.50001,0.999999999,(2*n)/10)];
x2=ones(1,length(x1))-x1;
x11=0:0.1:1;
%CONSTANTES A,B,C DE ANTOINE
%ETANOL
A1=8.04494;B1=1554.3;C1=222.65;
%AGUA
A2=7.96681;B2=1668.21;C2=228;
%PRESION CONSTANTE
P=520;%mmHg
T1=B1/(A1-log10(P))-C1;
T2=B2/(A2-log10(P))-C2;
for k=1:n
syms T
Pvp1(k)=10^(A1-(B1/(C1+T)));
Pvp2(k)=10^(A2-(B2/(C2+T)));
x0=[x1(k) x2(k)];
T0=T+273.15;
R=[0.9011 0.6744 1 0.92];
Q=[0.848 0.540 1.20 1.4];
v1=[1 1 1 0 ];
v2=[0 0 0 1 ];
v=[v1;v2]';
a=[0 0 986.5 1318;0 0 986.5 1318;156.4 156.4 0 353.5;300 300 -229.4 0];
r=R*v;
q=Q*v;
fs=(x0.*r)/(sum(r.*x0));
fa=(x0.*q)/(sum(q.*x0));
z=10;
L=(z/2)*(r-q)-(r-1);
lngc=(log(fs./x0)+(z/2)*q.*log(fa./fs)+L-(fs./x0).*sum(L.*x0));
X1=v1./(sum(v1));
X2=v2./(sum(v2));
om1=(X1.*Q)./sum(X1.*Q);
om2=(X2.*Q)./sum(X2.*Q);
tmn=eval(exp(-a./T0));
for i=1:4
j=1;
while j <= 4
s1(j)=(om1(j)*tmn(i,j))./(sum(om1.*tmn(:,j)'));
s2(j)=(om2(j)*tmn(i,j))./(sum(om2.*tmn(:,j)'));
j=j+1;
end
lnr1(i)=Q(i)*(1-log(sum(om1.*tmn(:,i)'))-(sum(s1)));
lnr2(i)=Q(i)*(1-log(sum(om2.*tmn(:,i)'))-(sum(s2)));
end
V=[v1(1) v2(1) v1(2) v2(2) v1(3) v2(3) v1(4) v2(4)];
for i=1:4
X(i)=(x0(1)*v1(i)+x0(2)*v2(i))/(sum([x0 x0 x0 x0].*V));
end
for i=1:4
m0(i)=X(i)*Q(i)/(sum(X.*Q));
end
for i=1:4
j=1;
while j <= 4
s1(j)=(m0(j)*tmn(i,j))./sum(m0.*tmn(:,j)');
j=j+1;
end
lnrk(i)=Q(i)*(1-log(sum(m0.*tmn(:,i)'))-(sum(s1)));
end
lnR1=sum(v1.*(lnrk-lnr1));
lnR2=sum(v2.*(lnrk-lnr2));
lngr=[lnR1 lnR2];
lng=lngc+lngr;
g=exp(lng);
y1(k)=(x1(k)*Pvp1(k)*g(1)/P);
y2(k)=(x2(k)*Pvp2(k)*g(2)/P);
f=(y1(k)+y2(k))-1;
df=diff(f,T,1);
e=10^-6;d=1;
T=(T2+T1)/2;
while d > e
To=T-eval(f./df);
d=abs(eval(f));
T=To;
end
Tt(k)=T;
y1(k)=eval(y1(k));
y2(k)=eval(y2(k));
Pvp1(k)=eval(Pvp1(k));
Pvp2(k)=eval(Pvp2(k));
fprintf('%5.4f %8.4f %10.4f %8.4f %8.4f %8.4f %8.4f %8.4f
\n',x1(k),x2(k),Pvp1(k),Pvp2(k),Tt(k),y1(k),y2(k),y1(k)+y2(k))
end
subplot(1,2,1),plot(x1,y1,x11,x11,'-r'),xlabel('X1 ETANOL
(L)'),ylabel('Y1 ETANOL (V)'),title('DIAGRAMA X1 VS
Y1'),legend('UNIFAQ'),grid
subplot(1,2,2),plot(x1,Tt,'-g',y1,Tt,'-b'),xlabel('X1.Y1'),ylabel('T
ºC'),title('DIAGRAMA VS
X1.Y1'),legend('x1(Lìquido)UNIFAQ','y1(Vapor)UNIFAQ'),grid

You might also like