Abstract
In numerical reservoir simulations, Newton’s method is a concise, robust and, perhaps the most commonly used method to solve nonlinear partial differential equations (PDEs). However, as reservoir simulators incorporate more and more physical and chemical phenomena, writing codes that compute gradients for reservoir simulation equations can become quite complicated. This paper presents an automatic differentiation (AD) framework that is specially designed for simplifying coding and simultaneously maintaining computational efficiency. First a parse tree for a mathematical expression is built and evaluated with the backward mode AD, and then the derivatives with respect to the expression’s arguments are transformed to derivatives with respect to the PDE’s independent variables. The first stage can be realized either by runtime polymorphism to gain higher flexibility or by compile-time polymorphism to gain faster execution speed; the second stage is realized by linear combinations of sparse vectors, which can be accelerated by recording the target column indices. The AD framework has been implemented in an in-house reservoir simulator. Individual tests on some complex mathematical expressions were carried out to compare the speed of the manual implementation, the runtime polymorphic implementation and the compile-time polymorphic implementation of the differentiation. Then the performance of the three was analyzed in complete simulations. These cases indicate that the proposed approach has good efficiency and is applicable to reservoir simulations.
Article PDF
Similar content being viewed by others
References
Alexandrescu, A.: Modern C ++ design: generic programming and design patterns applied. Addison-Wesley Professional (2001)
Aubert, P., Di Césaré, N., Pironneau, O.: Automatic differentiation in C ++ using expression templates and application to a flow control problem. Comput. Vis. Sci. 3(4), 197–208 (2001)
Baur, W., Strassen, V.: The complexity of partial derivatives. Theor. Comput. Sci. 22(3), 317–330 (1983)
Beda, L., Korolev, L., Sukkikh, N., Frolova, T.: Programs for automatic differentiation for the machine BESM. Inst. Precise Mechanics and Computation Techniques. Academy of Science, Moscow (1959)
Bendtsen, C., Stauning, O.: FADBAD, a flexible C ++ package for automatic differentiation. Department of Mathematical Modelling. Technical University of Denmark (1996)
Bischof, C., Khademi, P., Mauer, A., Carle, A.: ADIFOR 2.0: Automatic differentiation of Fortran 77 programs. IEEE Comput. Sci. Eng. 3(3), 18–32 (1996)
Bischof, C.H., Haghighat, M. Hierarchical approaches to automatic differentiation. BBCG96, 83 (1996)
Borodin, A., Munro, I.: The computational complexity of algebraic and numeric problems. (1975)
Cacuci, D.G.: Sensitivity theory for nonlinear systems. I. Nonlinear functional analysis approach. J. Math. Phys. 22(12), 2794–2802 (1981)
Cacuci, D.G.: Sensitivity theory for nonlinear systems. II. Extensions to additional classes of responses. J. Math. Phys. 22(12), 2803–2812 (1981)
Cao, H.: Development of techniques for general purpose simulators. Stanford University (2002)
DeBaun, D., Byer, T., Childs, P., Chen, J., Saaf, F., Wells, M., Liu, J., Cao, H., Pianelo, L., Tilakraj, V.: An extensible architecture for next generation scalable parallel reservoir simulation. In: SPE Reservoir Simulation Symposium (2005)
Griewank, A.: On automatic differentiation. Mathematical Programming: recent developments and applications 6, 83–107 (1989)
Haaland, S.E.: Simple and explicit formulas for the friction factor in turbulent pipe flow. J. Fluids Eng.; (United States) 105(1) (1983)
Hogan, R.J.: Fast reverse-mode automatic differentiation using expression templates in C + . Submitted to ACM Trans. Math. Softw. (2014)
Huang, H., Ayoub, J.: Applicability of the Forchheimer equation for non-Darcy flow in porous media. SPE J. 13(1), 112–122 (2008)
Jiang, Y.: Techniques for modeling complex reservoirs and advanced wells. Stanford University (2007)
Lie, K.A., Krogstad, S., Ligaarden, I.S., Natvig, J.R., Nilsen, H.M., Skaflestad, B.: Open-source MATLAB implementation of consistent discretisations on complex grids. Comput. Geosci. 16(2), 297–322 (2012)
Lieberherr, K.J., Holland, I.M.: Assuring good style for object-oriented programs. IEEE Softw. 6(5), 38–48 (1989)
Peaceman, D.W.: Interpretation of well-block pressures in numerical reservoir simulation. Soc. Pet. Eng. J. 18(03), 183–194 (1978)
Phipps, E., Pawlowski, R.: Efficient expression templates for operator overloading-based automatic differentiation. In: Recent Advances in Algorithmic Differentiation, pp. 309-319. Springer (2012)
Phipps, E.T., Bartlett, R.A., Gay, D.M., Hoekstra, R.J.: Large-scale transient sensitivity analysis of a radiation-damaged bipolar junction transistor via automatic differentiation. In: Advances in automatic differentiation, pp. 351-362. Springer (2008)
Rall, L.B.: Automatic differentiation: techniques and applications (1981)
Shi, H., Holmes, J., Durlofsky, L., Aziz, K., Diaz, L., Alkaya, B., Oddie, G.: Drift-flux modeling of two-phase flow in wellbores. SPE J. 10(1), 24–33 (2005)
Speelpenning, B.: Compiling fast partial derivatives of functions given by algorithms. In. Illinois Univ., Urbana (USA). Dept. of Computer Science (1980)
Utke, J.: OpenAD: Algorithm implementation user guide. Technical Mem (2004)
Utke, J., Naumann, U., Fagan, M., Tallent, N., Strout, M., Heimbach, P., Hill, C., Wunsch, C.: OpenAD/F: A modular open-source tool for automatic differentiation of Fortran codes. ACM Trans. Math. Softw. (TOMS) 34(4), 18 (2008)
Veldhuizen, T.: Expression templates. C ++ Report 7(5), 26–31 (1995)
Veldhuizen, T.: Arrays in blitz ++. In: Computing in object-oriented parallel environments, pp. 223-230. Springer (1998)
Wei, Z., Zhang, D.: Coupled fluid-flow and geomechanics for triple-porosity/dual-permeability modeling of coalbed methane recovery. International Journal of Rock Mechanics and Mining Sciences. 47(8), 1242–1253 (2010)
Wengert, R.: A simple automatic derivative evaluation program. Commun. ACM 7(8), 463–464 (1964)
Wolfe, P.: Checking the calculation of gradients. ACM Trans. Math. Softw. (TOMS) 8(4), 337–343 (1982)
Younis, R., Aziz, K.: Parallel automatically differentiable data-types for next-generation simulator development. In: SPE Reservoir Simulation Symposium (2007)
Younis, R.M.: Modern advances in software and solution algorithms for reservoir simulation. Stanford University (2011)
Zhou, Y., Tchelepi, H., Mallison, B.: Automatic differentiation framework for compositional simulation on unstructured grids with multi-point discretization schemes. In: SPE Reservoir Simulation Symposium (2011)
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (https://creativecommons.org/licenses/by/4.0), which permits use, duplication, 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.
About this article
Cite this article
Li, X., Zhang, D. A backward automatic differentiation framework for reservoir simulation. Comput Geosci 18, 1009–1022 (2014). https://doi.org/10.1007/s10596-014-9441-z
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10596-014-9441-z