You are on page 1of 2

ASSIGNMENT QUESTION:

The stream in Table 1 is at 100 psia and 178◦F. Calculate the fraction that is vapor by
solving the Rachford–Rice equation using MATLAB.

SOLUTION:
STEPS:
 Create an M-File and save it as “vpequil.m”.
 Store all the data and write the equations to find the liquid and vapor fractions.
 Run the M-File and answers will be displayed in the command window.
MATLAB CODE:
M-File: vpequil.m
%Input stream containing Propane,n-Butane and n-Pentane at 100psia and 178
degree fahrenheit
%calculation of vapor-fraction by solving Rachford-Rice equation
%Basis: 100 lb mol
n = [20 30 50] %molar flow rates of Propane,n-Butane,n-Pentane
nt = n(1)+n(2)+n(3); %total molar flow rate
z1 = n(1)/nt; %mole-fraction of Propane
z2 = n(2)/nt; %mole-fraction of n-Butane
z3 = n(3)/nt; %mole-fraction of n-Pentane
z = [n(1)/nt + n(2)/nt + n(3)/nt]; %sum of mole-fractions
fprintf('\n z1 for Propane =%.2f \n z2 for n-Butane =%.3f \n z3 for n-Pentane
=%.2f \n', z1,z2,z3)
K1 = 3.7; %K-value for Propane
K2 = 1.4; %K-value for n-Butane
K3 = 0.6; %K-value for n-Pentane
fprintf('\n K1 for Propane =%.2f \n K2 for n-Butane =%.3f \n K3 for n-Pentane
=%.2f \n', K1,K2,K3)
%xi = zi/(1+(Ki-1)*v)formula to find the liquid-fraction
vo = 0.7; %initial guess
V = fzero(@(v)(K1-1)*z1/(1+(K1-1)*v)+ (K2-1)*z2/(1+(K2-1)*v)+ (K3-1)*z3/(1+
(K3-1)*v),vo)
x1 = feval(@(v)z1/(1+(K1-1)*v),V) %liquid-fraction of Propane
x2 = feval(@(v)z2/(1+(K2-1)*v),V) %liquid-fraction of n-Butane
x3 = feval(@(v)z3/(1+(K3-1)*v),V) %liquid-fraction of n-Pentane
fprintf('\n x1 for Propane =%.2f \n x2 for n-Butane =%.3f \n x3 for n-Pentane
=%.2f \n', x1,x2,x3)
%yi = xi*Ki formula to find the vapor-fraction
x = x1+x2+x3 %total liquid-fraction
y1 = x1*K1;
y2 = x2*K2;
y3 = x3*K3;
fprintf('\n y1 for Propane =%.2f \n y2 for n-Butane =%.3f \n y3 for n-Pentane
=%.2f \n', y1,y2,y3)
y = y1+y2+y3 %total vapor-fraction

You might also like