Professional Documents
Culture Documents
%*******************************************************
%The following lines are data to be inputted by the user
%Input Mole Fraction Compositions. Use a row vector only in the same
%order as propsRows.
zi = [.8168 .1501 .0331];
%Input temperature in K
T = 323.15; %K
%Input Pressure in MPa
P = .2; %MPa
%End of input parameters
%*******************************************************
%Calculate the sum of the matrix above to satisfy the sum on page 585
AMix = zi * Amat * zi';
%Calculate the B of mixing using formula on page 585
BMix = sum(zi .* B);
%Clear two matrices that will store the component fugacity coefficents and
%component fugacities. Each column is for a component, and each
%row is for a root.
compFugCo = [];
compFug = [];
%loop through each root
for i = 1:rootRegion
%calculate the component coefficients
compFugCoI = exp(B/BMix*(Z(i)-1)-ones(1,nComp)*log(Z(i)-BMix)-
AMix/BMix/2.8284*log((Z(i)+2.4142*BMix)/(Z(i)-.4142*BMix))*((2*zi*Amat)/AMix-
B/BMix));
%Use the coefficients to calculate the component fugacities
compFugI = P .* zi .* compFugCoI;
%Add the current calculations to the matrices storing all of the
%component fugacities and fugacity coefficients for the current root
compFugCo = [compFugCo; compFugCoI];
compFug = [compFug; compFugI];
end