You are on page 1of 20

PPE-309L Process

Engineering
Computing Lab
2020 Fall-5th Semester
Instructor: Ms. Komal Naveed
Email id: komal.naveed@uet.edu.pk
Designation: Graduate assistant
University of Engineering and Technology Lahore
Solving equation of
state (EOS) for
multicomponent
systems using MATLAB
Example-Assignment 4-Q#1

• Consider the following mixture going into a water-gas shift reactor to make
hydrogen for the hydrogen economy. CO, 630; H2O, 1130; CO2, 189; H2, 63
kmol/h. The gas is at 1 atm and 500 K. Use MATLAB to compute the specific
volume using
• Ideal gas law
• Redlich–Kwong equation of state
• Redlich–Kwong–Soave equation of state.
Example-Assignment 4-Q#1

• The acentric factors for the RK–Soave method are: CO, 0.049; water, 0.344;
CO2, 0.225; Hydrogen, 0.22.
• Where did you get the other data you needed? How do the three answers
compare? Is the gas ideal or not? Comment. Then redo the calculations
for a pressure of 200atm and comment on the results.
Equations of state for pure components
Equations of state for Mixtures
Solution

• First, Put the values of molar flow rates, temperature, pressure and molar
masses in the m-file as follows
n=[630 1130 189 63]; %flow rates in kmol/h of CO,H2O,CO2&H2;
m=[28.01 18.01528 44.01 2.01588]; %molar masses of CO,H2O,CO2&H2;
T=500; %unit=K;
P=1; %unit=atm;
• Find the overall flow rate of the stream and print the result
Continue..

nt=n(1)+n(2)+n(3)+n(4) %overall flowrate;


fprintf('\n overall flow rate=%.1f\n',nt)
• To find the weight fraction of each component in the stream, divide the
individual flowrates to the total flowrate.
N=n./nt;
fprintf('\n n=%.4f for CO \n n=%.4f for H2O \n n=%.4f for CO2 \n n=%.4f for
H2\n',N)
Continue..

• Once the weight fraction of each component has found, molar mass of
the mixture can be calculated as follows.
Mmixture=N(1)*m(1)+N(2)*m(2)+N(3)*m(3)+N(4)*m(4);
fprintf('\n molar mass of mixture=%.4f\n',Mmixture)
• Put the values of accentric factors ‘a’ and Ideal gas constant ‘R’.
a=[0.049 0.344 0.225 0.22]; %accenteric factor of CO,H2O,CO2&H2;
R=0.08206; %unit=L.atm/K.mol;
Continue..

• The required values of critical temperature ‘Tc’ and critical pressure ‘Pc’ for all
components are reported in Chemical Engineering Thermodynamics by
J.M.Smith, H.C. Van Ness, and M.M. Abbott, 6th Edition, pg. no.632 and 633.
Reduced temperature can be calculated as:
Tc=[132.91 647 304.20 33.20]; % critical temp. in K for CO,H2O,CO2&H2;
Pc=[34.529 218 72.90 12.8]; % criticl pressure in atm for CO,H2O,CO2&H2;
Tr=T./Tc;
fprintf('\n Tr=%.4f for CO \n Tr=%.4f for H2O \n Tr=%.4f for CO2 \n Tr=%.4f for
H2\n',Tr)
Continue..

• After the addition of all given variables, find the specific volume of the
mixture by ideal gas
v=R*T/P % ideal gas equation;
videal=v/Mmixture;
fprintf('\n specific volume by ideal gas law=%.4f L/g\n',videal)
• Ideal gas equation can be used to calculate initial guess in fzero function.
Continue..

• Now calculate the specific volume of the mixture by Redlich Kwong Equation as
alpha=1./Tr.^0.5; %alpha for CO,H2O,CO2&H2;
fprintf('\n alpha=%.4f for CO \n alpha=%.4f for H2O \n alpha=%.4f for CO2 \n alpha=%.4f
for H2\n',alpha)
a1=0.42748*(R^2*Tc.^2./Pc); % constants for RK equation;
fprintf('\n a1=%.4f for CO \n a1=%.4f for H2O \n a1=%.4f for CO2 \n a1=%.4f for H2\n',a1)
b1=0.08664*(R*Tc./Pc); % constants for RK equation;
fprintf('\n b1=%.4f for CO \n b1=%.4f for H2O \n b1=%.4f for CO2 \n b1=%.4f for H2\n',b1)
Continue..

• For the multicomponent system, values of a and b can be calculated from


equations given in table 2.2
amixture=(N(1)*a1(1)^0.5+N(2)*a1(2)^0.5+N(3)*a1(3)^0.5+N(4)*a1(4)^0.5)^2;
fprintf('\n value of a for mixture of water and gas=%.4f\n',amixture)
bmixture=(N(1)*b1(1)+N(2)*b1(2)+N(3)*b1(3)+N(4)*b1(4));
fprintf('\n value of b for mixture of water and gas=%.4f\n',bmixture)
Continue..

• Then apply fzero and feval command to find the result


x=fzero(@(v)P*v^3-R*T*v^2+(amixture-P*bmixture^2-R*T*bmixture^2)*v-
amixture*bmixture,v); %RK equqtion;
fprintf('\n molar volume by RK equation=%.4f L/mol \n',x)
disp('applying feval for checking roots')
y=feval(@(v)P*v^3-R*T*v^2+(amixture-P*bmixture^2-R*T*bmixture^2)*v-
amixture*bmixture,x)
vRK=x/Mmixture
fprintf('\n specific volume by RK equation=%.4f L/g\n',vRK)
Continue..

• Follow the same procedure to find the specific volume of the system using SRK equation
• % by Redlich Kwong Soave equation;
m=0.480+1.574.*a-(0.176.*a.^2);
fprintf('\n m=%.4f for CO \n m=%.4f for H2O \n m=%.4f for CO2 \n m=%.4f for H2\n',m)
alpha2=(1+m.*(1-Tr.^0.5)).^2; % values of alpha by SRK equation;
fprintf('\n alpha2=%.4f for CO \n alpha2=%.4f for H2O \n alpha2=%.4f for CO2 \n alpha2=%.4f
for H2\n',m)
a2=0.42748*(R^2*Tc.^2./Pc).*alpha2; % values of a for SRK equation;
fprintf('\n a2=%.4f for CO \n a2=%.4f for H2O \n a2=%.4f for CO2 \n a2=%.4f for H2\n',a2)
disp('values of b are same as of RK equation')
a2mixture=(N(1)*a2(1)^0.5+N(2)*a2(2)^0.5+N(3)*a2(3)^0.5+N(4)*a2(4)^0.5)^2;
fprintf('\n value of a2 for mixture of water and gas=%.4f\n',a2mixture)
b2mixture=(N(1)*b1(1)+N(2)*b1(2)+N(3)*b1(3)+N(4)*b1(4));
fprintf('\n value of b for mixture of water and gas=%.4f\n',b2mixture)
x2=fzero(@(v) P*v^3-R*T*v^2+(a2mixture-P*b2mixture^2-R*T*b2mixture)*v-a2mixture*b2mixture,41.0300); %SRK
equation;
fprintf('\n molar v olume by SRK equation=%.4f L/mol \n',x)
disp('applying fev al for checking roots')
y2=feval(@(v) P*v^3-R*T*v^2+(a2mixture-P*b2mixture^2-R*T*b2mixture)*v-a2mixture*b2mixture,x2)
v SRK=x2/Mmixture;
fprintf('\n specific v olume by SRK equation=%.4f L/g\n',vSRK)
fprintf('\n specific v olume by ideal gas equation=%.4f L/g\n',videal)
fprintf('\n specific v olume by RK gas equation=%.4f L/g\n',vRK)
Overall M-file Commands
• %by ideal gas law;
• n=[630 1130 189 63]; %flow rates in kmol/h of CO,H2O,CO2&H2;
• m=[28.01 18.01528 44.01 2.01588]; %molar masses of CO,H2O,CO2&H2;
• T=500; %unit=K;
• P=1; %unit=atm;
• nt=n(1)+n(2)+n(3)+n(4) %overall flowrate;
• fprintf('\n overall flow rate=%.1f\n',nt)
• N=n./nt;
• fprintf('\n n=%.4f for CO \n n=%.4f for H2O \n n=%.4f for CO2 \n n=%.4f for H2\n',N)
• Mmixture=N(1)*m(1)+N(2)*m(2)+N(3)*m(3)+N(4)*m(4);
• fprintf('\n molar mass of mixture=%.4f\n',Mmixture)
• a=[0.049 0.344 0.225 0.22]; %accenteric factor of CO,H2O,CO2&H2;
• R=0.08206; %unit=L.atm/K.mol;
• Tc=[132.91 647 304.20 33.20]; % critical temp. in K for CO,H2O,CO2&H2;
• Pc=[34.529 218 72.90 12.8]; % criticl pressure in atm for CO,H2O,CO2&H2;
• Tr=T./Tc;
• fprintf('\n Tr=%.4f for CO \n Tr=%.4f for H2O \n Tr=%.4f for CO2 \n Tr=%.4f for H2\n',Tr)
• v =R*T/P % ideal gas equation;
• v ideal=v/Mmixture;
• fprintf('\n specific v olume by ideal gas law=%.4f L/g\n',videal)
• % By Redlich Kwong Equation;
• alpha=1./Tr.^0.5; %alpha for CO,H2O,CO2&H2;
• fprintf('\n alpha=%.4f for CO \n alpha=%.4f for H2O \n alpha=%.4f for CO2 \n alpha=%.4f for H2\n',alpha)
• a1=0.42748*(R^2*Tc.^2./Pc); % constants for RK equation;
• fprintf('\n a1=%.4f for CO \n a1=%.4f for H2O \n a1=%.4f for CO2 \n a1=%.4f for H2\n',a1)
• b1=0.08664*(R*Tc./Pc); % constants for RK equation;
• fprintf('\n b1=%.4f for CO \n b1=%.4f for H2O \n b1=%.4f for CO2 \n b1=%.4f for H2\n',b1)
• amixture=(N(1)*a1(1)^0.5+N(2)*a1(2)^0.5+N(3)*a1(3)^0.5+N(4)*a1(4)^0.5)^2;
• fprintf('\n value of a for mixture of water and gas=%.4f\n',amixture)
• bmixture=(N(1)*b1(1)+N(2)*b1(2)+N(3)*b1(3)+N(4)*b1(4));
• fprintf('\n value of b for mixture of water and gas=%.4f\n',bmixture)

• x=fzero(@(v)P*v^3-R*T*v^2+(amixture-P*bmixture^2-R*T *bmixture^2)*v -amixture*bmixture,v); %RK equqtion;

• fprintf('\n molar volume by RK equation=%.4f L/mol \n',x)

• disp('applying feval for checking roots')

• y=feval(@(v)P*v^3-R*T*v^2+(amixture-P*bmixture^2-R*T *bmixture^2)*v -amixture*bmixture,x)

• vRK=x/Mmixture
• fprintf('\n specific volume by RK equation=%.4f L/g\n',vRK)

• % by Redlich Kwong Soave equation;


• m=0.480+1.574.*a-(0.176.*a.^2);
• fprintf('\n m=%.4f for CO \n m=%.4f for H2O \n m=%.4f for CO2 \n m=%.4f for H2\n',m)

• alpha2=(1+m.*(1-Tr.^0.5)).^2; % values of alpha by SRK equation;

• fprintf('\n alpha2=%.4f for CO \n alpha2=%.4f for H2O \n alpha2=%.4f for CO2 \n alpha2=%.4f for H2\n',m)

• a2=0.42748*(R^2*Tc.^2./Pc).*alpha2; % values of a for SRK equation;


• fprintf('\n a2=%.4f for CO \n a2=%.4f for H2O \n a2=%.4f for CO2 \n a2=%.4f for H2\n',a2)
• disp('values of b are same as of RK equation')

• a2mixture=(N(1)*a2(1)^0.5+N(2)*a2(2)^0.5+N(3)*a2(3)^0.5+N(4)*a2(4)^0.5)^2;

• fprintf('\n value of a2 for mixture of water and gas=%.4f\n',a2mixture)


• b2mixture=(N(1)*b1(1)+N(2)*b1(2)+N(3)*b1(3)+N(4)*b1(4));
• fprintf('\n value of b for mixture of water and gas=%.4f\n',b2mixture)
• x2=fzero(@(v) P*v^3-R*T*v^2+(a2mixture-P*b2mixture^2-R*T*b2mixture)*v-
a2mixture*b2mixture,41.0300); %SRK equation;
• fprintf('\n molar volume by SRK equation=%.4f L/mol \n',x)
• disp('applying feval for checking roots')
• y2=feval(@(v) P*v^3-R*T*v^2+(a2mixture-P*b2mixture^2-R*T*b2mixture)*v-
a2mixture*b2mixture,x2)
• vSRK=x2/Mmixture;
• fprintf('\n specific volume by SRK equation=%.4f L/g\n',vSRK)
• fprintf('\n specific volume by ideal gas equation=%.4f L/g\n',videal)
• fprintf('\n specific volume by RK gas equation=%.4f L/g\n',vRK)

You might also like