Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you correct this code on matlab and compleat the code to find pressure saturation and fugacity liquid and fugacity for vapor when philiq equal

can you correct this code on matlab and compleat the code to find pressure saturation and fugacity liquid and fugacity for vapor when philiq equal phivap for each tempretaure.(Tc =658.3; % Critical temperature in K
Pc =1.817e6; % Critical pressure in Pa
omega =0.562; % Acentric factor
% Universal gas constant
R =8.314; % J/(mol K)
b =0.07780* R * Tc / Pc;
kappa =0.37464+1.54226* omega -0.26992* omega^2;
% Reduced temperatures
Tr =[0.7,0.8,0.9,1.0];
%loop
for i=1:length(T)
T=Tr(i);
Tr= T / Tc;
alpha =(1+ kappa *(1- sqrt(T / Tc)))^2;
a =0.45724* R^2* Tc^2/ Pc * alpha;
%initial guess for psat (pa)
if Tr ==0.7
psat=48418;
end
if Tr==0.8
psat=227470;
end
if Tr==0.9
psat=711240;
end
if Tr==1
psat =1704911;
end
tolerance =1e-4;
error=0;
while error < tolerance
%solve
A= a*psat/(R * T)^2;
B = b*psat /(R * T);
coeffs =[1,-1+B, A-(2*B)-(3*B^2),-(A*B)+(B^2)+(B^3)];
z=roots(coeffs);
z=real (z(imag(z)==0)); %keep one real root
z_min = min(z);
z_max = max(z);
%calculate fugacity coefficient
philiq = exp((z_min-1)-log(z_min-B)-(A/(2*sqrt(2)*B))*log((z_min+(1+sqrt(2))*B)/(z_min+(1-sqrt(2))*B)));
phivap = exp((z_max-1)-log(z_max-B)-(A/(2*sqrt(2)*B))*log((z_max+(1+sqrt(2))*B)/(z_max+(1-sqrt(2))*B)));
%calculate psat new
psatnew = psat*(philiq/phivap);
error = abs((philiq/phivap)-1);
psat= psatnew ;
end
end
%calculate volumes
Vliq = z_min*R*T/psat;
Vvap = z_max*R*T/psat;)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Chemical Engineering Thermodynamics

Authors: Hendrick C. Ness, H.C.Van, Van Ness

4th International Edition

0071003037, 978-0071003032

More Books

Students also viewed these Chemical Engineering questions

Question

10:16 AM Sun Jan 29 Answered: 1 week ago

Answered: 1 week ago