Vous êtes sur la page 1sur 6

# Epsilon = ep

Sigma = sm

Omega = om

Otro = ps

The MATLAB function cubicEOSZ implements the cubic equation of state. This function uses
the built-in function fzero to estimate the compressibility factor and molar volume. A simple calling
syntax is
[Z V] = cubicEOSZ(state, eos, T, P, Tc, Pc, w)
Here, state denotes the state of the fluid: 'l' or 'L' when the fluid is liquid, 'l' or 'L' when the fluid is
vapor. eos is the equation of state being used: 'VDW' when the van der Waals equation is used, 'RK'
when the Redlich–Kwong equation is used, 'SRK' when the Soave–Redlich–Kwong equation is
used, and 'PR' when the Peng–Robinson equation is used (both capital and lowercase letters are permitted).
T and P are the temperature (K) and pressure (bar), respectively; Tc and Pc are the critical
temperature (K) and pressure (bar), respectively; and w is the acentric factor. Z and V are estimated
values of the compressibility factor and the molar volume (cm3/mol).

function [Z V] = cubicEOSZ(state,eos,T,P,Tc,Pc,w)
% Estimation of Z and V using cubic equations of state
% input
% state: fluid state (liquid: L, vapor: V)
% eos: type of equation being used (VDW, RK, SRK, PR)
% T,P: temperature (K) and pressure (bar)
% Tc,Pc: critical temperature (K) and pressure (bar)
% w: acentric factor
% Tr and Pr (reduced T and P)
Tr = T/Tc; Pr = P/Pc; R = 83.14; % cm^3*bar/mol/K
nc = length(w);
% set parameters
eos = upper(eos);
switch eos
case {'VDW'}
sm = 0; ep = 0; om = 0.125; ps = 0.42188; mx = [0];
case{'RK'}
ep = 0; sm = 1; om = 0.08664; ps = 0.42748;
al = 1./sqrt(Tr);
mx = (Tr.^(-1/4) - 1)./(1 - sqrt(Tr));
case{'SRK'}
ep = 0; sm = 1; om = 0.08664; ps = 0.42748;
al = (1+(0.48+1.574*w-0.176*w.^2).*(1-sqrt(Tr))).^2;
mc = [0.48 1.574 0.176];
mx = [ones(nc,1) w -w.^2]*mc';
case{'PR'}
ep = 1 - sqrt(2); sm = 1 + sqrt(2); om = 0.07780; ps = 0.45724;
mc = [0.37464 1.54226 0.26992];
mx = [ones(nc,1) w -w.^2]*mc';
end
% calculation of alpha, beta and q
al = (1 + mx.*(1-sqrt(Tr))).^2;
beta = om*Pr./Tr; q = ps*al./(om*Tr);

## Example 4.3: Molar Volume of n-Butane7

Determine the molar volumes of saturated vapor and saturated liquid n-butane using the cubic
equations of state (the van der Waals equation, the Redlich–Kwong equation, the Soave–Redlich–
Kwong equation, and the Peng–Robinson equation). For n-butane, the vapor pressure at 350 K is
9.4573 bar, Tc = 425.1 K, Pc = 37.96 bar, and w = 0.2.
Solution
The following commands show the calculation procedure for the saturated vapor using the van
der Waals equation:
>> T=350; P=9.4573; Tc=425.1; Pc=37.96; w=0.2;
>> state ='v'; eos = 'vdw';
>> [Z V] = cubicEOSZ(state,eos,T,P,Tc,Pc,w)
Z=
0.8667
V=
2.6669e+03
The calculation procedure for the saturated liquid using the Redlich–Kwong equation is as follows:
>> state = 'L'; eos = 'rk';
>> [Z V] = cubicEOSZ(state,eos,T,P,Tc,Pc,w)
Z=
0.0433
V=
133.2663
Results of calculations for each equation of state are summarized in Table 4.3.
1

## Teniendo en cuenta que

The MATLAB function phimix estimates the fugacity coefficients of all components in a mixture
from cubic equations of state. This function has the syntax

[Z,V,phi] = phimix(ni,P,T,Pc,Tc,w,k,state,eos)
where ni is the number of moles (or mole fractions) of each component in a mixture (vector), P is
the pressure (Pa), T is the temperature (K), w is the acentric factor, k is a matrix of binary
interaction
parameters, state denotes the state of the fluid ('L': liquid, 'V': vapor), eos is the equation of state
being used ('RK', 'SRK', or 'PR'), Z is the compressibility factor, V is the molar volume, and phi is
the fugacity coefficients of all components (vector).

## function [Z,V,phi] = phimix(ni,P,T,Pc,Tc,w,k,state,eos)

% Estimates fugacity coefficients of all components in a mixture using
% the cubic equation of state
% Inputs:
% ni: number of moles (or mole fractions) of each component (vector)
% P, T: pressure(Pa) and temperature(K)
% Pc, Tc: critical P(Pa) and T(K) of all components (vector)
% w: acentric factors of all components (vector)
% k: symmetric matrix of binary interaction parameters (n x n)
% state: fluid state('L': liquid, 'V': vapor)
% eos: equation of state('RK', 'SRK', or 'PR')
% Outputs:
% V: molar volume (m3/mol)
% Z: compressibility factor
% phi: fugacity coefficient vector
ni = ni(:); Pc = Pc(:); Tc = Tc(:); w = w(:); % column vector
x = ni/sum(ni); % mole fraction
R = 8.314; % gas constant: m^3 Pa/(mol K) = J/mol-K
Tref = 298.15; % reference T(K)
Pref = 1e5; % reference P(Pa)
Tr = T./Tc;
eos = upper(eos); state = upper(state);
switch eos
case{'RK'}
ep = 0; sm = 1; om = 0.08664; ps = 0.42748;
al = 1./sqrt(Tr);
case{'SRK'}
ep = 0; sm = 1; om = 0.08664; ps = 0.42748;
al = (1+(0.48+1.574*w-0.176*w.^2).*(1-sqrt(Tr))).^2;
case{'PR'}
ep = 1 - sqrt(2); sm = 1 + sqrt(2); om = 0.07780; ps = 0.45724;
al = (1+(0.37464+1.54226*w-0.26992*w.^2).*(1-sqrt(Tr))).^2;
end
ai = ps*(R^2).*al.*(Tc.^2)./Pc; am = sqrt(ai*ai').*(1 - k); % nxn matrix
a = x'*am*x; bi = om*R*Tc./Pc; b = x'*bi;
beta = b*P/R/T; q = a/(b*R*T);
% compressibility factor(Z) and molar volume (V)
state = upper(state);
c(1) = 1;
c(2) = (sm +ep)*beta - (1+beta);
c(3) = beta*(q + ep*sm*beta -(1+beta)*(sm+ep));
c(4) = -beta^2*(q +(1+beta)*ep*sm);

% Roots
Z = roots(c);
iz = abs(imag(Z)); Z(and(iz>0,iz<=1e-6)) = real(Z(and(iz>0,iz<=1e-6)));
for i = 1:length(Z), zind(i) = isreal(Z(i)); end
Z = Z(zind);
if state == 'L'
Z = min(Z);
else
Z = max(Z);
end
V = R*T*Z/P;
% fugacity coefficients
bara = (2*ni'*am - a*ones(1,length(ni)))'; barb = bi;
phi = exp((Z - 1)*barb/b - log((V - b)*Z/V) + (a/(b*R*T))/(ep – sm)*...
log((V + sm*b)/(V + ep*b))*(1 + bara/a - barb/b));
end