0% found this document useful (0 votes)
48 views2 pages

Final Thermo Code

This MATLAB code analyzes thermodynamic properties for a two-component system. It calculates activity coefficients and Gibbs energy for given mole fractions and pressures at 79.8°C. Curve fitting is used to predict values at 90°C. Graphs are generated comparing measured and predicted pressure-composition data at both temperatures.

Uploaded by

api-302257258
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)
48 views2 pages

Final Thermo Code

This MATLAB code analyzes thermodynamic properties for a two-component system. It calculates activity coefficients and Gibbs energy for given mole fractions and pressures at 79.8°C. Curve fitting is used to predict values at 90°C. Graphs are generated comparing measured and predicted pressure-composition data at both temperatures.

Uploaded by

api-302257258
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

Thermodynamics MATLAB Code

clear;
clc;
T=79.80;
X1=[0 0.0856 0.1558 0.3012 0.4114 0.4202 0.4287 0.5782 0.5556 0.7390
0.8201 1]';
Y1=[0 0.3542 0.3765 0.4060 0.4201 0.4234 0.4287 0.4376 0.4642 0.5649
0.6428 1]';
X2=(1-X1);
Y2=(1-Y1);
A1=8.37895;
A2=8.07131;
B1=1788.020;
B2=1730.630;
C1=227.438;
C2=233.426;
Psat1=(10^(A1-(B1/(T+C1))));
Psat2=(10^(A2-(B2/(T+C2))));
P=[352.6 530 539.6 547 548.1 548.5 549.7 545.7 541.7 506.6 479.2 374.6]';
%calculating gammas and gibbs energy at each pressure and concentration
for i=[1:12]
gamma1(i)=((Y1(i)*P(i))/(X1(i)*Psat1));
gamma2(i)=((Y2(i)*P(i))/(X2(i)*Psat2));
Gibbs(i)=(X1(i)*log(gamma1(i))+X2(i)*log(gamma2(i)));
%Two Parameter values from curve fitting
A21=1.032;
A12=2.375;
end
T2=90;
newPsat1=(10^(A1-(B1/(T2+C1))));
newPsat2=(10^(A2-(B2/(T2+C2))));
newX1=[0:.01:1]';
newX2=1-newX1;
l=length(newX1);
%calculating new gammas and predicted pressures at each respective mol frac
for j=1:l
new_gamma1(j)=exp((newX2(j)*newX2(j)*(A12+((2*(A21-A12))*newX1(j)))));

new_gamma2(j)=exp((newX1(j)*newX1(j)*(A21+((2*(A12-A21))*newX2(j)))));
PredP1(j)=((new_gamma1(j)*newX1(j)*Psat1)+
(new_gamma2(j)*newX2(j)*Psat2));
PredP2(j)=((new_gamma1(j)*newX1(j)*newPsat1)+
(new_gamma2(j)*newX2(j)*newPsat2));
newY1(j)=((new_gamma1(j)*newX1(j)*Psat1)/PredP1(j));
newY12(j)=((new_gamma1(j)*newX1(j)*newPsat1)/PredP2(j));
end
%graphing predicted pxy diagram at 90 degC
plot(newX1,PredP2,'b')
hold on
plot(newY12,PredP2,'c')
ylabel('Pressure [mm Hg]')
xlabel('X1 Y1 @90 degC')
legend('Liquid', 'Vapor')
title('P-XY at T=90 degC')
%graphing pxy diagram at 79.8 degC
figure
plot(X1, P, '*', Y1, P, '*', newX1, PredP1, 'r', newY1, PredP1, 'g')
ylabel('Pressure [mm Hg]')
xlabel('X1 Y1 @79.8 degC')
legend('Liquid', 'Vapor', 'Predicted Liquid', 'Predicted Vapor')
title('P-XY at T=79.80 degC')

You might also like