Study of compositional multiphase flow formulation using complementarity conditions

. In this article, two formulations of multiphase compositional Darcy ﬂ ows taking into account phase transitions are compared. The ﬁ rst formulation is the so-called natural variable formulation commonly used in reservoir simulation, the second has been introduced by Lauser et al. and uses the phase pressures, saturations and component fugacities as main unknowns. We will discuss how the Coats and the Lauser approaches can be used to solve a compositional multiphase ﬂ ow problem with cubic equations of state of Peng and Robinson. Then, we will study the results of several synthetic cases that are representative of petroleum reservoir engineer-ing problems and we will compare their numerical behavior.


Introduction
In reservoir simulations, compositional multiphase flow coupled with detailed physical laws based on equations of state [1][2][3][4] remains an important and challenging problem. This issue consists in solving a large system of nonlinear equations coupling the conservation of the components with the thermodynamical equilibrium constraints. Many formulations have been proposed; we refer to, for example [5][6][7][8][9]. The difficulty lies in handling the appearance and disappearance of phases assumed to be at thermodynamical equilibrium.
The traditional dynamic approach [10], called "variable switching", considers only the unknowns of the present phases and the equations for them. It is heavy to implement and costly in CPU time, because the "switching" occurs constantly, even from a Newton iteration to another. An alternative approach, called "unified formulation", enables one to keep a fixed set of unknowns and equations regardless of the context using nonlinear complementarity conditions [11,12]. These constraints provide elegant models for complex problems and lead to efficient methods to solve them numerically. Interesting results have already been obtained in several fields like solid or fluid mechanics and economics [12,13]. Thus, this paper will concentrate on the physical validation of this new approach in reservoir simulation industry comparing two formulations for compositional multiphase flow with cubic equations of state.
The first formulation we study is from the variable switching approach, called Natural Variables Formulation (NVF) and introduced by Coats [5,10]. It is based on the natural unknowns (pressures, saturations, molar fractions) and on phase apparition detection through a flash calculation [14]. This model is stable in regard to phase transitions but can quickly become complex to manage the set of present phases and the associated unknowns/equations at each point of the time-space domain.
For the second formulation, we examine a recent unified formulation introduced by Lauser et al. [15], which uses the phase pressures, saturations and component fugacities as main unknowns with complementarity conditions for handling phase transitions. These complementarity constraints can be equivalently reformulated as Karush-Kuhn-Tucker (KKT) conditions of Gibbs free energy minimization problem and this is known as the Gibbs tangent plane. The resulting system leads to a fixed set of unknowns and a fixed set of equations whatever the present phases, and it allows to avoid the flash calculation. On the other hand, it requires to compute molar fractions and their derivatives as a function of pressures, temperature and fugacities. From the practical viewpoint, as the new formalism involves several nonsmooth "complementarity" equations, it is necessary after discretization to resort to "semismooth" Newton methods, called Newton-min algorithm [16][17][18]. This Complementarity Condition Formulation will be denoted by CCF in the following.
The paper is organized as follows. In Section 2, we describe the system of equations for the multiphase compositional model, relevant physical properties along with their dependencies and relations of thermodynamical equilibrium between phases. In Sections 3 and 4, the two formulations are detailed and their advantages and drawbacks are further discussed. In Section 5, we present some numerical aspects of the resolution of both systems and in particular for the nonlinear solver. The specific treatment of aquifer cells is presented in Section 6. Finally, in the last Section 7, the two formulations are compared into several synthetic cases that are representative of petroleum reservoir engineering problems.

Multiphase compositional model
For the sake of simplicity, we assume the medium is isotherm with fixed temperature T, hence in the following the dependence of the physical laws on temperature will not be shown. We consider a compositional model for a three-phase flow: water (w), oil (o) and gas (g). Let A = {w, o, g} be the set of phases. We suppose that the oil and gas phases are represented by a mixture of n c components. Moreover, we assume that the water phase is pure, that means that it is composed only of H 2 O, and that it is immiscible with the other phases. Therefore only the hydrocarbons oil and gas phase are mixable and compositional.

Conservation laws
The governing partial differential equations are obtained by enforcing the molar conservation law for each component. In particular, the velocity of each phase is given by Darcy's law. For the water component, we have and, for each hydrocarbon component i = 1,. . .,n c , we have The molar flow rates have the following form where Q a m 3 s Â Ã represents the flow rate of phase a and depends on the nature of the associated well. The velocities of the phases are computed through Darcy's lawṽ The units of the physical quantities defined above are given in the international unit system.
The thermodynamical aspect is constantly present in the simulations of flows in a porous medium. It is necessary, for example, to be able to describe the physical evolution of the mixtures present in the reservoir. This is important not only for being able to simulate flows as well as possible but also for determining which recovery process is best suited. In this section, we will introduce some notions to better understand the thermodynamical aspect involved.

Equilibrium equations
In addition to the molar conservation equations, we have to consider the relations of thermodynamical equilibrium between different phases. For every component, it can be expressed as the equality of the fugacity of oil and gas phase, that is: Let C a ¼ ðC a j Þ j¼1;...;nc be the vector of components molar fractions in phase a, then the fugacities can be computed through where P is a reference pressure and corresponds to the pressure of a given phase a and U a i is the fugacity coefficient of the component i in the phase a 2 fo; gg. The fugacity coefficient is computed using an equation of state [19]. We can rewrite equation (3) as is defined as the ratio between the fugacity coefficients of oil and gas phase and it represents the distribution of component i between these two phases.

Negative flash calculation
The solution of the thermodynamical equilibrium (3) is computed using a negative flash calculation [14]. We define Z ¼ ðz i Þ i¼1;: : :; n c the total molar fraction of the components in the hydrocarbon mixture such as X nc i¼1 z i ¼ 1: For a given reference pressure P and a fixed total molar fraction Z, the negative flash is to find V 2 R the molar fraction of the gas phase and " C o 2 ½0; 1, " C g 2 ½0; 1 the molar fractions of the components in the oil and gas phase at equilibrium, which are the solutions of the nonlinear system The solutions V ! 1 and V 0 correspond to a stable single phase system. In the following, we denote by Flash (P, Z) the negative flash calculation.

From phase stability test to complementarity condition
The necessary and sufficient condition for a phase of a n c component mixture with composition Z ¼ ðz 1 ; z 2 ; . . . ; z n c Þ to be stable at some given pressure and temperature [19,20] is given by following inequality where the value of the vector C ¼ ðc 1 ; c 2 ; . . . ; c nc Þ containing the molar fractions of an incipient phase that would separate from the phase with composition Z in case of instability. The function D(C) is called the tangent plane distance function. Hence, the problem of the thermodynamical stability analysis consists in resolving the following constrained minimization problem The chemical potential l i [J mol À1 ] of a component i is given by and the relation (6), the function (4) can be rewritten as follow We define the Lagrangian for the constrained problem (5) as where k is the Lagrange multiplier. It is easy to write the optimality conditions from (8) Replacing these optimality conditions in the equation (7), one can show that k is nonnegative. Introducing a variable transformationC i ¼ c i expðÀ k RT Þ, we can proof that the stationary pointsC ¼ ðC 1 ;C 2 ; . . . ;C nc Þ indicate stability when Consequently, this inequality will be used in the following as a term of the complementarity conditions (11) to represent the equilibrium of the oil and gas phases.

Closure equations
To solve any system of equations, we have to make sure that it is mathematically well-defined. This means that the equations are independent, i.e., that no equation can be expressed in term of the others, that a unique solution exists and that the number of unknowns is equal to the number of equations. In order to close the system, we need to add other equations. Firstly we can consider the relations between capillary pressure P o À P w ¼ P cw S w ð Þ; Moreover, since there must be conservation of volume, we have X a2A S a ¼ 1: At last, if the oil phase (resp. gas phase) is present, the following relation holds In the next section, two formulations are detailed and their advantages/drawbacks are discussed.

Natural variable formulation
The reservoir simulation industry commonly uses the formulation introduced by K.H. Coats [10] based on natural variables that are: pressures, saturations and components molar fractions and on the phase apparition detection by a flash calculation. The main advantage of this formulation is the use of the natural set of unknowns for the hydrodynamical and thermodynamical laws. On the other hand, its biggest disadvantage is that the set of unknowns and equations depends on the present phases. For this reason, we have to compute the set of present phases at each point of the space-time domain and then switch unknowns and equation according to which phases are present. We use a negative flash calculation [14] and the saturation sign to determine phases appearances and disappearances respectively. Let A p be the set of present phases, thus, depending on the point in the time-space domain we are considering, we can have We summarize below the principle of the treatment of the phase appearance and disappearance: -The test of phase appearance is done only for the contexts where saturated oil or gas phase is present (i.e., A p = {w,o} or A p = {w, g}). A negative flash calculation for the current reference pressure P and overall composition z returns the gas molar fraction V, then if A p = {w, o} and V > 0 the oil phase becomes saturated and the gas phase appears. A p becomes As in this model, we suppose that the water phase is immiscible with the other phases the context A p = {w} needs a particular treatment (see Sect. 6).
Hence, in the case of no aquifer cells and if we choose oil pressure as the reference pressure, the problem we have to solve is to find for every a 2 A p , P, S a , C a satisfying the following system of equations The following table shows the number of equations we have to solve depending on the context.
Similarly, the unknowns of the system are given by the following table.
We can notice that in all the cases the number of equations corresponds to the number of unknowns. In the next section, we present a new formulation introduced in [15], which is based on nonlinear complementarity conditions [12,16,21].

Complementarity condition formulation
Recently, new formulations have been introduced for modeling systems which have to switch continuously between different states. A new way of incorporating phase transitions into the simulation of multiphase, multicomponent processes in porous media have been developed. The idea is that a fluid phase appears or vanishes if a physical quantity exceeds a given threshold. Based on this observation we formulate the conditions for the local presence of fluid phases as a set of so-called complementarity conditions. This approach uses the fact that these constraints can be reformulated equivalently as a non-differentiable but semismooth equation, called nonlinear complementarity equation. The complementarity problems were first manifested in optimality conditions for optimization problems [12]. The methods for the resolution of complementarity problems have spread in the last years following the work of the numerics [9, 16-18, 21, 22]. We focus on the formulation introduced by Lauser et al. [15] which uses the pressures, the phase saturations and the components fugacities as main unknowns. The biggest advantage of this formulation with respect to the previous one is the use of a fixed set of equations and unknowns independent on the present phases and, therefore, the flash calculation is avoided. The molar fractions C a of the components are computed starting from the fugacities and the reference pressure. They are defined as the solutionC a ¼ ðC a i Þ i¼1;...; n c of the nonlinear system If the phase a is present, the quantityC a coincides with the molar fraction C a . On the contrary, if a is absent,C a represents the molar fraction that is at thermodynamical equilibrium with the ones of the present phase. In this casẽ C a doesn't have a physical meaning but it is still included in the system of equations. For this reason the quantities ðC a i Þ i¼1;...;nc are called extended molar fractions. Thanks to the thermodynamical equilibrium, we have and then the molar fractions of a component i can be computed from the same fugacity f i for both the phases. With this formulation, phase transitions are managed using complementarity conditions. The idea is that a phase a 2 fo; gg is not present if its saturation is zero and the sum of its extended molar fraction is less than one. On the other hand, the phase is present if its saturation is greater than zero and the sum of its extended molar fractions is equal to one. Therefore for one phase a 2 fo; gg we have the following relations: -If phase a is present S a > 0 and 1 À P nc These constraints are equivalent to the following complementarity conditions As said before, they can be reformulated using a complementarity function. In this work, we use the minimum function as complementarity function. Therefore the conditions (11) can be rewritten in the following way Let A = {w, o, g} be the set of phases. Then, the problem we have to solve with this formulation is as follows. Find P ; S a ; ðf i Þ i¼1; ...;nc satisfying the following system of equations where a 2 A: In the following tables, we can find the number of unknowns and of equations of this formulation.
We can notice that, in all the cases, the number of equations corresponds to the number of unknowns. Hence, the resulting system of mass conservation equations and equilibrium conditions is fully free of inequalities (pure set of equations).

Discretization and numerical resolution
Let M h be an admissible finite volume mesh of the reservoir given by a family of control volumes noted K. We also introduce an increasing sequence of discret times ft n g 0 n N such that t 0 = 0 and t N = T and we denote by Dt n the time step such as Dt n = t n Àt nÀ1 for n = 1,. . ., N. The systems (9) and (4) are discretized using fully implicit Euler integration in time and a cell-centered finite volume scheme with a two-point flux discretization. The mobility terms are up-winded with respect to the sign of the phase Darcy flux [1]. The vectors of the discrete unknowns in each finite volume K and on the whole mesh are denoted respectively by X n K and X n h ¼ fX n K g K2M h .

Natural variable formulation
For NVF, the set of discrete unknowns is depending on the context A n p;K in each finite volume K and is given at each time t n by: if A n p;K ¼ fw; o; gg X n K ¼ P n K ; S n w;K ; S n o;K ; S n g;K ; C o;n K ; C g;n K ; if A n p;K ¼ fw; og X n K ¼ P n K ; S n w;K ; S n o;K ; C o;n K ; if A n p;K ¼ fw; gg X n K ¼ P n K ; S n w;K ; S n g;K ; C g;n K : We obtain at each time step n = 1, 2, . . ., N a nonlinear system denoted by where R K X n h À Á is the set of discrete conservation equations and F K X n K À Á is the set of discrete closure equations and thermodynamical equilibrium equations depending in the context in each cell K 2 M h . In the following, we omit the subscript n for the sake of clarity. The nonlinear system (13) is solved at each time step by a Newton algorithm. At each Newton iteration (l), we have to solve the following linear system.
where oR ðlÞ K oX h resp. oF ðlÞ K oX K is the Jacobian of the vector R K (resp. F K ) and dX h . In order to reduce the size of the system (14) in a system of only n c + 1 equations per cell, we split the set of unknowns X K into n c + 1 primary unknowns X p K and a set of remaining secondary unknowns X s K . This splitting is done cell by cell depending on the set of present phases: where R ðlÞ The secondary unknowns X s K are eliminated using the closure equations is assumed to be non singular.
Finally, the linear system we have to solve at each Newton's iteration (l) consists of the following equations   Then, we update the context in each cell K 2 M h using the algorithm presented at the beginning of this section:  . The stopping criteria of the Newton algorithm is given by where || Á || is a given norm, ɛ a specified tolerance and X ð0Þ h is an initial guess for the Newton algorithm. In general, the initial guess corresponds to the values of the unknowns at the previous time step X h ¼ X nÀ1 h . If the Newton algorithm does not converge, the time step is restarted with a value divided by two Át n Át n 2 À Á .

Complementarity condition formulation
One of the advantages of this formulation is that the set of discret unknowns is fixed and it is not depending of the phase state in each finite volume K. It is given by X n K ¼ P n K ; S n w;K ; S n o;K ; S n g;K ; f n 1;K ; . . . ; f n nc;K : After discretization, we obtain at each time step n = 1, 2,. . ., N a nonlinear system denoted by where H K X n h À Á is the set of discret conservation equations with closure equations and / K X n K À Á is the set of discret complementarity equations in each cell K 2 M h . The only drawback of the introduction of the minimum function is that the problem (15) is no longer C 1 but we can solve it using the semismooth Newton's method, called the Newton-min method [9,11]. At each Newton-min iteration (l), we have to solve the following linear system K . This method has locally a superlinear convergence. Globally, when the starting point is not close enough to a solution, the algorithm may diverge, even when the functions are linear, as shown and discussed in [16][17][18]. The size of the linear system may also be reduced by using a similar splitting strategy as in the Coats formulation for primary and secondary variables but this has not been implemented yet in our prototype. For the stopping criteria and the time step control, we use the same strategy as the one presented for NVF.
The advantage of this formulation is to lead to a fixed set of unknowns and equations, which is easier to deal with the phase appearance and disappearance than the Coats formulation. Nevertheless, we have to resolve a local nonlinear system (10) for oil and gas phases and in each finite volume K to obtain the component molar fractions and propagate its derivatives in the density and viscosity laws by using the chain rule lemma. When the fugacity coefficients do not depend on concentrations, typically with K i (T, P) equilibrium models, it only occurs a linear scaling of phase concentrations which is easy to follow. In our case, where the fugacity coefficients are computed by an Equation of State (EoS), it results in a nonlinear scaling and artificial coupling between the concentrations which is more challenging. This is the price to pay for the elimination of fugacity equality constraints from the system.
As regards the initial conditions, we have to set the values of pressure, saturation, and composition of each phase at the initial state. In addition, for the complementarity formulation, we have to compute the initial fugacity starting from the reference pressure and compositions of the phases. If in a cell K 2 M h , the gas phase is present and the oil phase is absent, we have On the other hand, if the oil phase is present and the gas phase is absent, we have At last, if both oil and gas phases are present we can compute the fugacities using indifferently (17) or (18) because the two phases are supposed to be at thermodynamical equilibrium and then It is important to remark that also with this formulation, the case of aquifer cells needs a particular treatment (see Sect. 6).

Aquifer cells
The case of cells where only the water phase and only the water component are present requires major consideration because the water phase is immiscible with other phases. In fact, in this case, for both the formulations, using the equations introduced in the previous sections the system diverges. Therefore we have to change the system of equations to solve. We define a new set of independent unknowns which are pressure and number of moles per unit volume of each component denoted by n i for all i = 1,. . ., n c and introduced in [23]. In these cells we still consider the conservation equation for the water component, however, the conservation equations for the hydrocarbon components become where q i d represents the source term. Therefore in the case of aquifer cells, for both the formulations, the system we have to solve is the following. If A p = {w}, find P; n 1 ; . . . ; n nc such that . . . ; n c ; In the following tables, we can find the number of unknowns and of equations of this particular case.
For the aquifer cells, if at least one n i becomes greater than zero, we must test the appearance of the oil phase and/or the gas phase as follows. We first compute the total molar fraction of each component Knowing the overall composition and the pressure, we can perform a negative flash calculation to obtain the molar fraction of the gas phase V.
if V ! 1 the gas phase appears and then A p becomes A p = {w, g}, if V 0 the oil phase appears and then A p becomes A p = {w, o}.
if 0 < V < 1 the oil and gas phases appear and then A p becomes A p = {w, o, g}.

Numerical results
In this section, we compare the behavior of the natural variable formulation and the complementarity condition formulation by means of selected test settings. In order to model the different physical phenomena present in the study of flows in porous media, more choices are possible. The models chosen in our cases are the following.

Triphasic fluid flow model
The relative permeabilities are modeled using the Brooks and Corey's correlation: k rw S w ð Þ ¼ k rw;max S w À S wi 1 À S orw À S wi nw ; k r ow 1 À S w ð Þ¼k r ow;max 1 À S w ð ÞÀS orw 1 À S wi ð ÞÀS orw now ; where: -S w : water saturation, -S wi : irreducible water saturation, -S orw : residual saturation of oil in the oil-water flow, -S org : residual saturation of oil in the oil-gas flow, -S w : gas saturation, -S gc : saturation of critical gas, k rw;max ; k rwo;max ; k rg;max ; k rog;max : maximum values of the relative permeabilities, nw, now, ng, nog parameters related to the size of the pores.
In our simulation we choose for the parameters the values presented in Table 1, Table 2 and Table 3.
The relative permeability of the oil is computed from the previous functions and from the Stone II model [24] k ro ðS w ; S g Þ ¼ k ro;max k row k ro;max þ k rw k rog k ro;max þ k rg À k rw À k rg : The other physical properties of oil and gas such as the fugacities and the densities are computed using the Peng-Robinson equation of state and for the computation of the viscosities the Lohrenz-Bray-Clark model [25] is used. The properties of water (density and viscosity) are computed using data from [26].

Peng-Robinson equation of state
For each phase a 2 fo; gg, we write the Peng-Robinson equation of state [27] as follows where -P: the reference pressure, -R: universal gas constant, -T: temperature, v a : molar volume of phase a, a a : Van der Waals potential of phase a, b a : covolume parameter of phase a.
In a mixture, the factors a a and b a are defined by Equations n c + 1 Unknowns n c + 1 where C a i is the molar fraction of component i in phase a, a ij ¼ ð1 À d ij Þ ffiffiffiffiffiffiffi ffi a i a j p ; and d ij is a binary interaction parameter between components i and j, and a i and b i are empirical factors for pure component i. The interaction parameters account for molecular interactions between two unlike molecules. By definition, d ij is zero when i and j represent the same component, small when i and j represent components that do not differ much (e.g., when components i and j are both alkanes), and large when i and j represent components that are substantially different. Ideally, d ij depends on pressure, temperature and on the identities of components i and j [28]. The factors a i and b i can be computed from where T ci and P ci are the critical temperature and the critical pressure of component i, the EOS parameters X ia and X ib are given by and x i is the acentric factor of component i. Let Introducing the compressibility factor equation (21) can be expressed as a cubic equation in Z a : Z 3 a À ð1 À B a ÞZ 2 a þ ðA a À 2B a À 3B 2 a ÞZ a À ðA a B a À B 2 a À B 3 a Þ ¼ 0: This equation has three roots. When only one root is real, it is selected. If there are three real roots, the selection of the right one depends on the dominance of the liquid phase or the vapor phase. Now, for i = 1,. . .,n c and a = o, g, the fugacity coefficient of component i in a mixture can be obtained from At last, the fugacity of component i is . . . ; n c ; a ¼ o; g:

Test of CO 2 injection in a three-component system
The first case is a miscible gas (CO 2 ) injection in a quarter of five-spot saturated with oil. The domain has a size of 100 m in both x and y-direction and it is discretized using a 20 Â 20 regular grid blocks. The reservoir model is homogeneous: the permeability is equal to 500 mD and the porosity is 0.3. The gas, composed only of CO 2 , is injected with a constant rate that is equal to 80 m 3 /day and the pressure at the producer is fixed to 55 bar. The temperature is assumed to be constant at 80°C and the initial pressure is equal to 55 bar. The total simulation time is 300 days, the initial time step is 0.05 day and the minimum and maximum time step are respectively 10 À5 day and 20 days. The initial water saturation is given by S w = S wi = 0.25 (S wi is the irreducible water saturation) and the oil saturation is equal to 1 À S wi . The oil and gas phases are a mixture of three components C 1 , C 6 and CO 2 and the initial oil composition is given by C 1 (20%), C 6 (80%) and CO 2 (0%). Figures 1a and 1b show the distribution of the gas saturation in the domain for NVF formulation (Fig. 1a) and CCF formulation (Fig. 1b) at 300 days. Figures 1c  and 1d show the distribution of the CO 2 molar fraction in the gas phase for NVF formulation (Fig. 1c) and CCF formulation at 300 days (Fig. 1d). In Figures 1e and 1f, we report respectively the cumulative oil and gas production. The results are similar for the two formulations.
In Figures 2a-2d, we can see the oil and gas saturation and composition in the middle cell of the domain. The results are the same except for the gas composition when it is missing in the cell. Indeed, for the NVF, the composition of the absent phase is given by the negative flash solution and the sum of the molar fraction in this phase is equal to one, whereas for the complementarity condition formulation, it is obtained by solving the local nonlinear system (10) and the sum is less than one. It is also important to note that the gas phase appears exactly at the same time for both formulations (Fig. 2b).  Table 4 summarizes the numerical results in terms of number of time steps, number of Newton iterations and number of restarted time steps. For this simulation, the NVF and the complementarity condition formulation performed with the same behavior.

Test of CO 2 injection in a seven-component system
The second case study still simulates a CO 2 injection in a three-dimensional quarter five spot saturated with oil. The reservoir size is 100 Â 100 Â 20 m and we use a 20 Â 20 Â 4 grid blocks to discretize the reservoir model. The fluid is a seven components model (C 1 N 2 , C 23 , CO 2 , C 46 , C 712 , C 1319 and C þ 20 ), with the following initial composition: C 1 N 2 (38.8209%), C 23 (14.5821%), CO 2 (2.2685%), C 46 (11.9334%), C 712 (19.4598%), C 1319 (8.7079%) and C þ 20 (4.2274%). The initial pressure and temperature are respectively 200 bar and 132.77°C (above the bubble point). The CO 2 is injected with a fixed rate of 300 m 3 /day and the production pressure is 150 bar (below the bubble point). The other model's properties are the same as in the first test.
The results given in Figures 3a-3f show that the agreement between the two formulations is quite good.
Nevertheless, we observe slight differences for the oil and gas cumulative production.
In Figures 4a-4d, we plot the oil and gas saturation and composition (only for the first four components) in the cell at the middle and at the top of the reservoir. Once again, we observe that the results are identical for both formulations except for the gas composition at the very beginning of the simulation when this phase is absent in the cell. Table 5 indicates that the NVF ran with a lower number of Newton's iterations than the complementarity condition formulation.

Test of condensate gas problem
The third case study is a condensate gas reservoir with a unique producer well in the center. The geometry of the  reservoir is the same than in the first test and the mesh used is composed of 21 Â 21 grid blocks. The initial gas saturation is 1 À S wi with S wi equals to 0.25. The fluid model is the seven components mixture used in the second test but with a different initial global composition: C 1 N 2 (66.8503%), C 23 (14.6099%), CO 2 (3.075%), C 46 (6.8369%), C 712 (6.0289%), C 1319 (1.814%) and C þ 20 (0.785%). We study two different initial points: the first one corresponds to an initial pressure and temperature equal to 290 bar and 196.85°C (470 K), and the second point is near the critical point with an initial pressure and temperature equal to 310 bar and 132.78°C (405.93 K) (Fig. 5). The production pressure is 240 bar (below the dew point).
The total simulation time is 1000 days, the initial time step is 10 À4 day and the minimum and maximum time step are respectively 10 À6 day and 20 days.
The results are the same for both formulations and we report in Tables 6 and 7 only the numerical behavior of these formulations (the total number of time steps and the number of Newton's iterations). In this test case, the complementarity formulation has better behavior than the NVF and especially when starting near the critical point for which the complementarity formulation requires fewer time steps and less Newton's iterations than the NVF.

Test of gas injection in aquifer cells
For the last test, we model an injection of gas in an aquifer. This is a well-known case in the reservoir industry and it is interesting because we suppose that the water phase is pure and immiscible with the other phases. We consider a twodimensional domain initially saturated only by water (S w = 1). The reservoir model and the fluid model are the same as in the first test.
Gas is injected, with a constant rate 30 m 3 /day, in the aquifer through an injection well located at the lower left corner of the domain. The injected gas is composed by C 1 (20%), C 6 (5%) and CO 2 (75%). A production well is located in the upper right corner of the domain and it works with an imposed pressure equal to 50 bar. The temperature is set at 80°C and the initial pressure is 50 bar.   Once again, the two formulations lead to similar physical results. Regarding the numerical behavior, as we can see in Table 8 they perform the simulation with the same number of time steps and without restart. However, we can notice that the CCF formulation effectuates slightly more Newton's iterations than the NVF formulation.

Summary and conclusions
In this work, we develop two isothermal compositional formulations in the same framework and compare them for four different synthetic problems. The first formulation is the well known NVF which is commonly used in reservoir simulator, and the second one is the more recent complementarity condition formulation. The main advantages of this second formulation are to lead to a fixed set of unknowns and equations whatever the present phases and it allows to avoid the flash calculation. Nevertheless, the use of pressures, saturations, and fugacities as main unknowns induces more non-linearities in the system, and we have to solve two local nonlinear systems in each cell and at each Newton's iteration to obtain the component molar fractions in the oil and gas phases in function of the main unknowns.
Our first numerical tests indicate that the two formulations lead to similar physical results with quite similar behavior except for the condensate gas test cases and near the critical point for which the complementarity formulation outperform the NVF in terms of the number of time step and the number of Newton iterations.
Then in order to compare fairly the CPU times, we have to reduce the size of the linearized system at each Newton iteration by adding a splitting strategy (eliminating the closure equations and the complementarity constraints as it is done in the NVF formulation). But the choice of the primary unknowns and remaining secondary unknowns depends on the context in each cell. This work is under investigation.
A study of the semi-implicit time scheme for the complementarity condition formulation is a work in progress. This scheme consists in calculating the flux terms implicitly with respect to the pressure and the saturations, and explicitly with respect to the fugacities. More complex and realistic test cases will also be treated to compare the two formulations.