Abstract
Fluid flow in heterogeneous porous media arises in many systems, from biological tissues to composite materials, soil, wood, and paper. With advances in instrumentations, high-resolution images of porous media can be obtained and used directly in the simulation of fluid flow. The computations are, however, highly intensive. Although machine learning (ML) algorithms have been used for predicting flow properties of porous media, they lack a rigorous, physics-based foundation and rely on correlations. We introduce an ML approach that incorporates mass conservation and the Navier–Stokes equations in its learning process. By training the algorithm to relatively limited data obtained from the solutions of the equations over a time interval, we show that the approach provides highly accurate predictions for the flow properties of porous media at all other times and spatial locations, while reducing the computation time. We also show that when the network is used for a different porous medium, it again provides very accurate predictions.
Similar content being viewed by others
Introduction
Fluid flow and transport in heterogeneous porous media are of fundamental importance to the working of a wide variety of systems of scientific interest, as well as applications1,2. Examples of such porous media include catalysts, membranes, filters, adsorbents, print paper, wood, nanostructured materials, and biological tissues, as well as soil and pavement, and oil, gas, and geothermal reservoirs. Such porous media are typically heterogeneous, with the heterogeneity manifesting itself in the shape, size, connectivity, and surface structure of the pores at small scales, and in the spatial variations of the porosity, permeability, and the elastic moduli at large length scales. Thus, any attempt to model flow and transport in porous media entails having the ability to handle big data that is used3 in computing the spatial distribution of the pressure, fluid velocity, etc., throughout the pore space. The heterogeneity and the associated big data, contained in high-resolution two- or three-dimensional (2D or 3D) images of porous media used in their modeling imply that the calculations are highly intensive. Thus, developing efficient predictive algorithms has always been an active area of research.
Significant advancements have been made over the last decade in the development of deep-learning approaches that have made considerable contributions to progress in image analysis, which is also important to studying fluid flow and transport in porous media4,5,6, and other fields. The traditional neural networks, developed to handle large data, have great potential as approximators. Feed-forward neural networks (FFNNs), representing supervised learning methods, try to identify the relationship between the input and output iteratively by minimizing a cost function. To alleviate the computational burden associated with the minimization, advanced optimization methods have been developed7. There is, however, no systematic approach for increasing the accuracy of fully connected FFNNs, as they rely on correlations between data and the properties to be predicted, hence requiring a large amount of training data for acceptable accuracy. Thus, it is most desirable to develop alternatives.
Progress has been made very recently to develop such alternatives, commonly referred to as physics-informed machine learning (ML) in which the network is trained partly based on the fundamental equations that govern the physics of the process under study. Thus, by incorporating the equations in the cost function, one speeds up the convergence and produces accurate predictions, whereas the network requires training with much less data. The idea of using the equations that govern the physics of fluid flow and transport in porous media in the cost function and optimization was first proposed by Sahimi and colleagues8,9. Development of such techniques based on the ML methods was first reported for solving differential10 and partial differential equations11,12,13,14,15,16, and has been recently proposed for analyzing hydrodynamic systems17.
In this study, we aim to fill the gap between the ML methods and direct numerical simulation of fluid flow in a porous medium by combining the advantages of both approaches to obtain accurate solutions of the pressure and fluid velocity fields efficiently. The current ML methods are accurate estimator techniques when they have been sufficiently trained with a large number of datasets of enough variety. Multiple studies have used physics-informed FFNNs for a variety of purposes. However, as our goal is making predictions for fluid flow in images of porous media, it is not practical to use fully connected neural networks, due to the complexity of the images and low efficiency of such networks in discovering complex patterns.
To address the issue, we propose an approach based on an ML method that incorporates in its training (in the cost function) the governing equations for fluid flow in porous media, i.e., the mass conservation (MC) and the Navier–Stokes equations (NS). The result is a highly efficient method for predicting the flow properties. Our multiphysics approach integrates the MC and NS equations, and digital images of heterogeneous pore space with the training of the ML algorithm. As the input data, such as the images of pore space, are complex and large, one needs a network that decreases the computations time. Despite increasing applications of the ML methods, there has been only a limited number of attempts for addressing problems associated with porous materials4,5,6,19,20,21,22,23,24,25,26,27,28.
Results and discussion
We divide our results into two parts. In one part, we present and discuss calculations for the polymeric membrane. In the next part, we demonstrate that the same physics-informed recurrent encoder–decoder (PIRED) network can provide accurate predictions for a completely different porous medium.
Effect of incorporating the governing equations in the learning of the algorithm
Using the proposed PIRED network, we reconstructed the velocity and pressure field in new images using only a small number of images without specifying any boundary conditions. Figure 1a, b present, respectively, the change in the cost function σ2 for the training and testing datasets of the network. σ2 decreases for both variables during both the training and test data, indicating convergence toward the true solutions for both the pressure and fluid velocity fields.
To demonstrate the accuracy and efficiency of the PIRED, we also computed σ2 using a data-driven ML (DDML) algorithm, one in which the governing equations were not incorporated in the cost function. The results for σ2 are presented in Fig. 1c, d for both the training and testing. As can be seen, compared with Fig. 1a, b, DDML has a much weaker performance.
To better illustrate the improvement produced by incorporating the governing equations in the cost function, the PIRED and DDML are compared in terms of the number of data points used for training the network based on the correlation coefficient R2, as well as σ2 in Fig. 2a, b. Clearly, there exists a significant difference between the two methods and, in particular, when the number of the samples is small. The discrepancy is, however, smaller when a larger number of datasets are used.
PIRED-predicted pressure and velocity fields
Figure 3 compares the predicted spatial distribution of the pressure \(\hat{P}\) at four (dimensionless) times t1 = 15 < t2 < t3 < t4 = 185 with the actual P in one of the randomly selected 2D images not used in the training, with the results for all other slices being just as accurate (see below). Figure 4 compares the corresponding results for the magnitude ∣v∣ of the fluid velocity. As the spatial distributions of the differences \(P-\hat{P}\) and \(| {{{\bf{v}}}}| -| \hat{{{{\bf{v}}}}}|\) indicate, the predictions agree very closely with the actual data. Therefore, not only are the distributions of P and v reproduced accurately, the correlations between their values with increasing time are also honored.
Another quantitative comparison is based on selecting at random a vertical line (a plane in 3D) in one of the 300 testing images and comparing the PIRED-predicted P and v along that line with their actual values. One example is shown in Fig. 5a, b for pressure and velocity, which indicates a very good agreement between the predictions and the actual data. The same accuracy was obtained for all other slices.
Next, we compared the calculated ensemble-averaged maps of the PIRED-predicted ∣v∣ and ∣P∣ over the 300 testing images with the actual averages. The results are presented in Fig. 6, where Fig. 6a, c are the averages of actual (numerical) results and Fig. 6b, d are the averages of PIRED prediction results for velocity and pressure. The results in Fig. 6 indicate an excellent agreement.
PIRED predictions for another porous material
We define an effective permeability K by, K = μLq/(SΔP), where q, S, and ΔP are, respectively, the steady-state volume flow rate and the surface area perpendicular to the macroscopic pressure drop ΔP. K was computed for all the 300 testing slices and was predicted by the PIRED network as well. The comparison is shown in Fig. 7a.
However, a most stringent test of the PIRED network is if we predict the properties of a completely different porous medium, without using any data associated with it. Thus, we used the image of a Fontainebleau sandstone18 with a porosity of 0.14. As the sandstone’s morphology is completely different from the membrane’s, we used a slightly larger number of 2D slices from the membrane (not the sandstone) to better train the PIRED network. Figure 7b compares the effective permeabilities of 100 2D slices of the sandstone with the predictions of the PIRED network. The images of the two types of porous media are also shown in Fig. 7c, d.
Figure 8 compares the predicted spatial distribution of the pressure \(\hat{P}\) at four (dimensionless) times t1 < t2 < t3 < t4 with the actual P field in one of the randomly selected 2D images of the sandstone, with the results for all other slices being just as accurate. Figure 9 presents the corresponding results for the velocity field in the sandstone. In both cases, the agreement between the predictions and the actual fields is excellent. As the spatial distributions of the differences \(P-\hat{P}\) and \(| {{{\bf{v}}}}| -\hat{| {{{\bf{v}}}}| }\) in Figs. 8 and 9 indicate, both the pressure and velocity fields agree very closely with the actual distributions.
Summarizing, we presented a physics-informed encoder–decoder algorithm, the PIRED network, by incorporating the MC and the NS equations in its learning process, in order to predict fluid flow in a complex porous medium. The network provides highly accurate predictions for the fluid velocity and pressure fields at every point of the medium that was not used in the training, as well as its effective permeability. Not only does the PIRED network require a significantly smaller amount of data to make accurate predictions and, therefore, much less computations, it also provides accurate predictions for other types of porous media without using their data.
Methods
We divide this section into four parts and explain the structure of PIRED and the details of the computations.
Computational details
If the input and output are both in the form of images, as is the case in this study, an autoencoder network produces more accurate predictions. However, when the input or output is represented by spatial images or time series, which is the case when one solves the MC and NS equations, recurrent neural networks (RNNs) connect the data series. The RNNs output is used as the input in the decoder section to generate output data. Therefore, we couple an RNN to an encoder–decoder network, resulting in a PIRED network in which the cost function is defined partly based on the solutions of the MC and the NS equations.
We use the reverse Kullback–Leibler (KL) divergence (relative entropy)29 for minimizing the cost function. We suppose that p(x) is the true probability distribution of the input/output data, whereas q(x) is an approximation to it. The reverse KL divergence from q to p is a measure of the difference between p(x) and q(x), and the aim is to ensure that q(x) represents p(x) accurately enough that it minimizes the reverse KL divergence DKL(q∥p), given by
where X is the space in which p(x) and q(x) are defined. DKL = 0, if q(x) matches p(x) perfectly and, in general, it may be rewritten as
where \(H[q(x)]={E}_{x \sim q}[-{{\mathrm{log}}}\,q(x)]\) is the entropy of q(x), with E denoting the expected value operator and, thus, \({E}_{x \sim q}[-{{\mathrm{log}}}\,p(x)]\) is the cross-entropy between q and p. Optimization of DKL with respect to q is defined by
Thus, according to Eq. (3), one samples points from q(x) and does so, such that they have the maximum probability of belonging to p(x). The entropy term of Eq. (3) “encourages” q(x) to be as broad as possible. Thus, the autoencoder tries to identify a distribution q(x) that best approximates p(x).
Network architecture
As in the present problem the input and output images are distinct, the PIRED network, a supervised one, consists of encoder and decoder, known as the U-Net and residual U-Net (see Fig. 10). The encoder has four blocks with the block containing the standard convolutional (CL) and activation layers (AL), and the pooling and batch normalization layers (PL and BNL). The PL compresses the input to its most important characteristics, eliminating the unnecessary features, and stores them in the latent layer, which itself consists of the AL, CL, and BNL. The BNL not only allows the use of higher learning rates by reducing internal covariate shift but also acts as a regularizer for reducing overfitting30. The mean 〈x〉 and variance Var[x] of batches of data x are computed in the BNL and a new normalized variable y is defined by
Here, γ and β are learnable parameter vectors that have the same size as the input data, and ϵ is set at 10−5. During training, the layer keeps running estimates of its computed mean and variance, and uses them for normalization during evaluation. The variance is calculated by the biased estimator.
The decoder also consists of four blocks, with each block containing the CL, AL, and BNL, as well as a transposed CL (TCL), which is similar to a deconvolutional layer in that if, e.g., the first encoder has a size 128 × 64 × 64 (i.e., 128 features with a size 64 × 64), then, one has a similar size in the decoder. The TCL uses the features extracted by the PL to reconstruct the output, the pressure P and fluid velocity v fields at each specified time epoch. The latent layer of the RNN that we use improves its performance and speeds up significantly the overall network’s computations, because it is in the form of residual blocks, i.e., layers that, instead of having only one connection, are connected to further previous layers.
The input and output data
We used a high-resolution 3D image of a polymeric membrane of size 500 × 500 × 1000 voxels. Its porosity, thickness, permeability, and mean pore size are, respectively, 0.77, 60 μm, 10−12 m2, and 8 μm, respectively. An image of a 2D slice of the membrane is shown in Fig. 7c. We selected at random 700 2D slices of the image with size 175 × 175 pixels for the fluid flow calculations and training the PIRED, and another 300 slices for testing the accuracy. The 700 images were inserted in the PIRED network’s first layer, whereas the last layer contained the output, the distributions of P and v. The fluid density and viscosity were set at 0.997 g/cm3 and 1.89 × 10−3 g/(cm ⋅ s), with the fluid injection velocity being 1 cm/s.
We computed the P and v fields at four times and represented them by images. It is noteworthy that the amount of the data needed for computing P and v is significantly smaller than what would be needed by the standard ML methods.
Training PIRED
If L and v0 represent the characteristic length scale and fluid velocity in the medium, we introduce dimensionless variables, x* = x/L, y* = y/L, v* = v/v0, t* = tv0/L, and P* = PL/(μv0). Deleting superscript * for convenience, the MC equation, ∇ ⋅ v = ∂vx/∂x + ∂vy/∂y = 0 remains unchanged. The NS equation becomes
where \({{{\rm{Re}}}}=\rho {v}_{0}L/\mu\) is the Reynolds number. We define three functions, ξ1 = ∇ ⋅ v, \({\xi }_{2}=D{v}_{x}/Dt-{{{{\rm{Re}}}}}^{-1}\left(-\partial P/\partial x+{\nabla }^{2}{v}_{x}\right)\), and \({\xi }_{3}=D{v}_{y}/Dt-{{{{\rm{Re}}}}}^{-1}\left(-\partial P/\partial y+{\nabla }^{2}{v}_{y}\right)\), and incorporate them in the cost function σ2, minimized by the PIRED network, instead of naively minimizing the squared error between the data and predicted values of v and P. For exact convergence to the actual (numerically calculated) values (by solving the MC and NS equations), we must have ξi = 0 with i = 1 − 3. Thus, the PIRED network learns that the mapping between the input and output must comply with ξi = 0, which not only enriches its training but also accelerates convergence to the actual values. σ2 is defined by
where n is the number of data points used in the training, and Pi and ∣vi∣ are the actual pressure and magnitude of the velocity at point (xi, yi) at time ti, with superscript \(\hat{}\) denoting the predictions by the PIRED network.
The derivatives in ξi were estimated using the Sobel operator31, an inexpensive and effective way for computing the gradients, used commonly in image processing. It may be thought of as a smoothed finite-difference operator consisting of two 3 × 3 convolution kernels for the horizontal (H) and vertical (V) directions, which convolve with the image I in order to estimate the H and V derivatives. The kernels are given by, Gx = M * I and Gy = MT * I, where T and * represent the transpose and convolution operations, and
To further quantify the accuracy of the results, we also computed R2, which is a measure indicating the closeness of the predictions and the actual data; for a very accurate model, one should have, R2 ≈ 1.
where \({\hat{\psi }}_{i}\) is the network’s prediction, ψi is the actual value, and n is the number of the samples.
We solved the MC and the NS equations using the open-source OpenFOAM. The fluid was injected at one side and a fixed pressure was applied to the opposite side. The other two boundaries were assumed to be impermeable.
Solving the MC and NS equations in each 2D image took about 6 central processing unit (CPU) minutes. The computations for training the PIRED network on an Nvidia Tesla V100 graphics processing unit (GPU) took about 2 GPU hours. Then, the tests took less than a second.
Data availability
The data supporting findings within this paper are available from the corresponding author upon reasonable request.
Code availability
The code supporting findings within this paper are available from (servehka@usc.edu) upon reasonable request.
References
Blunt, M. J. Multiphase Flow in Permeable Media: A Pore-Scale Perspective. (Cambridge Univ. Press, 2017).
Sahimi, M. Flow and Transport in Porous Media and Fractured Rock. 2nd edn (Wiley-VCH, 2011).
Jablonka, K. M., Ongari, D., Moosavi, S. M. & Smit, B. Big-data science in porous materials: materials genomics and machine learning. Chem. Rev. 120, 8066 (2020).
Kamrava, S., Tahmasebi, P. & Sahimi, M. Enhancing images of shale formations by a hybrid stochastic and deep learning algorithm. Neural Netw. 118, 310 (2019).
Wu, H., Fang, W. Z., Kang, Q., Tao, W. Q. & Qiao, R. Predicting effective diffusivity of porous media from images by deep learning. Sci. Rep. 9, 1 (2019).
Kamrava, S., Tahmasebi, P. & Sahimi, M. Linking morphology of porous media to their macroscopic permeability by deep learning. Transp. Porous Media 131, 427 (2020).
Bishop, C. M. Neural Networks for Pattern Recognition. (Clarendon, 1995).
Hamzehpour, H. & Sahimi, M. Development of optimal models of porous media by combining static and dynamic data: the porosity distribution. Phys. Rev. E 74, 026308 (2006).
Hamzehpour, H., Rasaei, M. R. & Sahimi, M. Development of optimal models of porous media by combining tatic and dynamic data: the permeability and porosity distributions. Phys. Rev. E 75, 056311 (2007).
Raissi, M., Perdikaris, P. & Karniadakis, G. E. Machine learning of linear differential equations using Gaussian processes. J. Comput. Phys. 348, 683 (2017).
Bar-Sinai, Y., Hoyer, S., Hickey, J. & Brenner, M. P. Learning data-driven discretizations for partial differential equations. Proc. Natl. Acad. Sci. USA 116, 15344 (2019).
Meade, A. J. & Fernandez, A. A. The numerical solution of linear ordinary differential equations by feedforward neural networks. Math. Comput. Model 19, 1 (1994).
He, S., Reif, K. & Unbehauen, R. Multilayer neural networks for solving a class of partial differential equations. Neural Netw. 13, 385 (2000).
Aarts, L. P. & Van Der Veer, P. Neural network method for solving partial differential equations. Neural Process. Lett. 14, 261 (2001).
Han, J., Jentzen, A. & Weinan, E. Solving high-dimensional partial differential equations using deep learning. Proc. Natl. Acad. Sci. USA 115, 8505 (2018).
Raissi, M., Perdikaris, P. & Karniadakis, G. E. Physics-informed neural networks: a deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. J. Comput. Phys. 378, 686 (2019).
Raissi, M., Yazdani, A. & Karniadakis, G. E. Hidden fluid mechanics: learning velocity and pressure fields from flow visualizations. Science 367, 1026 (2020).
Andreä, H. et al. Digital rock physics benchmarks-Part I: imaging and segmentation. Comput. Geosci. 50, 25 (2013).
Tahmasebi, P., Kamrava, S., Bai, T. & Sahimi, M. Machine learning in geo- and environmental sciences: from small to large scale. Adv. Water Resour. 142, 103619 (2020).
Van der Linden, J. H., Narsilio, G. A. & Tordesillas, A. Machine learning framework for analysis of transport through complex networks in porous, granular media: a focus on permeability. Phys. Rev. E. 94, 022904 (2016).
Erofeev, A., Orlov, D., Ryzhov, A. & Koroteev, D. Prediction of porosity and permeability alteration based on machine learning algorithms. Transp. Porous Media 128, 677 (2019).
Kamrava, S., Sahimi, M. & Tahmasebi, P. Quantifying accuracy of stochastic methods of reconstructing complex materials by deep learning. Phys. Rev. E 101, 043301 (2020).
Mosser, L., Dubrule, O. & Blunt, M. J. Reconstruction of three-dimensional porous media using generative adversarial neural networks. Phys. Rev. E 96, 043309 (2017).
Zhang, F., Teng, Q., Chen, H., He, X. & Dong, X. Slice-to-voxel stochastic reconstructions on porous media with hybrid deep generative model. Comput. Mater. Sci. 186, 110018 (2021).
Wei, H., Zhao, S., Rong, Q. & Bao, H. Predicting the effective thermal conductivities of composite materials and porous media by machine learning methods. Int. J. Heat Mass Transfer 127, 908 (2018).
Alqahtani, N., Alzubaidi, F., Armstrong, R. T., Swietojanski, P. & Mostaghimi, P. Machine learning for predicting properties of porous media from 2d X-ray images. J. Pet. Sci. Eng. 184, 106514 (2019).
Feng, J., Teng, Q., He, X. & Wu, X. Accelerating multi-point statistics reconstruction method for porous media via deep learning. Acta Mater. 159, 296 (2018).
Srinivasan, S., Karra, S., Hyman, J., Viswanathan, H. & Srinivasan, G. Model reduction for fractured porous media: a machine learning approach for identifying main flow pathways. Comput. Geosci. 23, 617 (2019).
Kullback, S. & Leibler, R. A. On information and sufficiency. Annal. Math. Statist 22, 79 (1951).
Ioffe, S. & Szegedy, C. Batch normalization: Accelerating deep network training by reducing internal covariate shift. Preprint at https://arXiv:1502.03167V3 (2015).
Zhu, Y., Zabaras, N., Koutsourelakis, P. S. & Perdikaris, P. Physics-constrained deep learning for high-dimensional surrogate modeling and uncertainty quantification without labeled data. J. Comput. Phys. 394, 56 (2019).
Acknowledgements
We are grateful to the National Science Foundation for partial support of this work through Grant CBET 2000968. Most of the computations were carried out at the High-Performance Computing Center of the University of Southern California.
Author information
Authors and Affiliations
Contributions
S.K.: Methodology of PIRED network, computations, software, and contributing to the writing of the first draft of the paper. P.T.: Data curation and review. M.S.: Conceptualization, supervision of the project, writing the final draft of the paper, and funding acquisition.
Corresponding author
Ethics declarations
Competing interests
The authors declare no competing interests.
Additional information
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as 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. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Kamrava, S., Sahimi, M. & Tahmasebi, P. Simulating fluid flow in complex porous materials by integrating the governing equations with deep-layered machines. npj Comput Mater 7, 127 (2021). https://doi.org/10.1038/s41524-021-00598-2
Received:
Accepted:
Published:
DOI: https://doi.org/10.1038/s41524-021-00598-2
This article is cited by
-
Visual Ensemble Analysis of Fluid Flow in Porous Media Across Simulation Codes and Experiment
Transport in Porous Media (2024)
-
Prediction of the inertial permeability of a 2D single rough fracture based on geometric information
Acta Geotechnica (2024)
-
Deep learning for diffusion in porous media
Scientific Reports (2023)
-
Wavelet gated multiformer for groundwater time series forecasting
Scientific Reports (2023)
-
Dispersive transport dynamics in porous media emerge from local correlations
Nature Communications (2022)