A Monte Carlo Algorithm for Immiscible TwoPhase Flow in Porous Media
 2k Downloads
 5 Citations
Abstract
We present a Markov Chain Monte Carlo algorithm based on the Metropolis algorithm for simulation of the flow of two immiscible fluids in a porous medium under macroscopic steadystate conditions using a dynamical pore network model that tracks the motion of the fluid interfaces. The Monte Carlo algorithm is based on the configuration probability, where a configuration is defined by the positions of all fluid interfaces. We show that the configuration probability is proportional to the inverse of the flow rate. Using a twodimensional network, advancing the interfaces using time integration, the computational time scales as the linear system size to the fourth power, whereas the Monte Carlo computational time scales as the linear size to the second power. We discuss the strengths and the weaknesses of the algorithm.
Keywords
Dynamical pore network models Markov Chain Monte Carlo Metropolis Monte Carlo Immiscible twophase flow Ergodicity1 Introduction
The characterization of porous media at the pore level is undergoing a revolution (Blunt et al. 2013). Through the use of new scanning techniques, we are capable of reconstructing the pore space completely, including the tracking of motion of immiscible fluids. A gap is now appearing between the geometrical characterization of porous media and our ability to predict their flow properties based on this knowledge.
The pore scale may be of the order of microns, whereas the largest scales—e.g., the reservoir scale—may be measured in kilometers. Hence, there are some eight orders of magnitude between the smallest and the largest scales. At some intermediate scale, that of the representative elementary volume (REV), the porous medium may be regarded as a continuum and the equations governing the flow properties are differential equations. The crucial problem is to construct these effective differential equations from the physics at the pore scale. This is the upscaling problem. A possible path toward this goal is to use brute computational power to link the porescale physics to pore networks large enough so that a continuum description makes sense. Alas, this is still beyond what can be done numerically. However, computational hardware and algorithms are steadily being improved, and we are moving toward this goal.
It is the aim of this paper to introduce a new algorithm that improves significantly the efficiency of network models (JoekarNiasar and Hassanizadeh 2012). These are models that are based on the skeletonization of the spaces in such a way that a network of links and nodes emerge. Each link and node is associated with parameters that reflect the geometry of the pore space they represent. The fluids are then advanced by time stepping some simplified version of equations of motion of fluid. The bottleneck in this approach is the necessity to solve the Kirchhoff equations to determine the pressure field whose gradient drive the fluids in competitions with the capillary forces.
A different and at present popular computational approach, among several, is the lattice Boltzmann method (Ramstad et al. 2010, 2012). This method, based on simultaneously solving the Boltzmann equations for different species of lattice gases, is very efficient compared to the network approach necessitating solving the Kirchhoff equations. However, the drawback of the lattice Boltzmann approach is that one needs to resolve the pore space. Hence, one needs to use a grid with a finer mask than the network used in the network approach. This makes the lattice Boltzmann approach very efficient at the scale where the actual shape of the pores matters, but not at the larger scale where the largescale topology of the pore network is more important. Further methods that resolve the flow at the pore level are, e.g., smoothed particle hydrodynamics (Tartakovsky and Meakin 2005; Ovaysi and Piri 2010; Liu and Liu 2010) and density functional hydrodynamics (Armstrong et al. 2016). When network models are so heavy numerically that the networks that can be studied are not much larger than those studied with the porescale methods, the latter win as they can give a more detailed description of the flow. However, if the computational limitations inherent to network models could be overcome, they would form an important tool in resolving the scaleup problem: At small scales network, models would be calibrated against the methods that are capable of resolving the flow at the pore level. On large scales, their results may be extrapolated to scales large enough for homogenization, i.e., replacing the original pore network by a continuum.
As pointed out above, the bottleneck in the network models is the necessity to determine the pressure field at each time step. When the time steps are determined by the motion of the fluid interfaces, these will be small as they typically are set by the time lapse before the next interface reaches a node in the network. Time stepping allows detailed questions concerning how flow patterns develop in time to be answered. That is, the time stepping provides a detailed sequence of configurations where each member of the sequence is the child of the one before and the parent of the one after. If the quantities that are calculated are averages over configurations, time stepping will provide too much information; for averages, the order in which the configurations occur is of no consequence. If the order in which the fluid configurations occur is scrambled, the averages remain unchanged. This is where the Monte Carlo method enters. It provides a way to produce configurations that will result in the same averages as those obtained through time stepping. The order in which the configurations occur will be different from those obtained by time stepping. The timestepping procedure necessitates that there are tiny differences between each configuration in the sequence, since the time steps have to be small. This limitation is overcome in the Monte Carlo method, which we will describe here. This makes the Monte Carlo method much more efficient than time stepping as we will see.
In Sect. 2, we describe the network model we use to compare the Monte Carlo method with time stepping, see Aker et al. (1998), Knudsen et al. (2002). In the next Sect. 3, we start by explaining the statistical mechanics approach to immiscible twophase flow in porous media that lies behind the Monte Carlo algorithm we propose (Hansen et al. 2016; Savani et al. 2016). In particular, we derive the configuration probability—the probability that a given distribution of fluid interfaces in the model will appear. This is also known as the ensemble distribution in the statistical physics community. Based on this knowledge, we then go on to describe the Monte Carlo algorithm itself. This section is followed by Sect. 4 where we compare the Monte Carlo method with time stepping using the same network model described in Sect. 2. We then go on to compare the efficiency in terms of computational cost of the two methods. We end this section by discussing the limitations of the Monte Carlo algorithm as it now stands and point toward how these may be overcome. We end by Sect. 5 where we summarize the work and draw our conclusions.
2 Network Model
In order to have a concrete system to work with, we describe here the details of the network model we use. The model is essentially the one first developed in references Aker et al. (1998), Knudsen et al. (2002). For simplicity, we do not consider a reconstructed pore network based on a real porous medium (Tørå et al. 2011; Ramstad et al. 2009). Rather, we simply use a twodimensional square network, with disorder in the pore radii, oriented at \(45^\circ \) with respect to the average flow direction as shown in Fig. 1. As described in Knudsen et al. (2002), we use biperiodic boundary conditions. Hence, the network takes a form of the surface of a torus. In this way, the twophase flow enters a steady state after an initial transient period. This steady state does not mean that the fluid interfaces are static. Rather, we use capillary numbers high enough so that fluid clusters incessantly form and break up. By steady state, we mean that the macroscopic averages—averages over the entire network—are well defined and do not drift.
A pressure difference \(\Delta P\) is applied across the network. This is done in spite of the network being periodic in the direction of the pressure difference, see Knudsen et al. (2002). By demanding balance of flow at each node using the Washburn equation (2), we determine the pressures (\(p_i\)) at the nodes. This is done by solving the corresponding matrix inversion problem by using the conjugate gradient algorithm (Batrouni and Hansen 1988).
When the pressures at nodes are known, the flow \(q_{ij}\)—here between neighboring nodes i and j connected by a link—is calculated using Eq. (2). Knowing the velocity of the interfaces in each link, we then determine the time step such that any meniscus can move a maximum distance, say, onetenth of the length of corresponding link in that time. All the interfaces are then moved accordingly, and the pressure at the nodes are determined again by the conjugate gradient algorithm. This is equivalent to eventdriven molecular dynamics. When an interface reaches the node, the interface will spread into the links that are connected to the node and which have fluid entering them from the node. The rules for how this is done are described in detail in Knudsen et al. (2002).
3 Metropolis Monte Carlo
We first describe the theory that lies behind the Monte Carlo algorithm that we present. We need to introduce the concepts of configuration, and configuration probability, also known as the ensemble distribution in the statistical mechanics community. We then go on to derive the configurational probability. Armed with this, we construct the Monte Carlo algorithm (Press et al. 2007) after having presented a short review of the Metropolis version of Monte Carlo (Press et al. 2007; Metropolis et al. 1953).
3.1 Statistical Mechanics of Immiscible TwoPhase Flow
We now turn to complex network topologies. For concreteness, we may imagine a twodimensional square network. However, the arguments presented in the following are general. A configuration is given by the position of all interfaces. Let us denote that \({\mathbf {x}}=(x_1,x_1,x_2,\ldots ,x_N)\), where \(x_i\) is the position of the ith interface. Hence, \(x_i\) contains information both on which link the interface sits in and where it sits in the link. A flow Q passes through the network. The flow equations for the network consist of a Washburn constitutive equation for each link combined with the Kirchhoff equations distributing the flow between the links. The motion of the interfaces is highly nonlinear, but of the form \(\dot{x}_i=g_i({\mathbf {x}})\). Solving these equations gives \(x_j=x_j(t)\).
Is the system ergodic? Equations (7), (14) and (16) answer this question positively. Time averages give, by construction, the same results as configurational averages.
3.2 Implementation of the Metropolis Algorithm
In order to present the details of the Metropolis Monte Carlo algorithm that we propose, we first review the general formulation of the Metropolis algorithm (Krauth 2006; Landau and Binder 2015).
3.2.1 General Considerations
3.2.2 The Implementation
The Metropolis Monte Carlo algorithm based on Eq. (23) consists of two crucial steps. The first step consists in generating a trial configuration, and the second step consists in deciding whether to keep the old configuration or replacing it with the trial configuration.
The first step, generating the trial configuration, is governed by the trial configuration probability \(\pi ({\mathbf {x}},{\mathbf {x}}')\), which must obey the symmetry (21). That is, if the system is in configuration \({\mathbf {x}}\), the probability to pick a trial configuration \({\mathbf {x}}'\) must be equal to the probability to pick as trial configuration \({\mathbf {x}}\) if the system is in configuration \({\mathbf {x}}'\).
Suppose the system is in configuration \({\mathbf {x}}\). One needs to define a neighborhood of configurations among which the trial configuration is chosen. If the neighborhood is too restricted, the Monte Carlo random walk will take steps that are too small and hence would be inefficient. If, on the other hand, the neighborhood is too large, the random walk ends up doing huge steps that will miss the details.
We choose a randomly positioned subnetwork as shown in Fig. 3. The network consists of \(\varLambda \times \varLambda \) links. We “lift” the subnetwork out of the complete network and fold it into a torus, i.e., implementing biperiodic boundary conditions. The configurations of fluid interfaces in the subnetwork remain unchanged at this point.
The biperiodic boundaries of the subnetwork are then opened up, and the subnetwork with the new configuration of fluid interfaces is placed back into the full network. This is then the trial configuration \({\mathbf {x}}'\).
Part of the probabilistic choice of the trial configuration that defines \(\pi ({\mathbf {x}},{\mathbf {x}}')\) rests on the choice of the subnetwork: Its position is picked at random. Hence, if the system is in state \({\mathbf {x}}\) or in trial state \({\mathbf {x}}'\), the probability to pick a particular subnetwork is the same. This makes this part of the choice of trial configuration symmetric. When the subnetwork is time stepped for 4 subsystem pore volumes, this is done at constant flow rate \(\varTheta \). Hence, all subnetwork configurations are equally probable, see Eq. (19). Hence, also this part of the choice of trial configuration is symmetric. The full probability \(\pi ({\mathbf {x}},{\mathbf {x}}')\) is the probability of picking a given subnetwork times the probability that a given configuration will occur. Combining the two leads to the necessary symmetry (21).
We point out here that whereas the configurational probability \(\varPi ({\mathbf {x}})\) in (19) is valid for all configurations, through the way we generate our samples, we are restricting ourselves to physically realistic samples in that they are generated through timestepping parts of the system. We cannot at this stage prove that this does not bias our sampling.
Once the trial configuration \({\mathbf {x}}\) has been generated, it is necessary to calculate the total flow rate \(Q=Q({\mathbf {x}}')\) in the network. We then decide to accept the trial configuration \({\mathbf {x}}'\) by using (23). This defines a Monte Carlo update.
We repeat this procedure until each link in the network has been part of at least one subnetwork. This defines a Monte Carlo sweep.
4 Results
We now present numerical results of the Monte Carlo simulation considering the model described in Sect. 2, and we will compare them with the results by timestepping simulations. Simulations are performed for two different ensembles, one is when the total flow rate Q is kept constant (CQ ensemble) and the other when the total pressure drop \(\Delta P\) is kept constant (CP ensemble). A network of \(40\times 40\) links (\(L=40\)) is considered for both Monte Carlo and timestepping procedure. The subnetwork size is \(20\times 20\) links (\(\varLambda =20\)). To identify whether the system has reached the steady state, we measured the quantities as a function of time steps in time stepping and as a function of sweeps in the case of Monte Carlo. We then identified the steady states when the averages of measured quantities (e.g., \(F_\text {nw}\) and \(\Delta P\) or Q) did not drift with time or with sweeps. We then take average over time (time stepping) or sweeps (Monte Carlo), which give us the time average and the ensemble average, respectively. We average 10 different networks, but with the same sequence of networks for both Monte Carlo and time stepping. First we present the results for CQ ensemble. Two capillary numbers, \(\text {Ca} = 0.1\) and 0.01, are used, and for each \(\text {Ca}\), simulations are performed for different values of nonwetting saturations in intervals of 0.05 from 0.05 to 0.95.
4.1 Constant Q Ensemble
4.2 Constant \(\Delta P\) Ensemble
Percentage of rejected configurations in the constant \(\Delta P\) ensemble
\(\Delta p\)  \(S_{nw}\)  Rejections (%) 

15 kPa  0.3  2.1 
0.5  2.3  
0.7  1.5  
6.5 kPa  0.3  8.8 
0.5  11.6  
0.7  4.2 
4.3 Computational Cost
Here, we present a detailed comparative analysis of the computational cost of the two algorithms. We do this by measuring the computational time (\(T_\text {MC}\) for the Monte Carlo method and \(T_\text {TS}\) for the timestepping method, respectively) for different system sizes L.
We use the conjugate gradient method to solve the Kirchhoff equations. This is an iterative solver. When the network contains \(L\times L\) links (\(L^2/2\) nodes), each iteration demands \(L^2/2\) operations. The number of iterations necessary to solve the equations exactly scales as \(L^2\), making the total cost scale as \(L^\beta \), where \(\beta =2+2=4\). However, in practice, the number of iterations necessary to reach the solution of the Kirchhoff equations to within machine precision is much lower than that needed for the theoretically exact solution. As we shall see, \(\beta \) is much smaller than four.
The number of time steps needed to push one pore volume through the network is \(n_\text {t}\). We expect it to depend on L as \(n_\text {t}=aL^\tau \), where a is a prefactor essentially measuring the number of time steps on the average it takes for an interface to cross a link. In our calculations, this is of the order of 10. Intuitively, this number should be proportional to the length of the network, L, making \(\tau =1\). In practice, as we shall see, it is slightly larger.
Hence, we summarize: The timestepping procedure scales as \(L^{3.99}\), whereas the Monte Carlo algorithm scales as \(L^{1.98}\), as shown in Fig. 8.
4.4 Limitations
A closer inspection of Figs. 4, 5, 6 and 7 shows that the match between the Monte Carlo and the timestepping procedures is good, but not perfect. In this section, we discuss the discrepancies between the two methods quantitatively.
When the nonwetting saturation \(S_\text {nw}\) is small, the nonwetting fluid will form bubbles or small clusters surrounded by the wetting fluid. As \(S_\text {nw}\) is increased, these clusters grow in size until there is a percolationtype transition where the wetting fluid starts forming clusters surrounded by the nonwetting fluid. This scenario has been studied experimentally by Tallakstad et al. (2009a, b). They argued that there is a length scale \(l^*\). Clusters that are larger than this length scale will move, whereas clusters that are smaller will be held in place by the capillary forces. The Monte Carlo algorithm calls for selecting a subnetwork, which is then “lifted” out of the system, “folded” into a torus and then time stepped. The boundaries of the subnetwork will cut through clusters and mobilize these. This changes the cluster structure from that of the timestepping procedure.
Clearly, for the Monte Carlo algorithm to be perfected, this tendency of chopping up large nonwetting clusters needs to be counteracted. Presumably, this is a problem that decreases with increasing system and sublattice size as it is a boundary effect.
5 Conclusion
We have in this work presented a new Monte Carlo algorithm for immiscible twophase flow in porous media under steadystate conditions using network models. It is based on the Metropolis transition probability (23), which in turn is build upon the configuration probability (19) which we derive here. By steadystate conditions, we mean that the macroscopic parameters that describe the flow such as pressure difference, flow rate, fractional flow rate and saturation all have welldefined means that stay constant. On the pore level, however, clusters flow, merge, break up, and so on. The flow may be anything but stationary. We described the algorithm in Sect. 3.2.2.
Computationally, the Monte Carlo algorithm is very fast compared to time stepping. We find that the timestepping procedure when implemented on a square lattice demands a computing time that scales as the linear size of the lattice, L, to the fourth power, whereas the Monte Carlo method scales as the linear size to the second power, see Sect. 4.3. However, there is another term that contributes to the computing time in the Monte Carlo procedure which scales as \(L^{4.88}\). This term has a prefactor associated with it, which is very small compared to the other term scaling as \(L^2\). For L up to about 230, this term is small compared to the first one.
5.1 Open Questions
There are open questions with respect to the Metropolis Monte Carlo approach that we present here. The most important step in the direction of constructing such an approach is to identify the configuration probability (19). The second most important step is to provide a way to generate trial configurations that obey the symmetry requirement (21). Section 3.2.2 is concerned with this.

The Monte Carlo algorithm needs to be generalized to irregular networks, e.g., those based on reconstructed porous media (Blunt et al. 2013).

The necessity to solve the Kirchhoff equations for the entire pore network once for every Monte Carlo update will slow down the algorithm when it is implemented for large systems. Ideally, one should find a way to circumvent this necessity.

The Monte Carlo algorithm has a tendency to break up large nonwetting clusters as described in Sect. 4.4. This is a problem for large nonwetting saturations. It is most probably a boundary effect that comes from the way the subnetworks are constructed. However, it needs to be overcome if the algorithm is to be useful for the entire range of saturations.
We have in this article presented a first attempt at constructing a Markov Chain Monte Carlo algorithm based on the configurational probability (19). There is no reason not to believe that other ways of constructing such Monte Carlo algorithms might be possible that are both faster and do not pose the challenges listed above.
Notes
Acknowledgements
IS, AH and SK thank VISTA, a collaboration between Statoil and the Norwegian Academy of Science and Letters for financial support. SS and AH thank the Beijing Computational Science Research Center and its director, Professor HaiQing Lin, for financial support and for providing an excellent atmosphere for doing science. We thank Eirik Grude Flekkøy, Knut Jørgen Måløy, Miguel Rubi and Marios Valavanides for many interesting discussions.
References
 Aker, E., Måløy, K.J., Hansen, A., Batrouni, G.G.: A twodimensional network simulator for twophase flow in porous media. Transp. Porous Media 32, 163 (1998)CrossRefGoogle Scholar
 Armstrong, R.T., Berg, S., Dinariev, O., Evseev, N., Klemin, D., Koroteev, D., Safanov, S.: Modeling of porescale phenomena using density functional hydrodynamics. Transp. Porous Media 112, 577 (2016)CrossRefGoogle Scholar
 Batrouni, G.G., Hansen, A.: Fourier acceleration of iterative processes in disordered media. J. Stat. Phys. 52, 747 (1988)CrossRefGoogle Scholar
 Blunt, M.J., Bijeljic, B., Dong, H., Gharbi, O., Iglauer, S., Mostaghimi, P., Paluszny, A., Pentland, C.: Porescale imaging and modeling. Adv. Water Resour. 51, 197 (2013)CrossRefGoogle Scholar
 Hansen, A., Sinha, S., Bedeaux, D., Kjelstrup, S., Savani, S., Vassvik, M.: A new set of equations describing immiscible twophase flow in homogeneous porous media. arXiv:1605.02874 (2016)
 JoekarNiasar, V., Hassanizadeh, S.M.: Analysis of fundamentals of twophase flow in porous media using dynamic porenetwork models: a review. Crit. Rev. Environ. Sci. Technol. 42, 1895 (2012)CrossRefGoogle Scholar
 Knudsen, H.A., Aker, E., Hansen, A.: Bulk flow regimes and fractional flow in 2D porous media by numerical simulations. Transp. Porous Media 47, 99 (2002)CrossRefGoogle Scholar
 Krauth, W.: Statistical Mechanics: Algorithms and Computations. Oxford University Press, Oxford (2006)Google Scholar
 Landau, L.D., Binder, K.: A Guide to Monte Carlo Simulations in Statistical Mechanics, 4th edn. Cambridge University Press, Cambridge (2015)Google Scholar
 Liu, M.B., Liu, G.R.: Smoothed particle hydrodynamics (SPH): an overview and recent developments. Arch. Comput. Methods Eng. 17, 25 (2010)CrossRefGoogle Scholar
 Metropolis, N., Rosenbluth, A.W., Rosenbluth, M.N., Teller, A.H., Teller, E.: Calculation of equations of state by fast computing machines. J. Chem. Phys. 134, 1087 (1953)CrossRefGoogle Scholar
 Ovaysi, S., Piri, M.: Direct porelevel modeling of incompressible fluid flow in porous media. J. Comput. Phys. 229, 7456 (2010)CrossRefGoogle Scholar
 Press, W.H., Teukolsky, S.A., Wetterling, W.T., Flannery, B.P.: Numerical Recipes 3rd Edition: The Art of Scientific Computing. Cambridge University Press, Cambridge (2007)Google Scholar
 Ramstad, T., Hansen, A.: Cluster evolution in steadystate twophase flow in porous media. Phys. Rev. E 73, 026306 (2009)CrossRefGoogle Scholar
 Ramstad, T., Hansen, A., Øren, P.E.: Fluxdependent percolation transition in immiscible twophase flows in porous media. Phys. Rev. E 79, 036310 (2009)CrossRefGoogle Scholar
 Ramstad, T., Øren, P.E., Bakke, S.: Simulation of twophase flow in reservoir rocks using a lattice Boltzmann method. SPE J. 15, 917 (2010)CrossRefGoogle Scholar
 Ramstad, T., Idowu, N., Nardi, C., Øren, P.E.: Relative permeability calculations from twophase flow simulations directly on digital images of porous rocks. Transp. Porous Media 94, 487 (2012)CrossRefGoogle Scholar
 Savani, I., Bedeaux, D., Kjelstrup, S., Sinha, S., Vassvik, M., Hansen, A.: Ensemble distribution for immiscible twophase flow in twodimensional networks. arXiv:1606.02569. (2016)
 Sinha, S., Hansen, A., Bedeaux, D., Kjelstrup, S.: Effective rheology of bubbles moving in a capillary tube. Phys. Rev. E 87, 025001 (2013)CrossRefGoogle Scholar
 Tallakstad, K.T., Knudsen, H.A., Ramstad, T., Løvoll, G., Måløy, K.J., Toussaint, R., Flekkøy, E.G.: Steadystate twophase flow in porous media: statistics and transport properties. Phys. Rev. Lett. 102, 074502 (2009a)CrossRefGoogle Scholar
 Tallakstad, K.T., Løvoll, G., Knudsen, H.A., Ramstad, T., Flekkøy, E.G., Måløy, K.J.: Steadystate twophase flow in porous media: an experimental study. Phys. Rev. E 80, 036308 (2009b)CrossRefGoogle Scholar
 Tartakovsky, A.M., Meakin, P.: A smoothed particle hydrodynamics model for miscible flow in threedimensional fractures and the twodimensional Rayleigh–Taylor instability. J. Comput. Phys. 207, 610 (2005)CrossRefGoogle Scholar
 Tørå, G., Øren, P.E., Hansen, A.: A dynamic network model for twophase flow in porous media. Transp. Porous Media 92, 145 (2011)CrossRefGoogle Scholar
 Washburn, E.W.: Dynamics of capillary flow. Phys. Rev. 17, 273 (1921)CrossRefGoogle Scholar
Copyright information
Open AccessThis article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.