==== Front Sci Rep Sci Rep Scientific Reports 2045-2322 Nature Publishing Group UK London 35319 10.1038/s41598-023-35319-w Article Generalized neural closure models with interpretability https://orcid.org/0000-0002-9197-0736 Gupta Abhinav http://orcid.org/0000-0002-1869-3883 Lermusiaux Pierre F. J. pierrel@mit.edu grid.116068.8 0000 0001 2341 2786 Department of Mechanical Engineering, Center for Computational Science and Engineering, Massachusetts Institute of Technology, Cambridge, MA 02139 USA 30 6 2023 30 6 2023 2023 13 1063420 1 2023 16 5 2023 © The Author(s) 2023 https://creativecommons.org/licenses/by/4.0/ Open AccessThis 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 licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence 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 licence, visit http://creativecommons.org/licenses/by/4.0/. Improving the predictive capability and computational cost of dynamical models is often at the heart of augmenting computational physics with machine learning (ML). However, most learning results are limited in interpretability and generalization over different computational grid resolutions, initial and boundary conditions, domain geometries, and physical or problem-specific parameters. In the present study, we simultaneously address all these challenges by developing the novel and versatile methodology of unified neural partial delay differential equations. We augment existing/low-fidelity dynamical models directly in their partial differential equation (PDE) forms with both Markovian and non-Markovian neural network (NN) closure parameterizations. The melding of the existing models with NNs in the continuous spatiotemporal space followed by numerical discretization automatically allows for the desired generalizability. The Markovian term is designed to enable extraction of its analytical form and thus provides interpretability. The non-Markovian terms allow accounting for inherently missing time delays needed to represent the real world. Our flexible modeling framework provides full autonomy for the design of the unknown closure terms such as using any linear-, shallow-, or deep-NN architectures, selecting the span of the input function libraries, and using either or both Markovian and non-Markovian closure terms, all in accord with prior knowledge. We obtain adjoint PDEs in the continuous form, thus enabling direct implementation across differentiable and non-differentiable computational physics codes, different ML frameworks, and treatment of nonuniformly-spaced spatiotemporal training data. We demonstrate the new generalized neural closure models (gnCMs) framework using four sets of experiments based on advecting nonlinear waves, shocks, and ocean acidification models. Our learned gnCMs discover missing physics, find leading numerical error terms, discriminate among candidate functional forms in an interpretable fashion, achieve generalization, and compensate for the lack of complexity in simpler models. Finally, we analyze the computational advantages of our new framework. Subject terms Marine biology Scientific data Fluid dynamics Physical oceanography Computational science 100007297 United States Department of Defense | United States Navy | ONR | Office of Naval Research Global (ONR Global) N00014-20-1-2023 issue-copyright-statement© Springer Nature Limited 2023 ==== Body pmcIntroduction The field of Scientific Machine Learning (SciML1) is burgeoning with innovative methods that combine machine learning with existing scientifically-derived differential equation models and computational physics schemes. This is in part because many realistic dynamical models are complex, and often truncated, coarsened, or aggregated due to computational cost constraints. Machine learning (ML) is then used to learn and represent the neglected and unresolved terms in a data-driven fashion2–9. Such techniques that express the missing dynamics as functions of modeled state variables and parameters are referred to as closure models. Most ML closure models (and SciML results in general) are however often limited both in interpretability as black-box ML models and in generalization over different computational grid resolutions, initial conditions, boundary conditions, domain geometries, and physical or problem-specific parameters. Addressing the challenges of interpretability and generalization is imperative to justify the costs of training the SciML models using data sets obtained from expensive measurements or generated by solving the complex dynamical models in the first place. The goal of the present study is to simultaneously address these challenges and learn closure models which are both generalizable and interpretable. The need for closure modeling arises for a variety of reasons, ranging from computational cost considerations, preference for simpler models over complex ones due to overparameterization, or lack of scientific understanding of processes and variables involved in the system of interest. The simpler or the known model is often referred to as a low-fidelity model, while the complex counterpart in either models or observations is then referred to as the high-fidelity model, reality, or real-world data. Low-fidelity models can be categorized into three categories: (i) Reduced-order models, in which the original high-dimensional dynamical system is projected and solved in a reduced space. While it is computationally cheaper to solve the low-dimensional system, these models can quickly accumulate errors due to the missing interactions with the truncated dimensions10–12; (ii) Coarse-resolution models, in which we only resolve the scales of interest. In these cases, the neglected and unresolved scales, along with their interactions with the resolved ones, can lead to unintended or unacceptable effects at global scales13–17; (iii) Simplistic or speculative models, in which an incomplete representation or understanding of processes and interactions occurs, and thus uncertainty in the model formulations and even in the relevant state variables themselves. This can lead to a gross or incorrect approximation of the real-world phenomena18–22. In2, neural closure models (nCMs) are developed for low-fidelity models using neural delay differential equations (nDDEs) and data from high-fidelity simulations. The need for time delays in closure parameterizations is rooted in the presence of inherent delays in real-world systems23,24 and theoretically justifed by the Mori–Zwanzig formulation25–28. Using nDDEs for closure modeling has a number of advantages. They allow for the use of smaller architectures and account for the accumulation of numerical time-stepping error in the presence of neural networks (NNs) during training. Additionally, nDDEs are agnostic to the time-integration scheme, handle unevenly-spaced training data, and have good performance over prediction periods much longer than the training or validation periods. However, there are other highly-desirable properties, as mentioned above. Fundamental questions for neural closures include: Can they be interpretable and lead to analytical expressions? Can they achieve generalization over many conditions and variables, as physics-based models do? How can they be combined seamlessly with classic numerical schemes? A number of recent approaches have aimed to address such questions, however, challenges remain especially for partial differential equations (PDEs). This is often because NNs are used with the discretized ordinary differential equation (ODE) form of the corresponding PDEs, which makes it inherently difficult to generalize to changes in boundary conditions, domain geometry, and computational grid. Recently, a few studies have taken steps at addressing these drawbacks. Sirignano et al.8 augment the underlying PDE with a neural network, however, they only learn a Markovian closure. The inputs to the neural network include the state, its spatial derivatives, and a fixed number of neighboring grid points. They also provide an accompanying discrete adjoint PDE for efficient training. Saha et al.9 use a radial-basis-functions-based collocation method to allow for mesh-free embedding of NNs. However, the resulting NNs also only learn a Markovian closure, do not account for the accumulation of time-integration errors, and lack interpretability. In the present study, we develop the unified neural partial delay differential equations (nPDDEs) that augment existing/low-fidelity models in their PDE forms with both Markovian and non-Markovian closures parameterized with deep-NNs. The neural closure terms then contain instantaneous and delayed contributions. Their inputs consist of the modeled states, their spatial derivatives, combinations of derivatives, and any other problem-specific variables and parameters. The melding of the low-fidelity model and deep-NNs in the continuous spatiotemporal space automatically allows for generalizability to computational grid resolution, boundary conditions, and initial conditions. By design, the closure terms can also provide analytical expressions of the missing terms, thus leading to interpretability. The resulting nPDDEs are discretized using any numerical method relevant to the dynamical system studied. Further, we provide adjoint PDE derivations in the continuous form, thus allowing one to implement across differentiable and non-differentiable computational physics codes, and also different machine learning frameworks. All our derivations and implementations are done considering deep-NN architectures, thus automatically encompassing linear- and shallow-NNs, and providing the user or subject-matter-expert user with the flexibility of choosing the architectural complexity in accord with the prior information available. We refer to the new methodology as generalized neural closure models (gnCM). Through a series of experiments, we demonstrate the flexibility of gnCMs to learn closures either in an interpretable fashion, black-box fashion, or both simultaneously, using the prior scientific knowledge about the problem at hand. The gnCMs can eliminate erroneous and redundant input terms, or combine them to achieve increased accuracy. We also demonstrate the generalizability of our learned closures to changes in physical parameters, grid resolution, initial conditions, and boundary conditions. Our first class of simulation experiments uses nonlinear waves and advecting shocks problems governed by the KdV-Burgers and classic Burgers PDEs. Our learned gnCM finds missing terms, discovers the leading truncation error, and a correction to the non-linear advection term. We find that training on data corresponding to just a few combinations of grid resolution and Reynolds number is sufficient to ensure that the learned closures are generalizable over a range of grid resolution and Reynolds number combinations, initial and boundary conditions, and also outperform the popular Smagorinsky subgrid-scale closure model. Our second class of experiments is based on ocean acidification models, where we learn the functional form of biological processes and compensate for the lack of complexity in simpler models obtained by aggregation of components and other simplifications of processes and parameterizations. Finally, we comment on the computational advantages of our new gnCM framework. In what follows, we first develop the “Theory and methodology” for the gnCMs. “Application results and discussion” showcases the generalization and interpretability properties of the gnCMs in experiments with nonlinear waves, advecting shocks, and ocean acidification, and discusses computational advantages. Finally, “Conclusions” are provided. Theory and methodology The functional form of closure models representing missing dynamics can be derived by the Mori–Zwanzig formulation25–28, which proves it to be dependent on the time-lagged state dynamics. Many systems are modeled assuming smooth fields of state variables governed by advection-diffusion-reaction PDEs. Such PDEs implicitly assume that local information between state variables is exchanged instantaneously at any spatial location. In reality, however, time delays occur for several reasons. First, reactions or changes in populations have non-negligible time scales. Such time delays are captured in more complex models by modeling intermediate state variables. The time response of lower-complexity models can thus approximate that of high-complexity models by explicitly introducing delays23,24. Second, time delays arise due to missing subgrid-scale processes and/or truncated modes in reduced-order models. For all of these reasons, memory-based terms and thus non-Markovian closure terms are needed to augment low-fidelity models2. In general, low-fidelity models are also outright missing Markovian terms due to truncation, coarse resolution, or incomplete and uncertain functional forms of some of the model terms. We will therefore use both Markovian and non-Markovian terms to close low-fidelity models in their PDE forms. This leads to partial delay differential equations (PDDEs) that are widely used in ecology, control theory, biology, and climate dynamics, to name a few application areas29. In this study, the Markovian and non-Markovian closure terms will be modeled using deep-NNs. To achieve full interpretability from the learned weights of the NNs of the closure models, we at times consider single-layer linear-NNs. Closure terms in general depend on the state variables, their spatial derivatives, and combinations of these belonging to a function library. As the presence of discrete delays can be seen as a special case of distributed delays, the non-Markovian term is assumed to contain distributed delays and have a maximum finite time-delay (τ). Given a continuous state vector comprising of Ns different states, u(x,t):R×[0,T]→RNs, we thus consider a dynamical system belonging to domain Ω of the following form,1 ∂u(x,t)∂t=Lu(x,t),∂u(x,t)∂x,∂2u(x,t)∂x2,...,x,t;ν⏟Low-Fidelity/KnownModel+FNNu(x,t),∂u(x,t)∂x,∂2u(x,t)∂x2,...,x,t;ϕ⏟MarkovianClosureTerm+∫t-τtDNNu(x,s),∂u(x,s)∂x,∂2u(x,s)∂x2,...,x,s;θds⏟Non-MarkovianClosureTerm,x∈Ω,t≥0,u(x,t)=h(x,t),-τ≤t≤0andB(u(x,t))=g(x,t),x∈∂Ω,t≥0, where L, FNN, and DNN are nonlinear functions parameterized with ν, ϕ, and θ, respectively. ν are problem-specific parameters associated with the physical/biological/chemical phenomenon of interest, while ϕ and θ are the NN weights. When compared to PDEs, PDDEs require a history function (h(x,t),-τ≤t≤0) for their initialization at t=0. The operator B represents appropriate boundary conditions such as Dirichlet, Neumann, etc. which are needed to solve the system uniquely. Furthermore, for ease of notation, we have assumed a one-dimensional (1D) domain, however, the method directly extends to 2D and 3D domains. Neural partial delay differential equations We now obtain ML schemes that learn PDDEs parameterized using deep-NNs. They are referred to as neural partial delay differential equations (nPDDEs). Without loss of generality, and for brevity, we limit ourselves to nPDDEs with only a Markovian term and a non-Markovian term with distributed delays. The low-fidelity model can be considered to be absorbed in the Markovian closure term. Hence, the nPDDE is of the form,2 ∂u(x,t)∂t=FNNu(x,t),∂u(x,t)∂x,∂2u(x,t)∂x2,...,∂du(x,t)∂xd,x,t;ϕ+∫t-τtDNNu(x,s),∂u(x,s)∂x,∂2u(x,s)∂x2,...,∂du(x,s)∂xd,x,s;θds,x∈Ω,t≥0,u(x,t)=h(x,t),-τ≤t≤0andB(u(x,t))=g(x,t)x∈∂Ω,t≥0. The two deep-NNs, instantaneous FNN(∙;ϕ) and delayed DNN(∙;θ), remain parameterized by ϕ and θ, and for generality, they are considered to be functions of an arbitrary number of spatial derivatives, with the highest order defined by d∈Z+. We can rewrite Eq. (2) as an equivalent system of coupled PDDEs with discrete delays,3 ∂u(x,t)∂t=FNNu(x,t),∂u(x,t)∂x,∂2u(x,t)∂x2,...,∂du(x,t)∂xd,x,t;ϕ+y(x,t),x∈Ω,t≥0,∂y(x,t)∂t=DNNu(x,t),∂u(x,t)∂x,∂2u(x,t)∂x2,...,∂du(x,t)∂xd,x,t;θ-DNNu(x,t-τ),∂u(x,t-τ)∂x,∂2u(x,t-τ)∂x2,...,∂du(x,t-τ)∂xd,x,t-τ;θ,x∈Ω,t≥0,u(x,t)=h(x,t),-τ≤t≤0andB(u(x,t))=g(x,t),x∈∂Ω,t≥0,y(x,0)=∫-τ0DNNh(x,s),∂h(x,s)∂x,∂2h(x,s)∂x2,...,∂dh(x,s)∂xd,x,s;θds. Let us assume that high-fidelity data is available at M discrete times, T1<...