Open Collections

UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

Phase-splitting prediction in isothermal flash calculations Romero, Alejandro Antonio 1989

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Item Metadata

Download

Media
831-UBC_1989_A7 R65.pdf [ 13.58MB ]
Metadata
JSON: 831-1.0058885.json
JSON-LD: 831-1.0058885-ld.json
RDF/XML (Pretty): 831-1.0058885-rdf.xml
RDF/JSON: 831-1.0058885-rdf.json
Turtle: 831-1.0058885-turtle.txt
N-Triples: 831-1.0058885-rdf-ntriples.txt
Original Record: 831-1.0058885-source.json
Full Text
831-1.0058885-fulltext.txt
Citation
831-1.0058885.ris

Full Text

P H A S E - S P L I T T I N G P R E D I C T I O N I N I S O T H E R M A L F L A S H C A L C U L A T I O N S By Alejandro Antonio Romero B.A.Sc. (Chemical Engineering) Universidad Nacional Autonoma de Mexico A THESIS SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF APPLIED SCIENCE in THE FACULTY OF GRADUATE STUDIES CHEMICAL ENGINEERING We accept this thesis as conforming to the required standard THE UNIVERSITY OF BRITISH COLUMBIA July 1989 © Alejandro Antonio Romero, 1989 In presenting this thesis in partial fulfilment of the requirements for an advanced degree at the University of British Columbia, I agree that the Library shall make it freely available for reference and study. I further agree that permission for extensive copying of this thesis for scholarly purposes may be granted by the head of my department or by his or her representatives. It is understood that copying or publication of this thesis for financial gain shall not be allowed without my written permission. Department of Chl*iic*l t=r$\nte.f\*3 The University of British Columbia Vancouver, Canada Date Ju/jf Zt,lW  DE-6 (2/88) Abstract The development of processes that operate at conditions where multiple fluid-phase equi-l ibr i a may occur demands fast and reliable simulation algorithms. The success of these algorithms depends on the correct prediction of the number and compositions of the phases present at a given temperature, pressure and overall fluid composition. The most commonly used routine for this purpose is the isothermal (single-stage) flash calculation. A robust and efficient method to predict phase-splitting previous to performing an isothermal flash is implemented i n this work. It is based on the thermodynamic stability analysis of the source phase using a Gibbs energy tangent-plane criterion. Depending on the outcome of the phase-split tests, the system may be declared stable as a single phase and thus no further calculations are needed, or unstable i n which case a potential two- or three-phase solution can be obtained. Only i n this last instance would the corresponding flash calculation follow, depending on the nature and quantity of the phases found: a vapour-liquid ( V L ) or a l iquid- l iquid (LL ) flash if two phases are predicted, or a mult i -phase flash ( V L L ) when three phases are expected. In addit ion to readily recognizing the number and type of phases present, the sta-bi l i ty tests provide excellent in i t i a l composition estimates for the flash which assure fast convergence to the stable solution. Even though the algorithms developed can be used wi th any suitable model to calculate equil ibrium properties, cubic equations of state are used throughout i n this work as a single model to describe a l l fluid phases. n Table of Contents Abstract ii List of Tables vi List of Figures viii List of Symbols xi Acknowledgement xv 1 Introduction 1 1.1 Purpose and scope 2 1.1.1 The flash algorithms 3 1.1.2 Thermodynamic models 3 1.2 Structure of this study 4 2 Previous works on phase-splitting 6 2.1 Thermodynamic stability 6 2.2 Phase-splitting 12 2.2.1 Liquid-l iquid split tests 12 2.2.2 Gibbs energy minimizat ion algorithms 18 2.2.3 Mass balance approaches 30 3 Proposed algorithm 35 3.1 General scheme 36 i i i 3.2 Phase search strategy 43 3.2.1 Vapour phase search 49 3.2.2 L iqu id phases search 57 3.3 Init ial izat ion procedures 67 3.3.1 Vapour phase 67 3.3.2 L iqu id phases 68 3.4 Phase removal tests 78 3.4.1 Multiphase flash method 81 3.4.2 Bubble- and dew-point equations method 84 3.4.3 Coupled method 88 4 Results and discussion 90 4.1 Systems tested 91 4.2 Phase search init ia l izat ion 97 4.2.1 Vapour phase 97 4.2.2 L iqu id phases 99 4.3 Phase search performance 107 4.3.1 Vapour phase 110 4.3.2 L iqu id phases 115 4.3.3 Wegstein's method 128 4.4 Phase removal tests 135 4.4.1 Multiphase flash method 135 4.4.2 Coupled method 138 4.4.3 Bubble- and dew-point equations method 139 4.5 Overal l phase-splitting prediction performance 142 IV 5 Conclusions and recommendations 152 5.1 General conclusions 152 5.2 Specific remarks and recommendations 153 Bibliography 158 Appendices 163 A Two- and three-phase flash algorithms 163 A . l Isothermal V L or L L flash 163 A.1.1 L i m i t for the phase ratios 167 A.1.2 V L flash init ia l izat ion 168 A . 1.3 L L flash init ial ization 168 A . 2 Isothermal V L L flash 170 A.2.1 L i m i t for the phase ratios 174 A.2.2 V L L flash init ia l izat ion 175 A . 3 Wegstein's method 175 B Act iv i ty coefficient models in the phase-splitting algorithm 178 B. l Activit ies and standard states 179 B.2 Vapour and l iquid phases search 181 B.3 L i q u i d phase init ia l izat ion 182 Appendices 185 C Description and listings of the computer programs 185 v List of Tables 4.1 Initial composition estimates for the vapour phase search using Raoult's law and for the flash calculation using the incipient vapour found 98 4.2 Composition estimates for the incipient liquid phases obtained with the various initialization methods tried, composition of the incipient phases found and equilibrium values for two feed compositions in System 4- • • • 100 4.3 Comparison of the reliability and efficiency of the four methods tested to provide initial compositions for the liquid phase search 103 4.4 % RMS deviation of the incipient phase estimates and of the equilibrium values from the actual incipient phases composition (mole fraction) in the prediction of LL immiscibility for System 1 105 4.5 Vapour and liquid phases search performance for System 2 from 90 to 320 K indicating the stable solution, the number of iterations required for con-vergence and the CPU time (in milliseconds) required for the initialization plus the phase search 109 4.6 Phase equilibria predictions comparison for System 5 when the phase-splitting algorithm is used with the optional additional phase search to find a missed vapour giving correct VL equilibria solutions 112 4.7 Equilibria predictions when the phase-splitting algorithm is used with and without the optional additional phase search to find a missed liquid yielding correct LL equilibria solutions for System 4 120 vi 4.8 Performance of Wegstein's method in the vapour and liquid phase search as a function of parameters w and tmax for Systems 1, 2 and 3 compared to the use of direct substitution 130 4.9 Performance of the phase removal tests and of the subsequent flash calcula-tion in the phase-splitting prediction for Systems 1, 2 and 3 near saturation point conditions 137 4.10 Comparison of the phase removal tests reliability with and without the additional phase search versus the direct three-phase flash calculation for Systems 1 and 6 140 4.11 Comparison of the prediction of the phase distribution for System 1 at different temperatures with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding type of flash. 144 4.12 Predictions of the equilibrium conditions for System 2 at different tem-peratures with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding type of flash. . 146 4.13 Number and type of phases predicted for System 3 at different pressures with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding flash 148 4.14 Equilibria predictions for System 7 at three temperature and pressure con-ditions with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding flash 150 4.15 Summary of the phase equilibrium predictions for the seven systems tested obtained with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding type of flash when required 151 vn List of Figures 2.1 Molar Gibbs energy of mixing at constant temperature and pressure for a binary liquid system presenting a miscibility gap 9 2.2 Thermodynamic stability regions for a binary liquid mixture at constant pressure showing the connodal and spinodal domes 10 2.3 Vapour-liquid thermodynamic stability regions in a Gibbs energy as a func-tion of composition diagram for the methane- propane system at 278 K and 33.6 bar (modified from Radzyminski and Whiting) 11 2.4 Graphical representation of Michelsen's stability test for the case of a stable binary system 27 2.5 Michelsen's stability test and initial guess compositions for an unstable binary system 28 3.6 Flow chart of the phase-splitting algorithm proposed in this work 40 3.7 Erroneous prediction of VL equilibrium due to bypass of a liquid incipient phase when using Michelsen's method for the n-hexane-water system at 378 K and 4-08 atm (diagram modified from Heidemann) 45 3.8 Bypass of a vapour incipient phase when using the tangent plane criterion leading to an incorrect LL equilibrium prediction in a hypothetical binary mixture 45 3.9 Additional phase search to find the n-hexane rich liquid incipient phase for the n-hexane-water system (378 K and 4-08 atm) leading to the correct prediction of LL equilibria 46 viii 3.10 Detection of an incipient vapour phase by means of the additional search proposed for the binary mixture of Figure 3.8 leading to the proper predic-tion of a VL stable system 47 3.11 Binary system stable as VL for which two incipient liquid phases are found in the phase search, one being superfluous 80 4.12 Gibbs energy of mixing diagram for the n-hexane- water system at 378 K and 5 atm (System 4) showing that both components are immiscible almost throughout the entire composition range 101 4.13 Gibbs energy of mixing diagram for the hydrogen sulphide-methane system at 190 K and 38 atm (System 5) for which the vapour phase is detected with the additional phase search leading to the correct prediction of VL equilibria 113 4.14 Gibbs energy of mixing as a function of composition for the methane-n-butane-water system (System 6) at 311 K and 60 atm considered as a vapour 123 4.15 Gibbs energy of mixing surface for System 6 considered as a liquid in the entire composition range at 311 K and 60 atm 123 4.16 Gibbs energy of mixing for the stable system (System 6 at 311 K and 60 atm) obtained by superimposing the vapour and liquid-like surfaces and retaining the least Gibbs energy values at every composition 124 4.17 Gibbs energy of mixing as a function of composition for the methane-carbon dioxide-hydrogen sulphide system (System 1) at 171 K and 20 atm corresponding to the stable solution 126 4.18 Contour lines of the Gibbs energy of mixing surface for System 1 as a stable system 126 ix 4.19 Type and number of phases present at equilibrium in the composition plane for System 1 at 171 K and 20 atm according to the location of the feed. . 127 4.20 Composition of the phases formed at equilibrium when System 1 splits as two- or three-phase stable mixtures at different feed locations 127 4.21 Performance of direct substitution and Wegstein's method in the vapour phase search for System 2 at 169.9 K and 60.5 atm 133 4.22 Convergence behaviour when using direct substitution and Wegstein's method in the liquid phase search for System 2 at 160 K and 40 atm 133 4.23 Convergence characteristics of Wegstein's method compared with direct substitution in the liquid phase search for System 1 at 180 K and 20 atm. 134 x List of Symbols a act ivity D determinant of H ^ g F number of moles i n the feed or stability criterion function / fugacity or function defined by equations (3.50) and (3.78) g molar Gibbs energy or dimensionless stability criterion function g* modified dimensionless stability criterion function g"j second part ial derivative of Ag wi th respect to composition H^g Hessian matr ix of Ag h parameter defined by equation (2.17) K equil ibrium constant k i terat ion number indicator kij binary interaction parameter L l iqu id or number of moles in the l iquid m number of composition vectors for the l iquid search n number of components i n the mixture n, mole numbers of component i P pressure P sat saturation pressure p phase init iator i n l iquid I Qi function defined by equation (2.27) Q2 function defined by equation (2.28) q phase init iator in l iquid / / x i R universal gas constant r gradient function defined by equation (2.22) 5 variable defined by equation (3.43) or (3.70) T temperature t step size i n Wegstein's method V vapour or number of moles in the vapour w Wegstein's method application frequency X mole numbers of the l iquid incipient phase x l iqu id composition (mole fraction) Y mole numbers of the vapour incipient phase y vapour composition (mole fraction) z global or feed composition (mole fraction) Q objective function Greek letters a phase ratio V/F 3 phase ratio Li/F of function defined by equation (2.23) TL function defined by equation (3.116) I V function defined by equation (3.115) 7 act ivi ty coefficient A property of mixing £ convergence tolerance r] control variable for the use of Wegstein's method u chemical potential v control variable in the phase removal tests 7r number of phases xn fugacity coefficient phase ratio L[/F phase ratio Lu/F Pitzer 's acentric factor superscripts i teration number indicator l iquid vapour l iquid phase / l iquid phase II infinite di lut ion property incipient phase standard state property i n the mixture ideal state subscripts bubble-point cr i t ical constant dew-point i n i t i a l value component index number vector index number index for the phase init iator in l iquid / or indicator for a pseudo-parameter index for the phase init iator in l iquid II xin r index for the rest of the components p, q) 3-4 three-phase / hquid phase J // l iqu id phase II xiv Acknowledgement Since it would be impossible to name them individual ly without making embarrassing omissions, I wish to express my gratitude to a l l whom directly or indirectly contributed to this work. Specially I would like to thank my advisor, D r . D . W . Thompson, for his guidance throughout my research. The financial assistance provided by the University of Br i t i sh Columbia by means of a Graduate Fellowship is gratefully acknowledged. xv Chapter 1 Introduction The equipment design and simulation of processes that are conducted under conditions at which multicomponent mixtures may form two or three fluid phases require adequate prediction of phase equilibria using models that incorporate temperature, pressure and compositional effects. Failure to obtain correct estimates of phase equil ibria can cause serious operation problems. For example, unexpected formation of two l iqu id phases on the trays of a dist i l lat ion column can significantly reduce its capacity and efficiency. W h e n the appearance of a second l iquid phase is suspected, conditions should be determined to avoid i t or the proper steps must be followed to take i t into account [1]. Without doubt, the most commonly used routine for phase equil ibria prediction is the isothermal isobaric flash, which according to Joul ia et a l . [2], is the most important routine i n a process simulator. It is used not only to simulate an actual flash tank or other phase-contacting separation operations, but to define unknown conditions of inlet or effluent streams i n process units as diverse as valves, heat exchangers, reactors, com-pressors, etc. W h e n the behaviour of systems which may form three phases is described, the isothermal flash calculation must be able to determine whether a given mixture is a vapour ( V ) , a l i qu id (L) , a two-phase ( V L or L L ) or a three-phase ( V L L ) mixture for a wide range of temperature and pressure specifications and for a broad spectrum of components. A l so , when two or three phases are present, the composition and amount of each phase should be obtained. Since flash calculations are performed hundreds or thousands of times i n a moderately sized simulation, the algorithm must be fast as well 1 Chapter 1. Introduction 2 as reliable. 1.1 Purpose and scope T w o factors that determine the satisfactory outcome of isothermal flash calculations, other than the flash algorithm per se, are given primary importance and constitute the ma in objectives of this work: 1. The reliable prediction of the number and type of phases actually present before conducting the flash calculation, and 2. The generation of sound in i t i a l composition estimates when the flash is to be carried out. W h e n considering i tem 1., it has been recognized [3] that a large amount of computational t ime is wasted when a system which may have three phases is considered under conditions at which only one or two phases exist. For such cases i t is desirable to detect the presence of only one or two phases as early as possible. Item 2. has been given considerable attention i n the literature reviewed. It is well known that convergence either to the (most) stable solution (that wi th the least Gibbs energy at constant temperature and pressure) or to a spurious one (corresponding to a local minima) is very dependent on the in i t i a l composition estimates of the phases assumed to appear. To achieve the desired objectives, prior to the isothermal flash a phase-splitting test based on a modified version of Michelsen's [4] thermodynamic stabil ity analysis has been implemented. This analysis has the advantage that no i n i t i a l estimates of the number of phases present at equil ibrium are required and for unstable systems the composition of the new phases are provided and are used as starting values i f the flash calculation is required. Thus , i n the method to be proposed, i f only one phase is found the flash Chapter 1. Introduction 3 is avoided. If two phases are predicted, the corresponding V L or L L two-phase flash is executed instead of the more time-consuming three-phase flash calculation. 1.1.1 The flash algorithms As mentioned earlier, the performance of the flash algorithms themselves is not the main concern i n this work although they are used for comparative purposes and are incorporated i n the computational scheme proposed. The flash routines used are those developed i n [5] (with slight modifications) since they were considered to be dependable and were readily available. Two types of isothermal isobaric calculations are considered: a two- phase flash for the prediction of V L or L L equilibria, and a general three-phase flash for V L L equilibria computations. This last calculation can be reduced to either of the first k i n d if the existence of only two phases is detected. The flash algorithms are based on a mass-balance approach using an equation decoupling method which gives Rachford-Rice type check functions (for a general description of this computation method see Appendix A ) . A thorough discussion of the isothermal flash problem has recently been presented by A m m a r and Renon [6]. 1.1.2 Thermodynamic models The necessary and sufficient condition for thermodynamic equil ibrium i n a multi-phase multicomponent system at constant temperature and pressure, which requires the total Gibbs energy to have a m i n i m u m value, can be expressed by the condition of equality of fugacities for a l l the components i n the phases i n which they are present. Two general methods, which differ i n the thermodynamic models used, are commonly uti l ized to obtain fugacities. Those that use an activity coefficient model for the l iquid phase and a correlation or equation of state for the vapour (mixed model approach), and those where the same equation of state is used to represent both phases (single model approach). Chapter 1. Introduction 4 There are inherent advantages and disadvantages i n each method, but they w i l l not be addressed i n this work i n which only the single model approach is used. Two well known cubic equations of state, which have gained popularity because of their s implicity and flexible application, are used as thermodynamic models. These are the Soave-Redlich-Kwong [7] and the Peng-Robinson [8] equations wi th the modification proposed by Mathias [9] to handle polar compounds and supercritical components. Also , to avoid the t r iv ia l solution i n the density root calculation, the algorithm of Mathias et al . [10] is incorporated as implemented by M o l i n a and Romero [5]. A l though the use of these equations has been widespread i n the gas and petroleum processing, it is not l imited to these industries alone. 1.2 Structure of this study To give the reader a perspective of the approaches taken i n the prediction of the stability of fluid mixtures, a literature review on the more relevant methods is given i n Chapter 2. Then i n the next chapter the proposed phase-splitting algorithm is presented. The global scheme is in i t i a l ly discussed followed by a more thorough description of each part of the algorithm. Because these parts are considered i n detail i n different sections, i t may be helpful to occasionally make reference to the first section pertaining the global scheme. In Chapter 4 are given the results of the performance of each part of the algorithm according to their execution order. Also the overall results of the equilibria predictions are presented and compared against those obtained wi th the direct three-phase flash. The conclusions drawn from these calculations and the recommendations for the use of the proposed algorithm are given i n the last chapter. Append ix A gives a description of the flash algorithms (two- and three-phase) devel-oped i n reference [5], which are used i n the final part of the phase-splitting algorithm. Chapter 1. Introduction 5 The direct three-phase flash is used also as a reference for the performance of the splitting method. Appendix B indicates the changes which would be needed i n the proposed algo-r i t h m i f a mixed model approach was to be employed to calculate equil ibrium properties (using an act ivity coefficient model for the l iquid phase and an equation of state for the vapour). F i n a l l y i n Appendix C are presented the computer programs written (in Fortran 77) to perform the phase equilibria calculations. Complete listings and descriptions are given as well as the input and output files for an example calculation. Chapter 2 Previous works on phase-splitting The problem of determining whether or not a single-phase multicomponent mixture w i l l split spontaneously and irreversibly into two or more distinct phases was first addressed by Gibbs i n 1876 [11]. To date, a satisfactory solution to this problem has not been found except for the case of binary mixtures. The extension to ternary or higher systems is far from simple and despite several attempts made, there is s t i l l disagreement i n the development of practical solutions l . The theoretical approach to this problem consists of doing a thermodynamic stability analysis on the system, which, as w i l l be explained, is of l imi ted significance to establish other more practical criteria. 2.1 Thermodynamic stability W h e n considering the phase stability of homogeneous multicomponent systems at con-stant temperature, pressure and overall fixed composition, three equil ibrium states can be defined: stable, unstable and metastable. A system is considered to be stable i f after following a minor perturbation it reverts to its original state. Thermodynamically, the total Gibbs energy of a stable mixture is at a global m i n i m u m and thus can not be de-creased relative to allowable changes that may take place wi th in the system under the assumption of constant temperature and pressure. O n the contrary, an unstable phase Examples are the criticism of Van Dongenet al.'s work [11] by Michelsen in [12] and the corresponding response, ibid. p. 377, as well as the comments on Beegle et al.'s paper [13] by Heidemann in [14] and the subsequent reply, ibid., p. 826. 6 Chapter 2. Previous works on phase-splitting 7 can not exist as such and w i l l be permanently altered as a result of even an infinitesi-mal perturbation, decreasing its Gibbs energy by spontaneously changing to one or more stable phases. Since the definition of the magnitude of a 'minor perturbation' is arbitrary, i t can be ambiguous to define a metastable system which w i l l not be altered by a small perturbation but w i l l become unstable wi th respect to a larger perturbation. Thus , a phase change may or may not happen when a mixture is considered metastable. Classical thermodynamics textbooks consider metastable systems as stable, and only the l imi t between the unstable and the metastable region is discussed (e.g. i n Mode l l and Re id [15], chapter 9). This l imi t is referred to as the l imi t of intrinsic stability, diffusional stability or material stability. V a n Dongen et a l . [11] follow this same criterion and show that the negative definiteness of the matr ix of second part ia l derivatives of the molar Gibbs energy of mix ing with respect to composition at constant temperature and pressure is the necessary and sufficient condition for instability. This square symmetric matr ix , which is the Hessian of the molar Gibbs energy of mix ing Ag, is: 1 tf. V 5n-l,l (2.1) where n is the number of components i n the mixture and g"j, the second part ial derivative of Ag w i th respect to composition (mole fraction z) at constant temperature and pressure, is (2.2) Chapter 2. Previous works on phase-splitting 8 According to [11], the l imit of intrinsic stability, at which H A 9 just ceases to be positive definite, occurs where the determinant D of the Hessian matr ix itself becomes zero. This means that i f D is negative, the mixture is unstable and w i l l split i n two or more phases, but if positive, i n which case the system may be stable or metastable, the original phase is considered to remain as a homogeneous mixture. The locus of points where D = 0, called the spinodal curve, is relatively easy to calculate even for multicomponent systems as stated by Maurer and Prausnitz [16], however, the computational effort required is not negligible. A major point overlooked when considering only the stability criterion to predict phase equil ibria is that for practical engineering applications, metastable mixtures are unstable virtually in all situations, forming separate phases [3],[12]. Therefore, phase homogeneity can exist only i n the stable region. Consequently, i f the stability analysis indicates that the system is unstable (D < 0), a phase split w i l l take place, but if D > 0 i t is not possible to determine whether a mixture is stable and w i l l remain as a single phase or metastable and hence form a new phase. In short, the result of doing a thermodynamic stability analysis on a homogeneous mixture (i.e. knowing the coordinates of the spinodal curve) is not always sufficient to predict phase-splitting. To overcome this problem, the l imit between the metastable and the stable region, which defines the so-called connodal or equil ibrium curve, must be known. F inding the coordinates of the connodal curve requires further calculations based on other phase-splitting tests, treated i n section 2.2. To illustrate the l imitations of using phase stability criteria to predict phase equilib-r ium, let us consider the case of a binary mixture. Typical ly , a plot of the Gibbs energy of mixing as a function of composition is used to explain l iquid-l iquid equilibria when a miscibil i ty gap exists. Such a diagram is depicted i n Figure 2.1. The unstable region is bounded by the points C and D , which correspond to the inflection points on the Chapter 2. Previous works on phase-splitting 9 A AQ/RT 0 x' x 1 composition (mole fraction x) Figure 2.1: Molar Gibbs energy of mixing at constant temperature and pressure for a binary liquid system presenting a miscibility gap. curve. A t these points, D — 0 and i n between them, where the curve is concave, D < 0. Regions B C and D E are metastable; the boundary between these and the stable regions is given by points B and E , defined by the common tangent represented by the dashed line. Clearly, a l iquid i n the region B E w i l l form two distinct phases w i t h equi l ibrium compositions x 1 and x 11 since by doing so w i l l decrease its Gibbs energy to a min imum along the line B E . A thermodynamic stabil i ty analysis is only able to predict a miscibil i ty gap i n the region C D , but not i n the metastable regions. Figure 2.2 shows the connodal (sometimes called binodal) and spinodal curves for a hypothetical binary mixture at constant pressure. Note that the former curve is defined by the locus of points corresponding to the equil ibrium compositions and the latter by the loci where D — 0. The metastable region is located between the connodal and the spinodal dome, and both meet at the cr i t ica l point (corresponding i n this case to an upper cri t ical solution temperature). Chapter 2. Previous works on phase-splitting 10 critical point apinodal / \ _ c o n n o d a l curve / curve \\ stable / / T'T, stable 11 | v\ unstable t 1 t metastable metastable 0 1 composition (mole fraction x) Figure 2.2: Thermodynamic stability regions for a binary liquid mixture at constant pres-sure showing the connodal and spinodal domes. For vapour-liquid equilibria i n binary systems, the Gibbs energy of mix ing curves are somewhat different from that represented i n Figure 2.1. W h e n cubic equations of state are used to obtain fluid properties, such as the Soave-Redlich-Kwong equation, Radzyminski and W h i t i n g [17] stress that the Gibbs energy of a mixture is not a smooth, continuous function of composition. The actual curve does not exhibit a maximum, but rather i t has two branches that meet at a cusp, one corresponding to the vapour and the other to the l iquid density roots. They point out that misunderstanding of phase-splitting can lead to misuse of the algorithms for phase equil ibrium calculation based on stabil-i t y analyses. A l though the problems associated with phase stability mentioned before are not specifically addressed, these can be inferred from the results presented by them. As an example, for the methane-propane system at 278 K and 33.6 bar their stability Chapter 2. Previous works on phase-splitting 11 0 -0.05 -0.1 'A g -0.15 RT -0.2 -0.25 -0.3 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 methane mole fraction Figure 2.3: Vapour-liquid thermodynamic stability regions in a Gibbs energy as a function of composition diagram for the methane- propane system at 278 K and 33.6 bar (modified from Radzyminski and Whiting). analysis indicates that the unstable region, where a two-phase V L mixture is predicted, occurs i n the composition range from about 0.466 to 0.504 methane mole fraction. A t that temperature and pressure the bubble- and dew- point compositions are 0.205 and 0.780 respectively, so the actual V L region is much broader than predicted by the stabil-i t y analysis as shown in Figure 2.3. The unstable region is reduced even more at higher temperatures, e.g. for the calculation at 311 K (and 33.6 bar) this region comprises the range 0.290 to 0.295, whereas the actual two-phase region extends from 0.131 to 0.518 methane mole fraction corresponding to the bubble- and dew-point compositions. The fact that the spinodal dome is always contained wi th in the equi l ibr ium dome adds another feature that makes thermodynamic stability tests unattractive from a practical point of view. This feature is that the coordinates of the l imi t of intrinsic stability Chapter 2. Previous works on phase-splitting 12 usually constitute poor in i t i a l estimates for the actual equi l ibrium compositions. The reason for this is that the in i t i a l composition estimates should preferably be outside the immiscibi l i ty region rather than inside i t i n order to avoid convergence of the equil ibrium calculations to the tr iv ia l solution, i n which the number of phases predicted is less than the number corresponding to the stable solution. To eliminate ambiguity in some of the terms used from this point on, the region where D < 0 (section C D on the curve i n Figure 2.1) w i l l be referred to as ' intrinsically unstable' or 'thermodynamically unstable', whereas this and the metastable regions as a whole (portion B E of the curve) wi l l be generically called 'unstable'. A l so , when referring to the Hessian matr ix criterion to determine phase stability, the term 'thermodynamic stabil i ty ' w i l l be employed as opposed to simply 'stability' , which w i l l be used i n a broader sense to describe methods to find conditions i n the unstable region. 2.2 Phase-splitting Alternative methods to thermodynamic stability analysis, whose goals are to predict the number and type of phases at equil ibrium and/or to obtain accurate i n i t i a l composition estimates for equil ibrium calculations, are referred to as phase-splitting methods i n this study. Some of them resort to stability tests of different kinds; the various approaches reviewed are discussed i n this section. 2.2.1 Liquid-liquid split tests Maurer and Prausnitz's method A n approximate procedure to obtain the L L connodal curve i n binary, ternary and higher systems is proposed by Maurer and Prausnitz i n [16]. Their concern is not to calculate the equi l ibr ium compositions but to determine whether or not at a given temperature, Chapter 2. Previous works on phase-splitting 13 pressure and overall l iquid composition immiscibi l i ty w i l l occur. For multicomponent systems their method, which is developed for ternary mixtures and then extended to four or more components, starts by doing a thermodynamic stability analysis of the system. If intrinsic instability is detected, two l iquid phases must be present and then i t is suggested that the equil ibrium compositions be obtained by a flash calculation. O n the contrary, i f the determinant D is positive, any binary pairs for which a miscibil ity gap exists at some composition i n the range 0 < x < 1 are determined as well as the corresponding spinodal and connodal composition coordinates. For the case where only one binary pair has a miscibil i ty gap, a t r ia l point t between the original feed composition z and the mid-point of the spinodal coordinates of the immiscible pair is tested for thermodynamic stability. If such a point is i n the intrinsically unstable region, the original system is considered to be metastable, separating into two phases; otherwise i t is assumed stable as a single phase. W h e n two or more binaries are part ia l ly miscible the calculation is extended to a l l these binary systems. The usefulness of this method clearly depends on the magnitude of the distance between points z and t. Various criteria , based on geometrical considerations, are given by these authors to select this length parameter. A l though the approximate calculations presented are claimed to require about one order of magnitude less computing time than "the exact calculations" (presumably an equi l ibrium flash), the method has some inherent features that restrict its use. It is intended only for L L equilibria prediction where at least one of the binary pairs has a miscibi l i ty gap, the immiscible region tends to be overestimated, and is based on geo-metrical relationships rather than on thermodynamic grounds. Also , since each possible binary pair i n the mixture must be tested for stability i n the whole composition range, the extension to systems wi th a large number of components would significantly reduce Chapter 2. Previous works on phase-splitting 14 its computational efficiency 2 . Shah's method The method presented by Shah [1] is intended to determine whether a second l iquid phase may exist i n any tray of a multicomponent dist i l lat ion column, but the heuristic algorithm developed to test for the stability of the existing l iquid is flexible enough to be used i n other equil ibrium calculations. For example, Fournier and Boston [18] use it i n their V L L flash algorithm which is based on the same strategy as Shah's tray test: beginning wi th the assumption that only one l iquid is present, the V L equil ibrium and mass balance equations are solved. Then the l iqu id resulting from the two-phase calculation is examined for stability. If it is stable, there is no need to search for a second l iquid ; however, i f found unstable, the two-phase solution is not val id and calculations are carried out to find a three-phase solution. This strategy as a whole defeats the purpose of the present study since two or at least one flash calculation is required to determine the configuration of the system at equil ibrium. Nevertheless, the heuristic stability test, which accounts for phase separation i n the metastable region, is of interest. It is based on the following features: a) the stability of the V L system is determined by examining only the l iquid phase; b) instability is indicated by splitt ing the l iquid phase into a pair of l iquids, not necessarily i n equilibrium but subject to the mass balance constraints, having a lower Gibbs energy than the original l iquid ; c) a splitt ing algorithm generates an in i t i a l guess of the l iquid split which allows a region of lower Gibbs energy to be found quickly and prevents convergence to a t r iv ia l solution when the original l iquid is unstable. The assumption taken in a) is somewhat dubious since i t can be conceived that the vapour phase found from the V L calculation can itself be unstable and split into different 2The number of binary pairs that can be formed out of an n component system is n!/[(n — 2)! • 2!] or n(n — l)/2. E.g. for a 3 component system there are 3 possible binary pairs; for 10 components the number of binaries is 45. Chapter 2. Previous works on phase-splitting 15 vapour and l iquid phases. His argument stating that " T h e val idity of determining the stability of the whole system just by testing for the stabil ity of the l iqu id phase results from the fact that the vapour and the l iquid phases are i n equi l ibr ium wi th each other before testing for the presence of the second l iquid phase" seems inconclusive. Looked at from a Gibbs energy analysis perspective, his justification can be questioned as follows: i f the VL solution corresponds to a local min imum i n Gibbs energy and a global min imum can be reached by obtaining an alternative V'L'L" solution, the vapour V may or may not correspond to the same V vapour. If V is in the same amount and is of the same composition as the original V, it can be concluded that V was stable and that the unstable L split into liquids L' and L". However, i f V is of a different nature than V and L is s imilar to either U or L", it is clear that V split into V and L" or into V and L', respectively, and the assertion that V was indeed unstable can be made. A n example i n which this last situation prevails is given by Founder and Boston [18] when flashing at 377.59 K and 40.83 atm a mixture consisting of propylene, diisopropyl ether, isopropanol and water. The vapour fraction obtained for a V L flash is 0.8725 whereas for the V L L flash is 0.2414. It is mentioned that the second l iquid phase was formed pr imari ly from the vapour phase of the two-phase flash solution and that the original l iquid phase of the V L flash was "nearly stable". Even though the three-phase solution was correctly predicted using Shah's stability test i n this example, the first assumption on which the stability test is based may make it prone to failure. For this reason and since i t requires a previous V L flash calculation, this stability test a lgorithm is not adequate for the purpose of this work. O f more importance is the i n i t i a l split algorithm proposed by Shah (which is the second step of the stability test) and thus w i l l be considered next. This algorithm generates composition estimates for two new l iquid phases if they were to form from an unstable l iquid phase. It is based on selecting the component most likely to init iate a new separate phase from the Chapter 2. Previous works on phase-splitting 16 original l iquid (source phase). Once this new phase (designated phase J) is init iated, the component wi th the lowest solubility i n i t is selected as the init iator of the second new phase (phase II). Then the remaining components are split between the two new phases as dictated by the mass balance and equil ibrium equations. Initially, the component wi th the largest pseudo infinite-dilution act ivity i n the orig-ina l mixture is selected as the init iator of phase J and is indicated by subscript p. The pseudo infinite- di lut ion activity for component i is obtained as the product of the global composition and the activity coefficient at infinite di lut ion for that component, i.e. Xijf°. Shah asserts that the component wi th the max imum pseudo infinite- di lut ion activity i n a given solution w i l l have the maximum tendency to init iate a separate l iquid phase since the mole fraction of a component i n a solution is a measure of its availability and the inverse of the infinite-dilution activity coefficient is an indirect measure of its solubility i n the rest of the solution. Phase II is init iated by selecting the component which has the largest pseudo infinite-dilution activity i n the pure p component and is designated wi th subscript q. Then components p and q are split between phases I and II assuming no other components are present. Lett ing n 7 , n 7 7 , n* and n 7 7 denote the mole numbers of p and q i n phases / and II, the phase equil ibrium and mass balance requirements dictate that: 7,T </K7 + nj') = nj/(nj + „ J ) (2.3) 7fX/K + O = + »{') ( 2- 4) where i t has been considered that the activity coefficients of p and q i n phases II and / , respectively, are constant and each equal to its corresponding infinite d i lut ion value, and Chapter 2. Previous works on phase-splitting 17 i n phases I and I I are equal to the pure component values (i.e. equal to 1 considering symmetric normalization of the activity coefficients). Al so , considering 1 mole of the original mixture, nl + n ^ x , (2.5) and n j + n j 7 = xq (2.6) Equations (2.3) through (2.6) can be arranged to give a system of two simultaneous non-linear equations which may be solved for the moles of p and q i n both phases. Once these variables are determined, the split for the remaining components between phases / and I I is determined again assuming that only p and q are present. Thus , for the rest of the components (designated by subscript r) taken one at a time, the equil ibrium and mass balance equations yield: 7fV7K + < + <) = 7,"V7 W + „ { ' + n r " ) (2.7) and given the condition that for 1 mole of total mixture n[ + n r / 7 = xT (2.8) equation (2.7) is a simple non-linear equation in one unknown (either n 7 or nj. 1) which needs to be solved for the remaining n - 2 components. Once a l l the n 1 and n 11 vectors Chapter 2. Previous works on phase-splitting 18 are obtained, normalization gives the two in i t i a l estimates x 1 and x 11 assuming phase-splitting of the original l iquid phase of composition x. 2.2.2 Gibbs energy minimization algorithms Gautam and Seider's method In the work presented by Gautam and Seider [19], an algorithm that permits the split of either the vapour or the l iquid phases is introduced. This algorithm is coupled wi th a particular Gibbs energy minimizat ion method (the R a n d method, a Newton-based algorithm), but any other minimizat ion method can be used. Their strategy allows for the assumption of one or more phases and the addition of vapour or l iquid phases as necessary during the equil ibrium calculations so that the system's Gibbs energy is minimized. Given guesses for phase distribution and compositions, the calculation is started using the minimization algorithm. Along the search trajectory an addit ional phase is postulated by splitting the source phase into two or by splitt ing each phase if two are assumed. In this last case, the source phase is selected as the phase which leads to the lowest Gibbs energy after being split into two. If a decrease i n Gibbs energy occurs by splitt ing the source phase, the t r i a l phases replace the source phase and the minimizat ion algorithm is continued. However, since the two tr ia l phases may coalesce after several iterations if the new phase is present i n trace quantity (in which case the decrease i n Gibbs energy is not significant), the phase present i n trace amount is dropped and the split test is repeated for the tr ia l phase having the next lowest Gibbs energy. If an increase i n Gibbs energy is observed when the first phase split is attempted, a few iterations of the minimizat ion algorithm are carried out to permit a decrease. If a decrease is s t i l l not achieved, the calculation is repeated for the next tr ia l phase w i t h the lowest Gibbs energy. If after examining a l l combinations of source and tr ia l phases Chapter 2. Previous works on phase-splitting 19 the phase-split is unsuccessful, the source phase(s) is(are) considered stable. To decide when to attempt the addition of a phase during the search trajectory, a criterion based on a measure of the degree of convergence is given to compute the number of iterations between splitt ing checks. Gautam and Seider assert that their algorithm works well i n the metastable region and that the global min imum i n Gibbs energy was obtained i n every case tested. They also point out a potential pit fal l which could be avoided, but the efficiency of the method would be considerably reduced. The l iabi l i ty arises from the decision to accept the first t r i a l phases that lead to a Gibbs energy reduction i n order to save computer time, rather than examine a l l combinations of source and tr ia l phases. This gives rise to the possibility that the same two tr ia l phases are accepted repeatedly wi th one of them rejected after a certain number of iterations and/or that other tr ia l phases which might lead to a more stable solution (with the least Gibbs energy) are prevented from being considered. For example, starting wi th a l iqu id , i n the phase-splitting test L —> VL —> VL'L'[ —• • • • the sequence delimited by the bracket could be repeated preventing the examination of the t r ia l phases L'L". Other restrictions to the algorithm are that i t is designed to work coupled w i t h a minimizat ion algorithm to obtain equilibrium compositions, but not as a stand-alone method to predict phase- splitt ing prior to the actual equil ibrium calculation. Al so , the approach is based on the assumption that if a solution wi th 7T phases exists, i t has a lower Gibbs energy than a ir — 1 phase solution which Baker et a l . [21] have claimed to be a heuristic rule wi th possible exceptions. Final ly , but not of least importance, is the restriction that the systems tested must contain at least one part ia l ly miscible pair for the algorithm to apply. Despite these drawbacks the phase-splitting part of the algorithm, used to generate i n i t i a l composition estimates for the postulated new phases, has been frequently alluded Chapter 2. Previous works on phase-splitting 20 to i n many phase-splitting methods. For instance, i n a recent paper Walraven and V a n Rompay [20] use a modified Gautam and Seider's splitting algorithm to determine the stability of the l iquid phase and i f unstable propose a short-cut l iquid-l iquid calculation to estimate the equil ibrium compositions. Since it also serves as a basis for one of the ini t ia l izat ion schemes proposed i n Chapter 3, the phase- splitt ing method of Gautam and Seider w i l l be reviewed here. According to these authors the magnitude of the activity of a component i n a mixture is a measure of its tendency to form two phases, so the first step of their splitt ing method is to locate the component wi th the highest act ivity i n the original mixture (identified i n this study as component p). Then a second component (labeled here q) is selected as the one wi th the highest binary activity wi th p, considering a composition proportional to that of the source phase. W h e n forming a new l iquid phase, i f a component is present in large amounts in the source phase and this phase is a l iquid , such a component is bypassed in the selection of p and q. This is done to assure that the l iqu id t r ia l phases are not similar i n composition to any already existing l iquid . W i t h components p and q identified, i f the two tr ia l phases are l iqu id , their compositions x 1 and x11 are determined by solving the equations l lA = l?*? (2-9) « = 7,"*J' (2-10) where x^ = tip/{rip + n ^ ) , xq = n1/(n1 + n 7 ) and similarly for x™ and x*1, 7 being the activity coefficient and np, nq the mole numbers. Equations (2.9) and (2.10) constitute a system of two simultaneous non-linear equations considering that the total number of moles of p and q i n the mixture are known: n p = n 7 -(- n 7 7 and nq — n 7 + n 7 7 . A Chapter 2. Previous works on phase-splitting 21 Newton-Raphson procedure is suggested by Gautam and Seider to solve these equations wi th the physical properties assumed constant over an iteration. If the t r ia l phases are a vapour and a l iquid , the corresponding equations to obtain compositions y and x are yp<j>pP = xplpf°p (2.11) yq<f>qP = xqlqf° (2.12) which are solved making analogous considerations as those described above for equations (2.9) and (2.10). In this case, <j> is the fugacity coefficient, P the pressure and f° the standard state fugacity. The remaining n — 2 chemicals i n the mixture are ordered according to their decreasing binary activity wi th component p. Each of these components, identified by subscript r , is distributed i n turn according to iWr = 7 r " * r J J (2-13) for two l iquid t r ia l phases, where x\ = n$/Xnp+ng+nr) a n < l s imilarly for xj. 1, or according to yr4>rP = xrlrf° (2.14) for a vapour and l iquid t r i a l phases w i t h yT = nj //(n p + + n^) and xr obtained accordingly. Since the total number of moles of each r component is known ( n r = nj.+n1/ Chapter 2. Previous works on phase-splitting 22 or nT = +n^) and those of p and q i n each tr ia l phase can be solved for, equation (2.13) or (2.14) has a single unknown. Aga in i n this case, when forming a new l iquid phase from a l iqu id source phase, any chemical present i n large amounts i n the original l iquid is distributed after the remaining components. Because each component r is distributed leaving the amounts of the previous components fixed, these authors [19] stress that the compositions given by either of equations (2.13) or (2.14) do not correspond to equi l ibrium states. This means that in i t ia l ly the two tr ia l phases may not have a lower Gibbs energy than the source phase, but this is accounted for i n the minimizat ion algorithm. Soares et al.'s method A m o n g the many flash algorithms based on Gibbs energy minimizat ion , the work done by Soares et al.[22] pays special attention to the selection of i n i t i a l guess compositions and flow rates for part ial ly miscible systems. This ini t ia l izat ion scheme, rather than the minimizat ion algorithm, is of particular interest because the total number of phases expected i n the solution need not be specified i n advance and because of the distinctive approach to init ial ize the vapour phase. The method begins by estimating the flow rate and composition of the vapour phase based on calculating the two-phase bubble and dew temperatures (Tg and Tp) of the feed at the specified pressure. Knowing that for T — Tg the vapour flow rate is equal to zero and that for T = To it is equal to the feed flow rate, a linear interpolation is carried out to estimate the vapour flow rate at the specified temperature. Al so , since for T = Tg the vapour composition is the one obtained from the bubble-point calculation and for T = To i t is that of the feed, the composition of the vapour can also be readily obtained by interpolation. Al though not specified by these authors, i t is clear that by doing these saturation calculations the condition where the mixture is a l l vapour (T > To) or where no vapour is present (T < Tg) can be detected at this point. Chapter 2. Previous works on phase-splitting 23 W i t h the estimates of the vapour flow rate and composition, a mass balance leads to the overall l iqu id flow rate and composition guesses. This l iqu id may then be split into two new l iqu id phases using a L L equil ibrium calculation. In order to avoid a t r iv ia l solution i n this calculation, the in i t i a l composition guesses overestimate the separation to be obtained. This is done by assuming a number of l iqu id phases equal to the number of components, considering each phase as being almost a pure component wi th small specified amounts of the other constituents. The number of l iquid phases is eventually reduced as phases wi th equal compositions or zero flow rates are eliminated. The above method is claimed to allow the determination of i n i t i a l composition esti-mates for the different phases which are close to the solution; nevertheless i t has some disadvantages. Since three rigorous phase equil ibrium calculations are required (two satu-ration point calculations and a L L equil ibrium computation) the method lacks the desired efficiency. In addition, the saturation point calculations themselves require composition estimates for the incipient phases as well as in i t i a l guesses for the saturation temper-atures. Methods to provide these estimates are not included as part of the algorithm discussed. Michelsen's method Stabil ity tests which do not require estimates of the number of phases at equil ibrium and that provide compositions of the new phases for unstable systems are presented by Michelsen i n [4] as a preliminary step i n isothermal flash calculations. These tests are based on the tangent plane criterion of Gibbs as put i n theorem form by Baker et a l . [21], who demonstrate that the necessary and sufficient condition for a system to be stable at constant temperature and pressure is that the tangent plane to the Gibbs energy surface at the global composition z should at no other point intersect (lie above) the Gibbs energy Chapter 2. Previous works on phase-splitting 24 surface 3 . The resulting corollary would express that at a given composition a system is unstable i f the tangent plane to the Gibbs energy surface at that point intersects (lies above) the Gibbs energy surface at some other point i n the overall composition range. Baker et a l . [21] indicate that mathematically the solution of the phase equilibria problem can be obtained by finding a plane tangent to the Gibbs energy surface at two or more points which leads to the least value i n Gibbs energy. Such points of tangency correspond to the compositions of the predicted equilibrium phases, being required by the material balance restrictions that the global composition of the system he wi th in the region bounded by these points. Since the slope of the tangent plane corresponds to the components' chemical potentials, this tangent plane criterion is equivalent to that requiring equality of chemical potentials, preservation of the material balance and a state of lowest possible Gibbs energy as the conditions for equil ibrium at the specified temperature and pressure. W i t h this i n mind , Michelsen's stability test can be more easily understood. This test has its foundation on the fact that i f a decrease i n Gibbs energy can not be achieved when a mixture is divided into two phases (formed by removing an infinitesimal amount from the original mixture) , then the mixture is stable. This criterion for stability can be expressed as n F(x) = Xi[ui(x) - fn(z)] > 0 (2.15) «=i for a l l t r ia l compositions x, where fii(z) and Hi(x) are the chemical potentials of compo-nent i at the feed composition and at any other composition and n is the total number of components i n the mixture. 3For binary systems the Gibbs energy surface is a curve and the tangent plane is a straight line; for multicomponent systems the Gibbs energy surface is a hypersurface and the tangent plane corresponds to a hyperplane. Note also that the Gibbs energy of mixing surface can be equivalently used for this analysis. Chapter 2. Previous works on phase-splitting 25 Michelsen asserts that F(x) w i l l be non-negative i f i t is non- negative at a l l stationary points, that is, points where the derivatives of F(x) wi th respect to a l l independent variables equal zero. In terms of fugacity coefficients <^ ,-, the stability criterion can be written i n the form n g{x) = F(x)/RT = Y,Xi[\nxi + In<j>i{x) - hi] > 0 (2.16) t=i where hi = In Zi +In (j>i(z) (2.17) for i = 1 , 2 , . . . , n. The corresponding stationarity criterion is l n x , + In 4>i(x) - hi = k (2.18) Introducing new variables X , = exp(— /c)x,-, this last equation becomes InXi + In <j>i(x) -hi = 0 (2.19) The independent variables Xi can be interpreted as mole numbers wi th corresponding mole fractions Xi = Xi/ X)"=i Xi- Michelsen shows that stationary points are found by solving equation (2.19) and that stability is verified provided that at a l l stationary points g(X) > 0, corresponding to £ " = 1 Xi < 1. Conversely, a phase is unstable if stationary points where g(X) < 0 or 53?=i Xi > 1 can be located. Chapter 2. Previous works on phase-splitting 26 A n equivalent stability criterion to that of equation (2.16), based on variables Xi, is formulated as g*(X) = 1 + Xi[lnXi + In<f>i(x) - hi - 1] > 0 (2.20) i=i where no constraints on Xi except that Xi > 0 are required. Michelsen also shows that the stationary points of g*(X) correspond to those of g(X) and are given by solving equation (2.19). Moreover, since g*(X) is negative at a l l points where g(X) is negative, a negative g*(X) indicates that the system is unstable. Thus, solving for equation (2.19) and obtaining £"= i -X» a r e a l l the necessary calcu-lations required to determine the stability of the system of composition z at constant temperature and pressure. The geometrical interpretation of the stability test corre-sponds to finding the maximum (in absolute value) vertical distances F from the tangent plane (at the feed composition z) to the Gibbs energy surface at any other composition. If any of these distances are found to be negative then the system is unstable, but if a l l .F's are non-negative the system is stable. Therefore, new phases wi l l be found whenever negative min ima i n F are located and the corresponding points wi l l also provide in i t i a l composition estimates for these new phases. These concepts are shown i n Figures 2.4 and 2.5 for a hypothetical binary mixture, where the tangent line to the Gibbs energy is represented by the dotted line. For the case represented i n Figure 2.4 the system is stable at composition z since only non-negative values of F can be obtained. The tangent line intersects the Gibbs energy of mixing curve only at the feed composition and never lies above i t . In Figure 2.5 two minima i n F are found; the tangent line lies above the Gibbs energy of mixing curve and intersects i t at points other than z. The composition of the two incipient phases corresponding to the minima i n F are x' 1 and x'n whereas Chapter 2. Previous works on phase-splitting 27 o z 1 composition (mole fraction) Figure 2.4: Graphical representation of Michelsen's stability test for the case of a stable binary system. the equi l ibr ium values, given by the equil ibrium tangent line (dashed l ine) , are x l and xu. (Note that i n this case the composition of the incipient phases are very close to the actual equi l ibr ium compositions). The methods proposed i n [4] for solving the stationarity condit ion (equation (2.19)) are direct substitution or accelerated direct substitution, where subsequent iterates are de-termined from l n X / f c + 1 ) = hi - ln4k)(x) (2.21) It is stated that direct substitution has linear convergence and that i f the composition dependence of the fugacity coefficients is weak, convergence w i l l be rapid. Acceleration methods such as the General Dominant Eigenvalue M e t h o d (Crowe and Nishio [23]) or Chapter 2. Previous works on phase-splitting 28 Ag/RT o x-/ x/ z x . « x „ ! composition (mole fraction) Figure 2.5: Michelsen's stability test and initial guess compositions for an unstable binary system . Broyden's method (Dennis and More [24]) are recommended but not tested. A min-imizat ion method (Murray [25]) applied to the stability function (equation (2.20)) is also suggested. W h e n direct substitution is used, iterations can be terminated early i n cases where the t r iv ia l solution X = z is approached. After each iteration a convergence variable r is calculated as r = 2g*(X)/8 (2.22) where P = - * . ) ^ ^ = £ ( * . • - Zi)[\nXi + In<f>i{x) - hi] (2.23) •=1  OJii i=l The value of r w i l l approach 1 as X approaches the t r iv ia l solution, so the search is abandoned when |r — 1| < 0.2 and g*(X) < 1 0 - 3 . Michelsen recognizes that except for Chapter 2. Previous works on phase-splitting 29 the case where the t r iv ia l solution X = z is the only min imum i n the modified distance function g*(X), the minimizat ion problem has multiple solutions and thus multiple in i t i a l estimates are necessary to assure that negative min ima are detected. For V L equilibria problems he claims that the in i t i a l estimate is not crucial and essentially i t is only re-quired that the two in i t i a l composition vectors be located on opposite sides of the phase composition z. For hydrocarbon systems the following two sets of i n i t i a l estimates are recommended: Xi = ZiKi (2.24) Xi = Zi/Ki (2.25) where the equil ibrium K factors are approximated by /C = ^ e x p [ 5 . 4 2 ( l - | ^ ) ] (2.26) i n which subscript c indicates the corresponding cr i t ical constant for component i. W h e n the stability of multiphase systems is investigated (or for the case of L L equilibria), the search for an addit ional phase is required and a different in i t ia t ion procedure is suggested. The number of in i t i a l estimates chosen is equal to the number of components and the compositions of the phases are selected as the pure components. It is recommended that instead of converging each in i t i a l estimate i n turn , calculations be done i n parallel for a l l estimates. For each tr ia l phase the value of r is evaluated and iterations are discontinued when r is increasing or when the t r iv ia l solution is approached. If no negative values of g*(X) are encountered after four iterations, only the X vector wi th the smallest value of Chapter 2. Previous works on phase-splitting 30 r is converged; i f this leads to the t r iv i a l solution it is assumed that the system is stable. In spite of having strong thermodynamic foundations and being claimed very reliable at a reasonable computational cost, the method proposed by Michelsen has some weak-nesses. For example, i t is shown that direct substitution converges to a local m i n i m u m of g*(X) and also the init ia l izat ion procedure does not guarantee the detection of a l l negative min imum. Also , init ial izing with the pure components when searching for a multiphase solution may lead to conditions where a pure l iquid does not exist i n which case addit ional procedures must be followed (such as evaluation of fugacity coefficients at lower temperatures or higher pressures to ensure liquid-like properties). Nonetheless, these drawbacks mainly concern the init ia l izat ion step and can be part ia l ly if not total ly ehminated by undertaking more rigorous starting procedures, i n which case the method has advantages that offset these l imitations. For this reason a modified version of this method is incorporated into the phase-splitting algorithm proposed i n this thesis. 2.2.3 M a s s b a l a n c e approaches W u a n d B i s h n o i ' s m e t h o d W u and Bishnoi [26] developed a procedure to determine which phases are present i n three-phase equil ibrium calculations and to generate the appropriate in i t ia l izat ion pa-rameters. They affirm that i t allows the solution of the equil ibrium and mass balance equations (using a Newton-Raphson method) without the difficulties caused by disappear-ing phases. For isobaric-isothermal flash calculations the following strategy is suggested to establish whether three phases exist and to generate in i t i a l values for the unknowns. Initially, a three-phase bubble-point temperature calculation for the feed mixture is exe-cuted. If the specified temperature is less than the bubble-point temperature (T < TB3<J>) Chapter 2. Previous works on phase-splitting 31 the existence of a vapour phase is ruled out. In such a case the l iquid stability test de-veloped by Shah [1] is performed. If only one l iquid is found, the rest of the calculations are skipped. Otherwise, i f the l iquid mixture is unstable, the necessary in i t i a l estimates are available and a l iquid-liquid calculation is carried out. In the case that T > TB34,, a two-phase dew-point temperature calculation is performed. If the specified temperature is larger than the dew- point temperature (T > Tp) only a vapour phase can exist and the calculation ends. O n the contrary, i f T < To, a V L flash calculation is proposed to generate new vapour and l iquid phases V and U. The stability of the vapour V is tested by doing an isothermal flash calculation for the V mixture. If no l iquid is generated, V is stable. Otherwise the vapour V is unstable and new vapour V" and l iquid L" phases are generated. Then a L L equil ibrium calculation is done for the l iquid mixture U" obtained by combining U and L". If the l iquid L'" is stable (claimed possible only when L" = 0 and L' is stable), the solution is V L equil ibrium and the flash calculation is completed. If L'" is unstable, the amounts and compositions of the vapour and the two l iqu id phases are used as in i t i a l values for the three-phase flash. In their calculations, these authors find that both or either of the vapour V and the l iquid L' can be unstable and hence the necessity for the stability tests on both of these phases. The procedure described above, although straight-forward, can be very inefficient since i t constitutes a 'brute-force' method to determine the number and type of phases expected at equil ibrium. For instance, when the stable solution is V L L equil ibrium, a tota l of five rigorous equilibrium calculations (two saturation-point determinations, two V L flashes and a L L equilibrium calculation) are required prior to the actual three-phase flash. For a V L stable solution these same five calculations could be needed to obtain the equi l ibrium conditions. Clearly, the practical use of such an algorithm is l imited since i t would be too time consuming to be used i n a process simulator on a routine basis. Chapter 2. Previous works on phase-splitting 32 Nelson's method The multiphase flash algorithm presented by Nelson [3] is based on the solution of the mass balance and equil ibrium equations using a Newton-Raphson technique and has two features that make it attractive to this work. First , particular attention is given to the arrangement of the system of non-linear equations to be solved i n order to make them more suitable for solution by the Newton-Raphson method. The resulting equations are of the Rachford-Rice type (for a more thorough treatment on this particular subject see for example Ohanomah's [27] work) and are very similar to those developed i n indepen-dent form for the flash algorithms used i n this thesis (see Appendix A ) . Secondly, the method in i t ia l ly assumes the presence of three phases (two liquids and a vapour) but the determination of the actual number of phases present, based on the so-called bubble-and dew-point criteria, is incorporated into the flash algorithm. Therefore the presence of only one or two phases is quickly recognized. Defining the V L equil ibrium constants as Kn = yi/xf and K& = Vi/x*1, and the phase ratios as ipi — Li/F and V>2 = LJI/F where z, x1, x11, F, Li and L / j are the compositions and total moles of feed, of l iquid phase / and of l iquid phase 77 respectively, and y is the composition of the vapour, the working equations for three-phase calculations derived by Nelson from the mass balance and equilibrium conditions are w , , * ) - ± K a K a + - « , ) - ° < 2 2 8 ) which are well suited for numerical solution to obtain xp\ and ^2 since they contain no superfluous roots i n the domain of interest (0 < tpi < 1 and 0 < yj2 < ! ) • These Chapter 2. Previous works on phase-splitting 33 equations are solved holding Kn and K& fixed using a Newton-Raphson procedure with the required part ia l derivatives evaluated analytically. It is shown i n [3] that criteria to determine the number of phases at equil ibrium can be derived based on the bubble- and dew-point type of equations obtained by examining the behaviour of equations (2.27) and (2.28) at the l imi t ing cases where only one or two phases exist. These criteria apply under circumstances that Nelson defines as " n o r m a l " , that is, where the functions Qi, Q2 and Q\ — Q2 behave i n such a way that i n the three- phase region the following relations are satisfied: X ) " = 1 z,Kn > 1, 2~^ "=i  Zi/Kn > 1> E"=i*.-tf.-2 > 1, £ ? = i 2 , - / # « > 1, £ " = ! ZiKn/Ka > 1 and £ "= i z . / W ^ . i > 1. The criteria for the existence of two phases are summarized as follows: 1. Only vapour and l iquid phase I exist i f Yl?=i  ziKn > 1> !C"=i  Zi/Kn > 1 and #2(^1,0) < 0 at the root of Qi(^i,0) = 0; 2. Only vapour and l iquid phase II exist i f J2?=i  zi^i2 > 1, Y£=i zi/Ki2 > 1 and Qi(0, ip2) < 0 at the root of Q2(0, ^2) = 0; 3. Only l iquid I and l iquid II exist i f £ ? = 1 ZiK^/Kx > 1, J2?=i ZiK^/Kn > 1 and Qityu 1 - ^1) > 0 or Q 2 (^i , 1 - V>i) > 0 at the root of 1 - ^1) - £ 2 ( ^ 1 , 1 -V>i) = 0. Nelson demonstrates that no more than one of the above two-phase tests can be satisfied at one time. The criteria for the existence of only one phase are: 1. O n l y the vapour phase exists i f YA=1 Zi/Kn < 1 and £ " = 1 Z{jK{2 < 1; 2. Only l iquid phase I exists i f J2?=\  zd<-i\ < 1 and £ " = 1 Zi/Ki2 < 1; 3. Only l iquid phase II exists i f J2?=i ziKi2 < 1 and £ " = 1 Zi/Kn < 1. Chapter 2. Previous works on phase-splitting 34 Since the tests for the existence of two phases require a 1- dimensional iterative search, i t is recommended to conduct them after the one-phase tests are completed. Nelson stresses that the compositions for a l l three phases should be calculated even when only one or two phases are present. The reason given for this is that "the calculation of a TAT-value ordinari ly requires the composition of both l iquid and vapour phases so these must be provided even if one or both of these phases do not exist" . Thus , when convergence is achieved i n the inner Newton-Raphson iteration loop (to solve for xpi and xp2) wi th a given set of K-values, these are reevaluated i n an outer loop at the new-found compositions and the three-phase flash is continued. This procedure is repeated unt i l compositions and ./Y-values converge to a pre- specified degree of accuracy. Al though Nelson recognizes the importance of detecting the presence of only one or two phases i n a potential three-phase system, the method described above suggests that non-existing phases should not be eliminated but carried along the computation. This is justified for the case where i t is determined that only two phases are present by stating that the phase ratios are already at hand from the 1-D iterative search procedure (in the two-phase existence test) and that only the phase compositions remain to be calculated. Nonetheless, i n this scheme the recognition of the correct number of phases seems of small significance since a three-phase calculation is performed irrespective of the phases predicted by the proposed criteria. Another l imita t ion of the method is that the criteria to test for the existence of one or two phases are subject to the assumption of three phases being present under the "normal " conditions described above. No actions are suggested when these conditions are violated and the circumstances leading to their violat ion are not specified. Chapter 3 Proposed algorithm After reviewing the main phase-splitting methods presented i n Chapter 2, it can be concluded that most of them seem inadequate to fulfill the objectives of this work, namely provide a phase- splitt ing algorithm which can accurately and efficiently: 1. Predict the number and type of phases formed at equil ibrium by a multicompo-nent system at a specified temperature, pressure and overall composition without performing a flash calculation. 2. Provide composition estimates for the phases present in order to init iate the flash calculation when required. Wi thout doubt, Michelsen's stability analysis [4] is the method that most closely appears to satisfy these objectives. Because of this and since i t has other desirable features, i t was decided to incorporate i t into the algorithm proposed i n this thesis. In spite of appearing very robust at first instance, when Michelsen's method was implemented i n the algorithm to be discussed, drawbacks other than the ones mentioned i n Section 2.2.2 became evident. This lead to several proposed modifications of the original Michelsen method which exploit its advantages and attempt to eliminate its pitfalls. Basically the flaws found are that under certain circumstances the tangent plane criterion is unable to detect an incipient phase which is present at equil ibrium and i n other cases a superfluous t r i a l phase not corresponding to the equil ibrium solution may be found. These problems and the solutions proposed to avoid them are discussed i n more detail i n the following 35 Chapter 3. Proposed algorithm 36 sections. 3.1 General scheme The following scheme is used i n the phase-splitting algorithm developed i n this work (a more detailed description of the procedure i n step by step form is given next). Initially, i t is established whether the multicomponent mixture considered as a monophasic system is l iquid-like or vapour-like at the specified temperature, pressure and overall composition, depending on which state has a lower Gibbs energy. Then , a phase search is conducted based on an improved version of Michelsen's stability analysis, that is, incipient phases are sought i n order to minimize the system's Gibbs energy by splitt ing i t into two or three phases. If no incipient phases are detected the calculation terminates and the system is declared stable as a single phase (either as a vapour or as a l iquid depending on whether the original system was found to be vapour-like or l iquid-like). W h e n only one incipient phase is found, i t is assumed that the stable system is i n the two phase region (with phases corresponding to the incipient phase and the monophasic system) and then the appropriate flash calculation can be conducted. If two incipient phases are detected, then depending on the nature of these and of the in i t i a l monophasic system, a two or three-phase solution is postulated as described below. For the case that three incipient phases are found (possible only if the original system is liquid-like as w i l l be seen) a three-phase solution is assumed. In a l l instances where a V L L (three-phase) solution is feasible, a phase removal test is conducted to assure that three phases are present at equil ibrium. This test, which allows dropping any superfluous phase found i n the search, can be done based on the criteria to reduce the number of phases i n flash calculations developed i n [5], on Nelson's bubble- and dew-point equations approach [3] or using a coupled method suggested i n this work. Chapter 3. Proposed algorithm 37 Phase-splitting algorithm The phase-splitting algorithm developed consists of the following steps: 1. A t the given temperature, pressure and global composition, the Gibbs energy of mix ing of the system is calculated considering i t as a homogeneous vapour and as a homogeneous l iquid . The original system (source phase) is considered either vapour- like or liquid-like depending on which of the hypothetical homogeneous systems has a lower Gibbs energy of mixing. If the system is vapour-like, Step 8 is executed, otherwise Step 2 follows. 2. T h e system is liquid-like. Using the phase-search algorithm described i n Section 3.2.1 (modified Michelsen method), a vapour t r ia l phase is searched. If the search fails, a stable vapour phase may not exist, however i t could have been missed because of the l imitations i n Michelsen's algorithm (this is i l lustrated and discussed i n Section 3.2). Irrespective of the outcome of this search, the next step is followed. 3. One or more incipient l iquid phases (originated from the liquid-like system) are sought using the phase-search procedure described i n Section 3.2.2. If no vapour phase was found i n Step 2, Step 6 is executed. 4. If no l iqu id t r i a l phases were found i n the previous step, then the system can be assumed stable as a V L mixture (since an incipient vapour has been found). However, because an incipient l iquid may have been overlooked i n the original search (modified Michelsen's method), an additional search can be conducted (this optional search is also described i n Section 3.2.2). If s t i l l a new l iqu id is not found, i t is considered that the system is stable as V L . A t this point the phase-splitting calculation ends and a V L flash can be carried out wi th in i t i a l compositions of the vapour being y = y' and of the l iquid x — z (where the prime indicates the Chapter 3. Proposed algorithm ,38 composition of the incipient phase found). If an incipient l iquid phase is detected i n the additional search, then the system is potentially a three-phase mixture (with in i t i a l compositions y = y', x1 = x' and x11 = z) and a phase removal test is conducted as indicated i n Section 3.4 to determine whether the system is stable as V L , L L or V L L . Then the corresponding flash calculation can be performed. 5. If one or two' incipient l iquid phases are detected using the modified Michelsen method (Step 3), the system can form three phases (with in i t i a l compositions x1 = x', x11 = z or x1 — x'1, x11 = x'n and y — y') and any of the phase el imination tests proposed can be conducted to determine the configuration of the system. The phase-splitting calculation terminates here and again the corresponding flash can be executed to determine the equil ibrium compositions and phase ratios. 6. No incipient vapour phase exists for the liquid-like system. If no l iquid tr ia l phases could be found i n Step 3, then the original system is stable as a l iquid and no further calculations are required. 7. If one or two l iquid tr ia l phases were found (in Step 3) the system can be assumed stable as L L . However, the possibility of existence of a vapour which may have been missed i n the search can be checked (optional) by carrying out an additional search (see Section 3.3.1). If no incipient vapour is found after this more thorough search, the stable solution is considered to be a L L mixture wi th starting compositions x1 = x' and x11 = z or x1 — x'1 and x11 = x'11. A t this point the calculation ends and the two-phase flash can be performed, except if i n the additional search a vapour phase is detected. In this case a phase removal test is again executed to determine the stable system and the corresponding flash can then be conducted. Chapter 3. Proposed algorithm 39 8. The system is vapour-like. One or more l iquid tr ia l phases are looked for using the modified Michelsen phase search. If incipient l iquid phases are not found, the system is stable as a vapour and the calculation ends. 9. If only one l iquid is found i n the previous step, the system can be assumed stable as a V L mixture. In this case a second incipient l iquid may have been missed i n the in i t i a l search, thus an additional search may also be conducted. If a new l iquid t r ia l phase is not found, the system is considered stable as V L having in i t i a l compositions y = z, x = x' and the calculation ends. A two-phase flash may then follow to obtain the equil ibrium compositions and phase fraction. However, i f a new l iqu id t r ia l phase is obtained i n the additional search, the stable solution among the possible V L , L L or V L L solutions is determined wi th the phase number reduction method chosen (Section 3.4) starting wi th y — z, x 1 = x' 1 and x 11 = x' u and afterwards the flash calculation can be conducted. 10. If two incipient l iquid phases were found i n Step 8, again it is possible to have either a two or three-phase solution at equilibrium. The phase removal test is then performed (with the same starting values as above) to determine the configuration of the system followed by the specific type of flash calculation i f required. The flow chart representing the phase-splitting algorithm just described is depicted i n Figure 3.6. Some important aspects considered when implementing the algorithm just seen, other than the phase search strategy and the phase removal tests, are described next. Through-out this work, the molar Gibbs energy of mixing rather than just the molar Gibbs energy is used i n the calculations since the former property gives a measure of the deviation of the system's condition from ideality. This can be seen when considering the definition of the molar Gibbs energy of mixing for a homogeneous multicomponent phase at fixed Chapter 3. Proposed algorithm Obtain a g v «nd a g L » t the specified T, P and z Vapour-like system Search for liquid trial phases 1 Liquid-like system Search tor a vapour trial phase Search lor liquid trial phases Stable system as V Stable system as VL 2-phase Hash Stable system as VL 2-phase Hash Phase removal test to determine a VL. LL or VLL solution Stable system as L Stable solution as LL 2 or 3-phase flash 2-phase flash Figure 3.6: Flow chart of the phase-splitting algorithm proposed in this work. Chapter 3. Proposed algorithm 41 temperature and pressure, which is the mixture's molar Gibbs energy g less the mole fraction weighted sum of the pure components Gibbs energies p,-: n n A<7 = 9 - £ zi9i = RTYs Zi I n ( 3 - 2 9 ) i=i t=i where z,- represents the global composition of each component and a, its activity i n the mixture. W h e n an equation of state is used to represent the properties of both the vapour and l iqu id phases, the activity can be expressed for either phase as f^^zjhP ft 4>1P°  K ) where 2,- is the composition of the corresponding phase (either a vapour or a l iquid) ; fi and (f>i are the fugacity and fugacity coefficients of component i at the given T , P and composition. Variables wi th a hat ' A ' indicate the property i n the mixture and superscript indicates the property i n the standard state. As Walas [28] points out, i n order to take advantage of the requirement of equality of fugacities of individual components i n a l l phases at equi l ibrium, the standard states of condensed and vapour phases must be consistent. Equal ly , when a Gibbs energy analysis is done to determine equil ibrium states, consistency i n the standard states must be observed. Since equation (3.29) is obtained for isothermal conditions, the standard state temperature must be the same as that of the mixture, but the pressure and composition of the standard state are arbitrary. Because cubic equations of state can represent continuity of states, the same standard state can be chosen for the vapour and l iquid phases. The most convenient one for the fugacity is the fugacity of the pure component i n the vapour phase at a pressure of one atmosphere. This gives the advantage of consistency and ease of evaluation since the values of <f>Y are Chapter 3. Proposed algorithm 42 generally unity at 1 a tm. Considering that the reference state is arbitrary, even i f <f>Y is different from one (for example for components that associate i n the vapour phase), the value of ff is set to 1 a tm. Taking this into account, for the vapour phase equation (3.30) reduces to y = y_i$P_ ( 3 3 1 ) I atm v ' and for the l iquid phase i t can be expressed as In short, the dimensionless molar Gibbs energy of mix ing is calculated as Agv/RT = J2 Vi Hvi$(T, P, y)P(atm)] (3.33) for the vapour phase and as n AgL/RT = £ Xi l n [ x , ^ f ( T , P , x)P(atm)] (3.34) i=i for the condensed phases. To obtain the fugacity coefficients, either the Soave-Redlich-Kwong or the Peng-Robinson equations of state are used i n this work. If three real density roots are found when solving for the cubic equation, the evaluation of the fugacity coefficients for the vapour and l iquid phases is done using respectively the vapour-like and the liquid-like roots. If at the specified conditions only one real density root exists, this root is used for Chapter 3. Proposed algorithm 43 the corresponding phase and an extrapolated value of density is used for the phase that is infeasible as indicated i n [5] (also described in [10]). This extrapolation algorithm has been used very successfully i n this work to avoid the so called ' t r iv ia l solution' i n the calculation of the density roots. It should be mentioned that i n these cubic equations the classical mix ing rules (allowing the use of binary interaction coefficients) are used wi th the modifications proposed by Mathias [9] to include polar compounds and supercritical components. 3.2 Phase search strategy Before going into the details of the search strategy for the vapour and l iqu id phases, flaws i n the detection of incipient phases when using Michelsen's method under certain circumstances w i l l be addressed. Specifically, failure to correctly predict the phases at equi l ibrium may occur when three potential phases exist and the tangent plane criterion is unable to detect one of the incipient phases for a range of feed compositions. These flaws, which are not foreseen by Michelsen, are shown here graphically for the case of binary mixtures but are l ikely to happen i n multicomponent systems. Three cases where Michelsen's method is prone to failure are expected when incorpo-rated into the phase-splitting algorithm proposed. These are (refer to the general scheme described earlier): i) when the system is vapour-like and one l iquid is found, another incipient l iquid could have been bypassed; ii) when the system is liquid-like and one or two incipient l iquid phases are found but no vapour is detected, a vapour phase may have been missed, and iii) when the system is liquid-like, no incipient liquids are detected and a tr ia l vapour Chapter 3. Proposed algorithm 44 is found, a l iquid tr ia l phase may have been bypassed. In order to eliminate these failures, an optional additional search is suggested i n this work to detect possibly missed phases. Figure 3.7 shows the Gibbs energy of mixing for a binary mixture of water and n-hexane as obtained by Heidemann [29] which can be used to exemplify case i ) . A t the feed composition the system is vapour-like and the tangent line to the Gibbs energy curve at this point (dotted line) indicates the presence of one incipient l iquid phase (corresponding to a negative min imum F ) . Hence, a V L solution would be predicted using the tangent plane criterion since only one incipient l iquid is found from the vapour- l ike source phase (the n-hexane rich l iquid phase is bypassed). However, the stable solution is that of a L L mixture as indicated by the lower dashed line since i n this state a m i n i m u m i n Gibbs energy is achieved. It should be noted that failure to detect the n-hexane rich phase can occur for a wide range of feed compositions, not only i n the v ic ini ty of the point z considered. In Figure 3.8 case ii) is shown for a hypothetical mixture which is l iquid-like at the feed composition z. Aga in i n this case Michelsen's method indicates the presence of one incipient l iqu id phase. Due to the slope of the tangent line (dotted line) to the Gibbs energy curve at z, a vapour incipient phase is missed i n the phase search. This would lead to the prediction of a L L solution instead of the more stable V L solution which has a lower Gibbs energy. In this case the vapour incipient phase is bypassed only for feed compositions i n the vicinity of point z. Although no graphical representation for case i i i ) could be depicted for a binary sys-tem, evidence of failure under the conditions corresponding to this case was found i n calculations performed for mul t i component systems. The addit ional phase search method proposed is intended to find phases which may Chapter 3. Proposed algorithm 45 Ag/RT \ L . . - V L / . . - - - - " L L I- " S = " ' " 0 Z 1 mole fraction n-hexane Figure 3.7: Erroneous prediction of VL equilibrium due to bypass of a liquid incipient phase when using Michelsen's method for the n-hexane-water system at 378 K and 4-08 atm (diagram modified from Heidemann). o z 1 composition (mole fraction) Figure 3.8: Bypass of a vapour incipient phase when using the tangent plane criterion leading to an incorrect LL equilibrium prediction in a hypothetical binary mixture. Chapter 3. Proposed algorithm 46 o z 1 mole fraction n-hexane Figure 3.9: Additional phase search to find the n-hexane rich liquid incipient phase for the n-hexane-water system (378 K and 4-08 atm) leading to the correct prediction of LL equilibria. have been bypassed i n the in i t i a l search. Because a more thorough search i n not always required or may not be desired by the user, i t is left as an option i n the overall algorithm. T h e rationale behind the method is that after the modified Michelsen search is completed, whenever cases i) to i i i ) occur, a pseudo- tangent plane is constructed and used wi th the tangent plane criterion i n the same fashion as the actual tangent plane but only to search for a specific phase. For binary systems this additional search can again be il lustrated graphically for cases i) and ii) described above. In the former case, the l iqu id tr ia l phase found i n the in i t i a l search and the feed point are used to obtain the slope of the line connecting them which characterizes the pseudo- tangent line used for the additional l iqu id phase search as illustrated i n Figure 3.9. This figure shows how a value of F < 0 is obtained when considering the pseudo-tangent line which allows the n-hexane rich phase missed i n Figure 3.7 to be found, leading to the correct prediction of L L equilibria. For case i i ) when i n the in i t i a l search only one l iquid incipient phase is obtained this and Chapter 3. Proposed algorithm 47 o z 1 composition (mole fraction) Figure 3.10: Detection of an incipient vapour phase by means of the additional search proposed for the binary mixture of Figure 3.8 leading to the proper prediction of a VL stable system. the l iquid-like feed point are used to construct the pseudo-tangent line. Thi s is shown i n Figure 3.10 i n which the vapour phase missed wi th Michelsen's method (see Figure 3.8) can be found thanks to the additional search strategy giving the correct prediction of a V L stable system. W h e n two incipient liquids are found i n the in i t i a l search for case ii) these points are used to construct the pseudo-tangent line needed to look for the possibly missed vapour phase (although not illustrated this case is very similar to that shown i n Figure 3.10) A similar approach is used for case i i i ) but i n this instance the points required for the pseudo-tangent l ine are the liquid-like feed and the vapour t r ia l phase already found in order to search for an incipient l iquid. A l t h o u g h the pseudo-tangent method was found to work quite well for the additional phase search i n binary mixtures, a direct upgrading for systems w i t h three or more components could not be made since the multi-dimensionality of the problem did not Chapter 3. Proposed algorithm 48 allow a successful analogous approach. For binary systems the feed point and the point corresponding to the incipient phase found (cases i) to i i i )) or the two incipient liquids (case ii)) define the pseudo-tangent line required i n the additional phase search method proposed. For multicomponent mixtures (n > 3) the orientation of the pseudo- tangent plane or hyperplane can not be defined wi th only two points since an infinite number of planes can pass through them. To overcome this problem, a variat ion i n the two component method was devised i n which a pseudo-tangent plane orthogonal to the Gibbs energy of mix ing axis is always used i n the additional search. This variation, which can be visualized for ternary systems as having a pseudo-tangent plane parallel to the composition plane i n a 3-D Ag versus mole fraction diagram, worked satisfactorily i n many cases but i n others i t d id not aid decisively to find new phases. The implementation of the addit ional phase search (for binary and higher systems) is described i n Section 3.2.1 when searching for a vapour (case ii)) and i n Section 3.2.2 when searching for a l iquid (cases i) and i i i ) ) . Another aspect regarding the phase search strategy which should be mentioned here is the numerical method used (in the modified Michelsen method) to solve for the mole numbers of the incipient phases from the stationarity condition (equation 2.19). As Michelsen [4] suggests, direct substitution or accelerated direct substitution are the ob-vious candidates to solve for this equation since i t is well suited for these methods when arranged i n the form of equation 2.21. According to h i m , when using direct substitution the approach to the solution w i l l be rapid if the dependence of the fugacity coefficients on composition is weak since the method has a linear rate of convergence. Because the calculations performed when L L or V L L equil ibrium is involved imply highly non-ideal systems (in which fugacity coefficients are strongly dependent on composition), i t is expected that convergence w i l l be slow if direct substitution is used. This calls for Chapter 3. Proposed algorithm 49 acceleration methods wi th faster convergence rates that do not require excessive com-putational effort. In their evaluation of Michelsen's method i n L L calculations, Swank and Mul l ins [30] find that the most efficient method to accelerate the direct i teration calculation is the Newton-Raphson method when compared to the General Dominant Eigenvalue method ( G D E ) [23] and to Broyden's method [24]. They recommend a direct iteration scheme accelerated wi th the G D E method and the Newton-Raphson method for a maximum of 15 iterations. For final convergence the use of a Gibbs energy minimiza-tion wi th Murray ' s method [25] is suggested after 15 iterations. Murray ' s minimizat ion of the Gibbs energy is recommended for every iteration i f greater reliabil ity is required but at the sacrifice of speed. A n efficient method for accelerated direct substitution not considered i n [30], which does not require gradient information, is Wegstein's method [31]. It has been shown i n [5] that this method has good convergence characteristics when used to solve for equi-l ibr ium compositions i n flash and saturation point calculations wi th a min imal added computational load. Given its desirable features to accelerate compositions as indepen-dent variables and since the objective function (equation 2.21) is well suited for its use (i.e. is of the form x = /(#)), Wegstein's method is the numerical method chosen i n the modified Michelsen's phase search. 3.2.1 Vapour phase search The objective of the vapour phase search method proposed as part of the phase-splitting algorithm described earlier is to find the vapour composition y that satisfies the station-arity condition (analogous to equation (2.19)): \nYi+ln]>Y(y)-hf = 0 (3.35) Chapter 3. Proposed algorithm 50 for i = 1,2,... , n , where n is the number of components i n the mixture. The steps of the proposed search method are: Modified Michelsen's method. Vapour phase search 1. G iven composition estimates for the incipient vapour to be searched, the in i t i a l values of the mole number variables Y{ (independent variables) are set to Y^ = y^ = yiinu (3.36) and parameters exp(/if) are obtained as exp(hf) = z4f(z) (3.37) where (z) is the fugacity coefficient of i for the system as a l iqu id at the feed composition (already obtained for the liquid-like system by taking £ , = z, when evaluating Ag L/RT from equation (3.34)). 2. F rom the chosen equation of state the fugacity coefficients <f>\0^ = <^ 0^(T, P , y^) are obtained and variables are calculated as (refer to equation (2.21)) i f > = exp(hf - ln * i °> ) = exp(A? ) / ^ | 0 ) = f(Y^) (3.38) Chapter 3. Proposed algorithm 51 3. The corresponding vapour compositions are calculated by normalization of the mole numbers: 1 i vP = (3-39) and the values of <f>^ are obtained wi th these compositions from the equation of state. B y direct substitution the updated mole numbers are calculated as i f U e x p ^ f ) / ^ / ^ 1 ) ) (3.40) 4. S t a r t o f t h e i t e r a t i v e c y c l e . If conditions are met to use Wegstein's method, new values of Y±k+1^ are obtained from Y?k+1) = (1 - ti)Ylk) + tif{Y±k)) (3.41) where k indicates the iteration number (fc=l,2, . . . ,kmax) and t,, the step size pa-rameter, is calculated as U = ^— (3.42) 1 - S; with Chapter 3. Proposed algorithm 52 y(fc) _ y(k-l) V-^l The values of £, obtained are l imited i n such a way that t, = tmax when rj, > tmax and t{ — tmax i f tj *C tmax. If direct substitution is used (i.e. t, is set to 1 for every component) then y.(*+i) = / ( F . W ) (3.44) 5. The new compositions are obtained as and the corresponding fugacity coefficients are calculated from the equation of state: ^*+1) = ^(*+1)(r Jp,y(*+1)). 6. The objective function is then evaluated S(Yi) = £ | V ; ( f c + 1 ) - Y{k)\ (3.46) t=i as wel l as parameters g*, 8 and r : 4* = 1 + ^Y^ +1)(lnY^ +1) + l n # + 1 ) - / i f - 1) (3.47) 1=1 Chapter 3. Proposed algorithm 53 n P = £ ( > f + 1 ) - * , ) ( l n * f + 1 ) + l n # + 1 ) - hf) (3.48) r = 2g*/B (3.49) 7. To monitor the unsuccessful convergence behaviour of the method, the following checks are made: (a) Check for convergence of the current composition vector to the feed composi-t ion, i.e. check i f is approaching z. (b) Check if the value of r is approaching 1 i n consecutive iterations. (c) Check if Yl"=i l ^ f c + 1 ^ , when < 1, is decreasing i n consecutive iterations. (d) Check if the objective function 9(YJ) is increasing i n consecutive iterations. (e) Check if g*, when < 0, is not changing significantly i n consecutive iterations. (f) Check i f the objective function increases after using Wegstein's method. If so, the acceleration method is used less frequently unt i l the objective function decreases again after applying i t . 8. Test for convergence either to a min imum i n Gibbs energy or to the tr iv ia l solution: -Convergence to a min imum i n Gibbs energy. If 5(1; ) < e or i f check (e) is satisfied, convergence has been achieved and Step 10 is executed. Chapter 3. Proposed algorithm 54 -Convergence to the t r iv ia l solution. If |r - 1| < 0.2 and g* < 1 0 - 3 or i f check (a) is satisfied or if any of checks (b) through (d) are met i n two consecutive iterations, Step 11 is carried out. If none of the above tests are satisfied, the method continues i n the next step. 9. The functions / ( i f + 1 > ) = e x p ^ f (3.50) are calculated and the variables for the next iterative loop are assigned by setting k = k + 1. Ii k < kmax Step 4 is executed, otherwise convergence has failed and Step 12 is performed. 10. If J2i=i i f > 1 (or equivalently g* < 0) a stationary point corresponding to an incipient vapour wi th composition has been found. This means that the original system (liquid-like) is unstable and the appearance of the t r i a l vapour phase decreases the Gibbs energy of the global system. If ]£!Li i f < 1 (corresponding to g* > 0) no vapour phase has been found i n the search and the original system is stable wi th respect to the formation of an incipient vapour. 11. The t r iv ia l solution i n which y = z has been found or no solution to equation (3.35) could be obtained. In either case i t is considered that the search is unsuccessful, i.e. no incipient vapour could be found and a split of the original system into a V L system does not occur. 12. The max imum number of iterations allowed has been reached forcing the calculation to end. In spite of not having reached convergence, i f the current composition Chapter 3. Proposed algorithm 55 values for the vapour t r ia l phase are such that Y^k+l^ > 1 i t is considered that an incipient vapour has been found. If this condition is not met, the search is designated unsuccessful. Additional vapour phase search W h e n the system is l iquid-like and one or two l iquid phases are detected i n the phase-splitt ing algorithm but no vapour is found when applying the phase search method just seen, an addit ional search may be conducted to check for the presence of an incipient vapour (case i i ) ) . For binary systems, the slope of the pseudo-tangent line needed for the proposed additional search (see Figure 3.10) is obtained according to: dAg = AgL(z) - AgL(x') dzi Zi — x\ when this line passes through the feed point and the one incipient l iquid found or from dAg AgL(x'H) - AgL{x' 1) dzi x\ 11 - x'f (3.52) when two incipient l iquid phases wi th compositions x' 1 and x'n have been found. This slope can be used to calculate a pseudo-chemical potential of mix ing Ap^. from the following thermodynamic relation (from Walas [20], equations (2.56), (2.65) and (7.4)): A # = A^(z) - ( ^ ) (3.53) k^i \  k J Zj^iik which i n turn is needed to obtain a pseudo-fugacity coefficient at the feed composition Chapter 3. Proposed algorithm 56 denned as AuL l n # ( * ) = - ^ - M * . - P ) (3.54) W i t h this variable a pseudo-parameter h^. analogous to hi (see equation (2.17)) can be obtained from fc£=ln*,- + l n # ; ( z ) ' (3.55) B y combining equations (3.54) and (3.55) h^. can be expressed as AuL hLPi = ^*--lnP (3.56) Once h^. has been calculated, the additional vapour phase search can be conducted by using the same search method described above but substituting exp ( / i f ) for exp(/ip.) i n a l l instances. For systems having 3 or more components the slope of the pseudo- tangent plane i n a l l directions is set to zero: ^ = 0 (3.57) ozi and because of this condition equation (3.53) reduces to A / £ = AgL{z) (3.58) Chapter 3. Proposed algorithm 57 Consequently, h^. can be easily obtained as &9L{z) RT - I n P (3.59) for a l l components. Aga in exp(hp.) is used instead of exp(h^) to conduct the additional search. 3.2.2 L i q u i d phases s ea rch W h e n searching for one or two l iquid phases wi th the phase- splitting algorithm proposed, i t is the l iqu id compositions x that satisfy the following stationarity conditions (equivalent to equation (2.19)) that are sought: if it is vapour-like. The l iquid phase search algorithm is similar to the one already de-scribed for the vapour. One of the major differences is that because i n the l iquid search at least two distinct l iquid phases are sought simultaneously, more than one composition vector is required i n the calculations. Thus, instead of having a single vector of n compo-nents, an array of m in i t i a l composition vectors is used i n the search. As the calculation proceeds the number of vectors can be reduced if required such that a max imum of two ]nXi + ]n^{x)- hf = 0 (3.60) when the original system is l iquid-like and l n X , + l n < £ f ( x ) - hY = 0 (3.61) Chapter 3. Proposed algorithm 58 vectors are considered for final convergence. The steps of the proposed search method are: Modified Michelsen's method. Liquid phases search 1. Having the array of l iquid composition estimates, the starting values of the mole number variables X, ) t - are assigned as XW = x?J = XKinit (3.62) where subscript j indicates the vector number (j — 1,2,..., ra) and subscript i the component index (i = 1,2, . . . , n ) . Then the parameters exp(Af) or exp(hY) are obtained as e x p ^ f ) = z$(z) (3.63) or as e x p ( ^ ) = z^Y(z) (3.64) depending on whether the system is liquid-like or vapour-like (for simplicity, in either case these parameters w i l l be written as exp(/i,)). The values of ^(z) and (j>Y(z) are at hand since they are required to evaluate equations (3.33) and (3.34) at the feed composition (Step 1 in the phase-splitting algorithm). Chapter 3. Proposed algorithm 59 2. The fugacity coefficients <f>^} = <j)j\°\T, P , x ^ ) are evaluated from the equation of state and the mole numbers X^} are calculated according to: 4 V = exp(fc.- - In $ ) ) = e x p ^ O M ? = f(X$) (3.65) 3. The new l iquid compositions are calculated by normalizat ion of the mole numbers: yW * W =  j' { ( 1 ) (3.66) and the corresponding fugacity coefficients <j>^} are evaluated. Using direct substi-tut ion, the updated mole numbers are calculated as X g > = exp(fc,-)/$) = / ( 4 V ) (3-67) 4. Start of the iterative cycle. If the necessary conditions are met to use Wegstein's method, accelerated compositions Xjk+1^ are obtained as where indicates the iteration number (k — 1, 2,... , /c m a x ) and parameters <Jt- are calculated as Chapter 3. Proposed algorithm 60 = r r — (3-69) with f(xV)-f(xt 1]) ( 3 7 Q ) The values of tjj are l imited i n such a way that i^,- = tmax i f tj)t- > i m a x and tjti — tmax d tj,i *~ tmax-W h e n direct substitution is used then the updated mole numbers are obtained as A - g + 1 ) = / ( * £ > ) (3.71) 5. The new mole fraction compositions are obtained according to y-(fc+l) (fc+i) _ co 7 2 \ and the corresponding fugacity coefficients are obtained from the equation of state: ^ • + 1 ) = ^ + 1 ) ( T , P , x f + 1 ) ) . 6. The objective functions are evaluated for each composition vector *i(x*)=ib\ xi? i)-x$i )\ (3-73) i=i Chapter 3. Proposed algorithm 61 as well as parameters gf, 8j and ry. 9j = 1 + E 4 " + 1 ) ( l n 4 " + 1 ) + l n <^S + 1 ) - k - 1) (3-74) «=i ft = £ ( 4 * + 1 ) - + l n - M (3-75) «=i r; = (3.76) 7. The unsuccessful convergence behaviour of the method is monitored by doing the following checks on every composition vector j: (a) Check for convergence to the feed composition, i.e. check if a^ f c + 1^ is approach-ing z. (b) Check if the value of rj is approaching 1 i n consecutive iterations. (c) Check if £ " = i XJ * + 1 ) , when < 1, is decreasing i n consecutive iterations. (d) Check if the objective function SSJ^XJJ) is increasing i n consecutive iterations. (e) Check if g*-, when < 0, is not changing significantly i n three consecutive iter-ations. (f) Check i f the objective function increases for any composition vector after using Wegstein's method. If so, the acceleration method is used less frequently unt i l the objective function decreases again after applying i t . Chapter 3. Proposed algorithm 62 (g) If a l l values of g*- are > 0, the composition vector wi th the largest value of \rj— 1| is marked. 8. Test for convergence of the composition vectors either to a m i n i m u m i n Gibbs energy or to the tr iv ia l solution: -Convergence to a minimum i n Gibbs energy. If $Sj(Xjti) < £ or if check (e) is satisfied and i n either case YA=I > 1, a l iquid t r ia l phase has been found. Its composition and fugacity coefficients are saved. -Convergence to the tr iv ia l solution. If \r - 1| < 0.2 and g* < 1 0 - 3 or if check (a) is satisfied or if any of checks (b) through (d) are met i n two consecutive iterations, a t r iv ia l solution has been found for the corresponding vector. 9. Each pair of composition vectors are tested to be significantly different from one another to avoid convergence to a common vector. It is considered that two vectors are approaching the same value if El*tf-X,-,,-|<e (3-77) i=l 10. The following composition vectors are eliminated from the search: -Vectors that have converged to a min imum i n Gibbs energy or to the t r iv ia l solu-t ion. -Vectors that are not l ikely to converge, namely those that are not marked when check (g) is satisfied. Chapter 3. Proposed algorithm 63 -Vectors that have converged to a common value, except the one wi th the smallest objective function. Whenever a composition vector is eliminated, the value of m (the number of vectors i n the array) is set to m - 1. If a l l the composition vectors have been eliminated, the calculation terminates and Step 12 is executed. 11. The functions f(X^) = e x P ( / l , ) / # + 1 ) (3-78) are calculated and the variables for the next iterative loop are assigned by setting k = k + 1. If A: < kmax Step 4 is executed, otherwise the next step is followed. 12. If at least two tr ia l phases are found, again a test for the possible convergence to a common value is performed again as indicated i n Step 9. A l l common vectors but one are eliminated. If two incipient l iquid phases are found, it is considered that the presence of two liquids leads to a more stable solution than the presence of a single l iquid . (In the odd case that three different composition vectors are found, the two wi th the least Gibbs energy of mixing are considered stable). If one incipient l iquid phase is found the original system is unstable and the ap-pearance of the new phase wi l l decrease it's Gibbs energy. If no incipient l iquid phases are found, the search has failed and the original system is stable wi th respect to the formation of a new l iquid phase. Chapter 3. Proposed algorithm 64 Additional liquid phase search The attempt to find a l iquid phase which may have been bypassed i n the in i t i a l search of the phase-splitting algorithm can be conducted when cases i) and i i i ) (described at the beginning of Section 3.2) occur. In similar form as for the additional vapour search in case i i ) , the additional search for a l iquid phase consists on finding a pseudo-parameter h v. or h^. (for cases i) or i i i ) respectively) and conducting the modified Michelsen method wi th them. These pseudo-parameters define the pseudo-tangent plane necessary to apply the tangent plane criterion for the additional search. W h e n the system has 2 components, hp. is calculated as h v. = ^£--\nP (3.79) and hp. according to equation (3.56). The pseudo- chemical potential of mixing for the system as a vapour, A/ t^ . , is obtained similarly to Afip. from equation (3.53) but using the vapour properties. The slope of the pseudo-tangent line is obtained for case i) considering the vapour-like feed point and the one l iquid found: dAg = Agv{z) - AgL(x') dzi z{ - x'i and for case i i i ) from the liquid-like feed and the incipient vapour phase: dAg AgL(z) - Ag v(y') ~dz~ = zj-y-'  ( 3 - 8 1 ) Chapter 3. Proposed algorithm 65 For multicomponent systems (n > 3), because it is considered that the pseudo-tangent plane is orthogonal to the Ag axis at the feed composition, i.e. dAg/dzi = 0, the value of h v. is obtained as Pi ,v = A 0 ) _ l n p  p> RT and h^. is calculated from equation (3.59). W i t h h^{ or hp. evaluated, the additional search can be performed by using either exp(hp.) or exp(hp.) i n the modified l iquid search method described above. Once the algorithms to search for the vapour and l iqu id incipient phases have been presented, some relevant aspects of them can be addressed. The procedures followed to obtain the composition estimates required to init iate the search are treated in Section 3.3. W i t h respect to the solution of the stationarity condition (equations (3.35), (3.60) and (3.61)), i f desired direct substitution can be used throughout the calculation, i.e. the use of Wegstein's method is optional. W h e n Wegstein's method is employed, the best results are obtained if the acceleration is started i n the fourth i terat ion (if convergence has not been reached) allowing four direct iteration steps, which is also what Swank and Mul l ins [30] advise. To prevent overshooting when Wegstein's formula is applied, the value of the step size parameter is l imited. The typical value of tmax recommended in the literature is about 10, but as w i l l be seen i n the next chapter, a smaller value gave better results for the cases tested. The necessity to l imi t this parameter arises from the different conditions that develop depending on its value, namely: (3.82) Chapter 3. Proposed algorithm 66 value of ti value of Si condition U > 1 0 < 5, < 1 acceleration (extrapolation) U = l Si = 0 direct substitution 0 < tt < 1 Si < 0 damping (interpolation) U = 0 5j = ± 0 0 stagnation (no progress) U < 0 Si > 1 deceleration (extrapolation) ti = ± 0 0 S, = l no solution or oo solutions Another important consideration i n the use of Wegstein's method is its frequency of application. If used sporadically, the convergence rate may be similar to that of direct substitution and the advantage of the method is lost. O n the other hand, i f used every iteration it can lead to undesirable oscillatory behaviour. In the search method proposed, the frequency of application for acceleration can be pre-specified allowing its use every iteration or every 2nd, 3rd,. . . , etc. iteration. However, to avoid oscillations i n the calcu-lat ion and even divergence i n some cases, whenever the value of the objective function increases after applying Wegstein's method its frequency of use is reduced. In such cases it is employed only every n*w iterations (where n is a control variable which is increased by one when the objective function increases after accelerating and w is the selected frequency of application) unt i l the objective function decreases after accelerating, and only then it is set back to its original frequency w. To avoid convergence to the t r iv ia l solution, Michelsen proposes to stop the search when the value of r is close to 1 and g* is small (|r — 1| < 0.2 and g* < 10~ 3) or when r is greater than 0.8 and increases i n consecutive iterations (r > 0.8 and rk > r f c _ 1 ) . From the observations made for the systems tested, especially for the l iquid phase search, the first criterion (r ~ 1 and g* small) was found adequate but not the second since i n several cases it lead to a wrong prediction in which a t r iv i a l solution was indicated Chapter 3. Proposed algorithm 67 when an incipient phase corresponding to the correct solution was being approached. To overcome this weakness, the second criterion was substituted by checks (b) through (d) i n the phase search (Step 7) for both the vapour and the l iqu id phases. Because i n some cases none of these criteria were satisfied when a t r iv ia l solution was approached, check (a) was introduced. Check (e) was established to speed up the detection of an unstable solution i n the odd cases found (in particular for the l iquid phase) where convergence near the solution was very slow. These checks and the rest of the suggested modifications made to Michelsen's scheme to obtain more reliable results i n the search are discussed in detail i n Chapter 4. 3.3 Initialization procedures In order to init iate the vapour and l iquid search methods described before, estimates of the composition of the incipient phases are required. For the vapour phase an approach similar to that proposed by Michelsen is used, but for the l iquid phase(s) various alter-natives have been studied i n this work. Since one of the objectives of the phase-splitting method proposed here is to provide estimates for the equil ibrium compositions, the meth-ods to estimate the composition of the incipient phases (not necessarily at equilibrium) must be simple (to not cause a significant addit ional load to the overall algorithm) and dependable (to provide estimates i n the vic inity of the stationary points). 3.3.1 Vapour phase The simplest way to initialize vapour compositions is to assume that Raoult 's law applies i n which case the equil ibrium constants can be obtained as Kt = yi/xi = P,sat/P (3.83) Chapter 3. Proposed algorithm 68 where superscript ' ° ' indicates ideal conditions. For hydrocarbon systems an approxima-tion for the saturation pressure P" at is given by (reference [5]) P° at = PCi exp[5.3727(l + u>,)(l - TJT)] (3.84) where variables wi th subscript c are the crit ical constants and u> is Pitzer 's acentric factor. This approximation was satisfactory for the cases tested and there was no need to util ize more general and/or accurate vapour pressure correlations. Once estimates for the equi l ibrium ratios are available, the vapour composition can be obtained from Viinit = ' ' y » (3-85) Al though the assumption of ideal behaviour ceases to be val id as conditions deviate from those i n which the vapour can be treated as an ideal gas and the l iquid as an ideal solution, the results obtained for the systems studied indicate that the estimates obtained by means of equation (3.83) are adequate. Even for highly non-ideal conditions the estimates obtained with equation (3.85) were not far from the stationary points i n the cases tested and lead to convergence of the vapour phase search method i n a few iterations. 3.3.2 Liquid phases Since the l iqu id search is for one or two phases, multiple i n i t i a l estimates must be made (at least two different estimates are needed). One obvious choice is to consider ideal Chapter 3. Proposed algorithm 69 solution behaviour and use the values of Kf already obtained from equation (3.83). The composition estimates for an incipient l iquid are obtained from x> Z i / K r  i i n i t T.UizilKf) However, these values may not be very accurate and to assure that an incipient l iquid is not missed other in i t i a l estimates are needed. In the review by Swank and Mul l ins [30] of L L phase-splitting algorithms, three methods for generating in i t i a l guesses for immiscible phases are tested for reliability and efficiency: that of Gautam and Seider [19], Shah [1] and Michelsen [4], which have also been discussed i n Chapter 2. The first two methods are based on selecting two components as phase initiators (for systems of 3 or more components) and then assigning compositions for each phase according to the equil ibrium and mass balance equations. Thus two i n i t i a l composition vectors are obtained i n this form. The method of Michelsen uses as many in i t i a l guesses as there are components, starting each phase wi th the pure components. The results obtained i n [30] indicate that the method of Gautam and Seider and that of Shah are less reliable than Michelsen's when the same final convergence algorithm is used. Nevertheless, the three methods are implemented i n this work with some modifications to make them more efficient and a fourth method is proposed based also on the selection of phase initiators. Modified Michelsen's method According to Michelsen, using as many in i t i a l composition vectors as the number of com-ponents i n the mixture and starting with the pure t r ia l phases has the advantage that (3.86) Chapter 3. Proposed algorithm 70 l iquid immiscibi l i ty i n highly non-ideal systems is promptly detected and component fu-gacity coefficients are evaluated cheaply. W h e n dealing wi th hydrocarbon systems, he considers only the lightest and the heaviest components i n the mixture plus two addi-t ional estimates: one corresponding to a hypothetical ideal gas and another considering the arithmetic mean of the phase compositions already present. For V L equilibria in -volving hydrocarbons, two sets of compositions are recommended by h i m according to equations (2.24) and (2.25). As mentioned i n Section 2.2.2, starting wi th the pure phases as composition estimates has the disadvantage that for supercritical components the sys-tem's temperature and/or pressure must be altered temporarily to a point where l iquid properties can be evaluated for such components. In addition, the advantage of the easy evaluation of pure component fugacities is small since after the init ia l izat ion properties must be obtained for each component i n the mixture. For hydrocarbon systems, the selection of the pure phases based only on the lightest and heaviest components is not justified since their relative amounts in the mixture are not taken into account. Also , for the ini t ia l izat ion of l iquid t r ia l phases the ideal gas estimate is unnecessary. The modified ini t ia l izat ion scheme proposed consists of using as many composition estimates as components i n the mixture but instead of taking each phase as a pure component, for each phase a different component is considered predominant and the rest are evenly distributed among that phase. It was found that assigning a composition of 0.98 i n mole fraction for the most abundant component and 0.02/(n— 1) for the remaining ones gave good results. Since the composition estimates obtained with equation (3.86) are easily evaluated, this composition vector is also used giving a total of m = n + 1 in i t i a l estimates which are: Chapter 3. Proposed algorithm 71 0.98 i f j = i Xj,i init — * 0 . 0 2 / ( n - 1) iij^i i — 1 , . . . , n j = l , . . . , m x i mtt i f j = n + 1 (3.87) These i n i t i a l estimates have the advantage that by considering the starting phases as a mixture (rather than a pure component), extrapolated values of density from the equation of state can be used to evaluate fugacity coefficients i f at the specified conditions a l iquid does not exist. Thus the system's temperature and pressure need not be altered i n the ini t ia l izat ion step of the search method. Also , by considering the phases to be almost the pure components the advantage of overestimating the phase-split to quickly detect l iquid immiscibi l i ty is kept. Shah's method To estimate the composition of immiscible l iquid phases by selecting components p and q as phase initiators of phases / and II, the following scheme is implemented using Shah's method [1] seen i n Section 2.2.1. The component wi th the largest pseudo-infinite di lut ion activity a^°° is designated phase init iator p. The activity is calculated as (3.88) where <f)f°° is the fugacity coefficient for component i at infinite di lut ion. This fugacity coefficient is obtained considering that component i is present i n infinitesimal quantity ( 1 0 - 6 i n mole fraction) and that the compositions of the rest of the components are Chapter 3. Proposed algorithm 72 proportional to their compositions i n the feed. Then the second phase init iator q is selected as that component wi th the largest pseudo-infinite di lut ion activity i n pure component p according to equation (3.88) but with calculated considering only a binary mixture of almost pure p wi th each component i i n turn (i ^ p) present i n very small amount (mole fraction of 1 0 - 6 ) . Once components p and q have been obtained, their composition can be calculated from the mass balance and equil ibrium conditions by solving equations analogous to (2.3) and (2.4), but i n terms of fugacity coefficients: ffivl'lH 1 +  n") = fa'p/H + O (3-89) # p » j / w + o = w / r t 1 + o (3-9°) where i t has been assumed that the fugacity coefficients of components p and q in phases I and II are those of the pure components (<j>p and <f>^) and i n phases II and I are those at infinite di lut ion i n the binary mixture (<}>pn and fyq 1 ). Considering 1 mole of overall mixture, the mass balance restrictions dictate that n Ip + n Ip I = zp (3.91) n[ + n\ l = zq (3.92) which are similar relations to equations (2.5) and (2.6). The solution of equations (3.89) to (3.92) reduces to solving a quadratic equation i n any of the mole numbers np, n 1, n 11 or n 11. Taking as the independent variable, the Chapter 3. Proposed algorithm value of rip can be obtained by solving a ( n 7 ) 2 + bn[ + c = 0 and choosing the root that satisfies the condition 0 < n 7 < zp, where a = ABD - ACD - A 2E + A 2F b = B 2D - BCD - ABE - ACE + 2ACF c = C 2F - BCE with A = # - # » B = zAft* - 2cf>Lp) C = *P#» D = tf- %r E = 2zp^T _ Zq(f>Lq Chapter 3. Proposed algorithm 74 F = -zqtf (3.102) Then is obtained as j Ajntf + Bnj n — — Anj, + C which must satisfy the condition 0 < < zq. If both solutions to equation (3.93) meet the mass balance condition, the one selected is that which makes the condition for hold. If both rip roots do, it is irrelevant which one is selected. The values of n ^ 7 and n^ 1 are then obtained as n 11 = zp — np and n^ 1 = zq — n^. Once components p and q are chosen and their mole numbers i n both phases are known, the remaining r components (r = 1 , . . . , n — 2, r ^ p, r ^ q) are distributed among phases I and II one at the time considering that p and q are the only other components present. The corresponding mole numbers nj. and n 7 / are obtained from the mass balance and equilibrium relations giving: # " n r ' / ( n ; + np + „ J ) = # » n r ' 7 K " + n» + n g ") (3.104) which is equivalent to equation (2.7). Taking into account that for 1 mole of the original mixture ni + n 1/ = zT (3.105) equation (3.104) can also be reduced to solving a quadratic for n\: (3.103) Chapter 3. Proposed algorithm 75 d(ni) 2 + eni + f = 0 (3.106) where d=tfr (3.107) e = (zr-np- n[)ffi - (zr + n j ' + „ J ' ) # ~ (3.108) f = zr(n Ip + n Iq)^n (3.109) The value of n 7 should satisfy the condition 0 < nf. < zr; then nj. 1 is obtained as nj. 1 = zr-nj.. In case any of the mole numbers calculated is outside the range determined by the mass balance conditions, its value is set close to either the upper l imit z, or the lower l imi t 0, whichever is exceeded (i.e. n,- = 0.9z,- i f n ; > z, or nt- = O.lz,- i f n , < 0). W i t h the mole numbers for a l l components i n phases / and II available, the normalized in i t i a l compositions (mole fraction) are calculated as --jtfT^ter <3-110) n 11 = n / / + n / / + V " - 2 n"  ( 3 - 1 1 1 ) % + q + ^r¥:p<qnr and similarly for xiiQ, x2<q, xi<r and x2,r- This gives 2 composition vectors xiti and x2,i Chapter 3. Proposed algorithm 76 (i = 1 , . . . ,n ) as in i t i a l estimates for the l iquid phase, plus the one given by equation (3.86), yields a total of 3 in i t i a l composition estimates: xj,i init — * xl,i — x^,pi "^1,<7> xl,r x2,i — x2,pi x2,q-> x2,r r = 1, . . . , n - 2, r ^ p,q i = 1 , . . . , n (3.112) X3,i =  xh nit M o d i f i e d G a u t a m a n d S e i d e r m e t h o d The method of Gautam and Seider (Section 2.2.2) to generate in i t i a l compositions for L L phase-splitting introduced the idea of selecting two key components as phase ini t ia-tors. Because the calculation of the mole numbers of the components present in phases I and II is rather cumbersome i n their method, a simplified approach is suggested. W h a t makes this part of the method inefficient is that it requires solving two simultaneous non-linear equations (equations (2.9) and (2.10)) plus n — 2 single non-linear equations (corresponding to equation (2.13)) in which the activity coefficients 7, are strongly depen-dent on composition. The solution of these equations would increase the computational load considerably 1 and would also require that in i t i a l estimates be supplied. In the proposed modification to Gautam and Seider's method component p is chosen as that wi th the highest act ivity in the mixture (considered as a l iquid) . In this way the selection of this component is straightforward since the activities of each component i n xFor example, solving equations (2.9) and (2.10) for a binary system is equivalent to obtaining the actual equilibrium compositions, whereas what in wanted are estimates of the incipient phases to be used as initial compositions for the search method. Chapter 3. Proposed algorithm 77 the mixture have already been evaluated at the beginning of the phase-splitting algorithm (from equation 3.32). Then component q is selected as the component wi th the highest activity wi th component p i n a binary l iquid consisting of only these two components, considering their composition proportional to that of the mixture. W i t h components p and q available, to simplify the solution of equations (2.9) and (2.10) (but i n terms of fugacity coefficients) i n order to obtain their compositions, the assumption taken i n Shah's method is also made. That is, the fugacity coefficients of p i n phase I and of q i n phase 77 are calculated considering them as almost the pure components (since each phase init iator is assumed the most abundant component i n the phase where i t acts as 'solvent') and their fugacity coefficients i n phases II and I respectively are obtained as the infinite-dilution values (by assuming that components p and q are present i n small quantities i n phases II and I). Hence, the calculation of the mole numbers for p and q s imply requires the solution of equations (3.89) and (3.90) as described above. Then the compositions for the remaining components (if n > 3) i n the immiscible phases are also obtained as i n Shah's method wi th 3 composition vectors being generated (as i n equation (3.112)). Clearly, i f components p and q assigned in this form correspond to those obtained wi th Shah's method, the same in i t i a l composition vectors w i l l be obtained. Proposed method Another approach proposed i n this work is based on Shah's method and it only differs from it i n the way component p is selected. Since the activities of a l l components i n the mixture are available and because the activity was seen to give a relative measure of the tendency for a component to form a new phase, following Gautam and Seider component p is chosen as that with the highest activity i n the original l iquid-like system. Then component q is selected as explained for Shah's method (i.e. as the component with the largest pseudo-infinite di lut ion activity i n almost pure p), which is then followed Chapter 3. Proposed algorithm 78 throughout to obtain the 3 in i t i a l composition vectors. In this form the advantages of the two previous methods seen are combined giving an efficient and dependable way to obtain composition estimates for the phase search i n the splitt ing algorithm. 3.4 Phase removal tests A t the beginning of this chapter it was mentioned that when Michelsen's method was incorporated into the phase-splitting algorithm proposed, two main flaws were found. The first, which concerns the bypass of an incipient phase corresponding to a phase present at equil ibrium, has been dealt wi th and to overcome it an additional phase search is recommended. The second fault involves finding an incipient phase which does not correspond to the equil ibrium solution. The el imination of such phase is not attempted i n the modified search method since i t was found that a superfluous phase can also be obtained when the additional phase search is conducted. The principle behind the phase removal tests used i n this work to eliminate a super-fluous phase and thus reduce a potential three- phase system to a V L or L L solution at equil ibrium can be understood by looking at the source of the problem. The conditions that a phase equil ibrium solution must satisfy are that the system should have the lowest possible Gibbs energy (at the specified T , P and composition), the chemical potentials (or equivalently the fugacities) for each component must be equal i n a l l phases and the mass balance must be preserved. The first two conditions are taken care of i n the search method since they are implied i n the tangent plane criterion used. However, because the phases searched with the modified Michelsen method originate from a single phase system as incipient phases, their amount is considered infinitesimal and the mass balance restriction may not hold. Hence, phases for which the tangent plane criterion is satisfied but which do not correspond to the most stable solution may be found and if so must be Chapter 3. Proposed algorithm 79 eliminated to correctly predict the configuration of the system at equil ibrium. For binary systems the presence of a superfluous incipient phase can be il lustrated i n a diagram of the Gibbs energy of mix ing as a function of composition such as Figure 3.11. This diagram depicts the case of a vapour-like system at the feed composition z where two incipient l iquid phases are found i n the search. Only the vapour and one of the liquids ( l iquid I) pertain to the equil ibrium solution (shown by the V L / dashed line). The superfluous incipient l iquid II should be ruled out even i f a lower Gibbs energy seems to be obtained wi th the L L solution ( L / L / / dashed line) since at equil ibrium the mass balance restriction would not be satisfied for such solution. Graphically, the mass balance restriction is satisfied if the feed composition is i n between the compositions of the phases at equil ibrium as dictated by the lever rule 2 . This condition is not met for the L / L / / solution shown i n Figure 3.11, but is satisfied for the V L / solution, i.e. the equil ibrium compositions y and x 1 lie at both sides of the feed z. Thus for systems with two components a test based on the lever rule could be used to eliminate superfluous incipient phases combined wi th the conditions of equality of fugacities and a min imum i n Gibbs energy at equil ibrium (this is necessary for example i n the case of Figure 3.11 i n which a V L / / solution -not shown- would satisfy the mass balance restriction and equality of fugacities but would not lead to a min imum i n Gibbs energy for the system). Because for multicomponent systems there is no analog to the lever rule i n the con-text used here, the detection of a superfluous phase can not be done by knowing the composition of the incipient phases. Tests must then be made as the equil ibrium com-positions are approached by monitoring the violat ion of the mass balance restriction due 2 For binary systems the lever rule can be applied to establish the ratio of the amount of one phase to that of the feed. For example, the vapour fraction in a VL system can be obtained as V/F = (zi ~ Xi)/(yi - Xi). Chapter 3. Proposed algorithm 80 V L , L „ VL, 0 y Z x" composition (mole fraction) Figure 3.11: Binary system stable as VL for which two incipient liquid phases are found in the phase search, one being superfluous. to the presence of a superfluous phase. The methods described next provide such tests and have been incorporated into the phase-splitting algorithm to eliminate a superfluous phase whenever i t is detected i n a potential V L L system. They are based on using a three-phase flash calculation scheme to converge the compositions of the phases found towards the equil ibrium values by solving for the mole and phase fractions that satisfy the mass balance and equilibrium equations. Since an iterative procedure is required to accomplish this, a l imited number of iterations are carried out and during the calculation the tests for the fulfillment of the material balance restrictions are applied to the updated compositions to detect any extraneous phase. Depending on the outcome of these tests it is decided if at equil ibrium the system is a three-phase mixture or if a two-phase solution is more stable. Chapter 3. Proposed algorithm 81 3.4.1 Multiphase flash method Starting wi th the compositions of the phases found i n the search, a max imum of five iterations are conducted using a three-phase flash calculation scheme based on the method described i n Appendix A (but without the acceleration option). W i t h the new-found compositions at each iteration, the phase removal tests proposed i n [5] are performed to detect any superfluous phase. If i n five iterations no phase el imination has been done, it is considered that the mixture is stable as a V L L system and the current composition values are used as in i t i a l estimates for the eventual flash calculation. If any of the phases is found to be extraneous, i t is eliminated and the composition of the phases found i n the phase search for the corresponding two-phase flash (not the current composition values) are used as in i t i a l estimates i f the flash calculation is to be conducted. The steps of this phase removal method are: Phase removal test. Multiphase flash method 1. W i t h the in i t i a l composition vectors obtained from the phase search (y = y', x 1 = x', x 11 — z; y = y', x 1 = x' 1, x 11 = x'u or y = z, x 1 = x' 1, x 11 — x'n) the corresponding fugacity coefficients are obtained from the equation of state and the equil ibrium ratios, defined as K~iv = yt/xf1 and KiL = xf/xf1, are calculated according to Kiv = (3.113) KiL = ti iihLs (3.114) Chapter 3. Proposed algorithm 82 2. S t a r t o f t h e i t e r a t i v e c y c l e . If the maximum number of iterations is reached (set to five) the calculation terminates, the system is considered stable as a three-phase mixture and the current composition values are used as in i t i a l estimates for the V L L flash if needed. Otherwise, when all the K{L values are near unity, then both l iquid phases are very similar and the one for which the sum of the activities is greater is eliminated (since it is the phase wi th higher tendency to disappear). In such case the system is considered stable as V L and the calculation ends. The in i t i a l compositions for the flash are the compositions corresponding to the phases found i n the previous search (for the vapour and the l iquid not eliminated). 3. The phase ratios a and 8, defined a s a = V/F and 8 = Li/F (note that 1 — a - 0 = LulF) are solved for from the Rachford-Rice type arrangement of the mass balance and equil ibrium equations using a Newton-Raphson procedure where V, Lj, Lu and F are the total mole numbers of the vapour, l iquid I , l iquid II and the feed. 4. Once a and 8 are obtained, they are used as phase indicators to find any phase which should be eliminated in the calculation. The following checks are done and the corresponding control variables i/y, vjJI and ULtI (all being zero init ia l ly) are set accordingly: (a) If a < 0 and 8 < 0 or a < 0 and 8 > 1 then vy = vy + 1 and VTII = VT,I - 1. Tv(a,0) = Y: n Zi{l-Kiv) (3.115) l + a { K i v - l ) + 8 ( K i L - l ) (3.116) Chapter 3. Proposed algorithm 83 (b) If a < 0 and l - a - / 9 < 0 o r a < 0 and 1 - a - 3 > 1 then vy = vy + 1 and VLu = VLU ~ 1-(c) If a > 1 and 3 < 0 and 1 — a — /? < 0 then i f for l iquid I the sum of the activities is higher than for l iquid II VLJJ — vj^jj — 1, otherwise vjJl — VLJ — 1 when the sum of the activities for l iquid II is greater than for l iquid I. 5. W h e n outside the interval [0,1] the calculated values of a and 3 are l imited (as indicated i n Appendix A ) to avoid the calculation of negative mole fractions from equation (3.117). After these parameters have been l imited , addit ional checks are done: (a) If a is s t i l l outside the interval [0,1], then vy = vy + 1, otherwise vy = 0. (b) If 3 is not i n the interval [0,1] then z/£7 = i/£7 + 1, otherwise ULJ = 0. (c) If 1 — a — 3 is not i n the interval [0,1] then V L U = V L U + 1, otherwise VT,N = 0. 6. The el imination of any of the phases is analyzed depending on the value of the control variables: - If a < 0 and vy > 3 then the vapour phase is eliminated and the system is considered stable as L L . - If 3 < 0 and uij > 3 Bquid I is eliminated; i f l — a — 3 < 0 and i/£,/7 > 3 then l iqu id II is eliminated. In either case the system is declared stable as V L . W h e n any of the phases is eliminated the calculation terminates and the appropriate solution is the result of the phase-splitting prediction. The composition of the corresponding phases found in the search are used to init ial ize the two-phase flash if required. 7. The new compositions of the three phases are calculated according to Chapter 3. Proposed algorithm 84 l + a ( K i v - l ) + P { K i L - l ) (3.117) x*1 = x*HKiL (3.118) y* = x * n K i v (3.119) which are normalized so that the sum of each of the mole fractions equals unity: = dS77 (3-120) x' = i £ v  ( 3 - m ) 8. The fugacity coefficients are calculated from the equation of state wi th the updated composition values and the equil ibrium ratios are obtained from equations (3.113) and (3.114). A new iteration is started by executing Step 2. 3.4.2 Bubble- and dew-point equations method Following the method proposed by Nelson [3] (reviewed i n Section 2.2.3) a scheme based on analyzing the behaviour of the mass balance and equi l ibrium equations at the l imi t Chapter 3. Proposed algorithm 85 where only two or one phase exist is adopted. In this way tests to determine the number of phases at equil ibrium can be performed based on the so- called bubble- and dew-point equations derived. Instead of the phase and equilibrium ratios defined i n [3], parameters a = V/F, 8 = Li/F, K{v = yi/xj1 and KiL = yi/xj1 as defined i n the previous section are used for consistency in the relationships developed. This leads to slightly different but equivalent criteria for the phase removal tests based on the following equations (in terms of these parameters) versus equations (2.27) and (2.28) where the phase and equilibrium ratios used are ipi = Li/F, tp2 = L2/F, I<n = yi/xj and — yi/xj1. Al so , i n contrast to Nelson's method i n which the phase removal tests are executed throughout using a three-phase calculation i n the proposed method the configuration of the system is determined when any of the tests is satisfied for three consecutive iterations and at that point the calculation ends. This alternative method, which is also incorporated into a flash-like calculation, consists of the following steps: Phase removal test. Bubble- and dew-point method 1. W i t h the in i t i a l compositions obtained from the phase search the equil ibrium ratios are obtained according to equations (3.113) and (3.114). (3.123) (3.124) (even if fewer than three phases have been already detected) unt i l convergence is achieved, Chapter 3. Proposed algorithm 86 2. S t a r t o f t h e i t e r a t i v e c y c l e . The phase ratios a and 0 are calculated from equations (3.115) and (3.116) holding K{v and KiL fixed using a Newton-Raphson technique. 3. If a and/or 8 are outside the interval [0,1] they are hmited to avoid the calculation of negative mole fractions (as described i n Appendix A ) . Then the new compositions of the three phases are calculated as indicated by equations (3.117) to (3.122). 4. W i t h the updated compositions the fugacity coefficients are evaluated from the equation of state and new equil ibrium ratios are calculated. 5. Test for the existence of a single phase. The following checks are made: (a) If Yl?=i  zilKiv < 1 and YA=I  ziKiL/Kiv < 1 then the control variable vy is set to vy + 1, otherwise vy — 0. If vy > 3 the system is considered stable as a vapour and the calculation is terminated. (b) If Zi/KiL < 1 and £ ? = 1 ZiKiv/KiL < 1 or £ ?= i ZiKiv < 1 and £ ? = 1 z{KiL < 1 then VL = UL + 1, otherwise UL is set to 0. If UL > 3 the system is considered stable as a l iquid and the calculation ends. 6. Test for the existence of two phases. To determine i f the system is stable as a two-phase mixture the criteria used are: (a) If T,?=i  ziKivlKiL > 1 and £ ? = 1 ziKiL/Kiv > 1 and Q2(^i,0) < 0 at the root of Qi(ipi,0) = 0 then VVLJ — vyij + 1 and control variable VVLL is set to 0, otherwise vvLi ~ ®-> where (3.125) Chapter 3. Proposed algorithm 87 *<*-°>=£idfeSk) <3126) The system is considered stable as a V L mixture ( V L / ) i f VVLJ > 3 and the calculation ends at this point. (b) If YX=\ZiKiv > 1 a n d Y!i=\ZilKiv > 1 A N D QiQM < 0 at the root of # 2 ( 0 , ^ 2 ) = 0 then W L „ = vvLn + 1 A N D  VVLL = 0, otherwise vyLjl = 0, where The system is considered stable as a V L mixture ( V L / / ) i f VVLU > 3 and i f so the calculation terminates. (c) I F E"=I^^.L > 1 A N D T!i=\zilKiL > 1 a n d $ 2 ( 0 1 , 1 - V i ) > 0 at the root of Q i (V» i , l - V>i) - <?2 (V ' i ) l - ^ 1 ) = 0 t n e n " L I , =  V L L + 1 and i ^ L Z , = 0, otherwise !/£,£, = 0, where Chapter 3. Proposed algorithm 88 The system is considered stable as a LL mixture (L/L/j) i f V^L > 3 and in such case the calculation ends. 7. If none of the tests described in Steps 5 and 6 are satisfied then VVLL =  VVLL + 1-The system is considered stable as a VLL mixture i f VVLL > 3 i n which case the calculation ends. Otherwise a new iteration is started by going back to Step 2. As wi th the multiphase flash reduction tests, whenever a two-phase solution is obtained the in i t i a l estimates for the flash are the compositions of the corresponding phases found i n the search and not the current composition values which are used only if a VLL solution is predicted. 3.4.3 Coupled method As shown i n the next chapter, better results were obtained i n the phase removal tests when the two methods just described were used i n a coupled fashion. This approach is suggested because when the additional phase search was conducted, the multiphase flash method failed i n some specific cases i n which the bubble- and dew-point equations method was successful and vice-versa. Specifically, the multiphase flash method is used i n every case except when the option for the additional phase search is selected and the system is l iquid-like, a vapour is found and no liquids are detected (in the in i t i a l search) unt i l the addit ional phase search is performed, i n which case the bubble- and dew-point method is used as phase removal test. This strategy can be summarized as follows: Phase removal test. Coupled method 1. If the additional phase search is conducted and cases i) or ii) of the search (described i n Section 3.2) occur, then the multiphase flash method is used. It is also used when Chapter 3. Proposed algorithm 89 case i i i ) arises only if an additional l iquid is not found i n the search. 2. If i n the addit ional phase search a l iquid is found when case i i i ) develops, then the bubble and dew-point method is used as phase removal test. Chapter 4 Results and discussion The evaluation of the performance of any phase-splitting algorithm is not a simple task since a number of criteria can be considered for this purpose. For example, its efficiency can be matched against that of other methods by determining the computational load required to perform a calculation, but unless the comparison is based on the same grounds the results can be misleading. Therefore the same or equivalent conditions should be used if any comparison is attempted (such as init ia l izat ion parameters, convergence tolerance and objective function, correctness of the prediction and even C P U time evaluation at the same time of day). The same applies when comparing for reliabil ity since i n cases where a given method may fai l another may perform flawlessly or vice versa. To assess the phase-splitting method proposed, the ultimate purpose sought i n achiev-ing the objectives of this work must be taken into account. This is to reliably and efficiently determine the equil ibrium configuration of a system i n order to avoid the time- consuming three-phase flash calculation (or the more commonly used two-phase flash) when unnecessary. For this reason the equil ibrium conditions predicted w i t h the algorithm presented here are compared wi th the results obtained w i t h the more crude three-phase flash calculation, which itself can be reduced to a V L or L L flash when a two-or single-phase solution prevails at equil ibrium. In this way if w i t h the phase-splitting method a system is found stable as a single phase then the flash calculation is avoided; if the presence of two phases is recognized then only the corresponding two-phase flash is necessary, and i f three phases are found then and only then a three-phase flash is 90 Chapter 4. Results and discussion 91 executed. W h e n a flash is required after the phase-split t ing prediction is conducted, the in i t i a l estimates generated in the search (as described i n Chapter 3) are used; however, for the direct three-phase flash (i.e. when not using the phase-splitting algorithm) the in i t i a l estimates as proposed in [5] are employed. This ini t ia l izat ion scheme and the flash algorithms are also described in Appendix A . (Note: a l l the calculations presented here where done on an A m d h a l 5860 and the C P U times given are i n microseconds.) 4.1 Systems tested The performance of the different parts of the algorithm proposed is assessed by testing a total of seven multicomponent systems at conditions where one-, two- or three-phase equilibria exists according to Soave-Redlich-Kwong ( S R K ) or Peng-Robinson ( P R ) ther-modynamics. These systems have been taken from the literature reviewed except for the last one which corresponds to the actual operating conditions for a compressor gas mix-ture. It should be understood at this point that most of these systems are representative examples of different types of equilibria which can be described by the aforementioned equations of state. Thus, for many of these systems experimental data to compare the results obtained are not available and it is the qualitative description of the equilibria behaviour rather than the quantitative predictions what is of interest. This means that the abi l i ty of the equations of state to reproduce experimental data is beyond the scope of this work and that the results obtained are as accurate (quantitatively) as the ther-modynamic models used. When available, interaction parameters for each binary pair in the systems tested (fc t i J values) are used as reported from the source (unless otherwise specified) and if not given, they are taken from Reid et a l . [32] for the S R K equation. These systems and the temperature, pressure and composition conditions under which they were studied as well as the binary interaction parameters used are: Chapter 4. Results and discussion 92 System 1: methane-carbon dioxide-hydrogen sulphide T=120 -» 280 K P = 2 0 atm z 1 = 0 . 5 , z2=0.1, z 3 =0.4 T=171 & 200 K P = 2 0 atm 66 feed points z for each T comp. no. component 1 C H 4 fci,2 = 0.12 2 C 0 2 Jb l i3 = 0.08 3 H 2 S k2,3 = 0.12 Note that kij — kjj and that A;^ ,- = kjj = 0.0 This ternary mixture , which is capable of splitting into three phases, is taken from Michelsen [4] and has a very narrow temperature range i n which three phases co-exist at the specified pressure for the composition given (the upper three-phase cr i t ical point is at about 218 K and 62 atm). The S R K equation of state is used to describe this system and since binary interaction parameters are not reported i n [4], the values given i n [32] are used. System 2: methane-ethane-propane-n-butane-n-pentane-nitrogen T=90 -» 320 K P = 4 0 atm comp. no. component Zi k{$ 1 C H 4 0.5479 0.02 2 C 2rJ.6 0.0708 0.06 3 C 3 H . 8 0.0367 0.08 4 C4H10 0.0208 0.08 5 C s H i 2 0.0198 0.08 6 N 2 0.3040 0.0 Chapter 4. Results and discussion 93 A l l other = 0 Michelsen [33] uses this nitrogen-rich light-hydrocarbon system as an example of a mixture which exhibits unexpectedly complicated behaviour since according to S R K thermodynamics it has two separate three-phase regions and a total of six cr i t ical points. A t 40 atm the upper three-phase region is encountered around 151 K and as i n System 1 the temperature range for which three-phase equilibria is found is of less than two degrees values from Re id et a l . [32], not reported by Michelsen [33]). System 3: propane-n-butane-n-pentane-n-hexane-n-octane- -water T=430 K P = 5 -> 100 a tm comp. no. component Z{ kite 1 C3H8 0.16667 0.48 2 n C 4 H 1 0 0.16667 0.48 3 n C s H 1 2 0.20000 0.48 4 n C 6 H 1 4 0.06667 0.48 5 n C 8 H 1 8 0.13333 0.48 6 H 2 0 0.26667 0.0 This hypothetical system is used by Peng and Robinson i n [34] to make V L L calcu-lations where the capacity of the model to describe a l l three phases at equil ibrium wi th the equation of state proposed by them is discussed. The k{j values reported in their work are used here wi th the P R equation to describe this water-hydro carbon mixture; i n addition a value of 0.1277 is used i n this study as Mathias ' [9] polar parameter for water. In this case the calculations are done at constant temperature Chapter 4. Results and discussion 94 and various pressures. Because the two l iquid phases found are highly immiscible the three phase region is very broad (at 430 K the three-phase region extends from about 25 to 35 atm). System 4: n-hexane-water T=378 K P=5 a tm 21 feed points z comp. no. component k\t2 1 n C 6 H 1 4 0.48 2 H 2 0 Heidemann [29] uses this mixture as one of the systems to exemplify the prediction of V L L equil ibria wi th the W i l s o n modification of the Redl ich-Kwong equation of state. W i t h the binary interaction parameter set to 0.5 a semi-quantitative pre-dict ion of the solubility of water i n the hydrocarbon rich phase is possible. In the present work the S R K equation is used considering a value of kit2 = 0.48 to cor-respond to the value used for System 3. For this binary the calculations are done considering the feed i n the entire composition range, i.e. from 0 to 1 i n n-hexane mole fraction. System 5: hydrogen sulphide-methane T=190 K P = 3 8 a tm 21 feed points z comp. no. component k\t2 1 H 2 S 0.08 2 C H 4 Chapter 4. Results and discussion 95 This binary system is considered by Michelsen i n [4] because at the specified tem-perature and pressure the methane-rich phase is nearly supercritical, which makes this l iquid phase difficult to detect. The S R K equation of state is used wi th the binary interaction parameter taken from Reid et a l . [32]. The composition range tested includes the interval from 0 to 1 i n hydrogen sulphide mole fraction. System 6: methane-n-butane-water T=311 K P = 6 0 atm 66 feed points z comp. no. component /c;)3 1 C H 4 0.50 2 n C 4 H 1 0 0.48 3 H 2 0 0.0 This mixture is studied by Heidemann i n [29] using also the W i l s o n modification of the Redl ich-Kwong equation of state which predicts three-phase equilibria at the given temperature and pressure. The results obtained by h i m are claimed to be i n good agreement wi th the experimental data of M c K e t t a and K a t z [35] especially to match the water mole fraction i n both the hydrocarbon-rich l iquid and i n the vapour phase at 311 K . In the present work the S R K equation of state is used wi th interaction parameters set to 0.0 for the methane-n-butane pair, to 0.48 for n-butane-water and to 0.5 for methane-water, this last value as used i n [29]. System 7: hydrogen-carbon dioxide-hydrogen sulphide- methane-ethane-ethylene-propane-propylene-n-butane-isobutane- -1-butene-n-pentane-isopentane T=283 k 327 K P = 5 k 15 a tm Chapter 4. Results and discussion 96 comp. no. component Ki h,j 1 H 2 0.1561 0.0 0.0 0.0 2 C 0 2 0.0038 0.0 0.0 0.1020 3 H 2 S 0.0151 0.0 0.1020 0.0 4 C i 0.0608 -0.0205 0.0936 0.0823 5 c 2 0.0341 -0.0009 0.1340 0.0852 6 c r 0.0176 0.0325 0.0575 0.07* 7 c 3 0.1177 0.1077 0.1280 0.0798 8 C j 0.3169 0.1344 0.0681 0.07* 9 n C 4 0.0259 0.3628 0.1376 0.0588 10 i C 4 0.0862 0.37§ 0.15* 0.0595 11 i-c4= 0.1570 0.4§ 0.0629 0.06§ 12 n C 5 0.0059 0.5§ 0.1407 0.0681 13 i C 5 0.0029 0.5§ 0.1341 0.06* A l l other kij = 0; also kij = kjj and fc,,- = kjj = 0 kij values taken from El l io t and Daubert [36]; * from Reid et a l . [32]; § estimated values from the homologous series for which values were available This mixture corresponds to a wet gas compression operation for which i t was desired to determine if condensation would occur i n the second stage of compression (283 K and 5 a tm at the suction and 327 K and 15 a tm at the discharge). The mole fractions of the stream correspond to conditions where failure i n the compressor is reported presumably due to l iquid accumulation when there is a high flow rate of feed gas during cold weather. The S R K equation was used to predict the equil ibrium properties wi th updated kij values available from the literature. Chapter 4. Results and discussion 97 4.2 Phase search initialization The start of the phase search methods described in Chapter 3 requires i n i t i a l composition estimates of the t r i a l phases to be sought. A successful outcome i n the phase-splitting prediction depends among other factors on this first step, particularly i n the search for l iquid phases as w i l l be seen. The importance of this part of the algorithm becomes clear when i t is recognized that Michelsen's method and also the modification of it proposed here do not guarantee convergence to a global min imum i n Gibbs energy. Estimates i n the vic ini ty of the stable solution are necessary to detect a solution corresponding to a global m i n i m u m rather than to just a local one. 4.2.1 Vapour phase Under the conditions at which the different systems were tested i t was found that the generation of composition estimates for the vapour search (yfinit) according to equation (3.85), i n which Raoult 's law is assumed, gave satisfactory results. Even at high pressures where the ideal gas laws cease to be val id the values of yf init followed the correct trend i n mole number distr ibution and temperature dependence observed for the incipient vapour composition (also for the actual equihbrium values) and allowed the incipient phase to be found i n a few iterations. This can be seen i n the examples presented i n Table 4.1 i n which representative results are given for three systems (5, 1 and 2) at conditions where they are l iquid- l ike and a vapour phase is found giving a correct phase-split prediction i n every case. Setting the convergence tolerance e to 1 0 - 5 for the objective function (equation (3.46)) i n al l the points tested, 5 iterations were required at the most to find the incipient vapour except for System 2 at 169.9 K and 60.5 atm (not shown i n Table 4.1) for which 6 iterations were required. Chapter 4. Results and discussion 98 Vapour phase search ini t ia l izat ion System 5: H 2 S ( 1 ) - C H 4 ( 2 ) T=190 K P = 3 8 a tm feed Raoult's law incipient vapour equilibrium comp. no. of iterations to z.- yt vl y[ y'2 yi yi find incip. vapour O. l .0007 .9993 .0197 .9804 .0178 .9822 3 0.3 .0028 .9972 .0221 .9779 .0178 .9822 3 0.5 .0066 .9934 .0169 .9831 .0178 .9822 3 0.7 .0152 .9848 .0136 .9864 .0178 .9822 3 System 1: C H 4 ( 1 ) - C 0 2 ( 2 ) - H 2 S ( 3 ) zx = 0.5 z2 = 0.1 P = 2 0 a tm T(K) Raoult's law incipient vapour equilibrium comp. no. of iterations to yt yt y'i y'2 yi 2/2 find incip. vapour 180 .9916 .0047 .9794 .0125 .9617 .0291 2 200 .9850 .0079 .9559 .0241 .8952 .0707 2 System 2: hydrocarbons(l-5)- N 2 (6) P = 4 0 a tm T(K) Raoult's law incipient vapour equilibrium comp. no. of iterations to yt 2/2 y[ y'2 2/i 2/2 find incip. vapour 160 .2102 .7894 .2890 .7083 .3875 .6087 5 180 .2503 .7489 .3564 .6374 .5581 .4288 4 Table 4.1: Initial composition estimates for the vapour phase search using Raoult's law and for the flash calculation using the incipient vapour found. Chapter 4. Results and discussion 99 Al though the proposed method to estimate the incipient vapour composition could be inappropriate under more drastic conditions such as near cri t ical points or i n retrograde behaviour regions, calculations to see i f the search would fai l due to poor estimates were not done under such conditions. For the cases studied it was found that very accurate composition estimates were not crucial for the correct prediction of a vapour phase (probably because the fugacity coefficients were not highly composition dependent) and since the simple init ial ization procedure used worked flawlessly and efficiently no alternative methods were tried. 4.2.2 Liquid phases The init ia l izat ion for the l iquid phase search constitutes a more severe problem than the ini t ia l izat ion for the vapour not only because at least two distinct phases are sought but because the composition dependence of the fugacity coefficients is much stronger for condensed phases. This means that good in i t i a l estimates must be provided to assure a correct and efficient prediction of the incipient l iquids. It has been recognized by several authors (Michelsen [4], Maurer and Prausnitz [16], Walraven and V a n Rompay [20] among others) that in order to reliably predict L L equilibria the in i t i a l composition estimates of the l iquid phases should overestimate the immiscibi l i ty region (i.e. he outside of i t ) . Al though this condition is a desirable feature for the ini t ia l izat ion of the flash calculations, i t is not imperative and certainly an excessive overestimation i n which the guess compositions are far from the equil ibrium values is no better than values inside the two-phase region when close to the binodal curve. This was also observed for the ini t ia l izat ion of the incipient phases in the search methods. These concepts can be exemplified wi th the mixture n-hexane(l)- water(2) (System 4) for which Table 4.2 gives the composition estimates of the incipient phases (x7, x 7 7 and x\), the composition of the incipient phases found (x'/, x^77) and the actual equil ibrium values (x[, x[7) at two Chapter 4. Results and discussion 100 L iqu id phase search ini t ia l izat ion System 4: n C 6 H 1 4 ( l ) - H 2 0 ( 2 ) T=378 K P= 5 a tm modified Michelsen mod. Gautam & Seider (p=2,q=l) Shah (p=l,q=2) proposed method (p=2rf=l) 0.90 0.95 0.90 0.95 0.90 0.95 0.90 0.95 X1 .9800 .9800 1.000 .3425* .9890 .9948 1.000 .3425* -II xq .9800 .9800 .9988 .9994 1.000 1.000 .9988 .9994 x\ .8087 .8992 .8087 .8992 .8087 .8992 .8087 .8992 <.0001 <.0001 <.0001 no L found + <.0001 <.0001 <.0001 no L found + x i .9000 .9500 .9000 .9500 .9000 .9500 .9000 .9500 x[ <.0001 <.0001 <.0001 wrong V L <.0001 <.0001 <.0001 wrong V L .9894 .9894 .9894 prediction .9894 .9894 .9894 prediction * Compositions for the water-rich incipient phase J that underestimate the water content. + As a consequence phase I can not be found leading to an incorrect phase-splitting prediction. Table 4.2: Composition estimates for the incipient liquid phases obtained with the various initialization methods tried, composition of the incipient phases found and equilibrium values for two feed compositions in System 4-Chapter 4. Results and discussion 101 2.25 n-hexane mole fraction Figure 4.12: Gibbs energy of mixing diagram for the n-hexane- water system at 378 K and 5 atm (System 4) showing that both components are immiscible almost throughout the entire composition range. feed compositions of a n-hexane rich mixture. A t both Zi — 0.90 and z\ = 0.95 only one incipient phase was found i n the search (phase 7, r ich i n water) and thus the other incipient phase (n-hexane rich phase II) is taken as the feed i n order to init ia l ize the flash calculation. Because of this, the i n i t i a l compositions for the flash slightly underestimated the amount of n-hexane i n phase II but this d id not cause an erroneous outcome i n the calculation. However, the composition estimates for the phase search obtained with the modified Gautam and Seider method and wi th the proposed one at z x = 0.95 (marked with an asterisk in Table 4.2) clearly underestimated the water composition (phase initiator p = 2) i n phase I preventing the prediction of a water-rich incipient phase (marked wi th a cross). This lead to the incorrect prediction of a V L system at this composition. It was found that to avoid this problem the in i t i a l water composition in phase I should be greater than 0.75 i n mole fraction (xp > 0.75, Chapter 4. Results and discussion 102 p = 2); the reason for this can be seen i n Figure 4.12, which shows the Gibbs energy of mix ing as a function of composition. To reach the m i n i m u m i n the Ag/RT curve for the l iqu id corresponding to the water-rich phase the in i t i a l composition must be to the left of the max imum located approximately at a composition of 0.25 i n n-hexane (or 0.75 i n water), otherwise the phase search algorithm goes i n the 'downhi l l ' direction towards the other m i n i m u m (corresponding to the n-hexane rich phase to the right of the maximum). A s mentioned i n Section 3.3.2, Swank and Mul l ins [30] conclude that Gautam and Seider's and Shah's methods are less reliable than Michelsen's as i n i t i a l algorithms for calculating the equil ibrium compositions to predict L L phase-splitting. The evaluation of these methods as implemented i n the present work to init ia l ize the l iqu id search, as wel l as the alternative scheme proposed (by combining G a u t a m and Seider's wi th Shah's criteria to select the phase initiators), indicate that Shah's is perhaps the most reliable method followed closely by the one proposed. Then the modified G a u t a m and Seider and Michelsen methods are next i n that order. These conclusions are based on the frequency wi th which any of the ini t ia l izat ion algorithms lead to an incorrect prediction of the incipient phases due to faulty in i t i a l composition values. In Table 4.3 the performance of these methods is shown for some of the systems tested under the same conditions (e = 10~ 5 and using Wegstein's acceleration method); the table gives the number of iterations needed to find the incipient liquids, the C P U time required to generate the i n i t i a l compositions and to reach convergence i n the phase search (in milliseconds), and the number of times i n which an erroneous solution was obtained. Considering then the results shown i n this table and i n Table 4.2, where the proposed method as well as the modified Gautam and Seider's failed once, i t can be concluded that only a slight difference i n dependability was found among the four methods. W i t h regard to the efficiency of these methods (assessed by the C P U time required for the ini t ia l izat ion plus the phase search), that requiring the least computational effort Chapter 4. Results and discussion 103 L iqu id phase search ini t ia l izat ion no. of iters./(CPU msecs. initlzn. + search)/wrong prediction system no. no. of data points modified Michelsen modified Gautam &; Seider Shah proposed method 1 11 65/(99)/0 63/(96)/0 54/(107)/0 54/(86)/0 2 16 99/(444)/2 121/(394)/0 121/(480)/0 121/(381)/0 3 11 37/(260)/0 39/(184)/0 39/(239)/0 39/(177)/0 7 3 6/(438)/0 6/(137)/0 6/(259)/0 6/(137)/0 Tota l 41 207/(1241)/2 229/(811)/0 220/(1085)/0 220/(781)/0 Table 4.3: Comparison of the reliability and efficiency of the four methods tested to provide initial compositions for the liquid phase search. Chapter 4. Results and discussion 104 is the proposed method as can be observed from the results presented i n Table 4.3. W h e n the number of components i n the mixture is large (about 6 or more), the modified Michelsen method is the most time consuming option. This becomes more patent as the number of components increases since in i t i a l ly as many composition vectors are used i n the phase search as there are components i n the system, which eventually are reduced to two or one. For mixtures wi th a reduced number of components this and Shah's methods were of similar efficiency. Thus, when reliabil ity is of primary importance at the sacrifice of speed Shah's method should be used, otherwise as a short-cut method the scheme proposed becomes advantageous. To give an idea of the proximity of the i n i t i a l composition estimates to the incipient phase compositions and of these to the equil ibrium values, the percent root mean square deviation (% R M S dev.) from the incipient l iquid compositions are given i n Table 4.4 for System 1 at conditions where two l iqu id phases were found 1 . A t 120 and 140 K the modified Michelsen method gave the closest estimates to the actual incipient phases but at the higher temperature (160 K ) Shah's and the proposed method gave better results, whereas the modified Gautam and Seider method gave poor estimates i n a l l cases. Since the compositions given by the modified Michelsen method are fixed, they are not dependent on the composition or temperature of the feed i n contrast to the other three methods. For a l l methods except the modified Michelsen, better estimates for the incipient phases were obtained as the temperature increased; also the incipient phases became better estimates of the equihbrium compositions (i.e., as T increased the composition of the incipient phases approached the equihbrium values.) Contrary to what could be expected, i t was found that not always (although i n most cases) having better composition estimates lead to convergence i n less number 1The composition vector obtained from Raoult's law, xfinit, is not considered in the calculation of the % RMS deviation. Chapter 4. Results and discussion 105 L iqu id phase search ini t ia l izat ion System 1: C H 4 ( 1 ) - C 0 2 ( 2 ) - H 2 S(3) P = 2 0 a tm modified mod. Gautam Sz Shah &: proposed equilib Hum T(K) Michelsen Seider (p=l,q=2) method (p=l,q=3) composition Li LII  n°- its- Li La  no- Li La no- its. Li Ln 120 0.8 1.3 5 24.0 20.0 7 4.6 7.6 5 9.4 4.8 140 2.8 3.7 5 20.1 15.2 8 3.9 5.9 6 8.0 4.4 160 5.9 6.7 13 16.8 10.8 8 3.3 4.8 6 6.7 3.9 % RMS dev. = [%2"-i(comp.i — incip. comp.if/nf-5 x 100 Table 4.4: % RMS deviation of the incipient phase estimates and of the equilibrium values from the actual incipient phases composition (mole fraction) in the prediction of LL immiscibility for System 1. Chapter 4. Results and discussion 106 of iterations as was the case at 160 K i n Table 4.4. A larger number of iterations were required to reach convergence when using the modified Michelsen method than when the modified Gautam and Seider scheme was employed, i n spite of the former method giving estimates much closer to the solution. W i t h respect to the in i t i a l l iquid composition vector obtained wi th Raoult 's law, i t was found that i n some cases i t was a good approximation for one of the incipient liquids when two were found or for the only l iquid when just one phase was detected. In other cases i t could be considered only fair. Since for the methods i n which phase initiators are selected one of the vector estimates usually was similar or at least resembled the composition vector obtained wi th the ideal solution assumption, i t was considered at one point that this vector was unnecessary. W i t h the idea to increase the efficiency of the search algorithm by reducing the number of in i t i a l vectors, the el imination of vector xfinit was tested. This was also done when using the modified Michelsen ini t ia l izat ion scheme to reduce the number of in i t i a l composition vectors from n +1 to n. The results obtained showed that indeed the search was faster when reducing by one the number of in i t i a l vectors (since the more in i t i a l vectors the more calculations are required). However, for System 2 failure i n the l iquid search occurred by removing the ideal behaviour estimates when using the modified Gautam and Seider, Shah's and the proposed methods which otherwise gave correct results for a l l the cases tested. For Systems 1 and 3 no failures were detected because of the removal of this vector from any of the ini t ia l izat ion methods. From these results i t was decided to include the composition estimates xf i n i t as one of the in i t i a l vectors for the sake of reliability even if an additional computational effort was required. For example, of 13 points tested wi th System 2 the C P U time saved by not considering this vector was of about 19 % when init ia l iz ing wi th the proposed algorithm, but at the expense of 3 incorrect predictions; for Systems 1 and 3 a reduction of 12 % and 11 % was achieved when testing 11 points for each system. Chapter 4. Results and discussion 107 The generation of adequate composition estimates for the methods i n which phase initiators are selected for each l iquid phase (modified G a u t a m and Seider, Shah's and proposed methods) depends to a great extent on the correct allocation of such compo-nents. For binary systems the selection is almost t r iv ia l 2 but not so when 3 or more components are present. From the results obtained i t was observed that i n the majority of the cases the same components were selected when using Shah's and the proposed method, and that when the modified Gautam and Seider method lead to convergence i n a larger number of iterations, different components than those obtained wi th afore-mentioned methods had been selected. For example, for System 1 (see Table 4.3) more iterations are required i n the search when using the modified Gautam and Seider method which designates as phase initiators p and q methane and carbon dioxide respectively, than wi th Shah's or the proposed method which select methane and hydrogen sulphide. 4.3 Phase search performance As seen i n the previous section, the performance of the search method for condensed phases depends to some extent on the init ia l izat ion routine employed. In addition, there are other factors that can be determinant i n the outcome of the detection of these phases such as the value of the parameters selected when Wegstein's method is applied or the criteria used to eliminate unnecessary composition vectors along the search. For the vapour phase, the search is less complex since only one composition vector is used and it is also less sensitive to the in i t i a l compositions or the acceleration parameters chosen. For either the vapour or l iquid phases the additional search for possibly missed phases can avoid erroneous predictions i n some cases. In this section the influence of these factors 2Although the decision of which components act as phase initiators is immaterial, the assignment of which is phase initiator p and which is phase initiator q can make a difference in the outcome of the results; e.g., the erroneous predictions shown in Table 4.2 are due to the incorrect allocation (swapped) of the two components. Chapter 4. Results and discussion 108 on the search algorithms is discussed. To illustrate the outcome of the search for a vapour and l iquid phases the results for System 2 i n the temperature interval from 90 K to 320 K at fixed pressure are given in Table 4.5. In this case Wegstein's method was used every three iterations (starting in the fourth) wi th a maximum step size r m a x = 3 and setting the convergence tolerance to 10~ 5 . F rom low to high temperatures, i n the range specified the system can exist as a L L mixture, as a single l iquid , then again as a biphasic l iquid mixture (i.e. there is a lower and upper consolute temperature), as a three-phase system (between 150 and 152 K , not shown i n Table 4.5), as a V L mixture and finally as a vapour. This complex behaviour was adequately predicted wi th the phase-splitting algorithm proposed (without using the addit ional vapour or l iquid phase searches) except for two cases when the modified Michelsen ini t ia l izat ion scheme was used. From 90 to 180 K the system is liquid-like and thus the vapour search method was applied (refer to the phase- splitt ing scheme i n Section 3.1) leading to correct predictions except at 150 K i n which a superfluous vapour was found (i.e. a vapour is not present i n the stable solution, however this phase appears at 150.2 K corresponding to the three-phase bubble point temperature at 40 atm) but was later eliminated with the phase removal tests implemented. Note that only a few iterations were required to achieve convergence i n the vapour search and that the computational effort required is min imal when compared to that needed for the search of the l iqu id phases. From 200 K upward the system is vapour-like and thus only the l iqu id phase search was conducted. Since the system is liquid-like from 90 to 180 K , in those cases i n which none or only one incipient l iquid was found an additional incipient l iqu id is considered present having a composition equal to the feed. Thus, finding only one incipient l iqu id when the system is stable as a L L or V L L system or none when it is stable as a l i qu id or as a V L mixture does not constitute an erroneous prediction as long as the system is l iquid-like because the feed is considered as an incipient phase. From Chapter 4. Results and discussion 109 Vapour and l iquid phases search System 2: hydrocarbons(l-5)-N 2 (6) P = 4 0 a tm T stable (K) system vapour search Raoult's law liquids search mod. Gautam Shah & Seider 90 L L 100 L L 110 L 120 L 130 L 140 L 150 L L 160 V L 180 V L 200 V L 220 V L 240 V L 260 V L 280 V L 300 V 320 V no V 2(4) no V 2(4) no V 2(4) no V 2(4) no V 3(5) no V 4(6) V 5 ( 6 ) V 5 ( 7 ) V 4 ( 6 ) vapour-like system 1 modified Michelsen 2L 16(49) 1L* 22(46) no L 3(22) no L 3(22) no L 3(22) no L 3(22) no L+ 4(25) 1L 13(36) 1L 7(30) 1L 3(24) 1L 3(23) 1L 3(23) 1L 4(25) 1L 4(27) no L 4(24) no L 4(24) 2L 13(40) 2L 24(66) no L 4(17) no L 3(16) no L 3(16) no L 3(16) 1L 25(47) 1L 13(29) 1L 7(23) 1L 3(17) 1L 3(17) 1L 3(16) 1L 4(18) 1L 5(22) no L 4(17) no L 4(17) 2L 13(45) 2L 24(71) no L 4(22) no L 3(21) no L 3(22) no L 3(21) 1L 25(51) 1L 13(33) 1L 7(26) 1L 3 (22) 1L 3(23) 1L 3(24) 1L 4(24) 1L 5(28) no L 4(24) no L 4(23) proposed method 2L 13(38) 2L 24(65) no L 4(17) no L 3(14) no L 3(16) no L 3(16) 1L 25(46) 1L 13(28) 1L 7(21) 1L 3(16) 1L 3(16) 1L 3(17) 1L 4(17) 1L 5(21) no L 4(17) no L 4(16) * Prediction leads to LL solution corresponding to a local minimum, not to the most stable solution. + With the modified Michelsen method a liquid is not found in the interval 148-151 K leading to an incorrect V L prediction. Table 4.5: Vapour and liquid phases search performance for System 2 from 90 to 320 K indicating the stable solution, the number of iterations required for convergence and the CPU time (in milliseconds) required for the initialization plus the phase search. Chapter 4. Results and discussion 110 110 to 140 K where neither l iquid or vapour incipient phases were found the system was correctly declared stable as a single l iqu id , avoiding the need of a flash calculation. The flash was also avoided at 300 K and above where no l iquid was found and the system was stated stable as a vapour. It is also noteworthy to mention that for this system whenever conditions were close to where a new stable phase appeared (i.e. near bubble or dew points), the number of iterations required i n the search of the corresponding phase increased noticeably, particularly for the l iqu id phase. 4.3.1 Vapour phase Initially, the search algorithm for the vapour phase was implemented i n similar fashion as described by Michelsen i n [4] but using Wegstein's method to accelerate convergence. Then most of the modifications leading to the final form of the a lgori thm were derived from changes made to the l iqu id search method (described i n the next section). A l though i n many instances the need for these modifications was not observed for the vapour phase search, they were incorporated into the algorithm for consistency w i t h the analogous l iquid search method and as 'safety' features to assure reliability. W i t h respect to the use of Wegstein's method, treated i n more detail i n Section 4.3.3, i t was rarely required for the vapour search since i t was applied after the third iteration and i n most cases convergence was achieved i n three iterations or less. However, for the cases where convergence had not been reached i n the fourth iteration, i t aided i n achieving it at a faster rate than when direct substitution was used. In practical ly a l l the cases tested, the search method proposed worked flawlessly either finding a vapour phase when present at equil ibrium or indicating its absence when not. Only at conditions very close to a bubble point (but not quite where a vapour has appeared) a vapour corresponding to a superfluous phase was occasionally detected i n the search. This was the case for System 2 at 150 K described above (see Table 4.5) i n which Chapter 4. Results and discussion 111 a vapour was found just below the three-phase bubble point temperature. Al though this could lead to an erroneous prediction, i t is taken into account since such a phase is considered only as a potential phase (this is always done when three phases are detected as explained i n the phase search strategy) whose presence is examined by the subsequent phase removal tests. For instance, for the example referred, the superfluous vapour was eliminated w i t h the multiphase flash test giving a correct L L prediction. Thus finding a superfluous vapour does not necessarily constitute a major fault. Of more serious consequences can be the situation i n which a vapour that exists at equil ibrium is bypassed i n the search. Since phases can not be added after the search has been conducted, the omission of the vapour would lead to a spurious prediction. W i t h the addit ional search proposed i n Section 3.2 the possibility for the occurrence of this problem is reduced. For example, when using the original Michelsen method or the proposed one without the additional phase search, an erroneous L L solution was predicted for the hydrogen sulphide(l)-methane(2) system (System 5) i n the feed composition range of about 0.15 to 0.25 i n hydrogen sulphide mole fraction. For the compositions wi th in this interval a vapour phase was missed i n the in i t i a l search of the phase-splitting method giving faulty L L predictions. W h e n the additional search was carried out, the vapour phase was successfully detected wi th the pseudo-tangent plane criterion proposed giving correct V L solutions i n a l l cases. Table 4.6 gives the results obtained i n the entire composition range when the configuration of the system was predicted w i t h a V L L flash calculation and w i t h the phase-splitting algorithm with and without the option to search for addit ional phases (the additional search for a l iquid phase was not conducted since conditions for i t are not met). W h e n the direct flash calculation was used to predict the equi l ibrium conditions incorrect results are obtained i n two cases. The Gibbs energy of mixing for System 5 as a function of composition is given i n Chapter 4. Results and discussion 112 Effect of the additional (vapour) phase search System 5: H 2S(1)-CH4(2) T-=190 K P= 38 a tm Z\ stable VLL flash proposed algorithm solution no additional additional phase search phase search 0.00 V V V V 0.05 V L V L V L V L 0.10 V L V L V L V L 0.15 V L V * LL+ V L 0.20 V L V L LL+ V L 0.25 V L V L LL+ V L 0.30 V L V L V L V L 0.35 V L L L * V L V L 0.40 V L V L V L V L 0.45 V L V L V L V L 0.50 V L V L V L V L 0.55 V L V L V L V L 0.60 " • V L V L V L V L 0.65 V L V L V L V L 0.70 V L V L V L V L 0.75 V L V L V L V L 0.80 V L V L V L V L 0.85 V L V L V L V L 0.90 L L L L 0.95 L L L L 1.00 L L L L Wrong prediction(s) 2 3 0 Tota l C P U time (msecs.) 276 278 280 * Incorrect prediction. + Wrong prediction due to the bypass of the vapour phase. Table 4.6: Phase equilibria predictions comparison for System 5 when the phase-splitting algorithm is used with the optional additional phase search to find a missed vapour giving correct VL equilibria solutions. Chapter 4. Results and discussion 113 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 hydrogen sulphide mole fraction Figure 4.13: Gibbs energy of mixing diagram for the hydrogen sulphide-methane system at 190 K and 88 atm (System 5) for which the vapour phase is detected with the additional phase search leading to the correct prediction of VL equilibria. Figure 4.13. As can be seen, the system is liquid-like almost throughout the whole com-position range except i n the hydrogen sulphide dilute region, where i t is vapour-like. This section of the Gibbs energy curve is the one that accounts for the presence of the vapour phase i n the V L solution. Al though i t may seem that a L L system is also feasible, the stable two-phase solution corresponds to a vapour rich i n methane and a l iquid rich i n hydrogen sulphide. For example, at the feed compositions zi=0.15, 0.20 and 0.25 the Gibbs energies of mixing are respectively 985.25, 897.36 and 809.48 cal /gmolefor the L L solution (2.61, 2.38 and 2.14 i n dimensionless terms) against 980.42, 892.87 and 805.31 cal /gmolefor the stable V L solution (2.60, 2.37 and 2.13 i n dimensionless form). In Table 4.6 are also given the total C P U times (in milliseconds) required for the calcula-tions presented in which the modified Michelsen method was used to init ial ize the l iqu id search (for 2 components it was more efficient than the other methods) and parameters e, Chapter 4. Results and discussion 114 w and tmax were set to 10~ 5 , 3 and 3 respectively. The direct flash algorithm was faster i n this case than the proposed phase-splitting method but the difference is negligible. Even when the additional phase search was conducted, the difference i n C P U time was insignificant. Considering the improved reliability obtained when this last option was chosen, the small additional computational effort is of no concern. W h e n the additional search was not executed, evidence of a vapour phase being bypassed i n the search was also observed for Systems 1 and 6. For System 1 ( C H 4 ( 1 ) -C02(2)-H 2 S(3) ) i n 2 out of the 66 points tested throughout the entire composition range (at 171 K and 20 atm) a vapour was not found when i t should have been. A t the feed composition Z i=0 .7 , Z2=0.1 and z 3 =0 .2 a vapour was not detected i n the in i t i a l search leading the phase-splitting algorithm to a L L equihbrium prediction (with Ag =409.03 cal/gmole) whereas the stable system is a three- phase mixture (Ag =408.56 cal/gmole). Similarly, for the point Z i=0.7 , z 2 =0 .3 and z 3 = 1 0 - 8 a L L solution was predicted when the system is i n fact stable as a V L mixture (Ap=553.45 ca l /gmole for the L L system versus Ag =548.02 cal/gmole for the V L solution). A g a i n i n this case the incorrect prediction was caused by skipping a vapour phase i n the search. W h e n selecting the option to carry out the additional search, for the first point ( z i= 0 . 7 , z 2 =0 .1 , z 3 =0.2) a vapour phase was st i l l not found and thus the correct solution could not be obtained. For the second point (z i=0 .7 , z 2 =0 .3 , z 3 = 1 0 - 8 ) a vapour phase was found (2/1—0.1591, 2/2=0.3493, t/ 3=0.4916) but of composition very different from the vapour found at equi-hbr ium (t/i=0.9725, 2/2=0.0275, 2/3 <10 - 5 ) , which caused its removal when the phase reduction tests were conducted. For the methane(l)-n-butane(2)-water(3) system (Sys-tem 6) only i n 1 of the 66 points tested at different compositions (T=311 K and P = 6 0 atm) a vapour was not found i n the in i t i a l phase search (at the feed composition z i=0 .2 , Z2=0.1 and z 3 =0.7) . As a consequence a wrong L L solution was predicted since the system is stable as a V L L mixture (the Gibbs energy of the system decreases i n 24.50 Chapter 4. Results and discussion 115 cal/gmole wi th the appearance of the vapour phase). Even when the addit ional phase search was carried out, the vapour phase was st i l l bypassed. Therefore, i n these cases the addit ional search for a vapour was not successful. Since no other systems were found for which a vapour was missed with the in i t i a l search, the addit ional search strategy implemented could not be tested more extensively. 4.3.2 Liquid phases The search method for l iquid phases as implemented i n the original form proposed by Michelsen [4] was found to function acceptably i n some cases but frequently incorrect predictions were obtained wi th i t . To improve its performance several modifications were devised, mainly wi th regard to the detection of convergence of any composition vector to the t r iv i a l solution (where the incipient phase searched has the same composition as the feed). These modifications were incorporated also for the vapour phase search, unless otherwise specified. The only difference is that i f unsuccessful convergence is detected for the vapor the calculation terminates whereas for the l iquid the corresponding vector is eliminated and the calculation continues, except i f a l l the other vectors have been eliminated i n which case the calculation also ends. As mentioned i n Section 3.2, Michelsen indicates that a t r iv i a l solution is found when \r - 1| < 0.2 and g* < 1 0 - 3 (parameter r is defined i n equation (2.22) and g* i n (2.20)) or when r > 0.8 and rk > r * - 1 . The first criterion was found adequate (\r — 1| < 0.2 and g* < 1 0 - 3 ) , but to detect as early as possible the approach to a t r iv i a l solution only the first condition seemed necessary. The reason for this is that i n many cases a few more iterations were required for the condition g* < 1 0 - 3 to be satisfied, but the outcome of the result was not changed if this condition was eliminated. The second criterion (r > 0.8 and rk > r*"1) was abolished as a test to detect a t r iv i a l solution since i n many occasions as a correct incipient phase was being approached, the value of r would increase Chapter 4. Results and discussion 116 (r being > 0.8) from one iteration to the other. Thus, instead of the criteria used by Michelsen, i n the modified method the value of r is tested to see i f i t is approaching 1 i n consecutive iterations since such pattern indicated an approach to a t r iv i a l solution or to a stable system (this gives check (b) i n Step 7 of the search methods, Sections 3.2.1 and 3.2.2). It was also found that early termination of the search should be made when stabil ity is detected before convergence is reached, i.e., when an incipient phase can not be formed from the original phase 3 . Based on this fact, a criterion to stop the search when YA=I  Xi < 1 a n < l this sum is decreasing i n consecutive iterations is established (corresponding to check (c) i n the search methods). In the cases where the value of the objective function (equation (3.46) or (3.73)) increased i n consecutive iterations, termination of the search for the corresponding vector was needed to avoid divergence i n the calculation since i n such case an incipient phase was not being approached (this situation is accounted for i n check (d)). These checks worked well i n situations where Michelsen's criteria failed. However, s t i l l for a few of the points tested, in particular for Systems 1 and 6, monitoring convergence wi th checks (b) through (d) was not sufficient to detect a t r iv i a l solution. Because of this, i t was necessary to first test i f the actual composition of the incipient phase being searched was approaching the feed composition. This is done wi th check (a) by testing if £ " = 1 - z,| < 2n x 10"4, where x, is the current composition vector (in mole fraction), i n which case a t r iv i a l solution is found. Final ly , an addit ional test was required i n the modified Michelsen method for the cases where convergence to an unstable solution was slow (especially for the l iquid phase). In this instance, when negative values of g* (which indicate an unstable system and thus the formation of a new phase) are not changing 3According to the stability criteria developed by Michelsen, a phase is stable if at a stationary point E " = 1 Xi < 1 (where X,- are the mole numbers of the phase being searched). Thus, whenever a stationary point corresponding to a stable phase is approached an incipient phase can not be obtained. Chapter 4. Results and discussion 117 significantly i n 3 consecutive iterations 4 , i t is considered that a new phase has been found even i f convergence has not been reached and the current value of the composition vector is taken as a converged solution. It was observed that i n this case i f convergence was allowed (taking as many iterations as necessary) the composition values of the converged solution were practically the same as those obtained when the above criterion was used. This test corresponds to check (e) i n the search methods for the vapour and l iquid phases. For the search of l iquid phases, Michelsen recommends that i f no negative values of g* are found after 4 iterations the composition vector wi th the smallest value of r be converged, el iminating the rest. This criterion was found faulty i n cases where a composition vector had large r values since i t would be eliminated from the search when such vector corresponded to an unstable t r i a l phase. To avoid this, an analogous criterion was established which consists on eliminating after the fourth iteration a l l the composition vectors (provided that for a l l g* was > 0) except the one wi th the largest value of |r - 1|, that is, the one furthest from the t r iv ia l solution. This alternative criterion, used only for the l iqu id phase search, performed adequately i n the cases tested (corresponding to check (g) i n the l iquid search method). Since during the l iquid phase search a l l the composition vectors are converged simul-taneously, i t is important to keep track of the vectors that have reached convergence and of those that are converging to a common point. In the first case, once a vector satisfies one of the convergence tests of Step 8 (Section 3.2.2) i t is saved along wi th the corresponding fugacity coefficients and then eliminated from the search. In many cases two or more vectors would be converging to a common point, and eventually became the same. To avoid excess calculations, a criterion was set to eliminate a l l alike vectors but one. The test for convergence to a common point is done i n Step 9 and the elimination takes place i n Step 10. In this last step the vectors that have converged to a min imum i n 4When stating that the values of g* did not change significantly a tolerance of 1 0 - 6 was allowed. Chapter 4. Results and discussion 118 Gibbs energy or to the t r iv i a l solution and those not l ikely to converge are also eliminated, namely those not marked i n check (g) of Step 7. W h e n al l vectors have been eliminated or when the maximum number of iterations allowed is reached, the calculation ends. If no l iqu id t r ia l phases are found, the system is stable wi th respect to the formation of a new l iqu id phase. If one incipient l iquid is found, it is arbitrari ly designated as l iquid I and i f the system is l iquid-like the composition of the feed is assigned to l iqu id II. If two or more l iqu id phases are found, again a test for convergence to a common vector is done i n case the test made i n Step 9 failed. This can happen i f a vector quickly converges to a solution and another one, in i t ia l ly being distinctively different from the first, eventually converges to the same point. In case three different l iquid t r i a l phases are found (which is unlikely but nevertheless may happen), the two wi th the lowest Gibbs energy of mix ing are considered as the incipient phases. W i t h the proposed modifications the l iquid phase search algorithm performed soundly for the systems tested. O n the rare occasions where an incorrect prediction was obtained wi th a particular ini t ia l izat ion scheme, a correct result could always be obtained when using an alternative method. In these cases the l iquid search method appears to be sensitive to the i n i t i a l compositions used and failure can be attributed at least part ia l ly to the ini t ia l izat ion method used. For most of the systems studied, one or two incipient liquids were found when at equihbrium this number of l iquid phases were present, except on certain occasions when the system was liquid-like where none or only one incipient l iquid was found respectively. For example, for System 2 (Table 4.5) points near the two-and three-phase dew points, as well as the other points tested, were always correctly predicted (except for two cases when init ial izing with the modified Michelsen method) i n spite of finding i n some cases one less incipient phase than the number present at equihbrium. Superfluous l iquid phases were found occasionally, mainly near dew point conditions Chapter 4. Results and discussion 119 but in other cases too. For instance, for System 1 at 160 K and 20 a tm two incipient l iquid phases were found (no incipient vapour detected) giving the correct prediction of a L L stable system. A t 180 K the system is stable as a V L mixture but s t i l l two incipient liquids were found i n the search (as well as an incipient vapour). A s for the vapour phase, the presence of superfluous phases is contemplated since the phase removal tests are always applied when three potential phases are found. W h a t must be avoided is the situation i n which a phase that exists at equihbrium is bypassed i n the search. For this reason the additional search presented i n Section 3.2 is suggested after the i n i t i a l search is conducted. As an example of the usefulness of the addit ional phase search, i n Table 4.7 are given the equil ibrium predictions for the binary mixture n-hexane(l)-water(2) (System 4) at 378 K and 5 a tm throughout the entire composition range. W i t h the V L L flash calculation incorrect predictions were obtained i n 4 occasions and i n 11 wi th the proposed algorithm (initial izing wi th the modified Michelsen method) when the additional phase search was not conducted. In contrast, when the addit ional search was carried out no erroneous predictions were obtained. In a l l cases i t was an addit ional l iqu id phase that was found giving a correct L L prediction instead of the wrong V L solution. As can be seen i n Figure 4.12, the system is vapour-like i n a l l cases where the l iqu id was missed i n the in i t i a l search. In the composition range from 0.10 to 0.55 i n n-hexane mole fraction i t was the n- hexane r ich l iquid that was bypassed i n the original search and then found wi th the additional search, whereas for the point corresponding to a feed composition of 0.80 (also i n n-hexane mole fraction) i t was the water r ich phase that was missed and then found. Similarly to the results shown i n Table 4.6, the extra C P U time required for the additional search is not very significant particularly when considering the improvement i n reliability (parameters e, w and tmax were also set to 1 0 - 5 , 3 and 3 to generate the results given i n Table 4.7). Contrary to what was observed for the vapour phase, the addit ional phase search was Chapter 4. Results and discussion 120 Effect of the additional (liquid) phase search System 4: nC6Hi 4 (1 ) -H 2 0(2) T=378 K P-=5 a tm Z\ stable VLL flash proposed algorithm solution no additional additional phase search phase search 0.00 L L L L 0.05 L L V L * L L L L 0.10 L L V L * V L + L L 0.15 L L L L V L + L L 0.20 L L V * V L + L L 0.25 L L V * V L + L L 0.30 L L L L V L + L L 0.35 L L L L V L + L L 0.40 L L L L V L + L L 0.45 L L L L V L + L L 0.50 L L L L V L + L L 0.55 L L L L V L + L L 0.60 L L L L L L L L 0.65 L L L L L L L L 0.70 L L L L L L L L 0.75 L L L L L L L L 0.80 L L L L V L + L L 0.85 L L L L L L L L 0.90 L L L L L L L L 0.95 L L L L L L L L 1.00 L L L L Wrong prediction(s) 4 11 0 Tota l C P U time (msecs ) 143 152 192 * Incorrect prediction. + Wrong prediction due to the bypass of a liquid phase. Table 4.7: Equilibria predictions when the phase-splitting algorithm is used with and without the optional additional phase search to find a missed liquid yielding correct LL equilibria solutions for System 4-Chapter 4. Results and discussion 121 very effective for System 6 i n finding an incipient l iquid . Out of the 66 points tested at various compositions (with starting values obtained wi th the proposed init ia l izat ion method), in 6 of them incorrect V L equilibria predictions were obtained because a n-butane r ich l iquid tr ia l phase was missed i n the in i t i a l search (these points are centered i n a well defined region around the feed point Zi=0.6, 22=0.2, 23=0.2). However, when using the additional search, i n a l l 6 cases a new incipient l iquid (rich i n n-butane) was detected giving correct V L L predictions. The additional l iquid search strategy was also tested for System 2 at 150 K i n which an incorrect V L system was predicted when using the modified Michelsen method to obtain in i t i a l l iqu id composition estimates. In this case, although a new incipient phase was found wi th the additional search, the correct L L solution was not obtained but a spurious single-liquid prediction. The reason for this is that the incipient phase found has a composition very far from the equil ibrium value (an n-pentane rich l iquid was found instead of a l iquid wi th composition similar to the feed) which causes the consequent L L flash to predict the presence of only one l iquid phase. A l iquid phase was bypassed by the in i t i a l search only for the systems described above, and therefore the results obtained when the addit ional search was used are discussed just for these mixtures. In short, as for the vapour phase, the additional l iquid search strategy worked very well for binary systems, increasing markedly the reliabil ity of the equil ibrium predictions. For mixtures wi th 3 or more components, i n which a simplified criterion derived from the pseudo-tangent plane criterion used for binary systems was implemented, the proposed addit ional search aided in finding bypassed l iquid phases i n many (but not all) cases. However, no successful results were obtained i n finding a vapour phase when missed i n the in i t i a l search. In an attempt to better understand the tangent plane criterion i n order to improve the additional phase search strategy for multicomponent systems ( n > 3), the Gibbs energy of mixing surfaces for the two three-component systems studied (Systems Chapter 4. Results and discussion 122 1 and 3) were plotted as a function of composition considering the systems as vapour, as l iquid and then as the stable system (this last one constructed from the surface portions having a lower Gibbs energy from either of the vapour or l iqu id surfaces). Al though the 3-D plots obtained helped i n visualizing these surfaces, the information gained from them was l imi ted i n spite of having the Gibbs energy contour lines that indicate the presence of points such as local or global minima. Such surfaces are shown for the methane(l)-n-butane(2)-water(3) system (System 6) at 311 K and 60 a tm i n Figures 4.14, 4.15 and 4.16. In the first figure the Gibbs energy surface is obtained by considering that the system is a vapour i n the entire composition range and i n Figure 4.15 by considering i t as a l iquid throughout. To do so, even at conditions where neither one of the phases can exist as a single phase, extrapolated val-ues of density are used as obtained wi th the equation of state i n order to calculate the necessary thermodynamic properties (fugacity coefficients). Figure 4.16 represents the Gibbs energy that the stable system would have, which is obtained by superimposing the surfaces for the vapour-like and the liquid-like systems and el iminating the highest values of Gibbs energy at each composition, i.e., only the portions corresponding to the lower Gibbs energy are shown. Because the Gibbs energy values for the vapour-like system are higher than for the liquid-like system at almost every composition, the combined surface (for the stable system) looks very similar to that for the l iquid-like system. Only i n the methane-rich portion of the surface (farthest corner from the observers view-point) does the vapour have a lower Gibbs energy than the l iquid and thus for the stable system the vapour curve prevails in this region although this is barely noticeable i n the surface represented i n Figure 4.16. Chapter 4. Results and discussion 123 Figure 4.14: Gibbs energy of mixing as a function of composition for the methane-n-butane-water system (System 6) at 311 K and 60 atm considered as a vapour. Figure 4.15: Gibbs energy of mixing surface for System 6 considered as a liquid in the entire composition range at 311 K and 60 atm. Figure 4.16: Gibbs energy of mixing for the stable system (System 6 at 311 K and 60 atm) obtained by superimposing the vapour and liquid-like surfaces and retaining the least Gibbs energy values at every composition. Chapter 4. Results and discussion 125 For System 1 similar 3-D diagrams were obtained. In them the surface corresponding to the vapour-like system was also above that obtained when considering the system as a l iqu id , except for the methane-rich portion of the diagram which indicates that a vapour composed mainly of methane is present as a stable phase for some feed compositions. The Gibbs energy of mixing surface as a function of composition for the stable system is given i n Figure 4.17. B y inspecting this diagram it is difficult to foresee that the system can split i n two or three phases at equihbrium, depending on the feed composition. Looking i n more detai l at the contour lines given i n Figure 4.18, there is s t i l l no clear indication that phase spl itt ing w i l l occur. However, when performing the equihbrium calculations (either wi th a direct flash or wi th the phase- splitt ing algorithm proposed), a significant decrease i n Gibbs energy was obtained when a phase-split occurred. For example, at the feed composition of Z i=0 .1 , Z2=0.8, z 3=0.1 the Gibbs energy of mix ing for the system as a vapour is 1425.19 cal/gmole, as a l iquid is 923.97 cal/gmole and as the stable V L solution 725.79 cal/gmole; at Z i=0 .3 , Z2=0.6, z 3=0.1 the values of Ag for the system as a single vapour, as a l iquid , as a V L mixture and as the stable V L L solution are 1491.25, 1210.02, 1207.51 and 1013.81 cal/gmole respectively. In Figure 4.19 the stability of the feed is given as a function of composition indicating the type and number of phases i n which the system w i l l separate i n order to reach a stable state. Figure 4.20 shows the composition of each of the phases found at equihbrium. A s can be seen, for the two-phase solutions the composition of the vapour and of l iqu id I remain i n well defined areas whereas that of l iquid II changes considerably depending on the feed point (when a V L solution is obtained i t is l iquid II that is found). W h e n the system separates i n three phases, the compositions of each phase remain fixed. V2& of ^ l " ^ -bo1* for of Chapter 4. Results and discussion 127 0.0 0.1 0.2 0.S OA OJS 0.6 0.7 0.8 0.9 10 mole f rac carbon dioxide Figure 4.19: Type and number of phases present at equilibrium in the composition plane for System 1 at 171 K and 20 atm according to the location of the feed. 0J2 0.3 OA 0.5 0.6 0.7 0.8 0.9 10 mole frac. carbon dioxide Figure 4.20: Composition of the phases formed at equilibrium when System 1 splits as two- or three-phase stable mixtures at different feed locations. Chapter 4. Results and discussion 128 The fact that the vapour-like Gibbs energy surface was above that for the liquid-like sys-tem at almost every composition is most certainly the reason why the additional vapour phase search failed for the multicomponent systems tested. As mentioned i n Section 3.2, the pseudo-tangent plane criterion used (for mixtures wi th 3 or more components) considers a pseudo-tangent plane orthogonal to the Gibbs energy axis (parallel to the composition plane for ternary systems). Thus, whenever the vapour Gibbs energy of mixing surface lies above this pseudo-plane, an incipient vapour w i l l not be found. Also , a missed l iquid could be more easily found wi th the additional search since the pseudo-tangent plane is more l ikely to intersect the Gibbs energy surface for the liquid-like system. This can be anticipated to happen for any system for which the vapour surface lies mainly above that for the system considered as a l iqu id . In the opposite case, when the surface for the l iquid lies chiefly above that for the vapour (which did not occur for the systems studied), i t could be expected that the additional search for a missed vapour would be more successful, wi th a corresponding decreased l ikelihood of locating any bypassed l iquid phase. 4.3.3 Wegstein's method To solve for the mole numbers (independent variables) from the stationarity condition written i n the form of equations (3.35), (3.60) and (3.61), direct substitution can be used but Wegstein's acceleration method was successfully applied to increase the convergence rate i n the search algorithms. As mentioned i n Section 3.2, the method is started i n the fourth iteration i f convergence has not been obtained after four direct substitution steps. Al though only two direct substitution steps are required to init iate the method, two more are conducted to provide better starting points and to assure proper convergence behaviour. The two important convergence parameters that can be specified by the user when opting for this method are the frequency of application w and the maximum step Chapter 4. Results and discussion 129 size tmax. The outcome of the search depends to some extent on the values assigned to these parameters, more so for the l iquid than for the vapour phase. In order to select the opt imum values of w and tmax which minimize the number of iterations required to achieve convergence, different combinations of these variables were tested for Systems 1, 2 and 3. The values of w tried were such that the method was applied on every i terat ion, or every second or third iterations (i.e., to=l , 2 or 3, respectively). W h e n the values of w were higher than 3, the method performed very s imilarly to direct substitution and its advantage over it was lost. The results obtained are summarized i n Table 4.8, which gives the number of iterations required to obtain convergence i n the vapour and l iqu id phase searches (in this last case using starting compositions given by the proposed ini t ia l izat ion method) setting the convergence tolerance to 1 0 - 5 . For each of the systems tested the temperature and pressure conditions are given as well as the number of data points tested, indicated i n parenthesis. Also the results obtained wi th direct substitution (by fixing w to 0 ) are given i n this table. From the results presented it is evident that no single combination of w and tmax can be considered opt imum. However, i t is clear that the acceleration method performed better than direct substitution except for the vapour search for System 1 for which similar results where obtained wi th both methods. For System 2 the use of Wegstein's method i n every iteration lead to faulty convergence irrespective of the value of tmax when searching for l iquid phases. This happened also for w=2 and tu=3 when the value chosen for tmax was small (tmax=1.5) and similarly when direct substitution was used. The results obtained indicate that the use of Wegstein's method every iteration is not advisable since oscillatory behavior i n the convergence was discovered in a few cases and even divergence may occur. B y alternating wi th one or more direct substitution steps this problem was eliminated. The best results were obtained when the acceleration is carried every two iterations and assigning a value of tmax between 3 and 6. Higher values for this last Chapter 4. Results and discussion 130 Wegstein's acceleration method no. of iterations vapour/liquid search Wegstein's method System (no. of data points vapour/liquid) 1 (5/6) 2 (5/5) (1/1) S (1/4) frequency tmax 120-*220 K 90-* 170 K 169.9 K 430 K w 20 atm 40 atm 60.5 atm 20^ 50 at 1.5 10/39 18/55** 7/14 9/17 1 3.0 10/35 18/61* 7/12 8/17 4.5 10/35 18/54* 7/12 6/17 6.0 10/35 18/54* 7/12 11/17 1.5 10/40 18/82* 7/17 9/17 2 3.0 10/35 18/83 7/11 9/17 4.5 10/35 18/68 7/11 6/17 6.0 10/35 18/65 7/11 10/17 1.5 10/40 18/82* 8/17 10/17 3 3.0 10/36 18/84 6/13 9/17 4.5 10/35 18/79 6/13 11/17 6.0 10/35 18/73 6/13 11/17 direct substitution 10/43 19/89* 10/19 13/19 * Incorrect prediction obtained once because of improper convergence. ** Erroneous prediction obtained at two points because of faulty convergence. Table 4.8: Performance of Wegstein's method in the vapour and liquid phase search as a function of parameters w and tmax for Systems 1, 2 and 3 compared to the use of direct substitution. Chapter 4. Results and discussion 131 parameter d id not improve the outcome of the calculations and can be detrimental i f much larger than 10; values too close to 1 reduce the method to direct substitution. A second choice would be to accelerate every third iteration wi th the maximum step size parameter also i n the interval from 3 to 6. Because the opt imum convergence parameters may vary from one system to another, the values given above (obtained from the results of Systems 1, 2 and 3) served only as guidelines which were used for the other systems tested. It was found that convergence i n the vapour search was relatively insensitive to parameters w and tmax except at high pressures, where direct substitution became slow and the use of Wegstein's method improved significantly the convergence rate as for the l iquid search. A l though for many of the points tested the objective function 9(1; ) o r ^j(xj,i) (de-fined by equations (3.46) and (3.73)) decreased right after the acceleration method was applied, this was not always the case. For some systems (in particular 1 and 2) i t was frequent that when compositions were accelerated wi th Wegstein's method, the objective function evaluated at that iteration increased wi th respect to the value obtained i n the previous one. Then i n the following iteration a significant decrease would be achieved. This behaviour can be explained by the way i n which 9 is defined, i.e., as the sum of the absolute value of the difference i n compositions obtained i n the present and i n the pre-vious iterations. Thus, when a notable variation i n the compositions was obtained after accelerating, the objective function augmented accordingly. Then i n the following itera-t ion, w i t h the compositions closer to the converged values, 9 would decrease markedly. O n a few occasions it was also found that when the objective function increased after using Wegstein's method, oscillations in the calculation and even divergence would occur i f the method was applied continuously wi th the pre-specified frequency. For this reason whenever the value of 9 increased after accelerating, the frequency of the method was reduced to break the undesirable pattern. In such cases i t is employed only every n * w Chapter 4. Results and discussion 132 iterations, where 7  is a control variable which is increased by one ( init ial ly 77=1) when the objective function increases. W h e n 5 decreases after accelerating, the frequency of use is set to its original value by fixing 7  to 1. This strategy worked well i n every case tested allowing the use of Wegstein's method i n a reliable manner. Examples of the matters treated above are given i n Figures 4.21, 4.22 and 4.23 where the performance of Wegstein's method is compared w i t h that of direct substitution. Figure 4.21 concerns the vapour phase search for System 2 at 169.9 K and 60.5 atm; at this high pressure convergence became slow when direct substitution was used, requiring 10 iterations to achieve a tolerance of 1 0 - 5 . Using Wegstein's method wi th a frequency iy=3 and wi th tmax = 3 convergence was reached i n only 6 iterations (the same result was obtained wi th tmax set to 4.5 or 6 as indicated i n Table 4.8). In this case, when compositions were accelerated i n the fourth iteration the objective function decreases wi th respect to the value of the previous i teration, but increased when compared to the result obtained when using direct substitution. Then i n the next i terat ion a considerable reduction i n 5 was obtained leading to convergence i n one more iteration. Since the frequency of application was set to 3 i n this case, the acceleration would have been conducted i n the seventh iteration i f convergence had not been reached i n the sixth. W h e n w was fixed to 2 (not shown i n the figure) acceleration took place in the sixth iteration but the objective function d id not decrease enough to achieve convergence unt i l the seventh iteration. In Figure 4.22 the convergence behaviour for the l iqu id phase search is shown again for System 2 but at 160 K and 40 atm. Al though the convergence criterion was not met (e = 1 0 - 5 ) because the calculation was terminated early (check (e) i n Step 7 of the search method was satisfied), using Wegstein's method improved the convergence rate considerably. In this case w was set to 2 wi th t m a i = 4 . 5 . After accelerating in iteration 4, the objective function increased i n relation to the previous iteration and thus parameter Chapter 4. Results and discussion 133 0.1 e 1.000E-06 ' 1 — 1 1 — 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 10 iteration number Figure 4.21: Performance of direct substitution and Wegstein's method in the vapour phase search for System 2 at 169.9 K and 60.5 atm 1.000E-04 ' — ' — ' — 1 — L — i — 1 — L — J — 1 — 1 — L — i — 1 — 1 — 1 — 1 — 1 — 1 — 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 iteration number Figure 4.22: Convergence behaviour when using direct substitution and Wegstein's method in the liquid phase search for System 2 at 160 K and 40 atm. Chapter 4. Results and discussion 134 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 iteration number Figure 4.23: Convergence characteristics of Wegstein's method compared with direct sub-stitution in the liquid phase search for System 1 at 180 K and 20 atm. r) was set to 2. Then the frequency of application of Wegstein's method was changed to every 4 iterations (77 * w = 4); therefore the next time compositions were accelerated was i n iteration 8. If the calculation had not been terminated early and convergence had not been reached, since i n iteration 8 the objective function increased, the method would have been applied again i n iteration 14 (since n was set to 3 acceleration would be conducted every 6 iterations). O n both occasions that Wegstein's method was used 5 increased i n that iteration but decreased notably i n the next. O n l y the convergence behaviour of one composition vector is shown i n Figure 4.22 since i n this case only one phase was found i n the search. For System 1 at 180 K and 20 a tm two composition vectors were converged because two l i q u i d phases were found i n the search. The results are shown i n Figure 4.23. App ly-ing in i t i a l l y Wegstein's method every 3 iterations with tmax fixed to 3, the convergence Chapter 4. Results and discussion 135 tolerance (e = 1 0 - 5 ) was reached for l iquid I (the slowest to converge) i n 11 itera-tions, whereas wi th direct substitution it took 19. For this phase the objective function increased after accelerating the first time (iteration 4) and also the next occasion i n itera-t ion 10 (the acceleration frequency was changed from 3 to 6). In both instances a decrease i n 5 was obtained i n the following iteration. For the composition vector corresponding to l iquid I I convergence was achieved in 8 iterations whether Wegstein's method was used or not, but when used the objective function 5 acquired a much lower value. After accelerating the first time 5 was reduced and the method was applied again i n the sev-enth iteration, where i t increased (with respect to the value obtained i n iteration 6) but then dropped i n the next iteration, reaching convergence. 4.4 Phase removal tests The strategies developed for the phase removal tests to eliminate superfluous phases were described i n detail i n Section 3.4. In the previous Sections 4.3.1 and 4.3.2 i t was mentioned that whenever three potential phases were found i n the phase search, the need for such tests arose mainly i n calculations near saturation point conditions. Examples already seen are the superfluous vapour found for System 2 at 150 K and 40 atm near the three-phase bubble-point (located at 150.2 K at 40 atm) and the calculation for System 1 at 180 K and 20 atm where a superfluous l iquid was found close to the three-phase dew-point conditions (171.1 K at 20 atm). 4.4.1 Multiphase flash method In the iterative scheme proposed for the multiphase flash method a maximum of five iterations are allowed to determine if any of the phases found should be eliminated. This l imi t was set to gain efficiency by declaring the system stable as V L L i f at that point Chapter 4. Results and discussion 136 no phase had been eliminated, since each iteration corresponds to a ful l three-phase flash calculation. Also , by setting the l imit of the control variables vy, vjJl and viIII to 3 (as opposed to the value of 5 indicated i n [5]) a good compromise was obtained between speed and dependability. In Table 4.9 are given the results obtained wi th this method (also w i t h the bubble- and dew-point equations method) and w i t h the subsequent flash calculation for three systems tested near saturation point conditions. In a l l cases the splitt ing algorithm was carried out without the addit ional phase search option. For System 1 at the feed composition z i=0 .5 , 22=0.1, .23=0.4 and 20 a tm, correct results were obtained w i t h the phase removal method at conditions near the three-phase bubble- and dew-points (located at 170.1 K and 171.1 K respectively). In a l l cases the outcome of the test indicated the presence of the phases corresponding to the stable system. These predictions were the same as obtained when the subsequent flash calculation followed (either two- or three-phase, depending on the results of the phase removal test) to obtain the exact phase distribution and compositions. In four of the six points tested for System 2 near saturation points (Table 4.9), no phase el iminat ion took place when the mixture was actually stable as a two-phase system (the three-phase bubble- and dew-point temperatures are 150.2 and 151.3 K at 40 atm). However, when the eventual three-phase flash was conducted to obtain quantitative results, i t was properly reduced to a two- phase flash giving correct predictions. In such cases the phase- splitting algorithm anticipated a higher number of phases present at equihbrium. This problem could be avoided by increasing the l imi t i n the number of iterations i n the phase removal test, but since usually a flash calculation follows the phase-splitting prediction (except when only the phase distr ibution is pursued), this was not considered necessary. As shown i n Table 4.9, near the three-phase bubble-point correct predictions were obtained for System 3 wi th the phase removal test and wi th the subsequent flash. Chapter 4. Results and discussion 137 Phase removal tests multiphase flash method bubble & dew point method T(K) stable system test result flash result test result flash result System 1: C H 4 ( 1 ) - C 0 2 ( 2 ) - H 2 S ( 3 ) zl = 0.5 z2 = 0.1 P = 2 0 a tm 167 L L L L L L V L * V L 170 L L L L L L V L L + V L X 170.6 V L L V L L V L L V L L V L L 171 V L L V L L V L L V L L V L L 172 V L V L V L V L V L 180 V L V L V L L * L 200 V L V L V L V L L + V L System 2: hydrocarbons(l-5)-- N 2 (6) P = 2 0 a tm 150 L L V L L + L L V L L + V L 150.9 V L L V L L V L L V L L V L L 151.7 V L V L L + V L V L L 4 " V L 152 V L V L L + V L V L L 4 " V L 160 V L V L L + V L V L L + V L 180 V L V L V L V L L L L X System 3: hydrocarbons(l-5)-- H 2 0 ( 6 ) T=430 K P(atm) 25 V L L V L L V L L V L L V L L 30 V L L V L L V L L V L L V L L 35 V L L V L L V L L V L L V L L 40 L L L L L L L L L L * Erroneous result in the phase removal test leading to incorrect phase-splitting prediction. + No ph ase elimination with the phase removal tests but done in the subsequent 3-phase flash. x Incorrect result in the 3-phase flash. Table 4.9: Performance of the phase removal tests and of the subsequent flash calculation in the phase-splitting prediction for Systems 1, 2 and 3 near saturation point conditions. Chapter 4. Results and discussion 138 4.4.2 C o u p l e d m e t h o d Earl ier i n Section 3.4 it was mentioned that whenever the option to carry out the ad-dit ional phase search is selected i n the phase- splitt ing algorithm, superfluous phases (either vapour or l iquid) may be found. These phases should then be eliminated wi th the phase removal tests proposed. Unfortunately, i t was discovered that when conducting the addit ional phase search, the outcome of the phase reduction test based on the mult i -phase flash method was incorrect i n some cases due to very poor composition estimates of the addit ional l iquid phase found which would throw-off the calculation. This d id not happen when the test based on the bubble- and dew-point method of Nelson was applied. The results of these tests are presented i n Table 4.10 for Systems 1 and 6 at the conditions specified when tested i n the entire composition range (considering 66 different feed compositions). For the former system at 171 K and 20 a tm, two incorrect results were obtained wi th the multiphase flash removal test when the addit ional phase search was not conducted; however, when it was executed, incorrect predictions were obtained i n 5 more occasions (nevertheless more incorrect results were obtained wi th the bubble-and dew-point equations test and wi th the direct three-phase flash). In the additional 5 cases the system was found to be liquid-like, in i t i a l ly a vapour was found i n the search but no l iquid phases 5 , and wi th the addit ional phase search a l iquid was recognized. W i t h Nelson's method (bubble- and dew-point) these points were correctly predicted. Poorer results were obtained wi th the multiphase flash method at 200 K and 20 a tm when conducting the additional phase search since the incorrect predictions hiked from 2 to 13, a number much higher than wi th the other options. A g a i n i n these cases the system was l iquid-like, i n the search a vapour was detected but no liquids, except i n the addit ional search, and Nelson's method performed fine. 5This corresponds to case iii) described in the phase search strategy at the beginning of Section 3.2 Chapter 4. Results and discussion 139 Because of these observations it was decided to implement the improved empirical phase removal strategy described in Section 3.4.3 (coupled method), which can be selected as an option when the type of phase removal test is specified. The results obtained wi th this strategy are given i n Table 4.10. For System 1 the incorrect predictions were reduced to 2 at both temperatures, making the method the most reliable and efficient at 171 K , and as reliable as the direct three-phase flash but slightly slower at 200 K . In contrast to System 1, for System 6 the additional phase search helped i n reduc-ing the incorrect predictions from 9 to 5 when the multiphase flash reduction test was used. Nevertheless, i n two cases incorrect predictions were obtained again because poor estimates of the incipient l iquid found. W i t h the coupled method devised these wrong predictions were avoided, reducing to 3 the cases where faulty results were obtained as compared to 4 when Nelson's method was employed and to 13 when the direct three-phase flash was conducted. 4.4.3 Bubble- and dew-point equations method In order to increase the efficiency of the method suggested by Nelson [3], one or two of the phases found i n the search are subject to be eliminated when any of the corresponding tests is satisfied i n three consecutive iterations instead of waiting unt i l convergence is obtained (see Section 3.4.2). This is justified by the observation made i n practically a l l the cases tested: once three consecutive identical predictions were obtained, the same result would be obtained when convergence was reached. The results given i n Table 4.9 (which were obtained without the additional phase search) indicate that this method was less reliable than the multiphase flash approach for Systems 1 and 2 but performed equally well for System 3. In two occasions incorrect results were obtained for System 1 because of the phase removal test (at 167 K and 180 K ) ; for the point at 180 K the removal of two phases Chapter 4. Results and discussion 140 Phase removal tests no. of incorrect predictions (CPU time, msecs.) System 1 171 K, 20 atm 200 K, 20 atm System 6 311 K, 60 atm multiphase flash method without the addit ional search 2 (1150) 2 (917) 9 (1066) multiphase flash method wi th the addit ional phase search 7 (1238) 13 (1088) 5 (1295) bubble &; dew point method without the addit ional search 9 (1214) 0 (925) 10 (1138) bubble & dew point method wi th the addit ional search 9 (1329) 0 (1228) 4 (1401) coupled method wi th the addit ional search 2 (1237) 2 (1210) 3 (1297) direct three-phase flash 8 (1276) 2 (1024) 13 (906) Note: 66 points where tested for each system in the entire composition range Table 4.10: Comparison of the phase removal tests reliability with and without the ad-ditional phase search versus the direct three-phase flash calculation for Systems 1 and 6. Chapter 4. Results and discussion 141 was incorrectly executed, giving an erroneous L solution. For the points tested at 170 K and 200 K no phase removal was done i n spite of a two-phase solution being stable. A t 170 K , three phases were anticipated and when the subsequent flash was executed, an erroneous V L prediction was obtained instead of the stable L L solution. A t 200 K the three- phase flash was reduced to a V L flash giving a correct final result. For System 2, V L L solutions were determined i n four cases whereas the final calculation conducted wi th the flash (three- phase) indicated a V L stable mixture. Thus, as w i t h the multiphase flash based method, more phases than those present at equi l ibr ium were predicted i n most cases for this mixture. A t 180 K again three phases were declared stable and then the eventual flash gave an erroneous L L solution. F inal ly , the results obtained for System 3 gave correct predictions for a l l the points tested. W h e n considering the results given i n Table 4.10, i t is evident that performing the addit ional phase search did not set back the outcome of the phase removal test based on the bubble- and dew- point method, and for System 6 i t aided i n six occasions to obtain correct predictions. Al though for System 1 at 200 K correct results were obtained i n every case wi th this test, when considering the points tested at 171 K and for System 6 as wel l as those shown i n Table 4.9, i t seems that Nelson's approach is more prone to failure than the method based on the multiphase flash. A n exception to this is the particular s ituation described above when the additional phase search is conducted (i.e. a l iquid is found when the system is l iquid-like, a vapour is found i n the in i t i a l search but no l iquids), where the use of Nelson's method avoids the incorrect predictions. The coupled method suggested takes advantage of this and constituted the most robust option for the systems mentioned above as well as for the other systems tested. Chapter 4. Results and discussion 142 4.5 Overall phase-splitting prediction performance As indicated at the beginning of this chapter, the equil ibria conditions predicted with the algorithm proposed are compared wi th the results of the direct three-phase flash calculation. To obtain the equihbrium compositions and phase ratios after the number and type of phases have been determined wi th the phase-splitting algorithm, the corre-sponding flash calculations (if necessary) are also executed. As starting values for these calculations the compositions found i n the phase search are used as suggested in the general scheme described i n Section 3.1. For the direct three- phase flash method, the i n i t i a l estimates of the compositions and the phase ratios are obtained according to the ini t ia l izat ion schemes described i n Appendix A . In order to compare the computational effort required to generate the in i t i a l estimates i n this form and w i t h the phase-splitting algorithm, as well as that needed to conduct the flash 6 , detailed results indicating the C P U time (milliseconds) spent for these computations are given for Systems 1, 2, 3 and 7 i n Tables 4.11 to 4.14. In these tables are also shown the temperatures and pres-sures specified, the stable systems at equihbrium, the predictions w i t h the V L L flash and w i t h the phase- splitt ing algorithm, and the type of flash required according to this last algorithm. F inal ly , i n Table 4.15 is given a summary of the results obtained for the seven systems tested. In this table are indicated the number of data points tested for each system, the number of cases i n which incorrect predictions were determined w i t h the direct three-phase flash and wi th the corresponding flash following the splitt ing algorithm (if neces-sary), and the C P U time (msecs.) required for the entire calculations (comprising either the flash ini t ia l izat ion or the phase-splitting step, and the flash). The parameters and 6When the flash calculations are performed, compositions are accelerated with Wegstein's method applied every 2 iterations with damping since this gives the best results according to [5] (see also Appendix A). Chapter 4. Results and discussion 143 options selected for the phase-splitting algorithm are those considered as default values, based on the overall best performance for the systems tested. These are: ini t ia l izat ion of the l iquid phase search wi th the proposed algorithm (except for binary mixtures i n which the modified Michelsen method is used), Wegstein's method applied every two iterations (tu=2) wi th tmax = 2, use of the additional phase search, convergence tolerance e = 1 0 - 3 i n the search and phase removal test wi th the coupled method. To make the comparisons equitable, the same convergence tolerance e was specified for the flash calculations i n the direct V L L flash and the flash conducted after the phase-splitting prediction (set to io-5). For System 1 (Table 4.11) correct predictions were obtained wi th both methods for a l l the points i n the temperature range specified. Considering that the three-phase bub-ble and dew temperatures are 170.1 and 171.1 K respectively and that the two-phase dew-point occurs at 260.8 K , the predictions obtained wi th the phase-splitting algorithm indicate that the phase search and phase removal tests worked equally well near these saturation points as wi thin the one-, two- and three-phase regions. A l though the in i t ia l -izat ion for the direct three-phase flash as suggested i n [5] was much quicker than wi th the phase-splitting algorithm for this three component system, the flash calculations required less computational effort when the phase-splitting results were employed. The reason for this is that the values provided i n this form are much closer to the equihbrium solutions. Also , the flash calculation was very efficient because a considerable amount of time was saved by conducting only a two-phase flash when only two phases were present and since the flash was avoided at conditions where only one phase exists. However, the overall C P U time consumed with both methods was practical ly the same: 251 msecs. for the direct three-phase flash against 250 for the phase- splitting-flash method init ia l iz ing wi th the proposed algorithm, using Wegstein's method wi th w = 3, tmax = 3, without the addit ional phase search, using the multiphase flash removal test and setting e = 10" 3 Chapter 4. Results and discussion 144 Phase-splitting prediction performance System 1: C H 4 ( 1 ) - C 0 2 ( 2 ) - H 2 S(3) zx = 0.5 z2 = 0.1 P = 2 0 atm prediction (initlzn. CPU time/flash CPU time) T(K) stable system VLL flash phase- splitting flash type 120 L L L L (2/8) L L (9/3) 2-<f> 140 L L L L (2/9) L L (12/4) 2-<f> 160 L L L L (2/10) L L (9/5) 2-(j> 166 L L L L (3/11) L L (10/4) 2-(j> 167 L L L L (3/11) L L (10/4) 2-<j> 170 L L L L (3/9) L L (14/4) 2-(j> 170.6 V L L V L L (3/10) V L L (18/8) 3-<f> 171 V L L V L L (3/11) V L L (18/8) 3-<f> 172 V L V L (3/14) V L (15/4) 2-<f> 180 V L V L (2/15) V L (14/4) 2-<j> 200 V L V L (2/14) V L (12/3) 2-(f> 220 V L V L (2/13) V L (7/3) 2-<f> 240 V L V L (2/11) V L (7/3) 2-<j> 260 V L V L (3/11) V L (7/2) 2-<j> 261 V V (3/11) V (7/0) not needed 280 V V (3/12) V (7/0) not needed 300 V V (2/13) V (8/0) not needed 320 V V (3/12) V (7/0) not needed Tota l (46/205) (191/59) Initlzn. for the liquid search with the proposed algorithm, to = 3, tmax = 3, no additional phase search, multiphase flash phase removal test. Table 4.11: Comparison of the prediction of the phase distribution for System 1 at differ-ent temperatures with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding type of flash. Chapter 4. Results and discussion 145 (268 msecs. were required when fixing e to 1 0 - 5 i n the phase search, but practically iden-t ical results were obtained). Therefore, the efficiency and reliability of both approaches is comparable for this system at the conditions specified to obtain the results given i n Table 4.11 and no advantage is gained using a particular method. The results pertaining to the calculations at 171 K and 200 K (both at 20 atm) when the feed was varied along the entire composition plane are also summarized in Table 4.15. W h e n the specified temperature is 171 K , the phase-splitting algorithm was more dependable and slightly more efficient than the direct flash calculation. A t 200 K both methods gave 2 erroneous predictions, wi th the former algorithm requiring also less global C P U time to obtain the equihbrium compositions and phase distribution. B y reducing the convergence tolerance from 1 0 - 3 to 10~ 5 i n the phase search, the C P U times increased to 1264 msecs. at 171 K and 1194 at 200 K (not shown i n Table 4.15), but this did not alter the outcome of the calculations and st i l l two erroneous predictions were obtained i n each case. In the calculations done for System 2, the direct three-phase flash gave incorrect results i n 5 of the 19 points tested. Al though when using the phase-splitting algorithm a three-phase solution was predicted i n 4 occasions, the stable system being two-phase, correct predictions were obtained after executing the flash as shown i n Table 4.12 (this has already been discussed i n Section 3.4 and presented i n Table 4.9). For the rest of the points where only two phases exist at equihbrium, the use of the specific two-phase flash (either L L or V L ) reduced considerably the computational load required, and when only the existence of one phase was predicted the evasion of the flash was definitely time-saving.. For this six component mixture the generation of in i t i a l estimates for the direct three-phase flash was faster on a global basis (but not at every point) than wi th the phase-splitting counterpart when not considering the following flash calculation (492 msecs. against 608). However, the difference was reduced notably when the results Chapter 4. Results and discussion 146 Phase-splitting prediction performance System 2: hydrocarbons(l-5)-N 2 (6) P = 4 0 a tm prediction (initlzn. CPU time/flash CPU time) T(K) stable system VLL flash phase- splitting flash type 90 L L L * (25/32) L L (32/8) 2-0 100 L L L * (26/33) L L (54/7) 2-0 110 L L (26/32) L (22/0) not needed 120 L L (26/31) L (22/0) not needed 130 L L (26/29) L (23/0) not needed 140 L L (26/35) L (22/0) not needed 150 L L V L * (25/47) L L (58/113) 3-0+ 150.9 V L L V L * (26/35) V L L (58/13) 3-0 151.7 V L V L (26/35) V L (57/27) 3-0+ 152 V L V L (26/35) V L (57/32) 3-0+ 160 V L V L (25/37) V L (46/31) 3-0+ 180 V L V L (26/79) V L (33/11) 2-$ 200 V L V L (26/28) V L (17/12) 2-<j) 220 V L V L (26/29) V L (17/8) 2-0 240 V L V L (26/31) V L (17/8) 2-0 260 V L V L (26/32) V L (17/8) 2-0 280 V L V * (27/34) V L (21/8) 2-0 300 V V (26/33) V ( 1 7 / 0 ) not needed 320 V V ( 2 6 / 3 3 ) V (18/0) not needed Tota l (492/680) (608/286) * Incorrect prediction. + No phase elimination in the phase removal test but done in the subsequent flash. Initlzn. for the liquid search with the proposed algorithm, w — 2, tmax = 5, no additional phase search, multiphase flash phase removal test. Table 4.12: Predictions of the equilibrium conditions for System 2 at different tempera-tures with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding type of flash. Chapter 4. Results and discussion 147 are compared to the three component System 1 (Table 4.11). This trend, i.e., the phase-splitt ing approach being much more efficient as the number of components i n the mixture increases, was observed i n a l l cases and becomes very patent for System 7 (having 13 constituents) as w i l l be addressed later. Table 4.15 indicates that for the points tested, the phase-splitting algorithm is not only more reliable on a global basis when the flash is used subsequently, but also more efficient. The phase-splitting-flash method proposed was particularly advantageous over the di-rect three-phase flash under the conditions tested for System 3. B o t h methods performed without fault i n a l l instances, but the gain i n efficiency when the equihbrium conditions were determined wi th the phase-splitting method is evident as shown i n Table 4.13 and part icularly w i t h the default parameters according to Table 4.15. In most cases the in i -t ia l izat ion part of the methods was faster with the phase- splitting approach, but the benefit of this method came mainly i n the final flash calculation (when necessary) where convergence was obtained readily. Only a few iterations were required i n the flash be-cause the equihbrium composition estimates generated wi th the phase-splitting method (by means of the phase search strategy) are very close to the solution. Al though only three points were tested for the 13 component mixture tested (System 7), i t is evident that when a large number of species are present the computational load required i n the phase equil ibria predictions can be greatly decreased if the phase- sphtting method is em-ployed. This can be observed i n the results presented i n Table 4.14. Not only the total C P U t ime was brought down when compared to the direct three-phase flash because the flash is avoided or only the two-phase calculation is performed, but also the ini t ia l izat ion of these calculations was much faster with the phase-splitting approach. For System 4, which is one of the binary mixtures tested i n the whole composition range, the phase-splitting-flash method was slightly more time-consuming than the direct three-phase flash when calculations were done with the default values. Nevertheless, Chapter 4. Results and discussion 148 Phase-splitting prediction performance System 3: hydrocarbons( l-5)-H 2 0(6) T=430 a tm prediction (initlzn. CPU time/flash CPU time) P(atm) stable system VLL flash phase- splitting flash type 5 V V (27/25) V (15/0) not needed 10 V V (25/25) V (15/0) not needed 15 V V (27/22) V (15/0) not needed 20 V L V L (27/24) V L (18/4) 2-(f> 25 V L L V L L (27/16) V L L (34/3) 3-<f> 30 V L L V L L (27/16) V L L (34/3) 3-<j> 35 V L L V L L (26/22) V L L (36/3) 3-<f> 40 L L L L (26/41) L L (22/4) 2-<f> 60 L L L L (26/22) L L ( 2 1 / 8 ) 2-<f> 80 L L L L (26/18) L L (19/8) 2-<f> 100 L L L L (25/18) L L (19/8) 2-<j) Tota l (289/249) (248/41) Initlzn. for the liquid search with the proposed algorithm, w = 3, tmax = 3, no additional phase search, multiphase flash phase removal test. Table 4.13: Number and type of phases predicted for System S at different pressures with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding flash. Chapter 4. Results and discussion 149 considering that at a l l points correct predictions were obtained as indicated i n Table 4.15, this method is more appealing that the direct flash counterpart when dependability becomes an important factor. For this last method (direct three-phase flash), erroneous predictions were obtained i n 4 occasions. For the other binary mixture tested, System 5, the phase-splitting algorithm was more reliable than the direct flash (no erroneous predictions versus two wi th the flash) and also more efficient as indicated i n Table 4.15. The results obtained for System 6 (ternary mixture) , given also i n Table 4.15, indicate again that the direct flash was somewhat more efficient than the proposed method, but reliabil ity was sacrificed. In this case 13 incorrect results were predicted with the direct flash (out of 66), whereas the phase-splitting approach failed to give correct predictions only at 3 feed points. B y setting e to 1 0 - 5 reliability was not improved and the C P U time increased to 1297 msecs., which indicates that a more strict convergence tolerance i n the phase search was not beneficial. Chapter 4. Results and discussion 150 Phase-splitting prediction performance System 7: compressor gas mixture prediction (initlzn. CPU time/flash CPU time) T(K) P(atm) stable system VLL flash phase-splitting flash type 283 283 327 5 15 15 V V L V V (495/68) V L (504/84) V (504/71) V (52/0) V L (53/27) V (54/0) Tota l (1503/223) (159/27) Initlzn. for the liquid search with the proposed algorithm, w = 3, tmax = 3, no additional phase search, multiphase flash phase removal test. Table 4.14: Equilibria predictions for System 7 at three temperature and pressure condi-tions with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding flash. Chapter 4. Results and discussion 151 Summary of the results for the systems tested using the default parameters for the phase-splitting predictions no. of wrong predictions (total CPU time, msecs.) system no. data VLL flash phase-splitting T(K),P(atm) no. points z 1 18 0 (251) 0 (278) 120^320,20 fixed z 1 66 8 (1276) 2 (1239) 171,20 a l l z 1 66 2 (1204) 2 (1137) 200,20 a l l z 2 19 5 (1172) 0 (961) 90^320,40 fixed z 3 11 0 (538) 0 (267) 430 ,5-»100 fixed z 4 21 4 (143) 0 (184) 378,5 al l z 5 21 2 (276) 0 (256) 190,38 a l l z 6 66 13 (906) 3 (1239) 311,60 a l l z 7 3 0 (1726) 0 (186) 283,5&15 327,15 a l l z Tota l 281 34 (7492) 7 (5747) Default parameters: Initlzn. for the liquid search with the proposed algorithm, Wegstein's method with w = 3, tmax = 3, additional phase search, phase removal test with the coupled method. Table4.15: Summary of the phase equilibrium predictions for the seven systems tested ob-tained with the direct three-phase flash calculation and with the phase-splitting algorithm proposed followed by the corresponding type of flash when required. Chapter 5 Conclusions and recommendations 5.1 General conclusions Based on the evaluation of the results presented i n the previous chapter, i t can be stated that the algorithm developed, i n most instances, is able to accurately and efficiently: 1. Establish a priori the least number of phases present at equihbrium i n order to determine the need for an isothermal flash calculation. 2. Predict the configuration of the system when more than one phase is found, i.e. predict the type of phases and the corresponding flash calculation to be executed: V L , L L or V L L . 3. Concurrently generate composition estimates of the phases present to be used i n the eventual flash which are close to the equihbrium values, thus avoiding convergence to a t r iv ia l solution. This means that the objectives proposed at the beginning of this work have been reached and that the phase-splitting algorithm suggested offers a better alternative than the direct three-phase flash calculation when the equihbrium conditions for multicomponent mixtures capable of separating into three fluid phases are to be determined. The major advantage of using the proposed algorithm is its dependability since incorrect predictions were obtained i n only 2.5 % of the cases tested against 12.1 % when the direct flash was employed (which represents a reduction of almost 80 %). Also a very desirable 152 Chapter 5. Conclusions and recommendations 153 characteristic of the splitting algorithm is it 's efficiency when compared to the direct flash approach, although the reduction i n C P U time for the equil ibrium predictions was a not so overwhelming 23 % 1 . Nevertheless this is a significant improvement when considering that refinements i n reliability are almost always done at the sacrifice of speed, and here a good compromise between both characteristics was achieved. 5.2 Specific remarks and recommendations In spite of being very dependable, incorrect predictions were st i l l obtained with the proposed algorithm for some of the points tested (see Table 4.15). The source of the failures was the inabi l i ty to detect a vapour phase even when the addit ional phase search was conducted (in two occasions for System 1 at 171 K and 20 a tm and once for System 6 at 311 K and 60 atm) and the incorrect outcome of the phase removal strategy (twice for System 1 at 200 K and 20 atm a l iquid was not eliminated when it should have been and i n two other cases a vapour was not removed for System 6 at 311 K and 60 atm). Therefore, these parts of the algorithm are the ones that would need improvement i n order to have a more robust method. W i t h respect to the efficiency of the calculations, i t was observed that changing the convergence tolerance e i n the phase search from 10~ 5 to 1 0 - 3 reduced the C P U time required i n the search (and also that of the total calculation) without affecting the reliability of the predictions. However, i t diminished the accuracy of the compositions of the incipient phases used to init ial ize the flash calculations. This was noted because i n some cases more iterations were required i n the flash when the less strict convergence tolerance was set (and consequently more C P U time). Thus a more relaxed value of e can have a negative effect on the efficiency of the method and 1 Clearly these figures are only gross indicators of the performance of both methods, but serve as guidelines for comparison when considering that only a limited number of systems and conditions could be tested. Chapter 5. Conclusions and recommendations 154 ult imately i n its reliability. The particular conclusions that can be drawn from each part of the algorithm and some recommendations are: 1. The assumption of ideal gas behaviour to provide in i t i a l estimates for the vapour phase search was acceptable for the conditions tested, which were away from crit ical and retrograde behaviour regions. As Michelsen [4] suggests, i n the crit ical region the compositions corresponding to the ideal l iquid could also be used since by definition the vapour and l iquid phases become indistinguishable. 2. For the l iquid search init ial ization Shah's method was the most reliable. The new scheme proposed here was the next most reliable, and i t was also the least time-consuming especially for mixtures wi th a large number of components. For binary systems the modified Michelsen method gave the fastest results and was very de-pendable. In the comparison for the efficiency of the init ial izations, the C P U time required to generate the composition estimates plus the time needed to reach con-vergence i n the search gives a measure of how fast the ini t ia l izat ion methods are and of how close to the incipient phase composition are the values provided (con-sidering that normally the better the in i t i a l estimates the less C P U time required for convergence). 3. Convergence i n the search strategy for a vapour phase was obtained i n few itera-tions (three or less) for most cases except at high pressures. In these conditions the use of Wegstein's method accelerated the convergence rate compared to direct sub-st i tut ion, but the outcome of the search was not very sensitive to the acceleration parameters chosen. Nevertheless it is suggested to set the frequency of acceleration to each 2 or 3 iterations wi th a max imum step size between 3 and 6. Al though the phase search performed without flaw i n most cases, a superfluous vapour was Chapter 5. Conclusions and recommendations 155 found occasionally near bubble-point conditions which had to be removed with the phase el imination tests. The additional phase search was very helpful in finding a vapour missed i n the in i t i a l search for binary systems, but for the systems tested w i t h 3 or more components it was not successful (the core of the problem was the pseudo-tangent plane criterion used, not the composition estimates generated since these were fairly close to the equil ibrium values i n a l l cases i n which a vapour was not found). 4. W i t h the modifications proposed to Michelsen's method the reliability of the l iquid phase search as well as its efficiency improved considerably. The l iquid search was found sensitive to the init ia l izat ion scheme selected; when an incorrect prediction was obtained wi th one particular method, correct results were always obtained when using an alternative one. The use of Wegstein's method to accelerate compositions allowed convergence to be achieved much faster than wi th direct substitution. The selection of the parameters for acceleration frequency and maximum step size had a significant influence i n the efficiency of the method. The best results were obtained accelerating every two iterations (starting i n the fourth) wi th a maximum step size between 3 and 6 (specifically a value of 5 seemed to be the optimum); a second choice is to accelerate every three iterations wi th the max imum step size in the same interval (between 3 and 6). Acceleration every iteration is not recommended since i t can disrupt the steady convergence to the solution. The additional phase search proposed was very useful when a l iquid was missed i n the in i t i a l search, particularly for binary systems. For the multicomponent systems tested it aided i n obtaining a correct prediction i n most instances, increasing the dependability of the phase-splitting predictions. Therefore, the additional phase search strategy should always be used for binary systems and is also recommended for multicomponent Chapter 5. Conclusions and recommendations 156 systems as long as the improved phase removal strategy is selected to assure the best possible performance (see next item). W h e n superfluous l iqu id phases were found i n the search, they were mainly i n the vic ini ty of two- and three-phase dew-points. A w a y from these conditions the l iquid search functioned quite wel l . 5. Concerning the removal of a superfluous vapour w i t h the phase removal tests im-plemented, the one based on the multiphase flash method performed better than the bubble- and dew-point equations method, although it was not flawless. Similar results were obtained for the elimination of a superfluous l iqu id , except when the addit ional phase search was conducted (in systems w i t h 3 or more components) for case i i i ) 2 where the bubble- and dew-point equations method was more reliable. The coupled method suggested takes this situation into account and uses the mult i -phase flash removal test i n a l l cases but the one described. Thus i t is recommended when choosing the phase removal test option. 6. The convergence tolerance specified for the flash calculations was set to 10~ 5 i n a l l cases. This value was strict enough to achieve accurate results, i n particular to compare the Gibbs energies when two possible solutions were obtained i n order to determine the stable one. A more strict convergence tolerance contributed only to an increase i n the number of iterations to reach convergence, which were unnec-essary since the outcome of the results was practical ly unchanged. For the phase search method a convergence tolerance of 1 0 - 3 gave the best compromise between reliabil ity and efficiency. 2Corresponding to the case in which the system is liquid-like, a vapour is found in the initial search but not a liquid. Chapter 5. Conclusions and recommendations 157 Based on these remarks, the default values for the parameters and options that are recommended for the phase-splitting algorithm are: • Init ial izat ion of the l iquid phase search: wi th the algorithm proposed here, except for binary systems in which the modified Michelsen method is recommended. • Convergence tolerance for the phase search: e = 10~ 3 . • Convergence tolerance for the flash calculations: e = 1 0 - 5 . • Acceleration of compositions with Wegstein's method applied every two iterations (w = 2) wi th tmax = 5. • Phase search using the additional phase search strategy. • Phase removal test wi th the coupled method. Bibliography [1] V . B . Shah, Multicomponent Distillation with Two Liquid Phases, P h . D . Thesis, University of Toledo, Ohio (1980). [2] X . Joul ia , R. Maggiochi and B . Koehret, ' H y b r i d Methods for Phase Equi l ibr ium Flash Calculations' , Fluid Phase Equilib. 29, 15 (1986). [3] P. A . Nelson, 'Rap id Phase Determination i n Mult iple-Phase F lash Calculations' , Comput. Chem. Engng. 11, 581 (1987). [4] M . L . Michelsen, 'The Isothermal Flash Problem. Par t I. Stabi l i ty ' , Fluid Phase Equilib. 9, 1 (1982). [5] F . M o l i n a and A . A . Romero, Cdlculo de Equilibrio Liquido-Liquido- Vapor para Sis-temas Multicomponentes Utilizando Ecuaciones de Estado Cubicas, B . A . S c . Thesis, Universidad Nacional Autonoma de Mexico, Mexico (1987). [6] M . N . A m m a r and H . Renon, 'The Isothermal F lash Problem: New Methods for Phase Split Calculations' , AIChE J. S3, 926 (1987). [7] G . Soave, 'Equi l ibr ium Calculations from a Modified Redl ich-Kwong Equat ion of State', Chem. Eng. Sci. 27, 1197 (1972). [8] D . Y . Peng and D . B . Robinson, ' A New Two-Constant Equat ion of State', Ind. Eng. Chem. Funadm. 15, 59 (1976). [9] P. M . Mathias , ' A Versatile Phase Equi l ibr ium Equat ion of State', Ind. Eng. Chem. Process Des. Dev. 22, 385 (1983). 158 Bibliography 159 [10] P. M . Mathias , J . F . Boston and S. Watanasir i , 'Effective Ut i l i za t ion of Cubic Equa-tions of State for Thermodynamic Properties is Process Simulation' , AIChE J. 30, 182 (1984). [11] D . B . V a n Dongen, M . F . Doherty and J . R. Haight, 'Mater ia l Stabil i ty of Mul t i com-ponent Mixtures and the Mul t ip l i c i ty of Solutions to Phase-Equil ibrium Equations. 1. Nonreacting Mixtures ' , Ind. Eng. Chem. Fundam. 22, 472 (1983). [12] M . L . Michelsen, "Comments on 'Mater ia l Stability of Multicomponent Mixtures and the Mul t ip l i c i ty of Solutions to Phase-Equil ibrium Equations. 1. Nonreacting Mixtures ' " , Ind. Eng. Chem. Funadm. 23, 373 (1984). [13] B . L . Beegle, M . Model l and R. C . Re id , 'Thermodynamic Stabil ity Criter ion for Pure Substances and Mixtures ' , AIChE J. 20, 1200 (1974). [14] R. A . Heidemann, 'The Cr i ter ia for Thermodynamic Stabil i ty ' , AIChE J. 21, 824 (1975). [15] M . Mode l l and R . C . Reid , Thermodynamics and its Applications, 2nd. ed. Prentice-H a l l , N . J . (1983). [16] G . Maurer and J . M . Prausnitz, 'Thermodynamics of Multicomponent Liquid-Liquid-Vapour Equi l ibr ia for Dist i l lat ion Co lumn Design', Inst. Chem. Eng. 3, 1.3/41 (1979). [17] I. F . Radzyminski and W . B . W h i t i n g , ' F l u i d Phase Stabil ity and Equations of State', Fluid Phase Equilib. 34, 101 (1987). [18] R. L . Fournier and J . F . Boston, ' A Quasi-Newton Algor i thm for Solving Multiphase Equi l ibr ium Flash Problems', Chem. Eng. Commun. 8, 305 (1981). Bibliography 160 [19] R. Gautam and W . D . Seider, 'Computat ion of Phase and Chemical Equihbr ium. Part II. Phase-Splitting', AIChE J. 25, 999 (1979). [20] F . F . Y . Walraven and P. V . V a n Rompay, ' A n Improved Phase-Splitting Algor i thm' , Comput. Chem. Engng. 12, 777 (1988). [21] L . E . Baker, A . C . Pierce and K . D . Luks , 'Gibbs Energy Analysis of Phase Equi-l ibr i a ' , Soc. Pet. Eng. J., October, 731 (1982). [22] M . E . Soares, A . G . Medina , C . McDermott and N . Ashton, 'Three Phase Flash Calculat ion Using Free Energy Minimisat ion ' , Chem. Eng. Sci. 37, 521 (1982). [23] A . M . Crowe and M . Nishio, 'Convergence Promotion i n the Simulation of Chemical Processes-The General Dominant Eigenvalue Method ' , AIChE J. 21, 528 (1975). [24] J . E . Dennis and J . J . More , 'Quasi-Newton Methods, Mot iva t ion and Theory' , Siam Rev. 19, 46 (1977). [25] W . Murray, 'Second Derivative Methods' , i n W . Murray (Ed.) Methods for Uncon-strained Optimization. Academic Press, London (1972). [26] J . S. W u and P. R. Bishnoi , ' A n Algor i thm for Three- Phase Equ ihbr ium Calcula-tions', Comput. Chem Engng. 10, 269 (1986). [27] M . 0 . Ohanomah, Computational Algorithms for Multicomponent Phase Equilibria and Distillation, P h . D . Thesis, University of Br i t i sh Columbia , Vancouver, B . C . (1981). [28] S. M . Walas , Phase Equilibria in Chemical Engineering. Butterworth Publishers, Boston (1985). Bibliography 161 [29] R. A . Heidemann, 'Three-Phase Equi l ibr ia using Equations of State', AIChE J. 20, 847 (1974). [30] D . J . Swank and J . C . Mul l ins , 'Evaluation of Methods for Calculat ing L iqu id-L iqu id Phase-Splitting' , Fluid Phase Equilib. 30, 101 (1986). [31] J . H . Wegstein, 'Accelerating Convergence of Iteration Processes', Comm. ACM 1, 9 (1958). [32] R. C . Re id , J . M . Prausnitz and T . K . Sherwood, The Properties of Gases and Liquids. 3rd ed. M c G r a w - H i l l , New York (1977). [33] M . L . Michelsen, 'The Isothermal Flash Problem. Part II. Phase-Split Calculat ion' , Fluid Phase Equilib. 9, 21 (1982). [34] D . Y . Peng and D . B . Robinson, 'Two and Three Phase Equ i l ib r ium Calculations for Systems Containing Water' , Can. J. Chem. Eng. 6, 245 (1982). [35] J . J . M c K e t t a and D . L . K a t z , 'Methane-n-Butane- Water System i n Two- and Three-Phase Regions', Ind. Eng. Chem. 40, 853 (1948). [36] J . R. E l l io t Jr. and T . E . Daubert, 'Revised Procedures for Phase Equi l ibr ium Ca l -culations wi th the Soave Equation of State', Ind. Eng. Chem. Process Des. Dev. 24, 743 (1985). [37] M . 0 . Ohanomah and D . W . Thompson, 'Computat ion of Multicomponent Phase Equi l ibr i a—Part I Vapour-Liquid Equi l ibr ia ' , Comp. Chem. Engng. 8, 147 (1984). [38] J . M . Prausnitz, T . F . Anderson, E . A . Grens, C . A . Eckert , R. Hsieh and J . P. O 'Connel l , Computer Calculations for Multicomponent Vapour-Liquid and Liquid-Liquid Equilibria. Prentice H a l l , New Jersey (1980). Bi bliography 162 [39] M. 0. Ohanomah and D. W. Thompson, 'Computation of Multicomponent Phase Equilibria—Part II Liquid-Li quid and Solid- Liquid Equilibria', Comp. Chem. En-gng. 8t 157 (1984). Appendix A Two- and three-phase flash algorithms The isothermal flash algorithms used i n this thesis have been taken from the work of M o l i n a and Romero [5] and are described i n this section. The two-phase flash is capable of performing either a V L or L L calculation and the three-phase flash, which is intended for V L L computations, can be reduced to either of the first two types of equil ibrium. The original algorithms have been slightly modified to adapt them to the scheme used here when any of the flash calculations is necessary after the phase-splitting prediction. Besides the ini t ia l izat ion procedures for the three calculations ( V L , L L and V L L ) , the phase ratio l imi t ing strategies are also given, of which the one used for the V L L flash serves as a basis for the phase removal test described i n Section 3.4.1. In addit ion, a brief description of Wegstein's method as applied to accelerate the compositions of the phases is included. A . l Isothermal V L or L L flash In this calculation a feed stream of composition z is separated, at constant temperature and pressure, into two streams which can be a vapour and a l iquid or two immiscible liquids i n equil ibrium. The problem consists i n finding the compositions and phase ratios (on a molar basis) of the two new phases or i n determining i f the system is stable as a single phase. The data, unknowns and equations necessary to solve the flash are: Data : T , P, z 163 Appendix A. Two- and three-phase Hash algorithms 164 Unknowns: a = V/F, y,-, xi ( V L ) 8 = Lj/F, xj, xj1 ( L L ) number of unknowns=2n + 1 Equations: a) Mass balance <xyi + (1 - a)xi = Zi ( V L ) 8xj + (1 - fix? = Zi ( L L ) b) Equ i l ib r ium relations ft = fY ( V L ) ft1 = ft" ( L L ) c) Add i t iona l relations E - U x,- - JXi Vi = 0 ( V L ) TZ=1*l I-TZ=lxl = o (LL ) number of equations=2n -f 1 where V, Li and F are the mole numbers of the vapour, l iquid J and the feed; y,-, x,- (or xj, xj1) and Zi are the corresponding mole fractions and / the fugacities i n the indicated phases. The solution of this non-linear system of equations is given next for the case of a L L flash, and for V L calculations the method can be equally applied by substituting o:, y,-, x, and Kiv for 0, xj, xj1 and KiL respectively. The equihbrium constants (as defined i n equations (3.113) and (3.114)) are calculated in i t i a l ly i n the starting routine. The steps followed i n the calculation are: Appendix A. Two- and three-phase £ash algorithms 165 Two-phase flash algorithm 1. Start of the iterative cycle. Calculate 8 from rL(o,/?) = £ n Zi(l-KiL) = 0 (A.131) i=i 1 + 8(KiL - 1) using a Newton-Raphson technique (inner iterative cycle) where the derivative is obtained analytically. If after 15 iterations the value of 8 does not converge to the solution, the calculation continues i n the next step wi th the value generated i n the final i teration. 2. If the calculated value of 8 is > 1 or < 0, i t is l imi ted to avoid the calculation of negative mole fractions i n the next step. If the value of 8 is < 0 or > 1 i n 5 consecutive global iterations, the calculation terminates indicat ing that at the specified conditions only one phase exists. 3. The new compositions of the two phases are obtained as: 1 + 8{KiL - 1) (A.132) x, (A.133) which are then normalized (A.134) Appendix A. Two- and three-phase £ash algorithms 166 x? * f = y ^ 7 (A.135) 2^i=i xi 4. If applicable, the compositions of the two phases are accelerated using Wegstein's method. 5. The fugacity coefficients and the equihbrium constants are evaluated wi th the new compositions. 6. The objective function is calculated for the LL flash as: s = E i # ' * ? - # " * F i (A-1 3 6) «=i and for the VL calculation as: 9 = E l # V . - ( A . 1 3 7 ) 1=1 If S < e, the calculation ends as long as the compositions have not been accelerated i n the present iteration; i f they have, the calculation continues. 7. In case i t is applicable, the damping factor to be used i n Wegstein's method is calculated. 8. If the maximum number of iterations allowed is reached, the calculation is termi-nated. Otherwise the cycle is repeated by executing Step 1 again. Appendix A. Two- and three-phase flash algorithms 167 A.1.1 Limit for the phase ratios During the L L (or V L ) flash calculation the phase ratio 8 (or a) calculated i n the inner cycle (Newton-Raphson method) can be outside the interval [0,1]. Depending on the values of KiL and 8 (or of Kiv and a for the V L case), i t is possible that the compo-sitions calculated with equation (A.132) be negative, which should be avoided. A way to overcome this problem could be to set to zero any negative composition, but this can lead to divergence i n the calculation. The proposed method consists i n equating the denominator of equation (A.132) to zero, detect for which components the values of 8 are greater or smaller and as a function of these values l imi t 0 such that a l l compositions calculated are positive. This procedure is only applied i n the cases where the phase ratio is < 0 or > 1. For the L L calculation the strategy is as follows: 1. If 8 < 0, the greatest value of K{L is selected and w i t h i t /?m , n is obtained from 8min = 1/(1 - K i L m a x ) (A.138) This is the min imum value for 8 as long as i t is negative. If 0 was less than 8mini then at least for one component negative mole fractions would be calculated, therefore the value of 0 is taken as /3 m i n / 2 . O n the contrary, i f 0 > 0 (which occurs i f a l l K{L are < 1), then there is no lower l imit for 0, but anyhow it is bounded so i t does not take values less than —8mi„. 2. If 0 > 1, the smallest value of K{L is chosen and 0 m a x is calculated as (A.139) Appendix A. Two- and three-pha.se Bash algorithms 168 As long as i t is positive, this is the maximum value for B. If a l l KiL are greater than one, then no upper l imit for B exists and it is bounded to 1 — Bmax. If B was greater than Bmax, also negative mole fractions would be obtained, thus B is set to (1 + /3m«*)/2. The value of 8 obtained i n this form is used then to calculate the new compositions. The procedure for the V L case is identical , except that /3 is substituted by a and K{L by K~iv. A.1.2 V L flash initialization A t the temperature and pressure of the system, the compositions of the vapour and l iquid are obtained according to equations (3.85) and (3.86). W i t h these compositions the equihbrium constants are calculated wi th the equation of state and the in i t i a l vapour fraction a is computed from M « , 0) = ± "i {l~Kiv\, = 0 (A.140) f~i 1 + a(Kiv - 1) using a Newton-Raphson procedure wi th the starting value of a estimated i n a similar fashion as proposed by Ohanomah and Thompson [37]. If the calculated value of ct is greater than 0.95 i t is l imited to this value and i f less than 0.05 i t is fixed to this l imi t . A.1.3 L L flash initialization The ini t ia l izat ion of compositions for the two immiscible liquids is based on the selection of two key components as described by Prausnitz et a l . [38]. Several modifications are suggested i n [5] to make this method more flexible and efficient. The algorithm consists on determining the two components that w i l l act as 'solvents' i n each phase. A composition Appendix A. Two- and three-phase £ash algorithms 169 of 0.98 (in mole fraction) is assigned to the key component of phase I i n this phase and of 0.02 i n phase I I and similarly for the key component of phase / / . If both key components are already known, only the compositions are assigned. If one of the key components is known (arbitrari ly assigned to l iquid II), the algorithm finds the key component for the other phase (l iquid / ) and then the compositions are assigned. W h e n one key component is known, the other is selected by considering the rest of the components wi th feed composition > 0.1 as possible key components, one at a t ime. Each time the equil ibrium constants are calculated considering compositions as described above. W h e n the key components for both phases must be determined a similar procedure is applied, but the equil ibrium constants are calculated considering a l l the binary pairs of components wi th feed composition > 0.1 (contrary to the method described by Prausnitz et a l . [38], the order of the binary pairs is considered unimportant, which saves the calculation of n-1 equil ibrium constants). The key component selected for a given phase is the one that gives the largest equil ibrium constant or its inverse. This means that its fugacity coefficients i n both phases are very different and thus has a tendency to pass from the phase wi th large fugacity to that i n which the fugacity is small , acting as solvent i n the later phase. Another modification made to the original algorithm of Prausnitz et a l . is that when neither key component is known, the one for phase I I can be selected wi th what has been called by M o l i n a and Romero [5] the 'composition criterion' . It consists on assigning as key component for this phase the most abundant component i n the feed, since very l ikely i t w i l l act as solvent for one of the phases (when two or more components have the same composition and greater than that of the rest of the components this criterion is not valid). The advantage of this criterion is that the selection of the key component is made dependent on the feed composition, which permits the description of systems wi th more than one immiscible pair. This also saves a considerable amount of C P U time since only one key components needs to be Appendix A. Two- and three-phase Hash algorithms 170 determined, particularly when the number of components i n the system is large. Also, contrary to the method suggested by Prausnitz et a l . , which does not consider the case where only one component has a feed composition > 0.1, i n the proposed method [5] such component is taken as key component and the other is determined among the rest i n the fashion described above, but without the feed composition restriction. The estimation of the in i t i a l value of 0 is done by means of the mass balance as suggested by Ohanomah and Thompson i n [39], considering that phase I has Zk2Kk2L moles of key component 2 and phase II has Xki/KkiL moles of key component 1 (where subscripts kl and k2 indicate the index number of key components 1 and 2, respectively). Thus, the i n i t i a l value of 6 is obtained as the mole numbers of key components 1 and 2 i n phase J divided by the total moles of these key components i n the feed, that is *"*  = x' + l » t f + x »  ( A - 1 4 1 ) XJfcl +  Xk\ + Xk2 + Xk2 which can be expressed as 0init = 1/^*1 J + W f r : 2 , ( A A.2 Isothermal V L L flash In an isothermal VLL flash a feed stream of composition z is separated at constant temperature and pressure into three phases i n equihbrium (two liquids and a vapour) or only i n two (a vapour and a l iquid or two liquids) depending on the nature of the components, the value of z, and the temperature and pressure. The flash problem consists Appendix A. Two- and three-phase Hash algorithms 171 of finding the number and type of phases as well as their amount and composition. The data, unknowns and equations necessary to solve the flash are: Data : T , P , z Unknowns: a = V/F, 8 = Lj/F, </,-, x\, x? number of unknowns=3n -f 2 Equations: a) Mass balance cxyi + 0x\ + (1 - a - ^xj 1 = z{ b) Equi l ibr ium relations Si" = fY /["' = /["' c) Addi t iona l relations E J U z f - £ ^ = 0 number of equations=3n + 2 where V, L / , Lu and F are the mole numbers of the vapour, l iqu id I, l iqu id II and the feed; j/,-, xj, xj 1 and zi are the corresponding mole fractions and / the fugacities i n the indicated phases. Expressing the additional mass balance relations as a function of the feed composition, of the equil ibrium constants and of the phase ratios, equations (3.115) and (3.116) can be Appendix A. Two- and three-phase flash algorithms 172 obtained. Since the flash algorithm is designed i n such way that phases can be eliminated, i t can be reduced to a V L or L L calculation. This a lgorithm consists of the following steps: Three-phase flash algorithm 1. W i t h the estimated values of the compositions of the three phases the in i t i a l values of the equil ibrium constants are calculated. 2. Start of the iterative cycle. A l l the L L equil ibrium constants (KiL) are tested to see i f they are close to 1. If so, the compositions of the two liquids are very similar and the calculation is reduced to a V L separation (this is done to avoid convergence problems i n the calculation of a and 8 i n the next step). 3. The phase ratios a and 8 are obtained solving simultaneously equations (3.115) and (3.116) wi th a Newton method (inner iterative cycle) for non-linear equations. The part ia l derivatives necessary are calculated analytically. If during the inner iterative cycle the determinant of the system (for the derived linear system of equations) is close to zero, the calculation continues outside of the inner loop w i t h the values of a and 8 obtained wi th Newton's method at that point. This problem can occur when the in i t i a l composition values are very far from the solution. Al so , i f a and 8 do not converge i n 15 iterations i n the inner loop, the calculation continues i n the next step wi th the values i n this last iteration. 4. If after the third global iteration a > 1, 8 < 0 and 1 — a — 8 < 0 (which indicates that at least one of the l iquid phases must be eliminated), i t is determined which l iqu id phase has the greatest tendency to disappear. This phase is the one for which the sum of fugacities for a l l components is larger. Appendix A. Two- and three-phase flash algorithms 173 5. If any of the phase ratios is < 0 or > 1, its value is l imited to avoid the calculation of negative compositions. If a phase has been eliminated, the corresponding phase ratio is l imited as explained for the two-phase flash. In the case of a three-phase calculation a is l imited as i n a V L separation. W i t h the value of a obtained, the l imi t ing value of 0 is calculated and wi th i t the final value of 0 is determined such that a l l mole fractions are positive. 6. Test for the elimination of any of the phases. This is done when any of the phase ratios (a or 8) or 1 - a — 0 is < 0 i n five consecutive iterations, i n which case the corresponding phase is removed (when one of the l iquid phases is eliminated the other is labeled as l iquid II). Also , i f any of the variables just mentioned is > 1 i n five consecutive iterations, the calculation terminates indicating that only one phase exists. 7. The new compositions are calculated according to equations (3.117) to (3.119) and are then normalized as indicated i n equations (3.120) to (3.122). If any of the phases has been eliminated, its composition does not need to be obtained. 8. If applicable, Wegstein's method is used to accelerate the composition of the phases present. 9. The fugacity coefficients of a l l components i n the existing phases and the corre-sponding equihbrium constants are obtained. 10. The objective function is calculated from n (A.143) Appendix A. Two- and three-phase Hash algorithms 11A If the calculation has been reduced to a L L or V L flash the objective function is obtained from equations (A. 136) or ( A . 137). In the case that 5 < e, the compu-tat ion terminates as long as compositions have not been accelerated i n the present i teration. Otherwise the method continues. 11. If required, the damping factor to be used i n Wegstein's method is calculated. 12. The sequence is repeated by going back to Step 2. If the max imum number of iterations are reached without convergence, the computation is terminated. A.2.1 L imit for the phase ratios For the case of three phases, a is l imited as for the V L flash. W i t h a the l imi t ing value of 8 is obtained and wi th i t a new value of 8 is calculated such that the mole fractions derived are positive, according to the following scheme: 1. Calculate the l imi t ing value of 8 for a l l components as 2. If 8 (calculated i n Newton's method) is > 0, the smallest value of 8mm which is also greater than 8 is selected. 3. If 8 < 0, the greatest negative value of 8wm which is also greater than 8 is selected. 4. The new value of 8 to be used to obtain the new compositions is calculated as -a(Kiv KiL - 1 (A.144) follows: Appendix A. Two- and three-phase Hash algorithms 174 If the calculation has been reduced to a L L or V L flash the objective function is obtained from equations (A.136) or (A.137). In the case that 9 < e, the compu-tat ion terminates as long as compositions have not been accelerated i n the present iteration. Otherwise the method continues. 11. If required, the damping factor to be used i n Wegstein's method is calculated. 12. The sequence is repeated by going back to Step 2. If the max imum number of iterations are reached without convergence, the computation is terminated. A.2.1 L imit for the phase ratios For the case of three phases, ct is l imited as for the V L flash. W i t h a the l imi t ing value of 0 is obtained and wi th i t a new value of 0 is calculated such that the mole fractions derived are positive, according to the following scheme: 1. Calculate the l imit ing value of 0 for a l l components as * * • " " " ' ^ l l ' " 1 <A-U4> 2. If 3 (calculated i n Newton's method) is > 0, the smallest value of 0mm which is also greater than 0 is selected. 3. If 0 < 0, the greatest negative value of /?,• j , m which is also greater then 0 is selected. 4. The new value of 0 to be used to obtain the new compositions is calculated as follows: Appendix A. Two- and three-phase £ash algorithms 175 If 0 > 0 and 1 < 0lim < 0 then 0 = 1 + (Aim - l ) / 2 If 0 > 0 and 1 > 0lim < 0 then 0 = 0lim - 0.005 If 0 < 0 and 0 < 0lim then 0 = 0lim/2 A.2.2 V L L flash initialization The in i t i a l compositions of the two liquids are obtained wi th the key component criterion described for the L L flash ini t ia l izat ion. The vapour composition is estimated considering it as an ideal gas using equation (3.85). W i t h respect to the phase rations a and 0, the value of 0inn is fixed to 0.5 and wi th this value a,„,t is calculated considering the mass balance for key component 1, that is, Zkl - 0init xii - (1 - 0i„it)x Ik[ . . . < W = 7> 1 T, a—T77 (A.145) and then a better estimate of is obtained as 0init = 0.5(1 - ctinit) (A.146) A.3 Wegstein's method W h e n the equil ibrium constants are strongly dependent on the phase compositions, the equil ibrium calculations can be extremely slow. In such cases i t is convenient to accelerate these variables. Wegstein's method, applied for this purpose, consists on extrapolating linearly the compositions of each component using the two latest composition values Appendix A. Two- and three-phase £ash algorithms 176 available. The extrapolation is done i n such a way as to make the objective function zero. The new composition variables z (which i n this case can be either the l iquid or vapour compositions, not the feed) are obtained as z^ "\ new 4*) + c(z}*)-z{ f c - 1 ) ) (A.147) where k indicates the iteration number and c is the acceleration or damping factor ac-cording to its value: c > 0 acceleration c = 0 direct substitution — 1 < c < 0 damping c < — 1 deceleration In the method proposed by Prausnitz et a l . [38] c is obtained as ' = « » - ) - » < » - > ( A - 1 4 8 ) as long as Q( * - 2 ) > Q( f c _ 1 ) , i n such form that c is always > 0 and thus there is only possibility to accelerate. If Q( f c _ 2 ) < Q( f c _ 1 ) these authors use direct substitution. In [5] i t was found that for L L calculations near the plait point the objective function increased when accelerating compositions wi th c calculated wi th equation (A . 148) and convergence was not achieved. W i t h direct substitution convergence was reached i n these cases but i n a large number of iterations. However, wi th values of c < 0 the number of iterations was reduced significantly i f c was fixed between 0 and -0.6. In these cases of difficult convergence a strategy that allowed to dampen the calculation as required was Appendix A. Two- and three-phase Hash algorithms 177 developed i n [5] and was incorporated into Wegstein's method. The sequence of this scheme is: 1. Calculat ion of the new compositions i n iteration k and of the phase ratios a and/or 0. 2. W h e n conditions are satisfied for Wegstein's method as described by Prausnitz et a l . [38], the new compositions are calculated w i t h equation (A . 147) where c is obtained from equation (A.148). 3. The fugacity coefficients and equil ibrium constants are calculated wi th the compo-sitions obtained i n Step 1 or i n Step 2 when applied. 4. Calculat ion of the objective function for the corresponding type of equil ibrium and convergence test. 5. If Q(fc) > Q( f c - 1 ) then c is calculated as - aw • <A-149' If c is < —0.6, i t is l imited to this value to avoid a slow progress. If > —0.2 i t is considered that the increase i n the objective function is not large enough to require damping. When c is between these l imits new compositions are obtained according to equation (A. 147) and the updated value of the objective function i n iteration k is calculated. Once damping has been applied, the method keeps damping w i t h the specified frequency of application of Wegstein's method unt i l S becomes less than a pre-specified value to avoid divergence i n the calculation. After this Wegstein's method is applied i n the normal way and a new iteration is started by executing Step 1. Appendix B Act iv i ty coefficient models in the phase-splitting algorithm W h e n the equi l ibrium calculations involve polar compounds at low or moderate pressures, the l iqu id phase interactions can be better described w i t h an activity coefficient model than wi th cubic equations of state. In such cases the vapour phase properties can be adequately obtained wi th the v ir ia l equation of state (usually truncated after the second term). A t the present level of understanding of fluid phase molecular behaviour, the best practical pathway to obtain activity coefficients is to employ semi-empirical correlations that relate these variables to the temperature and the l iqu id phase composition through interaction parameters determined from equil ibrium data. The predictive correlations for the act ivity coefficient 7; include the Wohl-type equations (e.g. the Margules, van Laar and Scatchard- Hamer equations), the Redlich-Kister equation and the models based on the concept of local composition, such as W i l s o n , N R T L , U N I Q U A C and U N I F A C . This approach is useful for multicomponent mixtures because i n many cases, to a good approximation, extensions from binary to higher systems can be easily made. Nev-ertheless, since the activity coefficients dependence on pressure is usually not taken into account, the range of application of these models is l imi ted to low or moderate pres-sures, far from crit ical regions. Also , since a standard state fugacity is needed for each component, care must be exercised because this standard state is defined i n a differ-ent form depending on whether such component is condensable or non- condensable at the specified temperature and pressure (where the boundary between condensable and non-condensable is itself arbitrary). A l though activity coefficient models are not used in 178 Appendix B. Activity coefficient models in the phase-splitting algorithm 179 this work, some considerations wi th regard to their use i n the phase-splitting algorithm proposed are discussed here. B . l Activities and standard states W h e n an act ivity coefficient model is used for the l iquid phase, the act ivi ty is defined as ' f? fr where 7,- is the activity coefficient of component i at the system's temperature T and pressure P , / , ? ( P r ) the standard state fugacity at T and a reference pressure P r and f° the standard state fugacity at T and P . According to Prausnitz et a l . [38], 7; can be obtained as 7 , = 7 , ( P r ) e x p £ ^ P (B.151) where 7 ; (P r ) is the activity coefficient at the reference pressure and vf is the part ial molar l iqu id volume. Thi s last equation is introduced to evaluate a l l isothermal act ivity coefficients at the same reference pressure i n order to use the isothermal-isobaric form of the Gibbs-Duhem equation to correlate experimental activity coefficient data. This has the indirect effect of making the activity coefficients 'independent' of the pressure. Thus, substituting equation (B.151) i n (B.150), the activity i n the l iqu id phase can be expressed as .l xi7i(Pr){exp[vKP - Pr)/RT]f?(Pr)} dl = (B.150) (B.152) Appendix B. Activity coefficient models in the phase-splitting algorithm 180 Considering that the term i n curly brackets corresponds to ff for a condensable compo-nent, this equation becomes af = xni(Pr) (B.153) Then 7.(P r) can be obtained from any act ivity coefficient model and is pressure inde-pendent. This expression is analogous to equation (3.32) obtained i n Section 3.1. Thus, when an act ivity coefficient model is used, the reference state fugacity ff is taken as the fugacity of the pure l iquid i at the temperature and pressure of the mixture. To be consistent wi th this reference state, when using an equation of state for the vapour phase the reference state must be the pure component i at T and P i n the same state as the mixture, that is, as a vapour. The activity of i i n the vapour can then be obtained, according to equation (3.30), as &Y = ^ - (B.154) where <f>Y is the fugacity coefficient of i i n the mixture and <j>Y the fugacity coefficient of pure i (both evaluated at T and P). This is the analogous to equation (3.31). After making these considerations, the dimensionless Gibbs energies of mix ing for the vapour and l iquid phases, corresponding to equations (3.33) and (3.34), can be expressed respectively as: Ag v/BT = ± y i H y ^ ^ l ) (B.155) Appendix B. Activity coefficient models in the phase-splitting algorithm 181 Ag L/RT = Y,*M*MPr)] = 9E/RT + £ x , l n ( x t ) (B.156) i = l i = l where gE is the excess Gibbs energy given by the activity coefficient model. B.2 Vapour and liquid phases search W h e n a split model is used (i.e. using an equation of state to obtain the vapour fugacity and an activity coefficient model for the l iquid) , the search for an incipient vapour is conducted i n the same way as described i n Section 3.2.1, except that parameters exp(hf) should be obtained from « P ( A ? ) = (B.157) instead of using equation (3.37). For the additional vapour phase search also an analogous procedure can be followed as indicated i n Section 3.2.1, but instead of using equation (3.55) to obtain the pseudo-parameter hp{, the following expression is used / £ = l n z , + l n 7 p > . ( z ) (B.158) where the pseudo-activity coefficient at the feed composition 7Pl-(z) can be obtained as AuL ln7p,(z) = ^ f - I n * ; (B.159) Appendix B. Activity coefficient models in the phase-splitting algorithm 182 Similarly, the l iquid phase search can be conducted as indicated i n Section 3.2.2, but the stationarity conditions are defined as l n X , + l n 7 , ( x ) - hf = 0 (B.160) and InXi + l n 7 t ( x ) - hY = 0 (B.161) which replace equations (3.60) and (3.61). Also , the following equation is used instead of (3.63) exp(hf) = zi7i(z) (B.162) In addit ion, instead of using fugacity coefficients <j>jfP evaluated from an equation of state, act ivity coefficients 7 ^ evaluated wi th an activity coefficient model are employed throughout the calculation (i.e. 7 ^ replace 4%jp i n a l l instances). For the additional l iquid phase search, the value of exp(/if) used is that defined w i t h equation (B.162), otherwise the method is identical as the one described i n Section 3.2.2. B.3 L iquid phase initialization The necessary changes required to conduct the ini t ia l izat ion of the l iqu id compositions w i t h Shah's method, as well as wi th the modified Gautam and Seider and the proposed method are also straightforward. The calculation of the pseudo-infinite di lut ion activity 0,^°° required to select phase init iator p is done according to Appendix B. Activity coefficient models in the phase-splitting algorithm 183 ,00 (B.163) where 7? 0 is the infinite-dilution activity coefficient for component i. This equation Shah's method but the activity coefficient at infinite di lut ion for the binary mixture is used instead of the corresponding fugacity coefficient. Then equations (2.3) and (2.4) are used as explained i n Section 2.2.1 (which replace equations (3.89) and (3.90)) to obtain the compositions of components p and q. The solution to these equations can then be obtained by substituting equations (3.97) to (3.102) by equations (B.164) to (B.169) respectively: replaces equation (3.88). The selection of phase init iator q is done as described for A = I- 7 ; (B.164) (B.165) (B.166) (B.167) E = 2 z p 7 f - Z q (B.168) Appendix B. Activity coefficient models in the phase-splitting algorithm 184 F=-zq (B.169) To solve for the composition of the rest of the components (if n > 2), equation (2.7) replaces (3.104) and (3.107) to (3.109) are replaced by (B.170) to (B.172), which are: d = l l ~ - i r (B.170) e = = 7 r 7 / ° > r -n'p- ni) - TT(zr + n» + n1/) (B.171) f = zr7r(n Ip + n Iq) (B.172) The rest of the calculation can then be followed as indicated i n Section 3.2.2 and similarly for the modified G a u t a m and Seider and the proposed methods. Appendix C Description and listings of the computer programs The description and listings of a l l the programs and subroutines writ ten for the phase-splitt ing and flash calculations are presented i n this appendix (in Fortran 77 language). For each program an explanation of its purpose and main variables is given; also com-ments have been written throughout the listings to make them as self-explanatory as possible. The ma in program for the phase-splitting predictions, program P H A S P L I T , reads a l l necessary input parameters from a data file (in free format) wi th the following structure: 'SYSTEM NO.: A(l)-B(2)- ... H(n)' IFLG(O),H,ITMAX,EPS,IWEG,TIMAX IFTP,T,P,qiH,QFH,DELQ INITL,IFLG(15),INOLC,ISTA,ISRCH EPSF,IFLG(7),IWEGF,IFLG(8) Z(1),TC(1),PC(1),W(1),PP(1) Z(n),TC(H),PC(n),W(n),PP(n) KIJ(1,2) KIJ(1,3) KlJd.n) KIJ(2,3) KIJ(2,n) Kij(n-l,n) where a l l the variables are described i n the program list ing. 185 Appendix C. Description and listings of the computer programs 186 Similarly, for the direct flash calculations (either two- or three-phase), the necessary input data for program P H A S E Q should be given according to the following format: 'SYSTEM NO.: A(l)-B(2)- ... N(n)' IFLG(0),N,ITMAX,EPS,IFLG(7),IWEG,IFLG(8) ITEQ,IFTP,T,P,qiH,QFH,DELQ IFLG(9),IFLG(10),I0,I1,I2,ALPHA,BETA Z(1),TC(1),PC(1),W(1),PP(1) Z(n) ,TC(N) ,PC(n) ,W(rt) ,PP(n) KIJ(1,2) KIJ(1,3) KlJd.n) KIJ(2,3) KIJ(2,n) KIJ(n-i,n) As an example of an input file for program P H A S P L I T , the following data file cor-responds to the equil ibrium calculation for System 3 at 430 K and 30 a tm using the defalut values for the different options and parameters for the phase-splitting algorithm as recommened i n Chapter 5. •SYSTEM 3: C3H8(1) 1 6 50 l.D-3 2 0 430.0D0 30. DO 4 0 0 2 1 0.00001D0 1 2 1 0.16667D0 369.8D0 0.16667D0 425.2D0 0.20000D0 469.6D0 0.06667D0 507.4D0 0.13333D0 568.8D0 0.26667D0 647.3D0 0.D0 0.D0 0.D0 0.D0 0.48D0 0.D0 0.D0 0.D0 0.48D0 0.D0 0.D0 0.48D0 •nC4H10(2)-nC5H12(3)-nC6H14(4)-nC8H18(5)-H20(6)' 5.0D0 5.DO 40.DO 5.DO 41.9D0 37.5D0 33.3D0 29.3D0 24.5D0 217.6D0 0.152D0 0.193D0 0.251D0 0.296DO 0.394D0 0.344D0 0.D0 0.D0 0.D0 0.D0 0.D0 0.1277D0 Appendix C. Description and listings of the computer programs 187 O.DO 0.48D0 0.48D0 The file for the equihbrium calculation wi th the direct three-phase flash, read by program P H A S E Q , is: 'SYSTEM 3: C3H8(l)-nC4H10(2)-nC5H12(3)-nC6H14(4)-nC8H18(5)-H20(6)* 1 6 50 0.00001DO 3 0 430.0D0 30.DO 1 0 0 0 0 O.DO 0.16667D0 369.8D0 0.16667D0 0.20000D0 .06667D0 , 13333D0 .26667D0 .DO .DO .DO .DO .48D0 .DO 0  0. 0  0  0  0  0  0  0  O.DO O.DO 0.48D0 O.DO O.DO 0.48D0 O.DO 0.48D0 0.48D0 425.2D0 469.6D0 507.4D0 568.8D0 647.3D0 2 1 5.DO O.DO 41.9D0 37.5D0 33.3D0 29.3D0 24.5D0 217.6D0 40.DO 5.DO 0.152D0 0.193D0 0.251D0 0.296D0 0.394D0 0.344D0 O.DO O.DO O.DO O.DO O.DO 0.1277D0 The corresponding output from the phase-splitting prediction obtained w i t h program P H A S P L I T is SYSTEM 3: C3H8(l)-nC4H10(2)-nC5H12(3)-nC6H14(4)-nC8H18(5)-H20(6) PENG-ROBINSON EOS Z( 1)= 0.16667 Z( 2)= 0.16667 Z( 3)= 0.20000 Z( 4)= 0.06667 Z( 5)= 0.13333 Z( 6)= 0.26667 MAX. NO. ITERATIONS= 50 CONVERGENCE= 0.10000E-02 WEGSTEIN METHOD EACH 2 ITER TIMAX= 5.000 T= 430.000 K P= 30.000 atm Appendix C. Description and listings of the computer programs 188 DEL G VAP= 1163.4519 cal/gmol Z VAP= 0.6388 DEL G Liq= 1444.4997 cal/gmol Z LIQ= 0.3000 *** EXTRAPOLATED Z LIQ *** THE SYSTEM IS VAPOUR-LIKE CPU TIME= 2 msecs SUBROUTINE INLIQ RESULTS IP= 6 IQ= 5 0.00054 0.00013 0.00002 0.20393 0.20402 0.24486 0.01257 0.03109 0.08380 CPU TIME= 4 msecs 0.00000 0.00000 0.99930 0.08162 0.16324 0.10233 0.05987 0.45872 0.35395 SUBROUTINE LIQSER RE! UNSTABLE SYSTEM. Tl xl( 1)= 0.000000 xl( 2)= 0.000000 xl( 3)= 0.000000 xl( 4)= 0.000000 xl( 5)= 0.000000 xl( 6)= 1.000000 NO. OF ITERATIONS= CPU TIME= 14 msecs I LiqUID PHASES FOUND x2( 1)= 0.072379 x2( 2)= 0.115358 x2( 3)= 0.210365 x2( 4)= 0.105158 x2( 5)= 0.443579 x2( 6)= 0.053161 4 SUBROUTINE TESTA RESULTS V/F= 0.35542 Ll/F= 0.16964 YN( 1)= 0 .269908 X1N( 1) = 0 .000000 X2N( D = 0. 148939 YN( 2)= 0 .216527 X1N( 2) = 0 .000000 X2N( 2) = 0. 188887 YN( 3)= 0 .203340 X1N( 3) = 0 .000000 X2N( 3) = 0. 268932 YN( 4)= 0 .051276 X1N( 4)= 0 .000000 X2N( 4) = 0. 102002 YN( 5)= 0 .056524 X1N( 5) = 0 .000000 X2N( 5) = 0. 238428 YN( 6)= 0 .202426 X1N( 6) = 1 .000000 X2N( 6) = 0. 052812 +++ STABLE SYSTEM AS VLL +++ CPU TIME= 16 msecs VLL FLASH INITIALIZATION T= 430.000 K P= 30.000 atm V/F= 0.35542 Ll/F= 0.16964 CPU I Z Y XI X2 1 0. .16667 0. 26991 0, .00000 0, . 14894 2 0. .16667 0. 21653 0, .00000 0. .18889 3 0. ,20000 0. 20334 0, .00000 0. .26893 4 0. ,06667 0. 05128 0, .00000 0, .10200 5 0. ,13333 0. 05652 0. .00000 0. .23843 6 0. .26667 0. 20243 1. .00000 0. .05281 TIME= 36 msecs WEGSTEINS METHOD EACH 2 ITERATIONS WITH DAMPING MAXIMUM NO. OF ITERATIONS= 50 CONVERGENCE= 0.00001 VLL FLASH CALCULATION RESULTS T= 430.000 K P= 30.000 atm NUM. ITER.= 2 OBJ. FUNC.= 0.42037E-05 V/F= 0.35536 Ll/F= 0.16963 L2/F= 0.47501 DEL G= 1099.786 cal/gmol ZVAP= 0.70478 ZLiqi= 0.02052 ZLIQ2= 0.14416 KEY COMP. #1= 6 KEY COMP .#2= 5 I Z Y XI X2 KV=Y/X2 KL=X1/X2 1 0. 16667 0.26992 0.00000 0, . 14895 1.812 0.2032E-05 2 0. 16667 0.21652 0.00000 0, .18889 1.146 0.1008E-06 3 0. 20000 0.20332 0.00000 0 .26893 0.7560 0.3328E-08 4 0. 06667 0.05127 0.00000 0 .10200 0.5026 0.5728E-10 5 0. 13333 0.05651 0.00000 0 .23841 0.2370 0.3333E-13 6 0. 26667 0.20247 1.00000 0 .05282 3.833 18.93 Appendix C. Description and listings of the computer programs 189 CPU TIME= 6 msecs TOT CPU TIME= 42 msecs GLOBAL CPU TIME= 42 msecs The output from program PHASEQ for the same conditions is: SYSTEM 3: C3H8(l)-nC4H10(2)-nC5H12(3)-nC6H14(4)-nC8H18(5)-H20(6) PENG-ROBINSON EOS VLL FLASH WEGSTEINS METHOD EACH 2 ITERATIONS WITH DAMPING MAXIMUM NO. OF ITERATIONS= 50 CONVERGENCE= 0.00001 AUTO-INITIALIZATION K( 1, 6)= 0.4800 K( 2, 6)= 0.4800 K( 3, 6)= 0.4800 K( 4, 6)= 0.4800 K( 5, 6)= 0.4800 VLL FLASH INITIALIZATION T= 430.000 K P= 30.000 atm V/F= 0.74823 Ll/F= 0.12589 I Z Y XI X2 1 0. . 16667 0. 56751 0. .00000 0. .00000 2 0. .16667 0. 22938 0. .00000 0. .00000 3 0. .20000 0. 12253 0, .00000 0. .00000 4 0. ,06667 0. 01906 0. .00000 0. .00000 5 0. .13333 0. 00995 0. . 98000 0. .02000 6 0. .26667 0. 05158 0, .02000 0, .98000 CPU TIME= 27 msecs VLL FLASH CALCULATION RESULTS T= 430.000 K P= 30.000 atm NUM. ITER.= 6 OBJ. FUNC.= 0.18390E-06 V/F= 0.35536 Ll/F= 0.47502 L2/F= 0.16963 DEL G= 1099.786 cal/gmol ZVAP= 0.70479 ZLiqi= 0.14416 ZLIQ2= 0.02052 KEY C0MP.#1= 5 KEY COMP.#2= 6 I Z Y XI X2 KV=Y/X2 KL=X1/X2 1 0. .16667 0. .26992 0. .14895 0. .00000 0 .8918E+06 0 .4921E+06 2 0. ,16667 0. .21652 0. .18889 0. .00000 0 .1137E+08 0 .9919E+07 3 0. .20000 0. .20332 0. .26893 0. .00000 0 .2271E+09 0 .3005E+09 4 0. .06667 0, .05127 0. .10200 0. .00000 0 .8774E+10 0 .1746E+11 5 0. .13333 0. .05651 0. .23841 0. .00000 0 .7111E+13 0 .3000E+14 6 0. .26667 0. .20247 0. .05282 1. .00000 0 .2025 0 .5282E-01 CPU TIME= 22 msecs TOT CPU TIME= 49 msecs GLOBAL CPU TIME= 49 msec Appendix C. Description and listings of the computer programs * * * PROGRAM PHASPLIT (PHASE-SPLITTING PREDICTION) * * * * * * Purpose: * * Main program to determine the stability of a global homogeneous * * mixture of n components at a given temperature, pressure and * * composition. Calculations can be done at a fixed T, P and comp.; * * at fixed T, comp. and different pressures; at fixed P, comp. and * * different temperatures or at fixed T, P and different compositions * * for a binary or ternary mixture * * * * Main variables: * * -Alphanumeric * * DAMP Indicates i f damping is used in Wegstein's method when * * applied in flash calculations * * EOS Equation of state used: Soave-Redlich-Kwong or Peng- * * Robinson * * TYPEQ Type of equilibrium: VL, LL or VLL * * SYSTEM System's components and index number * * ZV,ZL1, Indicate i f the compressibility factor of a given phase * * ZL2 has been extrapolated in a flash calculation * * * * -Numeric * * ALPHA Molar phase ratio V/F * * ALSL Vector of the logarithm of the activity of each component * * in the system as a liquid * * APUR Vector of pure component dimensionless attraction * * parameters in the EOS * * BETA Molar phase ratio Ll/F * * BPUR Vector of pure component dimensionless repulsion * * parameters in the EOS * * DELGL Gibbs energy of mixing of the system as a liquid * * DELGV " " " " " " " " " vapour * * EPS Convergence tolerance in the phase search subroutines * * EPSF " flash subroutines * * FUCL1 Fug. coeff. vector of l i q . 1 in the phase search * * FUCL2 " " 2 " " " " * * FUCV " " " " the vapour in the phase search * * FUCD Dummy fug. coeff. vector * * FUCSL Fug. coeff. vector of the system as a liquid * * FUCSV " " " " " vapour * * FUCL1N Updated fug. coeff. vector of l i q . 1 * * FUCL2N " " " ' 2 * * FUCVN " " " " " the vapour * * HL See subroutine LIQSER * * HP " " PHASER * * HV " " VAPSER * * IFLG Vector of calculation's control flags * * IFTP Indicator of the T, P and comp. calculation conditions: * * 0=fixed T, P and comp.; l=fixed T ft comp., loop for * * different P; 2=fixed P ft comp., loop for different T; 3= * * fixed T ft P, loop for different comp. for a binary or * * ternary mixture * * INITL Indicator of the type of init i a l i z a t i o n subroutine for * * the liquid search: 1=INMICH; 2=INGASE; 3=INSHAH; 4=INLIQ * * INOLC Indicator for monitoring the complexity of the calctn.: * * 0=full calcn. with VAPSER, LIQSER (ft PHASER i f specified) * * followed by the corresponding flash; l=results of a l l the * * l i q . i n i t . routines without doing any further calcns.; 2= * Appendix C. Description and listings of the computer programs 191 * calc. using VAPSER & LIQSER without the flash (PHASER not * * used) * * ISTA Indicator of the 3 phase stability subroutine used: * * 0=TESTA; 1=KELSTA; 2=TESTA used except when the system is * * liquid-like, a vapour is found, no liquids are found but * * PHASER detects an additional liquid in which case NELSTA * * is used * * ISRCH Indicator for the type of phase search: 0=search without * * the additional search; l=thorough search using subroutine * * PHASER * * UMAX Maximum number of iterations allowed * * ITNUM Iteration number in which convergence is reached * * IWEG Frequency of application of Wegstein's method in VAPSER * * or LIQSER subroutines; i f zero, Wegstein's method not * * used and the solution is obtained by direct substitution * * IWEGF Frequency of application of Wegstein's method in the * * flash calculation routines * * KEQ Dummy equilibrium constants vector * * KV VL equilibrium constants vector * * KL LL " " " * * KIJ NxN array of binary interaction parameters in the EOS * * MX Number of i n i t i a l liquid composition vectors * * N Number of components in the system * * P System's pressure (atm) * * PC Vector of c r i t i c a l pressures * * PP Vector of Mathias polar parameters * * PVAP Vapour pressure estimation for each component * * R Universal gas constant (1.987 cal/gmole K) * * T System's temperature (K) * * TC Vector of c r i t i c a l temperatures * * TIMAX Maximum step size parameter in Wegstein's method when * * used ins subroutines VAPSER or LIQSER * * W Vector of Pitzer's acentric factors * * XIN " " i n i t i a l liquid phase composition using * * Raoult's law * * XI N+l x N array of i n i t i a l liquid compositions when routine * * INMICH is used and 3 x N array in a l l other i n i t i a l i z i n g * * subroutines * * XD Dummy vector of liquid composition * * XI Vector of l i q . 1 composition in the phase search * £ £2 ** ** ** 2 " (< M '* 11 * * XN Updated vector of single liquid phase composition * * XIN Updated vector of l i q . 1 composition * * X2N " " " " 2 " * * YI Vector of i n i t i a l vapour composition using Raoult's law * * Y H I I vapour composition the phase search * * YN Updated vector of vapour composition * * Z Vector of global mixture composition (mole fraction) * * (All vectors are of dimension N except when otherwise specified) * * * * System's flags: * * i IFLG(i) * * 0 0=SRK EOS; 1=PR EOS * * 1 l=extrapolated density for the vapour * * 2 l=extrap. density for the l i q . ( l i q . 1) * * 3 l=extrap. density for the l i q . ( l i q . 2) * * 4 O=subroutine PAB has not been executed; l=it's been executed * * 5 O=vapour t r i a l phase not found; l=vapour t r i a l phase found * * 6 0=no l i q . t r i a l phase(s) found; l=one l i q . t r i a l phase found; * * 2=two l i q . t r i a l phases found * * 7 0=Wegstein's method not used in the flash calculations; * £ ^ _ ti II I I ti I I I I II ^ * 8 0=no damping used in Wegstein's method in the flash calcns.; * Appendix C. Description and listings of the computer programs * l=damping is used * * 9 0=user supplied i n i t i a l estimates lor the flash calculation * * l=use of ini t i a l i z a t i o n routines (as in ref. [5]) * * 10 0=sequential init i a l i z a t i o n not used in the flash; * * 1= " " is * * 11 0=stable system as V; l=stab. sys. as L; 2=stab. sys. as VL; * * 3=stab. syst. as LL; 4=stab. syst. as VLL * * 12 0=no equilibrium calc. has been done; l=a calc. has been done * * 13 0=calc. of VL or LL eq. cts. when subroutine K is called; * * 1= " " fug. coeffs. when subroutine K is called * * 14 0=initialization for 2 phase eq. c a l c ; l=init. for 3 phase * * eq. calc. (as in ref [5J) * * 15 0=no printing of intermediate calcs.; l=printing of some * * calcs.; 2=full printing of intermediate calcs. * * 16 l=extrapolation control for l i q . 2 (VLL flash) * * 17 0=the original system is vapour-like l=is liquid-like * * 18 l=calculation using PHASPLIT to obtain i n i t i a l values for * * the 2 or 3 phase flash unknowns * * 19 0=no additional liquid found by PHASER when the system is * * liquid-like, a vapour has been found and no liquids found * * l=additional liquid found by PHASER in the case described * * * * Subroutines called: * * K * * VAPSER * * INMICH * * INGASE * * INSHAH * * INLIQ * * LIQSER * * PHASER * * HELSTA * * TESTA * * FLASH2 * * FLASH3 * * GIBBS * * * IMPLICIT REAL+8 (A-H.O-Z) REAL*8 KEq(20),KV(20),KL(20),KIJ(20,20) CHARACTER DAMP+16,E0S*25,SYSTEM*72,TYPEQ*10,ZV*8,ZL1*9,ZL2*9 DIMENSION ALSL(20),APUR(20),BPUR(20),C1(20),C2(20),FUCL1(20), + FUCL2(20),FUCV(20),FUCD(20),FUCSL(20),FUCSV(20), + FUCL1N(20),FUCL2N(20),FUCL1P(2),FUCL2P(20),FUCVN(20), + HL(20),HP(20),HV(20),IFLG(0:20),0BJL(2),0BJLP(2), + PC(20),PP(20),TC(20),W(20),XI(21,20),XIN(20),XN(20), + XD(20),X1(20),X2(20),X1N(20),X2N(20),X1P(20),X2P(20), + Y(20),YI(20),YN(20),Z(20),ZED(3) IT0TIM=0 R=1.987D0 DO 10 1=0,20 IFLG(I)=0 10 CONTINUE IFLG(18)=1 DO 30 1=1,20 DO 20 J=l,20 KIJ(I,J)=0.D0 20 CONTINUE 30 CONTINUE * The calculation conditions and variables are read from a data f i l e Appendix C. Description and listings of the computer programs 193 READ(5,*) SYSTEM,IFLG(0),N,ITMAX,EPS,IWEG,TIMAX, + IFTP,T,P,QIN,QFN,QDEL, + INITL,IFLG(15),IHOLC,ISTA,ISRCH, + EPSF,IFLG(7),IWEGF,IFLG(8) READ(5,*) (Z(I),TC(I),PC(I),W(I),PP(I), 1=1,1) DO 50 1=1,H DO 40 J=I+1,N READ(5,*) KIJ(I.J) KIJ(J,I)=KIJ(I,J) 40 CONTINUE 50 CONTINUE * Printing of the calculation conditions WRITE(6,600) SYSTEM 600 FORMAT (//2X.A60) IF (IFLG(O) .EQ. 0) THEN EOS='SOAVE-REDLICH-KWONG EOS' ELSE EOS='PENG-ROBINSON EOS' END IF WRITE(6,610) EOS 610 F0RMAT(/4X,A25) IF (IFTP .Eq. 3) THEN WRITE(6,615) T,P 615 F0RMAT(/4X,'T=',F8.3,' K',4X,'P=\F8.3,' atm'/) ELSE WRITE(6,620) (I,Z(I), 1=1,N) 620 F0RMAT(8X,*Z(',12,')=',F8.5) END IF IF (IFLG(15) .NE. 2) GO TO 80 DO 70 1=1,N DO 60 J=I+1,N IF (KIJ(I,J) .Eq. O.DO) GO TO 60 WRITE(6,630) I,J,KIJ(I,J) 630 FORMAT(8X,'K(',12,*,',12,')=',F7.4) 60 CONTINUE 70 CONTINUE 80 WRITE(6,640) ITMAX.EPS 640 FORMAT (4X,'MAX. NO. ITERATIONS=',I3,2X,'CONVERGENCE='.G12.5) IF (IWEG .EQ. 0) THEN WRITE(6,650) 650 FORMAT(4X,'DIRECT SUBSTITUTION'/) ELSE WRITE(6,660) IWEG,TIMAX 660 FORMAT(4X,'WEGSTEIN METHOD EACH',13,' ITER',2X,'TIMAX=',F7.3/) END IF IF (IFTP .Eq. 0) GO TO 97 IF (IFTP .Eq. 3) GO TO 92 * Loop for calculations at fixed T and various P or at fixed P at * various T DO 590 q=QIN,QFN,QDEL IF (IFTP .EQ. 1) THEN P=Q ELSE T=Q END IF GO TO 97 Appendix C. Description and listings of the computer programs * Loop for calculations at fixed T and P at different compositions 92 IF (N .GT. 3) THEN WRITE(6,665) 665 FORMAT(/4X,'WARNING: CALC. AT FIXED T ft P AT DIFFERENT' + /4X,'COMPOSITIONS ALLOWED ONLY FOR BINARY OR ' + /4X,'TERNARY MIXTURES') GO TO 590 END IF IF (N .EQ. 2) THEN DZ=0.05D0 ELSE DZ=0.1D0 END IF IF (N .EQ. 2) GO TO 95 DO 580 ZF1=1.D-8,1.D0+DZ,DZ DO 570 ZF2=1.D-8,1.D0+DZ,DZ Z(1)=ZF1 Z(2)=ZF2 Z(3)=1.D0-ZF1-ZF2 IF (Z(l) .GT. 1.D0) Z(l)=l.D0-l.D-8 IF (Z(2) .GT. l.DO) Z(2)=l.D0-l.D-8 IF (Z(3) .LE. O.DO) Z(3)=l.D-8 IF (ZF1+ZF2 .GT. l.DO+DZ) GO TO 570 ZT0T=Z(1)+Z(2)+Z(3) Z(1)=Z(1)/ZT0T Z(2)=Z(2)/ZT0T Z(3)=Z(3)/ZT0T GO TO 97 95 DO 565 ZA1=1.D-8,1.D0+DZ,DZ Z(1)=ZA1 Z(2)=1.D0-ZA1 IF (Z(2) .LE. O.DO) Z(2)=l.D-8 * Calculation of the fugacity coefficients for the vapour-like * and liquid-like system 97 CALL TIME(0,0,ITDUM) IFLG(1)=0 IFLG(2)=0 IFLG(13)=1 ITIMT=0 ITIMC=0 IP=0 MX=3 CALL K(XD,Z,TC,PC,W,PP,P,T,N,1,1,APUR,BPUR,FUCSV,FUCD, + Z1,ZD,KIJ,KEQ,IFLG) CALL K(XD,Z,TC,PC,W,PP,P,T,N,2,1,APUR,BPUR,FUCSL,FUCD, + Z2,ZD,KIJ,KEQ,IFLG) * System's Gibbs energy of mixing calculation and specification of * the type of system the original phase i s : vapour-like or liquid-* like SUM1=0.D0 SUM2=0.D0 PL0G=DL0G(P) DO 100 1=1,N HV(I)=DLOG(Z(I)*FUCSV(I)) HL(I)=DLOG(Z(I)*FUCSL(I)) ALSL(I)=HL(I)+PLOG SUM1=SUM1+Z(I)*(HV(I)+PL0G) Appendix C. Description and listings of the computer programs SUM2=SUM2+Z(I)*ALSL(I) 100 CONTINUE DELGV=R*T*SUM1 DELGL=R*T*SUM2 IF (DELGV .LT. DELGL) THEN IFLG(17)=0 ELSE IFLG(17)=1 END IF * Calculation of the i n i t i a l vapour and liquid compositions using * Raoult's law SUM1=0.D0 SUM2=0.D0 DO 110 1=1,N PVAP=PC(I)*DEXP(5.3727D0*(1.D0+W(I))*(1.DO-TC(I)/T))/P C1(I)=Z(I)*PVAP C2(I)=Z(I)/PVAP SUM1=SUM1+C1(I) SUM2=SUM2+C2(I) 110 CONTINUE DO 120 1=1,N YI(I)=C1(I)/SUM1 XIN(I)=C2(I)/SUM2 120 CONTINUE CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI * Printing of the calculation conditions IF (IFTP .Eq. 3) THEN WRITE(6,620) (I,Z(I), I=1,N) ELSE WRITE(6,615) T,P END IF WRITE(6,670) DELGV,Zl,DELGL,Z2 FORMAT(/8X,'DEL G VAP=*,F10.4,' cal/gmole*,4X,'Z VAP=',F7.4/ 8X,*DEL G Liq=',F10.4,' cal/gmole',4X,'Z Liq=', F7.4) IF (IFLG(l) .Eq. 1) WRITE(6,680) FORMAT(40X,'*** EXTRAPOLATED Z VAP ***') IF (IFLG(2) .Eq. 1) WRITE(6,690) F0RMAT(40X,EXTRAPOLATED Z Liq ***') IF (IFLG(17) .Eq. 0) WRITE(6,700) FORMAT(/4X,'THE SYSTEM IS VAPOUR-LIKE') IF (IFLG(17) .Eq. 1) WRITE(6,710) FORMAT(/4X,'THE SYSTEM IS LiqUID-LIKE') IF (IFLG(15) .Eq. 2) WRITE(6,720) (I,HV(I),I,HL(I), 1=1,N) FORMAT(6X,'hv(',12,')='.G11.4.2X,'hl(',12,')=',G11.4) WRITE(6,780) ITIMI IF (IFLG(17) .Eq. 0) GO TO 300 IF (INOLC .Eq. 1) GO TO 150 * The system is liquid like. A vapour phase is searched WRITE(6,730) 730 F0RMAT(/4X,'SUBROUTINE VAPSER RESULTS') CALL TIME(0,0,ITDUM) CALL VAPSER(EPS,ITMAX,IWEG,TIMAX,N,P,T,Z,YI,HL,TC,PC,W,PP, + APUR,BPUR,KIJ,ITNUM,OBJV,FUCV,Y,IFLG) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI Appendix C. Description and listings of the computer programs IF (IFLG(15) .HE. 0) GO TO 130 IF (IFLG(5) .Eq. 1) THEN WRITE(6,740) 740 FORMAT(6X,'UNSTABLE SYSTEM. VAPOUR PHASE FOUND') ELSE WRITE(6,750) 750 FORMAT(6X,'STABLE SYSTEM. VAPOUR PHASE HOT FOUND') END IF 130 WRITE(6,760) (I,Y(I), 1=1,1) 760 F0RMAT(8X,'y(',I2,')=',F9.6) WRITE(6,770) ITNUM 770 FORMAT(6X,'NO. OF ITERATIONS=',13) WRITE(6,780) ITIMI 780 FORMAT(4X,'CPU TIME=',I4,' msecs') * The system is liquid-like. A liquid phase is searched IF (INITL .NE. 1) GO TO 150 DO 140 1=1,N XI(N+1,I)=XIN(I) 140 CONTINUE CALL TIME(O.O.ITDUM) CALL INMICH(N.XI) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,790) 790 F0RMAT(/4X,'SUBROUTINE INMICH') IF (IFLG(15) .Eq. 2) WRITE(6,800) ((XI(J,I), 1=1,N), J=1,N+1) 800 F0RMAT(6X,6F9.5) WRITE(6,780) ITIMI WRITE(6,810) 810 F0RMAT(/4X,'SUBROUTINE LIQSER RESULTS') CALL TIME(O.O.ITDUM) CALL LiqSER(EPS,ITMAX,IWEG,TIMAX,N+l,N,P,T,Z,XI,HL,TC,PC,W,PP, + APUR,BPUR,KIJ,ITNUM,OBJL,FUCL1,FUCL2,XI,X2,IFLG) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI GO TO 210 150 DO 160 1=1,N XI(3,I)=XIN(I) 160 CONTINUE IF (INOLC .Eq. 1) GO TO 170 GO TO (170,180,190) INITL-1 170 CALL TIME(0,0,ITDUM) CALL INGASE(Z,TC,PC,W.PP.P.T.N,APUR,BPUR,KIJ,IFLG,ALSL, + IP.IQ.XI) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,820) IP.iq 820 F0RMAT(/4X,'SUBROUTINE INGASE RESULTS'/6X,*IP=',12,2X, + 'IQ=',I2) WRITE(6,830) ((XI(J.I), 1=1,N), J=l,3) 830 FORMAT(6X.6F9.5) WRITE(6,780) ITIMI IF (INOLC .Eq. 0) GO TO 200 180 CALL TIME(O.O.ITDUM) CALL INSHAH(Z,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG,IP,iq, + XI) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,840) IP.iq Appendix C. Description and listings of the computer programs 197 840 FORMAT(/4X,'SUBROUTINE INSHAH RESULTS'/6X,'IP=',12,2X, + 'IQ=',I2) WRITE(6,830) ((XI(J,I), 1=1,N), J=l,3) WRITE(6,780) ITIMI IF (INOLC .EQ. 0) GO TO 200 190 CALL TIME(0,0,ITDUM) CALL INLiq(Z,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG,ALSL, + IP.IQ.XI) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,850) IP.iq 850 F0RMAT(/4X,'SUBROUTINE INLIQ RESULTS'/6X,'IP=',12,2X, + 'iq=',I2) WRITE(6,830) ((XI(J,I), 1=1,N), J=l,3) WRITE(6,780) ITIMI IF (INOLC .Eq. 1) GO TO 570 200 WRITE(6,810) CALL TIME(O.O.ITDUM) CALL LiqSER(EPS,ITMAX,IWEG,TIMAX,MX,N,P,T,Z,XI,HL,TC,PC,W,PP, + APUR,BPUR,KIJ,ITNUM,OBJL,FUCL1,FUCL2,X1,X2,IFLG) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI 210 IF (IFLG(15) .NE. 0) GO TO 220 IF (IFLG(6) .Eq. 1) THEN WRITE(6,860) 860 F0RMAT(6X,'UNSTABLE SYSTEM. ONE LIQUID PHASE FOUND') ELSE IF (IFLG(6) .EQ. 2) THEN WRITE(6,870) 870 FORMAT(6X,'UNSTABLE SYSTEM. TWO LIQUID PHASES FOUND') ELSE WRITE(6,880) 880 FORMAT(6X,'STABLE SYSTEM. NO LIQUID PHASE(S) FOUND') END IF 220 WRITE(6,890) (I,X1(I),I,X2(I), 1=1,N) 890 FORMAT(8X,'xl(',12,')=',F9.6,2X,'x2(',12,')=',F9.6) WRITE(6,770) ITNUM WRITE(6,780) ITIMI IF (INOLC .Eq. 2) GO TO 1135 IF (ISRCH .Eq. 0) GO TO 226 * If a vapour is found and no liquid(s) found, a liquid phase which * might have been missed is searched using the additional search * (subroutine PHASER) IF (IFLG(5) .Eq. 1 .AND. IFLG(6) .Eq. 0) THEN CALL TIME(O.O.ITDUM) CALL PHASER(Z,Y,XD,P,T,N,DELGL,FUCV,FUCD,IFLG,HP) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI IF (INITL .Eq. 1) THEN MX=N+1 ELSE MX=3 END IF WRITE(6,892) 892 FORMAT(/4X,'SUBROUTINE LIQSER RESULTS AFTER CALLING PHASER') WRITE(6,780) ITIMI CALL TIME(O.O.ITDUM) CALL LiqSER(EPS,ITMAX,IWEG,TIMAX,MX,N,P,T,Z,XI,HP,TC,PC,W, + PP,APUR,BPUR,KIJ,ITNUM,OBJL,FUCL1,FUCL2,XI,X2, + IFLG) IF (IFLG(15) .NE. 0) GO TO 222 Appendix C. Description and listings of the computer programs 198 IF (IFLG(6) .EQ. 1) THEN IFLG(19)=1 WRITE(6,860) ELSE IF (IFLG(6) .Eq. 2) THEM WRITE(6,870) ELSE WRITE(6,880) END IF 222 WRITE(6,890) (I,X1(I),I,X2(I), 1=1,N) WRITE(6,770) ITNUM WRITE(6,780) ITIMI END IF * If no vapour is found and one or two liquid phases are found, a * vapour which might have been missed is looked for with the proposed * additional search IF (IFLG(5) .Eq. 0 .AND. IFLG(6) .NE. 0) THEN CALL TIME(O.O.ITDUM) IF (IFLG(6) .Eq. 1) THEN CALL PHASER(Z,XI,XD,P,T,N,DELGL,FUCL1,FUCD,IFLG,HP) ELSE CALL PHASER(Z,XI,X2,P,T,N,DELGL,FUCL1,FUCL2,IFLG,HP) END IF CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,895) 895 F0RMAT(/4X,'SUBROUTINE VAPSER RESULTS AFTER CALLING PHASER') WRITE(6,780) ITIMI CALL TIME(O.O.ITDUM) CALL VAPSER(EPS,ITMAX,IWEG,TIMAX,N,P,T,Z,YI,HP,TC,PC,W,PP, + APUR,BPUR,KIJ,ITNUM,OB J,FUCV,Y,IFLG) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI IF (IFLG(15) .NE. 0) GO TO 224 IF (IFLG(5) .Eq. 1) THEN WRITE(6,740) ELSE WRITE(6,750) END IF 224 WRITE(6,760) (I,Y(I), 1=1,N) WRITE(6,770) ITNUM WRITE(6,780) ITIMI END IF * If no vapour is found and no liquid(s) either, the system is * stable as a liquid 226 IF (IFLG(5) .Eq. 0 .AND. IFLG(6) .EQ. 0) THEN IFLG(11)=1 WRITE(6,900) 900 FORMAT(/4X,'+++ STABLE SYSTEM AS L +++') GO TO 440 END IF * If no vapour is found and one or two liquid phases are found, * the system is stable as LL IF (IFLG(5) .Eq. 0 .AND. IFLG(6) .NE. 0) THEN IFLG(11)=3 WRITE(6,910) 910 FORMAT(/4X,'+++ STABLE SYSTEM AS LL +++*) IF (IFLG(6) .Eq. 1) THEN Appendix C. Description and listings of the computer programs DO 230 1=1,H KL(I)=FUCSL(I)/FUCL1(I) X2(I)=Z(I) 230 CONTINUE ELSE DO 240 1=1,N KL(I)=FUCL2(I)/FUCL1(I) 240 CONTINUE END IF GO TO 440 END IF * If a vapour is found and no liquid phase(s) found, the system is * stable as VL IF (IFLG(5) .EQ. 1 .AND. IFLG(6) .EQ. 0) THEN IFLG(11)=2 WRITE(6,920) 920 F0RMAT(/4X,'+++ STABLE SYSTEM AS VL +++') DO 250 1=1,N KV(I)=FUCSL(I)/FUCV(I) X2N(I)=Z(I) 250 CONTINUE GO TO 440 END IF * If a vapour is found and one or two liquid phases are found, the * most stable system is determined using Nelson's or the multiphase * stability test (subroutines NELSTA or TESTA) IF (IFLG(6) .Eq. 1) THEN DO 260 1=1,N KV(I)=FUCSL(I)/FUCV(I) KL(I)=FUCSL(I)/FUCL1(I) X2(I)=Z(I) 260 CONTINUE ELSE DO 270 1=1,N KV(I)=FUCL2(I)/FUCV(I) KL(I)=FUCL2(I)/FUCL1(I) 270 CONTINUE END IF IF (INITL .Eq.l) THEN IP=1 X1MAX=X1(1) DO 280 1=2,N IF (X1(I) .GT. X1MAX) THEN IP=I X1MAX=X1(I) END IF 280 CONTINUE END IF IF (ISTA .EQ. 1 .OR. ISTA .EQ. 2 .AND. IFLG(19) .Eq. 1) THEN IFLG(19)=0 WRITE(6,930) 930 FORMAT(/4X,'SUBROUTINE NELSTA RESULTS') CALL TIME(0,0,ITDUM) CALL NELSTA(Z,Y,X1,X2,IP,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ, + KV,KL,IFLG,YN,XIN,X2N,FUCVN,FUCL1N,FUCL2N, + ALPHA,BETA) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI ELSE Appendix C. Description and listings of the computer programs 200 WRITE(6,940) 940 F0RMAT(/4X,'SUBROUTINE TESTA RESULTS') CALL TIME(0,0,ITDUM) CALL TESTA(Z,Y,X1,X2,IP,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ, + KV,KL,IFLG,YN,XIN,X2N,FUCVN,FUCL1N,FUCL2N, + ALPHA,BETA) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI END IF WRITE(6,950) ALPHA,BETA 950 FORMAT(6X,'V/F=',F9.5,2X,'Ll/F=*,F9.5) WRITE(6,960) (I,YN(I),I,X1N(I),I,X2N(I), 1=1,N) 960 FORMAT(6X,'YN(',12,')='.F9.6.2X,'X1N(',12,')=',F9.6,2X, + *X2N(',I2,')=',F9.6) IF (IFLG(ll) .Eq. 0) THEN WRITE(6,970) 970 FORMAT(/4X,'+++ SYSTEM STABLE AS V +++') ELSE IF (IFLG(ll) .Eq. 1) THEN WRITE(6,900) ELSE IF (IFLG(ll) .Eq. 2) THEN WRITE(6,920) IF (IFLG(14) .Eq.l) THEN DO 290 1=1,N KV(I)=FUCL1(I)/FUCV(I) 290 CONTINUE END IF ELSE IF (IFLG(ll) .Eq. 3) THEN WRITE(6,910) ELSE WRITE(6,980) 980 F0RMAT(/4X,'+++ STABLE SYSTEM AS VLL +++') END IF WRITE(6,780) ITIMI GO TO 440 * The system is vapour-like. A liquid phase is searched 300 IF (INOLC .Eq. 1) GO TO 320 IF (INITL .NE. 1) GO TO 320 DO 310 1=1,N XI(N+1,I)=XIN(I) 310 CONTINUE CALL TIME(0,0,ITDUM) CALL INMICH(N.XI) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,790) IF (IFLG(15) .Eq. 2) WRITE(6,800) ((XI(J.I), 1=1,N), J=1,N+1) WRITE(6,780) ITIMI WRITE(6,810) CALL TIME(O.O.ITDUM) CALL LIQSER(EPS,ITMAX,IWEG,TIMAX,N+1,N,P,T,Z,XI,HV.TC,PC,W.PP, + APUR,BPUR,KIJ,ITNUM,OBJL,FUCL1,FUCL2,X1,X2,IFLG) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI GO TO 380 320 DO 330 1=1,N XI(3,I)=XIN(I) 330 CONTINUE IF (INOLC .Eq. 1) GO TO 340 GO TO (340,350,360) INITL-1 340 CALL TIME(0,0,ITDUM) Appendix C. Description and listings of the computer programs CALL INGASE(Z,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG,ALSL, + IP.IQ.XI) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,820) IP.iq WRITE(6,830) ((XI(J.I), 1=1,H), J=l,3) WRITE(6,780) ITIMI IF (INOLC .Eq. 0) GO TO 370 350 CALL TIME(O.O.ITDUM) CALL INSHAH(Z,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG,IP,IQ, + XI) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,840) IP.IQ WRITE(6,830) ((XI(J,I), 1=1,N), J=l,3) WRITE(6,780) ITIMI IF (INOLC .Eq. 0) GO TO 370 360 CALL TIME(0,0,ITDUM) CALL INLiq(Z,TC,PC,W.PP.P.T.N,APUR,BPUR,KIJ,IFLG,ALSL, + IP.iq.XI) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI WRITE(6,850) IP.iq WRITE(6,830) ((XI(J,I), 1=1,N), J=l,3) WRITE(6,780) ITIMI IF (INOLC .Eq. 1) GO TO 570 370 WRITE(6,810) CALL TIME(O.O.ITDUM) CALL LiqSER(EPS,ITMAX,IWEG,TIMAX,MX,N,P,T,Z,XI,HV,TC,PC,W,PP, + APUR,BPUR,KIJ,ITNUM,OBJL,FUCL1,FUCL2,X1,X2,IFLG) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI 380 IF (IFLG(15) .NE. 0) GO TO 390 IF (IFLG(6) .EQ. 1) THEN WRITE(6,860) ELSE IF (IFLG(6) .Eq. 2) THEN WRITE(6,870) ELSE WRITE(6,880) END IF 390 WRITE(6,890) (I,X1(I),I,X2(I), 1=1,N) WRITE(6,770) ITNUM WRITE(6,780) ITIMI IF (INOLC .Eq. 2) GO TO 1135 IF (ISRCH .Eq. 0) GO TO 395 * If one liquid phase is found, another liquid phase which might * have been missed is searched using the proposed additional search IF (IFLG(6) .Eq. 1) THEN CALL TIME(0,0,ITDUM) CALL PHASER(Z,X1,XD,P,T,N,DELGV,FUCL1,FUCD,IFLG,HP) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI IF (INITL .Eq. 1) THEN MX=N+1 ELSE MX=3 END IF WRITE(6,892) WRITE(6,780) ITIMI CALL TIME(0,0,ITDUM) Appendix C. Description and listings of the computer programs 202 CALL LiqSER(EPS,ITMAX,IWEG.TIMAX,MX,N,P,T,Z,XI,HP,TC,PC,W, + PP,APUR,BPUR,KIJ,ITNUMP,OBJLP,FUCL1P,FUCL2P, + X1P.X2P.IFLG) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI IF (IFLG(6) .Eq. 2) THEN 0BJL(1)=0BJLP(1) 0BJL(2)=0BJLP(2) DO 392 1=1,H FUCL1(I)=FUCL1P(I) FUCL2(I)=FUCL2P(I) X1(I)=X1P(I) X2(I)=X2P(I) 392 CONTINUE END IF IF (IFLG(15) .NE. 0) GO TO 393 IF (IFLG(6) .Eq. 1) THEN WRITE(6,860) WRITE(6,890) (I,X1P(I),I,X2P(I), 1=1,1) GO TO 394 ELSE IF (IFLG(6) .Eq. 2) THEN WRITE(6,870) ELSE IFLG(6)=1 WRITE(6,880) END IF 393 WRITE(6,890) (I,X1(I),I,X2(I), 1=1,N) 394 WRITE(6,770) ITNUMP WRITE(6,780) ITIMI END IF * If no liquid phase(s) are found, the system is stable as vapour 395 IF (IFLG(6) .Eq. 0) THEN IFLG(11)=0 WRITE(6,970) GO TO 440 END IF * If one liquid phase is found, the system is stable as VL IF (IFLG(6) .Eq. 1) THEN IFLG(11)=2 WRITE(6,920) DO 400 1=1,N KV(I)=FUCL1(I)/FUCSV(I) Y(I)=Z(I) X2N(I)=X1(I) 400 CONTINUE GO TO 440 END IF * If two liquid phases are found, the most stable system is * determined using subroutines NELSTA or TESTA DO 410 1=1,N KV(I)=FUCL2(I)/FUCSV(I) KL(I)=FUCL2(I)/FUCL1(I) Y(I)=Z(I) 410 CONTINUE IF (INITL .Eq. 1) THEN IP=1 X1MAX=X1(1) Appendix C. Description and listings of the computer programs 203 DO 420 1=2,H IF (X1(I) .GT. X1MAX) THEN IP=I X1MAX=X1(I) END IF 420 CONTINUE END IF IF (ISTA .Eq. 1) THEN WRITE(6,930) CALL TIME(O.O.ITDUM) CALL NELSTA(Z,Y,X1,X2,IP,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ, + KV,KL,IFLG,YN,XIN,X2N,FUCVN,FUCL1N,FUCL2N, + ALPHA,BETA) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI ELSE WRITE(6,940) CALL TIME(0,0,ITDUM) CALL <TESTA(Z,Y,X1,X2,IP,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ, + KV,KL,IFLG,YN,XIN,X2N,FUCVN,FUCL1N.FUCL2N, + ALPHA,BETA) CALL TIME(1,0,ITIMI) ITIMT=ITIMT+ITIMI END IF WRITE(6,950) ALPHA,BETA WRITE(6,960) (I,YN(I),I,X1N(I),I,X2N(I), 1=1,N) IF (IFLG(ll) .Eq. 0) THEN WRITE(6,970) ELSE IF (IFLG(ll) .Eq. 1) THEN WRITE(6,900) ELSE IF (IFLG(ll) .Eq. 2) THEN WRITE(6,920) IF (IFLG(14) .Eq. 1) THEN DO 430 1=1,N KV(I)=FUCL1(I)/FUCSV(I) 430 CONTINUE END IF ELSE IF (IFLG(ll) .Eq. 3) THEN WRITE(6,910) ELSE WRITE(6,980) END IF WRITE(6,780) ITIMI * If the system is in the one phase region the calculation ends 440 IF (IFLG(ll) .Eq. 0 .OR. IFLG(ll) .Eq. 1) THEN WRITE(6,985) ITIMT 985 FORMAT(/4X,'TOT CPU TIME=',I4,' msecs') GO TO 1135 ELSE IF(IFLG(11) .Eq. 2) THEN * Calculation of the i n i t i a l value of V/F for the VL flash SUM1=0.DO SUM2=0.D0 DO 450 1=1,N SUM1=SUM1+KV(I)*Z(I) SUM2=SUM2+(1.D0-KV(I))*Z(I)/(1.D0+KV(I)) 450 CONTINUE SUM1=1.D0-SUM1 SUM2=2.D0*SUM2 F=SUM2/(SUM2-SUM1) Appendix C. Description and listings of the computer progra.ms 204 IF (F .GT. O.DO) THEN ALPHA=0.SDO*(1.DO-F) GO TO 470 END IF SUM3=0.D0 DO 460 1=1,1 SUM3=SUM3+Z(I)/KV(I) 460 CONTINUE SUM3=SUM3—1.DO ALPHA=(SUM2-0.5D0*SUM3)/(SUM2-SUM3) 470 IF (ALPHA .LT. 0.05D0) ALPHA=0.05D0 IF (ALPHA .GT. 0.95D0) ALPHA=0.9SD0 DO 480 1=1,N YN(I)=Y(I) XN(I)=X2N(I) 480 CONTINUE * Printing of the i n i t i a l estimates for the VL flash WRITE(6,990) T,P,ALPHA 990 FORMAT(/4X,'VL FLASH INITIALIZATION',2X,'T=',F8.3,' K', + 2X,'P=\F8.3,' atm',2X,'V/F=',F8.5/9X,'I',5X,'Z', + gx.'Y'.sx.'X') WRITE(6,1000) (I,Z(I),YN(I),XN(I), 1=1,N) 1000 F0RMAT(8X,I2,1X,F8.5,1X,F8.5,1X,F8.5) WRITE(6,780) ITIMT * VL flash calculation ITEQ=1 TYPEq='VL FLASH' CALL TIME(0,0,ITDUM) CALL FLASH2(ITEQ,EPSF,ITMAX,ITNUM,IWEGF,OBJ,N,P,T,ALPHA,XN, YN,Z.TC,PC,W,PP,KIJ,FUCVN,FUCL1N,Z1,Z2,KV,IFLG) CALL TIME(1,0,ITIMC) BETA=ALPHA CALL GIBBS(ITEQ,N,P,T,ALPHA,BETA,YN.XN,XIN,X2N,Z,TC,PC,W, PP,KIJ,FUCVN,FUCL1N,FUCL2N,DG,IFLG) BETA=0.DO GO TO 530 ELSE IF (IFLG(ll) .EQ. 3) THEN * Calculation of the i n i t i a l value of Ll/F for the LL flash IF (INITL .EQ. 1) THEN IF (IP .Eq. 0) THEN IP=1 X1MAX=X1(1) DO 490 1=2,N IF (X1(I) .GT. X1MAX) THEN IP=I X1MAX=X1(I) END IF 490 CONTINUE END IF iq=i X2MAX=X2(1) DO 500 1=2,N IF (X2(I) .GT. X2MAX) THEN iq=i X2MAX=X2(I) END IF 500 CONTINUE Appendix C. Description and listings of the computer programs 205 END IF BETA=(Z(IP)*(l.DO-l.DO/KL(IP))+KL(iq)*Z(iq))/ + (z(ip)+z(iq)) IF (BETA .LT. 0.05D0) BETA=0.05D0 IF (BETA .GT. 0.95D0) BETA=0.95D0 DO 510 1=1,1 X11T(I)=X1(I) X2N(I)=X2(I) 510 CONTINUE * Printing of the i n i t i a l estimates for the LL flash WRITE(6,1010) T,P,BETA 1010 FORMAT(/4X,'LL FLASH INITIALIZATION',2X,'T=',F8.3,' K', + 2X,»P=',F8.3,' atm',2X,'Ll/F=',F8.5/9X,'I',5X, + 'Z',8X,'X1',8X,'X2') WRITE(6,1000) (I,Z(I),X1N(I),X2N(I), 1=1,N) WRITE(6,780) ITIMT * LL flash calculation ITEQ=2 TYPEQ='LL FLASH' CALL TIME(0,0,ITDUM) CALL FLASH2(ITEQ,EPSF,ITMAX,ITNUM,IWEGF,OBJ,N,P,T,BETA,X2N, + XIN,Z.TC,PC,W.PP,KIJ,FUCVN,FUCL1N.Z1,Z2,KL,IFLG) CALL TIME(l.O.ITIMC) CALL GIBBS(ITEq,N,P,T,ALPHA,BETA,XIN,X2N,XI,X2,Z,TC,PC,W, + PP,KIJ,FUCVN,FUCL1N,FUCL2N,DG,IFLG) DO 520 1=1,1 YN(I)=0.D0 X1N(I)=X1(I) X2N(I)=X2(I) 520 CONTINUE GO TO 530 ELSE * Printing of the i n i t i a l estimates for the VLL flash WRITE(6,1020) T,P,ALPHA,BETA 1020 FORMAT(/4X,'VLL FLASH INITIALIZATION',2X,'T=',F8.3,' K', + 2X,'P=',F8.3,' atm'/30X,'V/F=',F8.5,3X,'Ll/F=',F8.5 + /9X,'I',5X,'Z',8X,'Y',8X,*X1',8X,'X2') WRITE(6,1030) (I,Z(I),YN(I),X1N(I),X2N(I), 1=1,N) 1030 F0RMAT(8X,I2,1X,F8.5,1X,F8.5,1X,F8.5,1X,F8.5) WRITE(6,780) ITIMT * VLL flash calculation ITEQ=3 TYPEq='VLL FLASH' CALL TIME(0,0,ITDUM) CALL FLASH3(EPSF,ITMAX,ITNUM,IWEGF,OBJ,N,P,T,ALPHA,BETA,YN, + XIN,X2N.Z.TC,PC,W.PP,KIJ,ZED,FUCVN,FUCL1N, + FUCL2N.IFLG) CALL TIME(1,0,ITIMC) END IF CALL GIBBS(ITEq,N,P,T,ALPHA,BETA,YN.XN,XIN,X2N.Z.TC,PC,W.PP, + KIJ,FUCVN,FUCL1N.FUCL2N.DG,IFLG) * Printing of the calculation results 530 0NMAB=1.DO-ALPHA-BETA Appendix C. Description and listings of the computer programs 206 IF (ITEQ .Eq. 2) THEN ZED(l)=O.DO ZED(2)=Z1 ZED(3)=Z2 ELSE IF (ITEq .Eq. 1) THEN ZED(1)=Z1 ZED(2)=0.D0 ZED(3)=Z2 END IF IF (IFLG(7) .Eq. 0) THEN WRITE(6,1040) 1040 F0RMAT(/4X,'WITHOUT WEGSTEINS METHOD') GO TO 540 END IF IF (IFLG(8) .Eq. 0) THEN DAMP=' WITHOUT DAMPING' ELSE DAMP=' WITH DAMPING' END IF WRITE(6,1050) IWEGF.DAMP 1050 F0RMAT(/4X,'WEGSTEINS METHOD EACH',13,' ITERATIONS',A16) 540 WRITE(6,1060) ITMAX.EPSF 1060 FORMAT(4X,'MAXIMUM NO. OF ITERATIONS=',13,2X, + 'CONVERGENCE=',F8.5) WRITE(6,1070) TYPEq 1070 FORMAT (/15X,A10.2X,'CALCULATION RESULTS') WRITE(6,1080) T,P,ITNUM,OB J,ALPHA,BETA,ONMAB,DG 1080 F0RMAT(4X,'T=',F8.3,' K',2X,'P=',F8.3,' atm',2X, + 'NUM. ITER.=',I3,2X,'0BJ. FUNC.='.E12.5/ + 4X,'V/F='.F8.5.2X,'Ll/F='.F8.5.2X,'L2/F=', + F8.5.2X,'DEL G='.F11.3,' cal/gmole') DO 560 1=1,N IF (ITEq .Eq. 2) THEN KV(I)=1.D0 ELSE KV(I)=FUCL2N(I)/FUCVN(I) END IF IF (ITEq .Eq. 1) THEN KL(I)=1.D0 ELSE KL(I)=FUCL2N(I)/FUCL1N(I) END IF 560 CONTINUE IF (IFLG(3) .Eq. 1) THEN ZL2='ZLiq2ext=' ELSE ZL2='ZLiq2=' END IF IF (IFLG(2) .Eq. 1) THEN ZLl='ZLiqiext=' ELSE ZLl='ZLiqi=' ENDIF IF (IFLG(l) .Eq. 1) THEN ZV='ZVAPext=* ELSE ZV='ZVAP=' END IF WRITE(6,1090) ZV,ZED(1),ZL1,ZED(2),ZL2,ZED(3) 1090 F0RMAT(4X,A8,F7.5,2X,A9,F7.5,2X,A9,F7.5) IF (ITEq .NE. 1) WRITE(6,1100) IP.iq 1100 FORMAT(4X,'KEY COMP.#1=',12,2X,'KEY COMP.#2=',12) WRITE(6,1110) Appendix C. Description and listings of the computer programs 207 1110 FORMAT(8X,'I*,5X,'Z',8X,'Y',8X,'XI',7X,'X2',5X, + 'KV=Y/X2',2X,'KL=X1/X2') WRITE(6,1120) (I,Z(I),YN(I),X1N(I),X2N(I),KV(I),KL(I), + 1=1,1) 1120 F0RMAT(7X,I2,1X,F8.5,1X,F8.5,1X,F8.5,1X,F8.5,2X, + Gil.4,21,611.4) WRITE(6,1130) ITIMC 1130 FORMAT(4X,'CPU TIME=',14,' msecs') WRITE(6,985) ITIMT+ITIMC 1135 WRITE(6,1140) 1140 FORMAT(/'=================================================='/) ITOTIM=ITOTIM+ITIMT+ITIMC * End of loop for calculation at different compositions at fixed T ft P 565 CONTINUE 570 CONTINUE 580 CONTINUE * End of loop for calculations at fixed comp. ft T at various P or at * fixed comp. ft P at different T 590 CONTINUE WRITE(6,1150) IT0TIM 1150 FORMAT(/4X,'GLOBAL CPU TIME=',I5,' msecs'/) STOP END CJN3 Iranian anuimoo oz anNiiNoo OT dl 0.N3 f3HIX=(l'r)IX f3NIX=(r'l)IX 3S13 f3ix=(r'i)ix N3HI (f -b3' I) JI H'i=r OT oa H'T=I oz oa (T-N)/(f3IX-Oa-T)=f3KIX oa86-o=r3ix 203.38A * 5ieu;3. ux sq.tt9uodmoo 9x15 jo 5S9.1 am 3uonre Axi^nbg p95nqx.1q.sxp sx * 80U9J9jfTp ZO'O em ptre Joq.00A 9u-r.puods9xxoo xcoq:} ux squauodmoo * sqq. 10 •qo'e© J O I peu2xss^ sx uoxqo'e.ij ©xoni ux 86*0 Jo uoxq.xsodmoo y * (OS'IS)IX K0ISH3Hia (Z-O'H-V) 8*1V3H IIOIldHI (IX'H)HOIHNI 3NiinoHans * indsvHd * * :A"q pa ti^o * * * * O U O H * * :paiT«o s9Uxq.no.xqns * * * * suoxqxsodraoo pxnbxx I B X I X U X J O A^xre K x N IX * * 5ndq.n0- * * * + sq.u9uodraoo jo .xaqnmg g * * qndui- * 41 : sje^snrexBj * * * * seq.'eurr.qss * * i«x3.xux S B sqtwuodinoo aond 905 Suxsn jo sra9iios S , U9S X9T I O X H 05 * * Xisfi sno2ox«vre ux sq.u9uodraoo 9jnd , qsoorre, jo s.xoqoeA uoxqxsodmoo jj * * 9 u x j 9 p x s u o o H3Sbn 9uxqno:tqns I O J suoxqxsodmoo pxnbxx f>ZTT"eT:l-T,II * * lasodmj * * * * * * (00HI3H S.H3S13H0IH HI SV 'SdHOO '011 dO "IINI) HOIHNI BNIlnOHanS * * * 80c suiviSojd jo^ndmoo 9ijf jo sSuifSTj puv nox^duosofj -Q xipuoddy Appendix C. Description and listings of the computer programs 209 ***************************************************** * * * SUBROUTINE INSHAH (INIT. OF Liq. COMPS. BY SHAH'S METHOD) * * * ********************************************************************* * * * Purpose: * * Initialize liquid compositions to be used in subroutine LIQSER * * by obtaining key components p and q according to Shah's method. * * These components s i l l be the phase initiators for the two liquid * * phases searched ( l i q 1 and 2). * * * * Parameters: * * -Input * * Z,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG as in program PHASPLIT * * * * -Output * * IP Index of key component p in phase 1 * * iq • " q " " 2 * * XI 2 x N array of i n i t i a l liquid compositions (mole frac.) * * * * Main variables: * * APT Vector of pure component dimensionless attraction param. * * in the EOS for the t r i a l components * * ACI Pseudo-infinite dilution activity of component i in the * * original mixture * * ACT Pseudo-infinite dilution activity of t r i a l components for * * phase 2 in comp. p * * BPT Vector of pure component dimensionless repulsion param. * * in the EOS for the t r i a l components * * FUCD Vector of dummy fug. coeffs. * * FUCLI " " infinite dilution fug. coeffs. in the mixture * * FUCLT " " " for the t r i a l * * components * * FUCP1 Fug. coeff. of pure p with trace of comp. q * * FUCP2 " " " p at infinite dilution in q * * FUCQ1 " " " q " " " " p * * FUCQ2 " " " pure q with trace of comp. p * * FUCR1 " " " i at infinite dilution in l i q . 1 * * FUCR2 " " " " " 2 * * PCT Vector of c r i t i c a l pressures for the t r i a l components * * PPT " " Mathias polar param. " * * PN1 Number of moles of comp. p in phase 1 * * PN2 " M " " " 11 M M 2 * * QNl q " " 1 * * QN2 " " 11 " " " 11 11 2 * * RN1 " " " " the remaining i comps. in phase 1 * * RN2 11 " " 11 " " " 11 11 M 2 * * TCT Vector of c r i t i c a l temperatures for the t r i a l comps. * * T0TN1 Total mole number in phase 1 * * T0TN2 " " 2 * * XINF Vector of infinite dilution composition * * XS Comp. vector for the t r i a l components in the second phase * * XT " " ' " " the l i q . * * * * Remaining variables defined as in program PHASPLIT * * * * Subroutines called: * * K * * * * Called by: * * PHASPLIT * Appendix C. Description and listings of the computer programs 210 SUBROUTINE INSHAH(Z,TC,PC,W,PP,P,T,H,APUR,BPUR,KIJ,IFLG, + IP.iq.XI) IMPLICIT REAL*8 (A-H.O-Z) REAL*8 KEq(3),KIJ(20,20) DIMENSION APT(3),APUR(20),BPT(3),BPUR(20),FUCD(3),FUCLI(20), + FUCLT(3),IFLG(0:20),PC(20),PCT(3),PP(20),PPT(3), + RN1(18),RN2(18),TC(20),TCT(3),W(20),WT(3),XD(3), + 11(21,20),XINF(20),XS(3),XT(3),Z(20) IF (IFLG(15) .Eq. 2) WRITE(6,500) 500 FORMAT(/4X,'SUBROUTINE INSHAH TRACING') IF (IFLG(15) .Eq. 2) WRITE(6,510) 510 F0RMAT(/4X,'FUG COEFF OF I IN THE LIQ MIXTURE AT INF DILUTION' + /4X,'I',10X,'FUG COEFF*) * Selection ol phase initiator p as the component with the largest * pseudo-infinite dilution activity in the overall mixture HAI=0.D0 ZI=l.D-6 DO 30 1=1,1 SUM=0.D0 DO 10 J=1,N IF (I .Eq. J) GO TO 10 SUM=SUM+Z(J) 10 CONTINUE SUM=SUM+ZI XINF(I)=ZI/SUM DO 20 J=1,N IF (I .Eq. J) GO TO 20 XINF(J)=Z(J)/SUM 20 CONTINUE CALL K(XD,XINF,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUCLI,FUCD, + ZI,ZD,KIJ,KEq,IFLG) ACI=Z(I)*FUCLI(I) *P IF (IFLG(15) .Eq. 2) WRITE(6,520) I.FUCLI(I) 520 F0RMAT(3X,I2,9X,F10.6) IF (HAI .LT. ACI) THEN HAI=ACI IP=I END IF 30 CONTINUE * Selection of phase initiator q as the component with the largest * pseudo-infinite dilution activity in pure component p HAT=0.D0 TCT(1)=TC(IP) PCT(1)=PC(IP) WT(1)=W(IP) PPT(1)=PP(IP) APT(1)=APUR(IP) BPT(1)=BPUR(IP) XT(2)=l.D-6 XT(1)=1.D0-XT(2) IF (IFLG(15) .Eq. 2) WRITE(6,530) 530 F0RMAT(/4X,'i FUG COEFF OF PURE p FUC COEFF OF i AT' + /4X,' WITH TRACE OF COMP i INF DILUTION IN p') DO 40 1=1, N IF (I .EQ. IP) GO TO 40 TCT(2)=TC(I) Appendix C. Description and listings of the computer programs 211 PCT(2)=PC(I) WT(2)=W(I) PPT(2)=PP(I) APT(2)=APUR(I) BPT(2)=BPUR(I) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,2,2,3,APT,BPT,FUCLT,FUCD, + ZT.ZD.KIJ.KEq.IFLG) ACT=Z(I)+FUCLT( 2 ) *P IF (IFLG(15) .Eq. 2) WRITE(6,540) I,FUCLT(1),FUCLT(2) 540 FORMAT(3X,12,8X,F10.6,15X,F10.6) IF (HAT .LE. ACT) THEN HAT=ACT iq=i * Assignment of fugacity coefficients of 'pure' p in phase 1 and * of q at infinite-dilution in phase 1 FUCP1=FUCLT(1) FUCqi=FUCLT(2) END IF 40 CONTINUE IF (IFLG(15) .Eq. 2) WRITE(6,550) FUCPl.FUCqi 550 FORMAT(4X,' FUCP1='.F10.6,' FUCqi='.F10.6) XT(l)=i.D-6 XT(2)=1.D0-XT(1) TCT(2)=TC(iq) PCT(2)=PC(iq) WT(2)=W(iq) ppT(2)=pp(iq) APT(2)=APUR(iq) BPT(2)=BPUR(iq) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,2,2,3,APT,BPT,FUCLT,FUCD, + ZT,ZD,KIJ,KEq,IFLG) IF (IFLG(15) .Eq. 2) WRITE(6,560) 560 F0RMAT(/4X,' FUG COEFF OF P AT FUC COEFF OF PURE q' + /4X,' INF DILUTION IN q WITH TRACE OF COMP P') IF (IFLG(15) .Eq. 2) WRITE(6,570) FUCLT(l),FUCLT(2) 570 FORMAT(4X,' FUCP2='.F10.6,' FUCq2='.F10.6) * Assignment of fugacity coefficients of p at infinite-dilution in * phase 2 and of 'pure' q in phase 2 FUCP2=FUCLT(1) FUCq2=FUCLT(2) * Calculation of the mole numbers of p and q from the equilibrium * and mass balance equations assuming no other components are * present A0=FUCP1-FUCP2 B0=Z(IP)*(FUCP2-2.D0*FUCP1) C0=Z(IP)*FUCP2 D0=FUCq2-FUCqi E0=2.D0*Z(IP)*FUCqi-Z(iq)*FUCq2 F0=-Z(iq)*FUCQ2 A=A0*(D0*(B0-C0)-A0*(E0-F0)) B=B0*D0*(BO-CO)-AO*(EO*(CO+BO)-2.D0*C0*F0) C=C0*(C0*F0-B0*E0) IF (A .Eq. O.DO) THEN PN1=-C/B GO TO 50 ELSE IF (C .Eq. O.DO) THEN PN1=-B/A Appendix C. Description and listings of the computer programs 212 GO TO 50 ELSE DISC=B*B-4.D0*A*C IF (DISC .LT. O.DO) THEN WRITE(6,580) 580 F0RMAT(/6X,'*** WARNING: NO REAL ROOTS FOUND WHEN TRYING' + /9X,'T0 SOLVE THE QUADRATIC EQUATION FOR npl IN' + /9X,'SUBROUTINE INSHAH') PN1=Z(IP)/2.D0 GO TO 60 ELSE IF (DISC .Eq. O.DO) THEN PN1=-B/(2.D0*A) GO TO 50 END IF END IF TWA=2.D0*A RTDISC=DSqRT(DISC) PN1=(-B+RTDISC)/TWA PNO=(-B-RTDISC)/TWA IF (PN1 .GT. O.DO .AND. PN1 .LT. Z(IP)) THEN qNl=-PNl*(AO*PNl+BO)/(AO*PNl+CO) IF (QN1 .GT. O.DO .AND. qNl .LT. Z(iq)) GO TO 80 ELSE IF (PNO .GT. O.DO .AND. PNO .LT. Z(IP)) THEN PN1=PN0 QN1=-PN1*(A0*PN1+B0)/(A0*PN1+C0) IF (qNl .GT. O.DO .AND. QNl .LT. Z(IQ)) THEN GO TO 80 ELSE GO TO 70 END IF END IF 50 IF (PN1 .LE. O.DO) PN1=0.1D0*Z(IP) IF (PN1 .GE. Z(IP)) PN1=0.9D0*Z(IP) 60 qNl=-PNl*(AO*PNl+BO)/(AO*PNl+CO) 70 IF (QNl .LE. O.DO) qNl=0.lDO*Z(iq) IF (qNl .GE. z(iq)) qNi=o.9DO*z(iq) 80 PN2=Z(IP)-PN1 qN2=z(iq)-qNi SMRN1=0.D0 SMRN2=0.D0 DENl=PNl+qNl DEN2=PN2+qN2 IF (IFLG(15) .Eq. 2) WRITE(6,590)A,B,C,DISC,Z(IP),Z(iq), + PNl,qNl,PN2,qN2 590 F0RMAT(/4X,'qUAD EQN FOR npl', + 2X,'A='.E12.5.1X,'B=*,E12.5,1X,'C=',E12.5,1X,'DISC=', + E12.5/4X,'Z(IP)='.F6.4.2X,'Z(iq)='.F6.4/4X,'PN1=', + F7.5.2X,»qNl='.F7.5.2X,*PN2=',F7.5,2X,'qN2=',F7.5) IF (N .Eq. 2) GO TO 110 * The mole numbers of the remaining components (one at the time) * are obtained again from the equilibrium and mass balance equations * assuming only p and q are present XT(1)=PN1/DEN1 XT(2)=qNl/DENl XT(3)=l.D-6 XS(1)=PN2/DEN2 XS(2)=qN2/DEN2 XS(3)=l.D-6 IF (IFLG(15) .Eq. 2) WRITE(6,600) 600 FORMAT(/4X,'i FUG COEFF OF i AT INF FUC COEFF OF i AT INF' + /4X,' DILUTION IN LIQUID 1 DILUTION IN LIQUID 2') Appendix C. Description and listings of the computer programs 213 DO 110 1=1,H IF ( i .Eq. IP .OR. i .Eq. iq) GO TO no TCT(3)=TC(I) PCT(3)=PC(I) WT(3)=W(I) PPT(3)=PP(I) APT(3)=APUR(I) BPT(3)=BPUR(I) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,3,2,3,APT,BPT,FUCLT,FUCD, + ZT.ZD.KIJ.KEq.IFLG) FUCR1=FUCLT(3) CALL K(XD,XS,TCT,PCT,WT,PPT,P,T,3,2,3,APT,BPT,FUCLT,FUCD, + ZT,ZD,KIJ,KEq,IFLG) FUCR2=FUCLT(3) IF (IFLG(15) .Eq. 2) WRITE(6,610) I.FUCRl.FUCR2 610 F0RMAT(3X,I2,' FUCR1=',F10.6,' FUCR2=',F10.6) A=FUCR1-FUCR2 B=FUCR2*(Z(I)-DEN1)-FUCR1*(Z(I)+DEN2) C=FUCR2*Z(I)*DENi IF (A .Eq. O.DO) THEN RN1(I)=-C/B GO TO 90 ELSE IF (C .Eq. O.DO) THEN RN1(I)=-B/A GO TO 90 ELSE DISC=B*B-4.D0*A*C IF (DISC .LT. O.DO) THEN WRITE(6,620) 620 F0RMAT(/6X,'*** WARNING: NO REAL ROOTS FOUND WHEN TRYING' + /9X,'T0 SOLVE THE QUADRATIC EQUATION FOR nrl IN' + /9X,'SUBROUTINE INSHAH') RN1(I)=Z(I)/2.D0 GO TO 100 ELSE IF (DISC .Eq. O.DO) THEN RN1(I)=-B/(2.D0*A) GO TO 90 END IF END IF TWA=2.D0*A RTDISC=DSqRT(DISC) RN1(I)=(-B+RTDISC)/TWA IF (RN1(I) .GT. O.DO .AND. RN1(I) .LT. Z(I)) GO TO 100 RN1(I)=(-B-RTDISC)/TWA IF (RN1(I) .GT. O.DO .AND. RN1(I) .LT. Z(I)) GO TO 100 90 IF (RN1(I) .LE. O.DO) RN1(I)=0.1D0*Z(I) IF (RN1(I) .GE. Z(I)) RN1(I)=0.9D0*Z(I) 100 RN2(I)=Z(I)-RN1(I) SMRN1=SMRN1+RN1(I) SMRN2=SMRN2+RN2(I) IF (IFLG(15) .EQ. 2) WRITE(6,630)A,B,C,DISC,Z(I),RN1(I),RN2(I) 630 F0RMAT(/4X,'CUAD EQN FOR nrl',2X,'A='.F10.6.1X,'B='.F10.6.1X, + 'C=«,F11.7,1X,'DISC='.F10.6/4X,'Z(I)='.F6.4.2X,'RN1=', + F7.S.2X,>RN2=*,F7.5) 110 CONTINUE * Calculation of the i n i t i a l composition estimates TOTN1=DEN1+SMRN1 T0TN2=DEN2+SMRN2 XI(1,IP)=PN1/T0TN1 XI(l,iq)=qNl/TOTNl XI(2,IP)=PN2/T0TN2 Appendix C. Description and listings of the computer programs 214 XI(2,IQ)=qN2/T0TN2 IF (IFLG(15) .Eq. 2) WRITE(6,640) DEN1,DEN2,SMRN1,SMRN2, + T0TN1,T0TN2 640 FORMAT(/4X,'DEN1=',F8.4,IX,'DEN2=',F8.4 + /4X,»SMRN1='.F8.4.1X,'SMRN2=',F8.4 + /4X,»T0TN1='.F8.4.1X,'T0TN2=',F8.4) DO 120 1=1, N IF ( i .Eq. IP .OR. i .Eq. iq) GO TO 120 XI(1,I)=RN1(I)/T0TN1 XI(2,I)=RN2(I)/T0TN2 120 CONTINUE RETURN END Appendix C. Description and listings of the computer programs 215 ********************************************************************** * * * SUBROUTINE INGASE (INIT. OF LIQ. COMPS. BY A MODIFIED GAUTAM * * ft SEIDER METHOD) * ********************************************************************** * * * Purpose: * * I n i t i a l i z e liquid compositions to be used in subroutine LIQSER by * * a simplified version of the method proposed by Gautam ft Seider to * * obtain the phase initiator components p and q in liquids 1 and 2 * * respectively. * * * * Parameters: * * -Input * * Z,TC,PC,V,PP,P,T,N,APUR,BPUR,KIJ,IFLG,ALSL as in program PHASPLIT * * * * -Output * * IP.IQ.XI as in subroutine INSHAH * * * * Main variables: * * ACT Activity i f t r i a l component i in a binary mixture with * * component p * * APT,BPT,FUCPl,FUCP2,FUCqi,FUCq2,FUCRl,FUCR2,PCT,PPT,PNl,PN2,QNl, * * qN2,RNl,RN2,T0TNl,T0TN2,WT,XS,XT as in subroutine INSHAH * * * * Remaining variables defined as in program PHASPLIT * * * * Subroutines called: * * K * * * * Called by: * * PHASPLIT * * * ********************************************************************** SUBROUTINE INGASE(Z,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG, + ALSL,IP,iq,XI) IMPLICIT REAL*8 (A-H.O-Z) REAL*8 KEq(3),KIJ(20,20) DIMENSION ALSL(20),APT(3),APUR(20),BPT(3),BPUR(20),FUCD(3), + FUCLT(3),IFLG(0:20),PC(20),PCT(3),PP(20),PPT(3), + RN1(18),RN2(18),TC(20),TCT(3),W(20),WT(3),XD(3), + XI(21,20),XS(3),XT(3),Z(20) IF (IFLG(15) .Eq. 2) WRITE(6,500) 500 F0RMAT(/4X,'SUBROUTINE INGASE TRACING') IF (IFLG(15) .Eq. 2) WRITE(6,510) 510 FORMAT(/4X,'ACTIVITY OF COMP. i IN THE ORIGINAL MIXTURE' + /4X,*i',10X,'ACTIVITY') * Selection of phase initiator p as the component with the highest * activity in the original mixture HAL=ALSL(1) IP=1 DO 10 1=2,N IF (HAL .LT. ALSL(I)) THEN HAL=ALSL(I) IP=I END IF 10 CONTINUE IF (IFLG(15) .Eq. 2) WRITE(6,520) (I,ALSL(I), 1=1,N) 520 F0RMAT(3X,I2,9X,F10.6) Appendix C. Description and listings of the computer programs 216 * Selection of phase initiator q as the component with the highest * binary activity with component p, considering a composition * proportional to that of the original mixture HAT=O.DO TCT(1)=TC(IP) PCT(1)=PC(IP) WT(1)=W(IP) PPT(1)=PP(IP) APT(1)=APUR(IP) BPT(1)=BPUR(IP) IF (IFLG(15) .Eq. 2) WRITE(6,530) 530 F0RMAT(/4X,'i FUG COEFF OF i IK' + /4X,* BIKARY MIXTURE WITH p') DO 20 1=1,1 IF (I .Eq. IP) GO TO 20 XT(1)=Z(IP)/(Z(I)+Z(IP)) XT(2)=1.D0-XT(1) TCT(2)=TC(I) PCT(2)=PC(I) WT(2)=W(I) PPT(2)=PP(I) APT(2)=APUR(I) BPT(2)=BPUR(I) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,2,2,3,APT,BPT,FUCLT,FUCD, + ZT.ZD.KIJ.KEq.IFLG) ACT=XT(2)*FUCLT(2)*P IF (IFLG(15) .Eq. 2) WRITE(6,540) I,FUCLT(2) 540 F0RMAT(3X,I2,8X,F10.6) IF (HAT .LE. ACT) THEN HAT=ACT iq=i END IF 20 CONTINUE * Calculation of the pure and infinite-dilution fug. coeffs. for * components p and q in phases 1 and 2 XT(2)=l.D-6 XT(1)=1.D0-XT(2) TCT(2)=TC(iq) PCT(2)=PC(iq) WT(2)=W(iq) ppT(2)=pp(iq) APT(2)=APUR(iq) BPT(2)=BPUR(iq) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,2,2,3,APT,BPT,FUCLT,FUCD, + ZT,ZD,KIJ,KEq,IFLG) * Assignment of fug. coeffs. of 'pure' p in phase 1 and of q at * infinite-dilution in phase 1 FUCP1=FUCLT(1) FUCqi=FUCLT(2) XT(l)=l.D-6 XT(2)=1.D0-XT(1) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,2,2,3,APT,BPT,FUCLT,FUCD, + ZT,ZD,KIJ,KEq,IFLG) * Assignment of fug. coeffs. of p at infinite-dilution in phase 2 * and of 'pure' q in phase 2 Appendix C. Description and listings of the computer programs 217 FUCP2=FUCLT(l) FUCq2=FUCLT(2) * Calculation of the mole numbers of p and q from the equilibrium * and mass balance equations assuming no other components are * present A0=FUCP1-FUCP2 B0=Z(IP)*(FUCP2-2.D0*FUCP1) C0=Z(IP)*FUCP2 D0=FUCQ2-FUCqi E0=2.DO*Z(IP)*FUCQ1-Z(IQ)*FUCQ2 F0=-Z(iq)*FUCQ2 A=A0*(D0*(B0-C0)-A0*(E0-F0)) B=B0*D0*(BO-CO)-AO*(EO*(CO+BO)-2.DO*CO*FO) C=CO*(CO*FO-BO*EO) IF (A .Eq. O.DO) THEN PN1=-C/B GO TO 30 ELSE IF (C .Eq. O.DO) THEN PN1=-B/A GO TO 30 ELSE DISC=B*B-4.D0*A*C IF (DISC .LT. O.DO) THEN WRITE(6,550) 550 F0RMAT(/6X,'*** WARNING: NO REAL ROOTS FOUND WHEN TRYING' + /9X,'T0 SOLVE THE qUADRATIC EqUATION FOR npl IN' + /9X,'SUBROUTINE INGASE') PN1=Z(IP)/2.D0 GO TO 40 ELSE IF (DISC .EQ. O.DO) THEN PN1=-B/(2.D0*A) GO TO 30 END IF END IF TWA=2.D0*A RTDISC=DSQRT(DISC) PN1=(-B+RTDISC)/TWA PNO=(-B-RTDISC)/TWA IF (PN1 .GT. O.DO .AND. PN1 .LT. Z(IP)) THEN qNl=-PNl*(AO*PNl+BO)/(AO*PNl+CO) IF (qNl .GT. O.DO .AND. qNl .LT. Z(IQ)) GO TO 60 ELSE IF (PNO .GT. O.DO .AND. PNO .LT. Z(IP)) THEN PN1=PN0 QN1=-PN1*(A0*PN1+B0)/(A0*PN1+C0) IF (QNl .GT. O.DO .AND. QNl .LT. Z(IQ)) THEN GO TO 60 ELSE GO TO 50 END IF END IF 30 IF (PN1 .LE. O.DO) PN1=0.1D0*Z(IP) IF (PN1 .GE. Z(IP)) PN1=0.9D0*Z(IP) 40 QN1=-PN1*(A0*PN1+B0)/(A0*PN1+C0) 50 IF (QNl .LE. O.DO) QN1=0.lDO*Z(iq) IF (qNl .GE. z(iq)) qNi=o.9DO*z(iq) 60 PN2=Z(IP)-PN1 qN2=z(iq)-qNi SMRN1=0.D0 SMRN2=0.D0 DEN1=PN1+QN1 DEN2=PN2+QN2 Appendix C. Description and listings of the computer programs 218 IF (IFLG(15) .EQ. 2) WRITE(6,560)A,B,C,DISC,Z(IP),Z(IQ), + PN1,QN1,PH2,QK2 560 FORMAT(/4X,'QUAD EQN FOR npl*. + 2X,'A=\E12.5,1X,'B=\E12.5,1X,'C=',E12.5,1X,'DISC=', + E12.5/4X, 'Z(IP)=' .F6.4.2X, >Z(iq)=' .F6.4/4X, •PN1=' , + F7.5.2X,,qKl=,,F7.5,2X,'PK2='.F7.5.2X,'QN2=',F7.5) IF (H .EQ. 2) GO TO 90 * The mole numbers of the remaining components (one at the time) * are obtained again from the equilibrium and mass balance equations * assuming only p and q are present XT(1)=PN1/DEN1 XT(2)=qNl/DENl XT(3)=l.D-6 XS(1)=PN2/DEN2 XS(2)=qN2/DEN2 XS(3)=l.D-6 IF (IFLG(15) .EQ. 2) WRITE(6,570) 570 F0RMAT(/4X,'i FUG COEFF OF i AT INF FUC COEFF OF i AT INF' + /4X,' DILUTION IN LiqUID 1 DILUTION IN LiqUID 2*) DO 90 1=1,N IF (I .Eq. IP .OR. i .Eq. iq) GO TO 90 TCT(3)=TC(I) PCT(3)=PC(I) WT(3)=W(I) PPT(3)=PP(I) APT(3)=APUR(I) BPT(3)=BPUR(I) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,3,2,3,APT,BPT>FUCLT,FUCD, + ZT,ZD,KIJ,KEq,IFLG) FUCR1=FUCLT(3) CALL K(XD,XS,TCT,PCT,WT,PPT,P,T,3,2,3,APT,BPT,FUCLT,FUCD, + ZT.ZD.KIJ.KEq.IFLG) FUCR2=FUCLT(3) IF (IFLG(15) .Eq. 2) WRITE(6,580) I.FUCRl.FUCR2 580 FORMAT(3X,12,' FUCR1='.F10.6,' FUCR2='.F10.6) A=FUCR1-FUCR2 B=FUCR2*(Z(I)-DEN1)-FUCRl*(Z(I)+DEN2) C=FUCR2*Z(I)*DEN1 IF (A .Eq. O.DO) THEN RN1(I)=-C/B GO TO 70 ELSE IF (C .Eq. O.DO) THEN RN1(I)=-B/A GO TO 70 ELSE DISC=B*B-4.D0*A*C IF (DISC .LT. O.DO) THEN WRITE(6,590) 590 FORMAT(/6X,'*** WARNING: NO REAL ROOTS FOUND WHEN TRYING' + /9X,'T0 SOLVE THE qUADRATIC EQUATION FOR nrl IN' + /9X,'SUBROUTINE INGASE') RN1(I)=Z(I)/2.D0 GO TO 80 ELSE IF (DISC .Eq. O.DO) THEN RN1(I)=-B/(2.D0*A) GO TO 70 END IF END IF TWA=2.D0*A RTDISC=DSqRT(DISC) RN1(I)=(-B+RTDISC)/TWA Appendix C. Description and listings of the computer programs IF (RNi(I) .GT. O.DO .AND. RN1(I) .LT. Z (D) GO TO 80 RN1(I)=(-B-RTDISC)/TWA IF (RNl(l) .GT. O.DO .AND. RN1(I) .LT. Z(I)) GO TO 80 70 IF (RN1(I) .LE. O.DO) RN1(I)=0.1D0*Z(I) IF (RN1(I) .GE. Z (D) RN1(I)=0.9D0*Z(I) 80 RN2(I)=Z(I)-RN1(I) SMRN1=SMRN1+RN1(I) SMRN2=SMRN2+RN2(I) IF (IFLG(15) .Eq. 2) WRITE(6,600)A,B,C,DISC,Z(I),RN1(I),RN2(I) 600 FORMAT(/4X,'CUAD EQN FOR nrl',2X,'A='.F10.6.1X,'B=',F10.6,1X, + 'C=',F11.7,1X,'DISC=',F10.6/4X,'Z(I)='.F6.4.2X,'RN1=', + F7.5,2X,'RN2=',F7.5) 90 CONTINUE * Calculation of the i n i t i a l composition estimates TOTN1=DEN1+SMRN1 T0TN2=DEN2+SMRN2 XI(1,IP)=PN1/T0TN1 XI(l,iq)=qNl/TOTNl XI(2,IP)=PN2/T0TN2 XI(2,iq)=QN2/T0TN2 IF (IFLG(15) .Eq. 2) WRITE(6,610) DEN1,DEN2,SMRN1.SMRN2, + T0TN1.T0TN2 610 FORMAT(/4X,'DEN1=',F8.4,IX,'DEN2=',F8.4 + /4X,'SMRN1='.F8.4.1X,'SMRN2=',F8.4 + /4X,*T0TN1=',F8.4,1X,'T0TN2=',F8.4) DO 100 1=1,N IF ( i .Eq. IP .OR. i .Eq. iq) GO TO 100 XI(1,I)=RN1(I)/T0TN1 XI(2,I)=RN2(I)/T0TN2 100 CONTINUE RETURN END Appendix C. Description and listings of the computer programs 220 ************************************************** * * * SUBROUTINE INLIQ (INITIALIZATION OF LIQ. COMPOSITIONS BY THE * * PROPOSED METHOD) * ********************************************************************** * * * Purpose: * * Initialize liquid compositions to be used in subroutine LIQSER. * * The proposed method selects the f i r s t phase initiator p as the * * component with the highest activity in the original system as in * * the Gautam & Seider method. This is the key comp. for phase 1. The * * second phase initiator Q (key comp. for phase 2) is that one with * * the largest pseudo-infinite dilution activity in pure comp. p * * obtained in the form proposed by Shah. * * * * Parameters: * * -Input * * Z,TC,PC,W.PP.P.T.N,APUR,BPUR,KIJ,IFLG,ALSL as in program PHASPLIT * * * * -Output * * IP.IQ.XI as in subroutine INSHAH * * * * Main variables: * * ACT,APT,BPT,FUCP1,FUCP2,FUCQ1,FUCQ2,FUCRl,FUCR2.PCT,PPT,PNI,PN2, * * qNl,qN2,RNl,RN2,T0TNl,T0TN2,WT,XS,XT as in subroutine INSHAH * * * * Remaining variables defined as in program PHASPLIT * * * * Subroutines called: * * K * * * * Called by: * * PHASPLIT * * * ********************************************************************** SUBROUTINE INLIQ(Z,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG, + ALSL,IP,IQ,XI) IMPLICIT REAL*8 (A-H.O-Z) REAL*8 KEq(2),KIJ(20,20) DIMENSION ALSL(20),APT(3),APUR(20),BPT(3),BPUR(20),FUCD(3), + FUCLT(3),IFLG(0:20),PC(20),PCT(3),PP(20),PPT(3), + RN1(18),RN2(18),TC(20),TCT(3),W(20),WT(3),XD(3), + XI(21,20),XS(3),XT(3),Z(20) IF (IFLG(15) .EQ. 2) WRITE(6,500) 500 F0RMAT(/4X,'SUBROUTINE INLIQ TRACING') IF (IFLG(15) .EQ. 2) WRITE(6,510) 510 FORMAT(/4X,'ACTIVITY OF COMP. I IN THE ORIGINAL MIXTURE' + /4X,'I',10X,'ACTIVITY') * Selection of phase initiator p as the component with the highest * activity in the original mixture HAL=ALSL(1) IP=1 DO 10 1=2,N IF (HAL .LT. ALSL(I)) THEN HAL=ALSL(I) IP=I END IF 10 CONTINUE IF (IFLG(15) .Eq. 2) WRITE(6,520) (I.ALSL(I), I=1,N) Appendix C. Description and listings of the computer programs 221 520 F0RMAT(3X,I2,9X,F10.6) * Selection of phase initiator q as the component with the largest * pseudo-infinite dilution activity in pure component p HAT=0.D0 TCT(1)=TC(IP) PCT(1)=PC(IP) WT(1)=W(IP) PPT(1)=PP(IP) APT(1)=APUR(IP) BPT(1)=BPUR(IP) XT(2)=l.D-6 XT(1)=1.D0-XT(2) IF (IFLG(15) .EQ. 2) WRITE(6,530) 530 F0RMAT(/4X,'i FUG COEFF OF PURE p FUC COEFF OF i AT' + /4X,' WITH TRACE OF COMP i INF DILUTION IN p') DO 20 1=1, N IF (I .Eq. IP) GO TO 20 TCT(2)=TC(I) PCT(2)=PC(I) WT(2)=W(I) PPT(2)=PP(I) APT(2)=APUR(I) BPT(2)=BPUR(I) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,2,2,3,APT,BPT,FUCLT,FUCD, + ZT,ZD,KIJ,KEq,IFLG) ACT=Z(I)*FUCLT(2)*P IF (IFLG(15) .Eq. 2) WRITE(6,540) I,FUCLT(1),FUCLT(2) 540 FORMAT(3X,12,8X,F10.6,15X,F10.6) IF (HAT .LE. ACT) THEN HAT=ACT IQ=I * Assignment of fugacity coefficients of 'pure' p in phase 1 and * of q at infinite-dilution in phase 1 FUCP1=FUCLT(1) FUCqi=FUCLT(2) END IF 20 CONTINUE IF (IFLG(15) .EQ. 2) WRITE(6,550) FUCP1.FUCQ1 550 FORMAT(4X,' FUCP1=',F10.6,' FUCQ1=*,F10.6) XT(l)=l.D-6 XT(2)=1.D0-XT(1) TCT(2)=TC(IQ) PCT(2)=PC(iq) WT(2)=W(iq) PPT(2)=PP(iq) APT(2)=APUR(iq) BPT(2)=BPUR(iq) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,2,2,3,APT,BPT,FUCLT,FUCD, + ZT,ZD,KIJ,KEq,IFLG) IF (IFLG(15) .EQ. 2) WRITE(6,560) 560 FORMAT(/4X,' FUG COEFF OF p AT FUC COEFF OF PURE q' + /4X,' INF DILUTION IN q WITH TRACE OF COMP p*) IF (IFLG(15) .Eq. 2) WRITE(6,570) FUCLT(l),FUCLT(2) 570 FORMAT(4X,' FUCP2='.F10.6,' FUCq2='.F10.6) * Assignment of fugacity coefficients of p at infinite-dilution in * phase 2 and of 'pure' q in phase 2 FUCP2=FUCLT(1) Appendix C. Description and listings of the computer programs 222 FUCq2=FUCLT(2) * Calculation of the mole numbers of p and q from the equilibrium * and mass balance equations assuming no other components are * present A0=FUCP1-FUCP2 BO=Z(IP)*(FUCP2-2.D0*FUCP1) C0=Z(IP)*FUCP2 D0=FUCQ2-FUCqi E0=2.D0*Z(IP)*FUCqi-Z(iq)*FUCQ2 F0=-z(iq)*FUcq2 A=A0*(D0*(B0-C0)-A0*(E0-F0)) B=B0*D0*(BO-CO)-AO*(EO*(C0+B0)-2.D0*C0*F0) C=C0*(C0*F0-B0*E0) IF (A .Eq. O.DO) THEN PN1=-C/B GO TO 30 ELSE IF (C .Eq. O.DO) THEN PN1=-B/A GO TO 30 ELSE DISC=B*B-4.D0*A*C IF (DISC .LT. O.DO) THEN WRITE(6,580) 580 FORMAT(/6X,'*** WARNING: NO REAL ROOTS FOUND WHEN TRYING' + /9X,'T0 SOLVE THE qUADRATIC EQUATION FOR npl IN' + /9X,'SUBROUTINE INLIQ') PN1=Z(IP)/2.D0 GO TO 40 ELSE IF (DISC .Eq. O.DO) THEN PN1=-B/(2.D0*A) GO TO 30 END IF END IF TWA=2.D0*A RTDISC=DSqRT(DISC) PN1=(-B+RTDISC)/TWA PNO=(-B-RTDISC)/TWA IF (PN1 .GT. O.DO .AND. PNi .LT. Z(IP)) THEN qNl=-PNl*(AO*PNl+BO)/(AO*PNl+CO) IF (qNl .GT. O.DO .AND. qNl .LT. Z(iq)) GO TO 60 ELSE IF (PNO .GT. O.DO .AND. PNO .LT. Z(IP)) THEN PN1=PN0 qNl=-PNl*(AO*PNl+BO)/(AO*PNl+CO) IF (qNl .GT. O.DO .AND. qNl .LT. Z(IQ)) THEN GO TO 60 ELSE GO TO 50 END IF END IF 30 IF (PNI .LE. O.DO) PN1=0.1D0*Z(IP) IF (PNI .GE. Z(IP)) PN1=0.9D0*Z(IP) 40 qNl=-PNl*(A0*PNl+B0)/(A0*PNl+C0) 50 IF (qNl .LE. O.DO) qNl=0.lDO*Z(iq) IF (qNl .GE. z(iq)) qNi=o.9DO*z(iq) 60 PN2=Z(IP)-PN1 qN2=z(iq)-qNi SMRN1=0.D0 SMRN2=0.D0 DENl=PNl+qNl DEN2=PN2+qN2 IF (IFLG(15) .Eq. 2) WRITE(6,590)A,B,C,DISC,Z(IP),Z(iq), Appendix C. Description and listings of the computer programs + PNl,qNl,PH2,qN2 590 FORMAT(/4X,'QUAD EQK FOR npl', + 2X,'A=',E12.5,1X,'B='.E12.5.1X,'C=*.E12.5.1X,'DISC=\ + E12.5/4X,'Z(IP)=',F6.4,2X,'Z(iq)='.F6.4/4X,'PH1=', + F7.5.2X,'qKl=',F7.5,2X,'PN2='.F7.5.2X,*qN2=*,F7.5) IF (N .Eq. 2) GO TO 90 * The mole numbers of the remaining components (one at the time) * are obtained again from the equilibrium and mass balance equations * assuming only p and q are present XT(1)=PN1/DEN1 XT(2)=qHl/DENl XT(3)=l.D-6 XS(1)=PN2/DEN2 XS(2)=qN2/DEK2 XS(3)=l.D-6 IF (IFLG(15) .EQ. 2)WRITE(6,600) 600 F0RMAT(/4X,'i FUG COEFF OF i AT INF FUC COEFF OF i AT INF' + /4X,' DILUTION IN LIQUID 1 DILUTION IN LIQUID 2*) DO 90 1=1,N IF (I .EQ. IP .OR. I .Eq. iq) GO TO 90 TCT(3)=TC(I) PCT(3)=PC(I) WT(3)=W(I) PPT(3)=PP(I) APT(3)=APUR(I) BPT(3)=BPUR(I) CALL K(XD,XT,TCT,PCT,WT,PPT,P,T,3,2,3,APT,BPT,FUCLT,FUCD, + ZT,ZD,KIJ,KEq,IFLG) FUCR1=FUCLT(3) CALL K(XD,XS,TCT,PCT,WT,PPT,P,T,3,2,3,APT,BPT,FUCLT,FUCD, + ZT,ZD,KIJ,KEQ,IFLG) FUCR2=FUCLT(3) IF (IFLG(15) .Eq. 2) WRITE(6,610) I,FUCR1,FUCR2 610 F0RMAT(3X,I2,' FUCR1=',F10.6,' FUCR2='.F10.6) A=FUCR1-FUCR2 B=FUCR2*(Z(I)-DEN1)-FUCR1*(Z(I)+DEN2) C=FUCR2*Z(I)*DEN1 IF (A .Eq. O.DO) THEN RN1(I)=-C/B GO TO 70 ELSE IF (C .Eq. O.DO) THEN RN1(I)=-B/A GO TO 70 ELSE DISC=B*B-4.D0*A*C IF (DISC .LT. O.DO) THEN WRITE(6,620) 620 F0RMAT(/6X,'*** WARNING: NO REAL ROOTS FOUND WHEN TRYING' + /9X,'T0 SOLVE THE QUADRATIC EQUATION FOR nrl IN* + /9X,'SUBROUTINE INLIQ') RN1(I)=Z(I)/2.D0 GO TO 80 ELSE IF (DISC .EQ. O.DO) THEN RN1(I)=-B/(2.D0*A) GO TO 70 END IF END IF TWA=2.D0*A RTDISC=DSqRT(DISC) RN1(I)=(-B+RTDISC)/TWA IF (RN1(I) .GT. O.DO .AND. RN1(I) .LT. Z(I)) GO TO 80 Appendix C. Description and listings of the computer programs 224 RN1(I)=(-B-RTDISC)/TWA IF (RN1(I) .GT. O.DO .AND. RN1(I) .LT. Z(I)) GO TO 80 70 IF (RN1(I) .LE. O.DO) RN1(I)=0.1D0*Z(I) IF (RN1(I) .GE. Z(I)) RN1(I)=0.9D0*Z(I) 80 RN2(I)=Z(I)-RN1(I) SMRN1=SMRN1+RN1(I) SMRN2=SMRN2+RN2(I) IF (IFLG(15) .EQ. 2) WRITE(6,630)A,B,C,DISC,Z(I),RN1(I),RN2(I) 630 FORMAT(/4X,'CUAD EON FOR nrl',2X,'A='.F10.6.1X,'B='.F10.6.1X, + 'C=',F11.7,1X,'DISC=*,F10.6/4X,'Z(I)=',F6.4,2X,'RNl=', + F7.5.2X,*RN2=',F7.5) 90 CONTINUE * Calculation of the i n i t i a l composition estimates TOTN1 =DEN 1 -t-SMRN 1 T0TN2=DEN2+SMRN2 XI(1,IP)=PN1/T0TN1 XI(l,iq)=QNl/TOTNl XI(2,IP)=PN2/T0TN2 XI(2,IQ)=qN2/T0TN2 IF (IFLG(15) .Eq. 2) WRITE(6,640) DEN1.DEN2.SMRN1.SMRN2.T0TN1, + T0TN2 640 F0RMAT(/4X,'DEN1=*.F8.4.1X,'DEN2=',F8.4 + /4X,'SMRN1=',F8.4,1X,'SMRN2=',F8.4 + /4X,'T0TN1=',F8.4,1X,'T0TN2=',F8.4) DO 100 1=1,N IF (I .EQ. IP .OR. I .Eq. iq) GO TO 100 XI(1,I)=RN1(I)/T0TN1 XI(2,I)=RN2(I)/T0TN2 100 CONTINUE RETURN END Appendix C. Description and listings of the computer programs ******************************************************* * * * SUBROUTINE VAPSER (VAPOUR PHASE SEARCH) * * * ********************************************************************* * * * Purpose: * * Search for an incipient vapour phase forming from the original * * system when i t is liquid-like. The method used is based on the * * stability analysis proposed by Michelsen as modified in this work * * * * Parameters: * * -Input * * EPS,ITMAX,IWEG,TIMAX,N,P,T,Z,YI,TC,PC,W.PP,APUR,BPUR,KIJ,IFLG as * * defined in program PHASPLIT * * HL Vector of the logarithm of the product of the feed comp. * * and the fug. coeff. for the original liquid-like mixture * * * * -Output: * * ITNUM Number of iterations required in the calculation * * OBJ Value of the objective function, defined as the sum of * * absolute value of the composition difference in two * * consecutive iterations * * FUCV Vector of fugacity coeffs. of the incipient vapour phase * * Y " " compositions " " " " " * * * * Main variables: * * BET Value of the gradient defined by Michelsen * * BY Vector of comp. vars. big Y (equivalent to mole numbers) * * BYN Vector of updated values of comp. vars. big Y * * BYO " " old " " " " " " * * EXHL " " values of the exponential of HL * * FBY " " the new values of big Y obtained by direct * * substitution * * GSTR Value of g*, which constitutes the stability criterion; * * i f g*>=0 the system is stable; i f g*<0 it ' s unstable * * GSTRO Value of GSTR in the previous iteration * * ITCRL Control variable for the application of Wegstein's method * * with a frequency determined by the variable IWEG * * JCF Control variable to check for convergence of the comp. * * vector to the feed comp. * * JCOB Control variable for the application of Wegstein's method * * in case the method causes the objective function to * * increase * * JDGST Control variable to check i f g*. when negative, is not * * changing significantly in consecutive iterations * * JRS Control variable to detect i f RSM is approaching 1 in * * consecutive iters. * * JIOB Control variable to check i f the objective function is * * increasing in consecutive iters. * * JSMBY Control variable to spot i f SMBYN, when less than 1, is * * decreasing in consecutive iters. * * OBJO Value of the objective function in the previous iteration * * RSM Gradient ratio r, defined by Michelsen, which is used to * * detect the approach to a t r i v i a l solution * * RSMO Value of RSM in the previous iteration * * SMBYN Sum of the values of BYN * * SMBYNO Value of SMBYN in the previous iteration * * SMSTAT Sum of the stationarity criterion for a l l components; * * approaches zero when a stationary point is reached * * STAT Value of the stationarity criterion for each component as * * defined by Michelsen * Appendix C. Description and listings of the computer programs 226 * TI Step size parameter in Wegstein's method. If TI=1, the * * method reduces to direct substitution * * * * Remaining variables defined as in program PHASPLIT * * Subroutines called: * * K * * * * Called by: * * PHASPLIT * * * *************************************************** SUBROUTINE VAPSER(EPS,ITMAX,IWEG,TIMAX,N,P,T,Z,YI,HL,TC,PC, + W.PP,APUR,BPUR,KIJ,ITNUM,OBJ.FUCV.Y,IFLG) IMPLICIT REAL*8 (A-H.O-Z) REAL*8 KEQ(20),KIJ(20,20) DIMENSION APUR(20),BPUR(20),BY(20),BYN(20),BY0(20),EXHL(20), + FBY(20),FUCD(20),FUCV(20),HL(20),IFLG(0:20),PC(20), + PP(20),TC(20),W(20),XD(20),Y(20),YI(20),Z(20) ITNUM=0 ITCRL=0 JCOB=0 * The i n i t i a l values of BY are set and parameter EXP(Hiliq) is * obtained DO 10 1=1,N BY0(I)=YI(I) EXHL(I)=DEXP(HL(I)) 10 CONTINUE IF (IFLG(15) .NE. 2) GO TO 20 WRITE(6,500) 500 F0RMAT(/4X,'INITIAL y COMPOSITIONS USING RAOULTS LAW') WRITE(6,510) (I,YI(I), 1=1,N) 510 F0RMAT(8X,'y(',12,')=',F8.5) * The fugacity coefficient for the vapour corresponding to the * i n i t i a l composition is evaluated 20 CALL K(XD,YI,TC,PC,W,PP,P,T,N,1,3,APUR,BPUR,FUCV,FUCD,Z1,ZD, + KIJ,KEQ,IFLG) * Calculation of a new value of BY using direct substitution SUM=0 DO 30 1=1, N BY(I)=EXHL(I)/FUCV(I) SUM=SUM+BY(I) 30 CONTINUE * Computation of the corresponding vapour composition (mole fraction) DO 40 1=1,N Y(I)=BY(I)/SUM 40 CONTINUE IF (IFLG(15) .NE. 2) GO TO 50 WRITE(6,520) 520 FORMAT(/4X,'y COMPOSITIONS WITH DIRECT SUBSTITUTION') WRITE(6,510) (I,Y(I), 1=1,N) * Evaluation of the fugacity coefficients corresponding to this * composition Appendix C. Description and listings of the computer programs 227 50 CALL K(XD,Y,TC,PC,W,PP,P,T,H,1,3,APUR,BPUR,FUCV,FUCD,Z1,ZD, + KIJ,KEQ,IFLG) * The value of F(BY) to be used in Wegstein's method is obtained DO 60 1=1,H FBY(I)=EXHL(I)/FUCV(I) 60 CONTINUE * Start of the iterative cycle 70 ITNUM=ITNUM+1 SMBYH=0.D0 IF (IFLG(15) .HE. 0) WRITE(6,530) ITHUM 530 F0RMAT(/4X,'*** ITERATION N0.= ',12/) * Wegstein's method is used to obtain updated BY values IF (ITHUM .LT. 4 .OR. ITNUM .LT. ITCRL+IWEG .OR. + IWEG .EQ. 0) THEN TI=1.D0 ELSE IF (IFLG(15) .NE. 0) WRITE (6,540) 540 FORMAT(4X,'WEGSTEIN METHOD USED') TI=0.D0 END IF DO 100 1=1,N IF (TI .Eq. 1.D0) GO TO 90 SI=(FBY(I)-BY(I))/(BY(I)-BYO(I)) TI=1.D0/(1.DO-SI) * Limitation of the value of parameter TI to avoid overshooting IF (TI .GT. TIMAX) TI=TIMAX IF (TI .LT. -TIMAX) TI=-TIMAX IF (IFLG(15) .NE. 2) GO TO 80 IF (TI .Eq. TIMAX) THEN WRITE(6,550) I 550 FORMAT(6X,'TI EqUALS TIMAX FOR COMPONENT ',12) ELSE IF (TI .Eq. -TIMAX) THEN WRITE(6,560) I 560 FORMAT(6X,'TI EqUALS -TIMAX FOR COMPONENT ',12) END IF 80 ITCRL=ITNUM 90 BYN(I)=(1.DO-TI)*BY(I)+TI*FBY(I) IF (BYN(I) .LT. O.DO) BYN(I)=l.D-6 SMBYN=SMBYN+BYN(I) 100 CONTINUE * The new vapour composition is calculated DO 120 1=1,N Y(I)=BYN(I)/SMBYN 120 CONTINUE IF (IFLG(15) .NE. 2) GO TO 130 WRITE(6,570) 570 F0RMAT(4X,'I',5X,'y',9X,'BYO',9X,'BY',9X,'FBY',9X,'BYN') WRITE(6,580) (I,Y(I),BY0(I),BY(I),FBY(I),BYN(I), 1=1,N) 580 F0RMAT(3X,I2,2X,F8.5,3X,F8.5,4X,F8.5,4X,F8.5,4X,F8.5) Appendix C. Description and listings of the computer programs 228 * Evaluation of the corresponding fugacity coefficients 130 CALL K(XD,Y,TC,PC,V,PP,P,T,N,1,3,APUR,BPUR,FUCV,FUCD,Z1,ZD, + KIJ,KEQ,IFLG) * Calculation of the objective function and of parameter r SUM=0.D0 BET=0.D0 0BJ=0.D0 SMSTAT=0.D0 DO 140 1=1,N 0BJ=0BJ+DABS(BYH(I)-BY(I)) STAT=DL0G(BYH(I)+FUCV(I))-HL(I) SMSTAT=SMSTAT+STAT SUM=SUM+BYN(I)*(STAT-1.DO) BET=BET+(BYN(I)-Z(I))*STAT 140 COHTIHUE GSTR=1.D0+SUM IF (DABS(BET) .LT. l.D-10) THEN IF (BET .GE. O.DO) BET=1.D-10 IF (BET .LT. O.DO) BET=-1.D-10 END IF RSM=2*GSTR/BET * Check for the convergence of the composition vector to the feed * composition SUM=0.D0 DO 145 1=1,N SUM=SUM+DABS(Y(I)-Z(I)) 145 CONTINUE IF (SUM .LT. N*2.D-4) THEN JCF=1 ELSE JCF=0 END IF * Check for the value of r approaching 1 in consecutive iterations IF (DABS(RSM-l.DO) .LT. DABS(RSM0-1.DO) .AND. ITNUM .GT. + 1) THEN JRS=JRS+1 ELSE JRS=0 END IF * Check i f SMBYN when less than 1 is decreasing in consecutive * iterations IF (SMBYN .LT. 1.D0 .AND. SMBYN .LT. SMBYNO .AND. ITNUM + .GT. 1) THEN JSMBY=JSMBY+1 ELSE JSMBY=0 END IF * Check for the objective function increasing in consecutive * iterations IF (OBJ .GT. OBJO .AND. ITNUM .GT. 1) THEN JI0B=JI0B+1 Appendix C. Description and listings of the computer programs 229 ELSE JIOB=0 END IF * Check i f g*, when negative, is not changing significantly in * consecutive iterations IF (GSTR .LT. O.DO .AND. DABS(GSTR-GSTRO) .LT. l.D-6 .AND. + ITNUM .GT. 1) THEN JDGST=JDGST+1 ELSE JDGST=0 END IF * Check for the objective function increasing after using Wegstein's * method. If so, the method is used only every JCOB+IWEG iterations * un t i l the objective function decreases again after applying the * acceleration method IF (TI .HE. 1.D0 .AND. OBJ .GT. OBJO) THEN JC0B=JC0B+1 ITCRL=ITNUM+JCOB*IWEG ELSE IF (TI .NE. 1.D0) THEN JC0B=0 ITCRL=ITNUM END IF IF (IFLG(15) .NE. 0) WRITE(6,590) OBJ,SMBYN,GSTR,SMSTAT,BET,RSM 590 FORMAT(/4X,'OBJ. FUNCN.='.F9.6.2X,'SUM Y='.F9.6.2X,'g*=',F9.6 + /4X,'SUM STAT CR='.F9.6.2X,'beta=',G12.5,2X,'r=',G12.5) * Test for convergence either to a minimum in Gibbs energy or to * the t r i v i a l solution IF (OBJ .LE. EPS .AND. ITNUM .GT. 1) GO TO 160 IF (JDGST .EQ. 3) GO TO 170 IF (DABS(RSM-l.DO) .LT. 0.2D0 .AND. GSTR .LT. l.D-3 .OR. JRS + .Eq. 2 .OR. JIOB .EQ. 2 .OR. JSMBY .Eq. 2 .OR. JFC .Eq. 1) + GO TO 180 * Assignment of the variables for the next iterative loop DO 150 1=1,N BY0(I)=BY(I) BY(I)=BYN(I) FBY(I)=EXHL(I)/FUCV(I) 150 CONTINUE RSM0=RSM OBJ0=OBJ SMBYNO=SMBYN * If the maximum number of iterations is reached, the calculation * ends IF (ITNUM .LT. ITMAX) THEN GO TO 70 ELSE GO TO 190 END IF * Convergence has been reached. Check to see i f the stationary point * corresponds to an unstable system or to a stable one 160 IF (SMBYN .GT. 1.D0) THEN Appendix C. Description and listings of the computer programs 230 IFLG(5)=1 IF (IFLG(15) .NE. 0) WRITE(6, 600) 600 F0RMAT(/4X,'CONV. REACHED. UNSTABLE SYSTEM. VAPOUR FOUND') ELSE IFLG(5)=0 IF (IFLG(15) .NE. 0) WRITE(6, 610) 610 FORMAT(/4X,'CONV. REACHED. STABLE SYSTEM. NO VAPOUR FOUND') END IF GO TO 200 * Convergence not reached but a stationary minimum has been found 170 IFLG(5)=1 IF (IFLG(15) .NE. 0) WRITE(6, 620) 620 FORMAT(/4X,'CONV. NOT REACHED. UNSTABLE SYSTEM. VAPOUR FOUND') GO TO 200 * A t r i v i a l solution is found 180 IFLG(5)=0 IF (IFLG(IS) .NE. 0) WRITE(6, 630) 630 FORMAT(/4X,'TRIVIAL SOLUTION FOUND') GO TO 200 * Maximum number of iterations reached 190 IF (SMBYN .GT. 1.D0) THEN IFLG(5)=1 IF (IFLG(15) .NE. 0) WRITE(6,620) ELSE IFLG(5)=0 IF (IFLG(15) .NE. 0) WRITE(6,640) 640 FORMAT(/4X,'CONV. NOT REACHED. STABLE SYSTEM. VAPOUR NOT FOUND + ') END IF 200 RETURN END Appendix C. Description and listings of the computer programs ***************************************************** * SUBROUTINE LIQSER (LIQUID PHASE SEARCH) * * * ********************************************************************* * * * Purpose: * * Search for two or one incipient liquid phase(s) forming from the * * original system, whether i t ' s vapour-like or liquid-like. The * * method used is based on the modified Michelsen's stability * * analysis * * * * Parameters: * * -Input * * EPS,ITMAX.IWEG,TIMAX,N.P.T.Z,XI,TC,PC,W,PP,APUR,BPUR,KIJ,IFLG as * * defined in program PHASPLIT * * M Number of i n i t i a l liquid composition vectors. M=N+1 when * * subroutine INMICH is used, and M=3 for any of the other * * i n i t i a l i z i n g routines * * HL Vector of the logarithm of the product of the feed comp. * * and the fug. coeff. for the original system as a liquid * * i f i t is liquid-like or as a vapour i f i t is vapour-like * * * * -Output * * ITNUM Number of iterations required for the calculation * * OBJL Two element vector with the value of the objective func. * * for liqs 1 and 2. Defined as the sum of the absolute * * value of the comp. difference (for each liq) in two * * consecutive iterations * * FUCL1 Vector of fug. coeffs. for the incipient l i q . phase 1 * * FUCL2 " " " " " " 2 * * XI " " compositions " " " " 1 * * 11 " 11 *' *' '* *' 11 2 * * * * Main variables: * * BET Value of the gradient defined by Michelsen * * BX M x N array of values of the composition variables big * * X (equivalent to mole numbers) in the current iteration * * BXN Array of updated values of comp. variables BX * * BXO " " old " " " " " * * DGRT Value of the Gibbs energy of mixing for the comp. vector * * when more than two different l i q . phases are found * * EXHL Vector of values of the exponential of HL * * FBX Array (M x N) of the new values of big X obtained by * * direct substitution * * FUCLJC Array of values of FUCL for the comp. vectors for which * * a l i q . t r i a l phase has been found * * FUCLQ Vector of fug. coeffs. for each l i q . being searched * * FUCLqS M x N array of fug. coeffs. for the M l i q . comp. vectors * * GSTR Vector (M dim.) with the values of g*, the stability * * criterion. If g*>=0 for a given comp. vector, the system * * is stable; otherwise i t ' s unstable * * GSTRJC Vector of values of GSTR for the comp. vectors for which * * a l i q . t r i a l phase has been found * * GSTRO Value of GSTR in the previous iteration * * ITCRL Vector of control variables for the application of * * Wegstein's method with a frequency determined by the * * variable IWEG * * JC Control variable for the index and number of comp. * * vectors for which a l i q . t r i a l phase has been found * * JCF Vector (M dim.) of control variables to check for * * convergence of any comp. vector the feed comp. * Appendix C. Description and listings of the computer programs 232 * JCOB Vector of control variables for the application of * * Wegstein's method in case the method causes the obj . * * func. to increase * * JDGST Vector (M dim.) of control variables to check i f g* for * * a given comp. vector, when negative, is not changing * * significantly in consecutive iters. * * JE Control variable for the index and number of comp. * * vectors that have been eliminated from the search * * JFLG Flag control variables to register the status of the * * comp. vectors. If JFLG=0, the vector remains in the * * search; i f JFLG=i, a l i q . t r i a l phase is found; i f * * JFLG#0 the vector is eliminated * * JGSTR Control variable to account for the comp. vectors for * * which g* is greater than zero * * JGRS Control variable which indicates the comp. vector index * * with the largest value of /r-1/ when a l l g* values are * * greater than zero * * JIOB Vector (M dim.) of control variables to check i f the * * objective function for any comp. vector is increasing * * in consecutive iterations * * JR Control variable for the index and number of comp. * * vectors for which different (distinct) l i q . phases have * * been found * * JRS Vector (M dim.) of control variables to detect i f the * * value of r for a given comp. vector is approaching one * * in consecutive iters. * * JSMBX H dim. vector of control variables to check i f SMBXH, * * when less than 1, is decreasing in consec. iterations * * LJFLG Array of control flags to identify the comp. vectors * * which have converged to the same liquid phase * * M Number of liquid com. vectors for ...which a l i q . phase is * * being searched * * OBJJC Vector of values of the obj. function of the comp. * * vectors for which a l i q . t r i a l phase has been found * * OBJO Vector of values of OBJ in the previous iteration * * RSM Vector of the gradient ratio r defined by Michelsen; * * used to detect the approach to the t r i v i a l solution * * RSMO Values i f RSM in the previous iteration * * SMBXN M dim. vector of the sum of the values of BXN for each * * l i q . searched * * SMBXNO Vector of values of SMBXN in the previous iteration * * SMSTAT Sum of the stationarity criterion for a l l comps. of a * * given comp. vector. Approaches zero when a stationary * * point is reached * * STAT Value of the stationarity criterion for each comp. as * * defined by Michelsen * * TI M dim. vector of the step size parameter in Wegstein's * * method. If TI=1, the method reduces to direct substn. * * X M x N array of corns, vectors of the l i q . phases being * * searched (mole fraction) * * XJC Array of values of X for the comp. vectors for which a * * l i q . phase has been found * * XJR Array of values of X for the comp. vectors for which * * different (distinct) l i q . phases have been found * * XL Vector of comps. for each l i q . phase being searched * * * * Remaining variables defined as in program PHASPLIT * * * * Subroutines called: * * K * * * * Called by: * * PHASPLIT * Appendix C. Description and listings of the computer programs 233 * * ************************************************* SUBROUTINE LIQSER(EPS,ITMAX,IWEG,TIMAX,M,H,P,T,Z,XI,HL,TC, + PC,W,PP,APUR,BPUR,KIJ,ITNUM,OBJL,FUCLl, + FUCL2,X1,X2,IFLG) IMPLICIT REAL+8 (A-H.O-Z) REAL*8 KEQ(20),KIJ(20,20) DIMENSION APUR(20),BPUR(20),BX(21,20),BXN(21,20),BX0(21,20), + DGRT(3),EXHL(20),FBX(21,20),FUCD(20),FUCL1(20), + FUCL2(20),FUCLJC(21,20),FUCLQ(20),FUCLqS(21,20), + GSTR(21),GSTR0(21),GSTRJC(21),HL(20),IFLG(0:20), + ITCRL(21),JCF(20),JC0B(21),JDGST(21),JFLG(21), + JI0B(21),JRS(21),JSMBX(21),LJFLG(21,21),0BJ(21), + 0BJJC(21),0BJL(2),0BJ0(21),PC(20),PP(20),RSM(21), + RSM0(21),SMBXN(21),SMBXN0(21),SUMJ(21),TC(20),TI(21), + W(20),X(21,20),Xi(20),X2(20),XD(20),XI(21,20), + XJC(21,20),XJR(21,20),XL(20),Z(20) ITNUM=0 JE=0 JC=0 * The i n i t i a l values of BX are set, parameter EXP(Hiliq) or * EXP(Hivap) is obtained and the fugacity coefficients for the * liquids corresponding to the i n i t i a l compositions are evaluated DO 30 J=1,M ITCRL(J)=0 JCOB(J)=0 SUMJ(J)=0.D0 DO 10 1=1,H BXO(J,I)=XI(J,I) XL(I)=XI(J,I) IF (J .NE. 1) GO TO 10 EXHL(I)=DEXP(HL(I)) 10 CONTINUE CALL K(XD,XL,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUCLq,FUCD, + Z2,ZD,KIJ,KEq,IFLG) DO 20 1=1,N FUCLqS(J,I)=FUCLq(I) 20 CONTINUE 30 CONTINUE IF (IFLG(15) .NE. 2) GO TO 40 WRITE(6,700) 700 FORMAT(/4X,'INITIAL x COMPOSITIONS') WRITE(6,710) ((J,I,XI(J,I), 1=1,N), J=1,M) 710 FORMAT(8X,'x(',12,12,')=',F8.5) * Calculation of the new values of BX using direct substitution 40 DO 60 J=1,M DO 50 1=1,N BX(J,I)=EXHL(I)/FUCLqS(J,I) SUMJ(J)=SUMJ(J)+BX(J,I) 50 CONTINUE 60 CONTINUE * The corresponding liquid composition (mole fraction) are obtained DO 80 J=1,M DO 70 1=1,N X(J,I)=BX(J,I)/SUMJ(J) 70 CONTINUE Appendix C. Description and listings of the computer programs 234 80 CONTINUE IF (IFLG(15) .NE. 2) GO TO 90 WRITE(6,720) 720 F0RMAT(/4X,'x COMPOSITIONS WITH DIRECT SUBSTITUTION') WRITE(6,710) ((J,I,X(J,I), 1=1,1), J=1,M) * Calculation of the fugacity coefficients corresponding to these * compositions 90 DO 120 J=1,M DO 100 1=1,1 XL(I)=X(J,I) -100 CONTINUE CALL K(XD,XL,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUCLQ,FUCD, + Z2,ZD,KIJ,KEq,IFLG) DO 110 1=1,N FUCLQS(J,I)=FUCLq(I) 110 CONTINUE 120 CONTINUE * The values of F(BX) to be used in Wegstein's method are calculated DO 140 J=1,M DO 130 1=1,1 FBX(J,I)=EXHL(I)/FUCLQS(J,I) 130 CONTINUE 140 CONTINUE * Start of the iterative cycle 150 ITNUM=ITNUM+1 DO 160 J=1,M SMBXN(J)=0.D0 160 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,730) ITNUM 730 F0RMAT(/4X,'*** ITERATION N0.=',I2) * Use of Wegstein's method to obtain updated BX values DO 200 J=1,M IF (ITNUM .LT. 4 .OR. ITNUM .LT. ITCRL(J)+IWEG + .OR. IWEG .Eq. 0) THEN TI(J)=1.D0 ELSE IF (IFLG(15) .NE. 0) WRITE(6,740) J 740 F0RMAT(4X,'WEGSTEINS METHOD USED FOR VECTOR',13) TI(J)=0.D0 END IF DO 190 1=1,N IF (TI(J) .Eq. 1.D0) GO TO 180 SI=(FBX(J,I)-BX(J,I))/(BX(J,I)-BXO(J,I)) TI(J)=1.D0/(1.DO-SI) * The value of parameter t is limited to avoid overshooting IF (TI(J) .GT. TIMAX) TI(J)=TIMAX IF (TI(J) .LT. -TIMAX) TI(J)=-TIMAX IF (IFLG(15) .NE. 2) GO TO 170 IF (TI(J) .Eq. TIMAX) THEN WRITE(6,750) I.J 750 F0RMAT(6X,'TI = TIMAX FOR COMP. ',12,' IN VECTOR ',12) ELSE IF (TI(J) .Eq. -TIMAX) THEN Appendix C. Description and listings of the computer programs 235 WRITE(6,760) I,J 760 FORMAT(6X,'TI = -TIMAX FOR COMP. ',12,' IK VECTOR *,I2) END IF 170 ITCRL(J)=ITKUM 180 BXN(J,I)=(1.D0-TI(J))*BX(J,I)+TI(J)*FBX(J,I) IF (BXH(J.I) .LT. O.DO) BXH(J,I)=l.D-6 SMBXK(J)=SMBXN(J)+BXN(J,I) 190 CONTINUE 200 CONTINUE * The new liquid compositions are obtained DO 220 J=1,M DO 210 1=1,N X(J,I)=BXN(J,I)/SMBXN(J) 210 CONTINUE 220 CONTINUE IF (IFLG(15) .NE. 2) GO TO 240 DO 230 J=1,M WRITE(6,770) J 770 F0RMAT(/4X,*J=',I2,5X,'I',6X,'x',9X,'BXO',9X,'BX',9X,'FBX', + 9X,'BXN') WRITE(6,780) (I,X(J,I),BX0(J,I),BX(J,I),FBX(J,I),BXN(J,I), + 1=1,N) 780 F0RMAT(12X,I2,2X,F8.6,3X,F8.5,4X,F8.5,4X,F8.5,4X,F8.5) 230 CONTINUE * Calculation of the corresponding fugacity coefficients 240 DO 270 J=1,M DO 250 I=1,N XL(I)=X(J,I) 250 CONTINUE CALL K(XD,XL,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUCLq,FUCD, + Z2,ZD,KIJ,KEQ,IFLG) DO 260 1=1,N FUCLQS(J,I)=FUCLQ(I) 260 CONTINUE 270 CONTINUE * Evaluation of the objective functions and parameters r JGSTR=0 DO 290 J=1,M SUM=0.D0 BET=0.D0 0BJ(J)=0.D0 SMSTAT=0.D0 DO 280 1=1,N OBJ(J)=OBJ(J)+DABS(BXN(J,I)-BX(J,I)) STAT=DL0G(BXN(J,I)*FUCLQS(J,I))-HL(I) SMSTAT=SMSTAT+STAT SUM=SUM+BXN(J,I)*(STAT-1.DO) BET=BET+(BXN(J,I)-Z(I))*STAT 280 CONTINUE GSTR(J)=1.D0+SUM IF (DABS(BET) .LE. l.D-10) THEN IF (BET .GE. 0) BET=1.D-10 IF (BET .LT. 0) BET=-1.D-10 END IF RSM(J)=2*GSTR(J)/BET IF (GSTR(J) .GT. O.DO) JGSTR=JGSTR+1 Appendix C. Description and listings of the computer programs 236 * Check for the convergence of any composition vector to the * feed composition SUM=O.DO DO 285 1=1,1 SUM=SUM+DABS(X(J,I)-Z(I)) 285 CONTINUE IF (SUM .LT. N*2.D-4) THEN JCF(J)=1 ELSE JCF(J)=0 END IF * Check i f the values of r are approaching 1 in consecutive * iterations IF (DABS(RSM(J)-l.DO) .LT. DABS(RSM0(J)-1.DO) .AND. ITNUM + .GT. 1) THEN JRS(J)=JRS(J)+1 ELSE JRS(J)=0 END IF * Check i f the values of SMBXN when less than 1 are decreasing in * consecutive iterations IF (SMBXN(J) .LT. 1.D0 .AND. SMBXN(J) .LT. SMBXNO(J) .AND. + ITNUM .GT. 1) THEN JSMBX(J)=JSMBX(J)+1 ELSE JSMBX(J)=0 END IF * Check for the objective function increasing in consecutive * iterations IF (OBJ(J) .GT. OBJO(J) .AND. ITNUM .GT. 1) THEN JI0B(J)=JI0B(J)+1 ELSE JIOB(J)=0 END IF * Check i f the values of g* when negative are not changing * significantly consecutive iterations IF (GSTR(J) .LT. O.DO .AND. DABS(GSTR(J)-GSTRO(J)) .LT. + l.D-6 .AND. ITNUM .GT. 1) THEN JDGST(J)=JDGST(J)+1 ELSE JDGST(J)=0 END IF * Check for the objective function increasing after using Wegstein's * method. If so, the method is used only every JCOB(J)*IWEG iterations * u n t i l the objective function decreases again after using the * acceleration method IF (TI(J) .NE. 1.D0 .AND. OBJ(J) .GT. OBJO(J)) THEN JC0B(J)=JC0B(J)+1 ITCRL(J)=ITNUM+JCOB(J)*IWEG ELSE IF (TI(J) .NE. 1.D0) THEN JC0B(J)=0 Appendix C. Description and listings of the computer programs 237 ITCRL(J)=ITNUM END IF IF (IFLG(15) .NE. 0) WRITE(6,790) J,0BJ(J),SMBXN(J),GSTR(J), + SMSTAT,BET,RSM(J) 790 FORMAT(/4X,'J=',12, + 4X,'0BJ. FUNCN.='.F9.6.2X,'SUM X='.F9.6.2X,'g*=',F9.6/ + 12X,'SUM STAT CR='.G13.6.2X,'beta=',G13.6,2X,'r=',G13.6) 290 CONTINUE * If a l l values of g* are greater than zero, the composition vector * with the largest value of /r-1/ is identified IF (JGSTR .EQ. M) THEN GRSM=DABS(RSM(1)-1.DO) JGRS=1 DO 300 J=2,M IF (DABS(RSM(J)-l.DO) .GT. GRSM) THEN GRSM=DABS(RSM(J)-1.DO) JGRS=J END IF 300 CONTINUE END IF * Test for convergence either to a minimum in Gibbs energy or to * the t r i v i a l solution DO 320 J=1,M IF (JDGST(J) .Eq. 3) THEN IF (SMBXN(J) .GE. 1.D0) JFLG(J)=1 IF (SMBXN(J) .LT. 1.D0) JFLG(J)=2 ELSE IF (OBJ(J) .LE. EPS .AND. ITNUM .GT. 1) THEN IF (SMBXN(J) .GE. 1.D0) JFLG(J)=1 - IF (SMBXN(J) .LT. 1.D0) JFLG(J)=2 ELSE IF (DABS(RSM(J)-l.DO) .LT. 0.2D0 .AND. GSTR(J) .LT. + l.D-3) THEN JFLG(J)=3 ELSE IF (GSTR(J) .GT. O.DO .AND. ITNUM .GE. 4 .OR. JRS(J) + .Eq. 2 .OR. JIOB(J) .Eq. 2 .OR. JSMBX(J) .Eq. 2 + .OR. JCF(J) .Eq. 1) THEN JFLG(J)=4 ELSE IF (JGSTR .Eq. M .AND. J .NE. JGRS) THEN JFLG(J)=5 ELSE JFLG(J)=0 END IF * If a liquid t r i a l phase is found, i t ' s composition and fugacity * coefficients are saved IF (JFLG(J) .Eq. 1) THEN JC=JC+1 GSTRJC(JC)=GSTR(J) 0BJJC(JC)=0BJ(J) DO 310 1=1,N XJC(JC,I)=X(J,I) FUCLJC(JC,I)=FUCLqS(J,I) 310 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,800) JC.J 800 FORMAT(/4X,12,' LiqUID TRIAL PHASE(S) FOUND* + /4X,'CORRESPONDING COMP. VECTOR #=*,12) END IF 320 CONTINUE Appendix C. Description and listings of the computer programs 238 * Test for the convergence of any composition vector(s) to a common * vector. The vector with the largest objective function of the two * common vectors being compared is selected for elimination DO 350 L=1,M DO 340 J=L+1,M SUM=0.D0 DO 330 1=1,H SUM=SUM+DABS(X(L,I)-X(J,I)) 330 CONTINUE IF (SUM .LE. N+2.D-2) THEN IF (OBJ(J) .GT. OBJ(L)) THEN JFLG(J)=6 ELSE JFLG(L)=6 END IF END IF 340 CONTINUE 350 CONTINUE * Elimination of the composition vector(s) that have converged, * that are not likely to converge or that have converged to a * common vector. Assignment of the variables for the next iteration DO 370 J=1,M IF (JFLG(J) .NE. 0) THEN JE=JE+1 IF (IFLG(15) .NE. 0) WRITE(6,810) JE,ITNUM,J,JFLG(J) 810 F0RMAT(/4X,I2,' COMP.VECTOR(S) ELIMINATED IN ITNUM=',I2 + /4X,'COMP. VECTOR ELIMINATED #= »,12,2X,'JFLG= ',12) GO TO 370 END IF DO 360 1=1,N BXO(J-JE,I)=BX(J,I) BX(J-JE,I)=BXN(J,I) FBX(J-JE,I)=EXHL(I)/FUCLqS(J,I) 360 CONTINUE RSMO(J-JE)=RSM(J) 0BJ0(J-JE)=0BJ(J) GSTR0(J-JE)=GSTR(J) SMBXNO(J-JE)=SMBXN(J) JRS(J-JE)=JRS(J) JI0B(J-JE)=JI0B(J) JSMBX(J-JE)=JSMBX(J) JC0B(J-JE)=JC0B(J) ITCRL(J-JE)=ITCRL(J) TI(J-JE)=TI(J) JDGST(J-JE)=JDGST(J) 370 CONTINUE M=M-JE JE=0 * The calculation terminates i f a l l the composition vectors have * been eliminated IF (M .EQ. 0) GO TO 380 * If the maximum number of iterations is reached, terminate the * calculation IF (ITNUM .LT. ITMAX) GO TO 130 IF (IFLG(15) .NE. 0) WRITE(6,820) Appendix C. Description and listings of the computer programs 239 820 FORMAT(/4X,'MAX. NO. OF ITERATIONS REACHED') * Convergence has been obtained 380 IF (JC .EQ. 0) THEN * No liquid t r i a l phase(s) found (liquids 1 and 2 do not correspond * to a solution, but the variables of current composition vectors * 1 and 2 are assigned to them) IF (IFLG(15) .NE. 0) WRITE(6,830) 830 FORMAT(/4X,'STABLE SYSTEM. NO LIQUID PHASE(S) FOUND') DO 390 1=1,N X1(I)=X(1,I) X2(I)=X(2,I) FUCLl(I)=FUCLqS(l,I) FUCL2(I)=FUCLQS(2,1) 390 CONTINUE 0BJL(1)=0BJ(1) 0BJL(2)=0BJ(2) IFLG(6)=0 GO TO 590 END IF IF (IFLG(15) .NE. 0) WRITE(6,840) JC 840 FORMAT(/4X,'UNSTABLE SYSTEM. ',12,' LIQUID PHASE(S) FOUND') IF (IFLG(15) .Eq. 2) WRITE(6,710)((J,I,XJC(J,I), 1=1,N), J=1,JC) IF (JC .Eq. 1) THEN * One liquid t r i a l phase found, designated as liquid 1. Compositions * and fugacity coefficients are assigned (liquid 2 does not correspond * to a solution, but the variables of current vector 1 are assigned * to i t ) 400 DO 410 1=1,1 X1(I)=XJC(1,I) X2(I)=X(1,I) FUCL1(I)=FUCLJC(1,I) FUCL2(I)=FUCLqS(1,1) 410 CONTINUE 0BJL(1)=0BJJC(1) 0BJL(2)=0BJ(1) IFLG(6)=1 GO TO 590 END IF * At least two liquid phases found. Test for the convergence of any * composition vector(s) to a common vector JR=JC DO 440 L=1,JC DO 430 J=L+1,JC SUM=0.D0 DO 420 1=1,1 SUM=SUM+DABS(XJC(L,I)-XJC(J,I)) 420 CONTINUE IF (SUM .LE. N*2.D-2) THEN JR=JR-1 LJFLG(L,J)=1 ELSE LJFLG(L,J)=0 END IF 430 CONTINUE 440 CONTINUE Appendix C. Description and listings of the computer programs IF (IFLG(15) .NE. 0) WRITE(6,850) JR 850 FORMAT(/4X,'NUMBER OF DIFFERENT LIQUID PHASES=',I2) IF (JR .EQ. JC) GO TO 520 * Composition vectors have converged to a common vector. A l l common * vectors but one are eliminated LJR=0 DO 450 1=1,1 XJR(1,I)=XJC(1,I) 450 CONTINUE DO 480 L=1,JR DO 470 J=L+1,JC IF (LJFLG(L.J) .EQ. 1) LJR=LJR+1 IF (J+LJR .GT. N) GO TO 490 DO 460 1=1,N XJR(J,I)=XJC(J+LJR,I) 460 CONTINUE 470 CONTINUE 480 CONTINUE * Assignment of the composition for the different liquid phase(s) 490 DO 510 J=1,JR DO 500 1=1,N XJC(J,I)=XJR(J,I) 500 CONTINUE 510 CONTINUE * If only one liquid phase is found, the corresponding variables are * assigned IF (JR .EQ. 1) GO TO 400 * Two or more liquid phases found 520 IFLG(6)=2 IF (JR .EQ. 2) THEN * When two liquid t r i a l phases have been found, the compositions and * fugacity coefficients are assigned DO 530 1=1,N X1(I)=XJC(1,I) X2(I)=XJC(2,I) FUCL1(I)=FUCLJC(1,1) FUCL2(I)=FUCLJC(2,I) 530 CONTINUE 0BJL(1)=0BJJC(1) 0BJL(2)=0BJJC(2) GO TO 590 ELSE * If more than two different liquid phases have been found (with a * maximum of 3), the two with the least dimensionless Gibbs energy * of mixing (DEL g/RT) are selected as the t r i a l phases and the * corresponding variables are assigned DO 550 J=l,3 DGRT(J)=0.D0 DO 540 1=1,N Appendix C. Description and listings of the computer programs 241 DGRT(J)=DGRT(J)+XJC(J,I)*DLOG(XJC(J,I)*FUCLJC(J,I)) 540 CONTINUE 550 CONTINUE IF (DGRT(3) .GT. DGRT(l) .AND. DGRT(3) .GT. DGRT(2)) THEN DO 560 1=1,N X1(I)=XJC(1,I) X2(I)=XJC(2,I) FUCL1(I)=FUCLJC(1,I) FUCL2(I)=FUCLJC(2,I) 560 CONTINUE 0BJL(1)=0BJJC(1) 0BJL(2)=0BJJC(2) ELSE IF (DGRT(2) .GT. DGRT(l) .AND. DGRT(2) .GT. DGRT(3)) THEN DO 570 1=1,N X1(I)=XJC(1,I) X2(I)=XJC(3,I) FUCL1(I)=FUCLJC(1,I) FUCL2(I)=FUCLJC(3,I) 570 CONTINUE 0BJL(1)=0BJJC(1) 0BJL(2)=0BJJC(3) ELSE DO 580 1=1, N X1(I)=XJC(2,I) X2(I)=XJC(3,I) FUCL1(1)=FUCLJC(2,1) FUCL2(I)=FUCLJC(3,I) 580 CONTINUE 0BJL(1)=0BJJC(2) 0BJL(2)=0BJJC(3) END IF IF (IFLG(15) .NE. 0) WRITE(6,860) 860 FORMAT(/4X,'VECTORS WITH LEAST GIBBS ENERGY OF MIXING') END IF 590 RETURN END Appendix C. Description and listings of the computer programs 242 ***************************************************** * * * SUBROUTINE PHASER (PHASE SEARCH) * * * ********************************************************************* * * * Purpose: * * Calculate the value of Hp to be used in the optional additional * * search in order to look for a possibly missed phase by the * * modified Michelsen method ( i n i t i a l search) * * * * Parameters: * * -Input: * * Z,P,T,N,IFLG as defined in program PHASPLIT * * XP Composition vector of the phase found in the i n i t i a l * * phase search * * XQ Composition " " a second liquid i f found; * * otherwise a dummy variable * * DELGS Gibbs energy of mixing for the system as a stable phase * * (either of the liquid-like or vapour-like system) * * FUCP Fugacity coeff. vector of the phase found with PHASPLIT * * FUCQ " " second liquid i f found; * * otherwise a dummy variable * * * * -Output: * * HP Vector of the pseudo-values of HL when the system is * * liquid-like and of HV when i t is vapour-like (see * * subroutines LIQSER and VAPSER) * * * * Main variables: * * DELGP Gibbs energy of mixing of the phase found in the i n i t i a l * * phase search * * DELGQ Gibbs energy of mixing of a second liquid i f found * * DIFDG Difference in Gibbs energy of mixing between the phase * * found and the system as a single phase or between the * * two liquids found * * PDGDZ Pseudo-slope of the Gibbs energy of mixing a the feed * * composition * * PMU Vector of values of the pseudo-chemical potential of * * mixing * * * ********************************************************************* SUBROUTINE PHASER(Z,XP,Xq,P,T,N,DELGS,FUCP,FUCq,IFLG,HP) IMPLICIT REAL*8 (A-H,0-Z) DIMENSION FUCP(20),FUCq(20),HP(20),IFLG(0:20),PDGDZ(20), + PMU(20),XD(20),XP(20),Xq(20),Z(20) PL0G=DL0G(P) RT=1.987D0*T IF (IFLG(15) .NE. 0) WRITE (6,500) 500 FORMAT(/4X,'SUBROUTINE PHASER RESULTS') * Calculation of Hp for a binary mixture IF (N .GT. 2) GO TO 90 * Calculation of the Gibbs energy of mixing for the phase(s) found * with the modified Michelsen method SUM=0.D0 DO 10 1=1,N SUM=SUM+XP(I)*(DL0G(XP(I)*FUCP(I))+PL0G) Appendix C. Description and listings of the computer programs 243 10 CONTINUE DELGP=RT*SUM IF (IFLG(5) .EQ. 0 .AND. IFLG(6) .EQ. 2) THEN SUM=0.D0 DO 20 1=1,N SUM=SUM+XQ(I)*(DLOG(Xq(I)*FUCq(I))+PLOG) 20 CONTINUE DELGQ=RT*SUM DIFDG=DELGQ-DELGP GO TO 40 END IF DIFDG=DELGS-DELGP * The pseudo-slope of the Gibbs energy of mixing at the feed, * the pseudo-chemical potential of mixing and the value of Hp * are evaluated DO 30 1=1,1 PDGDZ(I)=DIFDG/(Z(I)-XP(I)) 30 CONTINUE IF (.NOT. (IFLG(5) .EQ. 0 .AND. IFLG(6) .Eq. 2)) GO TO 60 40 DO 50 1=1,1 PDGDZ(I)=DIFDG/(Xq(I)-XP(I)) 50 CONTINUE 60 DO 80 1=1,N SUMPD=0.D0 DO 70 J=1,N IF (J .EQ. I) GO TO 70 SUMPD=SUHPD+Z(J)*PDGDZ(J) 70 CONTINUE PMU(I)=DELGS-SUMPD HP(I)=PMU(I)/RT-PLOG 80 CONTINUE IF (IFLG(15) .NE. 0) THEN WRITE(6,510) (I,PDGDZ(I),I,PMU(I), 1=1,N) 510 FORMAT(4X,'PDGDZ(',12,*)=*,G11.4,2X,'PMU(',12,')='.G11.4) WRITE(6,520) (I,HP(I), 1=1,N) 520 FORMAT (6X,'hp(',I2 ,')=',Gil.4) END IF RETURN * Calculation of Hp for a multicomponent mixture (N>2) 90 DO 100 1=1,N HP(I)=DELGS/RT-PLOG 100 CONTINUE IF (IFLG(15) .NE. 0) THEN WRITE(6,520) (I,HP(I), 1=1,N) END IF RETURN END Appendix C. Description and listings of the computer programs 244 **************************************************** * * * SUBROUTINE TESTA (TEST FOR THE STABILITY OF 3 PHASES) * * * ********************************************************************** * * * Purpose: * * Using the multiphase flash reduction tests, determine the number * * and type of phases corresponding to the most stable system from * * the results of the phase search when a potential 3 phase solution * * is found * * * * Parameters: * * -Input * * Z,Y,Xi,X2,IP,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG as defined in * * program PHASPLIT * * Kl Vector of VL equilibrium constants corresponding to the * * comps. obtained from the phase search * * K2 Vector of LL equilibrium constants corresponding to the * * comps. obtained from the phase search * * * * -Output * * YN,XIN,X2N,FUCVN,FUCL1N,FUCL2N,ALPHA,BETA as defined in program * * PHASPLIT * * * * Main variables: * * BL1 Variable to limit the value of BETA * * BL2 " " " * * D Determinant of the mass balance and equilibrium system of * * equations solved by Newton-Raphson's method * * El Partial derivative of the VL mass balance and equil. eqn. * * with respect to ALPHA * * E2 Same as El but derivative with respect to BETA * * E3 Partial derivative of the LL mass balance and equil. eqn. * * with respect to ALPHA * * E4 Same as E3 but derivative with respect to BETA * * Gl Value of the VL mass balance and equil. eqn. * * £*2 11 11 •• M M 11 " ** ** * * JL1 Control variable to count the number of successive iters. * * in which BETA<0 or BETA>1 * * JL2 Control variable to count the number of successive iters. * * in which 1-ALPHA-BETA<0 or 1-ALPHA-BETA>1 * * JV Control variable to count the number of successive iters. * * in which ALPHA<0 or ALPHA>1 * * OMKL Vector of values of one minus the LL equil. constants * * OMKV " " " " " " " VL " " * * * * Remaining variables as defined in program PHASPLIT * * * * Subroutines called: * * LIMAB * * K * * * * Called by: * * PHASPLIT * * * ********************************************************************** SUBROUTINE TESTA(Z,Y,X1,X2,IP,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ, + Kl,K2,IFLG,YN,XIN,X2N,FUCVN,FUCL1N,FUCL2N, + ALPHA,BETA) Appendix C. Description and listings of the computer programs 245 IMPLICIT REAL*8 (A-H.O-Z) REAL*8 Kl(20),K2(20),KEq(20),KIJ(20,20),KV(20),KL(20) DIMENSION APUR(20),BPUR(20),FUCD(20),FUCL1N(20),FUCL2N(20), + FUCVN(20),IFLG(0:20),0MKL(20),0MKV(20),PC(20), + PP(20),TC(20),W(20),X1(20),X2(20),X1N(20),X2N(20), + Y(20),YN(20),Z(20) IFLG(13)=1 ITMAX=5 ITNUM=0 JV=0 JL1=0 JL2=0 * Calculation of i n i t i a l estimates of phase indicators V/F and Ll/F BETA=0.5D0 ALPHA=(Z(IP)-BETA*X1(IP)-X2(IP)*(1.DO-BETA))/ + (Y(IP)-BETA*X1(IP)-X2(IP)*(1.DO-BETA)) BETA=BETA*(l.DO-ALPHA) IF (ALPHA .LT. O.OSDO) ALPHA=0.05D0 IF (ALPHA .GT. 0.95D0) ALPHA=0.95D0 IF (BETA .LT. 0.05D0) BETA=0.05D0 IF (BETA .GT. 0.95D0) BETA=0.95D0 IF (IFLG(15) .NE. 0) WRITE(6,500) ALPHA,BETA 500 FORMAT(4X,'V/F INIT='.F9.4.2X,'Ll/F INIT=',F9.4) DO 10 1=1,N KV(I)=K1(I) KL(I)=K2(I) 0MKV(I)=1.D0-KV(I) 0MKL(I)=1.D0-KL(I) YN(I)=Y(I) X1N(I)=X1(I) X2N(I)=X2(I) 10 CONTINUE * Start of the iterative cycle 20 ITNUM=ITNUM+1 IF (IFLG(15) .NE. 0) WRITE(6,510) ITNUM 510 F0RMAT(4X,'*** ITNUM=\I3) IF (ITNUM .GT. ITMAX) THEN IFLG(11)=4 GO TO 200 END IF * If the KL values are near unity, the liquid phase with greater * tendency to disappear is eliminated SUM=0.D0 DO 30 1=1,N SUM=SUM+DABS(OMKL(I)) 30 CONTINUE IF (SUM .LT. 0.001D0) THEN SMFL1=0.D0 SMFL2=0.D0 DO 40 1=1,1 SMFL1=SMFL1+X1N(I)*FUCL1N(I) SMFL2=SMFL2+X2N(I)*FUCL2N(I) 40 CONTINUE IF (SMFL1 .GT. SMFL2) THEN BETA=0.D0 ELSE BETA=1.DO-ALPHA Appendix C. Description and listings of the computer programs END IF IF (IFLG(15) .NE. 0) WRITE(6,520) 520 FORMAT(/4X,'STABLE SYSTEM AS V-L (KL=1)'/) IFLG(11)=2 GO TO 160 END IF * Calculation of V/F and/or Ll/F with VL and LL K's fixed using * Newton-Raphson's method DO 60 J=l,15 G1=0.D0 G2=0.D0 E1=0.D0 E2=0.D0 E3=0.D0 E4=0.D0 DO 50 1=1,N E5=(BETA*KL(I)+1.DO-BETA-ALPHA+ALPHA+KV(I))**2 IF (E5 .LT. l.D-30) E5=l.D-30 Gl=Gl+Z(I)*0MKV(I)/DSqRT(E5) E1=E1+Z(I)*0MKV(I)**2/E5 E2=E2+Z(I)*0MKV(I)*0MKL(I)/E5 G2=G2+Z(I)+0MKL(I)/DSQRT(E5) E3=E2 E4=E4+Z(I)+0MKL(I)**2/E5 50 CONTINUE IF (DABS(G1)+DABS(G2) .LT. l.D-7) GO TO 70 D=E1*E4-E2*E3 IF (DABS(D) .LT. l.D-15) GO TO 70 A0=ALPHA+(G2*E2-G1*E4)/D B0=BETA+(G1*E3-G2*E1)/D ALPHA=A0 BETA=B0 IF (DABS(D) .LT. l.D-9) GO TO 70 60 CONTINUE 70 IF (IFLG(15) .NE. 0) WRITE(6,530) ALPHA,BETA 530 FORMAT(4X,'V/F=',Fl1.4,2X,'Ll/F=',Fl1.4) * If more than one phase indicator is outside the interval [0,1], * the phase with greater tendency to disappear is found IF (ALPHA .LT. O.DO .AND. (BETA .LT. O.DO .OR. BETA .GT. + 1.D0)) THEN JL1=JL1-1 JV=JV+1 END IF 0NMAB=1.DO-ALPHA-BETA IF (ALPHA .LT. O.DO .AND. (ONMAB .LT. O.DO .OR. ONMAB .GT. + 1.D0)) THEN JL2=JL2-1 JV=JV+1 END IF IF (ALPHA .LE. 1.D0 .OR. BETA .GE. O.DO .OR. ONMAB .GE. + O.DO) GO TO 90 SMFL1=0.D0 SMFL2=0.D0 DO 80 1=1,N SMFL1=SMFL1+X1N(I)*FUCL1N(I) SMFL2=SMFL2+X2N(I)*FUCL2N(I) 80 CONTINUE Appendix C. Description and listings of the computer programs 247 IF (SMFL1 .GT. SMFL2) THEN JL2=JL2-1 ELSE JL1=JL1-1 END IF * Limitation of the calculated values of V/F and/or Ll/F when * outside the interval [0,1] to avoid calculation of negative * mole fractions 90 IF (ALPHA .GT. 1.D0 .OR. ALPHA .LT. O.DO) CALL LIMAB(N, + KV,ALPHA) BL2=0.D0 DO 100 1=1,N IF (OMKL(I) .Eq. O.DO) GO TO 105 BLl=(ALPHA*OMKV(I)-l.DO)/(-OMKL(I)) IF (BETA .GT. O.DO .AND. BL1 .GT. O.DO .AND. BETA .GT. + BL1 .AND. (BL1 .LT. BL2 .OR. BL2 .Eq. O.DO)) BL2=BL1 IF (BETA .LT. O.DO .AND. BL1 .LT. O.DO .AND. BETA .LT. + BL1 .AND. (BL1 .GT. BL2 .OR. BL2 .Eq. O.DO)) BL2=BL1 100 CONTINUE 105 IF (BL2 .Eq. O.DO) GO TO 110 IF (BETA .GT. O.DO .AND. BETA .GT. BL2 .AND. BL2 .GE. l.DO) + BETA=1.D0+(BL2-1.D0)/2.D0 IF (BETA .GT. O.DO .AND. BETA .GT. BL2 .AND. BL2 .LT. l.DO) + BETA=BL2-0.005D0 IF (BETA .LT. O.DO .AND. BETA .LT. BL2) BETA=BL2/2.DO 110 IF (ALPHA .LE. O.DO .OR. ALPHA .GE. l.DO) THEN JV=JV+1 ELSE JV=0 END IF IF (BETA .LE. O.DO .OR. BETA .GE. l.DO) THEN JL1=JL1+1 ELSE JL1=0 END IF ONMAB=1.DO-ALPHA-BETA IF (ONMAB .LE. O.DO .OR. ONHAB .GE. l.DO) THEN JL2=JL2+1 ELSE JL2=0 END IF IF (IFLG(15) .NE. 0) WRITE(6,540) ALPHA,BETA 540 FORMAT(4X,'V/F LIM='.F11.4.2X,'Ll/F LIM=',F11.4) * If the value of V/F, Ll/F or L2/F has been outside the interval * [0,1] for three consecutive iterations, the corresponding phase * is eliminated IF (IFLG(15) .NE. 0) WRITE(6,550) JV.JL1.JL2 550 FORMAT(4X,'IL1L1=',I3,2X,'IVL2=',I3,2X,'IVL1=',13) IF (.NOT. (ALPHA .LE. O.DO .AND. JV .GE. 3)) GO TO 120 * Elimination of the vapour phase ALPHA=0 IF (IFLG(15) .NE. 0) WRITE(6,560) 560 FORMAT(/4X,'STABLE SYSTEM AS L-L*/) IFLG(11)=3 GO TO 160 Appendix C. Description and listings of the computer programs 248 * Elimination of liquid 1 120 IF (JL1 .GE. 3 .AND. BETA .LE. O.DO) THEN BETA=0.D0 IF (IFLG(IS) .NE. 0) WRITE(6,570) 570 FORMAT(/4X,'STABLE SYSTEM AS V-L2'/) IFLG(11)=2 GO TO 160 END IF * Elimination of liquid 2 IF (JL2 .GE. 3 .AND. 1.DO-ALPHA-BETA .LE. O.DO) THEN BETA=1.DO-ALPHA IF (IFLG(15) .NE. 0) WRITE(6,580) 580 F0RMAT(/4X,'STABLE SYSTEM AS V-Ll*/) IFLG(11)=2 GO TO 160 END IF * Calculation of the new compositions of the 3 phases S0=0.D0 S1=0.D0 S2=0.D0 DO 130 1=1,N X2N(I)=Z(I)/(BETA*KL(I)+1.D0-ALPHA-BETA+ALPHA+KV(I)) IF (X2N(I) .LT. O.DO) X2N(I)=0.D0 S2=S2+X2N(I) X1N(I)=X2N(I)*KL(I) S1=S1+X1N(I) YN(I)=X2N(I)*KV(I) S0=S0+YN(I) 130 CONTINUE DO 140 1=1,N X2N(I)=X2N(I)/S2 X1N(I)=X1N(I)/S1 YN(I)=YN(I)/S0 140 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,590) (I,YN(I);I,X1N(I),I,X2N(I), + 1=1,N) 590 FORMAT(6X,'YN(',12,')=*.F9.6.2X,'X1N(',12,')='.F9.6.2X,'X2N(', + 12,')=',F9.6) * Calculation of the new values of K's IFLG(1)=0 IFLG(2)=0 IFLG(3)=0 IFLG(16)=0 CALL K(XD,YN.TC,PC,W.PP.P.T.N,1,3,APUR,BPUR,FUCVN,FUCD, + Zl.ZO,KIJ,KEq,IFLG) CALL K(XD,X1N,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUCL1N,FUCD, + Z2.Z0,KIJ,KEQ,IFLG) IF (IFLG(2) .Eq. 1) THEN IFLG(2)=0 IFLG(16)=1 END IF CALL K(XD,X2N,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUCL2N,FUCD, + Z3.Z0,KIJ,KEq,IFLG) IF (IFLG(2) .Eq. 1) THEN IFLG(2)=0 IFLG(3)=1 Appendix C. Description and listings of the computer programs 249 END IF IF (IFLG(16) .Eq. 1) IFLG(2)=1 DO 150 1=1, N KV(I)=FUCL2N(I)/FUCVN(I) KL(I)=FUCL2N(I)/FUCL1N(I) 0MKV(I)=1.D0-KV(I) 0MKL(I)=1.D0-KL(I) 150 CONTINUE IF (IFLG(15) .NE. 0) HRITE(6,600) (I,KV(I),I,KL(I), 1=1,N) 600 FORMAT(6X,>KV(',12,')='.F10.4.2X,'KL(',12,*) = '.F10.4) IF (IFLG(l) .Eq. 1 .AND. IFLG(15) .NE. 0) WRITE(6,610) 610 FORMAT(4X,'EXTRAPOLATED ZVAP') IF (IFLG(2) .Eq. 1 .AND. IFLG(15) .NE. 0) WRITE(6,620) 620 F0RMAT(4X,'EXTRAPOLATED ZLiqi') IF (IFLG(3) .Eq. 1 .AND. IFLG(15) .NE. 0) WRITE(6,630) 630 FORMAT(4X,'EXTRAPOLATED ZLiq2') * End of iterative cycle GO TO 20 * Results of calculation 160 IF (ALPHA .Eq. O.DO) THEN DO 170 1=1,N YN(I)=O.DO X1N(I)=X1(I) X2N(I)=X2(I) 170 CONTINUE GO TO 200 ELSE IF (BETA .Eq. O.DO) THEN DO 180 1=1,N YN(I)=Y(I) X1N(I)=0.D0 X2N(I)=X2(I) 180 CONTINUE IFLG(14)=0 GO TO 200 ELSE IF (BETA .Eq. 1.DO-ALPHA) THEN DO 190 1=1,N YN(I)=Y(I) X1N(I)=0.D0 X2N(I)=X1(I) 190 CONTINUE IFLG(14)=1 END IF 200 RETURN END * SUBROUTINE FOR LIMITING V/F OR Ll/F AS IN A 2-PHASE CALCULATION SUBROUTINE LIMAB(N,RK,C) IMPLICIT REAL*8 (A-H.O-Z) DIMENSION RK(20) RKM=RK(1) DO 20 1=2,N IF (C .LT. O.DO) GO TO 10 IF (RK(I) .LT. RKM) RKM=RK(I) GO TO 20 10 IF (RK(I) .GT. RKM) RKM=RK(I) 20 CONTINUE C0=1.D0/(1.D0-RKM) Appendix C. Description and listings of the computer programs 250 IF (C .LT. O.DO .AND. CO .GT. O.DO) THEN C=-CO GO TO 30 ELSE IF (C .GT. O.DO .AND. CO .LT. O.DO) THEN C=i.DO-CO GO TO 30 END IF IF (C .LT. O.DO .AND. C .LT. CO) C=C0/2.D0 IF (C .GT. l.DO .AND. C .GT. CO) C=(1.DO+CO)/2.DO 30 RETURN END Appendix C. Description and listings of the computer programs 251 ********************************************************************** * SUBROUTINE NELSTA (NELSON'S STABILITY TEST FOR 3 PHASES) * * * ********************************************************************** * * * Purpose: * * Using the modified Nelson's phase reduction tests, determine the * * number and type of phases corresponding to the most stable system * * from the results of the phase search when a potential 3 phase * * solution is found * * * * Parameters: * * -Input * * Z,Y,X1,X2,IP,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ,IFLG as defined in * * program PHASPLIT * * K1.K2 as defined is subroutine TESTA * * * * -Output * * YN,XIN,X2N,FUCVN,FUCL1N.FUCL2N,ALPHA,BETA as defined in program * * PHASPLIT * * * * Main variables: * * BL1,BL2,D,E1,E2,E3,E4,G1,G2,0MKL,0MKV as defined in subroutine * * TESTA * * * * DKV Vector of the values of the difference between the LL * * and VL equil. constants * * DGAMLL Partial derivative of GAMLL with respect to BETA * * DGMVL1 " " " GAMVL1 " * * DGMVL2 " " " GAMVL2 " " " ALPHA * * GAMLL Mass balance and equil. eqn. to test for the system LL as * * the stable solution * * GAMVL1 Mass balance and e q u i l . V L 1 * * as the stable solution * * GAMVL2 Mass balance and equil. ' V L 2 * * as the stable solution * * IL Control variable for a l i q phase as the stable solution * * IVL1 " " " the system VL1 as the stable soln. * * IVL2 " " VL2 " " " " * * ILL " " LL " " " " * * IVLL " " " " " VLL " " " " * * ILIM Limit for the number of consecutive iterations to * * determine the stable solution * * SI - S6 Value of the sum of the various feed comp. and equil. * * constants defined by Nelson as criteria for the * * existence of one, two or three phases * * * * Remaining variables as defined in program PHASPLIT and * * subroutine TESTA * * * * Subroutines called: * * LIMAB * * K * * * * Called by: * * PHASPLIT * * * ********************************************************************** SUBROUTINE NELSTA(Z,Y,X1,X2,IP,TC,PC,W,PP,P,T,N,APUR,BPUR,KIJ, + K1.K2,IFLG,YN,XIN,X2N,FUCVN,FUCL1N,FUCL2N, Appendix C. Description and listings of the computer programs 252 + ALPHA,BETA) IMPLICIT REAL+8 (A-H.O-Z) REAL*8 Kl(20),K2(20),KEq(20),KIJ(20,20),KV(20),KL(20) DIMENSION APUR(20),BPUR(20),DKV(20),FUCD(20),FUCL1N(20), + FUCL2N(20),FUCVN(20),IFLG(0:20),0MKL(20),0MKV(20), + PC(20),PP(20),TC(20),W(20),X1(20),X2(20),X1N(20), + X2N(20),Y(20),YN(20),Z(20) ILIM=3 IV=0 IL=0 IVL1=0 IVL2=0 ILL=0 IVLL=0 * Calculation of i n i t i a l estimates of phase indicators V/F and Ll/F BETA=0.5D0 ALPHA=(Z(IP)-BETA*X1(IP)-X2(IP)*(1.DO-BETA))/ + (Y(IP)-BETA*X1(IP)-X2(IP)*(1.DO-BETA)) BETA=BETA*(1.DO-ALPHA) IF (ALPHA .LT. 0.05D0) ALPHA=0.05D0 IF (ALPHA .GT. 0.95D0) ALPHA=0.95D0 IF (BETA .LT. 0.05D0) BETA=0.05D0 IF (BETA .GT. 0.95D0) BETA=0.95D0 IF (IFLG(15) .NE. 0) WRITE(6,500) ALPHA,BETA 500 FORMAT(4X,'V/F INIT=« .F9.4.2X,'Ll/F INIT=\F9.4) DO 10 1=1,N KV(I)=K1(I) KL(I)=K2(I) 0MKV(I)=1.D0-KV(I) 0MKL(I)=1.D0-KL(I) 10 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,510) (I,KV(I),I,KL(I), 1=1,N) 510 FORMAT(6X,'KV(',12,')=',F10.4.2X,'KL(',12,')='.F10.4) * Start of the iterative cycle * Calculation of V/F and Ll/F with VL and LL K's fixed using Newton-* Raphson's method 20 DO 40 J=l,15 G1=0.D0 G2=0.D0 E1=0.D0 E2=0.D0 E3=0.D0 E4=0.D0 DO 30 1=1,N E5=(BETA*KL(I)+1.DO-BETA-ALPHA+ALPHA*KV(I))**2 IF (E5 .LT. l.D-30) E5=l.D-30 Gl=Gl+Z(I)*0MKV(I)/DSqRT(E5) E1=E1+Z(I)*0MKV(I)**2/E5 E2=E2+Z(I)*0MKV(I)*0MKL(I)/E5 G2=G2+Z(I)*0MKL(I)/DSQRT(E5) E3=E2 E4=E4+Z(I)*0MKL(I)**2/E5 30 CONTINUE IF (DABS(G1)+DABS(G2) .LT. l.D-7) GO TO 50 D=E1*E4-E2*E3 IF (DABS(D) .LT. l.D-15) GO TO 50 A0=ALPHA+(G2*E2-G1*E4)/D B0=BETA+(G1*E3-G2*E1)/D ALPHA=A0 Appendix C. Description and listings of the computer programs 253 BETA=BO IF (DABS(D) .LT. l.D-9) GO TO 50 40 CONTINUE 50 IF (IFLG(15) .NE. 0) WRITE(6,520) ALPHA,BETA 520 FORMAT(4X,'V/F=',G11.4.2X,*L1/F='.G11.4) * Limitation of the calculated values of V/F and/or Ll/F when * outside the interval [0,1] to avoid calculation of negative * mole fractions IF (ALPHA .GT. l.DO .OR. ALPHA .LT. O.DO) CALL LIMAB(N, + KV,ALPHA) BL2=0.D0 DO 60 1=1,N IF (KL(I) .Eq. l.DO) GO TO 65 BL1=(ALPHA*(1.D0-KV(I))-1.D0)/(KL(I)-1.D0) IF (BETA .GT. O.DO .AND. BL1 .GT. O.DO .AND. BETA .GT. + BL1 .AND. (BL1 .LT. BL2 .OR. BL2 .Eq. O.DO)) BL2=BL1 IF (BETA .LT. O.DO .AND. BL1 .LT. O.DO .AND. BETA .LT. + BL1 .AND. (BL1 .GT. BL2 .OR. BL2 .Eq. O.DO)) BL2=BL1 60 CONTINUE 65 IF (BL2 .Eq. O.DO) GO TO 70 IF (BETA .GT. O.DO .AND. BETA .GT. BL2 .AND. BL2 .GE. l.DO) + BETA=1.D0+(BL2-1.D0)/2.D0 IF (BETA .GT. O.DO .AND. BETA .GT. BL2 .AND. BL2 .LT. l.DO) + BETA=BL2-0.005D0 IF (BETA .LT. O.DO .AND. BETA .LT. BL2) BETA=BL2/2.DO 70 IF (IFLG(15) .NE. 0) WRITE(6,530) ALPHA,BETA 530 FORMAT(4X,'V/F LIM=',G11.4,2X,'Ll/F LIM=',G11.4) * Calculation of the new compositions in the 3 phases S0=0.D0 S1=0.D0 S2=0.D0 DO 80 1=1,N X2N(I)=Z(I)/(BETA*KL(I)+1.DO-ALPHA-BETA+ALPHA*KV(I)) IF (X2N(I) .LT. O.DO) X2N(I)=0.D0 S2=S2+X2N(I) X1N(I)=X2N(I)*KL(I) S1=S1+X1N(I) YN(I)=X2N(I)*KV(I) S0=S0+YN(I) 80 CONTINUE DO 90 1=1,N X2N(I)=X2N(I)/S2 X1N(I)=X1N(I)/S1 YN(I)=YN(I)/SO 90 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,540) (I,YN(I),I,X1N(I),1,X2N(I), + 1=1,N) 540 FORMAT(6X,'YN(*,12,')=',F9.6,2X,'X1N(',12,')='.F9.6.2X,*X2N(', + 12,')=*,F9.6) * Calculation of KV and KL with the new composition values IFLG(1)=0 IFLG(2)=0 IFLG(3)=0 IFLG(16)=0 CALL K(XD,YN,TC,PC,W,PP,P,T,N,1,3,APUR,BPUR,FUCVN,FUCD.ZV,ZD, + KIJ,KEq,IFLG) CALL K(XD,X1N,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUCL1N,FUCD,ZL1,ZD, Appendix C. Description and listings of the computer programs 254 + KIJ,KEQ,IFLG) IF (IFLG(2) .Eq. 1) THEN IFLG(2)=0 IFLG(16)=1 END IF CALL K(XD,X2N,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUCL2N,FUCD,ZL2,ZD, + KlJ,KEQ,IFLG) IF (IFLG(2) .Eq. 1) THEN IFLG(2)=0 IFLG(3)=1 END IF IF (IFLG(16) .Eq. 1) IFLG(2)=1 DO 100 1=1,1 KV(I)=FUCL2N(I)/FUCVN(I) KL(I)=FUCL2N(I)/FUCL1N(I) 0MKV(I)=1.D0-KV(I) 0MKL(I)=1.D0-KL(I) DKV(I)=KL(I)-KV(I) 100 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,510) (I,KV(I),1,KL(I), 1=1,N) IF (IFLG(l) .Eq. 1 .AND. IFLG(15) .NE. 0) WRITE(6,550) 550 FORMAT(4X,'EXTRAPOLATED ZVAP') IF (IFLG(2) .Eq. 1 .AND. IFLG(15) .NE. 0) WRITE(6,560) 560 FORMAT(4X,'EXTRAPOLATED ZLiqi') IF (IFLG(3) .Eq. 1 .AND. IFLG(15) .NE. 0) WRITE(6,570) 570 FORMAT(4X,'EXTRAPOLATED ZLiq2') * Test for the existence of a single phase S1=0.D0 S2=0.D0 S3=0.D0 S4=0.D0 S5=0.D0 S6=0.D0 DO 110 1=1,N S1=S1+Z(I)/KV(I) S2=S2+Z(I)*KL(I)/KV(I) S3=S3+Z(I)*KV(I)/KL(I) S4=S4+Z(I)/KL(I) S5=S5+Z(I)*KV(I) S6=S6+Z(I)*KL(I) 110 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,580)S1,S2,S3,S4,S5,S6 580 FORMAT(6X,'Sl=',F9.5,2X,'S2=',F9.5,2X,'S3=',F9.5/ + 6X,'S4=',F9.5,2X,*S5='.F9.5.2X,'S6=',F9.5) IF (SI .LT. l.DO .AND. S2 .LT. l.DO) THEN IV=IV+1 IF (IFLG(15) .NE. 0) WRITE(6,590) 590 FORMAT(/4X,'STABLE SYSTEM AS VAPOUR'/) IF (IV .GE. ILIM) THEN IFLG(11)=0 ALPHA=1.D0 BETA=0.DO DO 120 1=1,N YN(I)=Z(I) X1N(I)=0.D0 X2N(I)=0.D0 120 CONTINUE GO TO 330 ELSE GO TO 20 Appendix C. Description and listings of the computer programs 255 END IF ELSE IV=0 END IF IF (S3 .LT. l.DO .AND. S4 .LT. 1.D0 .OR. + SB .LT. l.DO .AND. S6 .LT. l.DO) THEN IL=IL+1 IF (IFLG(15) .NE. 0) WRITE(6,600) 600 FORMAT(/4X,'STABLE SYSTEM AS LiqUID'/) IF (IL .GE. ILIM) THEN IFLG(11)=1 ALPHA=O.DO BETA=1.DO DO 130 1=1,N YN(I)=O.DO X1N(I)=Z(I) X2N(I)=0.D0 130 CONTINUE GO TO 330 ELSE GO TO 20 END IF ELSE IL=0 END IF IF (S2 .LE. l.DO .OR. S3 .LE. l.DO) GO TO 180 * Test lor the existence of vapour and liquid 1 BET=BETA DO 150 J=l,15 GAMVL1=0.D0 DGMVL1=0.D0 DO 140 1=1,N DEN=BET*DKV(I)+KV(I) GAMVL1=GAMVL1+Z(I)*DKV(I)/DEN DGMVL1=DGMVL1-Z(I)*(DKV(I)/DEN)**2 140 CONTINUE IF (DABS(GAMVLl) .LT. l.D-5) GO TO 160 B0=BET-GAMVL1/DGMVL1 BET=BO 150 CONTINUE 160 SO=O.DO DO 170 1=1, N SO=SO+Z(I)+OMKV(I)/(BET+DKV(I)+KV(I)) 170 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,610) ALP,SO 610 FORMAT(4X,'TEST FOR VL1'/ + 4X,'R00T BET OF GAMVL1='.G11.4.2X,'GAMVL2=',F9.5) IF (SO .LT. O.DO) THEN IVL1=IVL1+1 IVLL=0 IF (IFLG(15) .NE. 0) VRITE(6,620) 620 FORMAT(/4X,'STABLE SYSTEM AS VL1'/) IF (IVL1 .GE. ILIM) THEN BETA=l.DO-ALPHA IFLG(11)=2 GO TO 290 ELSE GO TO 20 END IF ELSE Appendix C. Description and listings of the computer programs 256 IVL1=0 END IF 180 IF (SI .LE. l.DO .OR. S5 .LE. l.DO) GO TO 230 * Test for the existence of vapour and liquid 2 ALP=ALPHA DO 200 J=l,15 GAMVL2=0.D0 DGMVL2=0.D0 DO 190 1=1,N DEN=1.D0-ALP*0MKV(I) GAMVL2=GAMVL2+Z(I)*0MKV(I)/DEN DGMVL2=DGMVL2+Z(I)*(OMKV(I)/DEN)**2 190 CONTINUE IF (DABS(GAMVL2) .LT. l.D-5) GO TO 210 A0=ALP-GAMVL2/DGMVL2 ALP=A0 200 CONTINUE 210 S0=0.D0 DO 220 1=1,N S0=S0+Z(I)*DKV(I)/(1.D0-ALP*0MKV(I)) 220 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,630) ALP,SO 630 F0RMAT(4X,'TEST FOR VL2'/ + 4X,'R00T ALP OF GAMVL2='.G11.4.2X,'GAMLL=',F9.5) IF (SO .LT. O.DO) THEN IVL2=IVL2+1 IVLL=0 IF (IFLG(15) .NE. 0) WRITE(6,640) 640 FORMAT(/4X,'STABLE SYSTEM AS VL2'/) IF (IVL2 .GE. ILIM) THEN BETA=0.D0 IFLG(11)=2 GO TO 290 ELSE GO TO 20 END IF ELSE IVL2=0 END IF 230 IF (S4 .LE. l.DO .OR. S6 .LE. l.DO) GO TO 280 * Test for the existence of liquid 1 and liquid 2 BET=BETA DO 250 J=l,15 GAMLL=0.DO DGAMLL=O.DO DO 240 1=1,N DEN=BET*0MKL(I)-1.D0 GAMLL=GAMLL+Z(I)*0MKL(I)/DEN DGAMLL=DGAMLL-Z(I)*(OMKL(I)/DEN)**2 240 CONTINUE IF (DABS(GAMLL) .LT. l.D-5) GO TO 260 BO=BET-GAMLL/DGAMLL BET=BO 250 CONTINUE 260 S0=0.D0 DO 270 1=1,N SO=SO+Z(I)*OMKV(I)/(1.DO-BET*OMKL(I)) 270 CONTINUE IF (IFLG(15) .NE. 0) WRITE(6,650) BET,SO Appendix C. Description and listings of the computer programs 257 650 FORMAT(4X,'TEST FOR L1-L2'/ + 4X,'R00T BET OF GAMLL=',G11.4,2X,'GAMVL2=',F9.5) IF (SO .GT. O.DO) THEN ILL=ILL+1 IVLL=0 IF (IFLG(15) .NE. 0) WRITE(6,660) 660 FORMAT(/4X,'STABLE SYSTEM AS LL'/) IF (ILL .GE. ILIM) THEN ALPHA=O.DO IFLG(11)=3 GO TO 290 ELSE GO TO 20 END IF ELSE ILL=0 END IF 280 IVLL=IVLL+1 IF (IFLG(15) .NE. 0) WRITE(6,670) 670 FORMAT(/4X,'STABLE SYSTEM AS VLL'/) IF (IVLL .GE. ILIM) THEN IFLG(11)=4 GO TO 330 ELSE GO TO 20 END IF * Results of the calculation 290 IF (ALPHA .Eq. 0) THEN DO 300 1=1,N YN(I)=O.DO X1N(I)=X1(I) X2N(I)=X2(I) 300 CONTINUE GO TO 330 ELSE IF (BETA .Eq. O.DO) THEN DO 310 1=1,N YN(I)=Y(I) X1N(I)=0.D0 X2N(I)=X2(I) 310 CONTINUE IFLG(14)=0 GO TO 330 ELSE IF (BETA .Eq. 1.DO-ALPHA) THEN DO 320 1=1,N YN(I)=Y(I) X1N(I)=0.D0 X2N(I)=X1(I) 320 CONTINUE IFLG(14)=1 END IF 330 RETURN END * SUBROUTINE FOR LIMITING V/F OR Ll/F AS IN A 2-PHASE CALCULATION SUBROUTINE LIMAB(N,RK,C) IMPLICIT REAL+8 (A-H.O-Z) DIMENSION RK(20) RKM=RK(1) DO 20 1=2,N Appendix C. Description and listings of the computer programs 258 IF (C .LT. O.DO) GO TO 10 IF (RK(I) .LT. RKM) RKM=RK(I) GO TO 20 10 IF (RK(I) .GT. RKM) RKM=RK(I) 20 CONTINUE C0=1.D0/(1.D0-RKM) IF (C .LT. O.DO .AND. CO .GT. O.DO) THEN C=-CO GO TO 30 ELSE IF (C .GT. O.DO .AND. CO .LT. O.DO) THEN C=l.DO-CO GO TO 30 END IF IF (C .LT. O.DO .AND. C .LT. CO) C=C0/2.D0 IF (C .GT. l.DO .AND. C .GT. CO) C=(1.D0+C0)/2.D0 30 RETURN END Appendix C. Description and listings of the computer programs 259 ************************************************** * * * PROGRAM PHASEQ (PHASE EQUILIBRIA) * * * ********************************************************************** * * * Purpose: * * Main program to calculate a VL, LL or VLL isothermal flash using * * the Soave-Redlich-Kwong or the Peng-Robinson EOS as described in * * Appendix B * * * * Main variables * * -Alphanumeric * * DAMP,EOS,TYPEq,SYSTEM,ZV.ZL1.ZL2 as defined in program PHASPLIT * * INIT Indicates i f the i n i t i a l estimates are supplied by the * * user or i f calculated with the in i t i a l i z a t i o n routines * * * * -Numeric * * ALPHA,BETA,IFLG,IFTP.ITMAX,KIJ,N,P,PC,PP,T,TC,W,Z as defined in * * program PHASPLIT * * * * DG Dimensionless Gibbs energy of mixing * * EPS Convergence tolerance * * FUGC1 Vector of fug. coeffs. for the vapour (VL or VLL calc.) * * or for l i q . 1 (LL calc.) * * FUGC2 Vector of fug. coeffs. for the l i q . (VL c a l c ) , for l i q . * * 1 (VLL c a l c ) or for l i q . 2 (LL calc.) * * FUGC3 Vector of fug. coeffs. for l i q . 2 (VLL calc.) * * 10 Control variable to apply the composition criterion in * * selection of key components; 0=not used; l=used * * II Key component for l i q . 1; i f 0 i t is calculated * * j2 11 " 11 M 2 " 11 " " *' * * ITEq Indicator of the type of calculation: 1=VL; 2=LL; 3=VLL * * ITNUM Number of iterations required to reach convergence * * IWEG Frequency of application of Wegstein's method * * Kl Equilibrium constants yi/x2i at equilibrium * * K2 " " xli/x2i at " * * KEq Vector of VL or LL equilibrium constants * * X Vector of mole fractions for the only liquid (VL calc.) * * or for l i q . 2 (LL calc.) * * XI Vector of mole fractions for l i q . 1 (VLL c a l c ) * $ j£2 11 11 11 M H " 2 11 * * Y . . . . .. ... .. t h e v a p o u r (VL or VLL calc.) * * or for l i q . 1 (LL calc.) * * ZED 3 element vector with the compressibility factors for the * * VLL c a l c ; the f i r s t corresponds to the vapour, the * * second to l i q . 1 and the last to l i q . 2 * * * * System's flags: * * 0,4,7,8,9,10,12,13,14,16,18 as described in the program PHASPLIT * * 5,6,11,15,17 not used * * i IFLG(i) * * 1 l=extrapolated density for the vapour (VL or VLL calc.) or * * for l i q . 1 (LL c a l c ) * * 2 l=extrap. density for the liquid (VL c a l c ) , for l i q . 1 (VLL * * calc.) or l i q . 2 (LL c a l c ) * * 3 l=extrap. density for l i q . 2 (VLL c a l c ) * * * * Subroutines called: * * IFLL * * IFVL * * IFVLL * Appendix C. Description and listings of the computer programs 260 * FLASH2 * * FLASH3 * * GIBBS * * * ************************************************** IMPLICIT REAL*8 (A-H.O-Z) REAL+8 KEq(20),KIJ(20,20),K1(20),K2(20) CHARACTER SYSTEM*72,E0S*25,TYPEQ*10,DAMP*16,INIT*20, 4 ZV*8,ZL1*9,ZL2*9 DIMENSION FUGC1(20),FUGC2(20),FUGC3(20),IFLG(0:20), + PC(20),PP(20),TC(20),W(20), + X(20),X1(20),X2(20),Y(20),Z(20),ZED(3) IT0TIM=0 DO 10 1=0,20 IFLG(I)=0 10 CONTINUE DO 30 1=1,20 DO 20 J=l,20 KIJ(I,J)=0.D0 20 CONTINUE 30 CONTINUE READ(5,*) SYSTEM,IFLG(0),N.ITMAX,EPS,IFLG(7),IWEG,IFLG(8), + ITEQ,IFTP,T,P,QIN,QFN,DELQ, + IFLG(9),IFLG(10),10,I1,12,ALPHA,BETA DO 40 1=1,N READ(5,*) Z(I),TC(I),PC(I),W(I),PP(I) 40 CONTINUE DO 60 1=1,N DO 50 J=1,N IF (I .GE. J) GO TO 50 READ(5,*) KIJ(I.J) KIJ(J,I)=KIJ(I,J) 50 CONTINUE 60 CONTINUE * Printing of calculation conditions WRITE(6,500) SYSTEM 500 FORMAT (//2X.A60) IF (IFLG(O) .EQ. 0) THEN EOS=*SOAVE-REDLICH-KWONG EOS* ELSE EOS=*PENG-ROBINSON EOS' END IF IF (ITEQ .EQ.l) THEN TYPEQ='VL FLASH' ELSE IF (ITEq. EQ. 2) THEN TYPEQ='LL FLASH' ELSE TYPEQ='VLL FLASH' END IF WRITE(6,510) EOS,TYPEQ 510 F0RMAT(/4X,A25,2X,A10) IF (IFLG(7) .EQ. 0) THEN WRITE(6,520) 520 FORMAT(4X, 'WITHOUT WEGSTEINS METHOD*) GO TO 70 END IF IF (IFLG(8) .EQ. 0) THEN DAMP=' WITHOUT DAMPING' ELSE DAMP=' WITH DAMPING' Appendix C. Description and listings of the computer programs 261 END IF WRITE(6,530) IWEG,DAMP 530 FORMAT(4X,'WEGSTEINS METHOD EACH',13,' ITERATIONS *,A16) 70 WRITE(6,540) ITMAX,EPS 540 FORMAT(4X,'MAXIMUM NO. OF ITERATIONS=',13,2X, + 'C0NVERGENCE=',F8.5) IF (IFLG(lO) .Eq. 1) THEN WRITE(6,550) 550 FORMAT(4X,'SEQUENTIAL CALCULATION') END IF IF (IFLG(9) .EQ. 1) THEN INIT='AUTO-INITIALIZATION' ELSE INIT='USER INITIALIZATION' END IF WRITE(6,560) INIT 560 F0RMAT(4X,A20/) DO 90 1=1,1 DO 80 J=1,N IF (I .GE. J .OR. KIJ(I.J) .Eq. O.DO) GO TO 80 WRITE(6,570) I,J,KIJ(I,J) 570 FORMAT(8X,'K(',12,',',12,*)=',F7.4) 80 CONTINUE 90 CONTINUE IF (IFTP .Eq. 0) GO TO 115 IF (IFTP .Eq. 3) THEN WRITE(6,575) T,P 575 F0RMAT(/4X,'T=',F8.3,' K',4X,'P=',F8.3,' atm'/) GO TO 100 END IF * Loop for calculations at fixed T and various P or at fixed P at * various T DO 310 Q=QIN,QFN,DELQ IF (IFTP .EQ.l) THEN P=q ELSE T=q END IF GO TO 115 * Loop for calculations at fixed T and P ar different compositions 100 IF (N .GT. 3) THEN WRITE(6,577) 577 F0RMAT(/4X,'WARNING: CALC. AT FIXED T & P AT DIFFERENT' + /4X,'COMPOSITIONS ALLOWED ONLY FOR BINARY OR' + /4X,'TERNARY MIXTURES') GO TO 310 END IF IF (N .Eq. 2) THEN DZ=0.05D0 ELSE DZ=0.1DO END IF IF (N .Eq. 2) GO TO 110 DO 305 ZF1=1.D-8,1.D0+DZ,DZ DO 300 ZF2=1.D-8,1.D0+DZ,DZ Z(1)=ZF1 Z(2)=ZF2 Z(3)=1.D0-ZF1-ZF2 IF (Z(l) .GT. l.DO) Z(l)=l.D0-l.D-8 Appendix C. Description and listings of the computer programs 262 IF (Z(2) .GT. l.DO) Z(2)=l.D0-l.D-8 IF (Z(3) .LT. O.DO) Z(3)=l.D-8 IF (ZF1+ZF2 .GT. l.DO+DZ) GO TO 300 ZT0T=Z(1)+Z(2)+Z(3) Z(1)=Z(1)/ZT0T Z(2)=Z(2)/ZT0T Z(3)=Z(3)/ZT0T GO TO 115 110 DO 295 ZA1=1.D-8,1.D0+DZ,DZ Z(1)=ZA1 Z(2)=1.D0-ZA1 IF (Z(2) .LE. O.DO) Z(2)=l.D-8 115 IF ((IFLG(9) .EQ. 0) .OR. (IFLG(IO) .EQ. 1 .AND. + IFLG(12) .Eq. 1)) GO TO 150 * Calculation of the unknown variables using the in i t i a l i z a t i o n * routines 11=0 12=0 GO TO (120,130,140) ITEq 120 CALL TIME(O.O.ITDUM) CALL IFVL(BETA,P,T,N,X,Y,Z,TC,PC,W,PP,KIJ,KEq,IFLG) CALL TIME(1,0,ITIMI) GO TO 200 130 CALL TIME(0,0,ITDUM) CALL IFLL(I0,I1,I2,BETA,P,T,N,X,Y,Z,TC,PC,W,PP,KIJ, + KEQ,IFLG) CALL TIME(1,0,ITIMI) GO TO 200 140 CALL TIME(0,0,ITDUM) CALL IFLLV(I0,I1,I2,BETA,ALPHA,P,T,N,Y,X1,X2,Z,TC,PC, + W,PP,KIJ,KEq,IFLG) CALL TIME(1,0,ITIMI) GO TO 200 * The i n i t i a l composition estimates are read from the data f i l e * when user supplied estimates are given 150 IF (IFLG(IO) .Eq. 1 .AND. IFLG(12) DO 190 1=1,N GO TO (160,170,180) ITEq 160 READ(5,*) Y(I),X(I) GO TO 190 170 READ(5,*) Y(I),X(I) GO TO 190 180 READ(5,*) Y(I),X1(I),X2(I) 190 CONTINUE 200 IF (ITEq .Eq. 1 .AND. IFLG(12) + .Eq. 1) BETA=ALPHA IF (ITEq .Eq. 1 .AND. IFLG(12) + .Eq. 0) BETA=ALPHA IF (ITEq .Eq. 2 .AND. IFLG(12) .Eq. + .Eq. 1) THEN DO 205 1=1,N Y(I)=X1(I) 205 CONTINUE END IF .EQ. 1) GO TO 200 EQ. 1 .AND. IFLG(IO) EQ. 0 .AND. IFLG(9) 1 .AND. IFLG(IO) * Printing of the i n i t i a l estimates GO TO (210,220,230) ITEQ 210 WRITE(6,580) T,P,BETA Appendix C. Description and listings of the computer programs 263 580 FORMAT(/4X,'VL FLASH INITIALIZATION',2X,'T=*,F8.3, ' K\ + 2X, 'P=' ,F8.3, ' atm',2X,'V/F=\F8.5/9X,'I',5X,'Z', + 9X,'Y',8X,'X') WRITE(6,590) (I,Z(I),Y(I),X(I), 1=1,N) GO TO 240 220 WRITE(6,600) T,P,BETA 600 FORMAT(/4X,*LL FLASH INITIALIZATION',2X,'T=',F8.3,' K', + 2X,'P=',F8.3,' atm',2X,'Ll/F=',F8.5/9X,'I',5X, + 'Z',8X,'XI',8X,'X2') WRITE(6,590) (I,Z(I),Y(I),X(I), 1=1,N) 590 F0RMAT(8X,I2,1X,F8.5,1X,F8.5,1X,F8.5) GO TO 240 230 WRITE(6,610) T,P,ALPHA,BETA 610 FORMAT(/4X,'VLL FLASH INITIALIZATION',2X,'T=',F8.3,' K', + 2X,'P=',F8.3,' atm'/30X,'V/F=',F8.5,3X,'Ll/F=',F8.5 + /9X,'I',5X,'Z',8X,'Y',8X,'XI',8X,'X2' ) WRITE(6,620) (I,Z(I),Y(I),X1(I),X2(I), 1=1,N) 620 F0RMAT(8X,I2,1X,F8.5,1X,F8.5,1X,F8.5,1X,F8.5) 240 IFLG(12)=1 WRITE(6,622) ITIMI 622 FORMAT(4X,'CPU TIME=',14,' msecs') * Isothermal flash calculation routines GO TO (250,250,260) ITEQ 250 CALL TIME(0,0,ITDUM) CALL FLASH2(ITEQ,EPS,ITMAX,ITNUM,IWEG,OBJ,N,P,T,BETA,X,Y,Z, + TC,PC,W,PP,KIJ,FUGCl,FUGC2,Zl,Z2,KEq,IFLG) CALL TIME(1,0,ITIMC) GO TO 270 260 CALL TIME(0,0,ITDUM) CALL FLASH3(EPS,ITMAX,ITNUM,IWEG,OB J,N,P,T,ALPHA,BETA,Y,X1, + X2,Z,TC,PC,W,PP,KIJ,ZED,FUGC1,FUGC2,FUGC3,IFLG) CALL TIME(1,0,ITIMC) * System's Gibbs energy of mixing calculation 270 CALL GIBBS(ITEq,N,P,T,ALPHA,BETA,Y.X,XI,X2,Z,TC,PC,W,PP,KIJ, + FUGC1,FUGC2,FUGC3,DG,IFLG) * Printing of results of calculation ONMAB=1.DO-ALPHA-BETA IF (ITEq .Eq. 2) THEN ZED(1)=0.D0 ZED(2)=Z1 ZED(3)=Z2 ELSE IF (ITEq .Eq. 1) THEN ZED(1)=Z1 ZED(2)=0.D0 ZED(3)=Z2 ENDIF WRITE(6,625) TYPEq 625 FORMAT (//15X,A10,2X,'CALCULATION RESULTS') WRITE(6,630) T,P,ITNUM,OB J,ALPHA,BETA,ONMAB,DG 630 F0RMAT(/4X,'T=',F8.3,* K*,2X,'P=',F8.3,' atm',2X, + 'NUM. ITER.=',I3,2X,'OBJ. FUNC.='.E12.5/ + 4X,*V/F='.F8.5.2X,'Ll/F='.F8.5.2X,'L2/F=\ + F8.5.2X,'DEL G='.F11.3,' cal/gmole') DO 280 1=1,N IF (ITEQ .EQ. 2) THEN K1(I)=1.D0 ELSE Appendix C. Description and listings of the computer programs Kl(I)=FUGC3(I)/FUGCl(l) END IF IF (ITEQ .EQ. 1) THEN K2(I)=1.D0 ELSE K2(I)=FUGC3(I)/FUGC2(I) END IF 280 CONTINUE IF (IFLG(3) .EQ. 1) THEN ZL2='ZLIQ2ext=* ELSE ZL2='ZLIQ2=' END IF IF (IFLG(2) .EQ. 1) THEN ZLl='ZLiqiext=' ELSE ZL1='ZLIQ1=' ENDIF IF (IFLG(l) .EQ. 1) THEN ZV='ZVAPext=' ELSE ZV='ZVAP=' END IF WRITE(6,640) ZV,ZED(1),ZL1,ZED(2),ZL2,ZED(3) 640 F0RMAT(4X,A8,F7.5,2X,A9,F7.5,2X,A9,F7.5) IF (IFLG(9) .EQ. 0) GO TO 290 IF (ITEQ .NE. 1 .AND. 10 .EQ.l) WRITE(6,650) 11,12 650 FORMAT(4X,'KEY C0MP.#1=',I2,2X,'KEY COMP.#2=',12, + 3X,'C0MP. CRITERION') IF (ITEq .NE. 1) WRITE(6,660) 11,12 660 FORMAT(4X,'KEY C0MP.#1=',I2,2X,'KEY COMP.#2=',12) 290 WRITE(6,670) 670 F0RMAT(/8X,'I',5X,'Z',8X,'Y',8X,'XI',7X,'X2',5X, + 'KV=Y/X2',2X,'KL=X1/X2') WRITE(6,680) (I,Z(I),Y(I),X1(I),X2(I),K1(I),K2(I), + 1=1,N) 680 F0RMAT(7X,I2,1X,F8.5,1X,F8.5,1X,F8.5,1X,F8.5,2X, + Gil.4,2X,Gil.4) WRITE(6,690) ITIMC 690 FORMAT(4X,'CPU TIME=*,14,' msecs') WRITE(6,700) ITIMI+ITIMC 700 FORMAT(/4X,'TOT CPU TIME=',I4,' msecs') WRITE(6,710) 710 FORMAT(/'================================================= ITOTIM=ITOTIM+ITIMI+ITIMC * End of loop for calculation at different compositions at fixed T * and P 295 CONTINUE 300 CONTINUE 305 CONTINUE * End of loop for calculation at fixed T and various P or at fixed * P and different T 310 CONTINUE WRITE(6,720) ITOTIM 720 F0RMAT(/4X,'GLOBAL CPU TIME=',I5,' msec'/) STOP END *************************************************** * * * IIldSVHd * * basvHd * * :Aq paxi^O * * * * OIHV * * OHM * * X * * tpaxi^o sauxqnojqns * * * * uoxq'ejaqx qsBd * * aijq ux z "bxi 1 0 PTnbTT 9XW I0J- ' S O ' B J J exoni jo joqoeA frX * * uoxq^jaqx qsBd * * aqq ux i 'btx Jo xnod^A eiiq J O J - S O B J I axon jo joqoaA £Y * * uoxq'ejaqx qs^d aqq ux uoxqounj qoaCqo aqq jo anx«A lf30 * * Z i PT n DTT .. .. .. ZS * * i -bxx J O J J O xnod^A auq J O J - S O B J J axom 1 0 nms XS * * uoxq^jaqx qs«d aiiq J O J joqoaA sqtreqsuoo nmxjqxxxnbg fX * * I< J O o> sx j / x i J O J / A upxuH J O J * * •sjaqx aAxssaoons jo jaqnmu aqq quuoo oq exqiexieA xojquoo gr * * 3/T1 *° d/A oq qoadsaj * * iqxa uoxqounj aoxn-pjojuo«n auq jo eAxq«AXjap x^T^J^d Od * * uoxqounj qoaCqo adXq aoxy-pjojtp'eH j * * d/11 -xo J/A oxq^j auq jo anx^A A\rejodmai 03 * * isaxqiexxBA ux'BH * * * * .. Z PT^TT •• •• ZZ * * (TI) T "bTT - 1 0 (1A) Jnod'BA aqq J O J joqosj A'qxxxqxssajdmoo XZ * * (TI) Z 'bTI Jo * * (TI) PT^TI 9VM- J 0 1 suoxqoBJi axora paq^xnox133 x ° JoqoaA £X * * (TI) T 'kxx JO * * (1A) Jnod-BA au;q J O J suoxqo'BJj axora paq'ex'113!'"83 I O JoqoaA TX * * quasajd ejaT[A sas-eqd eu;q * * ux quauodraoo up-ea J O J saouajajjxp Aqxa^eSnj aqq jo anx^A * * aqnxosqB aqq jo nms :uoxqounj BAxqoaCqo aqq jo anx^A f80 * * ( T I ) d/11 Jo (IA) i/A oxq*j as^ud JBIOU, VI33 * * baSVHd urej3ojd ux pauxjep SB 03M'20DflJ'TDOfld'HflNII * * qndqno- * * * * ( - O X B O n ) z "bTI * * J O J J O ( - 0 X ^ 0 IA) pxnbxx JOJ seq«raxqse uoxqo«jj axon zi * * ( - O X B O n ) x -bxx * * J O I J O (-ox183 1A) Jnod'BA aqq J O J saq'enixqsa uoxqoBJi exou. TX * * d/11 JO J/A oxq^j asBud auq 1 0 anxiBA x^T^T^I V133 * * II/IdSVHd urej2ojd ux pauxjap s« nx'dd'ft'Dd'Dl'Z'l'd'H'XVHII * * iD3SVHd tm»j2ojd ux pauxiap SB O l i l ' D3rtl' Sd3' b31I * * qndux- * * : sjaqaurejej * * * * -exjqxxxnba J O i\ J O J auop aq meo uoxq-exnox'eo * *  &m 'ajnssajd ptre emq-ejadraaq queqsuoo ye paqs^xj sx z uoxqxsoduoo * * X B tloiS w*T f l squauodnioo u jo ajnqxxra TB nana paqBux2xjo sasBud * * auq jo oxq«j asieud auq pme suoxqxsodnioo nmxjqxxxnbe auq aq^x^I^O * * resodjnj * * * ********************************************************************** * * * (HSVTd 1VHH3H10SI 3SVHd-3) SHSVTd 3NIinO*danS * * * ********************************************************************** 99Z suiviSoid idfnduioD ay 1) jo SSUT^SII puv uojiduosaQ xipuaddy Appendix C. Description and listings of the computer programs 266 SUBROUTINE FLASH2(ITEq,EPS,ITMAX,ITNUM,IWEG,OBJ,N,P,T, + BETA,X2,X1,Z,TC,PC,W,PP,KIJ,FUGC1, + FUGC2.Z1.Z2,KEq,IFLG) IMPLICIT REAL*8 (A-H.O-Z) REAL+8 KEq(20),KIJ(20,20),Kl(20) DIMENSION FUGC1(20),FUGC2(20),IFLG(0:20),PC(20),PP(20), + TC(20),W(20),X1(20),X2(20),X3(20),X4(20),Z(20), + APUR(20),BPUR(20) ITNUM=0 IFLG(4)=0 IFLG(13)=0 IC1=0 IC2=0 IC3=0 IC4=0 IC5=0 J3=0 Wl=O.DO * Calculation of the i n i t i a l K values when not available IF (IFLG(9) .Eq. 1 .AND. IFLG(IO) .Eq. 0 .OR. IFLG(18) .Eq. 1) + GO TO 5 CALL K(X2,Xl,TC,PC,W,PP,P,T,N,ITEq,3,APUR,BPUR,FUGCi, + FUGC2.Z1.Z2,KIJ,KEq,IFLG) * Start of the iterative cycle 5 ITNUM=ITNUM+1 L2=0 IF (ITNUM .GT. ITMAX) GO TO 170 * Calculation of beta with fixed K's using Newton's method DO 20 J=l,15 F=0.D0 F0=0.D0 DO 10 1=1,N RK4=BETA*(KEq(I)-1.DO)+1.DO F=F+Z(I)*(KEQ(I)-1.D0)/RK4 F0=F0-Z(I)*((KEq(I)-l.D0)/RK4)**2 10 CONTINUE IF (DABS(F) .LT. l.D-5) GO TO 30 B0=BETA-F/F0 BETA=B0 20 CONTINUE * Calculation of the LIMITING value of beta when not in the * interval [0,1] 30 IF (BETA .GE. O.DO .AND. BETA .LE. l.DO) GO TO 60 RK5=KEQ(1) DO 50 1=2,N IF (BETA .LT. O.DO) GO TO 40 IF (KEq(I) .LT. RK5) RK5=KEQ(I) GO TO 50 40 IF (KEq(I) .GT. RK5) RK5=KEq(I) 50 CONTINUE B3=1.D0/(1.D0-RK5) IF (BETA .LT. O.DO .AND. B3 .GT. O.DO) THEN BETA=-B3 GO TO 60 END IF Appendix C. Description and listings of the computer programs 267 IF (BETA .GT. O.DO .AND. B3 .LT. O.DO)THEN .LT. .GT. BETA=1.D0-B3 GO TO 60 END IF IF (BETA IF (BETA + 2.DO 60 IF (BETA J3=J3+1 ELSE J3=0 END IF 0. DO .AND. BETA .LT. B3) BETA=B3/2.D0 1. DO .AND. BETA .GT. B3) BETA=(1.D0+B3)/ LT. O.DO .OR. BETA .GT. l.DO) THEN * If the value of beta has been outside the interval [0,1] for * five consecutive iterations, the calculation ends indicating * the presence of only one phase IF (J3 .GE. 5) GO TO 180 * Calculation of the new compositions in both phases 70 SUM1=0.D0 SUM2=0.D0 DO 80 1=1,N X2(I)=Z(I)/(BETA*(KEq(I)-l.D0)+l.D0) IF (X2(I) .LT. O.DO) X2(I)=0.D0 Xl(I)=KEq(I)*X2(I) SUM1=SUM1+X1(I) SUM2=SUM2+X2(I) 80 CONTINUE DO 90 1=1,N X1(I)=X1(I)/SUM1 X2(I)=X2(I)/SUM2 90 CONTINUE * Starting in the third iteration Wegstein's method is used (optional) IF (IFLG(7) .Eq. 0 .OR. ITNUM .LT. 3) GO TO 110 IF (ITNUM .LE. 5 .AND. (BETA .LT. O.DO .OR. BETA .GT. + l.DO)) GO TO 110 IF (ITNUM .LT. IC1+IWEG) GO TO 110 IF (Wl .LE. -0.2D0) GO TO 100 IF (OBJ .GE. OBJL) GO TO 110 IF (OBJ .GT. 0.2D0) GO TO 110 100 CALL WEG(ITNUM,IC1,W1,0BJ,0BJL,N,X1,X3) CALL WEG(ITNUM,IC1,W1,OBJ,OBJL,N,X2,X4) * Calculation of the new K values 110 CALL K(X2,Xl,TC,PC,W,PP,P,T,N,ITEq,3,APUR,BPUR,FUGCl, + FUGC2.Z1.Z2,KIJ,KEQ,IFLG) * Calculation of the objective function 0BJL=0BJ OBJ=O.D0 DO 120 1=1,N OBJ=0BJ+DABS(FUGCl(I)*X1(I)-FUGC2(I)*X2(I)) 120 CONTINUE * Test for convergence IF (OBJ .LT. EPS) GO TO 160 Appendix C. Description and listings of the computer programs 268 * Calculation of the damping factor for Wegstein's method (optional) IF (IFLG(7) .EQ. 0 .OR. IFLG(8) .EQ. 0) GO TO 140 IF (ITNUM .LT. 3) GO TO 140 IF (L2 .Eq. 1) GO TO 140 CALL AMTO(OBJ,OBJL,L2,Wl,IC2,IC3,IC4,IC5) IF (IC5 .Eq. 0) GO TO 140 IC5=0 IC1=IC1-IWEG DO 130 1=1,N KEQ(I)=K1(I) 130 CONTINUE GO TO 70 * Storage of the last composition vector to be used in Wegstein's * method 140 DO 150 1=1,N Kl(I)=KEq(I) X3(I)=X1(I) X4(I)=X2(I) 150 CONTINUE GO TO 5 * Convergence is not allowed i f Wegstein's method has been applied in * the present iteration 160 IF (IC1 .EQ. ITNUM) GO TO 140 * Convergence: test to see i f two phases exist 170 IF (BETA .LT. O.DO .OR. BETA .GT. l.DO) GO TO 180 GO TO 200 * Feed composition outside the two phase region 180 DO 190 1=1,N X1(I)=Z(I) X2(I)=Z(I) 190 CONTINUE IFLG(12)=0 IF (BETA .LT. O.DO) BETA=0.DO IF (BETA .GT. l.DO) BETA=1.DO 200 RETURN END Appendix C. Description and listings of the computer programs ************************************************* * * * SUBROUTINE IFVL (INITIALIZATION FOR THE VL FLASH) * * * ********************************************************************** * * * Purpose: * * Provide i n i t i a l estimates of the vapour and liquid compositions * * as well as for the phase fraction V/F to i n i t i a l i z e the VL flash * * calculation * * * * Parameters: * * -Input * * P,T,N,Z,TC,PC,W,PP,KIJ as defined in program PHASEQ * * * * -Output * * ALPHA Estimated value of the ratio V/F * * X " mole fractions for the liquid * * Y . . . . .< •• .. v a p O U X * * KEQ Vector of i n i t i a l equilibrium constants * * * * Main variables: * * CI Vector of non-normalized vapour compositions * * C2 " " " liquid " * * PVAP Ratio of the vapour pressure to the total pressure * * SI Sum of the vapour compositions * * S2 liquid " * * * * Subroutines called: * * K * * * * Called by: * * PHASEQ * * * ********************************************************************** SUBROUTINE IFVL(ALPHA,P,T,N,X,Y,Z,TC,PC,W,PP,KIJ,KEq, + IFLG) IMPLICIT REAL+8 (A-H.O-Z) REAL+8 KEQ(20),KIJ(20,20) DIMENSION FUGCK20),FUGC2(20),IFLG(0:20),PC(20),PP(20), + TC(20),W(20),X(20),Y(20),Z(20),C1(20),C2(20), + APUR(20),BPUR(20) IFLG(4)=0 IFLG(13)=0 * Calculation of liquid and vapour compositions using Raoult's law SUM1=0.D0 SUM2=0.D0 DO 10 1=1,N PVAP=PC(I)*DEXP(5.3727D0*(i.D0+V(I))*(l.D0-TC(I)/T))/P C1(I)=Z(I)*PVAP C2(I)=Z(I)/PVAP SUM1=SUM1+C1(I) SUM2=SUM2+C2(I) 10 CONTINUE * Normalization of the calculated compositions DO 20 1=1,N Y(I)=C1(I)/SUM1 Appendix C. Description and listings of the computer programs 270 X(I)=C2(I)/SUM2 20 CONTINUE * Calculation of the i n i t i a l VL equilibrium constants CALL K(X,Y.TC,PC,W,PP,P,T,N,1,3,APUR,BPUR,FUGC1,FUGC2,Z1, + Z2,KIJ,KEQ,IFLG) * Calculation of the estimated value of alpha SUM1=0.D0 SUM2=0.D0 DO 30 1=1,N SUM1=SUM1+KEQ(I)*Z(I) SUM2=SUM2+(1.DO-KEQ(I))*Z(I)/(1.DO+KEQ(I)) 30 CONTINUE SUM1=1.D0-SUM1 SUM2=2.D0*SUM2 F=SUM2/(SUM2-SUM1) IF (F .GT. O.DO) THEN ALPHA=0.5D0*(1.DO-F) GO TO 50 END IF SUM3=0.D0 DO 40 1=1,N SUM3=SUM3+Z(I)/KEQ(I) 40 CONTINUE SUM3=SUM3-1.D0 ALPHA=(SUM2-0.5D0*SUM3)/(SUM2-SUM3) 50 IF (ALPHA .LT. 0.05D0) ALPHA=0.05D0 IF (ALPHA .GT. 0.95D0) ALPHA=0.95D0 RETURN END Appendix C. Description and listings of the computer programs 271 ********************************************************************** * SUBROUTINE IFLL (INITIALIZATION FOR THE LL FLASH) * * * * Purpose: * * Select the key components for liquid phases 1 and 2 and/or obtain * * the i n i t i a l composition values as well as the phase fraction Ll/F * * to start the LL flash calculation * * * * Parameters: * * -Input * * I0,I1,I2,P,T,H,Z,TC,PC,W,PP,KIJ as defined in program PHASEQ * * * * -Output * * II Key component for l i q . 1 * * 12 " " " " 2 * * BETA I n i t i a l estimate for the fraction Ll/F * * XI Mole fraction estimates for l i q . 1 * ^ 11 11 " " " 2 * * KEq LL equilibrium constants * * * * Main variables: * * 13 Temporary key component for l i q . 1 * ^ M M n H H 2 * K2 Matrix of the equilibrium cts. for a l l the binary pairs * * Ul Temporary value of the equilibrium ct. for the probable * * key component for l i q . 1 * * U2 Temporary value of the " " * * key component for l i q . 2 * * * * Subroutines called: * * K * * * * Called by: * * PHASEQ * * IFVLL * * * ****************************************************************** SUBROUTINE IFLL(I0,I1,I2,BETA,P,T,N,X2,X1IZ,TC,PC,W,PP, + KIJ,KEq,IFLG) IMPLICIT REAL*8 (A-H,0-Z) REAL*8 KEq(20),KIJ(20,20),K2(20,20) DIMENSION FUGC1(20),FUGC2(20),IFLG(0:20),PC(20),PP(20), + TC(20),W(20),X1(20),X2(20),Z(20),APUR(20), + BPUR(20) IFLG(4)=0 IFLG(13)=0 IF (II .NE. 0 .AND. 12 .NE. 0) GO TO 190 * Test to see i f there is more than one component with mole fraction * greater than 0.1 IC=0 DO 10 1=1,N IF (Z(I) .GT. 0.1D0) THEN J=I IC=IC+1 END IF 10 CONTINUE Appendix C. Description and listings of the computer programs 272 IF (IC .EQ. 1) THEN IP2=1 I2=J GO TO 80 END IF IF (II .NE. 0 .OR. 12 .NE. 0) GO TO 70 * Selection of key component for liquid 2 with the higher composition * criterion IF (10 .Eq. 0) GO TO 30 IC=0 C2=Z(1) 12=1 DO 20 1=2,N IF (Z(I) .LT. C2) GO TO 20 IF (C2 .Eq. Z(I)) THEN IC=IC+1 GO TO 20 END IF C2=Z(I) 12=1 IC=0 20 CONTINUE IF (IC .GT. 0) GO TO 30 GO TO 70 * Calculation of both key components 30 U1=1.D0 U2=1.D0 GO TO 150 40 CONTINUE Jl=l DO 60 J=2,N J1=J-1 IF (Z(J) .LE. 0.1D0) GO TO 60 DO 50 1=1,Jl IF (Z(I) .LE. 0.1D0) GO TO 50 IF (K2(J,I) .GT. Ul) THEN U1=K2(J,I) 13=1 END IF IF (l.D0/K2(J,I) .GT. Ul) THEN U1=1.D0/K2(J,I) 13=1 END IF IF (l.D0/K2(I,J) .GT. U2) THEN U2=1.D0/K2(I,J) I4=J END IF IF (K2(I,J) .GT. U2) THEN U2=K2(I,J) I4=J END IF 50 CONTINUE 60 CONTINUE IF (Ul .GT. U2) THEN 11=13 12=14 ELSE 11=14 12=13 Appendix C. Description and listings of the computer programs 273 END IF GO TO 190 * Calculation of one key component when the other is known 70 IP2=0 80 DO 90 1=1,N X1(I)=0.D0 X2(I)=0.D0 90 CONTINUE IF (12 .NE. 0) 14=12 IF (II .NE. 0) 14=11 U1=1.D0 X1(I4)=0.02D0 X2(I4)=0.98D0 DO 140 J=1,N IF (J .EQ. 14) GO TO 140 X2(J)=0.02D0 X1(J)=0.98D0 IF (N .EQ. 2) 13=J IF (J .EQ. 14+1) GO TO 130 IF (J .GT. 1) THEN X2(J-1)=0.D0 X1(J-1)=0.D0 END IF IF (IP2 .Eq. 1) GO TO 110 100 IF (Z(J) .LE. 0.1D0) GO TO 140 110 CALL K(X2,X1,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUGC1, + FUGC2.Z1.Z2,KIJ,KEq,IFLG) IF (KEq(J) .LT. Ul) GO TO 120 Ul=KEq(J) I3=J GO TO 140 120 IF (l.DO/KEq(J) .LT. Ul) GO TO 140 Ul=l.DO/KEq(J) I3=J GO TO 140 130 IF (J .GT. 2) THEN X2(J-2)=0.D0 X1(J-2)=0.D0 END IF GO TO 100 140 CONTINUE 12=14 11=13 GO TO 190 * Calculation of the LL equilibrium constants for a l l the binary * pairs 150 DO 160 1=1,N X1(I)=0.D0 X2(I)=0.D0 160 CONTINUE Jl=l DO 180 J=2,N X2(J1)=0.D0 X1(J1)=0.D0 J1=J-1 X2(J)=0.98D0 X1(J)=0.02D0 X2(J-1)=0.D0 X1(J-1)=0.D0 Appendix C. Description and listings of the computer programs 274 DO 170 1=1,Jl X1(I)=0.98D0 X2(I)=0.02D0 IF (I .GT. 1) THEN X1(I-1)=0.D0 X2(I-1)=0.D0 END IF CALL K(X2,X1,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUGC1, + FUGC2.Z1.Z2,KIJ,KEq,IFLG) K2(I,J)=KEq(J) K2(J,I)=KEq(I) 170 CONTINUE 180 CONTINUE GO TO 40 * Allocation of the mole fractions for both liquids according to * the calculated key components 190 DO 200 1=1, N X1(I)=0.D0 X2(I)=0.D0 200 CONTINUE X1(I1)=0.98D0 X2(I1)=0.02D0 X1(I2)=0.02D0 X2(I2)=0.98D0 IF (IFLG(14) .Eq. 1) THEN IFLG(14)=0 BETA=0.5D0 GO TO 210 END IF * Calculation of the i n i t i a l values of the LL flash equilibrium * constants CALL K(X2,X1,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUGC1, + FUGC2,Z1,Z2,KIJ,KEq,IFLG) * Calculation of the i n i t i a l value of beta BETA=(Z(Il)*(l.D0-l.D0/KEq(Il))+KEq(I2)*Z(I2))/ + (Z(I1)+Z(I2)) IF (BETA .LT. 0.05D0) BETA=0.05D0 IF (BETA .GT. 0.95D0) BETA=0.95D0 210 RETURN END Appendix C. Description and listings of the computer programs 275 *************************************************** * * * SUBROUTINE FLASH3 (3-PHASE ISOTHERMAL FLASH) * * * ********************************************************************** * * * Purpose: * * Calculate the equilibrium compositions and the phase ratios for * * the phases originated when a mixture of n components with global * * composition z is flashed at constant temperature and pressure. It * * is considered that a maximum of two liquid phases and a vapour * * exist (VLL c a l c ) , but the calculation can be reduced to VL or LL * * equilibrium * * * * Parameters: * * -Input * * ITEQ,EPS,IWEG,IFLG as defined in program PHASEQ * * ITMAX,N,P,T,Z,TC,PC,W,PP,KIJ as defined in program PHASPLIT * * ALPHA I n i t i a l value of the phase ratio V/F * * BETA " " " Ll/F * * XI Mole fraction estimates for the vapour * * X2 " " " " " l i q . 1 * ^ 11 " ** " " 11 2 * * * * -Output * * ITNUM,FUGC1,FUGC2,FUGC3,ZED as defined in program PHASEQ * * ALPHA Molar phase ratio V/F * * BETA " " " Ll/F * * OBJ Value of the objective function: sum of the absolute * * value of the fugacity differences for each component in * * the phases where present * * XI Vector of calculated mole fractions for the vapour * * X2 " " " " " " l i q . 1 * * X3 " " " " " " " 2 * * * * Main variables: * * AO Temporary value of V/F * * BO " " " Ll/F * * D Determinant for the Rachford-Rice derived system of * * equations used in the Newton-Raphson solution * * E1,E3 Partial derivatives of Gl and G2 with respect to V/F * * E2.E4 " " " V ' " " Ll/F * * Gl Rachford-Rice type function (eqn. 3.115) * * G2 " " " ( " 3.116) * * II Key component for l i q . 1 * * 12 " " " " 2 * * J3 Counter for the number of successive iterations in which * * V/F<0 or V/F>1 * * J4 Counter for the " " " * * L1/F<0 or L1/F>0 * * J5 Counter for the " " " " " " * * 1-V/F-L1/F<0 or 1-V/F-L1/F>0 * * Kl Vector of the VL2 equilibrium constants * * K2 " " " L1L2 " " * * K3 VL2 " " in the past itern. * * K4 ' L1L2 " ' " " * * OBJL Value of the objective function in the past iteration * * * * Subroutines called: * * K * * WEG * * AMTO * Appendix C. Description and listings of the computer programs 276 * * * Called by: * * PHASEQ * * PHASPLIT * * * ************************************************* SUBROUTINE FLASH3(EPS,ITMAX,ITNUM,IWEG,OBJ,N,P,T,ALPHA, + BETA,X1,X2,X3,Z,TC,PC,W,PP,KIJ,ZED, + FUGC1,FUGC2,FUGC3,IFLG) IMPLICIT REAL+8 (A-H.O-Z) REAL*8 KEq(20),KIJ(20,20),K1(20),K2(20),K3(20),K4(20) DIMENSION ZED(3),FUGC1(20),FUGC2(20),FUGC3(20),FUGC4(20), + IFLG(0:20),PC(20),PP(20),TC(20),W(20),X0(20), + Xl(20),X2(20),X3(20),X4(20),X5(20),X6(20), + Z(20),APUR(20),BPUR(20) ITNUM=0 ITEQ=3 IFLG(4)=0 IFLG(13)=i IC1=0 IC2=0 IC3=0 IC4=0 IC5=0 J3=0 J4=0 J5=0 J6=0 W1=0.D0 * Assignment of key components for the two liquids from their i n i t i a l * compositions 11=1 12=1 H1=X2(1) H2=X3(1) DO 10 1=2,N IF (X3(I) .GT. H2) THEN 12=1 H2=X3(I) ELSE IF (X2(I) .GT. HI) THEN 11=1 H1=X2(I) END IF 10 CONTINUE * Calculation of the i n i t i a l VL and LL K values IF (IFLG(18) .Eq. 1) GO TO 305 GO TO 300 * Start of the iterative cycle 20 ITNUM=ITNUM+1 L2=0 IF (ITNUM .GT. ITMAX) GO TO 410 SUM=0.D0 * Storage of the last composition vector to be used in Wegstein's * method Appendix C. Description and listings of the computer programs 277 DO 30 1=1,N K3(I)=K1(I) K4(I)=K2(I) X4(I)=X1(I) XE(I)=X2(I) X6(I)=X3(I) SUM=SUM+DABS(K2(I)-1.DO) 30 CONTINUE * If the LL K values are near unity, one of the liquid phases is * eliminated IF (SUM .LT. N+0.001D0 .AND. ITEQ .Eq. 3) THEN BETA=0.D0 ITEq=l J3=0 J4=0 J5=0 IFLG(13)=0 END IF A0=ALPHA B0=BETA * Calculation of V/F and/or Ll/F with VL and LL K'S fixed using * a Newton-Raphson method DO 80 J=1,1S G1=0.D0 G2=0.D0 E1=0.D0 E2=0.D0 E3=0.D0 E4=0.D0 IF (ITEQ .Eq. 1) THEN E4=1.D0 E3=0.D0 ELSE IF (ITEq .Eq. 2) THEN E1=1.D0 E2=0.D0 END IF IF (J6 .Eq. 1) BETA=1.DO-ALPHA DO 50 1=1,N E5=(BETA*K2(I)+1.DO-BETA-ALPHA+ALPHA*K1(I))**2 IF (E5 .Eq. O.DO) GO TO 50 IF (ITEq .Eq. 2) GO TO 40 Gl=Gl+Z(I)*(l.D0-Kl(I))/DSqRT(E5) E1=E1+Z(I)*(1.D0-K1(I))**2/E5 IF (ITEq .NE. 3) GO TO 40 E2=E2+Z(I)*(1.D0-K1(I))*(1.D0-K2(I))/E5 40 IF (ITEq .Eq. 1) GO TO 50 G2=G2+Z(I)*(1.D0-K2(I))/DSQRT(E5) E4=E4+Z(I)*(1.D0-K2(I))**2/E5 IF (ITEQ .NE. 3) GO TO 50 E3=E2 50 CONTINUE IF (DABS(G1)+DABS(G2) .LT. l.D-7) GO TO 90 D=E1*E4~E2*E3 IF (DABS(D) .EQ. O.DO) GO TO 90 IF (ITEq .Eq. 2) GO TO 60 A0=ALPHA+(G2*E2-G1*E4)/D IF (ITEq .Eq. 1) GO TO 70 60 B0=BETA+(G1*E3-G2*E1)/D 70 ALPHA=AO Appendix C. Description and listings of the computer programs BETA=BO IF (DABS(D) .LT. l.D-9) GO TO 90 80 CONTINUE * If more than one phase indicator is outside the interval [0,1], the * phase with greater tendency to disappear is found 90 IF (ITEQ .NE. 3) GO TO 130 IF (ALPHA .LT. O.DO .AND. (BETA .LT. O.DO .OR. BETA .GT. + l.DO)) THEN J4=J4-1 J3=J3+1 END IF 0NMAB=1.DO-ALPHA-BETA IF (ALPHA .LT. O.DO .AND. (ONMAB .LT. O.DO .OR. ONMAB .GT. + l.DO)) THEN J5=J5-1 J3=J3+1 END IF IF (ALPHA .LE. l.DO .OR. BETA .GE. O.DO .OR. ONMAB .GE. + O.DO) GO TO 110 S7=0.D0 S8=0.D0 DO 100 1=1,N S7=S7+X2(I)*FUGC2(I) S8=S8+X3(I)*FUGC3(I) 100 CONTINUE IF (S7 .GT. S8) THEN J5=J5-1 ELSE J4=J4-1 END IF * Limitation of the calculated values of V/F and/or Ll/F when * outside the interval [0,1] to avoid calculation of negative * mole fractions 110 IF (ITEQ .NE. 3) GO TO 130 IF (ALPHA .GT. l.DO .OR. ALPHA .LT. O.DO) CALL LIMAB(N, + Kl,ALPHA) B5=0.D0 DO 120 1=1,N IF (K2(I) .EQ. l.DO) GO TO 125 B3=(ALPHA*(1.D0-K1(I))-1.D0)/(K2(I)-1.D0) IF (BETA .GT. O.DO .AND. B3 .GT. O.DO .AND. BETA .GT. + B3 .AND. (B3 .LT. B5 .OR. B5 .Eq. O.DO)) B5=B3 IF (BETA .LT. O.DO .AND. B3 .LT. O.DO .AND. BETA .LT. + B3 .AND. (B3 .GT. B5 .OR. B5 .Eq. O.DO)) B5=B3 120 CONTINUE 125 IF (B5 .Eq. O.DO) GO TO 160 IF (BETA .GT. O.DO .AND. BETA .GT. B5 .AND. B5 .GE. 1.DO) + BETA=1.D0+(B5-1.D0)/2.D0 IF (BETA .GT. O.DO .AND. BETA .GT. B5 .AND. B5 .LT. l.DO) + BETA=B5-0.005D0 IF (BETA .LT. O.DO .AND. BETA .LT. B5) BETA=B5/2.D0 GO TO 160 130 IF (ITEq .Eq. 2) GO TO 140 IF (ALPHA .GT. O.DO .AND. ALPHA .LT. l.DO) THEN J3=0 GO TO 140 ELSE J3=J3+1 END IF Appendix C. Description and listings of the computer programs 279 CALL LIMAB(N,K1,ALPHA) 140 IF (ITEQ .Eq. 1) GO TO 170 IF (BETA .GT. O.DO .AND. BETA .LT. l.DO) THEN J4=0 GO TO 150 ELSE J4=J4+1 END IF CALL LIHAB(N,K2,BETA) 150 IF (ITEQ .Eq. 1) GO TO 170 0NMAB=1.DO-ALPHA-BETA IF (ONMAB .LE. O.DO .OR. ONMAB .GE. l.DO) THEN J5=J5+1 ELSE J5=0 END IF GO TO 170 160 IF (ALPHA .LE. O.DO .OR. ALPHA .GE. l.DO) THEN J3=J3+1 ELSE J3=0 END IF IF (BETA .LE. O.DO .OR. BETA .GE. l.DO) THEN J4=J4+1 ELSE J4=0 END IF 0NMAB=1.DO-ALPHA-BETA IF (ONMAB .LE. O.DO .OR. ONMAB .GE. l.DO) THEN J5=J5+1 ELSE J5=0 END IF * If the value of V/F, Ll/F or L2/F has been outside the interval * [0,1] for five consecutive iterations, the corresponding phase * is eliminated 170 IF (ALPHA .LE. O.DO .AND. J3 .GE. 5 .AND. ITEq .EQ. 1) + GO TO 390 IF (.NOT. (ALPHA .LE. O.DO .AND. J3 .GE. 5 .AND. ITEQ .NE. + D) GO TO 190 * Elimination of the vapour phase ALPHA=0 J3=0 J4=0 J5=0 ITEQ=2 L2=l IFLG(13)=0 IC1=ITNUM-1 W1=0.D0 IF (BETA .GT. O.DO .AND. BETA .LT. l.DO) GO TO 240 DO 180 1=1, N X3(I)=0.D0 X2(I)=0.D0 180 CONTINUE X2(I1)=0.98D0 X2(I2)=0.02D0 X3(I2)=0.98D0 Appendix C. Description and listings of the computer programs 280 X3(I1)=0.02D0 BETA=0.5D0 GO TO 300 * Elimination of liquid 1 190 IF (J4 .GE. 5 .AND. BETA .LE. O.DO) THEN BETA=0.D0 ITEQ=1 J3=0 J4=0 J5=0 IFLG(13)=0 GO TO 220 END IF * Elimination of liquid 2 IF (J5 .GE. 5 .AND. 1.DO-ALPHA-BETA .LE. O.DO) THEN J6=l BETA=1.DO-ALPHA ITEq=l J3=0 J4=0 J5=0 IFLG(13)=0 GO TO 200 END IF * Feed composition in the one phase region. The calculation ends IF (J3 .GE. 5 .AND. ALPHA .GE. l.DO) THEN ALPHA=1.D0 GO TO 390 ELSE IF (J4 .GE. 5 .AND. BETA .GE. l.DO) THEN BETA=1.DO GO TO 390 ELSE IF (J5 .GE. 5 .AND. 1.DO-ALPHA-BETA .GE. l.DO) THEN GO TO 390 END IF GO TO 240 200 DO 210 1=1,N X3(I)=X2(I) K1(I)=K1(I)/K2(I) K3(I)=K3(I)/K4(I) X6(I)=X5(I) 210 CONTINUE 220 IC1=ITNUM-1 L2=l W1=0 IF (ALPHA .GT. l.DO) ALPHA=0.98 DO DO 230 1=1,N K2(I)=1.D0 230 CONTINUE * Calculation of the new compositions in the 3 phases 240 S0=0.D0 S1=0.D0 S2=0.D0 DO 260 1=1, N X3(I)=Z(I)/(BETA*K2(I)+1.D0-ALPHA-BETA+ALPHA*K1(I)) IF (X3(I) .LT. O.DO) X3(I)=0.D0 S2=S2+X3(I) Appendix C. Description and listings of the computer programs 281 IF (ITEQ .Eq. 1) GO TO 250 X2(I)=X3(I)*K2(I) S1=S1+X2(I) 250 IF (ITEQ .Eq. 2) GO TO 260 X1(I)=X3(I)*K1(I) S0=S0+X1(I) 260 CONTINUE DO 280 1=1, N X3(I)=X3(I)/S2 IF (ITEq .Eq. 1) GO TO 270 X2(I)=X2(I)/S1 270 IF (ITEq .Eq. 2) GO TO 280 X1(I)=X1(I)/S0 280 CONTINUE * Starting in the third iteration Wegstein's method is used (optional) IF (IFLG(7) .Eq. 0 .OR. ITNUM .LT. 3) GO TO 300 0NMAB=1.DO-ALPHA-BETA IF (BETA .LT. O.DO .OR. BETA .GT. l.DO .OR. ALPHA .LT. + O.DO .OR. ALPHA .GT. l.DO .OR. ONMAB .LT. O.DO .OR. + ONMAB .GT. l.DO) GO TO 300 IF (ITNUM .LT. IC1+IWEG) GO TO 300 IF (Wl .LE. -0.2D0) GO TO 290 IF (OBJ .GE. OBJL) GO TO 300 IF (OBJ .GT. 0.8D0) GO TO 300 290 CALL WEG(ITNUM,IC1,W1,OBJ,OBJL,N.X3.X6) IF (ITEq .NE. 1) CALL WEG(ITNUM,IC1,W1,OBJ,OBJL,N.X2.X5) IF (ITEq .NE. 2) CALL WEG(ITNUM,IC1,W1,OBJ,0BJL,N,X1,X4) 300 IF (ITEQ .NE. 3) GO TO 320 * Calculation of the new values of K's IFLG(1)=0 IFLG(2)=0 IFLG(3)=0 IFLG(16)=0 CALL K(X0,X1,TC,PC,W,PP,P,T,N,1,3,APUR,BPUR,FUGC1,FUGC4, + Zl.ZO,KIJ,KEQ,IFLG) CALL K(X0,X2,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUGC2,FUGC4, + Z2.Z0,KIJ,KEq,IFLG) IF (IFLG(2) .Eq. 1) THEN IFLG(2)=0 IFLG(16)=1 END IF CALL K(X0,X3,TC,PC,W,PP,P,T,N,2,3,APUR,BPUR,FUGC3,FUGC4, + Z3.Z0,KIJ,KEq,IFLG) IF (IFLG(2) .Eq. 1) THEN IFLG(2)=0 IFLG(3)=1 END IF IF (IFLG(16) .Eq. 1) IFLG(2)=1 305 DO 310 1=1,N K1(I)=FUGC3(I)/FUGC1(I) K2(I)=FUGC3(I)/FUGC2(I) 310 CONTINUE GO TO 340 320 IF (ITEq .Eq. 2) GO TO 330 CALL K(X3,Xl,TC,PC,W,PP,P,T,N,ITEq,3,APUR,BPUR,FUGCl, + FUGC3,Z1,Z3,KIJ,Kl,IFLG) GO TO 340 330 IF (ITEq .Eq. 1) GO TO 340 CALL K(X3,X2,TC,PC,W,PP,P,T,N,ITEq,3,APUR,BPUR,FUGC2, Appendix C. Description and listings of the computer programs 282 + FUGC3.Z2.Z3,KIJ,K2,IFLG) 340 IF (ITNUM .EQ. 0) GO TO 20 * Calculation of the objective function 0BJL=0BJ 0BJ=0.D0 S5=0.D0 S6=0.D0 DO 360 1=1,N IF (ITEQ .Eq. 2) GO TO 350 S5=S5+DABS(FUGC1(I)*X1(I)-FUGC3(I)*X3(D) IF (ITEQ .Eq. 1) GO TO 360 350 S6=S6+DABS(FUGC2(I)*X2(I)-FUGC3(I)*X3(I)) 360 CONTINUE 0BJ=S5+S6 * Convergence test IF (OBJ .LT. EPS) GO TO 380 * Calculation of the damping factor for Wegstein's method (optional) IF (IFLG(7) .Eq. 0 .OR. IFLG(8) .Eq. 0) GO TO 20 IF (ITNUM .LT. 3) GO TO 20 0NMAB=1.DO-ALPHA-BETA IF (BETA .LT. O.DO .OR. BETA .GT. l.DO .OR. ALPHA .LT. + O.DO .OR. ALPHA .GT. l.DO .OR. ONMAB .LT. O.DO -OR. + ONMAB .GT. l.DO) GO TO 20 IF (L2 .Eq. 1) GO TO 20 CALL AMTO(OBJ,OBJL,L2,Wl,IC2,IC3,IC4,IC5) IF (IC5 .Eq. 0) GO TO 20 IC5=0 IC1=IC1-IWEG DO 370 1=1,N K1(I)=K3(I) IF (ITEQ .NE. 1) K2(I)=K4(I) 370 CONTINUE GO TO 240 380 IF (ITEq .Eq. 3 .AND. (BETA .LE. O.DO .OR. 1.DO-ALPHA-BETA + .LE. O.DO)) GO TO 20 * Convergence is not allowed i f Wegstein's method has been applied IF (IC1 .Eq. ITNUM) GO TO 20 * Convergence: test for the existence of 3 phases 390 IF (ALPHA .GE. l.DO) THEN ALPHA=1.D0 BETA=0.DO ELSE IF (ALPHA .LE. O.DO) THEN ALPHA=O.DO END IF IF (BETA .GE. l.DO) THEN BETA=l.DO ALPHA=O.DO ELSE IF (BETA .LE. O.DO) THEN BETA=O.DO END IF 0NMAB=1.DO-ALPHA-BETA IF (ONMAB .LE. O.DO) BETA=1.DO-ALPHA IF (BETA .LE. O.DO .OR. BETA .GE. l.DO .OR. ALPHA .LE. Appendix C. Description and listings of the computer programs 283 + O.DO .OR. ALPHA .GE. l.DO .OR. ONMAB .LE. O.DO .OR. + ONMAB .GE. l.DO) IFLG(12)=0 DO 400 1=1,N IF (ALPHA .Eq. l.DO) THEN X1(I)=Z(I) X2(I)=0.D0 X3(I)=0.D0 ELSE IF (BETA .Eq. l.DO .OR. ONMAB .Eq. l.DO) THEN X1(I)=0.D0 X2(I)=0.D0 X3(I)=Z(I) END IF IF (ALPHA .Eq. O.DO) X1(I)=0.D0 IF (BETA .EQ. O.DO .OR. ONMAB .Eq. O.DO) X2(I)=0.D0 400 CONTINUE 410 IFLG(13)=0 ZED(1)=Z1 ZED(2)=Z2 ZED(3)=Z3 RETURN END * SUBROUTINE FOR LIMITING V/F OR Ll/F AS IN A 2 PHASE CALCULATION SUBROUTINE LIMAB(N,RK3,C) IMPLICIT REAL*8 (A-H.O-Z) DIMENSION RK3(20) RK7=RK3(1) DO 20 1=2,N IF (C .LT. O.DO) GO TO 10 IF (RK3(I) .LT. RK7) RK7=RK3(I) GO TO 20 10 IF (RK3(I) .GT. RK7) RK7=RK3(I) 20 CONTINUE C3=1.D0/(1.D0-RK7) IF (C .LT. O.DO .AND. C3 .GT. O.DO) THEN C=-C3 GO TO 30 ELSE IF (C .GT. O.DO .AND. C3 .LT. O.DO) THEN C=1.D0-C3 GO TO 30 END IF IF (C .LT. O.DO .AND. C .LT. C3) C=C3/2.D0 IF (C .GT. l.DO .AND. C .GT. C3) C=(l.D0+C3)/2.D0 30 RETURN END Appendix C. Description and listings of the computer programs 284 ***************************************** * * * SUBROUTINE IFVLL (INITIALIZATION FOR THE VLL FLASH) * * * ********************************************************************** * * * Purpose: * * Obtain the key components for the liquid phases and/or provide * * composition estimates for the vapour and both liquids as well as * * estimates for the phase fractions V/F and Ll/F to i n i t i a l i z e the * * VLL flash calculation * * * * Parameters: * * -Input * * I0,I1,I2,P,T,N,Z,TC,PC,W,PP,KIJ as defined in program PHASEQ * * * * -Output * * ALPHA Estimated value of the ratio V/F * * BETA " Ll/F * * II Key component for l i q . 1 * * 2^ 11 M " " 11 * * Y Mole fraction estimates for the vapour * * XI " " " " l i q . 1 * * X2 " " " " " 2 * * * * Main variables: * * SI Sum of the mole fractions for the vapour * * PVAP Ratio of the vapour pressure to the total pressure * * * * Subroutines called: * * IFLL * * * * Called by: * * PHASEQ * * * ********************************************************************** SUBROUTINE IFVLL(I0,I1,I2,BETA,ALPHA,P,T,N,Y,X1,X2,Z, + TC,PC,W,PP,KIJ,IFLG) IMPLICIT REAL*8 (A-H.O-Z) REAL+8 KEQ(20),KIJ(20,20) DIMENSION IFLG(0:20),PC(20),PP(20),TC(20),W(20),X1(20), + X2(20),Y(20),Z(20),C1(20) IF (II .NE. 0 .AND. 12 .NE. 0) GO TO 10 IFLG(14)=1 * Assignment of key components for both liquids when not known CALL IFLL(I0,I1,I2,BETA,P,T,N,X2,X1,Z,TC,PC,W,PP,KIJ,KEQ, + IFLG) GO TO 30 * Allocation of mole fractions for both liquids with the key component * criterion * 10 DO 20 1=1,N X1(I)=0.D0 X2(I)=0.D0 20 CONTINUE X1(I1)=0.98D0 X2(I1)=0.02D0 X1(I2)=0.02D0 Appendix C. Description and listings of the computer programs 285 X2(I2)=0.98D0 30 BETA=0.5D0 * Calculation of the vapour i n i t i a l composition SUM1=0.D0 DO 40 1=1, H PVAP=PC(I)*DEXP(5.3727D0*(1.DO+W(I))*(1.DO-TC(I)/T))/P C1(I)=Z(I)*PVAP SUM1=SUM1+C1(I) 40 CONTINUE DO 50 1=1,H Y(I)=C1(I)/SUM1 50 CONTINUE * Calculation of the i n i t i a l values of alpha and beta ALPHA=(Z(II)-BETA*X1(II)-X2(I1)*(1.DO-BETA))/ + (Y(I1)-BETA*X1(I1)-X2(I1)*(1.DO-BETA)) BETA=BETA*(1.DO-ALPHA) IF (ALPHA .LT. 0.05D0) ALPHA=0.05D0 IF (ALPHA .GT. 0.95D0) ALPHA=0.95D0 IF (BETA .LT. 0.05D0) BETA=0.05D0 IF (BETA .GT. 0.95D0) BETA=0.95D0 RETURN END Appendix C. Description and listings of the computer programs 286 **************************************************** * * * SUBROUTINE WEG (WEGSTEIN'S METHOD TO OBTAIN NEW COMPOSITIONS) * * * ********************************************************************** * * * Purpose: * * Calculate new compositions for a single phase using Wegstein's * * acceleration method * * * * Parameters: * * -Input * * IC1 Iteration number in which Wegstein's method was last used * * ITNUM " " " the flash calculation * * Wl Damping or acceleration factor * * OBJ Value of the objective function in the flash * * OBJL " " " previous iteration * * N Number of components * * Xi Mole fractions for a given phase * * X2 " " " " " " in the previous iteration * * * * -Output * * Wl New value of the acceleration factor (W1>0). If i t ' s * * input value is for damping (-0.6<=Wl<=-0.2) i t is not * * modified * * XI Mole fractions calculated with Wegstein's method * * * * Subroutines called: * * none * * * * Called by: * * FLASH2 * * FLASH3 * * * ********************************************************************** SUBROUTINE WEG(ITNUM,IC1,Wl,OBJ,OBJL,N,XI,X2) IMPLICIT REAL*8 (A-H.O-Z) DIMENSION X1(20),X2(20) IC1=ITNUM IF (Wl .GE. O.DO) W1=0BJ/(0BJL-0BJ) * Calculation of the new composition SUM=O.DO DO 10 1=1,N X1(I)=X1(I)+W1*(X1(I)-X2(D) IF (X1(I) .LT. O.DO) X1(I)=0.D0 SUM=SUM+X1(I) 10 CONTINUE DO 20 1=1, N X1(I)=X1(I)/SUM 20 CONTINUE RETURN END Appendix C. Description and listings of the computer programs 287 * SUBROUTINE AMTO (DAMPING FACTOR CALCULATION) * * * * * * * * * * * * % * * % * * * * * * * * * * * * * * * * * * t * * * % * * % * 4 t * * * * * * * * * * * * * * * * * % * * * * * * * * * * * * * Purpose: * * Obtain the damping factor used in Wegstein's method * * * * Parameters: * * -Input * * OBJ,OBJL as described in subroutine WEG * * IC2,IC3,IC4,IC5 are control variables * * * * -Output * * L2 Control variable: 0=no damping in the present iteration; * * l=damping in the present iteration * * Wl Damping factor when the objective function increases * * significantly with respect to the last iteration * * * * Subroutines called: * * none * * * * Called by: * * FLASH2 * * FLASH3 * * * SUBROUTINE AMTO(OBJ,OBJL,L2,Wl,IC2,IC3,IC4,IC5) IMPLICIT REAL+8 (A-H.O-Z) W2=(0BJL-0BJ)/0BJ IF (W2 .LT. -0.6D0) W2=-0.6D0 IF (W2 .LE. -0.2D0) W1=W2 IF (W2 .LE. -0.2D0 .AND. IC4 .EQ. 0) THEN 104=1 ELSE GO TO 10 END IF IC2=7-IC3 IC3=IC3+2 IF (IC2 .LT. 1) IC2=1 10 IF (W2 .GT. -0.2D0 .AND. OBJ .GT. IC2*0.001D0) GO TO 20 IF (Wl .LT. -0.2D0 .AND. OBJ .GT. IC2+0.001D0) THEN L2=L2+1 IC5=1 ELSE W1=0.D0 IC4=0 END IF 20 RETURN END Appendix C. Description and listings of the computer programs ************************************************* * * * SUBROUTINE GIBBS (GIBBS ENERGY OF MIXING CALCULATION) * * * ********************************************************************** * * * Purpose: * * Calculate the Gibbs energy of mixing for a system of n components * * with a global composition z at a given temperature and pressure; * * the system may be VLL, LL, VL, L or V * * * * Parameters: * * -Input * * ITEQ,FUGC1,FUGC2,FUGC3 as defined in program PHASEQ * * ALPHA,BETA,N,P,T,Z,TC,PC,W,PP,KIJ as defined in program PHASPLIT * * Y Mole fractions for the vapour (VL or VLL calc.) or for * * l i q . 1 (LL calc.) * * X Mole fractions for the liquid (VL calc.) or for l i q . 2 * * (LL calc.) * * XI Mole fractions for l i q . 1 (VLL calc.) * £ " " ** 14 2 " * * * * -Output * * DG Gibbs energy of mixing (cal/gmole) * * Y Mole fractions for the vapour * * XI " " " l i q . 1 * * X2 " " " " 2 (the only l i q . in VL calc.) * * * * Main variables: * * PR Reference pressure (1 atm) * * R Universal gas constant (1.987 cal/gmole K) * * SI Gibbs energy of mixing for the vapour (cal/gmole) * * S2 " v " liquid 1 " * ^ 23 " n n ** " M 2 * * * * Subroutines called: * * K * * * * Called by: * * PHASEQ * * * ********************************************************************** SUBROUTINE GIBBS(ITEQ,N,P,T,ALPHA,BETA,Y,X,X1,X2,Z,TC,PC, + W,PP,KlJ,FUGC1,FUGC2,FUGC3,DG,IFLG) IMPLICIT REAL*8 (A-H,0-Z) REAL+8 KEq(20),KIJ(20,20) DIMENSION FUGCK20),FUGC2(20),FUGC3(20),FUGC4(20),PC(20) , + PP(20),TC(20),W(20),X(20),X0(20),X1(20),X2(20), + Y(20),Z(20),IFLG(0:20),APUR(20),BPUR(20),RM1(20), + RM2(20),RM3(20) * Assignment of the reference pressure and the phase indicators PR=1.D0 R=1.987D0 IF (BETA .EQ. l.DO .AND. ITEq .Eq. 2) BETA=0.DO IF (ITEq .Eq. 3 .AND. 1.DO-ALPHA-BETA .Eq. O.DO .AND. + BETA .NE. O.DO) BETA=0.DO IF (ITEq .EQ. 1) THEN ALPHA=BETA BETA=O.DO Appendix C. Description and listings of the computer programs 289 END IF IF (ITEQ .Eq. 2) ALPHA=O.DO * Calculation of the fugacity coefficients when only one liquid phase * is present IFLG(13)=1 IF (.NOT. (ALPHA .Eq. O.DO .AND. (BETA .Eq. O.DO .OR. + BETA .Eq. l.DO))) GO TO 20 CALL K(XO,Z.TC,PC,W,PP,P,T,N,2,1,APUR,BPUR,FUGC3,FUGC4, + Z3.Z0,KIJ,KEq,IFLG) DO 10 1=1,N Y(I)=0.D0 X1(I)=0.D0 X2(I)=Z(I) 10 CONTINUE GO TO 60 * Calculation of the fugacity coefficients when only a vapour phase * is present 20 IF (ALPHA .Eq. l.DO .AND. BETA .Eq. O.DO) THEN CALL K(X0,Z.TC,PC,W.PP.P.T.N,1,1,APUR,BPUR,FUGC1.FUGC4, + Z1,Z0,KIJ,KEq,IFLG) ELSE GO TO 40 END IF DO 30 1=1,N Y(I)=Z(I) X1(I)=0.D0 X2(I)=0.D0 FUGC3(I)=FUGC2(I) 30 CONTINUE GO TO 60 * Assignment of the variables according to the printing format 40 DO 50 1=1,N IF (ITEq .Eq. 1) THEN X2(I)=X(I) FUGC3(I)=FUGC2(I) X1(I)=0.D0 FUGC2(I)=0.D0 ELSE IF (ITEq .Eq. 2) THEN X1(I)=Y(I) X2(I)=X(I) FUGC3(I)=FUGC2(I) FUGC2(I)=FUGC1(I) Y(I)=0.D0 FUGC1(I)=0.D0 END IF 50 CONTINUE * Calculation of the Gibbs energy for each phase 60 S1=0.D0 S2=0.D0 S3=0.D0 0NMAB=1.DO-ALPHA-BETA DO 90 1=1,N IF (Z(I) .Eq. O.DO) GO TO 90 IF (ONMAB .NE. O.DO) THEN RM3(I)=R*T*DL0G(FUGC3(I)*X2(I)*P/PR) ELSE Appendix C. Description and listings of the computer programs 290 GO TO 70 END IF S3=S3+X2(I)*RM3(I) 70 IF (BETA .NE. O.DO) THEN RM2(I)=R*T*DL0G(FUGC2(I)*X1(I)*P/PR) ELSE GO TO 80 END IF S2=S2+X1(I)*RM2(I) 80 IF (ALPHA .NE. O.DO) THEN RM1(I)=R*T*DL0G(FUGC1(I)*Y(I)*P/PR) ELSE GO TO 90 END IF S1=S1+Y(I)*RM1(I) 90 CONTINUE * Calculation of the system's total Gibbs energy (cal/gmole) DG=ALPHA*S1+BETA*S2+0NMAB*S3 IFLG(13)=0 RETURN END Appendix C. Description and listings of the computer programs 291 ********************************************************************** * * * SUBROUTINE K (EQUILIBRIUM CONSTANTS CALCULATION) * * * ******************************************************************* * * * Purpose: * * Calculate the fugacity coefficients for a l l components in both * * phases for VL and LL equilibria as well as the corresponding * * equilibrium constants. For VLL equilibria only the fugacity * * coefficients are calculated for a given phase each time the * * subroutine is called. The Soave-Redlich-Kwong or the Peng-Robinson * * equations of state are used to evaluate the thermodynamic * * properties * * * * Parameters: * * -Input * * TC,PC,W,PP,P,T,N,KIJ,IFLG as defined in program PHASPLIT * * X Mole fractions vector; for VL equilibria corresponds to * * the liquid comp., for LL to liquid 2 and for VLL is a * * dummy variable * * Y Mole fractions vector; for VL equilibria corresponds to * * the vapour comp., for LL to liquid 1 and for VLL is any * * of the phases as indicated by variable IT * * IT Indicator for the type of phase; in VL equilibria IT=1 * * means the phase with composition Y is a vapour; in LL * * equilibria IT=2 and means phase with composition Y is a * * liquid; in VLL equilibria IE=1 indicates the phase is a * * vapour and IT=2 that i t is a liquid * * IE Control variable which indicates a flash calculation in * * which neither the temperature or the pressure change with * * respect to the last time the routine was executed. In * * such case parameters A and B for the pure components need * * not be calculated again * * APUR Vector of A parameters for the pure components evaluated * * at the specified T and P * * BPUR Vector of B parameters for " " " " * * at the specified T and P * * * * -Output * * APUR,BPUR as defined above * * FUGCl Vector of the calculated fugacity coefficients; for VL * * equilibria corresponds to the vapour; for LL to liquid 1 * * and for VLL to the specified phase with composition Y * * FUGC2 Vector of the calculated fugacity coefficients; for VL * * equilibria corresponds to the liquid; for LL to liquid 2 * * and for VLL is a dummy variable * * KEQ Vector of equilibrium constants for VL or LL equilibria * * * * Main variables * * L1,L2,U and W are equation of state parameters * * * * Subroutines called: * * PAB * * AB * * ZETA * * FUG * * * * Called by: * * PHASPLIT * * INSHAH * * INGASE * Appendix C. Description and listings of the computer programs 292 * INLIQ * * TESTA * * NELSTA * * VAPSER * * LIQSER * * PHASEQ * * IFLL * * IFVL * * FLASH2 * * FLASH3 * * GIBBS * * * ************************************************************ SUBROUTINE K(X,Y,TC,PC,V,PP,P,T,N,IT,IE,APUR,BPUR,FUGC1, + FUGC2,Z1,Z2,KIJ,KEQ,IFLG) IMPLICIT REAL*8 (A-H.O-Z) REAL*8 KEq(20),KIJ(20,20) DIMENSION FUGCK20),FUGC2(20),IFLG(0:20),PC(20),PP(20), + TC(20),W(20),X(20),Y(20),APUR(20),BPUR(20) IF (IFLG(O) .EQ. 0) THEN U=1.D0 V=O.DO ELSE U=2.D0 V=-1.D0 END IF IF (IE .EQ. 3 .AND. IFLG(4) .Eq. 1) GO TO 10 CALL PAB(P,T.N.TC,PC,H.PP,APUR,BPUR,IFLG) 10 IF (IFLG(13) .Eq. 0) THEN IFLG(1)=0 IFLG(2)=0 IFLG(3)=0 ELSE GO TO 30 END IF CALL AB(X,N,APUR,BPUR,KIJ,A2.B2) CALL ZETA(2,U,V,A2,B2,B9,Z2,IFLG) IF (IFLG(O) .Eq. 0) THEN RL2=DL0G((Z2+B2)/Z2) ELSE RL2=DL0G((Z2+B2*(l.D0+DSqRT(2.D0)))/(Z2+B2*(l.D0-+ DSqRT(2.DO))))/2.D0/DSqRT(2.DO) END IF DO 20 1=1,N CALL FUG(X,I,N,Z2,A2,B2,B9,APUR,BPUR,KIJ,RL2,FUGC2(I)) 20 CONTINUE 30 CALL AB(Y,N,APUR,BPUR,KIJ,Al.Bl) IF (IFLG(2) .Eq. 1 .AND. IFLG(13) .EQ. 0 .AND. IT .EQ. 2) + THEN IFLG(3)=1 IFLG(2)=0 END IF CALL ZETA(IT,U,V,A1,B1,B8,Z1,IFLG) IF (IFLG(O) .Eq. 0) THEN RL1=DL0G((Z1+B1)/Z1) ELSE RLl=DL0G((Zl+Bl*(l.D0+DSqRT(2.D0)))/(Zl+Bl*(l.D0-+ DSqRT(2.D0))))/2.D0/DSqRT(2.D0) END IF DO 40 1=1,N CALL FUG(Y,I,N,Z1,A1,B1,B8,APUR,BPUR,KIJ,RL1,FUGC1(I)) 40 CONTINUE Appendix C. Description and listings of the computer programs 293 IF (IFLG(13) .Eq. 1) GO TO 60 DO 50 1=1,N KEq(I)=FUGC2(I)/FUGCl(I) 50 CONTINUE 60 RETURN END Appendix C. Description and listings of the computer programs 294 ************************************************************* * * * SUBROUTINE PAB (PURE COMPONENT PARAMETER A AND B CALCULATION) * * * ********************************************************************** * * * Purpose: * * Obtain the pure component's attraction and repulsion parameters * * (in dimensionless form) from either the SRK or PR equations of * * state * * * * Parameters: * * -Input * * P,T,N,TC,PC,W,PP as defined in program PHASPLIT * * * * -Output * * APUR,BPUR as defined in subroutine K * * * * Called by: * * K * * * ********************************************************************** SUBROUTINE PAB(P,T,N,TC,PC,W,PP,APUR,BPUR,IFLG) IMPLICIT REAL*8 (A-H.O-Z) DIMENSION IFLG(0:20),PC(20),PP(20),TC(20),W(20),APUR(20), + BPUR(20),R(20),q(20) IF (IFLG(O) .EQ. 1) THEN C=0.37464D0 D=1.54226D0 E=-0.26992D0 A=0.45723553D0 B=0.077796074D0 ELSE C=0.48D0 D=1.574D0 E=-0.176D0 A=0.42748023D0 B=0.08664035D0 END IF DO 30 1=1, N R(I)=C+D*W(I)+E*W(I)**2 IF (T .GT. TC(I)) GO TO 10 Q(I)=(l.DO+R(I)*(l.DO-DSqRT(T/TC(I)))-PP(I)*(l.DO-+ T/TC(I))*(0.7D0-T/TC(I)))**2 GO TO 20 10 D=1.D0+R(I)/2.D0+0.3D0*PP(I) Q(I)=DEXP((D-1.D0)/D*(1.D0-(T/TC(I))**D))**2 20 APUR(I)=A*P/PC(I)*(TC(I)/T)**2*q(I) BPUR(I)=B*P/PC(I)*TC(I)/T 30 CONTINUE IFLG(4)=1 RETURN END Appendix C. Description and listings of the computer programs 295 *************************************************** * * * SUBROUTINE AB (MIXTURE'S A AND B PARAMETER CALCULATION) * * * ********************************************************************** * * * Purpose: * * Obtain the mixture's attraction and repulsion parameters (in * * dimensionless form) from either the SRK or PR equations of state * * * * Parameters: * * -Input * * N,APUR,BPUR,KIJ as defined in subroutine K * * X Vector of mole fractions for the specified phase * * * * -Output * * A Attraction parameter A for the mixture * * B Repulsion " B * * * * Called by: * * K * * * ********************************************************************** SUBROUTINE AB(X,N,APUR,BPUR,KIJ,A,B) IMPLICIT REAL*8 (A-H.O-Z) REAL*8 KIJ(20,20) DIMENSION X(20),APUR(20),BPUR(20) A=0.D0 B=0.D0 DO 20 1=1, N DO 10 J=1,N A=A+X(I)*X(J)*DSQRT(APUR(I)*APUR(J))*(1.D0-KIJ(I,J)) 10 CONTINUE B=B+X(I)*BPUR(I) 20 CONTINUE RETURN END Appendix C. Description and listings of the computer programs 296 ********************************************************************** * * * SUBROUTINE ZETA (COMPRESSIBILITY FACTOR CALCULATION) * * * ********************************************************************* * * * Purpose: * * Obtain the mixture's compressibility factor at the specified T, P * * and composition from the SRK or PR equations of state * * * * Parameters: * * -Input * * IT,A,B,IFLG as defined in subroutine K * * U,V Equation of state parameters * * * * -Output * * BO Calculated value of the mixture's B parameter to correct * * the fugacity coeffs. for the liquid when an extrapolated * * value of the compressibility factor is needed * * For the vapour or when an extrapolated compressibility * * factor is not required for the liquid, BO is equal to B * * Z Compressibility factor obtained for the phase indicated * * by variable IT * * * * Called by: * * K * * * ********************************************************************** SUBROUTINE ZETA(IT,U,V,A,B,BO,Z,IFLG) IMPLICIT REAL*8 (A-H.O-Z) DIMENSION IFLG(0:20) IF (IFLG(O) .EQ. 0) THEN Y0=3.8473221019D0 A0=4.933962452D0 A2=4.66044838388D0 ELSE Y0=3.9513730356D0 A0=5.877359948D0 A2=5.54485105556D0 END IF A1=A/B D0=1.D0/Y0 Bi=U*B-B-l.D0 C1=A+V*B*B-U*B*B-U*B D1=-V*B**3-V*B*B-A*B P=3.D0*C1-Bi**2 Q=B1**3+(27.D0*D1-9.D0*B1*C1)/2.D0 D2=P**3+Q*Q IF (D2 .LT. O.DO) THEN H=DAC0S(-q/DSqRT(-P**3)) GO TO 10 END IF 0NT=1.D0/3.D0 RI=-Q+DSQRT(D2) RM=DABS(RI)/RI*DABS(RI)**0NT RJ=-Q-DSqRT(D2) RN=DABS(RJ)/RJ*DABS(RJ)**0NT Z=(RM+RN-B1)/3.D0 10 IF (IT .Eq. 1) GO TO 40 * Calculation for the liquid Appendix C. Description and listings of the computer programs 297 IF (D2 .GE. O.DO) GO TO 20 Z=(-Bl+2.D0*DSQRT(-P)*DCOS(H/3.DO+2.DO/3.D0* + 3.14159265359D0))/3.D0 IF (Z .GT. B) GO TO 20 Z=(-B1+2.DO+DSQRT(-P)*DCOS(H/3.DO))/3.D0 20 D=B/Z F=1.DO/(1.DO-D)**2-Al*(2.DO*D+U*D*D)/(1.DO+U*D+V*D*D)**2 IF (Z .GT. B/DO .OR. F .LT. 0.1D0) THEN GO TO 70 ELSE GO TO 110 END IF * Extrapolation lor the liquid 30 IFLG(2)=1 IF (D .Eq. DO) THEN F=l.DO/(1.DO-D)**2-Al*(2.DO*D+U*D*D)/(1.DO+U*D+V*D*D) **2 ELSE F=F+0.1D0 END IF C2=F*(D-0.7D0*D0) F6=D/(1.D0-D)-A1*D*D/(1.DO+U*D+V*D*D) C0=F6-C2*DL0G(D-0.7D0+D0) D=DEXP((B-CO)/C2)+0.7D0*D0 Z=B/D GO TO 110 * Calculation lor the vapour 40 IF (D2 .GE. O.DO) GO TO 50 Z=(-B1+2.D0*DSQRT(-P)*DCOS(H/3.DO))/3.DO 50 IF (Al .LT. AO) GO TO 110 D=B/Z F=1.DO/(1.DO-D)**2-A1*(2.D0*D+U*D*D)/(1.DO+U*D+V*D*D)**2 IF (Z .LT. B/DO .OR. F .LT. 0.1D0) THEN GO TO 70 ELSE GO TO 110 END IF * Extrapolation lor the vapour 60 IFLG(1)=1 F6=D/(1.D0-D)-Al*D*D/(1.DO+U*D+V*D*D) F5=F+0.1D0 C2=(-F5*((D+D0)/2.DO-D)+F6)/(2.D0*F6**2*D*((D+D0)/2.D0-+ D)+F6**2*(D*D-((D+D0)/2.DO)**2)) C3=-(F5+C2+2.D0*F6**2*D)/F6**2 C0=1.D0/F6-C3*D-C2*D*D D=(-C3-DSQRT(C3**2-4.D0*C2*(CO-1.DO/B)))/(2.D0*C2) Z=B/D GO TO 110 * Calculation ol reduced density in the limit ol the allowed region 70 IF (Al .LT. A2) THEN D=DO GO TO 100 END IF IF (IT .EQ. 2) THEN D=0.8D0 Appendix C. Description and listings of the computer programs 298 ELSE D=0.1D0 END IF K=0 80 K=K+1 IF (K .GT. 25 .AND. IT .EQ. 2) THEN D=D0 GO TO 100 ELSE IF (K .GT. 25) THEN D=0.7D0*D0 GO TO 100 END IF F=l.D0/(1.DO-D)**2-Al*(2.DO*D+U*D*D)/(1.DO+U*D+V*D*D)**2-+ 0.1D0 F1=2.D0/(1.D0-D)**3-(A1*(1.D0+U*D+V*D*D)*(2.D0+2.D0*U*D)-+ 2.D0*A1*(2.DO*D+U*D*D)*(U+2.DO*V*D))/(1.DO+U*D+V*D*D) + **3 D3=D-F/F1 IF (DABS(1.D0-D/D3) .LT. l.D-5) GO TO 90 D=D3 GO TO 80 90 IF ((D .LT. O.DO .OR. D .GT. l.DO) .AND. IT .EQ .2) D=D0 IF ((D .LT. O.DO .OR. D .GT. l.DO) .AND. IT .EQ .1) + D=0.7D0*D0 100 IF (IT .EQ. 2) THEN GO TO 30 ELSE GO TO 60 END IF 110 IF (IFLG(2) .EQ. 1 .AND. IT .EQ. 2) THEN BO=D/(1.DO-D)-A1*D*D/(1.DO+U*D+V*D*D) ELSE BO=B END IF RETURN END Appendix C. Description and listings of the computer programs 299 * * * SUBROUTINE FUG (FUGACITY COEFFICIENTS CALCULATION) * * * * * * Purpose: * * Calculate the fugacity coefficient for component i in the * * mixture for a given phase * * * * Parameters: * * -Input * * N,APUR,BPUR,KIJ as defined in subroutine K * * Z,A,B,BO as defined in subroutine ZETA * * X Vector of mole fractions for the specified phase * * I Component number for which the fugacity coefficient is to * * be obtained * * RL Equation of state parameter * * * * -Output * * F Fugacity coefficient for component i in the specified * * B phase * * * * Called by: * * K * * * SUBROUTINE FUG(X,I,N,Z,A,B,BO,APUR,BPUR,KIJ,RL,F) IMPLICIT REAL+8 (A-H.O-Z) REAL*8 KIJ(20,20) DIMENSION X(20),APUR(20),BPUR(20) SUM=O.DO DO 10 J=1,N SUM=SUM+X(J)*DSQRT(APUR(I)*APUR(J))*(1.DO-KIJ(I,J)) 10 CONTINUE F=DEXP(BPUR( I)/B*(Z-l.DO)-DLOG(Z-B)+A/B*RL*(BPUR(I)/B-+ 2.D0*SUM/A))*B0/B RETURN END 

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
https://iiif.library.ubc.ca/presentation/dsp.831.1-0058885/manifest

Comment

Related Items