Corresponding author: A. Firoozabadi, Reservoir Engineering Research Institute, 595 Lytton Ave., Ste. B, Palo Alto, CA 94301, USA. (firstname.lastname@example.org)
 Most simulators for subsurface flow of water, gas, and oil phases use empirical correlations, such as Henry's law, for the CO2 composition in the aqueous phase, and equations of state (EOS) that do not represent the polar interactions between CO2and water. Widely used simulators are also based on lowest-order finite difference methods and suffer from numerical dispersion and grid sensitivity. They may not capture the viscous and gravitational fingering that can negatively affect hydrocarbon (HC) recovery, or aid carbon sequestration in aquifers. We present a three-phase compositional model based on higher-order finite element methods and incorporate rigorous and efficient three-phase-split computations for either three HC phases or water-oil-gas systems. For HC phases, we use the Peng-Robinson EOS. We allow solubility of CO2in water and adopt a new cubic-plus-association (CPA) EOS, which accounts for cross association between H2O and CO2 molecules, and association between H2O molecules. The CPA-EOS is highly accurate over a broad range of pressures and temperatures. The main novelty of this work is the formulation of a reservoir simulator with new EOS-based unique three-phase-split computations, which satisfy both the equalities of fugacities in all three phases and the global minimum of Gibbs free energy. We provide five examples that demonstrate twice the convergence rate of our method compared with a finite difference approach, and compare with experimental data and other simulators. The examples consider gravitational fingering during CO2sequestration in aquifers, viscous fingering in water-alternating-gas injection, and full compositional modeling of three HC phases.
 Gas injection in general, and CO2 injection in particular, is a promising option for improved oil recovery (IOR) for both fractured and unfractured reservoirs. Also, sequestration by CO2 injection in saline aquifers may be a promising approach to mitigate global warming. Several unique phase behavior properties make CO2 especially attractive. Up to 5 mol % of CO2 may dissolve in water at pressures encountered in saline aquifers and oil reservoirs, and the solubility in both light and heavy oil may be very high.
 Upon dissolution, CO2 may swell the oil and water phases. CO2 dissolution may also increase the density, which may start density-driven mixing due to gravity effects [Simon et al., 1978; Ashcroft and Ben Isa, 1997; Ahmed et al., 2012]. Under some reservoir conditions, CO2 has a higher density than the reservoir oil, making injection from the bottom more efficient. This effect is markedly different from, say, nitrogen injection. These aspects could have a significant impact on CO2sequestration and IOR. Accurate simulation of compositional effects using stability analysis and phase-splitting calculations in two- and three-phase flow is the main goal of this work.
 The CO2 solubility in the aqueous phase has generally been estimated using Henry's law, which has limitations for a CO2-rich liquid phase in equilibrium with water, due to the strong nonideality of the liquid phase. In three phase, the CO2composition in the aqueous phase is determined by fugacity equality in all three phases. We suggest using the cubic-plus-association-equations of state (CPA EOS) for both two- and three-phase flow when one phase is water and the hydrocarbon (HC) phases are CO2rich. The CPA-EOS can account for association (hydrogen bonding interactions) of water molecules and the cross association (polar-induced-polar interactions) of CO2 and water molecules [Li and Firoozabadi, 2009]. Reliable predictions by the CPA-EOS have been demonstrated inMutoru et al.  to pressures as high as 3000 bar and temperatures as high as 546 K.
 For applications other than steam injection, the mutual solubility of water and HCs is negligible (at K) and the CPA-EOS reduces to the Peng-Robonsin (PR)-EOS for the HC-rich and CO2-rich phases. In this temperature range, we derive highly CPU efficient three-phase stability and flash routines that accurately model the CO2solubility in the aqueous phase. In future work, we plan to account for salinity and extend the formalism to steam injection with full-species transfer by CPA-EOS.
 There have been no attempts in (1) EOS-based three-phase compositional modeling in the finite element framework or (2) to describe the aqueous phase by the CPA-EOS with cross association in modeling three-phase IOR and CO2 sequestration.
 Recently, Moortgat and Firoozabadi have modeled two-phase compositional flow in anisotropic media, using a powerful combination of high-order finite element methods. Specifically, the mixed hybrid finite element (MHFE) method is used to solve for pressure and fluxes, and mass transport is updated using a bilinear discontinuous Galerkin (DG) approach. The robustness and accuracy of the method, applied to two-phase problems, was demonstrated in earlier work and compared with commercial simulators [Hoteit and Firoozabadi, 2005, 2006a, 2006b]. Wheeler et al. recently applied similar finite element methods to single- and two-phase immiscible flow on hexahedral and simplicial grids. InMoortgat et al. , we developed the algorithm for the numerical modeling of three-phase flow, based on the combined DG and MHFE methods. The work presents a total flux formulation for three-phase flow and addresses complications with upwinding, but restricts compositional modeling to the nonaqueous phases. Here, we generalize that model to fully compositional three-phase flow. We distinguish two types of problems: (1) the flow of up to three HC phases, with transfer of all species between the three phases, which we model by the PR-EOS with volume translation [Peng and Robinson, 1976], based on three-phase-split methods proposed byLi and Firoozabadi , and (2) the flow of one or two HC phases and one aqueous phase. We introduce the CPA-EOS with cross association for the description of the aqueous phase.
 The MHFE-DG combination of finite element methods is particularly well suited to model heterogeneous and fractured reservoirs, in which the MHFE provides continuous fluxes and pressures throughout the domain, while the DG method allows sharp discontinuities in phase properties at phase boundaries, fracture-matrix interfaces, and jumps in permeability. By using higher-order methods, simulations can be carried out on significantly coarser meshes and at lower CPU cost compared with, for instance, first-order finite difference (FD) methods with single-point upstream weighting. Alternatively, on the same mesh, the MHFE-DG method will exhibit significantly less numerical dispersion and grid orientation effects than such FD methods. More specifically, insection 3.1, we demonstrate that the three-phase bilinear DG mass transport update has twice the convergence rate of an element-wise constant (FD) mass transport update. The mixed finite element method has furthermore proven to exhibit minimal sensitivity to grid orientation [Darlow et al., 1984].
 The three-phase modeling is improved by including Fickian diffusion for all three phases. The full matrix of composition-dependent, multicomponent diffusion coefficients in the nonaquoues phases are derived from the work byLeahy-Dios and Firoozabadi , and the aqueous phase coefficient by Mutoru et al. .
 The paper is organized as follows. First, we describe the mathematical model and numerical implementation. We keep the presentation succinct and provide only the governing equations of the higher-order approximation scheme. The main novelty of this work lies in the development of a highly efficient three-phase-splitting implementation in a reservoir simulator, using a new formulation in terms of the CPA-EOS for an aqueous phase and PR-EOS for nonassociating HC phases. The flow of three compositional phases with complex phase behavior exhibits a significantly higher degree of nonlinearity and is considerably more challenging to model than even the three-phase problem with a noncompositional aqueous phase using higher-order methods [Moortgat et al., 2011]. One manifestation of this nonlinearity is the orders of magnitude jumps in composition dependent total compressibility at phase boundaries. We provide expressions for three-phase partial molar volumes and total compressibility and discuss the strong sensitivity of compressibility on the phase-split results. Small errors in compressibility may lead to fluctuations in the pressure field. The fractional flow formulation presented in this work is very robust.
 After describing the algorithms, we present five characteristic numerical examples to verify our model: (1) we perform a convergence analysis to demonstrate the superiority of our higher-order finite element method to a traditional FD approach, (2) we compare our CPA predictions to experimental data over a wide range of temperatures and pressures, and contrast the results to a classic Henry's law, (3) we consider carbon sequestration and compare to analytical predictions for onset times and critical wavelengths, (4) we model an example from the literature for the fully compositional flow of three HC phases, and (5) we compare results for viscous fingering during water-alternating-gas (WAG) injection to a commercial simulator. The paper ends with concluding remarks.
2. Mathematical Model and Numerical Implementation
 Three-phase compositional flow in porous media is modeled by species balance, Darcy's law for the three phase fluxes, a pressure equation, and thermodynamic equilibrium among all three phases. The thermodynamic equilibrium relations are considerably more complicated when mass transfer is allowed among all phases. For three HC phases, we allow transfer of all species between all the phases and use the Peng-Robinson (PR) EOS for the phase description. For systems with an aqueous phase, we allow CO2 to dissolve in all three phases. H2O is assumed to be present in the aqueous phase only. This assumption is valid when the temperature is not too high ( ), but needs to be relaxed at higher temperature. HC components are assumed to be in nonaqueous phases only, because of their low solubility in H2O. As a result, the aqueous phase consists of only H2O and CO2. These assumptions result in a significant speedup for the compositional simulator.
2.1. Flow Equations
2.1.1. Mathematical Formulation
 The transport, pressure, and flux equations are as in Moortgat et al. . We will present them briefly for completeness. We index species by i and phases by . x, y, and z refer to the three HC phases in the absence of an aqueous phase. When one of the phases is aqueous, y refers to the aqueous phase and x and z to the two nonaqueous phases. We consider a mixture containing C components and choose H2O to be component 1 and CO2 as component 2.
 Darcy's law for multiphase flow for each phase flux is given by:
where K is the absolute permeability tensor of the porous medium; , , and are the relative permeability, viscosity, and mass density of phase α, respectively; p denotes the pressure and g the gravitational vector. We use the same relative permeability relations as in Moortgat et al. , following Stone [1970, 1973]. The viscosities for HC phases are computed using either the Lohrenz-Bray-Clark (LBC) [Lohrenz et al., 1964] or Christensen and Pedersen  correlations. The aqueous phase viscosity is insensitive to pressure and CO2 compositions and depends mainly on temperature T (K). We use the correlation , but other expressions may be used instead.
 Material balance for each species i can be expressed in terms of porosity φ, overall molar density c, phase molar densities cx, , overall mole fraction ni, phase compositions xi, yi, zi, Fickian diffusive fluxes and a source term (injection or production wells) Fi:
in which the diffusive fluxes are given in terms of the full matrix of multicomponent Fickian diffusion coefficients in nonaqueous phases, and , and a single diffusion coefficient for the aqueous phase, . The diffusive fluxes of the last component follow from the constraint that the sum over all species vanishes . When considering three HC phases, equation (3) applies to all phases, and the k and i indices start from 1.
where is the total fluid compressibility and is the total partial molar volume for component i. Expressions to evaluate and for two- and three-phase mixtures are provided inAppendix A. Formation compressibility ( ) may be important in the context of carbon sequestration in saline aquifers, where it may be as high as the water compressibility. To model weak rock compressibility, we assume a constant value for over a range of pressures and linearize the dependence of the porosity on pressure. In equations (2)–(5), we replace the porosity by , and in equation (5), we replace by , where is the porosity at the reference pressure p0.
2.1.2. Numerical Implementation
 We employ higher-order finite element methods to solve the above system of equations with the purpose of improving CPU efficiency by reducing numerical dispersion and grid orientation effects. Specifically, we adopt an implicit pressure explicit compositions (IMPEC) scheme. The MHFE method is used for the implicit simultaneous update of both the pressure and thetotal flux, to the same order. As mentioned in section 1, the accuracy of the resulting velocity field has a marked improvement over traditional FD methods [Ewing et al., 1991], particularly in heterogeneous media [Darlow et al., 1984; Hoteit and Firoozabadi, 2006b]. The diffusion fluxes are computed from cell-averaged phase compositions.
 We update the species balance equation explicitly using a DG method, which updates the compositions and phase properties of the phases and the (multiphase) mixture at the nodes or edges of each element. In our implementation, the order of mass transport update can be chosen as elementwise constant (FD), linear (for triangular grids) or bilinear (for rectangular grids). The interest in DG methods has increased over the years, and mathematical stability and convergence analyses have been carried out for a wide range of problems [Arnold, 1982; Babuska, 1973; Babuska and Zlamal, 1973; Wheeler, 1978; Brezzi and Fortin, 1991; Cockburn et al., 2000; Dawson et al., 2004; Riviere et al., 2001; Girault et al., 2008; Sun and Wheeler, 2005a; Sun et al., 2002; Sun and Wheeler, 2005b, 2005c, 2006a, 2006b, 2006c, 2007]. Formally, the bilinear DG method has 1 order higher convergence rate than traditional FD methods with single-point upstream weighting. In complicated applications, the convergence rate of both DG and FD methods may be lower and problem dependent. Insection 3.1, we establish that for three-phase flow using a bilinear mass transport update instead of elementwise constant approximations achieves twice the rate of convergence (for the same MHFE pressure and flux update). We note that while commercial simulators rely on lowest-order FD methods, various higher-order FD schemes have been proposed, which may have the same rate of convergence as our DG method. However, the DG method, combined with the MHFE pressure and flux update, has additional advantages in heterogeneous and fractured media where the phase properties are intrinsically discontinuous.
 The explicit mass transport update incurs a Courant-Friedrichs-Lewy (CFL) constraint on the time step, which is linear in the grid sizes for the convective term. Because of the composition dependence of the diffusion coefficients, the diffusive flux is part of the explicit update and requires a more severe CFL constraint quadratic in the grid size. However, the diffusion coefficients are small and many problems of interest are convection dominated. Furthermore, compared with lowest-order IMPEC schemes, the CLF condition is alleviated in our higher-order method by allowing significantly coarser grids.
 The phase equilibrium computations are based on the equality of fugacity in all three phases. While this equality is necessary, it is not sufficient and may have multiple solutions, only one of which satisfies thermodynamic equilibrium. At equilibrium, the Gibbs free energy must be at the global minimum, which requires a stability analysis. The phase stability analysis provides the unique phase-split solution, which improves the robustness of our formulation and has not been included before in compositional three-phase flow. Without stability analyses, phase-split routines may converge to a wrong solution at a local minimum of Gibbs free energy, which can cause unphysical oscillations throughout the domain.
 The work by Li and Firoozabadi is used to perform the phase-split computations for three HC phases. When we have an aqueous phase, we describe the nonaqueous phase by the PR-EOS with volume translation. For the aqueous phase, we implement the CPA-EOS with cross association between the H2O and CO2molecules and self-association of H2O molecules. We use the same volume shift to improve the density prediction in all the HC phases. In the aqueous phase, the volume shift for CO2 is different from the other phases, to allow highly accurate density results [Li and Firoozabadi, 2009]. Because the aqueous phase is far from the critical point, this apparent inconsistency does not result in complications.
 In the following subsections, we first introduce the CPA-EOS to describe the aqueous phase consisting of H2O and CO2. Then, we provide the general formalism for the two-phase and three-phase splitting calculations when H2O, CO2, and HC components are in the system.
2.2.1. CPA-EOS for the Aqueous Phase
 The compressibility factor Z of the aqueous phase, consisting of H2O and CO2, is expressed by the CPA-EOS as
In equation (6), y1 and y2 are mole fractions of H2O and CO2, respectively. A and B are energy and volume parameters of physical interactions, respectively. and represent the mole fractions of H2O and CO2 molecules not bonded on one of the association sites, respectively. They can be calculated from
where ξ and ϵ are the volume and energy parameters of association, respectively, kB is the Boltzmann constant, and R is the universal gas constant. The binary interaction coefficient used to calculate A and cross association factor between H2O and CO2 can be estimated as and with the reduced temperature of CO2. Note that in the absence of water ( ), the CPA-EOS reduces to the PR-EOS. Further details can be found inLi and Firoozabadi .
 Finding Z, and from equations (6)–(8)is key to the phase equilibrium computation involving an aqueous phase. Unlike the PR-EOS,equation (6) is not cubic and no exact solution can be obtained. Under general conditions, one cannot even determine a priori the number of solutions for Z due to the nonlinear coupling among equations (6)–(8). Without an initial guess for Z and knowledge of the number of solutions, fast solution schemes, such as the successive substitution iteration (SSI) and Newton methods, will not reliably converge to the true solution, but the bisection method always will. We suggest the following algorithm for efficient calculation of Z, , and .
 For pure water at typical reservoir temperatures and pressures ( , there is only one solution for Z higher than B ( has no meaning), and this solution is only slightly higher than B. When CO2 dissolves in water, Z for the aqueous phase changes only slightly because the CO2 solubility is low. In a reservoir simulator, initial guesses for Z, , and are generally available from (1) the previous time step and (2) the previous iteration in the phase-splitting routines. In that case, the most efficient procedure is to simultaneously solve forZ, , and by the Newton method. Only when initial guesses are not available or the Newton method fails because of a poor initial guess, the bisection method is adopted to find the solution of Z in the narrow range . In rare cases, no solution is found in this range, and we dynamically increase the upper limit by 0.1 increments. and are updated by the SSI method followed by the Newton method with the initial guess and given Z. With this optimized algorithm, we can perform phase-splitting computations (discussed later) using the noncubic CPA-EOS at CPU times comparable with phase-splits using the PR-EOS.
2.2.2. Two-Phase Splitting Calculation
 The two-phase equilibrium between phasesx and y satisfies the condition of equal fugacity of CO2 in these two phases, i.e., (here x refers to either of the nonaqueous phases and as before i = 1 is water and i = 2 is CO2). An equivalent expression uses the natural logarithm of the CO2 equilibrium ratio as the primary variable (phase x is chosen as the reference)
where is the CO2 equilibrium ratio, and and are the fugacity coefficients of CO2 in phases x and y. Molar fractions of component i in phases x and y are denoted by and and can be calculated from
Generally, the solution of the RR equation involves iterative procedures such as the Newton and/or bisection methods. However, when the aqueous phase contains only water and CO2, we have a quadratic RR equation that can be solved analytically for the aqueous phase amount . Of the two solutions, only one satisfies :
 In the two-phase splitting calculations, we first perform a number of SSI iterations. At each SSI step,K2 is updated iteratively through equation (9), and is solved analytically through equation (15) using the updated K2. The phase compositions are updated through equations (10)–(13). We define the difference between two successive iteration steps as . Once Δ is smaller than a given switch criterion, we switch to the Newton method, which has a quadratic convergence rate and can locate the solution in one or two iterations if the initial guess is good enough. We solve K2 and simultaneously until Δ is smaller than a predefined tolerance (we generally use ). Next, we perform a stability analysis to determine whether the two-phase state is stable, in which case the phase splitting is complete. Otherwise, we proceed with the three-phase split in the next section.
2.2.3. Three-Phase Splitting Calculation
 The three-phase equilibrium satisfies the condition of equal fugacities, i.e., and ( ). Similar to equation (9), we now have:
where the equilibrium ratios are , ( ). The fugacity coefficients of component i in phases x, y, and z are denoted by ( ), (i = 2), and ( ). The corresponding phase compositions are calculated from
where and are the mole fractions of phases y and z, respectively.
 To perform the three-phase splitting calculation, we need to provide initial guesses for all , ( ), , and when they are not available from the previous simulation time step. The best initial guess for is the two-phase splitting result. The two-phase stability testing provides an initial guess for . Initial guesses for and within can be obtained from two RR equations, using the initial guesses for and . The three-phase RR equations would traditionally be expressed as
When initial guesses are not available, equations (23) and (24)may be solved using a two-dimensional bisections method [Haugen and Firoozabadi, 2011]. These methods are computationally expensive for multicomponent mixtures. However, just as for the two-phase split, we can exploit the fact that the aqueous phase only contains two components.Equations (23) and (24)are intended as two relations to find the two-phase molar fractions and and simultaneously satisfy the mass constraints on all three phases. The mass constraints are also satisfied by:
but now equation (25) is another quadratic equation that can be solved analytically for one of the phase amounts. The correct solution is found by comparing the limiting case to the solution in equation (15). That is:
Using equation (27), can be eliminated from equation (26), which can then be solved either by a one-dimensional bisection method, or by the faster Newton method, when initial guesses for the phase amounts are available from the previous time step. For test cases with a large three-phase region, the analytical solution of the RRequations (14) and (25) results in a speedup of up to a factor 3 as compared to our most optimized iterative solution methods for equations (23) and (24).
 Once all the initial guesses are available, we run the SSI and Newton iterations to perform the three-phase splitting calculation, similar to the two-phase splitting. The difference between two successive iteration steps is now defined as . Because of the increased number of unknowns, the three-phase splitting generally needs more SSI steps to reach the switching criterion for Δ, but the Newton method can still converge to the final tolerance within a few steps. Sometimes, the Newton method may fail when Δ fluctuates or the Jacobian matrix becomes singular close to the critical point. If that happens, we switch back to the SSI method until the tolerance is met.
 Checking the errors and is particularly important near the critical point between phases x and z, where they converge much slower to the tolerance than and . We find that the total compressibility and total partial molar volume of the three-phase state (Appendix A) are very sensitive to the accuracy of and . An error as small as in the phase amounts may result in a negative total compressibility, which causes unphysical oscillations in the pressure field.
Appendix B discusses optimizations for time steps or spatial regions in which (1) there is no aqueous phase, or (2) no CO2 and therefore no mass transfer with the aqueous phase, or (3) only CO2 and H2O (in CO2 sequestration). The appendix also provides expressions to compute the properties of pure CO2 and H2O.
3. Numerical Experiments
 In the following examples, we provide a rigorous convergence analysis of our higher-order finite element method (example 3.1), and verify our model by comparing to experimental data (example 3.2), analytical analyses (example 3.3), and to other simulators available in the literature (example 3.4) and commercially (example 3.5).
 Some of the examples focus on viscous and gravitational fingering. Compositional multiphase flow often exhibits flow instabilities manifested as viscous or gravitational fingering. Viscous fingering is caused by the adverse mobility ratio of injected gas with respect to the displaced oil. Gravitational fingering may be triggered either by the density contrast between the injected gas itself with respect to the fluid in the domain or by changes in oil or water density due to mixing with the injected gas. CO2 requires particular attention, because it may be supercritical and denser than oil under certain reservoir conditions. Furthermore, when CO2dissolves in either oil or water, it may increase the oil/water density. This local density increase is gravitationally unstable to fingering. The initial onset of the instability consists of many small-scale fingers, which subsequently grow, merge, and develop into large-scale features. Numerical dispersion artificially suppresses the small-scale onset of fingering, which is one of the main motivations for using higher-order finite element methods. Fickian diffusion is a physical restoring force for fingering. Finally, predictions for the degree of gravitational fingering, e.g., in carbon sequestration, depend critically on the computed density increase upon mixing with CO2, which is why we rely on accurate EOS to model the phase behavior.
 We consider gravitational fingering in the context of carbon sequestration in example 3.3, and viscous fingering during WAG injection in anisotropic and heterogeneous domain in example 3.5. In a separate publication [Moortgat et al., 2012], we verified our algorithm by modeling a series of experiments in which supercritical CO2 is injected in a core saturated with oil and connate water, and at conditions where CO2 is denser than the oil. The core is positioned first horizontally and then vertically with CO2 injected either from the top or bottom to study the effects of gravitational fingering (and Fickian diffusion). Because CO2is denser than the oil, injection from the top is gravitationally unstable, while injection from the bottom initially results in near pistonlike displacement. Such stable displacement allows for a more straightforward convergence analysis then the case where the flow is unstable to highly nonlinear fingering or convection. Injection from the bottom is considered in example 3.1, in which we carry out a convergence analysis of our higher-order finite element method for three-phase compositional flow.
 The accuracy of the CPA EOS was confirmed by comparing to experimental data in Li and Firoozabadi . In example 3.2, we provide further verification for water-CO2 mixtures over a wide range of temperatures (288.7–394.3 K) and pressures (1–709 bar) from 13 experimental data sets in the literature, and compare to predictions from a classic Henry's law.
 In example 3.4, we use our fully compositional phase-splitting algorithm to model the flow of three HC phases. Fickian diffusion coefficients in the nonaqueous phases are computed at every time step using the formulation inLeahy-Dios and Firoozabadi . The diffusion coefficient in the aqueous phase is relatively insensitive to the pressure, and we use a constant value of m2 s−1 [Mutoru et al., 2011]. Lower diffusion coefficients may also be used for brine. Rock compressibility is only considered in example 3 for carbon sequestration.
 In this section, we use the more traditional indices for water (w), oil (o), and gas (g) phases for the relative permeability parameters. In the modeling of three HC phases, we use the same relative permeability model, and w indicates the third HC phase that appears for notational convenience. The Stone [1970, 1973]model calculates the relative permeability of an oil-gas system from the gas saturation, and the oil-water relative permeability from water saturation. In three-phase systems, the relative permeability is a weighted product of the two-phase relative permeabilities. Below a certain saturation, each of the three phases may become immobile through various processes (pressure drops, imbibition, drainage). Irrespective of the process, we refer to this saturation as the residual saturation for simplicity. The residual saturation of water (or third HC phase) is denoted bySwr, the residual oil saturation in the water-oil relative permeability relation bySrow, the residual oil saturation in the gas-oil relation bySrog, and the residual gas saturation by Srg. The corresponding endpoint relative permeabilities are for water (or third HC phase), for oil to water (or third HC phase), for oil to gas, and for gas. The powers are nw, now, nog, and ng.
 Simulations were run on an Intel Core i7 860 2.8 GHz CPU with 12 Gb RAM. The simulator uses a column preordered unsymmetric-pattern multifrontal direct solver [Davis, 2004]. CPU times are provided in the individual sections. We also compare to a commercial simulator, which was run on a 64 bit Intel Xeon(R) 3.07 GHz with 12.0 Gb of RAM.
3.1. Example 1: Supercritical CO2 Injection in Core Saturated With Oil and Connate Water
 We consider a cross-section of a vertical core saturated with oil and 32% connate water. Other simulation parameters are given inTable 1, and the fluid composition and critical parameters can be found in Moortgat et al. . Supercritical CO2 is injected from the bottom at one HC pore volume (PV) per day (the rate in Table 1 is with respect to total PV). Production is at constant pressure from the top. At the given temperature and pressure, the CO2 density of is higher than the oil density of , so injection from the bottom is gravitationally stable. The phase-split computations in this problem are challenging, because mixtures of the oil with CO2 are in the critical region. To establish convergence, simulations are carried out on , , , , and element meshes (we choose an uneven number of elements in the horizontal direction to have the production well in the center).
Table 1. Simulation Parameters for the Numerical Examples
Injection rate (PV yr−1)
 The power of the MHFE approximation for pressures and fluxes mainly applies to heterogeneous and fractured domains, which we are currently investigating. In this example, we neglect Fickian diffusion and quantify the reduction in numerical dispersion when the mass transport equation is updated with a bilinear DG method. Our MHFE-DG update involves five phase-split computations per rectangular element to obtain the phase compositions at the edge-centers and the cell-averaged phase compositions (the latter can theoretically be eliminated). The purpose of the example is to justify the additional phase-split computations in the higher-order method by comparing to a baseline in which only one phase split is carried out per element. The latter is equivalent to a traditional FD mass transport update, which we will refer to as MHFE-FD. Both MHFE-DG and MHFE-FD simulations use the same MHFE pressure and flux update and single-point upstream weighting to isolate the convergence of the mass transport update.
 In our three-phase compositional model, applied to water-oil-gas problems, the CO2 compositions in the three phases are the primary variables of interest. For clarity, we will use the shorthand notation and in this example for the compositions in the gas and water phase, respectively. Figure 1 shows the CO2composition in the gas and aqueous phases at 30% PV injection (PVI) along a vertical line in the center of the domain for both MHFE-DG and MHFE-FD simulations on the five meshes. As a reference, or “true,” solution, we take the MHFE-DG simulation on the finest mesh, which shows a sharp shock at . To quantify the convergence, we denote the reference MHFE-DG solution byu and the approximations on coarser grids by uh. We define the L1 and L2 error norms as
The numerical method is said to converge in either norm if
with p the order of convergence, the characteristic length of an element (scaled here by the coarsest element size), C a constant independent of u and uf, and and the width and height of the rectangular elements. We compute the L1 and L2 error norms for the primary variables and as well as the derived variable So. The corresponding convergence rates p are summarized in Table 2, and are similar to the rates obtained in Hoteit and Firoozabadi , where the MHFE-DG approach was applied to the simpler problem of immiscible two-phase flow. It is encouraging that the higher degree of nonlinearity in three-phase compositional flow does not reduce the order of convergence of our method. We reiterate the statement in the aforementioned work that the order of convergence is reduced from the optimal value because of the need for slope limiting around the sharp phase discontinuity.
Table 2. Order of Convergence p in Terms of L1 and L2 Errors in DG and FD Methods
 We return to our original question of the benefit of the DG mass transport update with multiple phase-split computations. On each given mesh, a MHFE-DG simulation requires about twice the CPU time of a MHFE-FD simulation, but we achieve twice the order of convergence ( ) in both L1 and L2norms with respect to a first-order approximation. In terms of CPU time, this means the following. Say we need a factor refinement in mesh size for a MHFE-DG simulation to reduce the error by a factorϵ. Then, we need a factor mesh refinement to achieve the same error reduction ϵwith a MHFE-FD simulation. Because the mass transport update is explicit, the CPU time roughly increases with mesh refinement as ( increase per time step and a factor ħreduction in time step). The CPU time for a MHFE-FD simulation that satisfies the same tolerance on the error will therefore scale with , or . Moreover, the constant C in equation (30)is larger for the MHFE-FD than for the MHFE-DG simulations. The implication is graphically illustrated inFigure 2, which plots the CPU times on a logarithmic scale for the MHFE-DG and MHFE-FD simulations on all mesh sizes versus theL1 and L2errors (normalized by the maximum errors for the MHFE-FD simulations on the coarsest mesh). As an example, we find that the error in an FD simulation on a mesh is comparable to an MHFE-DG simulation on a mesh (see also Figure 1), while requiring a factor 534 more CPU time. Even more mesh refinement is required for the MHFE-FD method to fully converge.
 The final observation for this example relates to the phase behavior due to CO2 solubility in water. Figure 3 shows the water saturation at 30% PVI on the finest mesh. Behind the CO2 front, the water saturation is increased due to mixing with CO2. The swelling increases the saturation above the residual saturation, allowing a small amount of water to flow. Because water is the densest phase and we consider a low injection rate, some of the water accumulates in the bottom. Swelling of the aqueous phase due to CO2 dissolution aids oil recovery from domains that have been water flooded or have a high connate water saturation. However, the beneficial effect is reduced by the fact that the dissolved CO2 is lost from the oil sweep.
3.2. Example 2: Comparison Between CPA and Henry's Law
 The accuracy of our CPA EOS, with consideration of associating molecules, was verified extensively against experimental data in Li and Firoozabadi . For the purpose of this work, we are mainly interested in the composition and phase behavior of a CO2-containing aqueous phase mixed with one or two HC phases (gas/oil). A common alternative approach to obtain the CO2 composition in the aqueous phase is the use of Henry's law [Harvey, 1996]. The correlation in Harvey  assumes a linear relation between the fugacity of CO2 and its composition in the aqueous phase, together with another correlation for the water vapor pressure [Saul and Wagner, 1987].
 In Figure 4, we combine our CPA predictions and computations with the aforementioned Henry's law and compare with a large number of published experimental data sets over a wide range of temperatures (288.7–394.3 K) and pressures (1–709 bar). The experimental data and references are summarized in Spycher et al. . We find that the CPA predictions agree well with the experiments at all temperatures and pressures. The compositions from Henry's law agree reasonably well at low pressures, but deviate considerably at higher pressures.
Spycher et al. propose a more complicated correlation that takes into account the variation of Henry's constant with pressure, as well as a dependence on the partial molar volumes averaged over a pressure range of interest, which shows better agreement with the measurements. In three-phase multicomponent mixtures, Henry's “constant” also becomes dependent on the overall composition. The CO2composition in the aqueous phase can no longer be computed directly from the fugacity in the vapor phase and Henry's constant, but becomes part of an iterative three-phase split to satisfy equality of fugacities in all three phases (see for instance,Luo and Barrufet ). When Henry's law is used instead of an EOS, an additional correlation is necessary to determine the aqueous phase density, because the compressibility factor is not known. In our fractional flow approach, the compressibility factor and its derivatives are also required to compute the total partial molar volumes and compressibility of multiphase mixtures. By using the CPA EOS, all phase-behavior aspects of multicomponent, multiphase mixtures can be computed self-consistently at any temperature and pressure. This will be even more critical in future work, in which we will consider higher temperature conditions (steam injection) where all species may transfer between the three phases, and CPA will be used to describe all phases.
3.3. Example 3: CO2 Sequestration in an Aquifer
 Although the objective of this work is the modeling of three-phase compositional flow, we present one example that demonstrates our modeling capabilities for two-phase carbon sequestration. We consider CO2 sequestration in an aquifer by injecting 5% PV of CO2 from the top without water production. Fickian diffusion drives the initial dissolution of CO2 into the water. The subsequent convective mixing due to the local density increase of the aqueous phase [Rongy et al., 2012] propagates at speeds proportional to the permeability. At a sufficiently high matrix permeability and low injection rate, all injected CO2 may be dissolved and mixed throughout the aqueous phase with only a low pressure increase due to swelling. Compared to the low compressibility of water, compressibility of the sandstone formations, in which aquifers are often found, may be significant in reducing the pressure buildup from CO2 injection. In this example, we account for a rock compressibility of .
 At high injection rates or low permeability, the convective mixing is too slow to transport the dissolved CO2 downward before the saturation composition is exceeded and a gas cap forms, which results in a steeper pressure increase. Generally, 1–2% PV of CO2 injection in aquifers suffices for CO2 sequestration purposes. The dissolution of CO2 in the aqueous phase has a major effect in reducing the leakage of CO2 in case of failure of the cap rock integrity [Firoozabadi and Cheng, 2010].
 We consider a 100 m × 100 m domain saturated with water at an initial (bottom) pressure of 100 bar and temperature of 350 K. At these conditions, the maximum composition of CO2 in the aqueous phase is 1.6 mol % (Figure 4e).
For this example, we assume a water viscosity , porosity , diffusion coefficient for CO2 in water , formation permeability K, and density increase of the aqueous phase upon CO2 dissolution , depending on the composition. The factor c1 varies from 96.23 in Xu et al.  and Pau et al. , in Riaz et al. , and 115.3 in Cheng et al. .
 More importantly, a critical time is predicted for the onset of gravitational fingering by
The factor c2 varies considerably from 47.9 in Slim and Ramakrishan  and Cheng et al.  and in Riaz et al.  to 1155, 1412, 1796, and 3670 in Pau et al.  and Pruess and Zhang . The reason is that the onset time is defined differently in various stability analyses and in simulations. In stability analyses, the definition is somewhat abstract in terms of the first or the dominant growing wave mode, whereas in simulations, it is generally defined by the first deviation of flow from a pure diffusive base state. The predictions for tcfrom simulations are generally at least 1 order of magnitude larger than those from stability analyses. Similarly, the first observable sign of gravitation fingering in Hele-Shaw cell experiments [e.g.,Kneafsey and Pruess, 2010] is an order of magnitude later than the tc from stability analysis.
 In this example, we perform simulations for , , and . The corresponding critical wavelengths from Riaz et al.  are 45, 9.7, and 4.8 m. To resolve the critical wavelengths, we use a element mesh.
 All the aforementioned stability analyses, as well as the simulations, assume a top layer that is always saturated with CO2, impermeable top and bottom boundaries, and periodic left and right boundaries. We are interested in CO2 injection in a bounded aquifer where the pressure will increase as CO2 is injected, because this pressure buildup raises concerns in the community about failure of the cap rock and potential leakage. We therefore assume impermeable boundaries in all directions, and inject CO2 uniformly from the top, without production. To compare to the above results in the literature, we inject at a sufficiently low rate such that the aqueous phase is near the saturation composition in the top, with little or no gas cap formation. This requires very low injection rates. We use PV yr−1 ( ), PV yr−1 ( ), and PV yr−1 ( ).
 To trigger the gravitational instability, linear stability analyses impose harmonic perturbations on the composition in the top layer [Riaz et al., 2006; Cheng et al., 2012]. In simulations, a more physical approach is to consider random perturbations in the permeability or porosity [Pau et al., 2010]. In lowest-order simulators, large perturbations may also be necessary to overcome the dampening effect of numerical dispersion on the fingering instability. In our work, we find that both gravitational and viscous (example 5) fingering can be resolved without a need for forced perturbations, and late-time fingering is relatively insensitive to the initial onset.
 In Figures 5 (CPU = 30 min), 6 (CPU = 50 min), and 7(CPU = 48 min), we show simulation results for 1 d, 0.5 d, and 0.1 d formation permeabilities, respectively. The left panels are for a homogeneous domain, and the right panels for a domain that has a random perturbation of 5% around the average permeability. The top panels are for early times, when a large number of small-scale gravitational fingers have developed with a relatively well-defined wavelength. The middle panels are around the time where the first finger(s) reach to bottom of the domain, and the bottom panels are at the end of the simulation after injecting 5% PV or CO2.
 The wavelengths observed in the top panels are approximately 1.7–2 m for , 3.4–4 m for , and 14.3 m for . This satisfies the inverse proportionality of the wavelength on the formation permeability (the wavelength at is slightly lower than expected, which may be due to the influence of the boundaries at this large wavelength). The wavelengths are in between those predicted from the stability analyses in Riaz et al. , Cheng et al. , and those from simulations in Pau et al.  and Pruess and Zhang .
 We define a critical time as the first time that we see any deviation in the aqueous phase CO2 composition from purely diffusive, and find yr for 1 d, yr for , and yr for 0.1 d (i.e., earlier than the fully developed fingers in the figures). These values scale as in equation (32), with about halfway between the values found from stability analyses and those from other simulations in the literature. Similar to the wavelength, tc at 0.1 d may be a little early because of the influence of the boundaries.
 As mentioned earlier, we find no significant difference between the sequestration process in a homogeneous domain and in a domain with small perturbations in the permeability. One exception may seem to occur in Figure 6with the development of two dominant fingers in the homogeneous case and three in the heterogeneous case, which results in the former fingers reaching the bottom of the domain earlier than the latter. However, this late-time evolution is highly nonlinear, and a simulation with a different random permeability sample may result in two dominant fingers as well.
 Qualitatively, all the figures exhibit splitting of finger tips and vortical motions, as has been reported in the literature. One critical parameter in the practical consideration of carbon sequestration without water production in finite aquifers is the pressure buildup due to CO2 injection. This pressure increase from CO2 injection is surprisingly underrepresented in the literature. Figure 8 shows the pressure evolution for all cases considered in this example. Because the injection rates are chosen to allow dissolution of all the injected CO2, the pressure increase is the same for all permeabilities and is only from the swelling of the aqueous phase (the pressure increase is slightly higher for the case, because a small amount of gas phase appeared at some of the finger foot points, where the CO2composition is generally highest). The final pressure increase can be readily verified by a constant-volume flash calculation (corrected for the formation compressibility). The formation compressibility allows about twice as much CO2 to be sequestrated for a given acceptable pressure increase. Figure 8 illustrates this by showing a simulation result for in which the rock compressibility is assumed zero and the pressure buildup from injecting 5% PV is 200 bar, when compared with 100 bar with rock compressibility. As one final example, we have also included a simulation result with rock compressibility but without gravity-driven convective mixing by considering CO2 injection in a horizontal domain (i.e., by setting g = 0). Again, the pressure buildup is twice as high when CO2 transport in the aqueous phase is only through the slow diffusive flux.
3.4. Example 4: Fully Compositional Flow for Three HC Phases
 We simulate the flow of three HC phases and allow mass transfer of all species between the three phases. The phase-split computations employ the PR-EOS with a volume translation [Li and Firoozabadi, 2012]. We do not consider diffusion in this example. A vertical 100 m × 100 m domain, discretized by 51 × 51 elements, is initially saturated with Nord Ward Estes (NWE) oil. We will refer to the initial NWE oil (and mixtures with CO2) as oil-I, and to the most CO2-rich phase as “gas.” The third phase, with intermediate properties, is oil-II. The phase identification is based on the molecular weights of the phases and verified by the molar fraction of the residue.
 The fluid properties are as in Okuno et al. , and repeated in Table 3. Other relevant simulation parameters are given in Table 1. We inject gas at 10% PV yr−1from the top-left corner, with a composition of 95 mol % CO2 and 5 mol % methane. Production is at a constant pressure (75 bar) from the bottom right.
Table 3. Initial Compositions and EOS Parameters in Example 4a
All VSP = 0.
 The CO2 concentration in each of the three phases at 75% PVI is given in Figure 9. A large three-phase region has appeared with a CO2composition of oil-II of up to 95 mol %. At 75 bar, the densities and viscosities for the injected gas, initial oil-I, and emerging oil-II (1:4 molar fraction of oil-I mixed with injection gas) are: , , and , respectively. The viscosities are: cP, cP, and cP.
 Oil-I also has a high CO2 concentration of up to 60 mol %. The high solubility of CO2in the two liquid phases results in a complex phase behavior. In particular, the density of oil-I is increased in the upper CO2-invaded regions. This is gravitationally unstable and causes fingering-like flow at the top phase boundary of oil-II. The high viscosity ratio between oil-I and gas/oil-II further complicates the flow patterns. Our three-phase model can robustly capture the phase behavior, and at an efficient CPU time of about 1 h for this example (for 100% PVI).
3.5. Example 5: WAG Injection in Anisotropic Domain
 In the last example, we study the three-phase WAG process in a wide and thin anisotropic domain. The domain dimensions are 600 m × 60 m and the other simulation parameters are summarized inTable 1. Due to the low vertical permeability, gravitational effects are reduced. Instead, we investigate the importance of viscous instabilities.
 The domain is initially saturated with 31% connate water and the same challenging oil as in example 3.1. In the WAG process, we inject alternating slugs with a width of 2.5% PV of water (first slug), and a gas consisting of 80 mol % CO2 and 20 mol % methane. Injection is uniformly from the left boundary at 5% PV yr−1, and production is at constant pressure from the middle of the right boundary.
 The initial oil has a density of 0.736 g cm−3 and a viscosity of 1.4 cP. Water has a density of 0.999 g cm−3 and a viscosity of 0.48 cP, and the injected gas has a density of 0.731 g cm−3 and a viscosity of 0.06 cP. Because the density of the injection gas is close to the oil density, but the viscosity is a factor 23 lower, we expect viscous instabilities. Figure 10ashows the result of a MHFE-DG simulation on a 300 × 30 mesh at 15% PVI (CPU is 50 min), and we see that indeed the front is unstable and breaks up in pronounced viscous fingering. When we repeat the simulation on a very fine 450 × 60 mesh (Figure 10b; CPU is 6 h), we resolve a bit more of the small-scale features, but the results are quite similar. In these simulations, the viscous fingers are resolved without any artificial perturbations. To determine whether the fingering is sensitive to additional perturbations, we repeat the first simulation on a 300 × 30 grid where the permeability in each cell is initialized with a random variation of 5% around the average.Figure 10shows that the same qualitative behavior is obtained from MHFE-DG simulations with or without artificially triggering instability.
 The picture is very different when we employ a lower-order (MHFE-FD) mass transport update. InFigure 11a, we see that the viscous fingering is completely suppressed on the 300 × 30 mesh (CPU is 24 min). On the finer 450 × 60 mesh (Figure 11b; CPU is 3 h) some fingering is visible, but to a much smaller extent than in the higher-order simulations. When we initialize with a perturbed permeability field, similar to the MHFE-DG simulations, the instability is triggered earlier, and larger viscous fingers develop (Figures 11c–11d). However, the onset time is still delayed and the instability is overdampened by numerical dispersion. As a result, the MHFE-FD simulations underestimate the breakthrough time of the fingers, and overestimate oil recovery.
 To further validate our model, we carry out FD simulations similar to Figure 11ausing both the implicit pressure, explicit saturation (IMPES) and fully implicit options of a commercial simulator and the Orthomin iterative linear solver. Because commercial simulators do not have a reliable model for multicomponent Fickian diffusion, we compare to a MHFE-FD simulation with our model that neglects Fickian diffusion and therefore shows a larger degree of viscous fingering.
Figure 12shows the results at 15% PVI for the three simulations. We find that there is reasonable agreement between our results and those from the commercial simulator using the IMPES option. The latter still shows more numerical dispersion and potentially grid dependence because it also uses a FD update for the pressure and flux fields. Our model, in this case, uses a lowest-order (FD) mass transport update in combination with the more accurate MHFE computation for the pressure and flux fields. The fully implicit computation with the commercial simulator inFigure 12c allows for larger time steps, but is the least accurate and exhibits considerable numerical artifacts.
 The CPU times for the IMPES and fully implicit simulations are 7.3 and 3.5 min, respectively. The CPU time with our IMPES code using a lowest-order mass transport update, in combination with the MHFE pressure and flux fields (and run on a slower processor), requires a CPU time of 6 min. This CPU comparison gives an indication of the high level of optimization of our model, even before considering the higher-order MHFE-DG mass transport update.
4. Concluding Remarks
 We have made the following advances in the modeling of compositional three-phase flow:
 1. A higher-order finite element framework that achieves minimal grid sensitivity (from MHFE) and twice the convergence rate of a lowest-order mass transport update (from DG). For a given accuracy, the MHFE-DG approach allows significantly coarser grids and 2 orders of magnitude improvement in CPU time.
 2. Incorporation of robust and efficient stability analysis and phase-split computations for the fully compositional modeling of three HC phases with transfer of all species between the three phases and satisfying the global minimum of Gibbs free energy.
 3. Compositional modeling of water, oil, and gas phases with CO2 solubility in water using an accurate CPA EOS, which takes into account polar interactions between CO2and water molecules. The phase-split computations strictly enforce equality of CO2fugacity in the three phases, and minimized Gibbs free energy, which guarantees the uniqueness of the solution. A naïve introduction of the CPA-EOS may result in inefficient compositional modeling because of the noncubic expression for the compressibility factor (Z) and two nonlinear equations for the portions of CO2 and H2O molecules that do not associate ( and ). We have resolved these issues by simultaneously solving for Z, , and with an efficiency comparable to solving the PR-EOS. Another challenge in three-phase flow is the solution of the RR equations. We find that we can solve the problem semianalytically by rewriting the RR relations, which circumvents the 2-D bisection method and improves the speed and robustness of phase splitting. Comparison to experimental data demonstrates remarkable accuracy over a wide range of temperatures (288.7–394.3 K) and pressures (1–709 bar).
 4. The computation of the two- and three-phase total compressibility and total partial molar volumes in a fractional flow formulation, using the PR- and CPA-EOS with volume translation. The pressure field is highly sensitive to the total compressibility that appears in the pressure equation introduced byAcs et al. . We have found that only providing a tolerance for convergence of either or is inadequate in the computation of the total compressibility in the near-critical region. We also need to guarantee that the phase mole fractions converge to a tight tolerance.
 In the numerical examples in section 3, we further verified our model (1) with experimental data for water-CO2 mixtures, (2) by comparison of simulation results for carbon sequestration to analytical solutions from linear stability analysis, and (3) by comparing simulations for WAG injection to results from a commercial simulator, which demonstrated the higher accuracy and CPU efficiency of the methods presented in this work.
Appendix A:: Three-Phase Total Compressibility and Total Partial Molar Volumes
 We define the following symbols. For any phase α, is the component number of moles, is the total number of moles, and is the molar volume without volume shift. For the mixture, is the component number of moles, is the total number of moles, is the total volume with volume shifts , and is the total volume without volume shift.
 The total compressibility and total partial molar volumes for three-phase water-containing mixtures are now given by:
 The equivalent expressions for a general two-phase mixture are given inFiroozabadi , without volume translation. The expressions with volume shift and an aqueous phase can be deduced from the three-phase relations given above.
Appendix B:: Specific Conditions
 Certain specific conditions require special attention. An element that contains only pure H2O or pure CO2in single-phase state can be described by the CPA-EOS or PR-EOS, respectively. The partial molar volume equals the molar volume of the pure component. The single-phase compressibility is calculated from
 When an element contains a single- or two-phase mixture of only H2O and CO2 mixture, phase x is pure CO2, described by the PR-EOS, and phaseyis described by the CPA-EOS, with compositions given by
 The RR equation is automatically satisfied. Similarly, the initial guess of K2 is estimated from the maximum CO2 solubility in H2O. We apply the SSI method followed by Newton method to solve the two-phase equilibrium of CO2. If the two-phase splitting fails due to one of the phases having a negative amount, we conclude that the mixture is in single-phase state. A complimentary stability criteria for simulations considering H2O/CO2 mixtures (such as example 3) is to compute a maximum solubility curve as a function of pressure for the given constant temperature as part of the initialization. When the overall CO2composition is lower than the maximum solubility, the mixture is in single phase, and we avoid the flash computation. For the single-phase state, the compressibility is the same as inequation (B1) and the partial molar volumes are given by
 Because phase x consists of pure CO2, we have
 For elements that do not contain an aqueous phase, we use the PR-EOS with volume shift to calculate the phase splitting and properties as in traditional two-phase simulations. This applies, for instance, to example 2 when we consider depletion of an oil reservoir that does not contain water.
 In an element where CO2 is absent, H2O forms a pure aqueous phase and the other components form one or two nonaqueous phases described by the PR-EOS as in traditional simulations, with compressibility and partial molar volumes from:
where and are the compressibility of aqueous and nonaqueous phase(s). Vxz and are the total volume and partial molar volume of component i of the nonaqueous phase(s).
 This work is supported by ConocoPhillips. Their support is greatly appreciated.