1 Introduction

Multiphase simulation of flow and transport across different scales is relevant to a vast range of natural and industrial applications, e.g. enhanced oil recovery (Akai et al. 2020; Aziz et al. 2020; Golparvar et al. 2018), geological CO\(_2\) and hydrogen storage (Celia et al. 2015; Krevor et al. 2015; Sáinz-García et al. 2017; Hashemi et al. 2021), optimization of fuel-cells operation (Niblett et al. 2020; Mukherjee et al. 2011), industrial energy storage (Chen et al. 2017; Qiu et al. 2012), etc. The accuracy of continuum-scale multiphase modelling depends on constitutive relations such as relative permeability and capillary pressure. These can be obtained numerically using digital rock physics, or through time-consuming and expensive experimental procedures (i.e. core flooding, two-phase centrifuge, etc.) (Blunt et al. 2013).

In recent decades, with improvements in X-ray tomography and other visualization techniques, we can visualize inside porous media and characterize events, fluid distribution, and in situ distribution of phases in porous media. Such advances helped us develop and verify digital rock physics techniques to simulate multiphase flow in porous media (Blunt et al. 2013). Hence, pore-scale models are a backbone of existing predictive models, either for phenomenological studies, upscaling of constitutive relations or avoiding experimental routines (Andrä et al. 2013).

Recent developments in the realm of pore-scale modelling of multiphase flow focus on simulating flow through a realistic digital representation of complex pore space (Raeini et al. 2014; Armstrong et al. 2016). It is well-understood that the pore structure in combination with fluid–fluid and solid–fluid interfacial forces governs the dynamics of multiphase flow and the geometry and morphology of phases (McClure et al. 2018; Bultreys et al. 2018; Liu et al. 2017). The pore structure of porous media can be obtained with good accuracy using \(\mu\)-CT X-ray imaging; additionally, there are well-established experimental methods to accurately measure fluid–fluid interfacial forces. In contrast, methods for assigning solid–fluid interfacial forces are not yet established. Fluid–fluid interfacial forces can often be considered constant throughout the simulation domain, and can therefore be described by simple models. Solid-fluid interfacial forces are usually imposed into the model using the wetting state of the solid wall and can have significant variation throughout the simulation domain, complicating its description (Berg et al. 2017).

Wettability is the relative preference of one fluid to coat the solid surface in the existence of another immiscible fluid, which is usually quantified by the contact angle (Cassie and Baxter 1944). The pore surface wettability determines the local balance of capillary forces and controls the local fluid distribution and morphology. The assignment of wettability to pore-scale models has long been recognized as having a strong impact on effective multiphase flow, and the lack of established methods has been recognized as the most significant issue for predictive multiphase modelling (Sorbie and Skauge 2012; Bondino et al. 2013). This long-lasting challenge is still an area of debate, and the in situ characterization of wettability is still considered inaccurate (Armstrong et al. 2021).

Despite recent attempts, measuring in situ contact angles on the fluid–solid–fluid (three-phase contact) line exhibits significant uncertainty and error due to contact angle hysteresis, effects of pore structure complexity, surface roughness, noise in image capturing, processing and segmentation (Andrew et al. 2014; Garfi et al. 2020, 2022). The pore-scale observations of two-phase fluid flow can be averaged into an equilibrium contact angle for the whole sample (Blunt et al. 2019), while it is well-known that the wetting state can be spatially variable in the pore space due to numerous reasons, e.g. mineralogy, clay coating, roughness, polar component coating, etc. (Blunt et al. 2013; Schmatz et al. 2015; Morrow 1975; Yang et al. 1999; Singh et al. 2016).

Various approaches were followed by different researchers to measure local contact angles in porous media to make a wettability map instead of assigning a constant wetting property to the whole sample with the aim of a more accurate multiphase flow simulation. Most of the studies use geometrical approaches to measure the local contact angle on the three-phase contact line (Khanamiri et al. 2020; Sun et al. 2020b; Blunt et al. 2020). Deficit curvature of the fluid and solid interfaces has also gained significant attention recently (Sun et al. 2020a, c, 2022). Some studies used the extracted pore network of the sample to measure local wettability, e.g. Mascini et al. (2020) used the extracted network of the sample to identify pore-filling events (Haines jump) to calculate local wettability (Zacharoudiou and Boek 2016; Zacharoudiou et al. 2018). Garfi et al. (2022) used the solid surface coverage in the pore regions to calculate the local wettability. Moreover, Foroughi et al. (2021) used a pore-by-pore scheme to optimize the local wetting property using experimental dynamic X-ray tomography of capillary-dominated displacement in the porous media.

In this paper, we introduce a new automated workflow to characterize the local wetting distributions in porous media using X-ray images of two-phase fluid distribution. For the multiphase simulation, we use the lattice Boltzmann method (LBM), and the model of choice is called the colour-gradient model which was originally proposed by Gunstensen et al. (1991) and modifications later on McClure et al. (2021). Yang and Boek (2013) showed the capabilities of colour-gradient LBM to simulate the flow of binary fluids with high viscosity contrast and high numerical stability. In this model, the contact angle can be simply defined by an affinity parameter (McClure et al. 2021). Simulations are conducted on isolated ganglia to get the wetting properties on the three-phase contact lines. Consequently, we have one LBM simulation for each ganglion, reducing the simulation domain and thereby improving the computational efficiency. We used a derivative-free optimization scheme to minimize the difference between the fluid distribution from the LBM simulations and the imaged ganglia geometry by varying the surface affinity parameter in the colour-gradient LBM. Local wetting properties information was populated into the whole sample by a three-dimensional (3D) linear interpolation technique to construct a wettability map for the whole sample. Then, the proposed workflow was utilized to characterize the wettability of three publicly available datasets, and the obtained results were compared with geometrical curvature analysis.

This manuscript is organized as follows: in the next section, Sect. 2, we will present the methods used in this paper; the LBM method, wettability determination from geometrical analysis, and wettability determination through our introduced method using LBM simulations. We will also present three experimental data sets used for testing our introduced methodology. In Sect. 3, first we provide numerical validation, in which we compare the results of the developed workflow with the more traditional geometrical analysis method for contact angle calculation for two synthetic cases. Then, we will present the contact angle distribution obtained by applying the geometrical method and the introduced LBM simulation method for the three experimental cases. Further, we will compare and discuss the results. In the last section, Sect. 4, we summarize and conclude.

2 Materials and Methods

This section starts by introducing the methods used in this article and is followed by a presentation of the experimental data. The experimental data will be used in the next section to test our introduced methodology for wettability characterization. As our introduced methodology is based on LBM simulations, we start this section with a brief overview of the LBM method.

2.1 Colour-Gradient Lattice-Boltzmann Model

The LBM is a computationally efficient and alternative approach to the classical computational fluid dynamics (CFD) methods to model flow and transport in complex geometries, which can be adapted to a wide range of applications. Models based on the LBM have been widely applied to study multiphase flow in porous media, with the colour-gradient model being the most popular implementation of two-fluid simulation (Huang et al. 2015; Ramstad et al. 2019). In this study, we used the LBPM open-source package (McClure et al. 2021), which is optimized to simulate incompressible immiscible two-fluid flows in \(\mu\)CT images of porous media. LBPM has routines to simulate unsteady displacement, steady-state flow at fixed saturation, and mimic centrifuge experiments (McClure et al. 2021). Here, we provide a brief introduction to lattice Boltzmann (LB) formulation and wetting state implementation of the LBPM for the sake of completeness, and the readers are referred to McClure et al. (2021) for more detailed formulation and in-depth discussion.

The colour-gradient LB model is defined based on three sets of lattice Boltzmann equations (LBE) to capture the interfaces between components a and b, and hydrodynamic properties. For incompressible immiscible mixture, the number density of two fluids, \(N_a\) and \(N_b\), must be conserved. Two particle-distribution functions, A and B, are defined which are governed by the following LBEs:

$$\begin{aligned} A_q({\textbf{x}}+\varvec{\zeta }_q\delta t,t+\delta t)&=\omega _q N_a\left[ 1+\frac{{\textbf{u}}\cdot \varvec{\zeta }_q}{c_s^2}+\beta \frac{N_b}{N_a+N_b}{\textbf{n}} \cdot \varvec{\zeta }_q \right] \end{aligned}$$
(1a)
$$\begin{aligned} B_q({\textbf{x}}+\varvec{\zeta }_q\delta t,t+\delta t)&=\omega _q N_b\left[ 1+\frac{{\textbf{u}}\cdot \varvec{\zeta }_q}{c_s^2}-\beta \frac{N_a}{N_a+N_b}{\textbf{n}} \cdot \varvec{\zeta }_q \right] \end{aligned}$$
(1b)

where \({\textbf{x}}\) and t are the space and time, respectively, \(\delta t\) is the time step, and \({\varvec{u}}\) is the flow velocity computed from hydrodynamic equations. The \(\beta\) parameter controls the thickness of the interface of the two components, and \({\varvec{n}}\) is the unit normal vector of the interface. In the above equations, \(\varvec{\zeta }_q\) and \(\omega _q\) are the microscopic velocity and the weighting factor in the q-direction of a lattice model, respectively. For our three-dimensional (3D) modelling, a seven-lattice velocity model (\(Q=7\)) is chosen for the above-mentioned equations, i.e. D3Q7. As such, the weights are \(\omega _0=\frac{1}{3}\), \(\omega _{1,\ldots ,6}=\frac{1}{9}\) and the microscopic velocities are the first seven directions in Eq. (6), i.e. \(q=0,\ldots ,6\). The speed of sound for this lattice is given by \(c_s=\frac{\sqrt{2}}{3}\). The number density of the two fluids is computed by the zeroth-moments of the corresponding particle distribution functions:

$$\begin{aligned} N_a&=\sum _{q=0}^{Q-1} A_q \end{aligned}$$
(2a)
$$\begin{aligned} N_b&=\sum _{q=0}^{Q-1} B_q \end{aligned}$$
(2b)

A phase indicator field, \(\phi\), is defined to locate the interface by the density of the two fluids:

$$\begin{aligned} \phi =\frac{N_a-N_b}{N_a+N_b} \end{aligned}$$
(3)

The unit normal vector of the colour gradient is calculated as

$$\begin{aligned} {\textbf{n}}=\frac{\varvec{\nabla }\phi }{|\varvec{\nabla }\phi |} \end{aligned}$$
(4)

In addition to the mass transport equation, momentum needs to be transported by an LBE to solve for two-fluid flow in porous media. A new particle distribution function, f, is defined which is governed by the following LBE equipped with the multi-relaxation-time (MRT) collision operator:

$$\begin{aligned} f_q({\textbf{x}}+\varvec{\zeta }_q\delta t,t+\delta t)-f_q({\textbf{x}},t)= \sum _{k=0}^{Q-1}M_{q,k}^{-1}S_kM_{q,k} (f_k^{eq}-f_k) \end{aligned}$$
(5)

where M and \(M^{-1}\) are the orthogonal transformation matrix and its inverse, respectively (Lallemand and Luo 2000), and S is the diagonal relaxation matrix containing the relaxation rates for each moment. Among the relaxation rates, the relaxation rate \(\tau\) is related to the kinematic viscosity of the fluid with \(\nu =c_s^2(\tau -0.5)\), while the rest of the relaxation times are determined based on accuracy and numerical stability. Generally, the MRT collision operator is employed to perform the collision in a moment space instead of a discrete velocity space which results in higher stability in lower kinematic viscosities. The equilibrium distribution function, \(f_k^{eq}\), and matrices M, \(M^{-1}\), and S are defined in detail in McClure et al. (2021), and their definitions are not mentioned here for the sake of briefness.

The hydrodynamic LBE (Eq. (5)) is solved on a popular D3Q19 lattice which is used by the LBPM package. For this lattice, the velocity set is

$$\begin{aligned} \varvec{\zeta }_{q} = {\left\{ \begin{array}{ll} \{0,0,0\}^T &{} \text {for}\; q=0\\ \{\pm 1,0,0\}^T &{} \text {for}\; q=1,2\\ \{0, \pm 1,0\}^T &{} \text {for}\; q=3,4\\ \{0,0, \pm 1\}^T &{} \text {for}\; q=5,6\\ \{\pm 1,\pm 1,0\}^T &{} \text {for}\; q=7,8,9,10\\ \{\pm 1,0,\pm 1\}^T &{} \text {for}\; q=11,12,13,14\\ \{0, \pm 1,\pm 1\}^T &{} \text {for}\; q=15,16,17,18\\ \end{array}\right. } \end{aligned}$$
(6)

and the weights are \(\omega _0=\frac{1}{3}\), \(\omega _{1,\ldots ,6}=\frac{1}{18}\), and \(\omega _{7,\ldots ,18}=\frac{1}{36}\). The speed of sound for D3Q19 lattice is \(c_s=\frac{1}{\sqrt{3}}\). By solving the LBE (Eq. (5)), one can determine the flow velocity based on the first moment of the distribution function:

$$\begin{aligned} {\textbf{u}}=\frac{\sum _{q=0}^{Q-1}f_q\varvec{\zeta }_q}{\sum _{q=0}^{Q-1}f_q} \end{aligned}$$
(7)

This velocity is used in the mass transport equations, Eqs. (1).

2.2 Modelling Wettability with Lattice-Boltzmann Models

One of the essential pieces of the multiphase flow simulation puzzle in porous media is the role of wettability, which affects flow on all scales. Therefore, it is important to allow for various implementations of wetting conditions to enable the simulation of different scenarios to be studied. There are various approaches for imposing wetting behaviour into LBMs (Huang et al. 2015).

In these models, the wetting characteristic can be applied as an upscaled property instead of taking the impact of different role-playing parameters like roughness, surface charge, film existence, etc. Note that some researchers used LBMs to study these effects on the upscaled behaviour of contact lines (Armstrong et al. 2021).

In the colour-gradient LBM, the wetting condition can be defined in the form of a scalar affinity value. It is demonstrated that the affinity value is equivalent to a pseudo-phase indicator field, \(\phi _s\), ranging from \(-1\) to 1. It should be noted that the subscript s stands for the solid phase. This simple method imposes the expected contact line behaviour for the stationary and moving contact lines (Latva-Kokko and Rothman 2005). On a flat surface with a well-defined contact line, the equilibrium contact angle (\(\theta _{\textrm{eq}}\)) is related to \(\phi _s\) by

$$\begin{aligned} \cos \theta _{\textrm{eq}}=\phi _s \end{aligned}$$
(8)

Note that \(\phi _s\) equals the thermodynamically based wettability index \(\omega _i = (\sigma _{bs} - \sigma _{as})/\sigma _{ab}\) introduced in Berg et al. (2020), where \(\sigma _{as}\) and \(\sigma _{bs}\) are the surface tension between the solid phase and fluid a and b, respectively, while \(\sigma _{ab}\) is the interfacial tension between fluid a and b.

Figure 1 shows the relation between the surface affinity parameter and contact angle for a ganglion. In this study, we stick to the commonly used terminology and refer to the local wetting state as \(\phi _s=1\) being a strongly water-wet state and \(\phi _s=-1\) being a strongly oil-wet state.

Fig. 1
figure 1

Contact angle (degrees) versus surface affinity parameter (\(\phi _s\)) for a ganglion

2.3 Geometrical Contact Angle Determination

For geometrical contact angle measurements, we followed the automated method proposed by Khanamiri et al. (2020) to calculate the contact angle along the three-phase contact line in the segmented experimental X-ray tomography data of two-phase fluid distributions. To calculate local curvature and contact angles, first, a triangulated mesh was applied to the fluid–fluid and solid–fluid interfaces of the segmented image. After correction for some artefacts in the generated mesh due to imaging resolution limitations, e.g. self-touching interfaces, the mesh was smoothed. The smoothing was applied following the method suggested by AlRatrout et al. (2017) with some modification, in which the vertices are displaced to minimize the curvatures while keeping the global phase volumes approximately constant (Meyer et al. 2003). In the smoothing procedure, some tuning parameters are used which may result in the divergence of meshes from the intended geometry. As such, the final mesh may not imitate porous structures in low-resolution images, and as a result, the measured properties such as the measured contact angle and the curvature can deviate (Khanamiri et al. 2020).

After smoothing the mesh, the contact angle between the solid–fluid and fluid–fluid meshes on a vertex on the three-phase contact line is calculated by the dot product of the unit normal vectors of the solid–fluid and fluid–fluid interfaces. Note that the geometrical contact angle method yields different contact angles along the three-phase contact line. As will be described in the next section, our proposed method yields a single affinity value for each ganglion.

Also, the local average curvature for an interface is calculated based on the dot product of the Laplace–Beltrami operator (Meyer et al. 2003) and the unit normal vector. Further details of the geometrical method can be found in Khanamiri et al. (2020). They showed that to have a good estimation of the mean contact angle, the fluid clusters with at least a few thousand vertices at the fluid–fluid interfaces should be considered for the computation. By investigating two analytical examples with known contact angles and curvatures, they found that the computed point-wise contact angles, average mean curvature, and interfacial area converge by increasing the grid resolution (or increasing the size of clusters), while the point-wise mean curvature does not converge.

2.4 Wettability Characterization Workflow

In this study, we propose a novel workflow to characterize the local wetting properties in a sample under two-phase conditions using local LBM simulation on individual ganglia. The procedure starts with a segmented image of a sample containing two immiscible phases. We assume that all interfaces are stagnant, either under steady-state conditions (i.e. the flow takes place in connected pathways of phases from the inlet to the outlet), or the injection of fluids is stopped and the image is taken after equilibration of phases inside the sample. Moreover, we assume that the wetting property along the three-phase contact line is uniform so that each ganglion is associated with a single tuning parameter (i.e. surface affinity) for a more robust optimization procedure.

Fig. 2
figure 2

A flowchart of the optimization loop, finding the affinity value \(\phi _s\) that minimizes the difference \(\epsilon\) in the phase field between the imaged ganglion \(\phi ^i\) and the simulated one \(\phi ^s\)

The first step in our workflow is the identification of all trapped ganglia of the phase with lower saturation in the sample and disconnected from the boundaries of the image. In the gas–water sample, we found the trapped ganglia of the gaseous phase, while in the oil–water samples, we found the trapped ganglia of the oil phase. In both cases, we then identified the trapped ganglia of the non-wetting phase. When we identify the ganglia of the non-wetting phase, we consider two voxels connected if they share a face. This ganglia labelling was conducted using the scipy Python-library, giving each ganglion a specific number. We only considered ganglia of size larger than 10 voxels, removing all ganglia smaller than this cut-off value from our set of ganglia. This cut-off value is arbitrary, however, including smaller ganglia than 10 voxels seemed to increase the noise in our results.

The optimization procedure for finding the wetting of a single ganglion is outlined in Fig. 2. In this optimization procedure, we first find the smallest rectangular cuboid encapsulating the ganglion under consideration and then enlarge this domain by five voxels in each direction to ensure that the ganglion is not interacting with the domain boundaries. Then, we set all fluid voxels outside this ganglion to the wetting phase, so that the ganglion contains all non-wetting phases inside the domain. We then initialize the LBM from this fluid distribution, so that we have the initial phase field \(\phi ^i = 1\) for all wetting phase voxels and \(\phi ^i = -1\) for non-wetting phase voxels. In other words, the phase field is \(-1\) inside the considered ganglion and 1 outside.

The optimization parameter for each set of simulations (i.e. each ganglion) was the surface affinity parameter, \(\phi _s\), and the optimization was performed with a derivative-free algorithm (Nelder–Mead). For a given surface affinity value \(\phi _s\) provided by the optimization algorithm, we associate all solid surface faces with this affinity value. We then performed an LBM simulation inside the domain with no flow boundary conditions until we achieved a relaxed system. From the relaxed system, we binarised the phase field as:

$$\begin{aligned} \phi ^s = {\left\{ \begin{array}{ll} 1 &{}\text {if}\; \phi \ge 0 \\ -1 &{}\text {if}\; \phi < 0 \end{array}\right. } \end{aligned}$$
(9)

Note that the initial phase field is already \(-1\) for voxels containing the non-wetting phase and 1 for voxels containing the wetting phase. We then calculated an error function from a voxel-by-voxel comparison of the simulated ganglion \(\phi ^s\) with the initial X-ray image geometry of the ganglion as given by \(\phi ^i\):

$$\begin{aligned} \epsilon = \epsilon (\phi ^i, \phi ^s) = \sqrt{\frac{1}{\left| \Omega \right| }\int _\Omega (\phi ^i - \phi ^s)^2 dV} \end{aligned}$$
(10)

where \(\Omega\) is the pore space of the rectangular cuboid domain. After convergence of the optimization loop, the obtained affinity value is assigned to the 3-phase contact line voxels in the X-ray image before moving to the next ganglion.

After optimising the surface affinity values for all ganglia, we obtained surface affinity values along all three-phase contact lines for these ganglia. These surface affinity values can then be translated to contact angles, using Eq. (8), for comparison with contact angle values obtained using the geometric method. Noteworthy, to make the comparison between the geometrical analysis and the developed workflow consistent, the percolating ganglia were excluded from the geometrical analysis as well. For this purpose, a new domain only including the analysed ganglia in the wettability characterization workflow was generated and fed into the geometrical analysis model.

For multi-phase flow simulations, a wettability map on all solid surfaces is required. While this is typically given as a single value, our workflow enables the distribution of wettability according to the obtained affinity values from the workflow outlined in Fig. 2. For this end, we populate all solid–fluid voxels of the segmented X-ray image using three-dimensional linear interpolation between the solid–fluid voxels on the three-phase contact lines, as these surfaces on the three-phase contact lines already have assigned surface affinity values from the workflow above. For the pore surface close to the boundaries of the domain, where the three-dimensional linear interpolation has insufficient data, the surface affinity value was chosen equal to the nearest point with an assigned value.

2.5 Experimental Datasets

We used three publicly available experimental \(\mu\)-CT datasets of imaged two-phase fluid distributions to assess the results of the developed wettability characterization workflow. These datasets were also used by other researchers for similar purposes which gave a good benchmark to compare our obtained results.

Gas–water Bentheimer sample This dataset was originally obtained by Sun et al. (2020a) and was used to get the wetting state using their theoretical development of geometrical analysis. A bench-top helical \(\mu\)-CT scanner was used to image the 3D configuration of air–water immiscible fluids under ambient conditions in an untreated Bentheimer sandstone sample (4.9 mm in diameter and 10 mm long). The sample was flooded with brine with an injection rate of \(3.3 \times 10^{-7}\) m/s until irreducible air saturation was obtained (\(S_w=0.93\)). The images were acquired with a resolution of 4.95 \(\upmu\)m and we used a sub-volume of \(720\times 891 \times 891\) voxels from the segmented image.

Oil–water Bentheimer samples (unaltered and altered) These datasets were previously created from laboratory observations and discussed by Lin et al. (2018, 2019a), and recently used by Garfi et al. (2022) for the spatial distribution of wettability. These datasets consist of extensive sets of quasi-static co-injection at different fractional flows of oil (decalin) and water phases in cylindrical rock samples (diameter of 6.1 mm). The brine fraction of flow \(f_b=Q_b / (Q_b+Q_o)\) was defined as the ratio of the brine injection flow rate, \(Q_b\) to the total injection rate, \(Q_b+Q_o\), where Q is the injection flow rate, and b and o subscripts denote brine and oil phases, respectively. For the unaltered sample, the oil phase (decalin) drainage was performed into the brine-saturated sample using centrifugation to reach irreducible water saturation. The imbibition was performed right after drainage in capillary dominant condition (Lin et al. 2019b). Brine imbibition was conducted in seven steps, increasing the fractional flow of brine from 0 to 1 (\(f_b=0\), 0.05, 0.15, 0.30, 0.50, 0.85, 1). The injection was continued until reaching the steady state, and once the pressure difference across the sample was equilibrated the \(\mu\)-CT images were acquired for each fractional flow with a resolution of 3.58 \(\upmu\)m. For the altered sample, the fractional flows were performed for \(f_b=0\), 0.02, 0.06, 0.24, 0.50, 0.80, 0.90, 1.

The ageing process applied to the modified Bentheimer dataset occurred between the drainage stage and the co-injection fractional flow stages of oil and brine. Following the drainage phase, the sample was placed in crude oil, causing decalin to be gradually replaced by crude oil through diffusion. The sample was then kept in crude oil for 30 days at a temperature of 80 \(^{\circ }\)C. Following this modification process, the sample was immersed in decalin to replace the crude oil. Afterwards, the coreflooding experiment was conducted. The composition of brine and more detail regarding the ageing process for the altered sample can be found in Lin et al. (2018, 2019a). For both datasets, our analysis was performed on a cubic region of 800\(^3\) voxels corresponding to 2.86\(^3\) mm\(^3\), of the image acquired for the fractional flow of \(f_b=0.5\).

3 Results and Discussion

In this section, we provide the obtained results and discuss the differences with geometrical analysis of the oil ganglia to obtain the wetting properties of the natural rocks filled with two fluid phases. Firstly, we present a simplified example for numerical validation, then we provide the results of Bentheimer sandstone with gas–water fluids, and finally, we discuss the results of water-wet and altered-wet (mixed-wet) sandstone samples with oil–water pair of fluids.

3.1 Numerical Validation

In this section, we provide numerical experiments for the validation of the developed workflow as well as compare the accuracy with the geometrical analysis contact angle measurement. For this purpose, two different cases were generated using two-phase colour LB simulations with surface affinities of \(\phi _s= 0.5\) and \(\phi _s=1\), where each case consisted of the same set of initial ganglia in a porous medium of \(100^3\) voxels as shown in Fig. 3a. The domain was then relaxed by LBM under no-flow conditions for the two surface affinities. To mimic the added noise and uncertainty of the imaging and segmentation process of experimental imaging of porous media, a median filter was applied to the simulated domains that introduce differences compared to the higher resolution LBM simulation results. Figure 3 depicts the initial domain with patches of the non-wetting phase, as well as the obtained numerical simulation results for \(\phi _s=0.5\) and \(\phi _s=1\). Finally, the wettability of the results was characterized by the developed workflow as well as the geometrical method to quantitatively evaluate the accuracy of each method based on initial input.

Fig. 3
figure 3

Numerical simulation of the two-phase static condition using the LBM. a Initial condition, a porous media of \(100^3\) voxel size, saturated with fluid 1 with patches of fluid 2 (non-wetting fluid, red colour). b final result for relaxation of the domain using \(\phi _s=0.5\), and c final results using \(\phi _s=1\)

Figure 4 shows the results of both the developed workflow and the geometrical analysis for these two cases. As it can be seen the geometrically obtained contact angles have a wider range. This is as expected due to the central limit theorem since the proposed method yields one single value for a ganglion, which corresponds to a value for each grid cell along the three-phase contact line for the geometrical method. The geometrical method yields a fair estimate for the \(\phi _s=0.5\) model but struggles to capture the affinity values for the \(\phi _s=1\) case. The results of the developed workflow are more representative of the high-affinity case of \(\phi _s=1\).

For the case with the surface affinity of 1 (i.e. \(\phi _s=1\), strongly non-wetting case) the geometrical analysis contact angles results range mostly from 0\(^{\circ }\) to 60\(^{\circ }\) with an average of 37.5\(^{\circ }\). For the case with \(\phi _s=0.5\) the obtained geometrical contact angles range from 37\(^{\circ }\) to 90\(^{\circ }\) with an average of 60\(^{\circ }\). On the other hand, the developed workflow gave a range of affinities for each case with averages of \(\phi _s=0.95\) and \(\phi _s=0.70\) for these two cases, corresponding to contact angles of 18\(^{\circ }\) and 46\(^{\circ }\), respectively. The presented results show that the wettability characterization results can be more representative using the developed workflow than the geometrical analysis method for the presented cases.

Fig. 4
figure 4

Obtained affinity value distributions for both the proposed method and the traditional geometrical analysis for the two simulated domains using lattice-Boltzmann simulations (\(\phi _s=0.5\) and \(\phi _s=1\), corresponding to contact angles of 60\(^{\circ }\) and 0\(^{\circ }\))

3.2 Gas–Water Bentheimer Sample

The first experimental dataset that we used to examine the proposed scheme for wettability characterization of two-phase fluid distribution was the Bentheimer sample saturated with water and gas fluid pair under no-flow boundary conditions in ambient pressure and temperature. The existence of water and gas together is beneficial as it is well-known that gas is usually the strongly non-wetting phase in such conditions. Figure 5a shows the obtained distribution of surface affinity parameter (\(\phi _s\)) for this sample. For the proposed wettability characterization scheme in this research, each ganglion gives a data point as the local simulation was performed on each disconnected gas ganglion and the surface affinity parameter was optimized based on how well the lattice-Boltzmann model described the geometry of that specific ganglion. The obtained distribution is significantly shifted towards the liquid-wetting end of the spectrum with most of the ganglia being well described with \(\phi _s=1\) which is the strongly non-wetting condition for the gas phase.

The geometrical algorithm gives multiple calculations along the three-phase contact line, to examine such effect in the proposed scheme surface affinity distribution we also plot the distribution of surface affinity weighted by the ganglion size in Fig. 5b. As can be seen, compared to Fig. 5b weighting the surface affinity by the size of the ganglion does not materially change the obtained distribution for the surface affinity. So, in the remaining part of the paper, we stick to unweighted distributions for the proposed wettability characterization scheme to highlight the differences with geometrical analysis.

Fig. 5
figure 5

The distribution of surface affinity parameter (\(\phi _s\)) for different ganglia in gas–water Bentheimer sample. a Unweighted distribution, b weighted distribution by the size of ganglia

To be able to directly compare the proposed method for wettability characterization using LBM with the geometrical analysis we converted the obtained \(\phi _s\) distribution to the contact angle, shown in Fig. 6. Both distributions show the water-wetting behaviour of the sample as expected while the proposed scheme characterizes the wettability as strongly liquid wetting, with most of the contact angle distribution being in the range of 0\(^{\circ }\)–45\(^{\circ }\). On the other hand, the geometrical analysis contact angle distribution provides a wider span with the peak of the distribution at around 60\(^{\circ }\), which is unexpected for the water and gas in the porous media in ambient conditions. As the geometrical analysis is a local numerical approach that calculates the contact angle based on the orthogonal vector of solid–fluid and fluid–fluid surfaces it is more prone to local artefacts, roughness, and abnormalities in imaging or natural rock surface. Moreover, Fig. 7 shows one of the observed ganglia in the porous media together with the simulated region for different affinities. In this specific case, the optimization algorithm converged to \(\phi _s=0.724\) which provides the best description of the cluster.

Figure 8 depicts the obtained wettability distribution map (i.e. \(\phi _s\)) for all solid–fluid voxels in the gas–water Bentheimer sample. The voxels are not shown for the top half of the sample for the sake of better visualization of the spatial distribution of the trapped gas ganglia in the sample, which gives the wetting properties of the sample.

Fig. 6
figure 6

Obtained contact angle distributions for geometrical analysis and the proposed scheme for the gas–water Bentheimer sample

Fig. 7
figure 7

One of the trapped gas ganglions in the gas–water Bentheimer sample and simulation cases for different surface affinity values using local LB simulations. For this cluster, the final optimized value of surface affinity is \(\phi _s=0.724\) which describes the original cluster the best

Fig. 8
figure 8

Surface affinity parameter (\(\phi _s\)) distribution map for all solid–fluid voxels in the gas–water Bentheimer sample

3.3 Oil–Water Bentheimer Samples (Unaltered and Altered)

In this section, we describe the results from running both our proposed wettability characterization workflow and from geometrical analysis on two Bentheimer samples, altered and unaltered, saturated with oil and brine. We expect the altered wettability sample to be mixed wet and the unaltered sample to be water wet (Garfi et al. 2022; Lin et al. 2019a). Figure 9 shows the obtained surface affinity distributions for altered and unaltered samples using local LB simulation on trapped ganglia. The wettability distribution of samples shows an obvious distinction between the two samples, with a shift towards oil-wetness for the altered sample, as well as a wider range showing the mixed-wet behaviour. Figure 10 depicts the obtained contact angle distributions for the altered and unaltered samples using geometrical analysis. The difference between the two samples is lower compared to Fig. 9. Moreover, both distribution profiles show a wide range of obtained contact angles with a slight difference between the peak contact angle values.

Fig. 9
figure 9

The distribution of obtained surface affinity parameter (\(\phi _s\)) for altered and unaltered Bentheimer sandstone samples saturated with oil and brine phases

Fig. 10
figure 10

The contact angle distribution for altered and unaltered Bentheimer sandstone samples saturated with oil and brine phases. The contact angle distribution is obtained by geometrical contact angle determination

Figure 11 compares all obtained contact angle distributions for altered and unaltered Bentheimer samples under oil–water fluid pair. For the unaltered sample, in which we expect a water-wet behaviour from clean Bentheimer sandstone the results of the proposed wettability characterization scheme show a stronger water-wetting behaviour compared to geometrical analysis. The same difference applies to the altered sample. The local LBM simulations show a peak contact angle distribution of around 70\(^{\circ }\) while the geometrical analysis distribution peaks around 90\(^{\circ }\), showing a neutral wetting behaviour. In the presented results, the contact angle distribution of the unaltered sample obtained by geometrical analysis matches the obtained contact angle distribution for the altered sample using local LBM simulations. Based on the provided results we believe that the proposed scheme provides more accurate and representative results compared to geometrical analysis, which might be due to smoothing the interface along the contact line and calculation of the normal vector locally.

Finally, Fig. 12 shows the obtained surface affinity parameter (\(\phi _s\)) map for all solid–fluid voxels for half of the altered and unaltered Bentheimer samples. The solid–fluid voxels are not shown for the top half of the sample for better visualization and to be able to visualize the wetting distribution inside the sample as well as the spatial distribution of three-phase contact lines. There is a significant difference between the affinity maps with a shift towards oil-wetness for the mixed wet sample, which is expected.

Fig. 11
figure 11

Contact angle distributions obtained from local LB simulations and geometrical contact angle determination schemes for altered and unaltered Bentheimer samples saturated with oil and brine phases

Fig. 12
figure 12

Surface affinity parameter (\(\phi _s\)) distribution map for all solid–fluid voxels in the a unaltered and b altered Bentheimer samples

4 Summary and Conclusions

This study presented a new approach to spatial characterization of wettability in porous media. The presented workflow is computationally efficient, as it uses local lattice-Boltzmann (LB) simulations and upscales well as it is performed on the segmented structure of rock and fluids in porous media. The developed workflow works on trapped ganglia of the non-wetting phase individually and conducts local lattice-Boltzmann simulations to obtain the most appropriate wetting parameter which describes that specific ganglion as close as possible to the observed geometry in the porous medium. We used a colour-gradient lattice-Boltzmann model to simulate two-phase fluid distribution in porous media.

To determine the local wettability in the porous medium, we isolated each disconnected ganglion of fluids and ran one LB simulation for each ganglion in the porous medium. We optimized the surface affinity parameter (through which the wettability is imposed in the solver) for each ganglion with the aim of the best ganglion shape replicating the LB results with the imaged ganglion geometry. Using this approach, we obtained a surface affinity parameter for each disconnected ganglion and assigned it to the three-phase (fluid–fluid–solid) contact line. Computing sequentially on a single ganglion makes the method computationally advantageous and RAM-efficient; moreover, it can be parallelized very efficiently to run the algorithm on multiple ganglia at the same time. After obtaining the surface affinity for all three-phase contact line voxels, the surface affinity of all solid–fluid voxels of the porous medium was estimated using 3D spatial interpolation.

First, the results of the developed workflow were compared with a geometrical contact angle (CA) determination scheme proposed by Khanamiri et al. (2020) on two synthetic cases, generated by two-phase flow simulation in a porous medium. Our analysis revealed that the results obtained from the developed workflow accurately represent both strongly wetting and intermediate wetting states, whereas the geometrical analysis struggles to capture the extreme wetting case and yields a broader spectrum of contact angles, leading to increased uncertainty. Then, three sets of experimental data were used to quantitatively compare the results of the proposed scheme with geometrical analysis. The first set of experimental data was from a Bentheimer sandstone saturated with air and water in ambient conditions. Both the proposed scheme and the geometrical analysis showed water wetness, with the former showing more water-wetting behaviour and a narrower span of contact angle distribution. It is known that natural surfaces show a strong liquid wetting behaviour in the presence of gas (Erfani et al. 2018), from which we conclude that the local LBM simulations provide a more realistic wettability description for this sample.

The second and third sets of experimental data were oil–water saturated unaltered and altered (aged with crude oil) Bentheimer samples under steady-state flow (\(f_w=0.5\)). We expect the unaltered sample to show a water-wet behaviour, while the altered sample is expected to be mixed-wet. The difference in contact angle distribution for these two samples was small when the geometrical contact angle determination was applied, while the proposed scheme showed a larger difference between the two datasets. The proposed scheme showed a water-wet behaviour for the unaltered sample, while the geometrical contact angle determination showed contact angle distributions peaking around a neutral wetting state (75 < CA < 105). Based on the provided results, we believe that the proposed scheme based on local LBM simulations provides more accurate and representative results compared to the traditional geometrical analysis.