1 Introduction

Rapid transient simulations of gas flow in pipeline networks are essential for safe operations of gas networks as well as reliable delivery of denominations. Yet, in a volatile supply and demand environment, due to increasing renewable energy sources, the time horizon for planning dispatch and load forecasting shortens while more sources of accountable uncertainties, such as effects of weather on energy consumption and production are introduced; to a lesser degree this is a long standing challenge [6]. An example is the interconnection of gas and power grids through gas-fired power plants [27, 91, 144]. Thus, more simulations for the uncertainty quantification of dynamic gas network behavior need to be completed in less time by the gas grid operators. However, available compute power is (and was [138]) never sufficient. To this end we evaluate customized model reduction techniques for an established class of gas network models.

This work and the associated software platform are an effort to determine which model reduction methods are suitable for enabling digital twins [58, 87, 121] of gas networks. Depending on the mathematical model and quantities of interest, the twin may contain redundant or superfluous information with respect to the simulations. Therefore, model reduction compresses the twin to a matched surrogate model, which is sufficiently accurate in the chosen operating region.

The swift numerical simulation of gas network twins by reduced order modeling is highly relevant, not only due to the transition towards renewables at the time of writing, which is underlined by the research projects MathEnergyFootnote 1 (Mathematical Key Technologies for Evolving Energy Grids) [29] that the authors are part of, and TRR154Footnote 2 (Mathematical Modelling, Simulation and Optimization using the Example of Gas Networks) [85], but also because of the intriguing numerical problem of model reduction for hyperbolic, nonlinear, coupled, parametric, multiscale partial differential-algebraic equation systems.

If relevant intraday demand changes occur, established steady / stationary / static simulations may not be sufficient anymore [42]. The basic model for the simulation of unsteady / dynamic / transient flow processes in gas pipelines is based on the one-dimensional (isothermal) Euler equations, originally introduced in [55], and popularized in [104] as well as in [80, 81] around the same time. A practical extension in the context of gas networks is the repetitive modeling approach [37], which enables a modular construction. For extensive details on gas network modeling, see the works [19, 33, 45, 94, 105, 123, 128, 131], and for a concise summary of the overall approach we recommend [7]. Furthermore, a system-theoretic approach to gas networks is discussed in [35, 54], and results on boundary reachability (controllability) and observability for this class of models have been derived in [8, 9].

In terms of complexity reduction for gas network models, earlier works applied techniques such as combining parallel pipelines [129], singular perturbation [127] and symbolic simplifications [95]. Younger works introduced projection-based model reduction methods from fluid dynamics, proper orthogonal decomposition (POD) [50, 51, 53], and system-theoretic methods [88] (matrix interpolation), [1, 89] (balanced truncation), or Padé-type approximations [39, 86] (moment matching).

In this work, we conceptually combine these previous approaches, by using system-theoretic but data-driven methods that are structure-preserving. The utilized data-driven assembly of the system-theoretic operators, central to the employed methods, is also a partial answer to the challenges posed in [57, Remark 5.10]; while structure preservation means in this context, retaining (particularly not mixing) the discretized physical variables in the reduced order model. Furthermore, we note that from this work’s point of view, [130, 144, 145] are concerned rather with (valuable) model simplifications than model reduction.

To avoid the analytically most complex aspects of the gas network model – the nonlinearities – one could linearize the model around an operating point. Yet, the different nonlinearities (i.e. friction, compressibility and compressors) are unlikely to have a compatible operating point for a wide range of scenarios. Furthermore, linearized and simplified models of gas flow have limitations with simulations of real scenarios [61], [134, Ch. 7]; hence, we use a nonlinear model. Since there is no general theory for model reduction of nonlinear systems, and a high degree of modularity in the gas network modeling process, model reduction algorithms have to be compared heuristically to determine their applicability. As a result of this reasoning and a demand for gas network simulation software tools [32, 69], a platform named morgen (model order reduction for gas and energy networks) was designed with the goal to compare different models, solvers and reductors. The morgenFootnote 3 platform is an open-source project, and designed in a configurable, modular, and extensible manner, so that modeling, discretization or model reduction specialists can compose and compare their methods fairly.

In summary, this work contributes a full, but also fully modular, modeling, model reduction and simulation open-source software stack for gas networks, and potentially other energy network systems (i.e. district heating networks, water networks), which brings together research results from various disciplines.

Overall, this work is organized as follows: In Sect. 2 the gas network model, simplifications, non-pipe elements, a relation to port-Hamiltonian theory, and obtaining a steady-state initial condition are described. Section 3 and Sect. 4 outline the general model reduction idea and propose five reduction method classes. The design and features of the morgen platform are summarized in Sect. 5, followed by three sets of numerical experiments in Sect. 6. We conclude by an outlook (Sect. 7) and an evaluation of our findings in Sect. 8. A list of recurring symbols is found in Table 1.

Table 1 List of recurring symbols

2 The transient gas network model

The goal of this section is to describe the partial differential-algebraic equation model of a gas network as an input-output system that maps boundary values to quantities of interest. First, the model for a single pipeline is summarized, which is based on the isothermal Euler equations of gas dynamics [104, 106]. Then, it is generalized to a network of pipes, and simplified compressors are added. Additionally, a connection to energy-based modeling is made.

Even though further non-pipe elements are common in gas networks, such as resistors, coolers, heaters, valves and control valves [45, 96], we prioritized compressors to focus on the model reduction aspect on a macro scale. Moreover, the practical numerical problems of scale homogenization, spatial discretization, index reduction and steady-state approximation are discussed in this section.

2.1 The gas pipeline model

The principal building blocks of gas transport networks are pipelines or ducts. Since the length of pipes exceeds their diameter by far (\(L>500d\), [81]), a spatial one-dimensional model suffices. We model gas flow in a (cylindrical) pipe of length L connecting two junctions by the isothermal Euler equations:

$$\begin{aligned} \begin{aligned} &\frac{1}{\gamma _{0} z_{0}} \partial _{t} p = -\frac{1}{S} \partial _{x} q, \\ &\partial _{t} q = -S \partial _{x} p - \biggl( \frac{S g \partial _{x} h}{\gamma _{0} z_{0}} p + \frac{\gamma _{0} z_{0} \lambda _{0}}{2 d S} \frac{ \vert q \vert q}{p} \biggr), \end{aligned} \end{aligned}$$
(1)

which determine the evolution of the coupled pressure \(p(x,t)\) and mass-flux \(q(x,t)\) variables. The physical dimension of the pipe enters as its diameter d and the derived cross-section area \(S = \frac{\pi }{4}d^{2}\), which is assumed constant, ignoring the influence of temperature and pressure on the pipe walls. These coupled partial differential equations (PDE) can also be characterized as a nonlinear, two-dimensional, first-order hyperbolic system of conservation laws: the pressure p preserves continuity, while the mass-flux q conserves momentum.

Following [64, 79, 108] and [19, Sect. 2.1], the inertia term has been neglected due to a low Mach number \(m \ll 1\), which leads to the ISO2 model in the TRR154 classification [33], also known as friction-dominated model [24, Sect. 3.2.1]. Furthermore, we assume a turbulent flow with a Reynolds number exceeding \(\operatorname{Re} \gg 10^{5}\) [40, 55], neither line breaks or valve closings happen intraday (to preclude associated shocks [34]), and low-frequency boundary values [10, 108], which in this work are (but generally not limited to) the supply pressure and demand mass-flux, due to frequent use in literature, and use-cases like guaranteed demand pressures [22, 63].

In (1), the linear reaction term describes the effect of gravity (with standard gravity \(g \equiv 9.80665 \frac{\text{m}}{\text{s}^{2}}\)) due to the pipe height \(h(x)\), while the nonlinear reaction term models loss of momentum due to friction at the pipe walls, specified by the (Darcy-Weisbach) friction factor \(\lambda _{0} := \lambda (d, k, \operatorname{Re}_{0})\), given a pipe roughness k, and an estimated mean Reynolds number Re0, see [19, Sect. 2.2].Footnote 4 This friction term is principal to the accuracy of the gas pipeline model [33, 61, 93, 107].

In this model variant, a (globally) constant mean compressibility factor \({z_{0} := z(p_{0},T_{0}) \in \mathbb{R}}\) is assumed [35, 62, 106, 111], as well as a constant gas state \(\gamma _{0}:= R_{S} T_{0}\), whereas the temperature \(T_{0}\) and the specific gas constant \(R_{S}\) are treated as parameters (see Sect. 2.6). To this end, the steady-state pressure \(\bar{p} =: p_{0}\) is used to compute \(z_{0}\), via heuristic formulas based on the Virial expansion [25], [19, Sect. 2.3].Footnote 5

2.2 Homogenizing scales

The SI-based units for pressure and mass-flux are [Pa] and [kg/s], respectively. This introduces a difference in scales of five orders of magnitude between the variables p and q, and hence induces numerical problems. To counter this multiscale structure, we simply rescale the pressure from [Pa] to [bar] which conveniently comprises a factor of 105. Nonetheless, the model still consists of two interacting physical variables, hence the model still has to be treated as a coupled system, however, without numerical multiscale issues.

2.3 The gas network model

Given the model for a single pipe from the previous section, a (gas) network of pipes can be encoded by a finite directed graph, which is a tuple \(\mathcal{G} = (\mathcal{N},\mathcal{E})\) of finite sets symbolizing nodes \(\mathcal{N}\), and oriented edges \(\mathcal{E}\). The edges correspond to pipes, while the nodes represent the junctions connecting pipes. The connectivity of the network is the relationship between edges and junctions, given by the incidence matrix \(\mathcal{A} \in \{-1,0,1\}^{|\mathcal{N}| \times |\mathcal{E}|}\), a map from edges to nodes, such that:

$$\begin{aligned} \mathcal{A}_{ij} = \textstyle\begin{cases} -1 & \mathcal{E}_{j} \text{ connects }\textit{from } \mathcal{N}_{i}, \\ \hphantom{-}0 & \mathcal{E}_{j} \text{ connects }\textit{not } \mathcal{N}_{i}, \\ \hphantom{-}1 & \mathcal{E}_{j} \text{ connects }\textit{to } \mathcal{N}_{i}. \end{cases}\displaystyle \end{aligned}$$

Note, that the orientation of the edges is not enforcing the dynamic flow direction of the gas, but is necessary to determine the complexity and boundary of the overall networked model [19, 53].

We introduce the notation \(|\mathcal{A}|\) for the component-wise absolute value of a matrix. Using this absolute value, the following partial incidence matrices associating edges entering and leaving nodes respectively are defined similar to a Heaviside function:

$$\begin{aligned} \mathcal{A}_{R} := { \tfrac{1}{2}} \bigl(\mathcal{A} + \vert \mathcal{A} \vert \bigr), \qquad \mathcal{A}_{L} := { \tfrac{1}{2}} \bigl( \mathcal{A} - \vert \mathcal{A} \vert \bigr). \end{aligned}$$

Next, based on this connectivity, certain conservation properties are enforced to maintain a network balance, and thus ensure physical relevance of the gas network model. Specifically, the Kirchhoff laws are applied to the network in vectorized (or rather matricized) form [18, 132]:

  1. 1.

    The sum of in- and outflows (mass-flux) at every node (junction) is zero: This means that no gas gets lost in transport from one pipe to the next, with the exception of boundary nodes. Hence, a vector of flows \(q \in \mathbb{R}^{|\mathcal{E}|}\) applied to the incidence matrix equals the (out-)flow at the boundary (discharge) nodes \(d_{q} : \mathbb{R}\to \mathbb{R}^{|\mathcal{N}_{D}|}\), which are mapped into the network via \(\mathcal{B}_{d} \in \{0,1\}^{|\mathcal{N}| \times |\mathcal{N}_{D}|}\):

    $$\begin{aligned} \mathcal{A} q(t) = \mathcal{B}_{d} d_{q}(t), \end{aligned}$$

    with \(\mathcal{N}_{D} \subset \mathcal{N}\) denoting the subset of boundary nodes, which only connect from one node respectively, but not to any node.

  2. 2.

    The sum of directed pressure drops in every fundamental loop is zero: Fortunately, an equivalent representation [143, Ch. 7.3] can be used, which resolves implicitly. It remains to ensure that the nodal pressures at the in-flow boundary (supply) nodes are associated to the boundary function \(s_{p} : \mathbb{R}\to \mathbb{R}^{|\mathcal{N}_{S}|}\), which are mapped to the network via \(\mathcal{B}_{s} \in \{0,1\}^{|\mathcal{N}_{S}| \times |\mathcal{E}|}\):

    $$\begin{aligned} \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} p(t) + \mathcal{B}_{s}^{\mathsf{\scriptscriptstyle T}} s_{p}(t) = A_{0,R}^{\mathsf{\scriptscriptstyle T}} p(t) - A_{0,L}^{\mathsf{\scriptscriptstyle T}} p(t), \end{aligned}$$

    with \(\mathcal{N}_{S} \subset \mathcal{N}\) denoting the subset of boundary nodes, which only connect to one node respectively, but not from any node, and the reduced incidence matrix \(\mathcal{A}_{0} \in \{-1,0,1\}^{|\mathcal{N}_{0}| \times | \mathcal{E}|}\), \(|\mathcal{N}_{0}| = |\mathcal{N}| - |\mathcal{N}_{S}|\), with all rows associated to supply nodes removed.

Given a connected and directed graph representing a gas network topology, with the dynamic flow in the pipe edges modeled by the PDE (1), then yields a partial differential-algebraic equation (PDAE) due to the above constraints.

2.4 Discretization and index reduction

Next, we delineate the discretization of the spatial differential operators and reduction of the (P)DAE index in the networked system, yielding a system of ordinary differential equations (ODE). Eventually, the remaining discretization of the temporal differential operators is addressed.

We explicitly do not use the decoupling approaches from [12] or [11], as the former employs linearization and hence does not fit this setting, while compared to the latter, our equivalent analytic index reduction is more convenient here.

The partial differential(-algebraic) equation is discretized using the method of lines: First in space, then in time, yielding a (nonlinear) dynamic system. For the spatial discretization a first-order upwind finite difference scheme is utilized [10, 133]. We select (only) two points for each of the k pipes with length \(L_{k}\), namely the start (\(\cdot ^{R}\)) and end point (\(\cdot ^{L}\)):

$$\begin{aligned} &\partial _{x} p_{k} \approx \frac{p_{k}^{R} - p_{k}^{L}}{L_{k}}, \quad k \in \mathcal{E}, \\ &\partial _{x} q_{k} \approx \frac{q_{k}^{R} - q_{k}^{L}}{L_{k}}, \quad k \in \mathcal{E}. \end{aligned}$$

The matter of short, long and varying lengths \(L_{k}\) is addressed in Sect. 2.4.3.

For each pipe, this leads to the following equations:

$$\begin{aligned} &\frac{1}{\gamma _{0} z_{0}} \partial _{t} p_{k}^{*} =- \frac{1}{S_{k}} \frac{q_{k}^{R} - q_{k}^{L}}{L_{k}}, \\ &\partial _{t} q_{k}^{*} = -S_{k} \frac{p_{k}^{R} - p_{k}^{L}}{L_{k}} - \biggl( \frac{S_{k} g (h_{k}^{R} - h_{k}^{L})}{\gamma _{0} z_{0} L_{k}} p_{k}^{*} + \frac{\gamma _{0} z_{0} \lambda _{0,k}}{2 d_{k} S_{k}} \frac{ \vert q_{k}^{*} \vert q_{k}^{*}}{p_{k}^{*}} \biggr). \end{aligned}$$

Now, different choices for \(( \cdot ^{*})\) are surmisable. Subsequently, two specific combinations of \(p^{*}\) and \(q^{*}\) will be discussed: The midpoint discretization [18, 50, 51, 53, 145], and the left-right discretization [48, 52, 115] resulting in (implicit) ODEs. For an error analysis of these two discretization variants, see [128]. In the following, we describe a unified approach of deriving these index-reducible discretizations.

For notational ease in the coming subsections, a vectorized form for the above (networked) system including its constraints is given by:

$$\begin{aligned} \begin{aligned} &d_{0} \partial _{t} p^{*} = D_{p} \bigl(q^{R} - q^{L} \bigr), \\ &\partial _{t} q^{*} = D_{q} \bigl( \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}}p + \mathcal{B}_{s}^{\mathsf{\scriptscriptstyle T}}s_{p} \bigr) - \biggl(D_{q} D_{g} d_{0} p^{*} + D_{f} \frac{ \vert q^{*} \vert q^{*}}{d_{0} p^{*}} \biggr), \\ &\mathcal{A}_{0} q^{*} = \mathcal{B}_{d} d_{q}, \end{aligned} \end{aligned}$$
(2)

using, thus resolving, the constraint \(\mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}}p + \mathcal{B}_{s}^{\mathsf{\scriptscriptstyle T}} s_{p} ={} p^{R} - p^{L}\), as well as \(d_{0} := \frac{1}{\gamma _{0} z_{0}} \in \mathbb{R}\) and the diagonal matrices:

$$\begin{aligned} D_{p,kk} := -\frac{1}{S_{k} L_{k}}, \qquad D_{q,kk} := - \frac{S_{k}}{L_{k}}, \qquad D_{g,kk} := g \bigl(h_{k}^{R} - h_{k}^{L}\bigr), \qquad D_{f,kk} := \frac{\lambda _{0,k}}{2 d_{k} S_{k}}. \end{aligned}$$

Note, that \((d_{0} \cdot p^{*})\) corresponds to the global average density, \((S_{k}^{-1} \cdot q_{k}^{*})\) to the local flow rate, and depending on the choices for \(p^{*}\) and \(q^{*}\), the model’s analytic and numerical character will differ.

2.4.1 Midpoint discretization

In case of the midpoint discretization, we set \(p_{k}^{*}\) and \(q_{k}^{*}\) to the mean of its associated edge’s endpoints:

$$\begin{aligned} &p_{k}^{*} = \frac{p_{k}^{R} + p_{k}^{L}}{2} =: p_{k}^{+}, \\ &q_{k}^{*} = \frac{q_{k}^{R} + q_{k}^{L}}{2} =: q_{k}^{+}. \end{aligned}$$

Furthermore, we define \(q^{-} := \frac{1}{2}(q^{R} - q^{L})\), and note, that in vectorized form, \({p^{+} = \frac{1}{2}(|\mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}}| p+| \mathcal{B}_{s}^{\mathsf{\scriptscriptstyle T}}| s_{p})}\).

Together with the algebraic constraints from Sect. 2.3, a DAE system in the variables p, \(q^{+}\), and \(q^{-}\) arises:

$$\begin{aligned} &d_{0} { \tfrac{1}{2}}\bigl( \bigl\vert \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} \bigr\vert \dot{p} + \bigl\vert \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} \bigr\vert \dot{s}_{p}\bigr) = D_{p} 2 q^{-}, \end{aligned}$$
(3a)
$$\begin{aligned} &\dot{q}^{+} = D_{q} \bigl( \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}}p + \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} s_{p}\bigr) - \biggl( D_{q} D_{g} d_{0} { \tfrac{1}{2}}\bigl( \bigl\vert \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} \bigr\vert p + \bigl\vert \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} \bigr\vert s_{p}\bigr) + D_{f} \frac{ \vert q^{+} \vert q^{+}}{d_{0} \frac{1}{2}( \vert \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} \vert p + \vert \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} \vert s_{ p})} \biggr), \end{aligned}$$
(3b)
$$\begin{aligned} &0 = \mathcal{A}_{0} q^{+} + \vert \mathcal{A}_{0} \vert q^{-} - \mathcal{B}_{d} d_{q}. \end{aligned}$$
(3c)

Since we aim to obtain an ODE, we need to transform this DAE system. The complexity of deriving this transformation is quantified by the DAE’s index. From the various DAE index concepts, we use the tractability index τ [92], for which the midpoint discretization guarantees \(\tau \leq 2\) [53].

This DAE can be decoupled into an ODE by rewriting it in the variables p and \(q^{+}\). To this end,

  1. 1.

    the pressure boundary condition implicitly resolves (2).

  2. 2.

    By multiplying the differential equation (3a) by \((|\mathcal{A}_{0}| D_{p}^{-1})\) from the left, the remaining algebraic constraint (3c) is removed by replacing \(\mathcal{A}_{0} q^{-}\) by \((-\mathcal{A}_{0} q^{+} + \mathcal{B}_{d} d_{q})\) in (3a). Since \(D_{p}\) is a diagonal matrix, this is also numerically feasible.

We also pre-multiply (3b) with the inverse of the diagonal matrix \(D_{q}\). Altogether, we obtain:

$$\begin{aligned} & \vert \mathcal{A}_{0} \vert \bigl({ \tfrac{1}{4}} D_{p}^{-1} d_{0}\bigr) \bigl\vert \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} \bigr\vert \dot{p} = - \mathcal{A}_{0} q^{+} + \mathcal{B}_{d} d_{q} - \vert \mathcal{A}_{0} \vert \bigl({ \tfrac{1}{2}} D_{p}^{-1} d_{0}\bigr) \bigl\vert \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} \bigr\vert \dot{s}_{p}, \end{aligned}$$
(4a)
$$\begin{aligned} & D_{q}^{-1} \dot{q}^{+} = \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} p + \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} s_{p} - \biggl( D_{g} d_{0} { \tfrac{1}{2}} \bigl( \bigl\vert \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} \bigr\vert p + \bigl\vert \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} \bigr\vert s_{p}\bigr) + D_{q}^{-1} D_{f} \frac{ \vert q^{+} \vert q^{+}}{d_{0} { \frac{1}{2}}( \vert \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} \vert p + \vert \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} \vert s_{p})} \biggr). \end{aligned}$$
(4b)

This system of a pressure and mass-flux variable now consists of only differential equations. Notably, the first equation of the ODE system contains a temporal derivative of the input function \(s_{p}\), which practically would need to be approximated numerically, for example by finite differences. However, we will assume that all inputs are sums of step functions, so that effectively \(\dot{s}_{p} \equiv 0\), which is reasonable as we assume exclusively low-frequency boundary values.

2.4.2 Endpoint discretization

For the endpoint discretization, also called left-right discretization, we set \(p_{k}^{*}\) and \(q_{k}^{*}\) to the left and right endpoints, respectively:

$$\begin{aligned} &p_{k}^{*} = p_{k}^{R}, \\ &q_{k}^{*} = q_{k}^{L}. \end{aligned}$$

Since \((\mathcal{B}_{s}^{\mathsf{\scriptscriptstyle T}}+ |\mathcal{B}_{s}^{\mathsf{\scriptscriptstyle T}}|) s_{p} = 0\), we can write \(p^{R} = \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}} p\). With the algebraic constraints from Sect. 2.3, a DAE system in the variables p, \(q^{R}\), and \(q^{L}\) results:

$$\begin{aligned} &d_{0} \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}} \dot{p} = D_{p} \bigl(q^{R} - q^{L}\bigr), \end{aligned}$$
(5a)
$$\begin{aligned} &\begin{aligned} \dot{q}^{L} &= D_{q} \bigl( \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}}p + \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} p_{s}\bigr) - \biggl( D_{q} D_{g} d_{0} \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}} p + D_{f} \frac{ \vert q^{L} \vert q^{L}}{d_{0} \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}} p} \biggr), \end{aligned} \end{aligned}$$
(5b)
$$\begin{aligned} &0 = \mathcal{A}_{0,R} q^{R} + \mathcal{A}_{0,L} q^{L} - \mathcal{B}_{d} d_{q}. \end{aligned}$$
(5c)

As for the midpoint discretization, we want to derive a system of ODEs. For the endpoint discretization, it is shown in [52, 115], that the tractability index is \(\tau = 1\), if all edges connecting supply nodes are directed from the supply, and each component of the graph is connected to at least one supply. This implies, no two supplies are to be directly connected. Similar to Sect. 2.4.1, this DAE can be decoupled into an ODE by rewriting it in the variables p and \(q^{L}\). Applying equivalent steps to (5a)–(5c) as for the midpoint decoupling (3a)–(3c) yields:

$$\begin{aligned} &\bigl(\mathcal{A}_{0,R} D_{p}^{-1} d_{0} \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}}\bigr) \dot{p} = - \mathcal{A}_{0} q^{L} + \mathcal{B}_{d} d_{q}, \end{aligned}$$
(6a)
$$\begin{aligned} &\begin{aligned} D_{q}^{-1} \dot{q}^{L} &= \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}} p + \mathcal{B}^{\mathsf{\scriptscriptstyle T}}_{s} s_{p} - \biggl( D_{g} d_{0} \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}} p + D_{q}^{-1} D_{f} \frac{ \vert q^{L} \vert q^{L}}{d_{0} \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}} p} \biggr), \end{aligned} \end{aligned}$$
(6b)

using \(\mathcal{A}_{0,R} + \mathcal{A}_{0,L} = \mathcal{A}_{0}\) in (6a).

An advantage of this endpoint discretization, in addition to the absence of a derivative of an input function, is the input-free friction term in (6b).

2.4.3 Temporal discretization

After spatial discretization and index reduction of the gas network model, a system of stiff nonlinear ODEs (in time) remains. The remaining temporal differential operator(s) are discretized using time-stepping schemes.

Due to the hyperbolicity of the pipeline model, the temporal resolution Δt used for the discrete integration interdepends on the spatial resolution Δx employed for the discretization of the spatial differential operators. Formally, this is expressed by the Courant-Friedrichs-Levy (CFL) condition [13, 59, 140], which states that the propagation of information cannot be faster than its conveyor:

$$\begin{aligned} \lambda _{\text{CFL}} := v_{\text{max}} \frac{\Delta t}{\Delta x} < 1, \end{aligned}$$

with the (dimensionless) CFL constant \(\lambda _{\text{CFL}}\), symbolizing the ratio of temporal and spatial discretization step-width scaled by the peak gas velocity \(v_{\text{max}}\). Since the flow is subsonic, \(v_{\text{max}}\) could be estimated from the (linearized) characteristics [59], or via the boundary values.Footnote 6 However, we fix this maximum gas speed to \(v_{\text{max}} = 20\frac{\operatorname{m}}{\operatorname{s}}\) (practically this is configurable in morgen).

Due to this relation of the space and time discretization and a pre-selected application-specific sampling frequency Δt of the output trajectory (i.e., every 60 s), Δx has to be adapted accordingly. The spatial discretization by finite differences in the previous sections ignores pipeline length, as each pipe is assigned only one (finite) difference. This means, pipes are potentially too long or too short with respect to a nominal length Δx, determined by the CFL condition \(\Delta x = (1-\varepsilon ) v_{\text{max}} \Delta t\), (\(0 < \varepsilon \ll 1\)). Thus, too long pipes are subdivided into virtual pipes of nominal length, while too short pipes, including a potential remainder of too long pipes, are “rounded” to a full nominal-length pipe, yet with a friction term scaled by the fraction of the short pipe’s length compared to the nominal length,

$$\begin{aligned} \widetilde{D}_{f,kk} = \textstyle\begin{cases} D_{f,kk} & L_{k} = \Delta x, \\ \frac{L_{k}}{\Delta x} D_{f,kk} & L_{k} < \Delta x. \end{cases}\displaystyle \end{aligned}$$

This approach assumes that delays due to the forced virtual length of an actually short pipe are insignificant, hence this simple homogenization of pipe lengths may be improved by replacing short pipes with friction-less shortcuts and a static pressure-drop, as used in the quasi-static model [50, 64] and similar to the subsequent compressor model in Sect. 2.5.

Overall, we refine each pipe into a sequence of pipes of a selected nominal length – a graph level refinement – which is determined using the CFL condition. We note here, that this methodology is aimed at ensuring a certain minimum length for each pipe, as the shortest pipe may dictate an unnecessarily finely resolved time discretization. In terms of a pipe’s maximum length, suggestions are for example: 5 km ([50]), or 10 km ([144]).

As the model is composed of a stiff, linear (hyperbolic) and a nonlinear component, an implicit solution of the linear part using a diagonally implicit Runge-Kutta (DIRK) method, and an explicit solution of the nonlinear part via a strong stability preserving (SSP) method, by an IMEX (IMplicit-EXplicit) solver, as proposed in [13, Sect. 3.2.2], is targeted. The actual quadrature rules used to compute the transient solutions are detailed in Sect. 5.3.

2.5 Simplified compressors

Beyond pipes, gas networks comprise a variety of non-pipe elements, of which the most important are compressors. Compressors increase gas pressure to counteract cumulative effects of retarding forces (friction, gravity, inertia etc.), and are grouped into stations with many possible configurations. For our purposes, we just allow fixed configurations on a macro scale [90] per scenario, which leads to a compressor being modeled as a special kind of edge that boosts the pressure from its suction inlet to its discharge outlet.

Compressors are typically modeled “ideally”, based on their power consumption, for example as a special node type; in-depth discussions can be found in [63, 123]. Due to this consumption model, such ideal compressor units are useful for energy utilization optimization tasks [40], yet, for a simplified transient simulation aspect already too complicated. A more practical approach is taken in [91, 144, 145], where a compression ratio \(\alpha _{i} \geq 1\) is used to scale the pressure in each node, or pipe [130], which means \(\alpha _{i} > 1\) indicates compression / a compressor, otherwise (\(\alpha _{i} = 1\)) a pipe.

Here, we utilize a likewise simple compressor model similar to [46, 139], for which we assume it is propelled by an external energy source, for example, given a compressor electrification, by excess renewable power [41], or that the off-take in gas is insignificant. But instead of using compression ratios, a constant (or parametric) target pressure is prescribed, modeling discharge pressure control [129].

The following affine compressor model is a variant of the compressor presented in [126] and used in [7]. We model a simplified compressor by a level, short pipe which increases the pressure at its outflow to a specified value \(\bar{p}_{c}\) (and without friction, \(\lambda _{ij} \equiv 0\)). Given the pipe from nodes i to j is treated as such a “compressor pipe”, with target pressure of \(\bar{p}_{c}\), the variables \(p_{ij}\) and \(q_{ij}\) are given by the differential equations:

$$\begin{aligned} \begin{aligned} &\dot{p}_{ij}(t) = q_{j} - q_{i}, \\ &\dot{q}_{ij}(t) = \bar{p}_{c} - p_{i}. \end{aligned} \end{aligned}$$
(7)

The target pressure \(\bar{p}_{c}\) could be a step function \(\bar{p}_{c}(t)\), and hence a control input [130], which could be accompanied by a discharge mass-flux output.

A compressor could also be interpreted as an actual pipe with “negative friction”, and we considered using such nonphysical pipes as compressor model, but a difficult transformation between friction and pressure increase would have to be calibrated for every model variant (including friction factor formulas) and updated with every change in any model.

2.6 Parametrization

For the considered pipeline model (1), two scalar parameters are of practical interest: The temperature of the gas \(T_{0}\) (in [K]), which is assumed to be constant throughout the network, and the global specific gas constant \(R_{S}\) (in [J/(kg K)]).

Due to mainly underground on-shore pipelines [94, Ch. 45], and coolers in compressor stations [90], using an isothermal model is a reasonable simplification. However, temperature is relevant as a global parameter, since the use of an isothermal model “freezes” the dynamic energy (temperature) component in the original Euler equations (in time), and while intraday ambient temperature variation can be neglected for simulations with a 24-hour time horizon, the temperature difference of a hot summer day and a cold winter day should be taken into account by a parameter representing an average temperature.

The specific gas constant, on the other hand, is determined by the gas composition, which may also vary. Again, local variations during an intraday simulation are neglected in this work, yet the average gas mixture of natural gas with, for example, hydrogen or bio-gas is relevant, so a parameter for the average specific gas constant is introduced. Together, the parameter-space Θ is given by:

$$\begin{aligned} \theta := \begin{pmatrix} T_{0} \\ R_{S} \end{pmatrix} \in \Theta \subset \mathbb{R}^{2}, \end{aligned}$$

and note that θ is used in the model (only) as \(d_{0} = \frac{1}{\gamma _{0} z_{0}} = \frac{1}{(T_{0} R_{S}) z_{0}} = \frac{1}{\theta _{0} \theta _{1} z_{0}}\). Yet, lumping into a single parameter would impede physical interpretation.

Applied to the respective components of the input-output model in Sect. 2.7, this leads to parameter-dependent quantities, which need to be regarded accordingly by the model reduction as discussed in Sect. 3.4.

2.7 Input-output model

After spatial discretization and index reduction, we end up with a square input-output system, a system with the same number of inputs and outputs, consisting of an ordinary differential equation, an output function and an initial value:

$$\begin{aligned} &\overbrace{ \begin{pmatrix} E_{p}(\theta ) & 0 \\ 0 & E_{q} \end{pmatrix}}^{E} \begin{pmatrix} \dot{p} \\ \dot{q} \end{pmatrix} = \overbrace{ \begin{pmatrix} 0 & A_{pq} \\ A_{qp} & 0 \end{pmatrix}}^{A} \begin{pmatrix} p \\ q \end{pmatrix} + \overbrace{ \begin{pmatrix} 0 & B_{pd} \\ B_{qs} & 0 \end{pmatrix}}^{B} \begin{pmatrix} s_{p} \\ d_{q} \end{pmatrix} + \overbrace{ \begin{pmatrix} 0 \\ F_{c} \end{pmatrix} + \begin{pmatrix} 0 \\ f_{q}(p,q,s_{p},\theta ) \end{pmatrix}}^{f}, \\ & \begin{pmatrix} s_{q} \\ d_{p} \end{pmatrix} = \underbrace{ \begin{pmatrix} 0 & C_{sq} \\ C_{dp} & 0 \end{pmatrix}}_{C} \begin{pmatrix} p \\ q \end{pmatrix}, \\ & \begin{pmatrix} p_{0} \\ q_{0} \end{pmatrix} = \begin{pmatrix} \bar{p}(\bar{s}_{p},\bar{d}_{q}) \\ \bar{q}(\bar{s}_{p},\bar{d}_{q}) \end{pmatrix}, \end{aligned}$$
(8)

with parameter independent linear vector field components A and B, parametric mass matrix \(E(\theta )\), and nonlinear friction and gravity retarding term \(f(p,q,s_{p},\theta )\). The actual composition of the dynamical system components depends on the discretization and index reduction, cf. Sect. 2.4, while the linear output function C consists of \(C_{sq} = -\mathcal{B}_{s}\) and \(C_{dp} = \mathcal{B}_{d}^{\mathsf{\scriptscriptstyle T}}\). The load vector \(F_{c} \in \mathbb{R}^{N_{q}}\) accumulates the respective discharge pressures \(\bar{p}_{c}\), as described in Sect. 2.5, for all compressors, and the initial state is given by a steady-state, whose computation is detailed in Sect. 2.8, depending on given steady-state boundary values \(\bar{s}_{p}\), \(\bar{d}_{q}\). Altogether, the gas network model is a generalized linear system \((E,A,B,C)\), together with a nonlinear part f.

A control system formulation of transient gas network simulation was already formulated in [81], and recently in [140]. Also in [35], a so-called “systemic interpretation” is discussed; inspired by [35, Fig. 2], we schematically illustrate (8) in Fig. 1.

Figure 1
figure 1

Schematic illustration of gas network input-output model

The specific structure and grouping for the single pipeline model (1), the index-reduced spatially discrete network models (4a)–(4b), (6a)–(6b), and the input-output model (8), is justified by the numerical processing: only two model components depend on the parameters, temperature \(T_{0}\) and specific gas constant \(R_{S}\), as well as on the compressibility factor \(z_{0}\), namely the mass matrix \(E_{p}\) and the jointly treated retarding forces gravity and friction \(f_{q}\). Hence, the linear part of the right-hand side vector field is non-parametric and compressibility-agnostic.

Overall, this system maps input boundary values, in the scope of this work, pressure at the inlets and mass-flux at the outlets, via the internal state, to output quantities of interest, here, mass-flux at the inlets and pressure at the outlets:

figure a

To this type of input-output system we can now apply (data-driven) system-theoretic model reduction methods, which preserve the input-to-output mapping S, but explicitly not the internal state \(( p \ q) ^{\mathsf{\scriptscriptstyle T}}\). Lastly, we note that based on [74], we added a model fact sheet in the Appendix.

2.8 Steady-state computation

After spatial discretization, the dynamic simulation becomes an initial value problem. Yet, only the boundary values of the network model are known a-priori. This means the internal state at time \(t=0\) is unknown. We assume simulations always start at a steady-state , for which \(\partial _{t} p = \partial _{t} q = 0\), given some (initial) boundary values \(\bar{s}_{p}\), \(\bar{d}_{q}\). The internal state is then computable as a steady-state problem. Since the employed model is nonlinear, we approximate the steady-state by a two-step procedure:

  1. 1a.

    Linear mass-flux steady-state: \(A_{pq} \bar{q} = -B_{pd} \bar{d}_{q}\).

  2. 1b.

    Linear pressure steady-state: \(A_{qp} \hat{p} = - (B_{qs} \bar{s}_{p} + F_{c} )\).

  3. 2.

    Corrected pressure steady-state: \(A_{qp} \bar{p} = - (B_{qs} \bar{s}_{p} + F_{c} + f_{q}( \hat{p},\bar{q},\bar{s}_{p},\theta ) )\).

Step 2 can be repeated until an error threshold is met by using the previously approximated pressure steady-state. Practically, the linear problems in Step 1 and Step 2 are solved by a QR-based least-norm method [23]. Note, that Step 1a and Step 1b can be solved in parallel and that the QR decomposition of Step 1b can be recycled in Step 2 because of the chosen model structure.

While this method works well for rooted-tree pipe-networks, it is not sufficient for cyclic networks with multiple supply nodes and non-pipe elements such as compressors. In this case, the resulting state after a limited number of the above algorithm’s iterations is used as an initial value for the first order IMEX integrator detailed in Sect. 5.3.3, which time-steps until a steady-state is sufficiently approximated. This approximate steady-state, associated to a fixed set of boundary values and parameters, is used as initial value for the simulations:

$$\begin{aligned} \begin{pmatrix} p_{0} \\ q_{0} \end{pmatrix} &= \begin{pmatrix} \bar{p}(\bar{s}_{p},\bar{d}_{q}) \\ \bar{q}(\bar{s}_{p},\bar{d}_{q}) \end{pmatrix}. \end{aligned}$$

While other time steppers are applicable, too, the first order IMEX solver is related to the initial (two-step) algebraic approximation, due to the synthesis of the linear / input / source and nonlinear / reaction terms.

2.9 Port-Hamiltonian structure

An interesting class of models are port-Hamiltonian systems, which have already been used for gas network modeling [39, 86]. Such port-controlled Hamiltonian models result from a system-theoretic approach to energy-based modeling, and are square, passive, stable and feature certain symmetries, besides their physical interpretability [15, 103]. To exploit results from port-Hamiltonian theory in the context of data-driven model reduction, we regiment the previous modeling approach into the port-Hamiltonian framework.

A linear input-state-output port-Hamiltonian model [135, Ch. 4] has the form:

$$\begin{aligned} \begin{aligned} &E \dot{x}(t) = \overbrace{(J - R) Q}^{A} x(t) + \overbrace{(G - P)}^{B} u(t), \\ &y(t) = \underbrace{(G + P)^{\mathsf{\scriptscriptstyle T}}Q}_{C} x(t), \end{aligned} \end{aligned}$$
(9)

with a symmetric positive definite mass matrix \(E = E^{\mathsf{\scriptscriptstyle T}}\), \(E > 0\), a skew-symmetric energy flux \(J = -J^{\mathsf{\scriptscriptstyle T}}\), a symmetric, positive, semi-definite energy dissipation \(R = R^{\mathsf{\scriptscriptstyle T}}\), \(R \geq 0\), a symmetric, positive definite energy storage Q, \(Q > 0\), resistive port matrix P and control port matrix G.Footnote 7

Here, we generalize the energy dissipation \(R \in \mathbb{R}^{N \times N}\) to a nonlinear mapping \({R : \mathbb{R}^{N} \to \mathbb{R}^{N \times N}}\), this means the linear constraints become [38]:

$$\begin{aligned} &R = R^{\mathsf{\scriptscriptstyle T}}\quad \rightarrow \quad \bigl\langle R(x) x', x'' \bigr\rangle = \bigl\langle x', R(x) x'' \bigr\rangle , \quad \forall x, x', x'' \in \mathbb{R}^{N} , \\ \end{aligned}$$
(10)
$$\begin{aligned} &R \geq 0 \quad \rightarrow \quad \bigl\langle R(x) x', x' \bigr\rangle \geq 0, \quad \forall x, x' \in \mathbb{R}^{N} . \end{aligned}$$
(11)

With this set up, we test the two index-reduced gas network model discretizations presented in Sect. 2.4.2 and Sect. 2.4.1 for compliance with the above port-Hamiltonian properties.

Proposition 1

The endpoint discretization (6a)(6b) is a port-Hamiltonian model.

Proof

We define the port-Hamiltonian state as \(x := ( p \ q^{L} ) ^{\mathsf{\scriptscriptstyle T}}\), which induces the remaining components. The mass matrix

$$\begin{aligned} E = \begin{bmatrix} (\mathcal{A}_{0,R} D_{p}^{-1} d_{0}(\theta ) \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}}) & 0 \\ 0 & D_{q}^{-1} \end{bmatrix} = E^{\mathsf{\scriptscriptstyle T}}> 0 \end{aligned}$$

is symmetric positive definite, if its diagonal blocks are. Given that the \(D_{*}\) are diagonal, and thus symmetric, as well as positive definite, both blocks are symmetric positive definite. The energy flux

$$\begin{aligned} J = \begin{bmatrix} 0 & -\mathcal{A}_{0} \\ \mathcal{A}_{0}^{\mathsf{\scriptscriptstyle T}}& 0 \end{bmatrix} = -J^{\mathsf{\scriptscriptstyle T}} \end{aligned}$$

is skew-symmetric by definition. The energy dissipation (see \(f_{q}\))

$$\begin{aligned} R(x) := \begin{bmatrix} 0 & 0 \\ 0 & ( D_{g} \operatorname{diag} ( \frac{\scriptstyle d_{0}(\theta ) \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}} p}{\scriptstyle q^{L}} ) + D_{q}^{-1} D_{f} \operatorname{diag} ( \frac{\scriptstyle \vert q^{L} \vert }{\scriptstyle d_{0}(\theta ) \mathcal{A}_{0,R}^{\mathsf{\scriptscriptstyle T}} p} ) ) \end{bmatrix}, \end{aligned}$$

with the \(\operatorname{diag}: \mathbb{R}^{N} \to \mathbb{R}^{N \times N}\) operator mapping a vector v to a diagonal matrix D such that \(v_{k} \mapsto D_{kk}\), and element-wise (fraction) nonlinearities, results in one non-zero diagonal block and thus fulfills (10). The condition (11) is fulfilled since in the friction term of R, the absolute value of the mass-flux (numerator), and the nodal pressure variable (denominator) are always non-negative.

Here, the energy storage represents the scale homogenization from Sect. 2.2,

$$\begin{aligned} Q = \begin{bmatrix} (10^{5} \cdot I_{N_{p}}) & 0 \\ 0 & (10^{-5} \cdot I_{N_{q}}) \end{bmatrix} = Q^{\mathsf{\scriptscriptstyle T}}> 0 \end{aligned}$$

which is a diagonal matrix of positive entries, and due to same block structure in E also fulfills \(Q^{\mathsf{\scriptscriptstyle T}}E = E^{\mathsf{\scriptscriptstyle T}}Q\). Lastly, the port matrix configuration

$$\begin{aligned} P := \begin{bmatrix} 0 & 0 \\ B_{S}^{\mathsf{\scriptscriptstyle T}}& 0 \end{bmatrix}, \qquad G := \begin{bmatrix} 0 & B_{D} \\ 0 & 0 \end{bmatrix}, \end{aligned}$$

complies to the port-Hamiltonian form. □

Some remarks are in order on this result: From the previous proof it is also immediately clear that the midpoint discretization cannot be a port-Hamiltonian model, due to the input dependence of the energy dissipation. Furthermore, this derivation tests if the endpoint discretization has the mathematical port-Hamiltonian structure, but does not verify a physical energy-based model.

The somewhat nonphysical treatment of the gravity term as dissipating instead of storing ([38]), is done with regard to the parametrization. Including the parametric gravity term as a retarding or damping force, and thus keeping the linear energy flux parameter-free, enables the previous steady-state computation.

Compressors, as modeled in Sect. 2.5 can be included by an additional summand inside the energy dissipation component, i.e. \(\frac{F_{C}}{q}\), similar to the gravity term. This exhibits an unphysical negative sign inside the dissipation, as a compressor introduces energy. Furthermore, this compressor model requires to remove components from the \(A_{qp}\) block of the system matrix (7), and thus perturbs the skew-symmetry of J.

Lastly, this notation for the dissipation can also be used for linearization, by constraining the argument of R to the steady-state ,

$$\begin{aligned} \widetilde{R} := R(\bar{x}) \approx R(x). \end{aligned}$$

Given the port-Hamiltonian model with a nonlinear resistive term, an (approximate) adjoint system can be derived by treating R as its image – a diagonal matrix. Transposing the (primal) port-Hamiltonian system’s (9) transfer function \(h(s) = (G + P)^{\mathsf{\scriptscriptstyle T}}Q (E s - (J - R) Q)^{-1} (G - P)\), and exploiting the system components properties, yields the dual system:

$$\begin{aligned} \begin{aligned} &E \dot{x}(t) = \overbrace{Q \bigl(-J - R \bigl(x(t) \bigr) \bigr)}^{A^{\mathsf{\scriptscriptstyle T}}} x(t) + \overbrace{Q (G + P)}^{C^{\mathsf{\scriptscriptstyle T}}} u(t), \\ &y(t) = \underbrace{(G - P)^{\mathsf{\scriptscriptstyle T}}}_{B^{\mathsf{\scriptscriptstyle T}}} x(t). \end{aligned} \end{aligned}$$
(12)

Hence, for the (nonlinear) endpoint discretization, its observability can be (approximately) quantified by the dual system’s reachability, as for linear systems. Conceptually, this could also be done with the midpoint discretization, as it supplies the same model components. However, it has no theoretical justification, as a dual system may not be accessible for (general) nonlinear systems.

3 Model reduction for gas networks

In this section, we summarize the principal approach behind all presented model reduction methods that are extended and tested in this work. The structure of the model laid out in Sect. 2 is given by (8). For large (expansive) networks, the differential equations in p and q become high dimensional, which impedes their solution [54, Sect. 7] and hence repeated simulations of scenarios. The aim of model reduction is to reduce the dimensionality of the differential equations, by computing subspaces of the phase space on which the trajectories evolve suitably similar (with regard to the quantities of interest). Furthermore, the reduced order model shall have the same form as the original model, and since two physical quantities are (bi-directionally) coupled in this system, the model reduction for interconnected systems [120] approach is used, yielding reduced operators for each subsystem:

$$\begin{aligned} & \begin{pmatrix} \widetilde{E}_{p}(\theta ) & 0 \\ 0 & \widetilde{E}_{q} \end{pmatrix} \begin{pmatrix} \dot{\tilde{p}} \\ \dot{\tilde{q}} \end{pmatrix} = \begin{pmatrix} 0 & \widetilde{A}_{pq} \\ \widetilde{A}_{qp} & 0 \end{pmatrix} \begin{pmatrix} \bar{p} +\tilde{p} \\ \bar{q} +\tilde{q} \end{pmatrix} + \begin{pmatrix} 0 & \widetilde{B}_{pd} \\ \widetilde{B}_{qs} & 0 \end{pmatrix} \begin{pmatrix} s_{p} \\ d_{q} \end{pmatrix} + \begin{pmatrix} 0 \\ \widetilde{F}_{c} \end{pmatrix} + \begin{pmatrix} 0 \\ \tilde{f}_{q}(\bar{p} +\tilde{p},\bar{q} { \scriptstyle +}\tilde{q},s_{p},\theta ) \end{pmatrix}, \\ & \begin{pmatrix} s_{q} \\ d_{p} \end{pmatrix} \approx \begin{pmatrix} \tilde{s}_{q} \\ \tilde{d}_{p} \end{pmatrix} = \begin{pmatrix} 0 & \widetilde{C}_{sq} \\ \widetilde{C}_{dp} & 0 \end{pmatrix} \begin{pmatrix} \bar{p} +\tilde{p} \\ \bar{q} +\tilde{q} \end{pmatrix}, \\ & \begin{pmatrix} \tilde{p}_{0} \\ \tilde{q}_{0} \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \end{pmatrix}, \end{aligned}$$

centered around the steady-state \(( \bar{p} \ \bar{q}) ^{\mathsf{\scriptscriptstyle T}}\). This structure preserving model order reduction was already used in [18, 53] in the context of model reduction for gas networks, while the centering has been used in [7] for gas network simulation and in [65] for nonlinear model order reduction. In the following, the general ansatz to obtain these reduced quantities (denoted by \(\tilde{ \cdot }\)) is summarized.

3.1 Projection-based model reduction

The reduced order model is computed by projecting the high-dimensional dynamics evolving in the (coupled) pressure and mass-flux phase spaces (of dimension \(N_{p}\) and \(N_{q}\)) to low(er)-dimensional subspaces (of dimension \(n_{p}\) and \(n_{q}\)), which capture the principal components of the respective trajectories. Given suitable discrete projection mappings from the original space to the reduced space \(V_{*}^{\mathsf{\scriptscriptstyle T}}\) and mappings from the reduced space back to the original space \(U_{*}\):

$$\begin{aligned} &U_{p} : \mathbb{R}^{n_{p}} \to \mathbb{R}^{N_{p}}, \qquad V_{p}^{\mathsf{\scriptscriptstyle T}}: \mathbb{R}^{N_{p}} \to \mathbb{R}^{n_{p}}: \qquad V_{p}^{\mathsf{\scriptscriptstyle T}}\cdot U_{p} = I_{n_{p}}, \\ &U_{q} : \mathbb{R}^{n_{q}} \to \mathbb{R}^{N_{q}}, \qquad V_{q}^{\mathsf{\scriptscriptstyle T}}: \mathbb{R}^{N_{q}} \to \mathbb{R}^{n_{q}}: \qquad V_{q}^{\mathsf{\scriptscriptstyle T}}\cdot U_{q} = I_{n_{q}}. \end{aligned}$$

Thus, the reduced trajectory results from applying \(V_{*}\) to the original trajectory’s steady-state deviation, while the original trajectory is approximately recovered by applying \(U_{*}\) to the reduced trajectory:

$$\begin{aligned} \begin{pmatrix} \tilde{p} \\ \tilde{q} \end{pmatrix} := \begin{pmatrix} V_{p}^{\mathsf{\scriptscriptstyle T}} (p - \bar{p}) \\ V_{q}^{\mathsf{\scriptscriptstyle T}} (q - \bar{q}) \end{pmatrix} \to \begin{pmatrix} \bar{p} + U_{p} \tilde{p} \\ \bar{q} + U_{q} \tilde{q} \end{pmatrix} \approx \begin{pmatrix} p \\ q \end{pmatrix}; \end{aligned}$$

the initial condition is also reduced by application of \(V_{*}\). Similarly, the components of the reduced system result from applying the \(U_{*}\) map to the argument of the respective operators, and the \(V_{*}\) map to the result of the operation.

For the linear operators, the matrices \(E_{*}\), \(A_{*}\), \(B_{*}\) and \(C_{*}\) and the vector \(F_{c}\), this leads conveniently to pre-computable reduced matrices and vector respectively,

$$\begin{aligned} \begin{aligned} \widetilde{A}_{pq} &:=V_{p}^{\mathsf{\scriptscriptstyle T}} \cdot A_{pq} \cdot U_{q} \in \mathbb{R}^{n_{p} \times n_{q}}, & \widetilde{A}_{qp} &:=V_{q}^{\mathsf{\scriptscriptstyle T}} \cdot A_{qp} \cdot U_{p} \in \mathbb{R}^{n_{q} \times n_{p}}, \\ \widetilde{B}_{pd} &:=V_{p}^{\mathsf{\scriptscriptstyle T}} \cdot B_{pd} \in \mathbb{R}^{n_{p} \times N_{s}}, & \widetilde{B}_{qs} &:=V_{q}^{\mathsf{\scriptscriptstyle T}} \cdot B_{qs} \in \mathbb{R}^{n_{q} \times N_{d}}, \\ \widetilde{C}_{dp} &:=C_{dp} \cdot U_{p} \in \mathbb{R}^{N_{d} \times n_{p}}, & \widetilde{C}_{sq} &:=C_{sq} \cdot U_{q} \in \mathbb{R}^{N_{s} \times n_{q}}, \\ \widetilde{E}_{p}(\theta ) &:=V_{p}^{\mathsf{\scriptscriptstyle T}} \cdot E_{p}(\theta ) \cdot U_{p} \in \mathbb{R}^{n_{p} \times n_{p}},\quad & \widetilde{E}_{q} &:=V_{q}^{\mathsf{\scriptscriptstyle T}} \cdot E_{q} \cdot U_{q} \in \mathbb{R}^{n_{q} \times n_{q}}, \\ \widetilde{F}_{c} &:=V_{q}^{\mathsf{\scriptscriptstyle T}} \cdot F_{c} \in \mathbb{R}^{n_{q}},& \end{aligned} \end{aligned}$$

yet, the nonlinear component \(\tilde{f}_{q}\) remains a composition operation:

$$\begin{aligned} \tilde{f}_{q} &:=V_{q}^{\mathsf{\scriptscriptstyle T}} \cdot f_{q}( \bar{p} + U_{p} \tilde{p} , \bar{q} + U_{q} \tilde{q} ,s_{p} ,\theta ) : \mathbb{R}^{n_{p}} \times \mathbb{R}^{n_{q}} \times \mathbb{R}^{N_{s}} \times \mathbb{R}^{2} \to \mathbb{R}^{n_{q}}. \end{aligned}$$
(13)

3.2 Structure preserving model order reduction

In this specific context, the term structure preserving model order reduction (SPMOR) has two meanings: first and foremost, SPMOR refers to the separate reduction of the state components, as above in the case of gas networks, the individual reduction of the discretized pressure p and mass-flux q variables. Second, SPMOR can also refer to preserving the port-Hamiltonian form (9). For projection-based model reduction, the former is generally ensured by separate projectors [44] (or an overall block diagonal projection). The latter is guaranteed by using Galerkin projections, which implies stability preservation [16], given a port-Hamiltonian full order model. Both SPMOR interpretations are jointly fulfilled if a block-diagonal (w.r.t. p and q) Galerkin projection is used.

3.3 The lifting bottleneck and hyper-reduction

The gas network models considered for reduction are nonlinear (and potentially non-smooth), hence the reduced order nonlinear part \(\tilde{f}_{q}\) involves lifting the reduced state up to the original high-dimensional space, evaluating the nonlinearity and projecting the result back down to the reduced low-dimensional space (13). As the high-dimensional space is involved, this is typically computationally demanding and may eat up the gains from the reduction of the linear part. To mitigate this so-called lifting bottleneck, hyper-reduction methods can be employed, which construct low-dimensional surrogates for nonlinearities.

In this work we discard (or rather defer) hyper-reduction due to the following reasoning: The purpose of this work is to determine which method constructs the best reduced order models, a hyper-reduction may inhibit comparability due to, for example, a dominating hyper-reduction approximation error. Second, various hyper-reduction methods for this setting are applicable (i.e. DEIM [26], Q-DEIM [36], DMD [142] or numerical linearization [98]), which may interact differently with the different model reduction methods. So as a first step, the bare model reduction methods are tested here (this means: which method’s linear subspaces capture the nonlinear dynamics best), at a later stage the best hyper-reduction method can then be determined. Lastly we note, the nonlinear part of the vector field consists exclusively of element-wise operations (see Sect. 2.9), a system with repeated scalar nonlinearities (SRSN) [28], which are less difficult to handle due to “locality” of the nonlinearity, and hence, its vectorization.

3.4 Parametric model reduction

There are two common approaches for projection-based parametric model order reduction: averaging and accumulating [67]. For the selected data-driven methods, averaging means that for a set of parameter samples the associated trajectories or derived quantities (such as the utilized system Gramians) are averaged, while accumulating refers to the concatenation of trajectories or derived quantities (such as the projectors).

Generally, each of the structure-preserving model order reduction methods in Sect. 4 can be used with either, we opted to use the averaging ansatz for all of the following methods since their computation is without exception based on parametric empirical Gramians [71].

4 Model reduction methods

In this section, we briefly summarize the employed model reduction methods from a practical point of view. For theoretical details and backgrounds we refer to the relevant works, cited in the respective subsections. Due to the non-differentiable nonlinearity (friction), the sought projections \(U_{*}\), \(V_{*}\) for all tested model reduction techniques are constructed from (transformed) time-domain trajectory data obtained from numerical simulations, which is given by discrete-time snapshots of the internal pressure nodes \(\widehat{X}_{p}\) and mass-flux edges \(\widehat{X}_{q}\),

$$\begin{aligned} &\widehat{X}_{p}(t;\theta _{k}) = \begin{bmatrix} p^{1}(t;\theta _{k}) & \ldots & p^{N_{s} + N_{d}}(t;\theta _{k}) \end{bmatrix}, \\ &\widehat{X}_{q}(t;\theta _{k}) = \begin{bmatrix} q^{1}(t;\theta _{k}) & \ldots & q^{N_{s} + N_{d}}(t;\theta _{k}) \end{bmatrix}, \end{aligned}$$

the external demand node pressure \(\widehat{Y}_{p}\) and supply node mass-flux \(\widehat{Y}_{q}\),

$$\begin{aligned} &\widehat{Y}_{p}(t;\theta _{k}) = \begin{bmatrix} \begin{pmatrix} s_{q}^{1}(t;\theta _{k}) \\ d_{p}^{1}(t;\theta _{k}) \end{pmatrix} & \ldots & \begin{pmatrix} s_{q}^{N_{p}}(t;\theta _{k}) \\ d_{p}^{N_{p}}(t;\theta _{k}) \end{pmatrix} \end{bmatrix}, \\ &\widehat{Y}_{q}(t;\theta _{k}) = \begin{bmatrix} \begin{pmatrix} s_{q}^{1}(t;\theta _{k}) \\ d_{p}^{1}(t;\theta _{k}) \end{pmatrix} & \ldots & \begin{pmatrix} s_{q}^{N_{q}}(t;\theta _{k}) \\ d_{p}^{N_{q}}(t;\theta _{k}) \end{pmatrix} \end{bmatrix}, \end{aligned}$$

as well as dual state components \(\widehat{Z}_{p}\) and \(\widehat{Z}_{q}\), if available,

$$\begin{aligned} &\widehat{Z}_{p}(t;\theta _{k}) = \begin{bmatrix} \mathfrak{p}^{1}(t;\theta _{k}) & \ldots & \mathfrak{p}^{N_{s} + N_{d}}(t; \theta _{k}) \end{bmatrix}, \\ &\widehat{Z}_{q}(t;\theta _{k}) = \begin{bmatrix} \mathfrak{q}^{1}(t;\theta _{k}) & \ldots & \mathfrak{q}^{N_{s} + N_{d}}(t; \theta _{k}) \end{bmatrix}. \end{aligned}$$

The state-space trajectories \(\widehat{X}_{*}(t;\theta _{k})\), \(\widehat{Z}_{*}(t;\theta _{k})\) are obtained for perturbations of the inputs, pressure at the \(N_{s}\) supply boundary nodes and mass-flux at the \(N_{d}\) demand boundary nodes, while the output trajectories \(\widehat{Y}_{*}(t;\theta _{k})\) are computed for perturbations in the respective \(N_{*}\) steady-state components. Using the dual state trajectories is significantly faster than output trajectories, as computing observability as dual reachability scales, as for the primal reachability, with the number of ports, instead of scaling with the number of internal states. The training parameters \(\theta _{k}\) are sampled from a sparse grid spanning the parameter space \(\Theta \subset \mathbb{R}^{2}\).

All methods are prefixed “Structured”, since the model structure of a pressure and mass-flux variable is preserved in the reduced order model. Practically, this means while pressure and mass-flux trajectories are computed simultaneously due to their coupling, the individual projectors for pressure and mass-flux are constructed separately.

The subsequent methods may not have been previously introduced explicitly in structured form, yet given [1, 120, 136] introducing structured Gramians, these are trivial extensions. For ease of notation, we describe the computation of projectors \(\{U_{p}, V_{p}\}\) and \(\{U_{q}, V_{q}\}\) generically as \(\{U_{*}, V_{*}\}\).

We implemented a total of thirteen model reduction method variants, which we compare in this work. All tested methods are data-driven and time-domain focused, as the dynamic gas network model (8) is nonlinear. Furthermore, all model reduction methods construct linear subspaces and are derived from methods for linear systems, yet differ from plain linearization: instead, the implemented methods assemble linear subspaces of the model’s phase space that, in a method specific sense, approximately enclosing the relevant nonlinear system evolution. Moreover, all methods are SVD-based [4], and their majority is originally based on (empirical) system Gramian matrices, for details see [66].

We highlight here that the time horizon for the training data is significantly shorter than for the actual simulations the reduced order model is targeted at. Furthermore, generic training inputs (transient boundary values), such as impulse, step or random signals, are utilized to avoid a model reduction crime [67] (comparable to an inverse crime): Test a reduced order model using the training parameters or inputs.

4.1 Empirical system Gramians

All model reduction methods currently included in morgen are computationally realized using empirical system Gramian matrices, which are system-theoretic operators encoding reachability and observability. From these, information on importance of linear combinations of states can be extracted. For linear systems, these system Gramians are typically computed via matrix equations, for general nonlinear systems there is no feasible closed form. However, the empirical system Gramians approximate the nonlinear Gramians based on state and output trajectory data. In case of a port-Hamiltonian (nonlinear) systems, the approximate dual system (12) enables substituting expensive state by port perturbations, and thus severely reduce computation times. Empirical Gramians are described in-depth in [66]; following only a brief summary is given.

4.1.1 Empirical reachability Gramian matrix

Reachability quantifies how well a system can be driven by the inputs, which is encoded by the reachability Gramian. The empirical reachability Gramian is an approximation based on state trajectory data [84]:

$$\begin{aligned} \widehat{W}_{R,*} :=\sum _{k=1}^{K} \sum_{m=1}^{N_{s} + N_{d}} \int _{0}^{\infty }\widehat{X}^{m}_{*}(t; \theta _{k}) \widehat{X}^{m}_{*}(t; \theta _{k})^{\mathsf{\scriptscriptstyle T}}\,\mathrm{d}t \in \mathbb{R}^{N_{*} \times N_{*}}. \end{aligned}$$
(14)

Given a suitable set of input perturbations, \(\widehat{W}_{R,*}\) approximates the nonlinear reachability Gramian near a steady-state [56].

4.1.2 Empirical observability Gramian matrix

Observability quantifies how well the state can be characterized from the outputs, which is encoded by the observability Gramian. The empirical observability Gramian is an approximation based on output trajectory data [84]:

$$\begin{aligned} \widehat{W}_{O,*} :=\sum _{k=1}^{K} \int _{0}^{\infty }\widehat{Y}_{*}(t;\theta _{k})^{\mathsf{\scriptscriptstyle T}} \widehat{Y}_{*}(t;\theta _{k}) \,\mathrm{d}t \in \mathbb{R}^{N_{*} \times N_{*}}. \end{aligned}$$
(15)

For a suitable set of steady-state perturbations, \(\widehat{W}_{O,*}\) approximates the nonlinear observability Gramian near a steady-state [56].

Given the port-Hamiltonian structure of a discretization, the empirical reachability Gramian of the dual system (12) can be used to compute the empirical observability Gramian [67, Sect. 2] with \(\widehat{Z}^{m}_{*}(t;\theta _{k})\) instead of \(\widehat{X}^{m}_{*}(t;\theta _{k})\).

4.1.3 Empirical cross Gramian matrix

The empirical cross Gramian concurrently encodes reachability and observability, which in conjunction quantifies redundancy also known as minimality; however, the (empirical) cross Gramian is only applicable for square systems, systems with the same number of inputs and outputs (which the gas network model (8) fortunately is), and an approximation is based on simulated state and output trajectory data [70]:

$$\begin{aligned} \widehat{W}_{X,*} :=\sum _{k=1}^{K} \sum_{m=1}^{N_{s} + N_{d}} \int _{0}^{\infty }\widehat{X}^{m}_{*}(t; \theta _{k}) \widehat{Y}_{*}(t; \theta _{k}) \,\mathrm{d}t \in \mathbb{R}^{N_{*} \times N_{*}}. \end{aligned}$$
(16)

For a suitable set of input and steady-state perturbations, \(\widehat{W}_{X,*}\) approximates the nonlinear cross Gramian near a steady-state [70].

Given the port-Hamiltonian structure of a discretization, the linear empirical cross Gramian exploiting the dual system (12) can be used to compute the empirical cross Gramian [14] with \(\widehat{Z}^{m}_{*}(t;\theta _{k})^{\mathsf{\scriptscriptstyle T}}\) instead of \(\widehat{Y}_{*}(t;\theta _{k})\).

4.1.4 Empirical non-symmetric cross Gramian matrix

A generalization of the empirical cross Gramian for non-square systems is the empirical non-symmetric cross Gramian, which is an approximation based on simulated state and (averaged) output trajectory data [72]:

$$\begin{aligned} \widehat{W}_{Z,*} :=\sum _{k=1}^{K} \sum_{m=1}^{N_{s} + N_{d}} \sum_{q=1}^{N_{s} + N_{d}} \int _{0}^{\infty }\widehat{X}^{m}_{*}(t; \theta _{k}) \widehat{Y}^{q}_{*}(t;\theta _{k}) \,\mathrm{d}t \in \mathbb{R}^{N_{*} \times N_{*}}. \end{aligned}$$
(17)

For a suitable set of input and steady-state perturbations, \(\widehat{W}_{Z,*}\) approximates the nonlinear cross Gramian near a steady-state. Even though the gas network model (8) is square, the empirical non-symmetric cross Gramian is included here, since, heuristically, it could provide better results than the regular cross Gramian [72]. Furthermore, an empirical non-symmetric linear cross Gramian is computable by similarly averaging over the dual states and replacing \(\widehat{Y}^{q}_{*}(t;\theta _{k})\) by \(\widehat{Z}^{q}_{*}(t;\theta _{k})^{\mathsf{\scriptscriptstyle T}}\).

4.2 Structured proper orthogonal decomposition

Proper orthogonal decomposition (POD) is a basic data-driven method for model reduction: given a matrix of state snapshots over time, the dominant left singular vectors are computed as a basis via a singular value decomposition (SVD) [97]. The basis vectors are assigned their principality with respect to the conveyed energy by the associated (relative) singular value magnitude.

In the context of this work, the POD is constructed from a system-theoretic point of view, that connects to the system property of reachability. Due to the overall structured approach to model reduction, a structured POD refers in this context to the separate PODs for pressure and mass-flux variables p and q as in [18, 51, 53].

4.2.1 Reachability-Gramian-based

The singular vectors to the principal singular values of the empirical reachability Gramian (14) correspond to the POD modes. To obtain a reduced order model, first, a truncated SVD (tSVD) of the empirical reachability Gramian,

$$\begin{aligned} W_{R,*} \stackrel{\mathrm{tSVD}}{=} U_{R,*} D_{R,*} U_{R,*}^{\mathsf{\scriptscriptstyle T}}, \end{aligned}$$

reveals the principal subspace of the respective trajectories \(\widehat{X}_{*}^{m}(t)\), whereas the importance of each basis vector (column) in \(U_{R,*}\) is determined by (the square-root of) the associated singular value \(\sigma _{i} := D_{R,* ii}^{1/2}\):

$$\begin{aligned} U_{*} := U_{R,*}. \end{aligned}$$

The matrix of basis vectors (POD modes) constitutes a Galerkin projection \(V_{*} := U_{*}\). Notably, (structured) POD only considers the input-to-state mapping, not the state-to-output mapping, and hence approximates the state variables, p and q, not the output quantities of interest \(s_{q}\) and \(d_{p}\).

The POD could also be computed directly from an SVD of the trajectory data, yet the computational overhead of using the empirical reachability Gramian is small compared to the trajectory simulation runtimes, and the systematic perturbations of the empirical Gramian approach [66] are exploited.

4.3 Structured empirical dominant subspaces

The previous (structured) POD method considers only the reachability information, hence the data only reflects the input-to-state mappings, and thus the POD derived ROMs (Reduced Order Model) approximate the state variables p and q. To approximate the outputs \(s_{q}\) and \(d_{p}\), the state-to-output mappings, encoding observability information, need to be considered, too.

The (empirical) dominant subspaces method initially developed in [110], and originally named DSPMR (Dominant Subspace Projection Model Reduction), conjoins and compresses the dominant reachability and observability subspaces of an input-output system, such as the gas network model (8), obtained from (empirical) system Gramians. Heuristically, this method seems to be useful for hyperbolic input-output systems [49]. Here, we consider three variants: first, based on the empirical reachability and observability Gramians, second, based on the empirical cross Gramian and third, based on the empirical non-symmetric cross Gramian.

4.3.1 Reachability- and observability-Gramian-based

The singular vectors associated to the principal singular values of the empirical reachability and observability Gramians span these dominant subspaces, which are first extracted by tSVDs, and then, after concatenation, compressed by orthogonalization via another tSVD:

$$\begin{aligned} &\widehat{W}_{R,*} \stackrel{\mathrm{tSVD}}{=} U_{R,*} D_{R,*} V_{R,*}^{\mathsf{\scriptscriptstyle T}}, \\ &\widehat{W}_{O,*} \stackrel{\mathrm{tSVD}}{=} U_{O,*} D_{O,*} V_{O,*}^{\mathsf{\scriptscriptstyle T}}, \\ & \begin{bmatrix} (\omega _{R} U_{R,*} D_{R,*}) & (\omega _{O} U_{O,*} D_{O,*}) \end{bmatrix} \stackrel{\mathrm{tSVD}}{=} U_{RO,*} D_{RO,*} V_{RO,*}, \end{aligned}$$

from which the singular vectors \(V_{*} = U_{*} := U_{RO,*}\) make up a Galerkin projection. The weights \(\omega _{R} := \|\widehat{W}_{R,*}\|_{F}^{-1}\), and \(\omega _{O} := \|\widehat{W}_{O,*}\|_{F}^{-1}\) equilibrate the potentially mismatched scales of the respective Gramians, akin to the refined DSPMR method from [110].

4.3.2 Cross-Gramian-based

A truncated SVD of the cross Gramian also engenders the sought dominant subspaces [20]: The (empirical) cross Gramian’s left and right singular vectors (approximately) span the reachability and observability subspaces, respectively, and their orthogonalized concatenation, via a truncated SVD,

$$\begin{aligned} &\widehat{W}_{X,*} \stackrel{\mathrm{tSVD}}{=} U_{X,*} D_{X,*} V_{X,*}^{\mathsf{\scriptscriptstyle T}}, \\ & \begin{bmatrix} (U_{X,*} D_{X,*}) & (V_{X,*} D_{X,*}) \end{bmatrix} \stackrel{\mathrm{tSVD}}{=} U_{RO,*} D_{RO,*} V_{RO,*}, \end{aligned}$$

yields a Galerkin projection \(V_{*} = U_{*} := U_{RO,*}\). The cross-Gramian-based variant does not need to additionally weight the reachability subspace \(U_{X,*}\) and observability subspace \(V_{X,*}\), as they are both extracted from the same matrix.

This cross-Gramian-based empirical dominant subspaces method seamlessly extends to the empirical non-symmetric cross Gramian \(\widehat{W}_{Z,*}\).

4.4 Structured empirical balanced truncation

The dominant subspaces method combines separately quantified input-to-state and state-to-output energies, but not the actual input-to-output energy. Such can be accomplished by balanced truncation and based on the Hankel operator, which maps past inputs to future outputs. This operator’s singular values measure the sought input-to-output energy, and the singular vectors constitute a basis. To obtain the Hankel operator’s truncated SVD, first, the underlying system needs to be balanced, and then singular vectors associated to small magnitude Hankel singular values are truncated.

Balanced truncation is the reference model reduction method for linear input-output systems, due to stability preservation in the ROMs and a computable error bound. For (control-affine) nonlinear input-output systems, such as the gas network model (8), balanced truncation can be generalized to empirical balanced truncation [84], while a structured variant is introduced as interconnected system balanced truncation [136], which we combine.

Again, we consider three variants: First, based on the empirical reachability and observability Gramian, second, based on the empirical cross Gramian and third, on the empirical non-symmetric cross Gramian; additionally, the reachability and observability-based balanced POD variant is included.

4.4.1 Reachability- and observability-Gramian-based

The original balanced truncation method is based on the reachability and observability Gramians [99]. A transformation into a balanced coordinate system in which both system Gramians are diagonal and equal is obtained via simultaneous diagonalization. Various balancing algorithms are available for this task [137], in this setting we selected the general balancing algorithm [118, 119], which utilizes the magnitude-based truncated eigenvalue-decomposition (tEVD) of the Gramians: The matrices \(U_{*}\), \(V_{*}\) constitute a Petrov-Galerkin projection, whereas the importance of each column is determined by the approximate Hankel singular values, the (diagonal) elements of \(D_{B,*}\):

$$\begin{aligned} \begin{aligned} &\widehat{W}_{R,*} \widehat{W}_{O,*} T_{R,*} \stackrel{\mathrm{tEVD}}{=} \Lambda _{R,*} T_{R,*}, \\ & (\widehat{W}_{R,*} \widehat{W}_{O,*} )^{\mathsf{\scriptscriptstyle T}}T_{O,*} \stackrel{\mathrm{tEVD}}{=} \Lambda _{O,*} T_{O,*}, \\ &T_{O,*}^{\mathsf{\scriptscriptstyle T}}T_{R,*} \stackrel{\mathrm{tSVD}}{=} U_{B,*} D_{B,*} V_{B,*}, \\ &U_{*} := T_{R,*} V_{B,*} D_{B,*}^{-\frac{1}{2}}, \\ &V_{*} := T_{O,*} U_{B,*} D_{B,*}^{-\frac{1}{2}}. \end{aligned} \end{aligned}$$
(18)

4.4.2 Cross-Gramian-based

For linear, symmetric systems, alternatively a balanced and truncated reduced order model can be computed via the cross Gramian. Yet, the gas network model (8) is neither linear nor symmetric, not even in a nonlinear sense of symmetric systems, i.e. gradient systems [75], but the considered input-output system is square. Hence, an empirical cross-Gramian-based reduced model is computable, but it will differ from the reduced model obtained by reachability- and observability-Gramian-based balanced truncation.

Given a cross Gramian with full rank, an (approximate) balancing projection is computable in a similar manner as for the (empirical) balanced truncation (18), but based on the left and right eigen spaces of the cross Gramian [77]:

$$\begin{aligned} \begin{aligned} &\widehat{W}_{X,*} T_{R,*} \stackrel{\mathrm{tEVD}}{=} \Lambda _{*} T_{R,*} \\ &\widehat{W}_{X,*}^{\mathsf{\scriptscriptstyle T}}T_{O,*} \stackrel{ \mathrm{tEVD}}{=} \Lambda _{*} T_{O,*} \\ &T_{O,*}^{\mathsf{\scriptscriptstyle T}}T_{R,*} \stackrel{\mathrm{tSVD}}{=} U_{X,*} D_{X,*} V_{X,*}, \\ &U_{*} := T_{R,*} V_{X,*} D_{X,*}^{-\frac{1}{2}}, \\ &V_{*} := T_{O,*} U_{X,*} D_{X,*}^{-\frac{1}{2}}. \end{aligned} \end{aligned}$$
(19)

The matrices \(U_{*}\), \(V_{*}\) again constitute a Petrov-Galerkin projection, and the importance of each column is determined by the absolute value of the (diagonal) elements of \(D_{X,*}\), which are only equal to the Hankel singular values for linear and symmetric systems.

As for the empirical dominant subspaces method, the cross-Gramian-based empirical balanced truncation variant directly extends to the non-symmetric cross Gramian \(\widehat{W}_{Z,*}\).

One could assume that if only one system Gramian has to be computed, instead of two for dominant subspaces or balanced truncation, that the cross-Gramian-based computation is significantly faster, but the overall number of simulated trajectories is the same for both methods, which causes the dominant fraction of computational cost. Thus, the empirical cross Gramian computation is merely somewhat quicker than the computation of both empirical reachability and observability Gramians.

4.4.3 Structured balanced POD

Instead of balancing the system using the product of the (empirical) reachability and observability Gramians, the dominant subspaces of the respective Gramians can be used to approximately balance the system. This variant of reachability- and observability-Gramian-based balanced truncation is called balanced POD [141], and the approximate balancing algorithm reads:

$$\begin{aligned} \begin{aligned} &\widehat{W}_{R,*} T_{R,*} \stackrel{\mathrm{tEVD}}{=} \Lambda _{R,*} T_{R,*}, \\ &\widehat{W}_{O,*} T_{O,*} \stackrel{\mathrm{tEVD}}{=} \Lambda _{O,*} T_{O,*}, \\ &T_{O,*}^{\mathsf{\scriptscriptstyle T}}T_{R,*} \stackrel{\mathrm{tSVD}}{=} U_{B,*} D_{B,*} V_{B,*}, \\ &U_{*} := T_{R,*} V_{B,*} D_{B,*}^{-\frac{1}{2}}, \\ &V_{*} := T_{O,*} U_{B,*} D_{B,*}^{-\frac{1}{2}}, \end{aligned} \end{aligned}$$
(20)

with the matrices \(U_{*}\), \(V_{*}\) inducing a Petrov-Galerkin projection.

Here, we categorized balanced POD as a variant of balanced truncation, due the algorithmic similarity to the balancing algorithm (18). Alternatively, we could have classified balanced POD as a variant of POD, since it can be described as POD with the observability Gramian defining the POD’s inner product [116].

We leave it to the reader to test other balancing algorithms, e.g. [17, 137], while we excluded the modified POD [67, 102], as it is not a Petrov-Galerkin method.

4.5 Structured empirical balanced gains

The empirical balanced gains method is a variant of the empirical balanced truncation method [30, 67]: While balanced truncation selects principality of subspaces based on the Hankel singular value magnitude, balanced gains [30] sorts the balanced basis vectors by the impulse response norm:

$$\begin{aligned} & \Vert s_{q} \Vert _{2}^{2} \approx \operatorname{tr}\bigl(C_{sq} \widehat{W}_{R,q} C_{sq}^{\mathsf{\scriptscriptstyle T}}\bigr) \approx \operatorname{tr} \bigl(B_{qs}^{\mathsf{\scriptscriptstyle T}}\widehat{W}_{O,q} B_{qs}\bigr) \approx \bigl\vert \operatorname{tr}(C_{sq} \widehat{W}_{X,q} B_{qs}) \bigr\vert , \\ & \Vert d_{p} \Vert _{2}^{2} \approx \operatorname{tr}\bigl(C_{dp} \widehat{W}_{R,p} C_{dp}^{\mathsf{\scriptscriptstyle T}}\bigr) \approx \operatorname{tr} \bigl(B_{pd}^{\mathsf{\scriptscriptstyle T}}\widehat{W}_{O,p} B_{pd}\bigr) \approx \bigl\vert \operatorname{tr}(C_{dp} \widehat{W}_{X,p} B_{pd}) \bigr\vert , \end{aligned}$$

for a system in balanced form. Hence, either method, balanced truncation and balanced gains compute the same balancing transformation, via (18) or (19), but the sequence of basis vectors differs due to the variant measures.

We note, that due to the linear input and output operators, the balanced gains method can be directly applied for the nonlinear gas network models (8).

4.5.1 Structured goal-oriented proper orthogonal decomposition

Similar to the balanced gains method, (structured) POD basis vectors can also be sorted, instead of by their singular value magnitude \(\sigma _{k}\), in terms of their impulse response, akin to the simplified balanced gains in [30], by the index \(d_{k}\)

$$\begin{aligned} d_{k} := \tilde{c}_{k} \tilde{c}_{k}^{\mathsf{\scriptscriptstyle T}} \sigma _{k}, \end{aligned}$$

for rows \(\tilde{c}_{k}\) of the POD-transformed output matrix . Given the reachability-based POD, this variant is related to the concept of output-reachability and \(H_{2}\)-norm model reduction [112].

4.6 Structured dynamic mode decomposition - Galerkin

In addition to the four energy-based method classes (Sects. 4.2, 4.3, 4.4, 4.5), also an alternative method from [2], based on system identification, is investigated. Yet, it is adapted as a structured projection-based model reduction method. After summarizing the parent system identification method, the derived model reduction technique is presented.

4.6.1 Dynamic mode decomposition

Dynamic mode decomposition (DMD) identifies a discrete-time operator from (discrete) trajectory time-series data, preserving certain modal behavior [117]. This system identification method is based on the Koopman operator, which is an infinite dimensional, but linear operator, mapping (a transformation, or observable of the) state \(x^{k}\) at discrete-time step k to \((k+1)\). DMD yields a (linear) finite-dimensional approximation of the Koopman operator preserving its dominant eigenmodes. Here, using the identity observable and given time series data \(X = [ x^{0} \ \ldots \ x^{K} ] \), DMD identifies an operator Â, via least-squares:

$$\begin{aligned} &x^{k+1} \approx \widehat{A} x^{k}, \end{aligned}$$
(21a)
$$\begin{aligned} &\widehat{A} := \begin{bmatrix} x^{1} & \ldots & x^{K} \end{bmatrix} \begin{bmatrix} x^{0} & \ldots & x^{K-1} \end{bmatrix}^{+}. \end{aligned}$$
(21b)

Since the underlying model is a control system, DMD with control (DMDc) [113] (and known input operator B), i.e. using \(X^{c} := [ x^{0} - B u^{0} \ \ldots \ x^{K} - B u^{K} ] \) instead of X for DMD, is applicable, yet, due to the perturbed steady-state training of ROMs (see Sect. 6.1) not beneficial.

4.6.2 Reachability-Gramian-based DMD-Galerkin

DMD is rather a system identification than a model reduction method. To fit into the projection setting, we utilize the DMD-Galerkin method [2], which forms a Galerkin projection U from the orthogonalized dominant eigenvectors (based on the associated eigenvalue magnitudes),

$$\begin{aligned} &\widehat{A} T \stackrel{\mathrm{EVD}}{=} T \Lambda , \\ & T \Lambda \stackrel{\mathrm{SVD}}{=} U D V^{\mathsf{\scriptscriptstyle T}}. \end{aligned}$$

Since only state-space trajectories are utilized, as for the POD, the DMD-Galerkin method approximates the state, not the output. Curiously, we note, that this method uses discrete-time information to assemble projections for continuous-time systems.

Practically, \(U_{*}\) are computed as a subset of singular vectors for the largest magnitude singular values, instead of orthogonalized eigenvectors. In the structured setting at hand \(\widehat{X}_{*} = [ x_{*}^{0} \ \ldots \ x_{*}^{K} ] \), with \(X_{*}\) representing the pressure and mass-flux states \(X_{p}\), \(X_{q}\), the respective Galerkin projection \(U_{*} = V_{*}\) is given by:

$$\begin{aligned} \begin{bmatrix} x_{*}^{1} & \ldots & x_{*}^{K} \end{bmatrix} \begin{bmatrix} x_{*}^{0} & \ldots & x_{*}^{K-1} \end{bmatrix}^{+} &\stackrel{\mathrm{tSVD}}{=} U_{*} D_{*} \widetilde{V}_{*}^{\mathsf{\scriptscriptstyle T}}. \end{aligned}$$

Effectively, the approximate Koopman operator  is computed via an empirical reachability Gramian, yet instead of the standard inner product, the DMD-“kernel” (21b) is used. Additionally, and in line with the original empirical Gramians [84], the utilized trajectories are centered, following [73]. This means theoretically, DMD-Galerkin is POD with a specific kernel, and practically, that by computation via an empirical Gramian the systematic perturbation properties can also be exploited for DMD-Galerkin.

5 morgen

The morgen (Model Order Reduction for Gas and Energy Networks) platform (version 1.0) implements the mathematical methods presented above, in MATLAB (≥ 2020b) and compatible to Octave (≥ 6.1). Compared to, for example [62], morgen does not feature a graphical user interface or Simulink integration, since it is designed for batch testing and multi-query use on (headless) workstations.

The source code is organized into five main components:

networks:

(holds network and scenario data-sets)

models:

(discretizes networks and assembles input-output systems)

solvers:

(computes solution time series for discrete models and scenarios)

reductors:

(reduces state variables of discrete models)

tests:

(defines experiments for data-model-solver-reductor combinations).

These components are briefly described in the following. For an illustration of the internal structure of morgen, see Fig. 2. Further code that is used by the main function or multiple components is contained in an utils folder, and the stand-alone network format convertersFootnote 8 are stored in a tools folder.

Figure 2
figure 2

Internal data flow and process of morgen

5.1 Networks

The networks directory stores the network .net files, and a folder for each network with the same name as the associated network file’s base name, which hold the scenario definition files. The .net file, in comma-separated value (CSV) format, defines the network topology and gas network components through an edge list. Each row encodes one edge through the information: edge type (pipe, shortcut, compressor, valve), “from”-node, “to”-node, length, diameter, incline, roughness; the latter three are only relevant for pipe edges.

Note that boundary nodes have to be leaf nodes of the network graph in order to be identified by morgen as such. Furthermore, if a boundary node shall act as supply and demand, it needs to be artificially split into two leaf nodes, as the edge connecting a supply node has to be directed from the leaf, while the edge connecting a demand node has to be directed towards the leaf (Sect. 2.3).

5.1.1 Scenario

A scenario is defined via a set of key-value pairs in an .ini file, whereas the sequence of pairs does not matter. Each network has at least a generic training.ini scenario. The following keys are mandatory for a scenario definition:

T0:

Mean temperature

RS:

Mean specific gas constant

tH:

Time horizon

ut:

List of time instances

up:

List of supply node pressures at time instances ut

uq:

List of demand node mass-fluxes at time instances ut.

Depending on the network composition, the following keys may need to be provided:

cp:

List of compressor discharge pressures

vs:

List of valve settings.

Note that amongst other configurations, the parameter ranges of temperature and specific gas constant for the parametric model reduction are set in the global morgen.ini file.

5.2 Models

A model encodes a spatial discretization of the simplified Euler equations (8) on a gas network topology in a structure with the members: A, B, C, E, F, f and the Jacobian J ([3, 128]), together with the system dimensions in terms of number of pressure-at-nodes and mass-flux-on-edges states, and total number of boundary / port nodes. It is ensured during the assembly of the model that the sparsity of the model components is preserved.

The model interface is given by the following signature: discrete = model(network,config);

While the linear components A, B, C, and F are provided as sparse matrices, the parameter-dependent linear component E is a closureFootnote 9 returning a sparse matrix, and the nonlinear component f and the (nonlinear) Jacobian J are closures returning the application of a state (as well as steady-state, input, parameters, compressibility).

Two spatial discretizations are currently provided in morgen:

ode_mid:

Midpoint ODE discretization (Sect. 2.4.1)

ode_end:

Endpoint ODE discretization (Sect. 2.4.2).

Even though both provided models are ODEs, DAE models can also be implemented and tested, given a solver (and reductor) is available.

5.3 Solvers

The morgen platform provides four solvers: An adaptive step-size method, a fixed step-size explicit method and two fixed step-size implicit-explicit methods.

While explicit solvers only require vector field evaluations at the cost of smaller time steps, implicit solvers have to solve a root-finding problem in each time step for a nonlinear model. An IMEX with singly DIRK (SDIRK) solver turns out to be the most efficient for this class of models, simplifying the nonlinear problem to a linear problem solvable by a single matrix decomposition per trajectory. Due to the non-diagonal mass matrix, even in the case of a sufficiently stable and accurate explicit method, at least one linear problem per trajectory would have to be solved.

The solver interface is given by the following signature: solution = solver(discrete,scenario,config); with the return value solution, being a structure, and the arguments discrete (model), scenario, and config(uration).

All provided fixed step-size solvers cache matrix decompositions. The initial steady-state is also cached, as is the QR decomposition used to compute it.

Even though the overall model (8) has a two dimensional structure and the reductors exploit this structure, the simulations itself can be performed on a lumped model (we omit parametrization here for ease of notation):

$$\begin{aligned} \begin{aligned} &E\dot{x}(t) = Ax(t) + Bu(t) + f \bigl(x(t),u(t)\bigr), \\ &y(t) = Cx(t). \end{aligned} \end{aligned}$$
(22)

5.3.1 Second-order adaptive implicit solver: generic

For validation purposes, the adaptive step-size solver for stiff systems ode23sFootnote 10 included in MATLAB (and Octave) [125, Sect. 2.3], based on a modified second order Rosenbrock formula is used and encapsulated as a generic solver. Due to preferential performance demonstrated in [51], ode23s is preferred over alternatives such as ode15s (or ode45).

5.3.2 Fourth-order “classic” Runge-Kutta solver: rk4

Since in [104, 105], the fourth-order explicit Runge-Kutta (RK) method [83] is employed, morgen provides it, too. This method is strong stability preserving [47], however it is not SSP-optimal and it works only for small time-steps.

5.3.3 First-order implicit-explicit solver: imex1

The lumped gas network model (22) can be split into a linear and a nonlinear part, of which the linear part is numerically stiff and hence should be solved with an implicit solver, while an explicit solver is preferred for the nonlinear part as to avoid solving a root-finding (optimization) problem in each time step.

An IMEX method allows this separate treatment of operators and is thus suitable for this hyperbolic and nonlinear system. Combining the first-order explicit Euler’s method with the first order implicit Euler’s method yields the first order IMEX method:

$$\begin{aligned} &E h^{-1}(x_{k+1} - x_{k}) = (1 - \gamma ) A x_{k} + \gamma A x_{k+1} + B u_{k} + f(x_{k},u_{k}) \\ &\quad \Rightarrow\quad E x_{k+1} - \gamma h A x_{k+1} = E x_{k} + (1 - \gamma ) h A x_{k} + h B u_{k} + h f(x_{k},u_{k}) \\ &\quad \Rightarrow\quad x_{k+1} = x_{k} + (E - \gamma h A)^{-1} h \bigl(A x_{k} + B u_{k} + f(x_{k},u_{k}) \bigr), \end{aligned}$$

with the associated Butcher tableaus Table 2. Even though this IMEX method is not a Runge-Kutta method [5], it was successfully applied to gas network models in [52] with a relaxation parameter set to \(\gamma = 1\).

Table 2 Butcher tableaus for the 1st-order IMEX method (Sect. 5.3.3)

5.3.4 Second-order implicit-explicit Runge-Kutta solver: imex2

A second-order (two-stage) IMEX Runge-Kutta solver is provided, based on the combination of a second-order explicit SSP Runge-Kutta method [47], and a second-order DIRK method. Following [109], such an IMEX-SSP2(2,2,2) method with relaxation γ is given by:

$$\begin{aligned} &z_{1} = (E - h \gamma \lambda A)^{-1} E x_{k}, \\ &z_{2} = (E - h \gamma \lambda A)^{-1} \bigl(E x_{k} + h B u_{k} + h f(x_{k},u_{k}) + h \gamma (1 - 2 \lambda ) A z_{1}\bigr), \\ &x_{k+1} = x_{k} + E^{-1} \frac{h}{2} \bigl(B u_{k} + f(x_{k},u_{k}) + \gamma A z_{1} + B u_{k+1} + f(z_{1},u_{k+1}) + \gamma A z_{2}\bigr). \end{aligned}$$

The explicit component of this IMEX method is SSP-optimal [47], while depending on the choice for the free parameter λ, different properties of the implicit component can be achieved (see Table 3). Practically, we found \(\lambda = { \frac{1}{2}}\), making the implicit part SDIRK and stiffly accurate, to work best. Additionally, we would like to highlight passive Runge-Kutta methods [101], specifically PDIRK (passive DIRK), as implicit IMEX component, which have various desirable stability and conservation properties [43].

Table 3 Parameter choices for the implicit 2nd-order IMEX-RK component

The associated Butcher tableaus are given in Table 4.

Table 4 Butcher tableaus for the 2nd-order IMEX-RK method (Sect. 5.3.4)

In our experiments, the first-order IMEX method Sect. 5.3.3 allowed larger time-steps and exhibited less numerical oscillations or artifacts compared to the second-order IMEX-RK methods. The generic (adaptive) method Sect. 5.3.1 also solves sufficiently accurate, but takes longer to compute. Thus, by default, we recommend the first-order IMEX integrator for gas network simulations.

5.4 Reductors

The reductor module provides methods that compute structuredFootnote 11 (struct.) projectors for a given discretization. These projectors can be stored on disk for reuse. Currently, the reductors, described in Sect. 4 are included:

pod:

Struct. proper orthogonal decomposition

eds:

Struct. empirical dominant subspaces

bpod:

Struct. balanced proper orthogonal decomposition

ebt:

Struct. empirical balanced truncation

gopod:

Struct. goal-oriented proper orthogonal decomposition

ebg:

Struct. empirical balanced gains

dmd:

Struct. dynamic mode decomposition Galerkin.

Each reductor variant has a suffix characterizing the employed empirical Gramians: _r for only reachability, _ro for reachability and observability, _wx for cross, and _wz for non-symmetric cross Gramian. For each reductor utilizing observability information (this includes the cross Gramians), a linear variant using the dual system is available, and signified with the additional suffix _l.

The reductors have the interface: [proj,name] = reductor(solver,discrete,scenario,config); returning a (cell) array of projectors with maximum configured column rank, as well as the reductor’s full name. These projectors specific to model and solver defining a ROM are then stored in a .rom file.

5.4.1 Empirical Gramian framework

The compute back-end for the model reduction methods is emgr – empirical Gramian framework [66]; currently in version 5.9 [68]. This (open-source) Octave and MATLAB toolbox computes the empirical Gramians, which are essential to construct the reduced order models via the Gramian-based model reduction methods from Sect. 4, including the structured DMD-Galerkin method.

5.5 Tests

A test is a script defining an experiment by specifying network, scenario, model, solver and reductors. The tests component is a collection of test scripts probing primarily model reduction for various networks. A typical test contains two calls to the main morgen function. The first call computes the reduced order model (offline phase): morgen(network,training_scenario,model,solver,reductors); which computes a ROM from a short, generic, steady-state training_scenario. The projectors defining the reduced order models are then stored in rom_files. The second call tests the reduced order model(s) on a longer test_scenario (online phase): morgen(network,test_scenario,model,solver,rom_files); Generally, a model reduction method can also be tested in a single call, disregarding that scenario’s boundary value time series, yet for productive use, a reduced order model is constructed once (first call), and then employed for many different scenarios (second call).

Included in morgen are two types of tests: First, tests prefixed with “sim_” only simulate the test scenarios, second, tests prefixed with “mor_” compute the reduced order models using training scenarios, and benchmark these ROMs on the test scenarios.

6 Numerical experiments

In the following, we present three sets of numerical experiments, with the purpose of demonstrating the reducibility of gas network models via the data-driven, parametric, system-theoretic model order reduction algorithms from Sect. 4, and illustrating the capabilities of the morgen framework summarized in Sect. 5. The first set uses a pipeline “network”, which is interesting in the context of model reduction, while the second set tests an academic toy network as a sanity check and a simple functionality test. Lastly, a realistic gas network topology is evaluated.

We note that various further networks are included for testing in morgen; among others: the Canvey-Leeds network [55, 79], the Belgium transport network [31, 95] and a part of the Fermaca network [114]. A synthetic pipeline model and associated simulation results were provided by the PSI Software AG for validation of morgen against the commercial PSIganesiFootnote 12 solver.

6.1 Workflow

For each of the numerical tests, the same workflow is employed, which is composed of a training phase (offline phase), in that the ROMs are computed, using a generic test scenario, with a (virtual) time horizon of 1 h, and boundary value input functions typical for system identification, i.e. Dirac impulse, step signal, random-binary signal or Gaussian noise [100, Ch. 16]. In the test phase (online phase), the ROMs are tested on scenarios with a (virtual) time horizon of 24 h [27, 90], (starting at 6 am [40]). In addition to shorter offline phases, this difference in training and test time horizons emphasizes generality of the ROMs.

To verify models and solvers [107] this offline/online procedure is performed for all combinations of:

Models:

ode_mid, ode_end;

Solvers:

imex1, imex2;

Reductors:

pod_r, eds_ro, eds_wx, eds_wz, bpod_ro, ebt_ro, ebt_wx, ebt_wz, gopod_r, ebg_ro, ebg_wx, ebg_wz, dmd_r;

whereas the port-Hamiltonian ode_end model is tested with the nonlinear as well as the linear reductor variant (_l suffix) if available, while the ode_mid model is only tested with the nonlinear reductor variant.

The models are specialized by the Schifrinson friction, and the AGA88 compressibility factor formula. We excluded the generic and rk4 solvers in this comparison as they are too slow or too fragile, respectively. Yet, the test scenario visualizations in Fig. 4(a) and Fig. 6(a) are computed by the generic solver.

For the parametric model reduction, the temperature range for training and testing is set to \([0^{\circ },15^{\circ }]\text{C}\), while the specific gas constant range is chosen as \([500,600]\frac{\text{J}}{\text{kg}\,\text{K}}\). During training, samples from the parameter space are drawn from a sparse grid, whereas for the tests, parameters are drawn from a uniform random distribution. For either test and training, five parameters are sampled. The input perturbations for the steady-state training scenario are selected to be a step function, which heuristically works well for hyperbolic systems [49].

The reduced order models are compared via the approximate, discrete, parametric, \((L_{2} \otimes L_{2})\)-norm of the output error [67]:

$$\begin{aligned} \Vert y - \tilde{y} \Vert _{L_{2} \otimes L_{2}} \approx \sqrt{\sum _{ \theta _{h} \in \Theta _{h}} \Delta t \bigl\Vert \operatorname{vec} \bigl(y_{h}( \theta _{h}) - \tilde{y}_{h}( \theta _{h}) \bigr) \bigr\Vert _{2}^{2}}, \end{aligned}$$

for a finite sample \(\Theta _{h}\) of the parameter space Θ and discrete output samples \(y_{h}(\theta _{h})\), \(\tilde{y}_{h}(\theta _{h})\). This energy norm is chosen, since all methods are at least related to an energy-based method. However, morgen can also provide the errors in the approximate parametric \((L_{k} \otimes L_{\ell })\) parameter-space-state-space norms for \(k \in \{1,2,\infty \}\), \(\ell \in \{0,1,2,\infty \}\), cf. [50]. Note, that due to nonlinearity of the considered models, and the averaging nature of the norm, a monotonic error decay cannot be expected. To enhance comparability of the results, also the reducibility measure MORscore [67] for each experiment is computed. The MORscore for a certain method and model is essentially the area above the method’s error graph in the relative error plot such as Fig. 4(c).

Lastly, we note that the following numerical experiments are conducted using a computer with an AMD Ryzen 4500U @ 2.3Ghz hexa-core processor and 16 GiB memory running MATLAB 2021a on Ubuntu 20.04 Linux.

6.2 Yamal-Europe pipeline

First, a pipeline is tested, which is an interesting test case, since the trivial topology (Fig. 3) comprises little redundancy, hence pipelines are a useful benchmark for model reduction methods.

Figure 3
figure 3

Pipeline topology

The Yamal-Europe pipeline connects gas fields in Russia with western Europe.Footnote 13 A section of this pipeline was also benchmarked in [19, 24, 25, 107], from which the technical properties and test scenario are taken. The considered pipeline section is 363 km long, has a diameter of 1.422 m, no (reported) inclination, and a pipe roughness of 0.01 mm. A steady-state, used as initial state, is set by a supply pressure of 84 bar and demand mass-flux of \(46.3\frac{\text{kg}}{\text{s}}\).

The semi-discrete nonlinear state-space system has two inputs and outputs as well as 908 states; and a time step width of 20 s is used. The employed test scenario is taken from [25], compressed to 24 h, and shown in Fig. 4(a), the associated model reduction errors are given in Fig. 4(c), Fig. 4(d), Fig. 4(e), and Fig. 4(f), for up to reduced order 150, while the resulting MORscores are listed in Table 5.

Figure 4
figure 4

Visualization of the test scenario, and model reduction errors of the tested ROMs for the Yamal-Europe pipeline from Sect. 6.2

Table 5 MORscores \(\mu (150,\epsilon _{\operatorname{mach}(16)})\) in the \(L_{2} \otimes L_{2}\) error norm for the “Yamal-Europe” pipeline network from Sect. 6.2; * notes linear reductors

Generally, the choice of solver is more relevant than the choice of model: while the MORscores for different models but same solver are similar, for the same model but different solver, they are significantly dissimilar. Also, the tested balancing (Petrov-Galerkin) methods perform worse than the Galerkin methods.

For both models, and the first-order IMEX solver, the structured empirical dominant subspaces methods perform best, followed (closely) by the DMD-Galerkin and (goal-oriented) POD method; then, among the balancing methods, the balanced POD and cross-Gramian-based variants. The most overall accurate method is the cross-Gramian-based dominant subspaces method.

For both models, in combination with the second-order IMEX-RK solver, the structured POD and goal-oriented methods lead, followed by the DMD-Galerkin reductor. For both solvers, the endpoint model performs better than the midpoint model. In case of the port-Hamiltonian endpoint model, the linear Galerkin reductors are about as accurate as the nonlinear Galerkin reductors.

We note that the cross-Gramian-based dominant subspaces methods produce the lowest errors, and since for the linear reductors used in combination with the endpoint model, the dominant subspaces methods are as efficient as the purely reachability-based DMD-Galerkin, and (goal-oriented) POD methods.

Interestingly, while the second-order IMEX-RK solver is better suited for simulations of the full order model, in terms of data-driven model reduction and/or reduced order model simulation it is significantly worse than the first-order IMEX solver. This is also demonstrated in the subsequent experiments.

6.3 MORGEN network

The second set of tests encompasses a synthetic network for testing morgen’s capabilities. This “MORGEN” network, with topology as in Fig. 5, tests the interaction of simplified compressors from Sect. 2.5 for various network features, such as cycles, multiple supply and demand nodes, and is in the spirit of a test network from [39].

Figure 5
figure 5

MORGEN network topology

Specifically, six sub-networks (in the shape of letters) are connected, the second and third sub-network contain a cycle, a compressor connects the third and fourth sub-network, and the fourth and fifth sub-network contain additional supply and demand nodes. The edges vary in length between 20 km and 60 km, while the diameter and roughness are consistently 1 m and 0.01 mm, respectively. A steady-state, used as initial state, is set by supply (and discharge) pressures of 50 bar at both supply nodes and the compressor, and demand mass-fluxes of \(30\frac{\text{kg}}{\text{s}}\) at all demand nodes.

In semi-discrete form, the nonlinear state-space system features six inputs and outputs as well as 901 states; and a time discretization with 60 s time steps. The employed 24 h test scenario is made from hourly standard load profiles [60] and shown in Fig. 6(a), the associated model reduction errors are given in Fig. 6(c), Fig. 6(d), Fig. 6(e), and Fig. 6(f), for up to reduced order 200, while the resulting MORscores are listed in Table 6.

Figure 6
figure 6

Visualization of the test scenario, and model reduction errors of the tested ROMs for the MORGEN network from Sect. 6.3

Table 6 MORscores \(\mu (200,\epsilon _{\operatorname{mach}(16)})\) in the \(L_{2} \otimes L_{2}\) error norm for the “MORGEN” test network from Sect. 6.3; * notes linear reductors

Again for this comparison, the choice of solver is more relevant than the choice of model, yet the MORscores are much lower, due to the complexities (cycles, compressor, multiple demands) of the network.

Both models in conjunction with the first-order IMEX solver only produce workable results with Galerkin methods. The endpoint ROMs are again more accurate than the midpoint ROMs. Notably, the linear reachability-and-observability dominant subspaces method for the endpoint model, is leading the MORscores.

The ROMs for both models with the second-order IMEX-RK solver perform worse, with the exception of the balanced truncation ebt_ro and balanced gains ebg_ro variants. However, the second-order IMEX-RK solver related ROMs are of no practical use due to the high(er) error.

Overall, the (linear) eds_ro dominant subspaces reductor produces the lowest error, followed by the DMD-Galerkin, (goal-oriented) POD, and cross-Gramian-based dominant subspaces methods. As for the pipeline, the endpoint model is better suited for model reduction, while the first-order IMEX solver results in significantly more accurate ROMs than the second-order IMEX-RK solver.

6.4 GasLib network

Lastly, a network topology derived from real-life is tested. The GasLib-134v2 network [122], modeling a part of the Greek natural gas transport system, is overlayed on a map of Greece in Fig. 7. The network has a total length of 1412 km and features a compressor. A steady-state, used as initial state, is set by supply (and discharge) pressures of 80 bar at supply nodes and the compressor, and demand mass-fluxes up to \(16\frac{\text{kg}}{\text{s}}\) at all demand nodes.

Figure 7
figure 7

GasLib134v2 network topology modeling a part of the Greek gas network (taken from https://gaslib.zib.de, licensed under CC-BY)

In semi-discrete form, the nonlinear state-space system has 48 inputs and outputs as well as 2682 states; and 30 s time steps are employed. For testing, a random (24 h) load profile is generated, by adding samples from a scaled uniform random distribution to the steady-state,Footnote 14 shown in Fig. 8(a), the associated model reduction errors are given in Fig. 8(c), Fig. 8(d), Fig. 8(e), and Fig. 8(f), for up to reduced order 250, while the resulting MORscores are listed in Table 7.

Figure 8
figure 8

Visualization of the test scenario, and model reduction errors of the tested ROMs for the GasLib-134v2 network from Sect. 6.4

Table 7 MORscores \(\mu (250,\epsilon _{\operatorname{mach}(16)})\) in the \(L_{2} \otimes L_{2}\) error norm for the “GasLib-134v2” benchmark network from Sect. 6.4; * notes linear reductors

As before, the choice of solver is more relevant than the choice of model. Challenges in this network, beyond the compressor, are the high number of boundary nodes, which are predominantly demand nodes (\(N_{d} = 45\)).

First, we note that only Galerkin methods produce consistently stable ROMs. Furthermore, in comparison with the previous experiments, the dominant subspace methods perform worse, and all variants based on reachability and observability Gramians perform relatively better. The endpoint model seems to be better suited for the tested model reduction methods than the midpoint model. And as for the other experiments, the first order IMEX solver outmatches the second order IMEX-RK solver.

Considering all experiments, the DMD-Galerkin method performs best in terms of MORscore, accuracy and efficiency, followed by the dominant subspaces methods. We also note that the purely reachability-based as well as the linear reductors exploiting the port-Hamiltonian structure are the most efficient. Surprisingly, Galerkin methods perform better than the tested Petrov-Galerkin methods in terms of accuracy and stability, while in an unstructured, non-parametric, linearized setting all tested Petrov-Galerkin methods would be stability preserving. Yet, structured balancing methods are explicitly not guaranteed to be stability-preserving [120, 136].

With regard to the computational complexity of the offline and online phase, we reiterate, that due to the absence of hyper-reduction, the online runtimes are not competitive (see Sect. 3.3), thus, we focus on the offline phase. Yet, due to the practical reducibility of the state-space dimension by more than one order of magnitude in the numerical experiments using the first order IMEX solver, a considerable speed-up is to be expected.

For the tested data-driven (time-domain) model reduction methods, the number of vector-field evaluations, or relatedly, the number of simulated trajectories measures the complexity, as these constitute their principal fraction. The empirical reachability Gramian requires \(N_{s} + N_{d}\) (number of ports) trajectories. The empirical observability Gramian requires \(N_{p} + N_{q}\) (number of states) trajectories. The empirical cross Gramian requires \(N_{s} + N_{d} + N_{p} + N_{q}\) trajectories, and the linear empirical cross Gramian requires \(2(N_{s} + N_{d})\) trajectories. For the tested reductors this amounts to \(N_{s} + N_{d}\) trajectories for the POD, goal-oriented POD, and DMD-Galerkin method, while the port-Hamiltonian variants of the dominant subspaces, balanced POD, balanced truncation and balanced gains methods need \(2(N_{s} + N_{d})\) trajectories, and their non-port-Hamiltonian variants require \(N_{s} + N_{d} + N_{p} + N_{q}\) trajectories.

These predicted complexities are reflected in the offline runtimes, when computed sequentially. As the computation of trajectories is embarrassingly parallel, all trajectories are however computable simultaneously. Nonetheless, the complexities of the reachability-Gramian-only and port-Hamiltonian reductors are independent from the discretization, and thus most relevant for large-scale gas networks.

7 Outlook

The next stage in the development of morgen involves testing larger real-life networks, such as the deliverable of the SciGRID_gasFootnote 15 (Open Source Model of the European Gas Network) project. Yet, various further venues of linked modeling and model reduction questions are still not covered by morgen.

In terms of model reduction, an interesting issue are intraday switchable valves, which change the topology of the gas network graph and likely require to extend the utilized model reduction methods towards these switched systems.

Another interesting question in need of further investigation is the minimal time horizon of the training phase. A lower bound is the time step times the longest path from a supply to a demand node, but this is likely not sufficient.

Besides an additional hyper-reduction module (Sect. 3.3) post-processing the reduced order models, a decoupler module pre-processing (DAE) models as described in [11, 12] is projected.

Also as detailed in Sect. 3.4, the pipe roughness is a relevant parameter for (transient) simulations [130], yet the entailing high-dimensional parameter space, due to the locally differing roughness and attrition rates, would have to be treated, too. This in turn would raise the question for combined state and parameter reduction [65], and is postponed to future investigations.

Finally, using a tunable efficiency factor [105, 107, 111] that scales the model’s friction term, can be used to tune the models to match real data.

8 Conclusions

In more than half a century of computational transient gas network simulation research and industrial use, morgen seems to be the first open-source platform covering modeling, simulation, and model order reduction of gas (and energy) networks. The target applications for morgen are finding the best model reduction method or best reduced order model for a network by heuristic comparison, as well as comparing model-solver-reductor simulation ensembles.

From a mathematical point of view, a next generation gas network simulation stack should consist of a (endpoint) port-Hamiltonian model, a (first-order) IMEX solver, and a block-diagonal Galerkin projection reductor, which is confirmed by the numerical results.

This results in the following heuristically determined but theoretically explainable recommended combination: The endpoint model together with the first-order IMEX solver, and a Galerkin reductor, specifically a structured dominant subspaces or structured DMD-Galerkin, exhibiting the highest MORscores in the numerical experiments. The performance of structured balanced truncation and the related structured balanced gains may be improved in terms of stability(-preservation) either by a variant of the technique [88], a stabilizing inner product [124], an (energy-)stable inner product [78], or an optimization-based post-processing as in [21].

Lastly, we invite researchers, engineers and users to provide their reductors, solvers, networks and scenarios for expansion and testing with morgen for a broader view of this comparison.