Calculation of Densities From Cubic Equations Of

March 22, 2018 | Author: germangsilva | Category: Equations, Mathematical Analysis, Mathematical Objects, Physical Sciences, Science


Comments



Description

Calculation of Densities from Cubic Equations ofState Ulrich K. Deiters Institute of Physical Chemistry, University at Cologne, D-50939 Koln, ¨ Germany Some cubic equations of state can e®entually ha®e unphysical solutions for the molar ®olume. The conditions for this phenomenon are discussed. The computational accuracy and computing time requirements of the analytical root finding method (Cardano’s formula) are in®estigated. A new, faster iterati®e root finder for cubic polynomials is proposed. Introduction In spite of their theoretical shortcomings, cubic equations of state are still frequently used in many chemical and engineering applications. This is partly due to the fact that these equations can be transformed into cubic polynomials with respect to the molar volume. This reducibility to a cubic polynomial is by no means required by physical insight, but by mathematical convenience: the calculation of the density or the molar volume from the given pressure and temperature, which is one of the most frequently performed operations in phase equilibrium calculations, can be done for these equations by Cardano’s formula. Its application does not require iteration or predetermined initial values, and if more than one solution is possible, it yields all of them. It is easy to program, fail-safe, and fast. 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 the road to the calculation of phase equilibria seems clear. It will be shown, however, that there are pitfalls along this road, and that some cubic equations of state can generate unphysical solutions. The admittedly fast execution of the density calculation is evidently an advantage over noncubic equations, which require higher-order or iterative root solvers. These require typically 2]4 times as much CPU time as Cardano’s formula, and it has been argued that this would slow down complex design programs in chemical engineering to a rather unacceptable degree. One might ask how these design programs could perform satisfactorily a few years ago, when the computers were significantly slower than nowadays, but that is not the objective of this work. Nevertheless, if the computational speed of the density calculation is essential, it might be worthwhile to look for alternatives to Cardano’s formula. 882 Cardano’s Formula and Cubic Equations of State Typical cubic equations of state are of the form ps p rep q p att Ž1. where the repulsion term p rep and the attraction term p att are simple rational functions of the molar volume; for the former usually Žbut not necessarily . the van der Waals term is used p rep s RT Vm y b Ž2. It should be noted that modern statistical thermodynamics does not support this repulsion term. There is, however, a cubic 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 denominator polynomials, it is turned into a cubic polynomial equation 3 Ý siVmi s 0 Ž3. is 0 from which the molar volume can be readily determined by Cardano’s formula, which is outlined below: April 2002 Vol. 48, No. 4 AIChE Journal April 2002 Vol. . for a wide range of volumes. on the liquid side. however. there is only one real root dano’s formula with a Newton iteration 3 3 q q b2 x 0 s y q'd q y y'd y 2 2 3 ( ( 3 Ý siVmi Otherwise. If d) 0. Substitute x s y y b 2r3 to eliminate the quadratic term y 3 s px q qs 0 ps b1 y with qs b 0 y b 22 3 b1 b 2 3 q 2 b 23 27 3. The relative error of the volume calculation is very close to this limit for gas volumes. ž / ž / q 3 2 4. isiVmi 27 ž ( / f sarccos y Ý k s 0. Divide by a3 to obtain the normalized form x 3 q b 2 x 2 q b1 x q b 0 s 0 bi s with ai a3 2. this is not acceptable. For many thermodynamic calculations. . including ‘‘unphysical’’ values. . No. for example. An example can be seen in Figure 1. A discussion of the unphysical roots as well as several diagrams similar to Figure 1 can be found in the work of Stamoulis Ž1994. but with molar volumes less than its covolume parameter. The common practice of identifying the lowest root of Cardano’s formula with the liquid volume could eventually lead to undesirable results. at 400 MPa. Usually a single iteration step is sufficient. Thus. it may seem surprising that many of them are able to generate unphysical }even negative}molar volumes at supercritical pressures or temperatures. A different pattern of numerical errors is obtained if the cubic polynomial is constructed in terms of densities instead of molar volumes. Cardano’s formula would return a negative molar volume! This insight is not really new. 1987. even this widely used equation describes states with positive pressure. 4 883 . Another simple way of reducing the computational errors of the volume calculation is to follow the evaluation of CarAIChE Journal Ž 10. even if double-precision numbers are used throughout the computer program. We checked the accuracy of the molar volumes obtained by Cardano’s formula against results obtained by iterative methods. including physically unreasonable branches. using densities or concentrations seems to be preferable to using molar volumes. there are three real solutions ( xk s 2 y p 3 cos with ž f q2p k 3 / y b2 3 VmX sVm y q y 2 is 1 Here Vm denotes the ‘‘raw’’ result from Cardano’s formula.1. . Evaluate the discriminant ds p 3 2 q Figure 1. 1965. Mohamed and Holder.. 1949. 400 K isotherm of nitrogen. The relative errors on the gas branch are now insignificantly higher Žup to 10y13 . calculated with the Redlich–Kwong equation of state. and even in some older publications ŽSavini et al. b. Evidently. p3 The evaluation of Cardano’s formula involves several referals to root or trigonometric functions. which shows an isotherm of the Redlich]Kwong equation of state ŽRedlich and Kwong.Algorithm 1: Cardano’s method for sol©ing cubic equations Given is a polynomial equation with real coefficients a i a3 x 3 q a2 x 2 q a1 x q a0 s 0 a3 / 0 with 1. 48.. the relative errors can be as high as 10y8..2. The theoretical precision of a double-precision number is approximately 10y15. is 0 3 Unphysical Roots In view of the well-established user-friendly behavior of cubic equations of state. but the large deviations on the liquid side are completely avoided. This can lead to a significant loss of numerical precision.3 . and it is safe to assume that the extrema of this function are close to those of the equation of state. The generalized cubic equation of state can be written as ps 884 RT a y Vm y b Vm2 q c1Vm q c 0 Ž 11. As shown in the diagram. so these negative roots are of no practical importance. Figure 2 shows that here negative molar volumes are calculated for all positive pressures. to treat the problem approximately by studying the function h Ž Vm . But there are other equations of state where the unwanted roots can occur at lower pressures. and the minimum in domain III is at Vm.. and that of the attractive part positive. it is advantageous to locate the minimum of the equation of state in domain III. the evaluation of the conditions of this minimum is tedious. this leads to a rather cumbersome polynomial equation. however. equation ŽSalim and Trebble. at Vm . unless the covolume parameter is made temperature-dependent. But after solving the cubic equation. Ž 12. the problem can only occur at supercritical temperatures. The highest pole is of first order and lies at Vm s b. it is necessary to check whether the results are inside the physically meaningful range. 1949. 4 AIChE Journal . the only extremum can occur at Vm s 0. the equation of state has a second-order pole at this molar volume. In principle it is possible to cast this equation into a polynomial form 3 and to derive the conditions under which undesirable solutions appear from its discriminant.e s bŽ1y'2 . 0 1 hence. Since the repulsive part has a stronger temperature dependence Ž AT . In the case of the Redlich]Kwong equation of state the appearance of negative roots is limited to rather high pressures.. the Trebble]Bishnoi]Salim ŽTBS. 48. which divide the range of molar volumes into four domains Žlabeled I]IV in the diagrams. It has three poles. Hence an alternative precaution would be to calculate the critical temperature and. It should be noted that the possibility of having negative roots must not be regarded as a weakness of the TBS equation: the equation works well where it is supposed to work. the equation of state can have a branch with positive pressure values in domain III. In Figure 1 this pressure is extremely high. and so domain III has zero width. is characterized by c 0 s 0 and c1 s b. s RT y a Vm y b 2 Vm q c1Vm q c 0 Ž . ŽOf course. Therefore.e s by b 2 q bc1 q c 0 Ž 14. and this leads to an equation for the molar volume of the extremum ' Vm. It should be noted that this molar volume does not depend on temperature. However. One should April 2002 Vol. it is necessary to verify the physical validity of the solutions if there is more than one.b requires that the numerator of Eq. However. 13 vanishes. 400 K isotherm of nitrogen. increasing the temperature will generally lower the pressure above which physically unreasonable densities can be generated. to retain the largest volume only. The contribution of the repulsive part of the equation of state is negative. for example. including physically unreasonable branches. Instead of looking for the number of solutions. which is a negative number. Equation 14 can now be applied to some cubic equations of state v For the equation of ®an der Waals we have c s c s 0. s p Ž Vm y b . calculated with the Trebble–Bishnoi–Salim equation of state. The other poles}if they exist}remain unchanged. the van der Waals equation does not produce physically unreasonable solutions for the molar volume. Figures 1 and 2 also show the reason for the appearance of undesirable roots: cubic equations of state have up to three real poles. Again.. Differentiation of this function with respect to Vm leads to Figure 2. No.. The ‘‘real’’ domain I is at Vm ) b. It is possible. far beyond the typical range of applicability of this equation.where a usually is a function of temperature. The pressure at this minimum is given by ps RT a y y'2 b Ž 4y3'2 . v The Redlich] Kwong equation ŽRedlich and Kwong. which is obtained from the equation of state by ‘‘multiplying out’’ the highest pole. d h Ž Vm . Physically unreasonable solutions can only occur at pressures above this minimum. b 2 Ž 15. than the attractive one Ž aA1r'T in the original version.. Thus. Either way. if T )Tc . the existence of an extremum of hŽ Vm . 2 Ž 13. and this can give rise to undesirable solutions. dVm sy a yVm2 q c0 q2 bVm q c1 b Ž Vm2 q c1Vm q c0 . 1991. it involves numerous references to ‘‘slow’’ functions. 1976. analytically. followed by deflation. it does not exclude unphysical solutions.4 4.2]1. as is shown by Figure 2. this equation can generate physically unreasonable solutions if d-'2 b. 300 MHz. ŽAlgorithm 2 is a general solver for cubic polynomials. is characterized by c1 s 2 b and c 0 sy b 2. .7 3. Hence. c and d. the calculation of molar volumes for fixed pressure and temperature can produce physically unreasonable values. For this equation the isotherm branch in domain III can even cross the abscissa. Test runs on a workstation wHewlett-Packard Series 9000rB1000 Žprocessor HP-PA-RISC 8500. gX Ž x Ž k . 3.e s bŽ1y 2y d 2rb 2 . . as shown by Table 1. y g Ž x Ž k . hydrogen. the minimum is even located at the same molar volume. Select an initial value from the interval boundaries: x Ž0. higher-order roots and trigonometric functions. This choice ensures that no extremum lies between the initial value and the nearest root. and it may therefore be worthwhile to look for alternatives. however. and Vm. CPU Time Required to Determine All Roots of a Cubic Polynomial trm s Algorithm 1 Real Root 3 Real Roots 1 ŽCardano. y g Ž x Ž k . one has to be on guard against such unwanted solutions when working with light gases Žsuch as helium. methane. c 0 syŽ bcq d 2 . s ½ yr if g Ž x infl . which means that physically unreasonable solutions can occur at any positive pressure. to solve cubic equations. Being mostly iterative. with Vm . s x Ž k . April 2002 Vol. x 1 . The following algorithm uses iteration. has two additional substance-dependent parameters.. This iteration scheme requires first and second derivatives. . Generally. the new algorithm does not suffer from loss of accuracy as does Cardano’s. hence. for example. The poles of the attractive term of this equation of state are further apart. Find the roots Žif any. v The Trebble]Bishnoi]Salim equation ŽSalim and Trebble. to make sure that such solutions are discarded within computer programs. The common programming practice to use the lowest root of a cubic equation as liquid volume can lead to erroneous results or premature program terminations. the Redlich]Kwong equation yields multiple solutions at 600 K and 50 MPa. of the quadratic polynomial hŽ x . No. it is necessary. . Conclusion With many cubic equations.0 1.9]2.b. ' New Algorithm While the program code of Cardano’s formula can be written in a rather compact way. v The Peng ] Robinson equation ŽPeng and Robinson. s Ý ci x i with c1 s c 2 x 1 q b 2 is 0 c 0 s c1 x 1 q b 1 6. 2 As no inflection points or extrema are lying between the initial value and the nearest root. ) 0 qr if g Ž x infl . Algorithm 2: New algorithms for sol©ing cubic equations Given is a polynomial equation with real coefficients a i : a3 x 3 q a2 x 2 q a1 x q a0 s 0 with a3 / 0 1. 2 ŽThis work. 2. it is necessary to check whether the solutions are physically meaningful. this equation of state is apt to produce physically unreasonable solutions. 5.: c 2 s1 2 hŽ x . Perform a deflation Ždivision of the nomalized cubic polynomial by a linear factor containing the first root. which is already in the range of technical hydrogenations. Divide by a3 to obtain the normalized form x 3 q b 2 x 2 q b1 x q b 0 s 0 with bi s ai a3 2. When it is applied to equations of state.. that these solutions have no practical importance: For hydrogen. The situation is quite similar to the Redlich]Kwong equation.5 1. 1991. 4 885 . Root calculation by Cardano’s formula should always be followed with a Newton iteration step. however. Care should be taken to minimize the number of multiplications within the iteration loop.x showed that Algorithm 2 is indeed faster than Cardano’s formula. at high reduced temperatures. AIChE Journal Table 1. The tendency to develop such solutions is greater if the two lower poles of the equations of state are farther apart. F 0 where x infl s y1r3 b 2 is the location of the inflection point. Iterate of the first root by Kepler’s method: x Ž kq1. The characteristic parameters of the generalized cubic equation are c1 s bq c.. nitrogen. gY Ž x Ž k . Determine an interval containing all real roots: y r F x k Fq r with r s1qmax Ž < bi < . as ensured by the previous step. convergence is guaranteed. 1 2 gX Ž x Ž k . The existence of physically unreasonable solutions is not an argument against classic cubic equations. 48.not conclude. . Phys. 12. and re®ision recei®ed Oct.’’ Ind.. ‘‘High Pressure Phase Behavior in Systems Containing CO 2 and Heavier Compounds with Similar Vapor Pressures. V. C. Chem. B. and U.. 10. 171 Ž1965. G. S... Redlich. of Delft.’’ J. Re®. PhD Thesis. 59 Ž1976..’’ 886 Chem. ‘‘On the Thermodynamics of Solutions. Y. ‘‘Heats of Mixing for Partially Miscible Systems: Methanol-n-hexane and Methanol-n-heptane. Acknowledgments Financial support by the Deutsche Forschungsgemeinschaft and by the Fonds der Chemischen Industrie is gratefully acknowledged. C. K. Yelash... N. D. 2001. Technical Univ. S. R.. Patterns of Fluid Phase Beha®iour in Binary and QuasiBinary Mixtures. and G.. ‘‘Closed-Loop Critical Curves in Simple van der Waals Fluid Models Consistent with the Packing Fraction Limit. April 2002 Vol. D. Fundam. 48. Deiters. 3079 Ž1999. Literature Cited Mohamed.. and H. van Ness.. 4 AIChE Journal . A. Holder. Chem. L. Manuscript recei®ed June 12.’’ J. Trebble. 32. An Equation of State}Fugacities of Gaseous Solutions.Cardano’s method is not the fastest algorithm for finding the roots of a cubic polynomial. 59 Ž1991. 65. Robinson. D. Eng. V. Kwong. and D.. Kraska. Chem. No.. Savini. Salim. and M. 110. Winterhalter. Peng.’’ Fluid Phase Equilib. 15.. Stamoulis. Eng. O. Data. P. H. The Netherlands Ž1994.. 44.. 2001. ‘‘A New Two-Constant Equation of State.. D.. 233 Ž1949.’’ Fluid Phase Equilib. Delft. Th. R. ‘‘A Modified Trebble]Bishnoi Equation of State: Thermodynamic Consistency Revisited. 295 Ž1987. and J.
Copyright © 2024 DOKUMEN.SITE Inc.