Energy-Conserving Neural Network for Turbulence Closure Modeling
In turbulence modeling, we are concerned with finding closure models that
represent the effect of the subgrid scales on the resolved scales. Recent
approaches gravitate towards machine learning techniques to construct such
models. However, the stability of machine-learned closure models and their
abidance by physical structure (e.g. symmetries, conservation laws) are still
open problems. To tackle both issues, we take the `discretize first, filter
next' approach. In this approach we apply a spatial averaging filter to
existing fine-grid discretizations. The main novelty is that we introduce an
additional set of equations which dynamically model the energy of the subgrid
scales. Having an estimate of the energy of the subgrid scales, we can use the
concept of energy conservation to derive stability. The subgrid energy
containing variables are determined via a data-driven technique. The closure
model is used to model the interaction between the filtered quantities and the
subgrid energy. Therefore the total energy should be conserved. Abiding by this
conservation law yields guaranteed stability of the system. In this work, we
propose a novel skew-symmetric convolutional neural network architecture that
satisfies this law. The result is that stability is guaranteed, independent of
the weights and biases of the network. Importantly, as our framework allows for
energy exchange between resolved and subgrid scales it can model backscatter.
To model dissipative systems (e.g. viscous flows), the framework is extended
with a diffusive component. The introduced neural network architecture is
constructed such that it also satisfies momentum conservation. We apply the new
methodology to both the viscous Burgers' equation and the Korteweg-De Vries
equation in 1D. The novel architecture displays superior stability properties
when compared to a vanilla convolutional neural network.
Toby van Gastelen, Wouter Edeling, Benjamin Sanderse
# Energy-Conserving Neural Network for Turbulence Closure Modeling

###### Abstract

In turbulence modeling, and more particularly in the Large-Eddy Simulation (LES) framework, we are concerned with finding closure models that represent the effect of the unresolved subgrid scales on the resolved scales. Recent approaches gravitate towards machine learning techniques to construct such models. However, the stability of machine-learned closure models and their abidance by physical structure (e.g. symmetries, conservation laws) are still open problems. To tackle both issues, we take the 'discretize first, filter next' approach, in which we apply a spatial averaging filter to existing energy-conserving (fine-grid) discretizations. The main novelty is that we extend the system of equations describing the filtered solution with a set of equations that describe the evolution of (a compressed version of) the energy of the subgrid scales. Having an estimate of the energy of the subgrid scales, we can use the concept of energy conservation and derive stability of the discrete representation. The compressed variables are determined via a data-driven technique in such a way that the energy of the subgrid scales is matched. For the extended system, the closure model should be energy-conserving, and a new skew-symmetric convolutional neural network architecture is proposed that has this property. Stability is thus guaranteed, independent of the actual weights and biases of the network. Importantly, our framework allows energy exchange between resolved scales and compressed subgrid scales and thus enables backscatter. To model dissipative systems (e.g. viscous flows), the framework is extended with a diffusive component. The introduced neural network architecture is constructed such that it also satisfies momentum conservation. We apply the new methodology to both the viscous Burgers' equation and the Korteweg-De Vries equation in 1D and show superior stability properties when compared to a vanilla convolutional neural network.

**Keywords**: Turbulence modeling, Neural networks, Energy conservation, Structure preservation, Burgers' equation, Korteweg-de Vries equation

## 1 Introduction

Simulating turbulent flows with direct numerical simulations (DNSs) is often infeasible due to the high computational requirements. This is due to the fact that with increasing Reynolds number fine computational meshes are required in order to resolve all the relevant scales. Especially for applications in design and uncertainty quantification, where typically many simulations are required, this rapidly becomes computationally infeasible [1; 2]. To tackle this issue several different approaches have been proposed, such as reduced order models [3], Reynolds-averaged Navier-Stokes (RANS) [4], and Large Eddy Simulation (LES) [5]. These approaches differ in how much of the physics is simulated and how much is modelled. Here we will focus on the LES approach.

In LES the large-scale physics is modelled directly by a numerical discretization of the governing equations on a coarse grid. However, due to fact that the filter does not commute with the nonlinear terms in the equations a commutator error arises. This prevents one from obtaining an accurate solution without knowledge of the subgrid-scale (SGS) content. This commutator error is typically referred to as the closure term and modeling this term is the main concern of the LES community. A major difficulty in the modeling of this closure term, by a corresponding closure model, is dealing with the exchange of energy from the small to the large scales (backscatter) [6; 7], as the SGS energy content is unknown during the time of the simulation. This makes accounting for backscatter difficult without leading to numerical instabilities
[8]. Classical physics-based closure models are therefore often represented by a dissipative model, e.g. of eddy-viscosity type [9], ensuring a net decrease in energy, or clipped such that backscatter is removed [10]. Even though the assumption of a global net decrease in energy is valid [9], explicit modeling of backscatter is still important, as locally the effect of backscatter can be of great significance [11; 12]. Closure models that explicitly model the global kinetic energy present in the small scales at a given point in time, to allow for backscatter without sacrificing stability, also exist [13]. Recently, machine learning approaches, or more specifically neural networks (NNs), have also become a viable option for the modeling of this closure term, as they show potential for outperforming the classical approaches in different use cases [14; 15; 16; 17]. However, stability remains an important issue along with abidance by physical structure such as mass, momentum, and energy conservation [18; 19; 20; 16].

In [18] the case of homogeneous isotropic turbulence for the compressible Navier-Stokes equations was investigated. A convolutional neural network (CNN) was trained to reproduce the closure term from high-resolution flow data. Although _a priori_ cross-correlation analysis on the training data showed promising results, stable models could only be achieved by projecting onto an eddy-viscosity basis. In [19] a gated recurrent NN was applied to the same test case which showed even higher cross-correlation values with the actual closure term, but still yielded unstable models, even after employing stability training on data with artificial noise [20]. In [16] the case of incompressible turbulent channel flow was treated. Here NNs with varying dimensions of input space were employed to construct a closure model. They showed that increasing the size of the input space of the NN improves _a priori_ performance. However, _a posteriori_ analysis showed that this increased input space also led to instabilities. Even after introducing a form of backscatter clipping to stabilize these larger models, they were still outperformed by NN closure models with a small input space, for which only the solution at neighboring grid points was provided to the NN. Two other recent promising approaches to improving the stability of NN closure models are 'trajectory fitting' [14; 15; 21; 22; 23] and reinforcement learning [24; 25]. Both of these approaches have in common that instead of fitting the NN to match the exact closure term (which is what we will refer to as 'derivative fitting'), one optimizes directly with respect to how well the solution is reproduced when carrying out a simulation with the closure model embedded into the solver. This has been shown to lead to more accurate and stable models [14; 15; 26]. The main difference between the two is that for trajectory fitting one requires the implementation of the spatial and temporal discretization to be differentiable with respect to the NN parameters. In this way one can determine the gradients of the solution error with respect to the NN parameters such that gradient-based optimizers can be applied to the corresponding optimization problem. Reinforcement learning on the other hand does not require these gradients which makes it suitable for non-differentiable processes such as chess and self-driving cars [27]. However, neither of these approaches lead to a provably stable NN closure model without some form of clipping and also do not guarantee abidance by the underlying conservation laws. The latter something that to our knowledge does not yet exist in the case of LES closure models.

To resolve the issues of stability and lack of physical structure, we present _a new NN closure model that satisfies both momentum and kinetic energy conservation and is therefore stable by design_, while still allowing for backscatter of energy into the resolved scales. As stated earlier, the difficulty of this task mainly lies in the fact that: (i) the kinetic energy conservation law includes terms which depend on the SGS content which is too expensive to simulate directly, and consequently (ii) kinetic energy of the large scales is not a conserved quantity (in the limit of vanishing viscosity). In order to tackle these issues we propose to take the 'discretize first, filter next' approach [22; 26]. This means that we start from a high-resolution solution with \(N\) degrees of freedom (on a fine computational grid), to which we apply a discrete filter (a spatial average) that projects the solution onto a coarse computational grid of dimension \(I\), with \(I\ll N\). Given the discrete filter the exact closure term can be computed from the high-resolution simulation by calculating the commutator error. The main advantage of this approach is that the closure term now also accounts for the discretization error. Based on the filter's properties we then derive an energy conservation law that can be split into two components: one that depends solely on the large, or resolved, scales (resolved energy) and another that solely depends on the SGS content (SGS energy) [13]. Like in existing works the closure model is represented by a NN, however, we include an additional set of SGS variables that represent the SGS energy in our simulation. The key insight is that the resulting total system of equations should still conserve energy in the inviscid limit, and we choose our NN approximation such that it is consistent with
this limit. In this way we still allow for backscatter without sacrificing stability.

The paper is structured in the following way. In section 2 we discuss Burgers' and Korteweg-de Vries equation and their energy and momentum conservation properties. We introduce the discrete filter, the resulting closure problem, and derive a new energy conservation law that describes an energy exchange between the resolved energy and the SGS energy. In section 3 we introduce our new machine learning approach for modeling the closure term, satisfying the derived energy conservation law using a set of SGS variables to represent the SGS energy. In addition, we show how to also satisfy momentum conservation. In section 4 we study the convergence properties and stability of our closure model with respect to the coarse grid resolution and compare this to a vanilla CNN. We also analyze the structure-preserving properties in terms of momentum and energy conservation and the ability of the trained closure models to extrapolate in space and time. In section 5 we conclude our work.

## 2 Governing equations, discrete filtering, and closure problem

Before constructing a machine learning closure on the discrete level, we formulate a description of the closure problem and the machinery required (e.g. discrete filters and reconstruction operators) at the discrete level, and we discuss the effect of filtering on the physical structure.

### Spatial discretization

We consider an initial value problem (IVP) of the following form:

\[\frac{\partial u}{\partial t} =f(u), \tag{1}\] \[u(\mathbf{x},0) =u_{0}(\mathbf{x}), \tag{2}\]

which describes the evolution of some quantity \(u(\mathbf{x},t)\) in space \(\mathbf{x}\in\Omega\) and time \(t\) on the spatial domain \(\Omega\subseteq\mathbb{R}^{d}\), given initial state \(u_{0}\). The dynamics of the system is governed by right-hand side (RHS) \(f(u)\), which typically involves partial derivatives of \(u\). After spatial discretization (method of lines), we obtain the vector \(\mathbf{u}(t)\in\mathbb{R}^{N}\) which approximates the value of \(u\) at each of the \(N\) grid points \(\mathbf{x}_{i}\in\Omega\) for \(i=1,\ldots,N\), such that \(\mathrm{u}_{i}\approx u(\mathbf{x}_{i})\). The discrete analogue of the IVP is then

\[\frac{\mathrm{d}\mathbf{u}}{\mathrm{d}t} =f_{h}(\mathbf{u}), \tag{3}\] \[\mathbf{u}(0) =\mathbf{u}_{0}, \tag{4}\]

where \(f_{h}\) represents a spatial discretization of \(f\). It is assumed that all the physics described by equation (1) is captured in the discrete solution \(\mathbf{u}\). This means that whenever the physics involves a wide range of spatial scales, a very large number of degrees of freedom \(N\) is needed to adequately resolve all these scales. This places a heavy (or even insurmountable) burden on the computational effort that is required to numerically solve the considered equations.

### Burgers' and Korteweg-de Vries equation and physical structure

We are interested in the modeling and simulation of turbulent flows. For this purpose, we first consider Burgers' equation, a 1D simplification of the Navier-Stokes equations. Burgers' equation describes the evolution of the velocity \(u(x,t)\) according to partial differential equation (PDE)

\[\frac{\partial u}{\partial t}=-\frac{1}{2}\frac{\partial u^{2}}{\partial x}+ \nu\frac{\partial^{2}u}{\partial x^{2}}, \tag{5}\]

where the first term on the RHS represents non-linear convection and the second term diffusion, weighted by the viscosity parameter \(\nu\geq 0\). These processes are somewhat analogous to 3-D turbulence in the fact that smaller scales are created by nonlinear convective terms which are then dissipated by diffusion [28]. We
will be interested in two properties of the Burgers' equation, which we collectively call'structure'. Firstly, momentum \(P\) is conserved on periodic domains:

\[\frac{\mathrm{d}P}{\mathrm{d}t}=\frac{\mathrm{d}}{\mathrm{d}t}\int_{\Omega}u \mathrm{d}\Omega=\int_{\Omega}-\frac{1}{2}\frac{\partial u^{2}}{\partial x}+ \nu\frac{\partial^{2}u}{\partial x^{2}}\mathrm{d}\Omega=-\frac{1}{2}[u^{2}]_{a }^{b}+\nu[\frac{\partial u}{\partial x}]_{a}^{b}=0, \tag{6}\]

Secondly, on periodic domains (kinetic) energy is conserved in the absence of viscosity:

\[\frac{\mathrm{d}E}{\mathrm{d}t}=\frac{1}{2}\frac{\mathrm{d}}{\mathrm{d}t}\int _{\Omega}u^{2}\mathrm{d}\Omega=\int_{\Omega}-\frac{u}{2}\frac{\partial u^{2}} {\partial x}+u\nu\frac{\partial^{2}u}{\partial x^{2}}\mathrm{d}\Omega=-\frac{ 1}{3}[u^{3}]_{a}^{b}+\nu[u\frac{\partial u}{\partial x}]_{a}^{b}-\nu\int_{ \Omega}\left(\frac{\partial u}{\partial x}\right)^{2}\mathrm{d}\Omega=-\underbrace {\nu\int_{\Omega}\left(\frac{\partial u}{\partial x}\right)^{2}\mathrm{d} \Omega}_{\geq 0}, \tag{7}\]

where we used integration by parts.

These properties can be preserved in a discrete setting by employing a structure-preserving scheme [29] on a uniform grid with grid-spacing \(h\). The convective term is approximated by the following skew-symmetric scheme:

\[\mathbf{G}(\mathbf{u})=-\frac{1}{3}\mathbf{D}_{1}\mathbf{u}^{2}-\frac{1}{3} \mathrm{diag}(\mathbf{u})\mathbf{D}_{1}\mathbf{u}, \tag{8}\]

where \(\mathbf{D}_{1}\) is the central difference operator corresponding to the stencil \((\mathbf{D}_{1}\mathbf{u})_{i}=(\mathrm{u}_{i+1}-\mathrm{u}_{i-1})/(2h)\), \(\mathbf{u}^{2}\) is to be interpreted element-wise, and \(\mathbf{D}_{2}\) is the diffusive operator with stencil \((\mathbf{D}_{2}\mathbf{u})_{i}=(\mathrm{u}_{i+1}-2\mathrm{u}_{i}+\mathrm{u}_ {i-1})/h^{2}\). We assume periodic boundary conditions (BCs). The spatial discretization leads to a system of ordinary differential equations (ODEs):

\[\frac{\mathrm{d}\mathbf{u}}{\mathrm{d}t}=\underbrace{\mathbf{G}(\mathbf{u})+ \nu\mathbf{D}_{2}\mathbf{u}}_{=f_{h}(\mathbf{u})}. \tag{9}\]

which we will march forward in time using an explicit RK4 scheme [30]. The structure is preserved because the discretization conserves the discrete momentum \(P_{h}=h\mathbf{1}^{T}\mathbf{u}\) (for periodic BCs):

\[\frac{\mathrm{d}P_{h}}{\mathrm{d}t}=h\mathbf{1}^{T}f_{h}(\mathbf{u})=0, \tag{10}\]

where \(\mathbf{1}\) is a column vector with all entries equal to one. Furthermore, due to the skew-symmetry of the convection operator the evolution of the discrete kinetic energy \(E_{h}=\frac{h}{2}\mathbf{u}^{T}\mathbf{u}\) (which we will refer to simply as energy) is given by:

\[\text{Burgers' equation:}\qquad\frac{\mathrm{d}E_{h}}{\mathrm{d}t}=h\mathbf{u}^{ T}f_{h}(\mathbf{u})=h\nu\mathbf{u}^{T}\mathbf{D}_{2}\mathbf{u}=-\nu|| \mathbf{Q}\mathbf{u}||_{2}^{2}. \tag{11}\]

Here we used the fact that \(\mathbf{D}_{2}\) can be written as the Cholesky decomposition \(-\mathbf{Q}^{T}\mathbf{Q}\)[3], where \(\mathbf{Q}\) is a simple forward difference approximation of the first-order derivative. The norm \(\|.\|_{2}\) represents the conventional two-norm further detailed in section 2.5. This discretization ensures net energy dissipation and conservation in the inviscid limit.

In addition to Burgers' equation we will consider the Korteweg-de Vries (KdV) equation:

\[\frac{\partial u}{\partial t}=-\frac{\varepsilon}{2}\frac{\partial u^{2}}{ \partial x}-\mu\frac{\partial^{3}u}{\partial x^{3}}, \tag{12}\]

where \(\varepsilon\) and \(\mu\) are parameters. The KdV equation conserves momentum and (kinetic) energy irrespective of the values of \(\varepsilon\) and \(\mu\). We discretize the nonlinear term in the same way as for Burgers' equation, using the skew-symmetric scheme. The third-order spatial derivative is approximated by the skew-symmetric central difference operator \(\mathbf{D}_{3}\) corresponding to the stencil \((\mathbf{D}_{3}\mathbf{u})_{i}=(-\mathrm{u}_{i-2}+2\mathrm{u}_{i-1}-2\mathrm{u }_{i+1}+\mathrm{u}_{i+2})/(2h^{3})\), see [31]. The resulting discretization is then not only momentum conserving, but also energy conserving in the case of periodic BCs:

\[\text{KdV equation:}\qquad\frac{\mathrm{d}E_{h}}{\mathrm{d}t}=0. \tag{13}\]
### Discrete filtering

In order to tackle the issue of high computational expenses for large \(N\) we apply a spatial averaging filter to the fine-grid solution \(\mathbf{u}\), resulting in the coarse-grid solution \(\bar{\mathbf{u}}\). The coarse grid follows from dividing \(\Omega\) into \(I\) non-overlapping cells \(\Omega_{i}\) with cell centers \(\mathbf{X}_{i}\). The coarse grid is refined into the fine grid by splitting each \(\Omega_{i}\) into \(J(i)\) subcells \(\omega_{ij}\) with cell centers \(\mathbf{x}_{ij}\). This subdivision is intuitively pictured in the upper grid of Figure 1, for a 1D grid. Given the coarse and fine grid, we define the mass matrices \(\boldsymbol{\omega}\in\mathbb{R}^{N\times N}\) and \(\boldsymbol{\Omega}\in\mathbb{R}^{I\times I}\) which contain the volumes of the fine and coarse cells on the main diagonal, respectively.

To reduce the degrees of freedom of the system we apply a discrete spatial averaging filter \(\mathbf{W}\in\mathbb{R}^{I\times N}\), \(I<N\), to the fine-grid solution \(\mathbf{u}\) in order to obtain the filtered solution \(\bar{\mathbf{u}}\):

\[\bar{\mathbf{u}}=\mathbf{W}\mathbf{u}. \tag{14}\]

The spatial averaging filter is defined as

\[\mathbf{W}:=\boldsymbol{\Omega}^{-1}\mathbf{O}. \tag{15}\]

with overlap matrix \(\mathbf{O}\in\mathbb{R}^{I\times N}\):

\[\mathbf{O}:=\begin{bmatrix}|\omega_{11}|&\dots&|\omega_{1J(1)}|&&&&\\ &&\ddots&\ddots&\ddots&&\\ &&&&|\omega_{I1}|&\dots&|\omega_{IJ(I)}|\end{bmatrix}. \tag{16}\]

Here \(|.|\) represents the volume of the considered subcell. The overlap matrix essentially contains the volume of the overlap between coarse-grid cell \(\Omega_{i}\) and fine-grid subcell \(\omega_{ij}\) at the appropriate locations. Note that each column of \(\mathbf{W}\) and \(\mathbf{O}\) only contains one non-zero entry.

The filter reduces the number of unknowns at each time step from \(N\) to \(I\). Next to the filter, we define a reconstruction operator \(\mathbf{R}\in\mathbb{R}^{N\times I}\) which relates to \(\mathbf{W}\) as

\[\mathbf{R}:=\boldsymbol{\omega}^{-1}\mathbf{W}^{T}\boldsymbol{\Omega}= \boldsymbol{\omega}^{-1}\mathbf{O}^{T}. \tag{17}\]

The matrix \(\mathbf{R}\) is essentially a simple approximation of the inverse of \(\mathbf{W}\) by a piece-wise constant function [32]. This is intuitively pictured in Figure 2. An important property of the filter/reconstruction pair, which will be used in subsequent derivations, is that

\[\mathbf{W}\mathbf{R}=\boldsymbol{\Omega}^{-1}\mathbf{O}\boldsymbol{\omega}^{ -1}\mathbf{O}^{T}=\begin{bmatrix}\ddots&&\\ &\sum_{j=1}^{J(i)}\frac{|\omega_{ij}|}{|\Omega_{i}|}&\\ &&\ddots\end{bmatrix}=\mathbf{I}. \tag{18}\]

Consequently, filtering a reconstructed solution \(\mathbf{R}\bar{\mathbf{u}}\) leaves \(\bar{\mathbf{u}}\) unchanged, i.e.

\[\bar{\mathbf{u}}=\underbrace{(\mathbf{W}\mathbf{R})^{p}}_{=\mathbf{I}}\mathbf{ W}\mathbf{u} \tag{19}\]

for \(p\in\mathbb{N}_{0}\). We will refer to this property as the 'projection' property, as it is similar to how repeated application of a projection operator leaves a vector unchanged. By subtracting the reconstructed solution \(\mathbf{R}\bar{\mathbf{u}}\) from \(\mathbf{u}\) we can define the subgrid-scale (SGS) content \(\mathbf{u}^{\prime}\in\mathbb{R}^{N}\):

\[\mathbf{u}^{\prime}:=\mathbf{u}-\mathbf{R}\bar{\mathbf{u}}. \tag{20}\]

Figure 1: Subdivision of the spatial grid where the dots represent cell centers \(x_{ij}\) and \(X_{i}\) for \(J(1)=J(2)=3\) and \(J(3)=4\).
In addition, we will refer to the SGS content in a single coarse cell \(\Omega_{i}\) as \(\mathbf{\mu}_{i}\in\mathbb{R}^{J(i)}\), see Figure 2. Applying the filter to \(\mathbf{u}^{\prime}\) yields zero:

\[\mathbf{W}\mathbf{u}^{\prime}=\mathbf{W}\mathbf{u}-\underbrace{\mathbf{W} \mathbf{R}}_{=\mathrm{I}}\bar{\mathbf{u}}=\bar{\mathbf{u}}-\bar{\mathbf{u}}= \mathbf{0}_{\Omega}, \tag{21}\]

where \(\mathbf{0}_{\Omega}\) is a vector with all entries equal to zero defined on the coarse grid. This can be seen as the discrete equivalent of a property of a Reynolds operator [5]. As illustration we show each of the introduced quantities, calculated for a 1D sinusoidal wave, in Figure 2.

### Discrete closure problem

After having defined the filter we describe the time evolution of \(\bar{\mathbf{u}}\). Since we employ a spatial filter that does not depend on time, filtering and time-differentiation commute: \(\mathbf{W}\frac{\mathrm{d}\mathbf{u}}{\mathrm{d}t}=\frac{\mathrm{d}(\bar{ \mathbf{W}}\mathbf{u})}{\mathrm{d}t}=\frac{\mathrm{d}\bar{\mathbf{u}}}{ \mathrm{d}t}\). The closure problem arises because such a commutation property is not true for the spatial discretization, i.e.

\[\mathbf{W}f_{h}(\mathbf{u})\neq f_{H}(\mathbf{W}\mathbf{u})=f_{H}(\bar{ \mathbf{u}}), \tag{22}\]

where \(f_{H}\) represents the same spatial discretization scheme as \(f_{h}\), but on the coarse grid. The closure problem is that the equations for \(\bar{\mathbf{u}}\) are 'unclosed', meaning that we require the fine-grid solution \(\mathbf{u}\) to be able to evolve the coarse-grid solution \(\bar{\mathbf{u}}\) in time. The filtered system can be rewritten in closure model form as

\[\frac{\mathrm{d}\bar{\mathbf{u}}}{\mathrm{d}t}=f_{H}(\bar{\mathbf{u}})+ \underbrace{(\mathbf{W}f_{h}(\mathbf{u})-f_{H}(\bar{\mathbf{u}}))}_{=: \mathbf{c}(\mathbf{u})}, \tag{23}\]

where \(\mathbf{c}(\mathbf{u})\in\mathbb{R}^{I}\) is the closure term. \(\mathbf{c}(\mathbf{u})\) is essentially the discrete equivalent of the commutator error in LES [5]. One advantage of having first discretized the problem is that \(\mathbf{c}(\mathbf{u})\) now also includes the discretization error. The aim in closure modeling is generally to approximate \(\mathbf{c}(\mathbf{u})\) by a closure model \(\tilde{\mathbf{c}}(\bar{\mathbf{u}};\mathbf{\Theta})\). In section 3 we choose to represent \(\tilde{\mathbf{c}}\) by a neural network (NN), whose parameters \(\mathbf{\Theta}\) are to be trained to make the approximation accurate. In constructing such approximations, we will also use the equation describing the evolution of the SGS content \(\frac{\mathrm{d}\mathbf{u}^{\prime}}{\mathrm{d}t}\):

\[\frac{\mathrm{d}\mathbf{u}^{\prime}}{\mathrm{d}t}=\frac{\mathrm{d}\mathbf{u}} {\mathrm{d}t}-\mathbf{R}\frac{\mathrm{d}\bar{\mathbf{u}}}{\mathrm{d}t}. \tag{24}\]
### Inner products and energy decomposition

To describe the energy that is present in the system at any given time, we define the following inner products and norms:

\[(\mathbf{a},\mathbf{b})_{\boldsymbol{\xi}} :=\mathbf{a}^{T}\boldsymbol{\xi}\mathbf{b} \tag{25}\] \[||\mathbf{a}||_{\boldsymbol{\xi}}^{2} :=(\mathbf{a},\mathbf{a})_{\boldsymbol{\xi}} \tag{26}\]

for \(\boldsymbol{\xi}\in\{\boldsymbol{\omega},\boldsymbol{\Omega}\}\). With this notation we can represent the inner product on the fine grid, \(\mathbf{a},\mathbf{b}\in\mathbb{R}^{N}\), as well as the coarse grid, \(\mathbf{a},\mathbf{b}\in\mathbb{R}^{I}\), respectively. For \(\boldsymbol{\xi}=\mathbf{I}\) we simply obtain the conventional inner product and two-norm, denoted as \((\mathbf{a},\mathbf{b})=\mathbf{a}^{T}\mathbf{b}\) and \(||\mathbf{a}||_{2}^{2}\), respectively. We also define a joint inner product as the following sum of inner products:

\[(\begin{bmatrix}\mathbf{a}_{1}\\ \vdots\\ \mathbf{a}_{M}\end{bmatrix},\begin{bmatrix}\mathbf{b}_{1}\\ \vdots\\ \vdots\\ \mathbf{b}_{M}\end{bmatrix})_{\boldsymbol{\xi}_{M}}:=\begin{bmatrix} \mathbf{a}_{1}\\ \vdots\\ \mathbf{a}_{M}\end{bmatrix}^{T}\underbrace{\begin{bmatrix}\boldsymbol{\xi}&&\\ &\ddots&\\ &&\boldsymbol{\xi}\end{bmatrix}}_{=\boldsymbol{\xi}_{M}}\begin{bmatrix} \mathbf{b}_{1}\\ \vdots\\ \mathbf{b}_{M}\end{bmatrix}, \tag{27}\]

where vectors \(\mathbf{a}_{i}\) and \(\mathbf{b}_{i}\) (\(i=1,\ldots,M\)) have the appropriate dimensions and are concatenated into a column vector. Furthermore, \(\boldsymbol{\xi}_{M}\) is the extended mass matrix. This notation is introduced in order to later extend our system of equations with additional equations for the subgrid content. Besides the projection property (19) an additional characteristic of the filter/reconstruction pair is that the inner product is conserved under reconstruction (see Appendix A):

\[(\mathbf{R}\bar{\mathbf{a}},\mathbf{R}\bar{\mathbf{b}})_{\omega}=(\bar{ \mathbf{a}},\bar{\mathbf{b}})_{\Omega}. \tag{28}\]

The total energy \(E_{h}\) of the fine-grid solution in terms of inner products reads

\[E_{h}:=\frac{1}{2}||\mathbf{u}||_{\omega}^{2}, \tag{29}\]

which can be decomposed using (20):

\[E_{h} =\frac{1}{2}||\mathbf{u}||_{\omega}^{2}=\frac{1}{2}||\mathbf{R} \bar{\mathbf{u}}+\mathbf{u}^{\prime}||_{\omega}^{2}\] \[=\frac{1}{2}||\mathbf{R}\bar{\mathbf{u}}||_{\omega}^{2}+( \mathbf{R}\bar{\mathbf{u}},\mathbf{u}^{\prime})_{\omega}+\frac{1}{2}|| \mathbf{u}^{\prime}||_{\omega}^{2}.\]

We can simplify this decomposition by noting that the cross-term is zero, i.e. \(\mathbf{R}\bar{\mathbf{u}}\) is orthogonal to \(\mathbf{u}^{\prime}\), see Appendix A. Combining this orthogonality property with property (28) leads to the following important energy decomposition:

\[E_{h}=\underbrace{\frac{1}{2}||\tilde{\mathbf{u}}||_{\Omega}^{2}}_{=:E_{h}}+ \underbrace{\frac{1}{2}||\mathbf{u}^{\prime}||_{\omega}^{2}}_{=:E_{h}^{\prime}}. \tag{30}\]

In other words, our choice of filter and reconstruction operators is such that the total energy of the system can be split into one part (the resolved energy \(\bar{E}_{h}\)) that exclusively depends on the filtered \(\bar{\mathbf{u}}\) and another part (the SGS energy \(E_{h}^{\prime}\)) that depends only on the SGS content \(\mathbf{u}^{\prime}\). The energy conservation law can also be decomposed into a resolved and SGS part:

\[\frac{\mathrm{d}E_{h}}{\mathrm{d}t}=\frac{\mathrm{d}\bar{E}_{h}}{\mathrm{d}t} +\frac{\mathrm{d}E_{h}^{\prime}}{\mathrm{d}t}=(\bar{\mathbf{u}},\frac{ \mathrm{d}\bar{\mathbf{u}}}{\mathrm{d}t})_{\Omega}+(\mathbf{u}^{\prime},\frac{ \mathrm{d}\mathbf{u}^{\prime}}{\mathrm{d}t})_{\omega}=0, \tag{31}\]

where we used the product rule to arrive at this relation. For Burgers' equation with \(\nu>0\), the last equality sign changes to \(\leq\). This means that even for dissipative systems the resolved energy could in principle increase (so-called 'backscatter'), as long as the total energy is decreasing.

We illustrate the energy decomposition using simulations of the KdV equation. Figure 3 shows the exchange of energy between the subgrid and filtered solutions. Clearly, the energy of the filtered solution is _not_ a conserved quantity.
### Momentum conservation

Next to the energy, we formulate the total discrete momentum in terms of an inner product and investigate if it is conserved upon filtering. The total discrete momentum is given by

\[P_{h}=(\mathbf{1}_{\omega},\mathbf{u})_{\omega}, \tag{32}\]

where \(\mathbf{1}_{\omega}\) is a vector with all entries equal to one, defined on the fine grid. From this definition we can show (see Appendix A) that the discrete momentum does not change upon filtering, i.e.

\[P_{h}=(\mathbf{1}_{\omega},\mathbf{u})_{\omega}=(\mathbf{1}_{\Omega},\bar{ \mathbf{u}})_{\Omega}. \tag{33}\]

This relation allows us to derive a momentum conservation condition on the closure term:

\[\frac{\mathrm{d}P_{h}}{\mathrm{d}t}=(\mathbf{1}_{\omega},f_{h}(\mathbf{u}))_{ \omega}=(\mathbf{1}_{\Omega},\mathbf{W}f_{h}(\mathbf{u}))_{\Omega}=(\mathbf{1 }_{\Omega},f_{H}(\bar{\mathbf{u}})+\mathbf{c}(\mathbf{u}))_{\Omega}=(\mathbf{ 1}_{\Omega},\mathbf{c}(\mathbf{u}))_{\Omega}=0, \tag{34}\]

where we used the fact that the coarse discretization is already momentum conserving.

## 3 Structure-preserving closure modeling framework

The derived discrete energy and momentum balances, before and after filtering, will be used to construct a novel structure-preserving closure model in this section. We will also discuss how to fit the parameters of the model. The ideas will be presented for periodic BCs in 1D, whereas different types of boundary conditions (BCs) are discussed in Appendix C.

### Framework

Many existing closure approaches aim at approximating \(\mathbf{c}(\mathbf{u})\) by a closure model \(\tilde{\mathbf{c}}(\bar{\mathbf{u}};\mathbf{\Theta})\), where \(\mathbf{\Theta}\) are parameters to be determined such that the approximation is accurate. In this work, we propose a novel

Figure 3: Simulation of KdV equation (12) with periodic BCs before and after filtering (left) and corresponding energy decomposition (right).
formulation, in which we extend the system of equations for the \(I\) filtered variables \(\bar{\mathbf{u}}\) with a set of \(I\) auxiliary SGS variables \(\mathbf{s}\in\mathbb{R}^{I}\) that locally model the SGS energy. This extended system of equations has the form

\[\frac{\mathrm{d}}{\mathrm{d}t}\begin{bmatrix}\bar{\mathbf{u}}\\ \mathbf{s}\end{bmatrix}=\begin{bmatrix}f_{H}(\bar{\mathbf{u}})\\ \mathbf{0}\end{bmatrix}+\mathbf{\Omega}_{2}^{-1}(\mathcal{K}-\mathcal{K}^{T}) \begin{bmatrix}\bar{\mathbf{u}}\\ \mathbf{s}\end{bmatrix}-\mathbf{\Omega}_{2}^{-1}\mathcal{Q}^{T}\mathcal{Q} \begin{bmatrix}\bar{\mathbf{u}}\\ \mathbf{s}\end{bmatrix}, \tag{35}\]

where \(\mathcal{K}=\mathcal{K}(\bar{\mathbf{u}},\mathbf{s},\mathbf{\Theta})\in \mathbb{R}^{2I\times 2I}\) and \(\mathcal{Q}=\mathcal{Q}(\bar{\mathbf{u}},\mathbf{s},\mathbf{\Theta})\in \mathbb{R}^{2I\times 2I}\), and \(\mathbf{\Theta}\) represents the parameters. Note that this system is an approximation of the true dynamics. Next to the introduction of the SGS variables \(\mathbf{s}\), the second main novelty in this work is to formulate the closure model in terms of a skew-symmetric term and a dissipative term. The skew-symmetric term is introduced to allow for a local energy exchange between the filtered solution and the SGS variables, and the dissipative term to provide additional dissipation. These operators will be modelled in terms of neural networks (NNs) with trainable parameters (contained in \(\mathbf{\Theta}\)). So even though the notation in (35) suggests linearity of the closure model in \(\bar{\mathbf{u}}\) and \(\mathbf{s}\), the dependence of \(\mathcal{K}\) and \(\mathcal{Q}\) on \(\bar{\mathbf{u}}\) and \(\mathbf{s}\) makes the model non-linear. The construction of the introduced operators will be detailed in sections 3.3 and 3.4. Note the presence of \(\mathbf{\Omega}_{2}^{-1}\) in (35), which is due to the fact that our energy definition includes \(\mathbf{\Omega}\).

The SGS variables \(\mathbf{s}\) are used to represent the SGS energy _on the coarse grid_, such that

\[\frac{1}{2}\mathbf{s}^{2}\approx\frac{1}{2}\mathbf{W}(\mathbf{u}^{\prime})^{2}, \tag{36}\]

where the notation \((.)^{2}\) is again to be interpreted element-wise. In section 3.2 we present how we achieve this approximation. By adding these SGS variables as unknowns into equation (35), we are able to include an approximation of the SGS energy into the simulation, while still significantly reducing the system size (from \(N\) to \(2I\)). Our key insight is that _by explicitly including an approximation of the SGS energy we are able to satisfy the energy conservation balance, equation (31)_. The energy balance serves not only as an important constraint that restrains the possible forms that the closure model (represented by a NN) can take, but also guarantees stability of our closure model, since the (kinetic) energy is a norm of the solution which is bounded in time.

Given the extended system of equations, the total energy is approximated as

\[E_{h}\approx E_{s}:=||\bar{\mathbf{U}}||_{\Omega_{2}}^{2}=\underbrace{\frac{1 }{2}(\bar{\mathbf{u}},\bar{\mathbf{u}})_{\Omega}}_{=E_{h}}+\underbrace{\frac{ 1}{2}(\mathbf{s},\mathbf{s})_{\Omega}}_{=:S}, \tag{37}\]

with \(S\) approximating the SGS energy

\[S\approx\bar{E}_{h}^{\prime}, \tag{38}\]

with evolution

\[\frac{\mathrm{d}E_{s}}{\mathrm{d}t}=\left(\bar{\mathbf{U}},\frac{\mathrm{d} \bar{\mathbf{U}}}{\mathrm{d}t}\right)_{\Omega_{2}}, \tag{39}\]

where we used the joint inner product notation introduced in (27) and concatenated the filtered solution and the SGS variables into a single vector \(\bar{\mathbf{U}}\in\mathbb{R}^{2I}\):

\[\bar{\mathbf{U}}:=\begin{bmatrix}\bar{\mathbf{u}}\\ \mathbf{s}\end{bmatrix}. \tag{40}\]

Upon substituting the closure model form, equation (35), the following evolution equation for the approximated total energy results:

\[\frac{\mathrm{d}E_{s}}{\mathrm{d}t}=(\bar{\mathbf{u}},f_{H}(\bar{\mathbf{u}})) _{\Omega}-||\mathcal{Q}\bar{\mathbf{U}}||_{2}^{2}, \tag{41}\]

as the skew-symmetric term involving \(\mathcal{K}-\mathcal{K}^{T}\) cancels. This equation can be further simplified when choosing a specific \(f_{H}\). For example, if we substitute the structure-preserving discretization of Burgers' equation (9) for \(f_{H}\) (with grid-spacing \(H\)) we obtain

\[\text{Burgers' equation:}\qquad\frac{\mathrm{d}E_{s}}{\mathrm{d}t}=-H\nu||\bar{ \mathbf{Q}}\bar{\mathbf{u}}||_{2}^{2}-||\mathcal{Q}\bar{\mathbf{U}}||_{2}^{2} \leq 0, \tag{42}\]
i.e. energy is dissipated from the system by two terms: the coarse-grid diffusion operator, and an additional (trainable) dissipation term. Here \(\bar{\mathbf{Q}}\) represents the forward difference approximation of the first-order derivative on the coarse grid. This additional dissipation term is required as the diffusion operator, discretized on the fine grid, is more dissipative than on the coarse grid, see Appendix B.

For energy-conserving systems, such as KdV, we set \(\mathcal{Q}\) to zero, and we obtain:

\[\text{KdV equation:}\qquad\frac{\mathrm{d}E_{s}}{\mathrm{d}t}=0. \tag{43}\]

We stress again that by having added an approximation of the subgrid energy into the equation system, we are able to use the concept of energy conservation (or dissipation) in constructing a closure model. Furthermore, as energy is dissipated or conserved the resulting model is stable by design.

### SGS variables

To represent the SGS variables we propose a data-driven linear compression of the SGS content (assuming uniform coarse and fine grids such that \(J(i)=J\)):

\[\mathrm{s}_{i}=\mathbf{t}^{T}\boldsymbol{\mu}_{i},\qquad i=1,\ldots,I, \tag{44}\]

where we recall that \(\boldsymbol{\mu}_{i}\in\mathbb{R}^{J}\) represents the SGS content in a single coarse cell \(\Omega_{i}\). The SGS variable \(\mathrm{s}_{i}\) is a representation of the SGS content within cell \(\Omega_{i}\) encoded by learnable compression parameters \(\mathbf{t}\in\mathbb{R}^{J}\). This linear compression can be written for all coarse-grid points as the following matrix vector product:

\[\mathbf{s}=\mathbf{T}\mathbf{u}^{\prime}, \tag{45}\]

with \(\mathbf{T}(\mathbf{t})\in\mathbb{R}^{I\times N}\) being the (sparse) compression matrix fully defined by the parameters \(\mathbf{t}\). Note that \(\mathbf{T}\) has the same sparsity pattern as \(\mathbf{W}\). Using this notation (40) can be written as

\[\bar{\mathbf{U}}=\mathbf{W}_{\mathbf{T}}\mathbf{u}, \tag{46}\]

where

\[\mathbf{W}_{\mathbf{T}}:=\begin{bmatrix}\mathbf{W}\\ \mathbf{T}(\mathbf{I}-\mathbf{R}\mathbf{W})\end{bmatrix}. \tag{47}\]

The main advantage of defining the compression as a linear operation is that, if we have reference data for \(\mathbf{u}^{\prime}\), we can easily obtain the evolution of \(\mathbf{s}\) as

\[\frac{\mathrm{d}\mathbf{s}}{\mathrm{d}t}=\frac{\partial\mathbf{s}}{\partial \mathbf{u}^{\prime}}\frac{\mathrm{d}\mathbf{u}^{\prime}}{\mathrm{d}t}=\mathbf{ T}\frac{\mathrm{d}\mathbf{u}^{\prime}}{\mathrm{d}t}. \tag{48}\]

Another advantage is that the Jacobian \(\frac{\partial\mathbf{s}}{\partial\mathbf{u}^{\prime}}=\mathbf{T}\) does not depend on \(\mathbf{u}^{\prime}\), such that we avoid the problem that arises when taking the 'natural' choice of \(\mathbf{s}\), which would be \(\mathbf{s}=\sqrt{\mathbf{W}(\mathbf{u}^{\prime})^{2}}\), namely that the Jacobian

\[\left(\frac{\partial\mathbf{s}}{\partial\mathbf{u}^{\prime}}\right)_{ij}= \frac{\mathrm{W}_{ij}\mathrm{u}_{j}^{\prime}}{\sqrt{\sum_{j=1}^{N}\mathrm{W}_{ ij}(\mathrm{u}_{j}^{\prime})^{2}}}\]

becomes undefined when the denominator is zero. A third advantage is that the linear compression allows us to calculate the contribution of a forcing term to \(\frac{\mathrm{d}\mathbf{s}}{\mathrm{d}t}\) (this will be explained in section 3.5). The parameters \(\mathbf{t}\) are chosen such that the SGS energy is accurately represented on the coarse grid, i.e. we determine the elements of \(\mathbf{t}\) such that they minimize the error made in approximation (36), leading to the loss function

\[\mathcal{L}_{s}(\mathcal{D};\mathbf{t})=\frac{1}{|\mathcal{D}|}\sum_{d\in \mathcal{D}}\frac{1}{|\Omega|}||\frac{1}{2}(\mathbf{T}(\mathbf{t})\mathbf{u}_ {d}^{\prime})^{2}-\frac{1}{2}\mathbf{W}(\mathbf{u}_{d}^{\prime})^{2}||_{ \Omega}^{2}, \tag{49}\]

where the notation \((.)^{2}\) is again to be interpreted element-wise. Here the subscript \(d\) represents a sample from the training dataset \(\mathcal{D}\) containing \(|\mathcal{D}|\) samples. Note that, due to the way \(\mathbf{t}\) appears in the loss function,
negative values for \(\mathbf{s}\) are allowed. To overcome the saddle point at \(\mathbf{t}=\mathbf{0}\) we initialize the elements of \(\mathbf{t}\) with random noise (see Appendix D). For \(J=2\) this minimization problem has an exact solution (see Appendix E).

To illustrate how the compression works in practice we consider a snapshot from a simulation of Burgers' equation (\(\nu=0.01\)) with periodic BCs, see Figure 4. We observe that \(\mathbf{s}\) serves as an energy storage for the SGS content, which is mainly present near shocks.

### Skew-symmetric closure term \(\mathcal{K}\)

Having defined the SGS variables \(\mathbf{s}\), we continue to detail the construction of \(\mathcal{K}\) appearing in equation (35). We propose the following decomposition:

\[\mathcal{K}=\begin{bmatrix}\mathbf{K}_{11}&\mathbf{K}_{12}\\ \mathbf{0}&\mathbf{K}_{22}\end{bmatrix}\quad\rightarrow\quad\mathcal{K}- \mathcal{K}^{T}=\begin{bmatrix}\mathbf{K}_{11}-\mathbf{K}_{11}^{T}&\mathbf{K} _{12}\\ -\mathbf{K}_{12}^{T}&\mathbf{K}_{22}-\mathbf{K}_{22}^{T}\end{bmatrix}, \tag{50}\]

with submatrices \(\mathbf{K}_{ij}(\bar{\mathbf{U}};\boldsymbol{\Theta})\in\mathbb{R}^{I\times I}\), which will depend on the solution \(\bar{\mathbf{U}}\) and trainable parameters \(\boldsymbol{\Theta}\). This decomposition is chosen such that the upper-left submatrix \(\mathbf{K}_{11}\) allows for an energy exchange within the resolved scales, the upper-right submatrix \(\mathbf{K}_{12}\) for an energy exchange between the resolved scales and the SGS variables, and the final submatrix \(\mathbf{K}_{22}\) for an energy exchange within the SGS variables. If all entries of each \(\mathbf{K}_{ij}\) would be taken as parameters, one would have \(\mathcal{O}(I^{2})\) parameters, which is too large for practical problems of interest. Instead, we propose to represent each \(\mathbf{K}_{ij}\) in terms of a matrix \(\boldsymbol{\Phi}_{ij}\in\mathbb{R}^{I\times I}\) of only \(2D+1\) diagonals \(\boldsymbol{\phi}_{d}^{ij}\in\mathbb{R}^{I}\) (\(d=-D,\ldots,D\)), where each diagonal is given by an output channel of a convolutional neural network (CNN, [33]):

\[\boldsymbol{\Phi}_{ij}=\begin{bmatrix}\ddots&&\ddots&\ddots&\ddots&&\ddots&&\\ &\boldsymbol{\phi}_{-D}^{ij}&\cdots&\boldsymbol{\phi}_{-1}^{ij}&\boldsymbol{ \phi}_{0}^{ij}&\boldsymbol{\phi}_{1}^{ij}&\cdots&\boldsymbol{\phi}_{D}^{ij} \\ &&\ddots&&\ddots&\ddots&\ddots&&\ddots\end{bmatrix}. \tag{51}\]

The hyperparameter \(D\) determines the sparsity of \(\boldsymbol{\Phi}_{ij}\) and is taken such that \(D\ll I/2\) to reduce computational costs. In this way only a local neighbourhood is included in the approximation. As the input channels of the CNN we take \(\{\bar{\mathbf{u}},\mathbf{s},f_{H}(\bar{\mathbf{u}})\}\). The dependence of \(\boldsymbol{\phi}_{d}\) on \(\bar{\mathbf{U}}\) through the CNN adds non-linearity to the

Figure 4: Learned SGS compression applied to Burgers’ equation for \(N=1000\), with \(I=20\) and \(J=50\). By filtering and applying the SGS compression the degrees of freedom of this system are effectively reduced from \(N=1000\) to \(2I=40\).
closure model. Multiplying some vector \(\mathbf{v}\) by \(\mathbf{\Phi}_{ij}\) thus corresponds to the following non-linear stencil

\[(\mathbf{\Phi}_{ij}\mathbf{v})_{k}=\sum_{d=-D}^{D}\phi_{dk}^{ij}(\bar{\mathbf{U} };\mathbf{\Theta})\mathrm{v}_{k+d}. \tag{52}\]

A CNN is chosen to represent the diagonals as it is invariant with respect to translations of the input channels. In this way our final closure model inherits this property. In total, the CNN thus consists of three input channels, an arbitrary number of hidden channels (to be specified in the results section), and \(3(2D+1)\) output channels:

\[\mathrm{CNN}:\bar{\mathbf{u}},\mathbf{s},f_{H}(\bar{\mathbf{u}})\mapsto \boldsymbol{\phi}_{d}^{11},\boldsymbol{\phi}_{d}^{12},\boldsymbol{\phi}_{d}^ {22}\qquad d=-D,\ldots D. \tag{53}\]

In the case of periodic BCs we apply circular padding to the input channels of the CNN to connect both ends of the domain. Different BC types are discussed in Appendix C.

Although in principle the matrices \(\mathbf{K}_{ij}\) could be represented directly by matrices of the form (51), such a construction is not momentum-conserving. In the next subsection we will propose an approach to express \(\mathbf{K}_{ij}\) in terms of \(\mathbf{\Phi}_{ij}\) which _is_ momentum conserving.

#### 3.3.1 Momentum-conserving transformation

Requiring momentum conservation for the extended system (35) leads to the following condition (see also (34)):

\[\left(\begin{bmatrix}\mathbf{1}_{\Omega}\\ \mathbf{0}_{\Omega}\end{bmatrix},\mathbf{\Omega}_{2}^{-1}(\mathcal{K}- \mathcal{K}^{T})\bar{\mathbf{U}}\right)_{\Omega_{2}}=\mathbf{1}_{\Omega}^{T}( \mathbf{K}_{11}-\mathbf{K}_{11}^{T})\bar{\mathbf{u}}+\mathbf{1}_{\Omega}^{T} \mathbf{K}_{12}\mathbf{s}=0, \tag{54}\]

such that we impose the following constraints on the \(\mathbf{K}\) matrices:

\[\mathbf{1}_{\Omega}^{T}\mathbf{K}_{11}=\mathbf{1}_{\Omega}^{T}\mathbf{K}_{11} ^{T}=\mathbf{1}_{\Omega}^{T}\mathbf{K}_{12}=\mathbf{0}_{\Omega}. \tag{55}\]

To satisfy conditions (55) we first define the linear operator \(\mathbf{B}\in\mathbb{R}^{I\times I}\) corresponding to the stencil

\[(\mathbf{B}\mathbf{v})_{i}=\sum_{j=-B}^{B}b_{i}\mathrm{v}_{i+j} \tag{56}\]

with \(2B+1\) parameters \(b_{i}\) (\(i=-B,\ldots,B\)), applied to some vector \(\mathbf{v}\). In addition, we define the matrix \(\bar{\mathbf{B}}\in\mathbb{R}^{I\times I}\) whose elements are given by

\[\bar{b}_{i}=b_{i}-\frac{1}{2B+1}\sum_{i=-B}^{B}b_{i}, \tag{57}\]

corresponding to the stencil

\[(\bar{\mathbf{B}}\mathbf{v})_{i}=\sum_{j=-B}^{B}\bar{b}_{i}\mathrm{v}_{i+j}. \tag{58}\]

In the periodic case this matrix satisfies

\[\mathbf{1}_{\Omega}^{T}\bar{\mathbf{B}}=\mathbf{1}_{\Omega}^{T}\bar{\mathbf{B }}^{T}=\mathbf{0}_{\Omega}, \tag{59}\]

independent of the choice of underlying parameters \(b_{i}\). A simple example of a matrix \(\bar{\mathbf{B}}\) that satisfies such conditions is the second order finite difference representation of a first-order derivative: \(B=1\), \(\bar{b}_{-1}=-1/(2H)\), \(\bar{b}_{0}=0\), \(\bar{b}_{1}=1/(2H)\). Our framework allows for more general stencils which are trained based on fine-grid simulations.
These \(\mathbf{B}\) matrices can be used to enforce momentum conservation on the \(\mathbf{\Phi}\) matrices by pre- and post-multiplication. This will be denoted by a superscript, e.g.

\[\mathbf{K}_{12}=\mathbf{\Phi}_{12}^{\bar{\mathbf{B}}\mathbf{B}}=\bar{\mathbf{B}}_ {1}^{\mathbf{\Phi}_{12}}\mathbf{\Phi}_{12}\mathbf{B}_{2}^{\mathbf{\Phi}_{12}} \tag{60}\]

such that \(\mathbf{1}_{\Omega}^{T}\mathbf{K}_{12}=0\) is satisfied. Note that satisfying this condition only requires a \(\bar{(.)}\) over the pre-multiplying \(\mathbf{B}\) matrix. The matrices \(\bar{\mathbf{B}}_{1}^{\mathbf{\Phi}_{12}},\mathbf{B}_{2}^{\mathbf{\Phi}_{12}} \in\mathbb{R}^{I\times I}\) each contain their own unique set of \(2B+1\) underlying parameters. The hyperparameter \(B\) is taken such that \(B\ll I/2\) to enforce sparsity and thus reduce computational costs. Similarly,

\[\mathbf{K}_{11}=\mathbf{\Phi}_{11}^{\bar{\mathbf{B}}\bar{\mathbf{B}}}=\bar{ \mathbf{B}}_{1}^{\mathbf{\Phi}_{11}}\mathbf{\Phi}_{11}\bar{\mathbf{B}}_{2}^{ \mathbf{\Phi}_{11}} \tag{61}\]

such that the constraints \(\mathbf{1}_{\Omega}^{T}\mathbf{K}_{11}=\mathbf{1}_{\Omega}^{T}\mathbf{K}_{11} ^{T}=0\) are met. The additional \(\mathbf{B}\) matrices of \(\mathbf{K}_{11}\) add another set of \(2(2B+1)\) parameters to the framework.

The full matrix \(\mathcal{K}\) follows as

\[\mathcal{K}=\begin{bmatrix}\mathbf{\Phi}_{11}^{\bar{\mathbf{B}}\bar{\mathbf{B }}}&\mathbf{\Phi}_{12}^{\bar{\mathbf{B}}\bar{\mathbf{B}}}\\ \mathbf{0}&\mathbf{\Phi}_{22}^{\bar{\mathbf{B}}\bar{\mathbf{B}}}\end{bmatrix}, \tag{62}\]

where we used a momentum-conserving matrix \(\bar{\mathbf{B}}\) where appropriate. We thus have \(6(2B+1)\) parameters that fully describe the \(\mathbf{B}\) matrices.

### Dissipative term \(\mathcal{Q}\)

In a similar fashion as \(\mathcal{K}\) we decompose \(\mathcal{Q}\) as

\[\mathcal{Q}=\begin{bmatrix}\mathbf{Q}_{11}&\mathbf{Q}_{12}\\ \mathbf{Q}_{21}&\mathbf{Q}_{22}\end{bmatrix}. \tag{63}\]

As for the \(\mathcal{K}\) matrix, we do not represent the entire matrix by parameters but instead use the output channels of the CNN to represent the diagonals of the submatrices. However, in this case we only construct the main and \(D\) upper diagonals. The reason for this will be explained later. The diagonals are again represented by CNN output channels \(\boldsymbol{\psi}^{ij}\in\mathbb{R}^{I}\) defining the matrix \(\mathbf{\Psi}_{ij}\in\mathbb{R}^{I\times I}\). The CNN of section 3.3 is thus extended and represents the mapping

\[\text{CNN}:\bar{\mathbf{u}},\mathbf{s},f_{H}(\bar{\mathbf{u}})\mapsto \boldsymbol{\phi}_{d_{1}}^{11},\boldsymbol{\phi}_{d_{1}}^{12},\boldsymbol{\phi }_{d_{1}}^{22},\boldsymbol{\psi}_{d_{2}}^{11},\boldsymbol{\psi}_{d_{2}}^{12}, \boldsymbol{\psi}_{d_{2}}^{21},\boldsymbol{\psi}_{d_{2}}^{22},\qquad d_{1}=-D, \ldots D,\quad d_{2}=0,\ldots D. \tag{64}\]

The underlying CNN now consists of three input channels, an arbitrary number of hidden channels, and \(3(2D+1)+4(D+1)\) output channels.

Again, like in case of \(\mathbf{\Phi}\), a mapping is needed to make the \(\mathbf{\Psi}\) matrices momentum-conserving. Substituting decomposition (63) into the momentum conservation constraint (34) results in

\[-\left(\begin{bmatrix}\mathbf{1}_{\Omega}\\ \mathbf{0}_{\Omega}\end{bmatrix},\mathbf{\Omega}_{2}^{-1}(\mathcal{Q}^{T} \mathcal{Q})\bar{\mathbf{U}}\right)_{\Omega_{2}}=-\mathbf{1}_{\Omega}^{T}( \mathbf{Q}_{11}^{T}\mathbf{Q}_{11}+\mathbf{Q}_{21}^{T}\mathbf{Q}_{21})\bar{ \mathbf{u}}-\mathbf{1}_{\Omega}^{T}(\mathbf{Q}_{11}^{T}\mathbf{Q}_{12}+ \mathbf{Q}_{21}^{T}\mathbf{Q}_{22})\mathbf{s}=0, \tag{65}\]

leading to the constraints

\[\mathbf{1}_{\Omega}^{T}\mathbf{Q}_{11}^{T}=\mathbf{1}_{\Omega}^{T}\mathbf{Q} _{21}^{T}=\mathbf{0}_{\Omega}. \tag{66}\]

The matrix \(\mathcal{Q}\) that satisfies these constraints follows as

\[\mathcal{Q}=\begin{bmatrix}\mathbf{\Psi}_{11}^{\mathbf{I}\mathbf{B}}&\mathbf{ \Psi}_{12}^{\mathbf{I}\mathbf{B}}\\ \mathbf{\Psi}_{21}^{\mathbf{I}\mathbf{B}}&\mathbf{\Psi}_{22}^{\mathbf{I} \mathbf{B}}\end{bmatrix}, \tag{67}\]

where we used a momentum-conserving matrix \(\bar{\mathbf{B}}\) where appropriate and replaced the pre-multiplying \(\mathbf{B}\) matrix by the identity matrix. The latter, in addition to only constructing the main and upper diagonals of the \(\mathbf{\Psi}\) matrices, makes that the sparsity pattern of \(\mathcal{Q}^{T}\mathcal{Q}\) matches that of \(\mathcal{K}-\mathcal{K}^{T}\). With the addition of this dissipative term all the \(\mathbf{B}\) matrices combined contain in total \(10(2B+1)\) parameters that are to be trained.
Figure 5: Example of a simulation of Burgers’ equation with periodic BCs using our trained structure-preserving closure model for \(I=20\) (left), along with the DNS solution for \(N=1000\) (right).
An example application of the framework is shown in Figure 5, where we simulate Burgers' equation using our structure-preserving closure modeling framework and compare it to a direct numerical simulation (DNS). It is again interesting to see that \(\mathbf{s}\) is largest at the shocks, indicating the presence of significant SGS content there. When comparing the magnitude of the different terms in (35) (see Figure 6), we observe that the \(\mathcal{K}\) term, that is responsible for redistributing the energy, is most important, and in fact more important than the coarse-grid discretization operator \(f_{H}(\bar{\mathbf{u}})\). In other words, our closure model has learned dynamics that are highly significant to correctly predict the evolution of the filtered system.

### Forcing

Our proposed closure modeling framework allows for the presence of a forcing term \(\mathrm{F}_{i}(t)\approx F(\mathbf{x}_{i},t)\) in the RHS of our discretized PDE (3), with \(\mathbf{F}\in\mathbb{R}^{N}\). As long as this term does not depend on the solution \(\mathbf{u}\) the forcing commutes with \(\mathbf{W}\). This means we can simply add \(\bar{\mathbf{F}}=\mathbf{W}\mathbf{F}\) to the RHS of (23) without any contribution to the closure term. In addition, we can account for its contribution to the evolution of \(\mathbf{s}\) by first computing its contribution \(\mathbf{F}^{\prime}\) to the evolution of the SGS content (see (24)) as

\[\mathbf{F}^{\prime}:=\mathbf{F}-\mathbf{R}\bar{\mathbf{F}}. \tag{68}\]

The contribution to the evolution \(\mathbf{s}\) is then given by \(\mathbf{T}\mathbf{F}^{\prime}\), see (48).

The full closure modeling framework is thus summarized by

\[\frac{\mathrm{d}\bar{\mathbf{U}}}{\mathrm{d}t}=\mathcal{G}_{\mathbf{\Theta}}( \bar{\mathbf{U}}):=\begin{bmatrix}f_{H}(\bar{\mathbf{u}})\\ \mathbf{0}\end{bmatrix}+\mathbf{\Omega}_{2}^{-1}(\mathcal{K}-\mathcal{K}^{T} )\bar{\mathbf{U}}-\mathbf{\Omega}_{2}^{-1}\mathcal{Q}^{T}\mathcal{Q}\bar{ \mathbf{U}}+\mathbf{W}_{\mathbf{T}}\mathbf{F}, \tag{69}\]

depending on parameters \(\mathbf{\Theta}\). Note that we separated the forcing from \(f_{H}\) (the RHS of the coarse discretization). In the results section we use a forcing term in some of the Burgers' equation simulations.

### Finding the optimal parameter values

The optimal parameter values \(\mathbf{\Theta}^{*}\), where \(\mathbf{\Theta}\) includes the weights of the CNN along with the parameters of the \(\mathbf{B}\) matrices, can be obtained numerically by minimizing

\[\mathcal{L}(\mathcal{D};\mathbf{\Theta}):=\frac{1}{|\mathcal{D}|}\sum_{d\in \mathcal{D}}\frac{1}{2|\Omega|}||\mathcal{G}_{\mathbf{\Theta}}(\mathbf{W}_{ \mathbf{T}}\mathbf{u}_{d})-\mathbf{W}_{\mathbf{T}}f_{h}(\mathbf{u}_{d})||_{ \Omega_{2}}^{2} \tag{70}\]

Figure 6: Magnitude of each of the different terms present in (35) corresponding to the simulation in Figure 5.
with respect to \(\mathbf{\Theta}\) for the training set \(\mathcal{D}\) containing \(|\mathcal{D}|\) samples. We will refer to this approach as 'derivative fitting', as we minimize the residual between the predicted and the true RHS. In (70) the true RHS is obtained by applying \(\mathbf{W_{T}}\) to the fine-grid RHS \(f_{h}(\mathbf{u}_{d})\). The subscript \(d\) indicates a sample from the training set.

We will combine this method with a different approach in which we directly optimize \(\mathbf{\Theta}\) such that the solution itself is accurately reproduced. To achieve this we minimize

\[\mathcal{L}_{n}(\mathcal{D};\mathbf{\Theta}):=\frac{1}{|\mathcal{D}|}\sum_{d \in\mathcal{D}}\frac{1}{n}\sum_{i=1}^{n}\frac{1}{2|\Omega|}||\mathcal{S}^{i}_{ \mathbf{\Theta}}(\mathbf{W_{T}}\mathbf{u}_{d})-\mathbf{W_{T}}\mathcal{S}^{i( \overline{\Delta t}/\Delta t)}(\mathbf{u}_{d})||^{2}_{\Omega_{2}}, \tag{71}\]

where \(\mathcal{S}^{i}_{\mathbf{\Theta}}(\mathbf{W_{T}}\mathbf{u}_{d})\) represents the successive application of an explicit time integration scheme for \(i\) time steps, with step size \(\overline{\Delta t}\), starting from initial condition \(\mathbf{W_{T}}\mathbf{u}_{d}\), using the introduced closure model. The fine-grid counterpart is indicated by \(\mathcal{S}^{i(\overline{\Delta t}/\Delta t)}(\mathbf{u}_{d})\), with step size \(\Delta t\), starting from initial condition \(\mathbf{u}_{d}\). Note the appearance of the ratio \(\overline{\Delta t}/\Delta t\), as the coarser grid for \(\tilde{\mathbf{u}}\) allows us to take larger time steps [34]. This further reduces the required computational resources. We will refer to this method of finding the optimal parameters as 'trajectory fitting'. This approach has been shown to yield more accurate and stable closure models [14; 15; 21; 22; 23], as this approach also accounts for the time discretization error.

In practice, we employ a hybrid approach in which we first use derivative fitting and subsequently continue with trajectory fitting, as the latter requires more computational effort.

## 4 Results

To test our closure modeling framework we consider the previously introduced Burgers' equation with \(\nu=0.01\) on the spatial domain \(\Omega=[0,2\pi]\) for two test cases: (i) periodic BCs without forcing and (ii) inflow/outflow (I/O) BCs with time-independent forcing. The implementation of BCs is discussed in Appendix C. We also consider a third test case: (iii) the KdV equation with \(\varepsilon=6\) and \(\mu=1\) on the spatial domain \(\Omega=[0,32]\) for periodic BCs. Parameter values for Burgers' and KdV are taken from [35]. Reference simulations are carried out on a uniform grid of \(N=1000\) for Burgers' and \(N=600\) for KdV up to time \(t=T=10\). The data that is generated from these reference simulations is split into a training set and a validation set. The simulation conditions (initial conditions, BCs, and forcing) for training and testing purposes are generated randomly, as described in Appendix D. In addition to this, the construction of a training and validation set, the training procedure, and the chosen hyperparameters are also described in Appendix D.

For the analysis, we will compare our structure-preserving framework (SP) to a vanilla CNN that models the closure term as \(\mathbf{c}(\mathbf{u})\approx\bar{\mathbf{Q}}\text{CNN}(\bar{\mathbf{u}},f_{ H}(\bar{\mathbf{u}});\boldsymbol{\theta})\) (with parameters \(\boldsymbol{\theta}\)). Multiplication of the CNN output channel by the coarse-grid forward difference operator \(\bar{\mathbf{Q}}\) takes care of the momentum conservation condition (this has been shown to yield more accurate closure models [26]). The same trick is not applied for our SP closure, as it would destroy the derived evolution of the (approximated) total energy, see (42) and (43). Instead we resort to the described pre- and post-multiplication by the parameterized \(\mathbf{B}\) matrices to satisfy momentum conservation. Furthermore, we consider the no closure (NC) case, i.e. \(\bar{\mathbf{c}}=\mathbf{0}_{\Omega}\), which corresponds to a coarse-grid solution of the PDEs. To make a fair comparison we compare closure models with the same number of degrees of freedom (DOF). For SP we have \(\text{DOF}=2I\), as we obtain an additional set of \(I\) degrees of freedom corresponding to the addition of the SGS variables. For the CNN and NC we simply have \(\text{DOF}=I\).

To march the solution forward in time we employ an explicit RK4 scheme [30] with \(\overline{\Delta t}=0.01\) (\(4\times\) larger than the DNS) for use cases (i) and (ii) and \(\overline{\Delta t}=5\times 10^{-3}\) (\(50\times\) larger than the DNS) for use case (iii). The SP closure models contain in total 7607 parameters (consisting of two hidden layers with each 30 channels and a kernel size of 5 for the underlying CNN) for use cases (i) and (ii) and 3905 (consisting of two hidden layers with each 20 channels and a kernel size of 5) for use case (iii). The purely CNN-based closure models consist of 3261 parameters (two hidden layers with each 20 channels and a kernel size of 7) for every use case. These settings are based on the hyperparameter tuning procedure in Appendix D. In between hidden layers we employ the ReLU activation function, whereas we apply a linear activation function to the final
layer for both SP and the vanilla CNN. For SP we choose \(D=B=1\) for the construction of the \(\mathbf{B}\) and \(\mathbf{\Phi}/\mathbf{\Psi}\) matrices for use cases (i) and (ii) matching the width of the coarse discretization \(f_{H}(\bar{\mathbf{u}})\). For (iii) we do the same and therefore take \(D=B=2\). Note that the same set of compression matrices and closure models are used for (i) and (ii), as they both correspond to the same equation. These closure models are thus trained on a dataset containing both simulation conditions. As stated earlier, the model parameters are optimized by first derivative fitting and then trajectory fitting. This is specified in Appendix D. We implement our closure models in the Julia programming language [36] using the Flux.jl package [37; 38]. The code can be found at [https://github.com/tobyvg/ECNCM_1D](https://github.com/tobyvg/ECNCM_1D).

### Closure model performance

We first examine the performance of the trained closure models based on how well the filtered DNS solution is reproduced for cases (i)-(iii) and unseen simulation conditions. During our comparison we will make extensive use of the normalized root-mean-squared error (NRMSE) metric, defined as

\[\text{NRMSE }\bar{\mathbf{u}}(t)=\sqrt{\frac{1}{|\Omega|}||\bar{\mathbf{u}}(t)- \bar{\mathbf{u}}^{\text{DNS}}(t)||_{\Omega}^{2}}, \tag{72}\]

to compare the approximated solution \(\bar{\mathbf{u}}\) at time \(t\), living on the coarse grid, to the ground truth \(\bar{\mathbf{u}}^{\text{DNS}}\) obtained from the DNS. We will refer to this metric as the solution error. In addition, we define the integrated-NRMSE (I-NRMSE) as

\[\text{I-NRMSE }\bar{\mathbf{u}}(t)=\frac{1}{t}\sum_{i}\overline{\Delta t} \text{ NMRSE }\bar{\mathbf{u}}(i\overline{\Delta t}),\qquad 0\leq i\overline{\Delta t}\leq t, \tag{73}\]

such that the sum represents integrating the solution error in time. We will refer to this metric as the integrated solution error.

#### 4.1.1 Convergence

As we refine the resolution of the coarse grid, and with this increase the number of DOF, we expect convergence of both the compression error \(\mathcal{L}_{s}\) (defined in equation (49)) and the solution error. We consider \(\text{DOF}\in\{20,30,40,50,60,70,80,90,100\}\), each with a different set of trained closure models. If the fine-grid resolution \(N\) is not divisible by the coarse-grid resolution \(I\) we first project the fine-grid solution on a grid with a resolution that is divisible by \(I\) to generate reference data. This is necessary for constructing the spatial averaging filter (see section 2.3). In total 36 closure models are trained: two (SP and CNN) for each combination of the 9 considered coarse-grid resolutions and equation (Burgers' or KdV). Closure models corresponding to Burgers' equation are applied to both use case (i) periodic and (ii) I/O conditions.

The SGS compression error evaluated over the validation set is shown in Figure 7. We observe monotonic convergence of the compression error as we refine the grid. We expect the compression error to further converge to zero until the exact solution is reached at \(\text{DOF}=N\) (\(J=2\)), see Appendix E. The faster convergence for the KdV equation is likely caused by the lower fine-grid resolution of \(N=600\), as opposed to \(N=1000\) for Burgers' equation.

Next, we look at the integrated solution error averaged over 20 simulations with unseen simulation conditions, generated as described in Appendix D, for each of the considered numbers of DOF, see Figure 8. For test cases (i) and (ii) we observe, for both SP and NC, almost monotonic convergence of the solution error as we increase the number of DOF in the simulation, with SP improving upon NC with roughly one order of magnitude. On the other hand, the solution error for the CNN behaves quite erratically: sometimes more accurate than SP, sometimes unstable (e.g. in case (ii) and DOF = 80, all 20 simulations were unstable), and sometimes less accurate than NC (case (i), \(\text{DOF}=90\)).

For test case (iii) we find that for most numbers of DOF the CNN outperforms SP, while not resulting in stable closure models for \(\text{DOF}\in\{90,100\}\). Overall, the conclusion is that our proposed SP closure model leads to much more robust simulations while being on par in terms of accuracy with a CNN closure model. Furthermore, for the lower numbers of DOF we observe similar performance for SP and the CNN. From this we conclude that the compression error (see Figure 7) is likely not the limiting factor of the closure model performance.
#### 4.1.2 Consistency of the training procedure

It is important to note that the closure models trained in the previous section possess a degree of randomness, caused by the (random) initialization of the network weights and the random selection the mini-batches. This can possibly lead to the irregular convergence behavior shown in the previous section. In order to evaluate this effect, we train 10 separate replica models for \(\text{DOF}=60\), which only differ in the random seed.

The trained models are evaluated in terms of stability (number of unstable simulations) and integrated solution error. A simulation is considered unstable when it produces NaN values for \(\bar{\mathbf{u}}(t)\) (\(t\leq T\)). In total 20 simulations per closure model are carried out using the same simulation conditions as in the convergence study. The results are depicted in Figure 9. With regards to stability we observe that all trained SP closure models produced exclusively stable simulations. This is in accordance with the earlier derived stability conditions (42) and (43) for the periodic cases. In addition, for the non-periodic test case (ii) we also observe a clear stability advantage, as all of the trained SP closure models still produced only stable simulations with a consistently low integrated solution error.

Regarding this integrated solution error, we observe that the SP closure models all perform very con

Figure 8: Integrated solution error evaluated at \(T=10\) averaged over 20 simulations for the different use cases (i)-(iii) and an increasing number of \(\text{DOF}\). Only stable simulations are considered for the depicted averages. Absence of a scatter point indicates no stable simulations.

Figure 7: Convergence of the SGS compression error when refining the coarse grid, evaluated on the validation set for Burgers’ equation (\(N=1000\)) and KdV equation (\(N=600\)).
sistently (errors are almost overlapping). The CNNs sometimes outperform SP for test cases (i) and (iii), but also show very large outliers. This confirms our conclusion of the previous section that our SP closure models are much more robust than the CNNs, which can be 'hit or miss' depending on the randomness in the training procedure.

#### 4.1.3 Error behavior in time

To further exemplify how structure preservation aids in robustness and accuracy we consider a single simulation of Burgers' equation with periodic BCs. We choose DOF = 90 (the value for which the CNN closure model performed poorly during the convergence study) and randomly select one of the simulations from the convergence study for the analysis. The resulting solution error trajectory and energy trajectories for this simulation are displayed in Figure 10. We find that the resolved energy for the CNN starts showing erratic behavior around the time the solution error surpasses the one of NC. Around \(t=4\) the resolved energy even increases drastically. The other three methods show no increase in energy. This is in accordance with the derived evolution of the energy: equation (11) for NC and the DNS, and equation (42) for SP. From this we conclude that there is a clear stability and accuracy benefit to adhering to physical structure, as compared to using a standard CNN.

Figure 10: Solution error (left) and resolved energy (right) trajectories for a simulation of Burgers’ equation with periodic BCs starting from an unseen initial condition. The presented results correspond to DOF = 90. For SP and the DNS the (approximated) total energy is displayed, as the SGS energy is small. These trajectories overlap for the entirety of the simulation.

Figure 9: Integrated solution error evaluated at \(T=10\) averaged over 20 simulations and % of unstable simulations for each closure model in the trained ensemble of closure models (DOF = 60). Use cases (i)-(iii) are considered. For (ii) two CNN closure models produced 100% unstable simulations and are therefore omitted from the graph.
### Structure preservation

To analyze how well the SP closure models adhere to physical structure we consider a single simulation of Burgers' and KdV with periodic BCs, i.e. use case (i) and (iii), and unseen simulation conditions. For the purpose of this analysis we stick to closure models corresponding to \(\text{DOF}=40\).

#### 4.2.1 Burgers' equation

For Burgers' equation the results are depicted in Figure 11. With regards to momentum conservation we find that each of the considered closures preserves momentum within machine precision. NC and the DNS achieve this through a structure-preserving discretization, the CNN achieves this through the multiplication by the forward difference operator \(\bar{\mathbf{Q}}\), and the SP model through the construction of \(\mathcal{K}\) and \(\mathcal{Q}\).

With regards to the energy, both the resolved energy \(\bar{E}_{h}\) as well as the (approximated) total energy \(E_{s}/E_{h}\) are considered. The first observation is that the energy of NC is strictly decreasing but remains at a too high level as compared to the DNS, which is consistent with our analysis in Appendix B. For SP the approximated total energy is also always decreasing, as derived in (42), thus successfully mimicking the property that the total energy should be decreasing for viscous flows and periodic BCs, in the absence of forcing. Furthermore, when looking only at the resolved energy we find that SP nicely captures the back and forth energy transfer between the resolved and SGS energy, similar to the DNS result. This means that it successfully allows for backscatter, without sacrificing stability. The CNN is omitted from this analysis, as earlier we observed that it is not strictly dissipative, see Figure 10.

#### 4.2.2 Korteweg-de Vries equation

Next, we study the KdV equation. With regards to momentum we observe that it is again conserved up to machine precision for each of the closures, see Figure 12. However, in contrast to Burgers' equation with viscosity, the total energy should now be exactly conserved. We mimic this by not including the dissipative \(\mathcal{Q}\) term in the SP closure model. We find that the approximated total energy is indeed conserved up to a time integration error, due to the use of an explicit RK4 integration scheme [30] instead of a structure-preserving time integration method such as implicit midpoint. This is done as implicit time integration schemes are incompatible with trajectory fitting. The energy error decreases with \(\mathcal{O}(\Delta t^{4})\) when the time step is decreased and is at machine precision for \(\overline{\Delta t}=10^{-4}\).

Based on the results for Burgers' and KdV equation, we conclude that our proposed SP closure model successfully achieves stability by mimicking the energy conservation law of the full system, while still allowing for backscatter to be modelled correctly.

Figure 11: Change in momentum \(\Delta_{t}P_{h}=P_{h}(t)-P_{h}(0)\) (left) and evolution of resolved and total energy (right) for a simulation of Burgers’ equation with periodic BCs starting from an unseen initial condition. The presented results correspond to \(\text{DOF}=40\).
### Extrapolation in space and time

As a final experiment we evaluate how well the closure models are capable of extrapolating in space and time. We consider the KdV equation on an extended spatial domain \(\Omega=[0,96]\), which is three times the size of the domain in the training data, and run the simulation until \(T=50\) (five times longer than present in the training data). As closure models, we use the ones trained during the convergence study that correspond to the grid-spacing of the employed grid. The resulting DNS (\(N=3\times 600\)), and absolute error (AE) for the NC, CNN, and SP simulations (\(\mathrm{DOF}=3\times 40\)) are shown in Figure 13. We observe that SP and the CNN both improve upon NC in the earlier stages of the simulation (\(t\leq 20\)), but less so for longer time spans. However, since the absolute error is sensitive to small translations in the solution (as observed in the later stages of the simulation), we require a more thorough analysis to further compare the two machine learning-based closure models.

For this purpose we first look at the trajectory of the resolved energy. This is presented in Figure 14. We find that for SP the resolved energy (in black) stays in close proximity to its corresponding filtered DNS simulation (in green). This is in contrast to the CNN (in red) which starts to diverge from the DNS (in brown) around \(t=5\). The resolved energy for the CNN also exceeds the maximum allowed total energy \(E_{h}\) (in orange) at different points in the simulation, which is unphysical. We thus conclude that adding the SGS variables and conserving the total energy helps with capturing the delicate energy balance between resolved and SGS energy that characterizes the DNS. It is also interesting to note that NC conserves the resolved energy, as the coarse discretization conserves the discrete energy. However, this is not desired, as the resolved energy is not a conserved quantity, see Figure 3.

To make a more quantitative analysis of this phenomenon we investigate the trajectory of the solution error and the Gaussian kernel density estimate (KDE) [39] of the resolved energy distribution, for both the CNN and SP. The latter analysis is carried out to analyze whether the closure models capture the correct energy balance between the resolved and SGS energy. The results for \(\mathrm{DOF}\in\{40,60,80\}\) are depicted in Figure 15. Looking at the solution error trajectories we find that at the earlier stages of the simulation the CNN outperforms SP (for \(\mathrm{DOF}=60\) and \(\mathrm{DOF}=80\)). However, SP slowly overtakes the CNN past the training region (\(t\leq 10\)). For \(\mathrm{DOF}=40\), SP outperforms the CNN roughly throughout the entire simulation. With regards to the resolved energy distribution we find that for each of the considered numbers of \(\mathrm{DOF}\) SP is capable reproducing the DNS distribution. On the other had, the CNN closure models struggle to capture this distribution. For \(\mathrm{DOF}=40\) a significant part of the distribution even exceeds the total energy present in the DNS, i.e. there occurs a nonphysical influx of energy.

From this we conclude that both the SP and CNN closure models are capable of extrapolating beyond

Figure 12: Change in momentum \(\Delta_{t}P_{h}=P_{h}(t)-P_{h}(0)\) (left) and change in (approximated) total energy \(\Delta_{t}E_{s/h}=E_{s/h}(t)-E_{s/h}(0)\) (right) for a simulation of KdV equation with periodic BCs starting from an unseen initial condition. The presented results correspond to \(\mathrm{DOF}=40\).
the training data. However, the fact that SP is capable of correctly capturing the energy balance between the resolved and unresolved scales allows it to more accurately capture the statistics of the DNS results. This in turn leads to more robust long-term solution error behavior.

## 5 Conclusion

In this paper we proposed a novel way of constructing machine learning-based closure models in a structure-preserving fashion by taking the 'discretize first and filter next' approach. We started off by applying a spatial averaging filter to a fine-grid discretization and writing the resulting filtered system in closure model form, where the closure term requires modeling. Next, we showed that by applying the filter we effectively remove part of the energy. We then introduced a linear compression of the subgrid-scale (SGS) content into a set of SGS variables living on the coarse grid. These SGS variables serve as a means of reintroducing the removed energy back into the system, allowing us to use the concept of kinetic energy conservation. In turn we introduced an extended system of equations that models the evolution of the filtered solution as well as the evolution of the compressed SGS variables. For this extended system we propose a structure-preserving closure modeling framework that allows for energy exchange between the filtered solution and the SGS variables, in addition to dissipation. This framework serves to constrain the underlying convolutional neural network (CNN) such that no additional energy enters the system for periodic boundary conditions (BCs). In this way we achieve stability by abiding by the underlying energy conservation law, while still allowing for backscatter through the energy present in the SGS variables. The framework is constructed such that momentum conservation is also satisfied.

Figure 13: Absolute errors for the simulations produced by the NC, CNN, and SP closures, as well as the DNS solution, for solving the KdV equation on an extended spatial \(\Omega=[0,96]\) and temporal domain \(t=[0,50]\). The grid resolutions correspond to \(\text{DOF}=3\times 40\) for the closure models and \(N=3\times 600\) for the DNS. The area enclosed within the dashed lines indicates the size of the domain used for training.
A convergence study showed that the learned SGS variables are able to accurately match the original SGS energy content, with accuracy consistently improving when refining the coarse-grid resolution.

Given the SGS compression operator, our proposed structure-preserving framework (SP) was compared to a vanilla CNN (adapted to be momentum-conserving). Overall, the SP method performed on par with the CNN in terms of accuracy, _provided that the CNN produced stable results_. However, the results for the CNN were typically inconsistent, not showing clear convergence of the integrated solution error upon increasing the degrees of freedom, in addition to suffering from stability issues. On the other hand, our SP method produced stable results in all cases, while also consistently improving upon the 'no closure model' results by roughly an order of magnitude in terms of the integrated solution error.

This conclusion was further strengthened by training an ensemble of closure models, where we investigated the consistency of the closure model performance with respect to the randomness inherent in the neural network training procedure. We observed that the trained vanilla CNNs differed significantly in performance and stability, whereas the different SP models performed very similarly to each other and displayed no stability issues. Our SP model is therefore more robust and successfully resolves the stability issues that plague conventional CNNs.

Our numerical experiments confirmed the structure-preserving properties of our method: exact momentum conservation, energy conservation (in the absence of dissipation) up to a time discretization error, and strict energy decrease in the presence of dissipation. We also showed that our method succeeds in accurately modeling backscatter. Furthermore, when extrapolating in space and time, the advantage of including the SGS variables and embedding structure-preserving properties became even more apparent: our method is much better at capturing the delicate energy balance between the resolved and SGS energy. This in turn yielded better long-term error behavior.

Based on these results we conclude that including the SGS variables, as well as adherence to the underlying energy conservation law, has the important advantages of stability and long-term accuracy, in addition to consistent performance. This work therefore serves as an important starting point for building physical constraints into machine learning-based turbulence closure models. In the future we aim to apply our SP framework to the Navier-Stokes equations in 2D and 3D, locally modeling the turbulent kinetic energy by a set of SGS variables. More generally, our framework is potentially applicable to a wide range of systems that possess multiscale behavior while also possessing a secondary conservation law, for example incompressible

Figure 14: Trajectory of the resolved energy \(\bar{E}_{h}\) for the simulation presented in Figure 13 for each of the different models corresponding to DOF = 40. The DNS resolved energy is depicted for both \(I=\) DOF (to compare with the CNN) and \(I=\) DOF/2 (to compare with SP).
pipe flow [40] and the streamfunction-vorticity formulation of Navier-Stokes in 2D [41].

**CRediT authorship contribution**

**T. van Gastelen:** Conceptualization, Methodology, Software, Writing - original draft. **W. Edeling:** Writing - review & editing. **B. Sanderse:** Conceptualization, Methodology, Writing - review & editing, Funding acquisition.

**Data availability**

The code used to generate the training data and the implementation of the neural networks can be found at [https://github.com/tobyvg/ECNCM_1D](https://github.com/tobyvg/ECNCM_1D).

**Acknowledgements**

This publication is part of the project "Unraveling Neural Networks with Structure-Preserving Computing" (with project number OCENW.GROOT.2019.044 of the research programme NWO XL which is financed by the Dutch Research Council (NWO)). In addition, part of this publication is funded by Eindhoven University of Technology.

Figure 15: Solution error trajectory (top) and KDEs estimating the distribution of \(\bar{E}_{h}\) (bottom) for the trained closure models corresponding to different numbers of DOF. These quantities are computed for a simulation of the KdV equation with the same initial condition on the extended spatial and temporal domain. In the top row the vertical black line indicates the maximum time present in the training data, while in the bottom row it indicates the total energy of the DNS (which should not be exceeded). The DNS resolved energy is again depicted for both \(I=\) DOF (to compare with the CNN) and \(I=\) DOF/2 (to compare with SP).