0% found this document useful (0 votes)
99 views7 pages

Code Ponchon

This document contains MATLAB code for modeling the equilibrium behavior of a distillation column. It defines functions for vapor-liquid equilibrium calculations and calculates temperature, composition, enthalpy, and other properties at each stage of the column. Plots are generated showing the equilibrium curves, enthalpy vs. composition, and column profiles. The code models various stages of the distillation process including enrichment, feed, and product sections.

Uploaded by

victor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views7 pages

Code Ponchon

This document contains MATLAB code for modeling the equilibrium behavior of a distillation column. It defines functions for vapor-liquid equilibrium calculations and calculates temperature, composition, enthalpy, and other properties at each stage of the column. Plots are generated showing the equilibrium curves, enthalpy vs. composition, and column profiles. The code models various stages of the distillation process including enrichment, feed, and product sections.

Uploaded by

victor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

3/31/19 8:16 PM C:\Users\saul\Desktop\P_S.

m 1 of 7

clc
clear
%metil etilcetona/tolueno
%Aa=[14.1334,13.932];Ba=[2838.24,3056.96];Ca=[218.69,217.625];
%Acl=[];Bcl=[];Ccl=[];
%Acv=[];Bcv=[];Ccv=[];
%A=[0.372,0.198];
%L=[];

%Metanol/Agua
%Aa=[,16.3872];Ba=[,3885.7];Ca=[,230.17];
%Acl=[,8.712];Bcl=[,1.25];Ccl=[,-0.18];
%Acv=[,3.470];Bcv=[,1.450];Ccv=[,0];
%L=[,40660];
%A=[,0.7947];

%Benceno/Tolueno
% Aa=[13.7819,13.932];Ba=[2726.81,3056.96];Ca=[217.572,217.625];
% Acl=[-0.757,15.311];Bcl=[67.96,6.79];Ccl=[-37.78,16.35];
% Acv=[-0.206,0.29];Bcv=[39.064,47.052];Ccv=[-13.301,-15.716];
% A=[1,1];
% L=[30820,33330];

%Etanol/Agua
Aa=[16.8958,16.3872];Ba=[3795.17,3885.7];Ca=[230.918,230.17];
Acl=[33.866,8.712];Bcl=[-172.60,1.25];Ccl=[349.17,-0.18];
Acv=[3.518,3.470];Bcv=[20.001,1.450];Ccv=[-6.002,0];
L=[38560,40660];
A=[1.6022,0.7947];

i=1;

%Datos
P=101.325;
xd=0.8;
xf=0.4;
xw=0.1;
q=0.6;
F=200;
R=2;
D=69.76;

L0=R*D;
V1=D+L0;
W=F-D;

%Funciones
Fpt=@(t) exp(Aa-Ba./(Ca+t));
Ftp=@(p) Ba./(Aa-log(p))-Ca;
Fca=@(x) [exp((1-x)^2*(A(1)+2*(A(2)-A(1))*x)),exp(x^2*(A(2)+2*(A(1)-A(2))*(1-x)))];
3/31/19 8:16 PM C:\Users\saul\Desktop\P_S.m 2 of 7

Fcpl=@(t1,t2) (Acl+Bcl*1e-3.*([t1,t2]+273.15)+Ccl*1e-6.*([t1,t2]+273.15).^2)*8.314;
Fcpv=@(t1,t2) (Acv+Bcv*1e-3.*([t1,t2]+273.15)+Ccv*1e-6.*([t1,t2]+273.15).^2)*8.314;

Ti=Ftp(P);

%Temperaturas de saturacion
for x=0:0.001:1
T1=mean(Ti);
T2=T1+1;
g=Fca(x);
%g=[1,1];
while abs(T1-T2)>1e-5
Ps=Fpt(T1);
a=Ps(1)/Ps(2);
Ps(2)=P/(a*x*g(1)+(1-x)*g(2));
T2=T1;
Tm=Ftp(Ps(2));
T1=Tm(2);
end
T(i)=T1;
Y(i)=1-((1-x)*Ps(2)*g(2))/P;
X(i)=x;
i=i+1;
end

%Calculo de entalpia
CpL=Fcpl(T(1),T(end));
CpV=Fcpv(T(1),T(end));
L1=L(1);
L2=CpL(2)*(T(1)-T(end))+L(2)-CpV(2)*(T(1)-T(end));
h=X.*CpL(1).*(T-T(end))+(1-X).*CpL(2).*(T-T(end));
H=Y.*(L1+CpV(1)*(T-T(end)))+(1-Y).*(L2+CpV(2)*(T-T(end)));

%entalpia de entradas y salidas


k0=0;k2=0;k3=0;k9=0;
s1=2;s2=1;
while s1>abs(s2)
k0=k0+1;
s1=xf-X(k0);
s2=xf-X(k0+1);
end
s1=2;s2=1;
while s1>abs(s2)
k2=k2+1;
s1=xd-X(k2);
s2=xd-X(k2+1);
end
s1=2;s2=1;
while s1>abs(s2)
k3=k3+1;
s1=xd-Y(k3);
3/31/19 8:16 PM C:\Users\saul\Desktop\P_S.m 3 of 7

s2=xd-Y(k3+1);
end
s1=2;s2=1;
while s1>abs(s2)
k9=k9+1;
s1=xw-X(k9);
s2=xw-X(k9+1);
end
hf=h(k0);
hd=h(k2);
H1=H(k3);
hw=h(k9);
qc=H1*V1-L0*hd-D*hd;

%Enriquesimiento
i=1;
for x=xf-0.15:0.01:xd
k1=0;
l1=L0;v1=V1;v2=v1+1;
s1=2;s2=1; %K1
while s1>abs(s2)
k1=k1+1;
s1=x-X(k1);
s2=x-X(k1+1);
end
hn=h(k1);
while abs(v1-v2)>1e-2
y=l1/v1*x+(xd*D)/v1;
s1=2;s2=1;k4=1;
while s1>abs(s2)
k4=k4+1;
s1=y-Y(k4-1);
s2=y-Y(k4);
end
Hn1=H(k4);
v2=v1;
v1=(V1*H1-hn*D-L0*hd)/(Hn1-hn);
l1=v1-D;
end
Ln(i)=l1;
Vn1(i)=v1;
Xer(i)=x;
Yer(i)=y;
her(i)=hn;
Her(i)=Hn1;
i=i+1;
end

%L.Alimentacion
i=1;
z1=0;z2=1;x=xf;y=xf;
3/31/19 8:16 PM C:\Users\saul\Desktop\P_S.m 4 of 7

Xf(i)=xf;Yf(i)=xf;
while x<1 & y<1 & x>0.01 & y>0.01
if q==0
x=x-0.01;
y=xf;
elseif q<1
x=x-0.01;
y=q/(q-1)*x-xf/(q-1);
elseif q==1
x=xf;
y=y+0.01;
else
x=x+0.01;
y=q/(q-1)*x-xf/(q-1);
end
i=i+1;
Xf(i)=x;
Yf(i)=y;
end

%Inicio del emp


z1=0;z2=1;x=xf;
while z2-z1>0
s1=2;s2=1;k7=0;
while abs(s1)>abs(s2)
k7=k7+1;
s1=x-Xer(k7);
s2=x-Xer(k7+1);
end
s1=2;s2=1;k71=0;
while abs(s1)>abs(s2)
k71=k71+1;
s1=x-Xf(k71);
s2=x-Xf(k71+1);
end
if q==0
x=x-0.01;
elseif q<1
x=x-0.01;
elseif q==1
z1=Y(k7);
else
x=x+0.01;
end
z2=Yer(k7);
z1=Yf(k71);
end

%Empobresimiento
lm=Ln(k7)+q*F;
vm=Vn1(k7)-(1-q)*F;
3/31/19 8:16 PM C:\Users\saul\Desktop\P_S.m 5 of 7

qr=W*hw+D*hd+qc-F*hf;
i=1;
for x=xw:0.01:xf
k1=0;l1=lm;v1=vm;v2=v1+1;
s1=2;s2=1;
while s1>abs(s2)
k1=k1+1;
s1=x-X(k1);
s2=x-X(k1+1);
end
hn=h(k1);
while abs(v1-v2)>2e-1
y=l1/v1*x-(xw*W)/v1;
s1=2;s2=1;k4=0;
while abs(s1)>abs(s2)
k4=k4+1;
s1=y-Y(k4);
s2=y-Y(k4+1);
end
Hn1=H(k4);
v2=v1;
v1=(W*hn-W*hw+qr)/(Hn1-hn);
l1=v1+W;
end
Lm(i)=l1;
Vm1(i)=v1;
Xem(i)=x;
hem(i)=hn;
Yem(i)=y;
Hem(i)=Hn1;
i=i+1;
end

%Composicion Critica
z1=0;z2=1;x=xf;
while z2-z1>0
s1=2;s2=1;k8=0;
while abs(s1)>abs(s2)
k8=k8+1;
s1=x-X(k8);
s2=x-X(k8+1);
end
if q==0
z1=xf;
x=x-0.01;
elseif q<1
z1=q/(q-1)*x-xf/(q-1);
x=x-0.01;
elseif q==1
z1=Y(k8);
else
3/31/19 8:16 PM C:\Users\saul\Desktop\P_S.m 6 of 7

z1=q/(q-1)*x-xf/(q-1);
x=x+0.01;
end
z2=Y(k8);
end

%Platos
i=2;
Yp=xd;
Xp=xd;
while Xp(end)-X(k8)>0
s1=2;s2=1;k5=0;
while abs(s1)>abs(s2)
k5=k5+1;
s1=Yp(end)-Y(k5);
s2=Yp(end)-Y(k5+1);
end
Yp(i)=Yp(end);
Xp(i)=X(k5);
i=i+1;
if Yp(end)>Y(k8)
s1=2;s2=1;k6=0;
while s1>abs(s2)
k6=k6+1;
s1=X(k5)-Xer(k6);
s2=X(k5)-Xer(k6+1);
end
Yp(i)=Yer(k6);
Xp(i)=X(k5);
i=i+1;
end

end

while Xp(end)-xw>0
s1=2;s2=1;k5=0;
while s1>abs(s2)
k5=k5+1;
s1=Yp(end)-Y(k5);
s2=Yp(end)-Y(k5+1);
end
Yp(i)=Yp(end);
Xp(i)=X(k5);
i=i+1;
if Xp(end)>xw
s1=2;s2=1;k6=1;
while s1>abs(s2)
k6=k6+1;
s1=X(k5)-Xem(k6-1);
s2=X(k5)-Xem(k6);
end
3/31/19 8:16 PM C:\Users\saul\Desktop\P_S.m 7 of 7

end
Yp(i)=Yem(k6);
Xp(i)=X(k5);
i=i+1;
end

figure(1)
plot(X,Y,X,X,'k',Xer,Yer,Xf,Yf,Xem,Yem,Xp,Yp)
set(gca,'XTick',(0:0.05:2)),set(gca,'YTick',(0:0.05:2))
grid on

figure(2)
% hold on
% for j=1:5:size(Xer,2)
% as1=[Xer(j),Yer(j)];
% as2=[her(j),Her(j)];
% plot(as1,as2,'k')
% end
% hold off
plot(X,h,Y,H),axis([0,1,-10000,70000])
set(gca,'XTick',(0:0.05:2)),set(gca,'YTick',(-5e4:2.5e3:1e6))
title("H vs X1/Y1"),xlabel("X/Y"),ylabel("H(J)")
grid on

% figure(3)
% subplot(2,2,[1,2])
% plot(X,h,Y,H)

% hold on
% for j=1:5:size(X,2)
% as1=[X(j),Y(j)];
% as2=[h(j),H(j)];
% plot(as1,as2,'k')
% end
% hold off
% subplot(2,2,[3,4])
% plot(X,Y,X,X,'k')

You might also like