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

% Temperatura Definida e Constante: Function

This MATLAB code defines functions and variables to calculate vapor-liquid equilibrium using the Wilson and virial equation of state models. It reads in experimental composition (x1) and pressure (Pref) data from an Excel file. The LIQX function uses fsolve to calculate the equilibrium composition (Y) and pressure (P) given an input x1. Plots compare the calculated and experimental Y, P vs x1.

Uploaded by

Igor Souza
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

% Temperatura Definida e Constante: Function

This MATLAB code defines functions and variables to calculate vapor-liquid equilibrium using the Wilson and virial equation of state models. It reads in experimental composition (x1) and pressure (Pref) data from an Excel file. The LIQX function uses fsolve to calculate the equilibrium composition (Y) and pressure (P) given an input x1. Plots compare the calculated and experimental Y, P vs x1.

Uploaded by

Igor Souza
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

function [K]=Termo()

% Temperatura definida e constante


T=70+273.15;
%Constante dos Gases
R=83.14;
%Parametros Gerais
TC=[587 647.3]; % Em
PC=[52.1 221.2]; % Em bar
VC=[238 57.1]; % Em
ZC=[0.254 0.235]; % Em
Fac=[0.281 0.344]; % Em
VLsat=[85.71 18.07]; % Em
% Propriedades cruzadas(binario)
TCij=(TC(1)*TC(2))^0.5;
VCij=((VC(1)^(1/3)+VC(2)^(1/3))*(0.5))^3;
ZCij=(ZC(1)+ZC(2))/2;
Facij=(Fac(1)+Fac(2))/2;
PCij=(ZCij*R*TCij)/VCij;
%Parametros Wilson
lambda=[-30.2607 1676.626]; % Em cal/mol
for i=1:1:2
A(1)=(VLsat(1)/VLsat(2))*exp(-(lambda(1)/(R*T)));
A(2)=(VLsat(2)/VLsat(1))*exp(-(lambda(2)/(R*T)));
end
% Pressao de vapor
AntA=[7.43155 8.07131];
AntB=[1554.679 1730.630];
AntC=[240.337 233.426];
for i=1:1:2
Psat(i)=(10^(AntA(i)-AntB(i)/(T-273.15+AntC(i))))/750;
end
%Temperatura critica
TR(1)=T/TC(1);
TR(2)=T/TC(2);
TRij=T/TCij;
% Constantes B0, B1, B e Bij
for i=1:1:2
B0(i)=0.083-(0.172/(TR(i)^1.6));
B1(i)=0.139-(0.172/(TR(i)^4.2));
B(i)=(B0(i)+Fac(i)*B1(i))*TC(i)*R/PC(i);
end
B0ij=0.083-(0.172/(TRij^1.6));
B1ij=0.139-(0.172/(TRij^4.2));
Bij=(B0ij+Facij*B1ij)*TCij*R/PCij;
function YP=LIQX(X1)
function F =gp(yp)

% Fator de Pointing
FP1=exp((VLsat(1)*(yp(2)-Psat(1)))*(1/(R*T)));
FP2=exp((VLsat(2)*(yp(2)-Psat(2)))*(1/(R*T)));
% Wilson
Gama1=exp(-log(X1+A(1)*(1-X1))+(1-X1)*((A(1)/(X1+A(1)*(1-X1)))(A(2)/(A(2)*X1+(1-X1)))));
Gama2=exp(-log((1-X1)+A(2)*X1)-X1*((A(1)/(X1+A(1)*(1-X1)))-(A(2)/(A(2)*X1+(1X1)))));
%Equacao virial
phi1= exp(((yp(1)^2)*B(1)+((1-yp(1))^2)*B(2)+2*yp(1)*(1yp(1))*Bij)*(yp(2)/(R*T)));
phi2= exp((((1-yp(1))^2)*B(1)+((1-(1-yp(1)))^2)*B(2)+2*(1-yp(1))*(1-(1yp(1)))*Bij)*(yp(2)/(R*T)));
%Funcao objetiva
F(1)= Gama1*FP1*X1-phi1*yp(1)*yp(2);
F(2)= Gama2*FP2*(1-X1)-phi2*(1-yp(1))*yp(2);
end
%Solver
options = optimoptions('fsolve','Display','iter');
[YP,fval] = fsolve(@gp,[0.2,0.4],options);
end
% Lendo x
filename='martin.xlsx';
sheet=1;
xlRange='I14:I29';
x1=xlsread(filename,sheet,xlRange);
% Lendo y referencia
filename='martin.xlsx';
sheet=1;
xlRange='E13:E28';
Yref=xlsread(filename,sheet,xlRange);
% Lendo P referencia
filename='martin.xlsx';
sheet=1;
xlRange='C13:C28';
Pref=xlsread(filename,sheet,xlRange);
%Respostas
for i=1:1:16
K(i,:)=LIQX(x1(i));
Y(i)=K(i,1);
P(i)=K(i,2)*750;
end

subplot(2,2,1)
plot(x1,P,'-',Y,P,':','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSi
ze',4);
axis([0 1 200 800])
xlabel('X1,Y1')
ylabel('Pressao (bar)')
legend('P-X','P-Y')
subplot(2,2,2)
plot(x1,Pref,'-',Yref,Pref,':','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','r','Ma
rkerSize',4);
axis([0 1 200 800])
xlabel('X1,Y1')
ylabel('Pressao (bar)')
legend('P-X','P-Y')
subplot(2,2,3)
plot(x1,Y,'--k',x1,Yref,'-r','LineWidth',2);
axis([0 1 0 1])
xlabel('X1')
ylabel('Y1')
legend('X','Y')
end

You might also like