Calculation of Densities From Cubic Equations Of

download Calculation of Densities From Cubic Equations Of

of 5

description

articulo

Transcript of Calculation of Densities From Cubic Equations Of

  • Calculation of Densities from Cubic Equations ofState

    Ulrich K. DeitersInstitute of Physical Chemistry, University at Cologne, D-50939 Koln, Germany

    Some cubic equations of state can eentually hae unphysical solutions for the molarolume. The conditions for this phenomenon are discussed. The computational accu-

    (racy and computing time requirements of the analytical root finding method Cardano's)formula are inestigated. A new, faster iteratie root finder for cubic polynomials is

    proposed.

    Introduction

    In spite of their theoretical shortcomings, cubic equationsof state are still frequently used in many chemical and engi-neering applications. This is partly due to the fact that theseequations can be transformed into cubic polynomials with re-spect to the molar volume.

    This reducibility to a cubic polynomial is by no means re-quired by physical insight, but by mathematical convenience:the calculation of the density or the molar volume from thegiven pressure and temperature, which is one of the mostfrequently performed operations in phase equilibrium calcu-lations, can be done for these equations by Cardano's for-mula. Its application does not require iteration or predeter-mined initial values, and if more than one solution is possi-ble, it yields all of them. It is easy to program, fail-safe, andfast.

    Usually the solution with the highest density if there is.more than one is associated with the liquid phase, the one

    with the lowest density with the vapor phase, and thus theroad to the calculation of phase equilibria seems clear. It willbe shown, however, that there are pitfalls along this road,and that some cubic equations of state can generate unphysi-cal solutions.

    The admittedly fast execution of the density calculation isevidently an advantage over noncubic equations, which re-quire higher-order or iterative root solvers. These requiretypically 2]4 times as much CPU time as Cardano's formula,and it has been argued that this would slow down complexdesign programs in chemical engineering to a rather unac-ceptable degree.

    One might ask how these design programs could performsatisfactorily a few years ago, when the computers were sig-nificantly slower than nowadays, but that is not the objectiveof this work. Nevertheless, if the computational speed of thedensity calculation is essential, it might be worthwhile to lookfor alternatives to Cardano's formula.

    Cardano's Formula and Cubic Equations of StateTypical cubic equations of state are of the form

    ps prepq patt 1 .

    where the repulsion term prep and the attraction term patt

    are simple rational functions of the molar volume; for the .former usually but not necessarily the van der Waals term is

    used

    RTrepp s 2 .

    V y bm

    It should be noted that modern statistical thermodynamicsdoes not support this repulsion term. There is, however, acubic equation of state for an attractive-hard-sphere fluid,

    which does not use the van der Waals term Yelash et al.,.1999 , but it is not considered here.

    By multiplying a cubic equation of state by the denomina-tor polynomials, it is turned into a cubic polynomial equation

    3is V s0 3 . i m

    is 0

    from which the molar volume can be readily determined byCardano's formula, which is outlined below:

    April 2002 Vol. 48, No. 4 AIChE Journal882

  • Algorithm 1: Cardano's method for sol'ing cubic equationsGiven is a polynomial equation with real coefficients ai

    a x3q a x2 q a xq a s0 with a /03 2 1 0 3

    1. Divide by a to obtain the normalized form3

    ai3 2x q b x q b xq b s0 with b s2 1 0 i a3

    2. Substitute xs yy b r3 to eliminate the quadratic term2

    b223y s pxq qs0 with ps b y1 3

    b b 2b31 2 2qs b y q0 3 27

    3. Evaluate the discriminant

    3 2p qds q / /3 2

    4. If d)0, there is only one real root

    3 3q q b2 x s y q d q y y d y( (0 2 2 3Otherwise, there are three real solutions

    p f q2p k b2x s2 y cos y , ks0, . . . ,1,2,3(k /3 3 3

    q 27with f sarccos y y( 3 /2 p

    The evaluation of Cardano's formula involves several refer-als to root or trigonometric functions. This can lead to a sig-nificant loss of numerical precision, even if double-precisionnumbers are used throughout the computer program.

    We checked the accuracy of the molar volumes obtainedby Cardano's formula against results obtained by iterativemethods. The theoretical precision of a double-precisionnumber is approximately 10y15. The relative error of the vol-ume calculation is very close to this limit for gas volumes; onthe liquid side, however, the relative errors can be as high as10y8. For many thermodynamic calculations, this is not ac-ceptable.

    A different pattern of numerical errors is obtained if thecubic polynomial is constructed in terms of densities insteadof molar volumes. The relative errors on the gas branch are

    y13.now insignificantly higher up to 10 , but the large devia-tions on the liquid side are completely avoided. Thus, usingdensities or concentrations seems to be preferable to usingmolar volumes.

    Another simple way of reducing the computational errorsof the volume calculation is to follow the evaluation of Car-

    Figure 1. 400 K isotherm of nitrogen, including physi-cally unreasonable branches, calculated withthe RedlichKwong equation of state.

    dano's formula with a Newton iteration

    3is V i m

    is 0XV sV y 10 .m m 3iis V i m

    is1

    Here V denotes the ``raw'' result from Cardano's formula.mUsually a single iteration step is sufficient.

    Unphysical RootsIn view of the well-established user-friendly behavior of cu-

    bic equations of state, it may seem surprising that many ofthem are able to generate unphysical}even negative}molarvolumes at supercritical pressures or temperatures. An exam-ple can be seen in Figure 1, which shows an isotherm of the

    .Redlich]Kwong equation of state Redlich and Kwong, 1949for a wide range of volumes, including ``unphysical'' values.Evidently, even this widely used equation describes states withpositive pressure, but with molar volumes less than its covol-ume parameter, b. The common practice of identifying thelowest root of Cardano's formula with the liquid volume couldeventually lead to undesirable results; for example, at 400MPa, Cardano's formula would return a negative molar vol-ume!

    This insight is not really new. A discussion of the unphysi-cal roots as well as several diagrams similar to Figure 1 can

    .be found in the work of Stamoulis 1994 and even in someolder publications Savini et al., 1965; Mohamed and Holder,

    .1987 .

    April 2002 Vol. 48, No. 4AIChE Journal 883

  • Figure 2. 400 K isotherm of nitrogen, including physi-cally unreasonable branches, calculated withthe TrebbleBishnoiSalim equation of state.

    In the case of the Redlich]Kwong equation of state theappearance of negative roots is limited to rather high pres-sures, far beyond the typical range of applicability of thisequation, so these negative roots are of no practical impor-tance. But there are other equations of state where the un-wanted roots can occur at lower pressures, for example, the

    . Trebble]Bishnoi]Salim TBS equation Salim and Trebble,.1991 . Figure 2 shows that here negative molar volumes are

    calculated for all positive pressures.It should be noted that the possibility of having negative

    roots must not be regarded as a weakness of the TBS equa-tion: the equation works well where it is supposed to work.But after solving the cubic equation, it is necessary to checkwhether the results are inside the physically meaningful range.Of course, the problem can only occur at supercritical tem-peratures. Hence an alternative precaution would be to cal-culate the critical temperature and, if T )T , to retain theclargest volume only. Either way, it is necessary to verify the

    .physical validity of the solutions if there is more than one.Figures 1 and 2 also show the reason for the appearance of

    undesirable roots: cubic equations of state have up to threereal poles, which divide the range of molar volumes into four

    .domains labeled I]IV in the diagrams . The highest pole isof first order and lies at V s b. The ``real'' domain I is atmV ) b. As shown in the diagram, the equation of state canmhave a branch with positive pressure values in domain III,and this can give rise to undesirable solutions.

    The generalized cubic equation of state can be written as

    RT aps y 11 .2V y b V qc V qcm m 1 m 0

    where a usually is a function of temperature. In principle it ispossible to cast this equation into a polynomial form 3 and toderive the conditions under which undesirable solutions ap-pear from its discriminant. However, this leads to a rathercumbersome polynomial equation.

    Instead of looking for the number of solutions, it is advan-tageous to locate the minimum of the equation of state indomain III. Physically unreasonable solutions can only occurat pressures above this minimum.

    Again, the evaluation of the conditions of this minimum istedious. It is possible, however, to treat the problem approxi-mately by studying the function

    a V y b .mh V s p V y b s RT y 12 . . .m m 2V qc V qcm 1 m 0

    which is obtained from the equation of state by ``multiplyingout'' the highest pole. The other poles}if they exist}remainunchanged, and it is safe to assume that the extrema of thisfunction are close to those of the equation of state. Differen-tiation of this function with respect to V leads tom

    d h V yV 2 qc q2bV qc b .m m 0 m 1sy a 13 .22dVm V qc V qc .m 1 m 0

    .Thus, the existence of an extremum of h V at V - b re-m mquires that the numerator of Eq. 13 vanishes, and this leadsto an equation for the molar volume of the extremum

    2V s by b q bc qc 14 .m,e 1 0It should be noted that this molar volume does not depend

    on temperature, unless the covolume parameter is made tem-perature-dependent.Equation 14 can now be applied to some cubic equations ofstate

    v For the equation of an der Waals we have c sc s0;0 1hence, the only extremum can occur at V s0. However, themequation of state has a second-order pole at this molar vol-ume, and so domain III has zero width. Therefore, the vander Waals equation does not produce physically unreason-able solutions for the molar volume.

    v .The Redlich] Kwong equation Redlich and Kwong, 1949is characterized by c s0 and c s b. It has three poles, and0 1 .the minimum in domain III is at V s b 1y 2 , which is am,enegative number. The pressure at this minimum is given by

    RT aps y 15 .2 y 2 b 4y3 2 b .

    The contribution of the repulsive part of the equation of stateis negative, and that of the attractive part positive. Since the

    .repulsive part has a stronger temperature dependence AT .than the attractive one aA1r T in the original version ,

    increasing the temperature will generally lower the pressureabove which physically unreasonable densities can be gener-ated. In Figure 1 this pressure is extremely high. One should

    April 2002 Vol. 48, No. 4 AIChE Journal884

  • not conclude, however, that these solutions have no practicalimportance: For hydrogen, the Redlich]Kwong equationyields multiple solutions at 600 K and 50 MPa, which is al-ready in the range of technical hydrogenations.

    v .The Peng ] Robinson equation Peng and Robinson, 1976is characterized by c s2b and c sy b2. The situation is1 0quite similar to the Redlich]Kwong equation; the minimumis even located at the same molar volume.

    v The Trebble]Bishnoi]Salim equation Salim and Treb-.ble, 1991 has two additional substance-dependent parame-

    ters, c and d. The characteristic parameters of the general- 2.ized cubic equation are c s bqc, c sy bcq d , and V1 0 m,e

    2 2 .s b 1y 2y d rb . Hence, this equation can generatephysically unreasonable solutions if d- 2 b. The poles of the

    attractive term of this equation of state are further apart;hence, this equation of state is apt to produce physically un-reasonable solutions, as is shown by Figure 2. For this equa-tion the isotherm branch in domain III can even cross theabscissa, which means that physically unreasonable solutionscan occur at any positive pressure.

    New AlgorithmWhile the program code of Cardano's formula can be writ-

    ten in a rather compact way, it involves numerous referencesto ``slow'' functions, for example, higher-order roots andtrigonometric functions, and it may therefore be worthwhileto look for alternatives. The following algorithm uses itera-tion, followed by deflation, to solve cubic equations.

    Algorithm 2: New algorithms for sol'ing cubic equationsGiven is a polynomial equation with real coefficients a :i

    a x3q a x2 q a xq a s0 with a /03 2 1 0 3

    1. Divide by a to obtain the normalized form3

    ai3 2x q b x q b xq b s0 with b s2 1 0 i a3

    2. Determine an interval containing all real roots:

    <

  • Cardano's method is not the fastest algorithm for findingthe roots of a cubic polynomial.

    AcknowledgmentsFinancial support by the Deutsche Forschungsgemeinschaft and by

    the Fonds der Chemischen Industrie is gratefully acknowledged.

    Literature CitedMohamed, R. S., and G. D. Holder, ``High Pressure Phase Behavior

    in Systems Containing CO and Heavier Compounds with Similar2 .Vapor Pressures,'' Fluid Phase Equilib., 32, 295 1987 .

    Peng, D. Y., and D. B. Robinson, ``A New Two-Constant Equation .of State,'' Ind. Eng. Chem. Fundam., 15, 59 1976 .

    Redlich, O., and J. N. S. Kwong, ``On the Thermodynamics of Solu-tions. V. An Equation of State}Fugacities of Gaseous Solutions,''

    .Chem. Re., 44, 233 1949 .Salim, P. H., and M. A. Trebble, ``A Modified Trebble]Bishnoi

    Equation of State: Thermodynamic Consistency Revisited,'' Fluid .Phase Equilib., 65, 59 1991 .

    Savini, C. G., D. R. Winterhalter, and H. C. van Ness, ``Heats ofMixing for Partially Miscible Systems: Methanol-n-hexane and

    .Methanol-n-heptane,'' J. Chem. Eng. Data, 10, 171 1965 .Stamoulis, D. Patterns of Fluid Phase Behaiour in Binary and Quasi-

    Binary Mixtures, PhD Thesis, Technical Univ. of Delft, Delft, The .Netherlands 1994 .

    Yelash, L. V., Th. Kraska, and U. K. Deiters, ``Closed-Loop CriticalCurves in Simple van der Waals Fluid Models Consistent with the

    .Packing Fraction Limit,'' J. Chem. Phys., 110, 3079 1999 .

    Manuscript receied June 12, 2001, and reision receied Oct. 12, 2001.

    April 2002 Vol. 48, No. 4 AIChE Journal886