4.1. Traditional Phase-Split Calculations
Traditionally, phase-split calculations are performed by solving Rachford–Rice (RR) equations involving phase equilibrium constants. Rachford–Rice equations are nonlinear functions obtained from the equal chemical potentials combined with species material balances [
2].
In the case of the three-phase flash, the main equations (Equations (17)–(21)) are reported below, with the hydrocarbon phase used as a as reference [
2,
16].
In this respect, the root-finding calculation is a complex one, given these equations present discontinuities at their extremes (division by zero) and may have an almost flat slope near their roots [
17].
Additionally, in solving the Rachford–Rice equations, the choice of numerical method is influenced by the independent variables that are selected, such as component mole fractions, equilibrium ratios, or the logarithm of equilibrium ratios [
18].
When equilibrium constant ratios or logarithms of equilibrium constants are considered, a Newton–Raphson method is typically applied. In the case of mole fractions, either a Newton method or a minimization of Gibbs free energy can be considered [
19]. Logarithms of K calculations are usually preferred, given the use of mole fractions may create an ill-defined Jacobian, and the natural logarithm stabilizes the Newton method when K values of different orders of magnitude are involved [
18].
Regarding multiphase flash-split calculations with three or more phases, they typically involve an outer loop, where the equilibrium constants are calculated, and an inner loop, where the mass balances (Rachford–Rice equations) are evaluated. The end goal is to determine the phase mole fractions and the compositions for a given set of K values [
20]. This inner loop is known as “constant-K” flash [
21].
Given the above, a general algorithm to solve multiphase flash calculations is described in
Figure 4. It can be observed that within each successive substitution step, the Rachford–Rice equations designated as “constant-K” flash are solved independently.
One should note that the solution of the two-phase constant-K flash calculation is a relatively easy one. However, and in the case where one has to account for a three-phase flash, these calculations may become extensive and challenging. This is due to the non-linearity of the objective resulting functions [
18].
The “constant-K” flash is discussed in
Section 4.2. In this respect, in phase-split calculations, good initial estimates increase the probability of finding the global minimum Gibbs free energy, with an initial guess from stability testing or the previous simulation timestep being an option [
2]. To accomplish this, constraints for the initial estimates are usually needed, as suggested previously by Okuno et al. [
20] and Leibovici and Neoschil [
22].
4.2. Constant-K Flash Solution
The solution of the “constant-K flash” has been studied previously using two different approaches [
24], which include (i) minimization techniques and (ii) direct solution of the RR equations. Tranenstein (1985) [
19] proposed a constrained minimization of the Gibbs free energy to solve the two-phase problem, whereas Leibovicy and Jean (1995) [
22] used a Newton procedure with a relaxation parameter to solve the multiphase problem. Furthermore, Okuno et al. (2010) [
20] minimized the non-monotonic convex function using the independent-phase mole fractions. Haugen et al. (2011) [
24] used a two-dimensional bisection method to provide good initial guesses for the Newton algorithm in the three-phase case. Li and Firoozabadi (2012) [
2] employed stability testing as an initial guess for phase-split calculations with a two-dimensional bisection method for two and three phases. Yan and Stenby (2014) [
25] proposed Householder’s high-order iteration method together with a method to improve the initial estimate for the two-phase problem. More recently, Fernandez-Martinez et al. (2020) [
17] applied an associated polynomial to obtain all the roots of a two-phase isothermal flash.
One of the most popular approaches to solve the “constant-K” flash problem is to use a Newton–Raphson method to solve Rachford–Rice equations (Equations (17) and (18)), obtaining values for
and
. In that case, the Newton–Raphson method considered is given by Equations (23)–(27).
The Newton–Raphson method solution can converge to a non-desired root value, with this being a function of the initial guest. It can also lead to numerical divergence, with this being an inherent characteristic of the non-linear equations being solved [
18]. As shown by Hinojosa-Gomez et al. (2012) [
26], Newton’s method fails to converge near the critical point and phase boundaries. Thus, good initial guesses are required for the phase fraction
calculations, with poor initial estimates leading to incorrect roots or being unable to find a numerical solution [
24,
26].
In this respect, the initial guess for
,
should be constrained within the proper solution domain. In this sense, when approaching the numerical solution of the constant-K flash, it is advantageous to consider this as an iterative constrained minimization calculation instead of being a root-finding problem [
20]:
refers to a convex function, as proven by Okuno et al., 2010 [
20], with
N linear constrains and with
representing the
gradient, with the condition of having a symmetric Jacobian matrix [
20,
27]. If this is the case, the
scalar function involves a gradient vector, which represents the RR equations [
20].
By integrating
(Equations (20) and (21)) with respect to
, one can obtain Equation (31), with the integration constant set to zero:
When examining the possible mathematical solutions for a multiphase system at equilibrium with the number of phases larger than 2 (
Np > 2), one can notice that the range of these solutions is wider than the space of the physical solutions [
22]. To address this matter, Leibovicy and Neoschil (1995) [
22] proposed that numerical solutions should be limited by hyperplanes defined by:
In this respect, it is important to notice that in Equation (31), the region
is unbounded if the following applies: (a) the function is monotonic, (b) it does not have a minimum, and (c) there is no solution to the constant-K flash with
Np phases [
20].
In that sense, Okuno et al. [
20] proposed a feasible solution region based on the non-negativity of phase-component mole fractions in a given phase,
L (
), such as:
Then, from Equation (34) and with positive phase-component mole fractions in phase
L, it results:
And from Equations (35) and (36):
Equations (40), (44), and (47) can be summarized as follows:
For .
Okuno et al. [
20] proposed a general definition of these thermodynamic parameters as:
with
,
and
.
The constant-K flash problem is solved by Equation (49).
In that sense, Equation (49) accounts for the “negative flash” case. One should note that when the iterative flash procedure yields
β values in the
or
ranges, this leads to a “negative flash” [
28]. These “negative flashes”, although “not physically acceptable” roots, can be preserved for the next calculation step. This is the case, given the anticipated function continuity. It is interesting to mention that Okuno et al.’s resulting algorithm performs better with initial negative roots than when the condition
is complied from the very beginning in the first calculation step [
28].
4.3. Algorithm to Solve the Flash Unit for Water/PASN Mixtures
After addressing the numerical solution of the constant-K flash problem, it is possible to complete the flash calculations as described in
Figure 4. In this sense, the steps involved in the flash calculations are as follows:
Input the operating and feed conditions: T, P, zi;
Provide an initial guess for the K-values;
Solve Rachford–Rice equations as discussed in
Section 4.2, minimizing Equation (49);
Calculate , , and from Equations (34)–(36);
Calculate the fugacity coefficients from Equation (15);
Calculate objective functions and compare with tolerance:
Check that , , and .
The main problem with the proposed algorithm is that it may be computationally very expensive [
1] as a function of the initial guesses chosen, as well as presenting both convergence and accuracy issues.
When applying the Newton–Raphson method (Equations (23)–(27)) using an initial estimate within the set boundaries (as presented in the following section), such as and , for the water/PASN, employing SRKKD EoS model and Python, the result is and root with four iterations only. In this respect, the HYSYS V9 results in this case were and , with the difference being much lower than 0.1%. In contrast and as expected, for the water/n-octane system, the calculation reaches the 10,000 maximum number of iterations with the obtained results not having physical meaning: and .
Given the above, the function
(Equation (49)) for the water/PASN mixture was minimized using different methods within the minimize functions available in the Python Optimize library. Tolerance was set in the 10
−8 range, with the percentage of difference for the calculated
values being lower than 0.3%.
Table 1 reports the various methods tested. Best results were obtained using the constrained optimization by linear approximation (COBYLA) method.
However, in spite of this, none of the considered methods led us to meaningful physical solutions for water/n-octane blends, as reported in
Table 2. Not even a genetic algorithm was able to numerically solve this case, arriving at a result of
. Additional explanations of this matter are described in
Section 4.4.
Regarding the VLLE for water/PASN, it can be calculated accordingly, as reported in
Table 3. In this case, the bubble pressure (
), which is of interest for this research, can be calculated using both Python and Hysis V9.
However, when comparing VLLE results from HYSYS V9 and results from SRKKD EoS implemented with Python, the described Python algorithm for water/PASN works better to calculate pressure results than HYSYS V9, as shown in
Figure 5 and
Figure 6, with SRKKD EoS implemented with Python achieving better agreement with experimental data from the CRE VL-Cell.
On the other hand, in the case of water/n-octane blends, the described algorithm presents convergence problems. To describe these issues, it is important to establish how the numerical Rachford–Rice equations (Equations (17)–(19)) influence these types of iterative calculations for both water/n-octane and water/PASN mixtures. To address this matter, the following section evaluates the approach proposed by Li and Firoozabadi [
29] and the boundaries set by Okuno et al. [
20].
4.4. Issues with Constant-K Solution Calculations
Li and Firoozabadi [
29] reported some examples of how
and
surfaces (Rachford–Rice surfaces) change, whereas
and
are varied, with
and
parameters representing the vapor and water fraction, respectively. A display of one of the examples reported by Li and Firoozabadi for a general case [
29] is shown in
Figure 7 for
and
intersecting the
z = 0 plane.
The triangle defined in
Figure 7a by the vertices (0,1), (0, 0), and (1, 0) represents the solution domain [
29], with the solution at
and
plane shown with a red dot.
In this regard, if one attempts to develop a similar Python-based calculation for an octane/water blend “constant-K” flash, one can observe that it is not possible to obtain a converging iterative solution. This is also true for a wide range of octane in water concentrations in the 0.5–99.75 wt.% range.
As a result, to provide a sound explanation of the findings, the following steps were followed:
- (a)
The first step involves the SRKKD EoS model and HYSYS V9 with “constant-K” flash simulations. Equilibrium constants are approximated on this basis and used later for a thorough analysis of Rachford–Rice equations.
- (b)
The second step considers a “constant-K” flash calculation using the equilibrium constant calculated in step 1. This helps to provide a good understanding of how the Rachford–Rice equations perform in such hydrocarbon/water mixtures.
4.4.1. Octane–Water Blends
To illustrate the calculations, a three-phase separator was specified in HYSYS V9 feeding a 100 kgmol/h blend with a 50% mol water/50% mol n-octane mixture for the first step. Working conditions for this three-phase separator were T = 80 °C and a vapor fraction of 0.1. In this case, the presence of air was not considered. Results obtained are reported in
Table 4.
In developing the second calculation step, using the
and
constants obtained from HYSYS V9 in Python, the
RRy and
RRw values were in a low-level range, as shown in
Figure 8a. The values of
and
also changed in a restricted domain. Furthermore, if the
value was higher than 0.63 or
was higher than 0.58, the solution for
and
did not converge.
Additionally, when
RRy and
RRw were considered at z = 0, the obtained
for different values of
led to two parallel and z = 0 plane-superimposed
RRy and
RRw straight lines, as shown in
Figure 9. In contrast, an HYSYS V9 solution was obtained, as identified with a red dot in
Figure 9.
As a result of this and under these conditions, one can understand why the iterative calculations trying to find an intersection of the RRy and RRw lines fail and the “constant-K” solution remains unknown.
Regarding these results, Haugen and Firoozabadi [
24] advanced that algorithms of this type solving
RR equations can fail when the lines at
RRy = 0 and
RRw = 0 are parallel in the domain of interest. In this respect, these authors designated these conditions as the result of a “bicritical point” where two of the phases have very similar compositions. They identified three different kinds of “bicritical regions” [
24]: (i)
, (ii)
or (iii), and
. In this case, the K values for water/n-octane mixtures are as follows:
and
. As a result and given the conditions considered involving
, they could be considered in partial agreement with case (iv) from the Haugen and Firoozabadi criteria [
24].
For different temperatures (in this case, 110 °C) (
Table 5), the behavior of n-octane/water mixtures displays similar calculation challenges, as can be observed in
Figure 10 and
Figure 11.
Haugen et al. (2011) [
24] described that the non-converging lines problem leads to a very large number of iterations, with the numerical solution becoming unacceptably expensive.
Thus, in the case of octane/water mixtures, the described and surfaces make it very challenging for a proposed algorithm, such as the SRKKD EoS model with Python algorithm, to converge towards a “constant-K” flash solution.
4.4.2. PASN/Water Blends
In contrast with the “non-convergence” results described in
Section 4.3 and
Section 4.4.1 for n-octane/water blends, the PASN/water mixtures evaluated with the SRKKD EoS model with Python can provide consistent “constant-K” flash-convergent simulations. This is the case when performing flash calculations for a 50%mole water/PASN mixture. Results after convergence are presented in
Table 6.
Figure 12 reports the calculated
RRy and
RRw, using
KiV and
KiW from the SRKKD model using the Python calculations. In this case, values of
and
are smaller than 0.5, providing converging numerical solutions in all cases.
Figure 13 further describes the “constant-K” flash solution for the
and
lines, displaying the numerical
and
solutions with convergence assured.
4.4.3. Boundary Conditions
Regarding the boundary conditions, if one considers the water/n-octane mixture with K
i approximated by HYSYS V9 (
Figure 11), the boundary conditions proposed by Okuno et al. [
20] result in Equations (54) and (55), with the hyperplanes superimposed to the lines for
and
, as presented in
Figure 14.
Furthermore, in applying the boundary conditions proposed by Okuno et al. [
20] for the water/PASN blend, the hyperplanes related to Equations (56)–(62) can be represented as in
Figure 15.
4.4.4. Remarks
On the basis of results from “constant-K” flash calculations for n-octane/water and PASN/water blends, one can conclude that the composition of hydrocarbon/water blends is a key factor in allowing for a viable numerical calculation using the Rachford–Rice equations. Thus, to address possible calculation uncertainty and ambiguity resulting for octane/water blends, an alternate methodology to calculate the molar fractions and mixture pressure is proposed in the upcoming sections.
4.5. Liquid-Phase K-Values from Experimental Data for Water/n-Octane Mixtures
As discussed in the previous sections, the initial guess for K values affects the convergence of the flash calculation algorithm (
Figure 4). Usually, Wilson correlation [
30] (Equation (63)) is used as a first approximation for the K value in the hydrocarbon phase. For the K values in the water phase, Connolly et al. [
1] suggested values based on the initial feed, as presented in Equation (64).
In this sense, another advantage of the CREC VL-Cell developed by CREC researchers is that it allows one to determine the solubility values based on the VLLE data obtained. The transition from the three-phase and two-phase regions defines the solubility limit.
Figure 16 presents the solubility limit regions for a water/n-octane mixture at 110 °C. This region is characterized by the transition from three phases to two phases.
The applicability of the CREC-VL-Cell for establishing solubility and solubility limits is not restricted to any type of hydrocarbon/water blend. Thus, the CREC-VL-Cell can be of special value in dealing with hydrocarbon/water blends involving intrinsic convergence uncertainties observed by octane–water mixtures while using the Rachford–Rice equations (refer to
Section 4.4).
Figure 17 shows that the solubility limit for an octane/water blend can be calculated from the intersection between the lines that define the three-phase and two-phase domain. The calculated solubilities at 110 °C are
and
, considering the 95% confidence interval defined by the blue region. Although the solubility of water in n-octane is in close agreement with
calculated, the value using HYSYS V9 with SRKKD EoS and Rachford–Rice equations yields a solubility for n-octane in water two orders of magnitude higher compared with the
Hysis V9-predicted value.
As a result, once the solubility values are obtained from the CREC-VL-Cell, it is possible to calculate water-phase constants as . Furthermore, for the vapor phase species at equilibrium, one can obtain an approximative value using and . Assuming the vapor phase behaves as an ideal gas, then , and the obtained results are and .
The mean value obtained has a 16.04% difference from the value predicted by HYSYS V9 (
). However, the HYSYS V9 value is within the range of the 95% confidence interval.
Figure 18 and
Figure 19 report the observed solubilities of water in n-octane and n-octane in water, respectively, as determined in the CREC VL-Cell and compared with the values reported by Maczynski et al. (2004) [
31] for both water in n-octane and n-octane in water.
Furthermore, on the basis of the experimental data obtained in the CREC-VL-Cell, a correlation to obtain the K values for water/octane mixtures in the temperature range of interest and low pressure (1–3 atm) is proposed. This correlation is given by the following Equation (65), with the constants involved reported in
Table 7. A comparison with calculated values from experimental results is also reported in
Figure 20, showing the adequate fitting of the experimental values by this correlation.
Given the observed differences with the experimental points reported in
Figure 6 and obtained in the CREC-VL-Cell, it is important to provide a more precise methodology to calculate the pressures at VLLE, accounting for the uncertainties related to the experimental values. This will be discussed in the following section.
4.6. Machine Learning Approach
As shown in the previous sections of this work (
Section 4.1,
Section 4.2,
Section 4.3,
Section 4.4,
Section 4.5), traditional thermodynamic models for multiphase systems based on Rachford–Rice equations overpredict vapor pressure in cases unable to provide converging and meaningful solutions.
Thus, to implement machine learning, linear regression, KNN, SVM, and decision tree regressor (DTR) are considered. On this basis, the prediction errors, coefficients of determination (R2), mean squared errors (MSE), and mean absolute errors (MAE) are established. To accomplish this for each experimental condition, the following is considered: (a) the predicted number of phases together with the feed molar fraction and temperature as input parameters [
4,
6] and (b) the system pressure as target variable. Additional details of the classification methodology can be found in a recent publication of our research group [
4].
In the case of KNN, SVM, and DTR, the parameters were tuned using a grid search with cross validation (GridSearchCV). This method allows for determination of the best set of parameters in each model based on the coefficient of determination (R
2). The training set was selected by randomly splitting the sample into 80% for training and 20% testing (train_test_split function). Results for the grid search are summarized in
Table 8, showing the best parameters for each method calculated by the GridSearchCV function by comparing R
2.
Table 9 reports the coefficient of determination (R
2), mean squared error (MSE), and mean absolute error (MAE) for the selected models (best score) for octane/water using the abundant testing dataset obtained in the CREC VL cell.
Figure 21 describes a comparison for the pressures measured and the predicted values, showing that the KNN model provides the best approximation, with an R
2 value of 0.99 and MSE values as low as 43.78 and 4.91 parameters. The KNN method is selected as the best model to predict the pressure of water/n-octane mixtures in the range of interest.
The best ML model to describe the behavior of pressure for n-octane/water blends is KNN, with this model overcoming the issues of the traditional thermodynamic models involving the Rachford–Rice equations, significantly reducing the uncertainty of any theoretically thermodynamically based algorithm.
In the same way, if a pseudo-binary mixture is assumed for PASN/water mixtures, a KNN model based on the experimental results can also be applied with an R
2 = 0.9933 MSE = 34.24 and MAE = 4.41, as presented in
Figure 22. The pseudo-component for the PASN is defined using the hydrocarbon blends reported in
Table 6.
Although the ML model developed in the present study has the ability to predict vapor pressure efficiently, it requires a significant number of experimental data points allowing for both the training of the proposed model, as well as its validation. In this respect, the availability of laboratory equipment, such as the CREC VL-Cell, providing abundant phase equilibrium data, is critical for both ML model development and validation.