Thermodynamics-Like Formalism for Immiscible and Incompressible Two-Phase Flow in Porous Media Alex Hansen, Santanu Sinha Abstract It is possible to formulate immiscible and incompressible two-phase flow in porous media in a mathematical framework resembling thermodynamics based on the Jaynes generalization of statistical mechanics. We review this approach and discuss the meaning of the emergent variables that appear, agiture, flow derivative and flow pressure, which are conjugate to the configurational entropy, the saturation and the porosity respectively. We conjecture that the agiture, the temperature-like variable, is directly related to the pressure gradient. This has as a consequence that the configurational entropy, a measure of how the fluids are distributed within the porous media and the accompanying velocity field, and the differential mobility of the fluids are related. We also develop elements of another version of the thermodynamics-like formalism where fractional flow rather than saturation is the control variable, since this is typically the natural control variable in experiments. 1  Introduction In spite of immisicble multi-phase flow in porous media being a field of great industrial importance for more than a century, basic research in this field has not received the attention that it deserves. A main reason for this is that the field is fragmented, being spread over many different disciplines such as biology, geology, geophysics, physics, chemistry, and materials science. Another reason is that it is easy to get the impression that it is not “clean" in the sense that it is a field where theories may be built. Rather it seems to be a collection of phenomena in need of classification. It is the aim of this paper to convince the readership that this is indeed not the case. There is a physics of flow in porous media Feder [2022] where general principles may be formulated. We will in the following present the readers with a review of our ongoing attempts at formulating a mathematical framework for immiscible and incompressible two-phase flow in porous media. In 1907, Buckingham introduced several of the central concepts used today in describing immiscible and incompressible fluid flow in porous media Buckingham [1907] , Narasimhan [2007] , but without joining them through equations. This was first done by Richards in 1931 Richards [1931] , who — as Buckingham — placed the flow problem in the context of water movement in soils. In 1936, building on the work by Wyckoff and Botset Wyckoff [1936] , Muscat and Meres Muscat [1936] introduced the concept of relative permeability, a concept generalizing the notion of “capillary conductance" that Buckingham introduced Buckingham [1907] . With the introduction of the capillary pressure curve by Leverett Leverett [1940] into the framework established by Muscat and Meres, the generalized Darcy constitutive equations that are generally used today in e.g. reservoir simulation, were in place. The formulation of the problem in the context of water in soils that Buckingham pioneered and which was followed by the work of Richards forms an alternate formulation of essentially the same ideas. We review briefly relative permeability theory — the only approach to immiscible two-phase flow in porous media in practical use today — in Section 2 . Relative permeability theory is purely phenomenological and has well-known deficiencies. As a result, there is an ongoing effort to derive effective equations going beyond relative permeability theory based on the physics at the pore scale. This effort is based on homogenization which we review briefly in Section 3 . In Section 4 , we introduce our approach to immiscible two-phase flow in porous media based on a generalization of statistical mechanics by Jaynes Jaynes [1957] , Hansen [2023] . Statistical mechanics in its traditional role is to connect a molecular description of matter to a description at the much larger scales where matter appears continuous, namely thermodynamics. In adopting this idea to two-phase flow in porous media, we find a thermodynamics-like framework on large scales that together with conservation laws provide a closed set of equations that has the equations of relative permeability theory as a special case. As in ordinary thermodynamics, the difference between intensive and extensive variables is central. We explore this in Section 5 . The intensive variables appearing in the thermodynamics-like formalism we derive are emergent in that they have no equivalent on the pore scale. This is discussed in Section 6 . The temperature-like intensive variable, agiture, we conjecture to be proportional to the pressure gradient in Subsection 6.1 . This conjecture has as a consequence that the configurational entropy, which is an example of Shannon’s information entropy, is related to the differential mobility 1 1 1 The differential mobility is the derivative of the flow velocity with respect to the pressure gradient. The mobility is the flow velocity divided by the pressure gradient. of the fluids. The flow derivative we discuss in Subsection 6.2 is the conjugate variable to the saturation which is the fractional volume. We end the section by discussing the conjugate of the porosity, the flow pressure in Subsection 6.3 . In Section 7 , we introduce the co-moving velocity which relates the thermodynamic velocities — corresponding to partial molar volumes in ordinary thermodynamics — to the seepage velocities which are the average pore velocity of each of the immiscible fluids. This concept has the potential to become a very useful concept in practical calculations. Section 8 contains material that has not been presented before. We start by pointing out a choice made when constructing the Jaynes statistical mechanics in Section 4 , and how it could have been made differently. Then, in Subsection 8.1 , we discuss what the ensuing thermodynamics-like formalism would be as a consequence: rather than having saturation as one of the control parameters, we find fractional flow rate being a control parameter. This is useful as this is the control parameter used in core flooding experiments. We end by summarizing and concluding in Section 9 . 2  Relative permeability theory The core idea of the relative permeability approach may be summarized as follows: We have two immiscible fluids, one more wetting with respect to the porous matrix than the other fluid. We will refer to them as the wetting (w) and non-wetting (n) fluid respectively. From the perspective of the wetting fluid, the pore space it sees is the total pore space of the porous medium minus the pore space occupied by the non-wetting fluid, and vice versa. The relative reduction of pore space for each fluid implies a reduction in effective permeability for each fluid. We express these statements in the form of two constitutive equations, one for each fluid Feder [2022] , \displaystyle{\vec{v}}_{w} \displaystyle= \displaystyle-\ \frac{Kk_{rw}(S_{w})}{\mu_{w}\phi S_{w}}\nabla P_{w}\;, (1) \displaystyle{\vec{v}}_{n} \displaystyle= \displaystyle-\ \frac{Kk_{rn}(S_{w})}{\mu_{n}\phi S_{n}}\nabla P_{n}\;. (2) Here {\vec{v}}_{w} and {\vec{v}}_{n} are the pore velocities of the wetting and non-wetting fluids, K is the (isotropic) permeability of the porous medium, \mu_{w} and \mu_{n} are the viscosities of each fluid, \phi is the porosity of the porous medium, P_{w} and P_{n} are the fluid pressures, S_{w} and S_{n} are the wetting and non-wetting saturations, and k_{rw}(S_{w}) and k_{rn}(S_{w}) are the relative permeabilities of the two fluids. It is an essential assumption in this theory that these two quantities are functions of the saturations alone. The saturations S_{w} and S_{n} are defined as the fraction of pore space occupied by each fluid so that S_{w}+S_{n}=1\;. (3) The difference in pressure between the two fluids is defined as the capillary pressure curve P_{c} , P_{n}-P_{w}=P_{c}(S_{w})\;. (4) It is an assumption that the capillary pressure curve only depends on the saturation S_{w} . The capillary pressure curve is a particularly difficult quantity, both conceptually and in terms of measurement, see e.g. Moura [2015] . We define the average pore velocity {\vec{v}}_{p} as {\vec{v}}_{p}=S_{w}{\vec{v}}_{w}+S_{n}{\vec{v}}_{n}\;, (5) i.e., we are using a volume average. This makes sense since we are assuming the fluids to be incompressible: \nabla\cdot[\phi{\vec{v}}_{p}]=0\;. (6) Volume conservation then gives \displaystyle\phi\frac{\partial S_{w}}{\partial t}+\nabla\cdot\left[\phi S_{w}{\vec{v}}_{w}\right] \displaystyle= \displaystyle 0\;, (7) \displaystyle\phi\frac{\partial S_{n}}{\partial t}+\nabla\cdot\left[\phi S_{n}{\vec{v}}_{n}\right] \displaystyle= \displaystyle 0\;, (8) where t is time. This set of equations is closed as long as k_{rw}(S_{w}) , k_{rn}(S_{w}) and P_{c}(S_{w}) are provided. In an industrial context, Special Core Analysis — SCAL — forms the work flow for obtaining this information. 3  Homogenization It is well known that assuming the three constitutive functions depend only on the saturation is generally not correct. The relative permeabilities do depend not only on the saturation, but also how the fluids arrange themselves in the porous medium, and this depends in turn on the flow rate. The capillary pressure curve is highly hysteretic, signaling that there are missing variables. However, it has turned out to be difficult to go beyond this almost 90 years old phenomenological framework. The dominating approach is based on homogenization. This approach may be divided into two branches: That which focuses on momentum transfer and that which focuses on energy transfer. In the first case, one starts with the hydrodynamic equations on the pore scale Ariault [1986] , Auriault [1987] , Auriault [1989] , Picchi [2018] , Picchi [2019] , Lasseux [2022] , and in the second case, one sets up a thermodynamic description at the pore scale Hassanizadeh [1979] , Hassanizadeh [1990] , Hassanizadeh [1993] , Hassanizadeh [1993b] . Then comes the coarse-graining, i.e., spatial averaging. There are several ways of doing this, perhaps that of Whitaker is the most well-known Whitaker [1986] , Whitaker [1986a] . It is based on equating the average of the gradient of a variable associated with pore space to the gradient of the average variable plus an integral over the surface area of the pores. Since the surface area of porous media scales as the volume (i.e., the surface area is extensive — the defining property of porous media), this integral does not vanish as one goes up in scale. We split the variable appearing in the surface integral into an average part and a fluctuating part. This leaves us with having the average, and gradients of the average expressed in terms of the fluctuations of the original variable. The last step is to make an independent assumption on how the fluctuating variables is related to the averages –– a closure assumption. With this, the equations between the original, pore-scale variables have been turned into equations between spatial averages of these variables. Whereas the first of these two approaches is based on momentum transfer, the second approach is based on energy transfer, i.e., thermodynamics. One starts with a thermodynamic description on the pore level which is then homogenized. This approach has developed into Thermodynamically Constrained Averaging Theory (TCAT) Gray [2005] , Gray [2005a] , Niessner [2011] , Gray [2014] . A recent paper by McClure et al. McClure [2022] attempts to derive the relative permeability equations from an energy budget based on thermodynamic considerations and homogenization. The relative permeability equations do appear as a first term in a series expansion. It is not shown in McClure [2022] , however, that the higher order terms are negligible. The topology of a geometric object such as a porous medium may be described using the four Minkowski functionals volume, surface area, mean curvature, and the Euler characteristics. The Hadwiger theorem states that the Minkowski functionals form a complete basis set for all extensive functions that are invariant with respect to the orientation of the object Mecke [2000] . The use of this theorem to characterize the free energy of fluids in a porous medium combined with homogenization forms another approach to the scale-up problem McClure [2018] , Khanamiri [2018] , Armstrong [2019] , McClure [2019] . Homogenization as seen so far is based on spatial averages only. McClure et al. McClure [2021] , McClure [2021] emphasize that there is also time which one should average over and that different processes work on different time scales. An approach circumventing the complexities associated with homogenization is based on classical non-equilibrium thermodynamics Groot [1984] , Kjelstrup [2017] , see kbhhg19 [] , kbhhg19b [] , Winkler [2020] , Bedeaux [2022] . By using the extensiveness of the internal energy of the fluids in the porous medium, the Euler theorem for homogeneous functions allows for defining thermodynamic variables such as pressure and chemical potentials on the Darcy scale. Gradients in the intensive variables are introduced and the machinery of classical non-equilibrium thermodynamics Groot [1984] , Kjelstrup [2017] is then set in motion. The underlying homogenization is somewhat hidden in this approach, but it is underlying the way a Representative Elementary Volume (REV) is defined and used. The main practical difficulty with homogenization is the complexity of the ensuing equations and the large number of variables that are necessary. The root of this difficulty is that homogenization can only produce averages over the original variables, and thus cannot produce new types of variables which go hand in hand with capturing emergent properties Anderson [1972] . 4  Statistical mechanics The essence of these efforts has been to find a description of immiscible and incompressible two-phase flow in porous media at scales where the medium acts as a continuum. 2 2 2 Including compressibility would necessitate switching from conserved fluid volume to conserved fluid mass. It would also couple the theory to ordinary thermodynamics through equations of state for the compressible fluids. We wish to avoid these complications at the present stage. This is an example of upscaling. The situation is thus that we have a continuum scale phenomenological theory — relative permeability theory that is simple enough to be used in practical situations, but which is approximate. Attempts at going beyond this theory has, however, not led to practical applications due to the complexity that arises. However, if we look beyond the problem we discuss here, there is an example of successful upscaling that is very familiar: The scale-up from a molecular description to thermodynamics based on statistical mechanics. At molecular scales, the position and momentum of each molecule are the variables that describe a monoatomic gas. This works even if we are dealing with millions of molecules in a molecular dynamics simulation Frenkel [2023] . However, it is rather of the order 10^{23} molecules that are relevant in e.g. chemistry. A molecular description at such scales is useless. Here emergent variables such as temperature and pressure adequately describe the gas. Statistical mechanics converts the molecular description to thermodynamics which not only contains emergent variables but also relations between them. These variables and their relations have no meaning within a molecular description. In the mid-fifties, Jaynes generalized statistical mechanics from being a theory for molecular matter to being based on information theory Jaynes [1957] . This was done by replacing Boltzmann’s statistical interpretation of thermodynamic entropy by Shannon’s generalized information entropy Shannon [1948] . The information entropy is a quantitative measure of what is not known about a system. Suppose we have a stochastic process that can produce N possible outcomes. We number the outcomes from 1 to N , assuming a probability p_{i} for the i th outcome, x_{i} . A quantitative measure of our ignorance about this process must be independent of how we group events together. For example, if we consider composite events such as p_{ij}=p_{i}p_{j} , i.e., the probability that an event i is followed by an event j , then the information entropy must remain the same. If we know nothing about the process, its information entropy must be at a maximum, since our ignorance is maximal. In order to utilize this, Shannon generalized to N outcomes the Laplace principle of insufficient reason Laplace [2003] which states that the optimal choice of probabilities for a stochastic process with two possible outcomes is to assign them equal probability. Hence, the optimal choice when there are N outcomes is to assign all probabilities the same value, p_{i}=1/N . There is only one function that can be constructed from p_{i} with these properties, S_{I}=-\sum_{i=1}^{N}p_{i}\ln p_{i}\;, (9) which is then the information or Shannon entropy. Jaynes then posed the question, what happens if we do know something about the system? Suppose we know the average of the outcomes, \langle x\rangle=\frac{1}{N}\sum_{i=1}^{N}p_{i}x_{i}\;. (10) Generalizing the principle of insufficient reason further, Jaynes proposed that the probabilities p_{i} in this case should be those that maximize the information entropy ( 9 ) given a fixed value for \langle x\rangle , equation ( 10 ). Figure 1: We define a plane that cuts through the cylindrical pore sample orthogonally to the average flow direction. We define Representative Elementary Area (REA) within the plane. There is a wetting fluid flow rate Q_{w} and a non-wetting fluid flow rate Q_{n} passing through the REA. The total flow rate is Q_{p} . The wetting fluid covers an area A_{w} of the REA and the non-wetting fluid an area A_{n} . The total pore area of the REA is A_{p} . Jaynes provided a set of circumstances for his generalized statistical mechanics to be applicable. Hansen et al. Hansen [2023] demonstrated that these circumstances are met for steady-state immiscible two-phase flow in porous media, and hence proceeded to construct such a statistical mechanics. The generalized statistical mechanics will produce a thermodynamics-like framework at large scales. This thermodynamic-like framework is the end goal of this approach. Suppose we have a cylindrical pore sample as shown in Figure 1 . Two immiscible fluids enter at the bottom and leaves at the top. The side walls are close off. We assume that the pore structure and chemical composition of the matrix to be statistically uniform throughout the sample. At some distance from the lower edge of the sample, one may assume that the fluids have mixed sufficiently to assume steady-state flow. That is, if we make transversal cuts through the sample, the structure of the porous medium and the distribution of fluids in the pore space to be statistically uniform: Comparing one cut to another, we will not be able to determine which is closest to the inlet. Figure 1 shows one such cut. Within this cut, we pick out a Representative Elementary Area (REA), which is large enough to represent the statistics of the sample and small enough to have the flow fluctuate. There is an volumetric flow rate Q_{p} passing through the REA which may be split into a volumetric flow rate of the wetting fluid Q_{w} and the volumetric flow rate of the non-wetting fluid Q_{n} , i.e., Q_{p}=Q_{w}+Q_{n}\;. (11) The area of the REA is A . An area A_{p}