원시데이터 수집 시스템
선정목록으로

Efficient Numerical Methods for Gas Network Modeling and Simulation

관련 수소연료전지 · (7) MEA(막전극접합체)

기본 정보

저자
  1. Qiu Yue
  2. Grundel, Sara
  3. Stoll, Martin
  4. Benner, Peter
DOI
10.48550/arxiv.1807.07142
저널
arXiv (Cornell University)
발행년도
2022
발행기관
Cornell University
피인용수
0
라이선스
0
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.48550/arxiv.1807.07142
토픽
Membrane Separation and Gas Transport
OpenAlex ID
W6910592270

평가 내용

관련도
관련
사업분야
수소연료전지 · (7) MEA(막전극접합체)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '수소연료전지 > MEA(막전극접합체)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

We study the modeling and simulation of gas pipeline networks, with a focus on fast numerical methods for the simulation of transient dynamics. The obtained mathematical model of the underlying network is represented by a nonlinear differential algebraic equation (DAE). With our modeling, we reduce the number of algebraic constraints, which correspond to the $(2,2)$ block in our semi-explicit DAE model, to the order of junction nodes in the network, where a junction node couples at least three pipelines. We can furthermore ensure that the $(1, 1)$ block of all system matrices including the Jacobian is block lower triangular by using a specific ordering of the pipes of the network. We then exploit this structure to propose an efficient preconditioner for the fast simulation of the network. We test our numerical methods on benchmark problems of (well-)known gas networks and the numerical results show the efficiency of our methods.

본문 98,672자

본문 펼치기
## Efficient Numerical Methods for Gas Network Modeling and Simulation ∗ Yue Qiu <sup>†</sup>, Sara Grundel <sup>‡</sup>, Martin Stoll <sup>§</sup>, Peter Benner <sup>¶</sup> Abstract We study the modeling and simulation of gas pipeline networks, with a focus on fast numerical methods for the simulation of transient dynamics. The obtained mathematical model of the underlying network is represented by a nonlinear differential algebraic equation (DAE). With our modeling, we reduce the number of algebraic constraints, which correspond to the (2 _,_ 2) block in our semi-explicit DAE model, to the order of junction nodes in the network, where a junction node couples at least three pipelines. We can furthermore ensure that the (1 _,_ 1) block of all system matrices including the Jacobian is block lower triangular by using a specific ordering of the pipes of the network. We then exploit this structure to propose an efficient preconditioner for the fast simulation of the network. We test our numerical methods on benchmark problems of (well-)known gas networks and the numerical results show the efficiency of our methods. Keywords : gas networks modeling, isothermal Euler equation, directed acyclic graph (DAG), differential algebraic equation (DAE), preconditioning ### 1 Introduction Natural gas is one of the most widely used energy sources in the world, as it is easily transportable, storable and usable to generate heat and electricity. Even though research on the transient gas network dates back to the 1980s [1, 2], often only stationary solutions of the gas network are computed. This is also reasonable as the variation in a classically operated gas transportation networks enforces no need for a truly transient simulation. However as we move from classical energy sources to renewable energy sources in which we may use the gas pipelines to deal with flexibility from volatile energy creation, the need for fast transient simulation will increase. In recent years, research on natural gas networks focuses on a variety of topics: transient simulations [1–5], optimization and control [6–8], time splitting schemes for solving the parabolic flow equations [9], discretization methods [10, 11], and model sensitivity study [12] to mention a few. It is obvious that efficient simulation techniques are needed both for design and for control. The objective of this paper is to speed up the computations at the heart of each simulation. For that we make use of a discretization that respects the hyperbolic nature of the problem by using a finite volume method (FVM), as well as exploiting the network structure to create good properties for the computations. We start as it is standard for modeling gas transport in a pipeline by the one-dimensional isothermal Euler equation, which is a partial differential equation (PDE). ∗This work is funded by the European Regional Development Fund (ERDF/EFRE: ZS/2016/04/78156) within the Research Center Dynamic Systems: Systems Engineering (CDS). †Corresponding author. Max Planck Institute for Dynamics of Complex Technical Systems, SandtorStraße 1, 39108, Magdeburg, Germany. E-mail: qiu@mpi-magdeburg.mpg.de, y.qiu@gmx.us ‡Max Planck Institute for Dynamics of Complex Technical Systems, SandtorStraße 1, 39108, Magdeburg, Germany. E-mail: grundel@mpi-magdeburg.mpg.de §Technische Universit¨at Chemnitz, Faculty of Mathematics, Reichenhainer Straße 41, 09107 Chemnitz, Germany. E-mail: martin.stoll@mathematik.tu-chemnitz.de ¶Max Planck Institute for Dynamics of Complex Technical Systems, SandtorStraße 1, 39108, Magdeburg, Germany. E-mail: benner@mpi-magdeburg.mpg.de 1 We introduce the necessary discrete variables for the pressure and the flux on each pipe and make sure to use as little algebraic equations as possible when considering a network of pipes. By further exploiting the structure of the system, we propose a preconditioner that enables fast solution of such a nonlinear equation using a preconditioned Krylov solver at each Newton iteration. The structure of this paper is as follows. We introduce the incompressible isothermal Euler equation for the gas dynamics modeling of each pipeline of the network in Section 2, and we apply the finite volume method (FVM) to discretize the incompressible isothermal Euler equation in Section 2. In Section 3, we introduce the details of gas network modeling starting from assembling all pipelines. This results in a set of nonlinear DAEs for the network model. We propose numerical algorithms to solve the resulting nonlinear DAE in Section 4 to simulate the gas network. We use benchmark problems from gas pipeline networks to show the efficiency and the advantage of our numerical algorithms in Section 5, and we draw conclusions in the last section. ### 2 Gas Dynamics in Pipelines In a typical gas transport network the main components are pipelines (or pipes, for short). In this section, we will discuss the dynamics of gas transported along pipes. 2.1 1D Isothermal Euler Equation The dynamics of gas transported along pipes is described by the Euler equation, which represents the laws of mass conservation, momentum conservation, and energy conservation. In this paper, we assume that the temperature is constant throughout the gas network, leading to the isothermal Euler equations. Therefore, the energy equation can be neglected. This may seem unrealistic, but for onshore gas networks, in which the pipes are buried underground, the temperature along pipes does not change much. This assumption greatly reduces the complexity of modeling and is widely used in the simulation of gas networks [5, 13–16]. Consider the 1D isothermal Euler equation over the spatial domain [0 _,_ _L_ ] given by _<u>∂</u>_ (1a) _∂t_ <sup>_ρ_</sup> <sup>=</sup> <sup>_−_</sup> _∂x_ <sup>_<u>∂</u>_</sup> <sup>_ϕ,_</sup> _∂t∂_ <sup>_ϕ_</sup> <sup>=</sup> <sup>_−_</sup> _∂x_ <sup>_<u>∂</u>_</sup> _∂x_ <sup>_<u>∂</u>_</sup> <sup>(</sup> <sup>_ρv_</sup> <sup>2)</sup> <sup>_−_</sup> <sup>_gρ_</sup> _∂x_ <sup>_<u>∂</u>_</sup> _∂x_ <sup>_<u>∂</u>_</sup> <sup>_p −_</sup> _∂x_ <sup>_<u>∂</u>_</sup> _∂x_ <sup>_<u>∂</u>_</sup> <sup>_h −_</sup> <sup>_<u>λ</u>_</sup> 2 <sup><u>(</u></sup> <sup>_<u>ϕ</u>_</sup> _d_ <sup><u>)</u></sup> (1b) 2 <sup><u>(</u></sup> <sup>_<u>ϕ</u>_</sup> _d_ <sup><u>)</u></sup> <sup>_ρv|v|,_</sup> _p_ = _γ_ ( _T_ ) _z_ ( _p, T_ ) _ρ._ (1c) Here, _ρ_ is the density of the gas ( _kg/m_ <sup>3</sup> ), _ϕ_ represents the flow rate and _ϕ_ = _ρv_ with _v_ the velocity of the gas ( _m/s_ ), _d_ is the diameter of the pipe ( _m_ ), _λ_ is the friction factor of the gas. Meanwhile, _p_ denotes the pressure of the gas ( _N/m_ <sup>2</sup> ), _T_ is the temperature of the gas ( _K_ ), and _z_ denotes the compressibility factor. The conservation of mass is given by (1a), and the conservation of momentum is represented by (1b), while the state equation (1c) couples the pressure with the density. By using the mass flow _q_ = _aϕ_ to substitute into (1a)–(1b), where _a_ is the cross-section area of pipes, we get _<u>∂</u>_ _∂x_ <sup>_q,_</sup> (2a) _a_ <sup>2</sup> _∂x_ <sup>_<u>∂</u>_</sup> <sup>_h −_</sup> 2 <sup>_<u>λ</u>_</sup> _da_ <sup><u>(</u></sup> <sup>_<u>q</u>_</sup> <sup><u>)2</u></sup> _<u>q</u>_ <sup>2</sup> _<u>qρ</u>_ <sup>2</sup> <sup>_−_</sup> <sup>_gρ_</sup> _∂x_ <sup>_<u>∂</u>_</sup> 2 <sup>_<u>λ</u>_</sup> _da_ <sup><u>(</u></sup> <sup>_<u>q</u>_</sup> <sup><u>)2</u></sup> _<u>q|ρq|</u>_ _ρ_ <sup>_,_</sup> (2b) <u>1</u> _a_ _∂t∂_ <sup>_ρ_</sup> <sup>=</sup> <sup>_−_</sup> _a_ <sup><u>1</u></sup> _∂t∂_ <sup>_q_</sup> <sup>=</sup> <sup>_−_</sup> _∂x_ <sup>_<u>∂</u>_</sup> _∂x_ <sup>_<u>∂</u>_</sup> <sup>_p −_</sup> _a_ <sup><u>12</u></sup> _<u>∂</u>_ _∂x_ _p_ = _γ_ ( _T_ ) _z_ ( _p, T_ ) _ρ._ (2c) For the isothermal case, the temperature _T_ equals _T_ 0 throughout the network, then _γ_ ( _T_ ) = _γ_ ( _T_ 0) = _γ_ 0, and _z_ ( _p, T_ ) = _z_ ( _p, T_ 0) = _z_ 0( _p_ ). Therefore, the compressibility factor _z_ ( _p, T_ ) is only related to 2 the pressure _p_ and we can rewrite (2a)–(2c) as <u>1</u> _γ_ 0 _<u>∂</u>_ _∂t_ _<u>p</u>_ _z_ 0( _p_ ) <sup>=</sup> <sup>_−_</sup> _a_ <sup><u>1</u></sup> _<u>p</u>_ _z_ 0( _p_ ) <sup>=</sup> <sup>_−_</sup> _a_ <sup><u>1</u></sup> _<u>∂</u>_ _∂x_ <sup>_q,_</sup> (3a) _−_ <sup>_<u>g</u>_</sup> <sup>_<u>g</u>_</sup> _<u>p</u>_ _<u>∂</u>_ _γ_ 0 _z_ 0( _p_ ) _∂x_ <sup>_h_</sup> <u>�</u> <u>��</u> <u>�</u> gravity term <u>1</u> _a_ _∂t∂_ <sup>_q_</sup> <sup>=</sup> <sup>_−_</sup> _∂x_ <sup>_<u>∂</u>_</sup> _∂x_ <sup>_<u>∂</u>_</sup> <sup>_p −_</sup> _a_ <sup>_<u>γ</u>_</sup> <sup><u>02</u></sup> _a_ <sup>2</sup> _a_ <sup>2</sup> _∂x_ _p_ <u>�</u> <u>��</u> <u>�</u> inertia term _<u>q</u>_ <sup>2</sup> _<u>z</u>_ <u>0(</u> _<u>p</u>_ <u>)</u> _−_ <sup>_<u>λ</u>_</sup> 2 <sup><u>(</u></sup> _da_ <sup>_<u>q</u>_</sup> <sup><u>)</u></sup> <sup>_<u>γ</u>_</sup> <sup>20</sup> <sup>_z_</sup> <sup>0(</sup> <sup>_p_</sup> <sup>)</sup> <sup>_<u>q|</u>_</sup> _p_ <sup>_<u>q|</u>_</sup> - <u>��</u> friction term _<u>∂</u>_ _∂x_ _γ_ 0 _<u>p</u>_ _z_ 0( _p_ ) _._ (3b) For the inertia term, it is studied in [13] that <sup>_<u>∂</u>_</sup> _∂x_ <sup>_p._</sup> _<u>γ</u>_ <u>0</u> _a_ <sup>2</sup> _<u>∂</u>_ _∂x_ _<u>q</u>_ <sup>2</sup> _<u>z</u>_ <u>0(</u> _<u>p</u>_ <u>)</u> _<u>z</u>_ <u>0(</u> _<u>p</u>_ <u>)</u> _≈_ 10 <sup>_−_</sup> <sup>3</sup> <sup>_<u>∂</u>_</sup> _p_ _∂x_ Therefore, the inertia term can be neglected and this neglection greatly simplifies the model, which is standard in the study of gas networks [4, 7, 8]. In this paper, we also use this simplification. Meanwhile, we will often assume that the elevation of pipes is homogeneous. The gravity term in (3b) then vanishes. However this term is easily treatable within our framework, which we will illustrate later in this section. Now, we get the model that describes the dynamics of isothermal gas transported along homogeneous elevation pipes given by _<u>∂</u>_ _∂x_ <sup>_q,_</sup> (4a) _<u>∂</u>_ _∂t_ _<u>p</u>_ _z_ 0( _p_ ) <sup>=</sup> <sup>_−_</sup> <sup>_<u>γ</u>_</sup> _a_ <sup><u>0</u></sup> _∂t∂_ <sup>_q_</sup> <sup>=</sup> <sup>_−a_</sup> _∂x_ <sup>_<u>∂</u>_</sup> _∂x_ <sup>_<u>∂</u>_</sup> <sup>_p −_</sup> <sup>_<u>λ</u>_</sup> <sup><u>(</u></sup> 2 <sup>_<u>q</u>_</sup> _da_ <sup><u>)</u></sup> <sup>_<u>γ</u>_</sup> <sup><u>0</u></sup> (4b) <sup><u>(</u></sup> 2 <sup>_<u>q</u>_</sup> _da_ <sup><u>)</u></sup> <sup>_<u>γ</u>_</sup> <sup><u>0</u></sup> <sup>_z_</sup> <sup>0(</sup> <sup>_p_</sup> <sup>)</sup> <sup>_<u>q|</u>_</sup> _p_ <sup>_<u>q|</u>_</sup> <sup>_._</sup> The details of modeling the compressibility factor _z_ 0( _p_ ) and the friction factor _λ_ ( _q_ ) are described in [17]. 2.2 Finite Volume Discretization In this paper, the dynamics of the gas transported along pipes are described by the 1D isothermal incompressible Euler equation ( _z_ 0( _p_ ) = 1) over the spatial domain [0 _,_ _L_ ] with homogeneous elevation. According to (4a)–(4b) we have _∂t∂_ <sup>_p_</sup> <sup>+</sup> _a_ <sup>_<u>c</u>_</sup> _<u>∂</u>_ _∂x_ <sup>_q_</sup> <sup>= 0</sup> <sup>_,_</sup> (5a) _∂t∂_ <sup>_q_</sup> <sup>+</sup> <sup>_a_</sup> _∂x_ <sup>_<u>∂</u>_</sup> 2 <sup>_<u>cλ</u>_</sup> _da_ _<u>q|pq|</u>_ _∂x_ <sup>_<u>∂</u>_</sup> <sup>_p_</sup> <sup>+</sup> 2 <sup>_<u>cλ</u>_</sup> _da_ = 0 _._ (5b) _p_ For simplification of notation we introduce _c_ = _γ_ 0 and we also assume _λ_ ( _q_ ) _≡_ _λ_ . The system (5a)– (5b) is nonlinear due to the friction term. For gas transportation pipes, the boundary condition at the inflow point _x_ = 0 is given by the prescribed pressure _ps_, while the boundary condition at the outflow point _x_ = _L_ is represented by the given mass flow (gas demand) _qd_ . Therefore, the boundary conditions for (5a)–(5b) are given as _p_ = _ps,_ at _x_ = 0 _,_ (6) _q_ = _qd,_ at _x_ = _L._ For the well-posedness and the regularity of the solution of the system (5)–(6), we refer to [18]. More advanced numerical schemes for hyperbolic PDEs, such as the total variation diminishing (TVD) method [19], or the discontinuous Galerkin method (DG) [20], could be implemented at the next step of our research to investigate more complicated dynamics of the gas networks. The scope of our paper is to develop a systematic numerical methodology for the fast simulation of the network dynamics while taking numerical accuracy into account. For such an FVM discretization, we partition the domain as shown in Figure 1. 3 e w Figure 1: finite volume cells partition In Figure 1, the left boundary of the control volume is denoted by ‘e’ while the right boundary of the control volume is denoted by ‘w’. For the isothermal incompressible Euler equation (5a)– (5b), we have two variables, i.e., the pressure _p_, and the mass flow _q_ . Together with the boundary condition (6), we use two different control volume partitions for the pressure and mass flow nodes, which are shown in Figure 2. e w (a) control volumes partition for _p_ <u>e</u> w (b) control volumes partition for _q_ Figure 2: control volumes partition for _p_ and _q_ To apply the FVM to discretize the PDE and the boundary condition, we integrate (5a)–(5b) over each control volume. To be specific, we integrate (5a) over the pressure control volume in Figure 2(a), and integrate (5b) over the mass flow control volume in Figure 2(b). To integrate (5a) over the _i_ -th control pressure control volume _Ci_, we have _Ci_ - _∂tp_ + <sup>_<u>c</u>_</sup> _a_ <sup>_∂xq_</sup> - _∂tp_ + <sup>_<u>c</u>_</sup> _a_ _dx_ = 0 _._ The discretization point in _Ci_ is either a virtual node along a pipe or a real node that connects two different pipes. Therefore, the coefficient _a_ of the PDE (5a)–(5b), which represents the crosssection area of a pipe, may have a sudden change at the node in control volume _Ci_ . Here, we use _Ci_ <sup>_−_</sup> and _Ci_ <sup>+</sup> to partition the control volume _Ci_ with _Ci_ = _Ci_ <sup>_−_</sup> <sup>_∪_</sup> <sup>_C_</sup> _i_ <sup>+,</sup> <sup>and</sup> <sup>the</sup> <sup>lengths</sup> <sup>of</sup> <sup>_C_</sup> _i_ <sup>_−_</sup> and _Ci_ <sup>+</sup> <sup>are</sup> <sup>_<u>hi</u>_</sup> 2 <sup>_<u>−</u>_</sup> <sup><u>1</u></sup> and <sup>_<u>h</u>_</sup> 2 <sup>_<u>i</u>_</sup> <sup>,</sup> <sup>respectively.</sup> <sup>This</sup> <sup>partition</sup> <sup>is</sup> <sup>shown</sup> <sup>in</sup> <sup>Figure</sup> <sup>3.</sup> _i_ <sup>+</sup> to partition the control volume _Ci_ with _Ci_ = _Ci_ <sup>_−_</sup> _i_ <sup>+,</sup> <sup>and</sup> <sup>the</sup> <sup>lengths</sup> <sup>of</sup> <sup>_C_</sup> _i_ <sup>_−_</sup> _i_ <sup>_−_</sup> and _Ci_ <sup>+</sup> _i_ <sup>+</sup> <sup>are</sup> <sup>_<u>hi</u>_</sup> 2 <sup>_<u>−</u>_</sup> <sup><u>1</u></sup> 2 <sup>_<u>i</u>_</sup> <sup>,</sup> <sup>respectively.</sup> <sup>This</sup> <sup>partition</sup> <sup>is</sup> <sup>shown</sup> <sup>in</sup> <sup>Figure</sup> <sup>3.</sup> 2 <sup>_<u>−</u>_</sup> <sup><u>1</u></sup> and <sup>_<u>h</u>_</sup> 2 <sup>_<u>i</u>_</sup> _i_ <sup>_−_</sup> <sup>_∪_</sup> <sup>_C_</sup> _i_ <sup>+</sup> Figure 3: Separation of control volume _Ci_ Therefore, we get _Ci_ _Ci_ <sup>+</sup> _<u>c</u>_ _a_ <sup>_∂xq_</sup> <sup>_dx_</sup> <sup>= 0</sup> <sup>_._</sup> _∂tp_ _dx_ + _Ci_ <sup>_−_</sup> _<u>c</u>_ _a_ <sup>_∂xq_</sup> <sup>_dx_</sup> <sup>+</sup> Furthermore, by applying the midpoint rule, we get - + <sup>_<u>c</u>_</sup> _ai_ - _<u>qi</u>_ <u>+</u> _<u>qi</u>_ <u>+1</u> _−_ _qi_ 2 = 0 _,_ _<u>hi−</u>_ <u>1 +</u> _<u>hi</u>_ _<u>c</u>_ _∂tpi_ + 2 _ai−_ 1 - _qi −_ <sup>_<u>qi−</u>_</sup> <sup><u>1 +</u></sup> <sup>_<u>qi</u>_</sup> 2 i.e., - <u>1</u> _−_ <sup><u>1</u></sup> 2 _ai−_ 1 2 _ai_ - <u>1</u> _−_ <sup><u>1</u></sup> 2 _ai−_ 1 2 _a_ _qi_ + <sup><u>1</u></sup> _qi_ +1 2 _ai_ = 0 _,_ (7) _<u>hi−</u>_ <u>1 +</u> _<u>hi</u>_ _∂tpi_ + _c_ 2 - <u>1</u> _−_ _qi−_ 1 + 2 _ai−_ 1 - _qi_ + <sup><u>1</u></sup> where _pi_ and _qi_ are the values at the center of the control volume for _i_ = 2 _, . . ., n −_ 1. Similarly, for the rightmost control volume of the pressure in Figure 2(a), we have _Cn_ <sup>_−_</sup> _<u>c</u>_ <sup>_<u>n−</u>_</sup> <sup><u>1</u></sup> _∂tpn_ + ( _qn −_ _qn−_ 1) = 0 _,_ (8) 8 2 _an−_ 1 - _∂tp_ + <sup>_<u>c</u>_</sup> _a_ <sup>_∂xq_</sup> - _dx ≈_ <sup>_<u>hn−</u>_</sup> <sup><u>1</u></sup> <sup>_<u>n−</u>_</sup> <sup><u>1</u></sup> _∂tpn−_ 1 + <sup><u>3</u></sup> <sup>_<u>hn−</u>_</sup> <sup><u>1</u></sup> 8 8 where _pn_ and _qn_ are the values at the end of the pipe. For the _i_ -th mass flow control volume _Ci_ shown in Figure 2(b), we integrate (5b) over it and get _Ci_ ( _∂tq_ + _a∂xp_ ) _dx_ = _−_ <sup>_<u>c</u>_</sup> 2 4 _<u>λ</u>_ _<u>q|q|</u>_ _dx._ _ad_ _p_ _Ci_ Applying the same partition of _Ci_ as in Figure 3, we have, _Ci_ ( _∂tq_ + _a∂xp_ ) _dx_ = ( _∂tq_ + _a∂xp_ ) _dx_ + _Ci_ <sup>_−_</sup> _Ci_ <sup>+</sup> ( _∂tq_ + _a∂xp_ ) _dx_ <sup>_<u>i−</u>_</sup> <sup><u>1</u></sup> _∂tqi_ + <sup>_<u>ai−</u>_</sup> <sup><u>1</u></sup> 2 2 <sup>_<u>h</u>_</sup> 2 <sup>_<u>i</u>_</sup> <sup>_∂tqi_</sup> <sup>+</sup> <sup>_<u>a</u>_</sup> 2 <sup>_<u>i</u>_</sup> <sup>(</sup> <sup>_pi_</sup> <sup>+1</sup> <sup>_−_</sup> <sup>_pi_</sup> <sup>)</sup> _≈_ <sup>_<u>hi−</u>_</sup> <sup><u>1</u></sup> <sup>_<u>i−</u>_</sup> <sup><u>1</u></sup> ( _pi −_ _pi−_ 1) + <sup>_<u>hi</u>_</sup> 2 2 <sup><u>1</u></sup> <sup>_<u>−</u>_</sup> <sup>_<u>ai</u>_</sup> _pi_ + <sup>_<u>ai</u>_</sup> 2 2 <sup>_<u>i</u>_</sup> 2 <sup>_pi_</sup> <sup>+1</sup> = <sup>_<u>hi−</u>_</sup> <sup><u>1 +</u></sup> <sup>_<u>hi</u>_</sup> _∂tqi_ + 2 = <sup>_<u>hi−</u>_</sup> <sup><u>1 +</u></sup> <sup>_<u>hi</u>_</sup> - _−_ <sup>_<u>ai−</u>_</sup> <sup><u>1</u></sup> <sup>_<u>−</u>_</sup> <sup><u>1</u></sup> _pi−_ 1 + <sup>_<u>ai−</u>_</sup> <sup><u>1</u></sup> <sup>_<u>−</u>_</sup> <sup>_<u>ai</u>_</sup> 2 2 _,_ and _Ci_ + <sup>_<u>hiλi</u>_</sup> _aidi_ - _<u>qi|qi|</u>_ _pi_ _<u>q|q|</u>_ _<u>λ</u>_ _ad_ _<u>|q|</u>_ _dx ≈_ <sup><u>1</u></sup> _p_ 2 2 _._ - _<u>hi−</u>_ <u>1</u> _<u>λi−</u>_ <u>1</u> _ai−_ 1 _di−_ 1 + <sup>_<u>hiλi</u>_</sup> Therefore, for the _i_ -th mass flow control volume _Ci_, we have + <sup>_<u>hiλi</u>_</sup> _aidi_ <sup>_<u>−</u>_</sup> <sup>_<u>ai</u>_</sup> _pi_ + <sup>_<u>ai</u>_</sup> 2 2 - _<u>hi−</u>_ <u>1</u> _<u>λi−</u>_ <u>1</u> _ai−_ 1 _di−_ 1 _._ (9) <sup>_<u>i</u>_</sup> 2 <sup>_pi_</sup> <sup>+1</sup> _<u>hi−</u>_ <u>1 +</u> _<u>hi</u>_ _∂tqi_ + 2 - _−_ <sup>_<u>ai−</u>_</sup> <sup><u>1</u></sup> <sup>_<u>i−</u>_</sup> <sup><u>1</u></sup> _pi−_ 1 + <sup>_<u>ai−</u>_</sup> <sup><u>1</u></sup> <sup>_<u>−</u>_</sup> <sup>_<u>ai</u>_</sup> 2 2 - = _−_ <sup>_<u>c</u>_</sup> 4 - = _−_ <sup>_<u>c</u>_</sup> - _<u>qi|qi|</u>_ _pi_ Similarly, for the leftmost mass flow control volume, we get <u>3</u> _<u>h</u>_ 81 <sup>_∂tq_</sup> <sup>1 +</sup> <sup>_<u>h</u>_</sup> 8 <sup><u>2</u></sup> <sup>_∂tq_</sup> <sup>2 +</sup> <sup>_<u>a</u>_</sup> 2 <sup><u>1</u></sup> <sup>(</sup> <sup>_−p_</sup> <sup>1 +</sup> <sup>_p_</sup> <sup>2) =</sup> <sup>_−_</sup> <sup>_<u>ch</u>_</sup> 4 _a_ <sup><u>1</u></sup> 1 <sup>_<u>λ</u>_</sup> _d_ 1 <sup><u>1</u></sup> _<u>q</u>_ <u>1</u> _<u>|q</u>_ <u>1</u> _<u>|</u>_ _p_ 1 _._ (10) where _p_ 1 and _q_ 1 are the values at the beginning of the pipe. Associating (7)–(10) with the boundary condition (6), we get = - _Mp_ _Mq_ - _∂tp_ _∂tq_ <u>�</u> - 0 _Kpq_ _Kqp_ 0 - _p_ + _q_ right BC <u>����</u> <u>�</u> _Bq_ <u>�</u> _qd_ 0 <u>�</u> _qd_ + left BC - <u>���</u> <u>�</u> 0 <u>�</u> _ps_ _Bp_ _ps_ + - 0 _,_ (11) _g_ ( _ps, p, q_ ) <u>�</u> �� _M_ - <u>��</u> <u>�</u> _K_ <u>����</u> _Bq_ where the mass matrices _Mp_ and _Mq_ are given by - <u>��</u> <u>�</u> _Bp_  <u>3</u> _<u>h</u>_ <u>1</u> _<u>h</u>_ <u>1</u> 8 8 _<u>h</u>_ <u>1+</u> _<u>h</u>_ <u>2</u> 2 _<u>h</u>_ <u>2+</u> _<u>h</u>_ <u>3</u> 2  ...    _<u>h</u>_ <u>1+</u> _<u>h</u>_ <u>2</u> 2 _<u>h</u>_ <u>2+</u> _<u>h</u>_ <u>3</u> 2 ... _<u>hn−</u>_ <u>2+</u> _<u>hn−</u>_ <u>1</u> 2 _<u>hn−</u>_ <u>1</u> <u>3</u> _<u>hn−</u>_ <u>1</u> 8 8 _Mp_ = and    _−_ <sup><u>1</u></sup> _,_  _,_ _Mq_ =  _<u>hn−</u>_ <u>2+</u> _<u>hn−</u>_ <u>1</u> 2 _a_ 1 <u>1</u> _a_ 1 <sup>_−_</sup> _a_ <sup><u>1</u></sup> 2 <u>1</u> <sup>_−_</sup> _a_ <sup><u>1</u></sup> 2 _a_ 2 _−_ <sup><u>1</u></sup> _a_ <u>12</u> <sup>_−_</sup> _a_ 2 <u>1</u> _a_ 2 <sup>_−_</sup> _a_ <sup><u>1</u></sup> 3 <u>1</u> <sup>_−_</sup> _a_ <sup><u>1</u></sup> 3 _a_ 3 ... ... ... _−_ <u>1</u> <u>1</u> _an−_ 3 _an−_ 3 <sup>_−_</sup> _a_ 2 _a_ 3 _Kpq_ = _−_ <sup>_<u>c</u>_</sup> 2  <u>1</u> <u>1</u> _an−_ 3 <sup>_−_</sup> _an−_ 2 <u>1</u> <u>1</u> _−_ 3 <sup>_−_</sup> _an−_ 2 _an−_ 2 _−_ <u>1</u> <u>1</u> _an−_ 2 _an−_ 2 <sup>_−_</sup> _a_ <u>1</u> <u>1</u> _an−_ 2 <sup>_−_</sup> _an−_ 1 _−_ <u>1</u> _an−_ 1  _,_ is an upper-triangular matrix with 3 diagonals and    _Kqp_ = _−_ <sup><u>1</u></sup> 2  _a_ 1 _a_ 1 _−_ _a_ 2 _a_ 2 _−a_ 2 _a_ 2 _−_ _a_ 3 _a_ 3 _−a_ 3 _a_ 3 _−_ _a_ 4 _a_ 4 ... ... ... _−an−_ 2 _an−_ 2 _−_ _an−_ 1 _an−_ 1 _,_ 5 is a lower-triangular matrix with 3 diagonals. Meanwhile, _<u>h</u>_ <u>1</u> _<u>λ</u>_ <u>1</u> _a_ 1 _d_ 1 _<u>q</u>_ <u>1</u> _<u>|q</u>_ <u>1</u> _<u>|</u>_ 0 ... 0 <u>1</u> _an−_ 1 <u>1</u> _an−_ 1       <sup>_<u>h</u>_</sup> _a_ <sup>_<u>n</u>_</sup> _n_ <sup>_<u>−</u>_</sup> _−_ <sup><u>2</u></sup> 2 <sup>_<u>λ</u>_</sup> _dn_ <sup>_<u>n</u>_</sup> _−_ <sup>_<u>−</u>_</sup> 2 <sup><u>2</u></sup> <sup>+</sup> <sup>_<u>h</u>_</sup> _a_ <sup>_<u>n</u>_</sup> _n_ <sup>_<u>−</u>_</sup> _−_ <sup><u>1</u></sup> 1 <sup>_<u>λ</u>_</sup> _dn_ <sup>_<u>n</u>_</sup> _−_ <sup>_<u>−</u>_</sup> 1 <sup><u>1</u></sup> _a_ 1 _d_ 1 _ps_ ( <sup>_<u>h</u>_</sup> _a_ <sup><u>1</u></sup> 1 <sup>_<u>λ</u>_</sup> _d_ 1 <sup><u>1</u></sup> <sup>+</sup> <sup>_<u>h</u>_</sup> _a_ <sup><u>2</u></sup> 2 <sup>_<u>λ</u>_</sup> _d_ 2 <sup><u>2</u></sup> <sup>_<u>h</u>_</sup> _a_ <sup><u>1</u></sup> 1 <sup>_<u>λ</u>_</sup> _d_ 1 <sup><u>1</u></sup> <sup>+</sup> <sup>_<u>h</u>_</sup> _a_ <sup><u>2</u></sup> 2 <sup>_<u>λ</u>_</sup> _d_ 2 <sup><u>2</u></sup> <sup>_<u>h</u>_</sup> _a_ <sup><u>2</u></sup> 2 <sup>_<u>λ</u>_</sup> _d_ 2 <sup><u>2</u></sup> <sup>+</sup> <sup>_<u>h</u>_</sup> _a_ <sup><u>3</u></sup> 3 <sup>_<u>λ</u>_</sup> _d_ 3 <sup><u>3</u></sup> <sup>_<u>h</u>_</sup> _a_ <sup>_<u>n</u>_</sup> _n_ <sup>_<u>−</u>_</sup> _−_ <sup><u>1</u></sup> 1 <sup>_<u>λ</u>_</sup> _dn_ <sup>_<u>n</u>_</sup> _−_ <sup>_<u>−</u>_</sup> 1 <sup><u>1</u></sup> <sup>)</sup> <sup>_<u>qn−</u>_</sup> _p_ <sup><u>1</u></sup> _n_ <sup>_<u>|</u>_</sup> _−_ <sup>_<u>qn</u>_</sup> 1 <sup>_<u>−</u>_</sup> <sup><u>1</u></sup> <sup>_<u>|</u>_</sup> <sup>_<u>h</u>_</sup> _a_ <sup><u>2</u></sup> 2 <sup>_<u>λ</u>_</sup> _d_ 2 <sup><u>2</u></sup> <sup>)</sup> <sup>_<u>q</u>_</sup> <sup><u>2</u></sup> _p_ <sup>_<u>|q</u>_</sup> 2 <sup><u>2</u></sup> <sup>_<u>|</u>_</sup> <sup>_<u>h</u>_</sup> _a_ <sup><u>3</u></sup> 3 <sup>_<u>λ</u>_</sup> _d_ 3 <sup><u>3</u></sup> <sup>)</sup> <sup>_<u>q</u>_</sup> <sup><u>3</u></sup> _p_ <sup>_<u>|q</u>_</sup> 3 <sup><u>3</u></sup> <sup>_<u>|</u>_</sup> _._ (12) _Bq_ = _−_ <sup>_<u>c</u>_</sup> 2   _,_ _Bp_ = <sup><u>1</u></sup> 2  _a_ 1 _a_ 1 0 ... 0 _,_ _g_ ( _ps, p, q_ ) = _−_ <sup>_<u>c</u>_</sup> 4  _p_ 3 ... ( <sup>_<u>h</u>_</sup> _a_ <sup>_<u>n</u>_</sup> _n_ <sup>_<u>−</u>_</sup> _−_ <sup><u>2</u></sup> 2 <sup>_<u>λ</u>_</sup> _dn_ <sup>_<u>n</u>_</sup> _−_ <sup>_<u>−</u>_</sup> 2 <sup><u>2</u></sup> <sup>+</sup> <sup>_<u>h</u>_</sup> _a_ <sup>_<u>n</u>_</sup> _n_ <sup>_<u>−</u>_</sup> _−_ <sup><u>1</u></sup> 1 <sup>_<u>λ</u>_</sup> _dn_ <sup>_<u>n</u>_</sup> _−_ <sup>_<u>−</u>_</sup> 1 <sup><u>1</u></sup> <sup>)</sup> <sup>_<u>q</u>_</sup> _p_ 2 ( <sup>_<u>h</u>_</sup> _a_ <sup><u>2</u></sup> 2 <sup>_<u>λ</u>_</sup> _d_ 2 <sup><u>2</u></sup> <sup>+</sup> <sup>_<u>h</u>_</sup> _a_ <sup><u>3</u></sup> 3 <sup>_<u>λ</u>_</sup> _d_ 3 <sup><u>3</u></sup> <sup>)</sup> <sup>_<u>q</u>_</sup> <sup><u>3</u></sup> <sup>_<u>|q</u>_</sup> _pn−_ 1   The vectors - _q_ 1 _q_ 2 _· · ·_ _qn−_ 1� _T_ _,_ - _T_ _,_ _q_ = _p_ = - _p_ 2 _p_ 3 _· · ·_ _pn_ represent the discretized analog of _p_ and _q_ to be computed, while _p_ 1 = _ps_, and _qn_ = _qd_ . The discretized model for the dynamics of gas transported along pipes shown in (11) is a nonlinear ordinary differential equation (ODE). The nonlinear term in this ODE comes from the discretization of the friction term in the momentum equation (5b). Remark 2.1. _The_ _obtained_ _model_ _in_ (11) _results_ _from_ _the_ _discretization_ _of_ _the_ _incompressible_ _isothermal_ _Euler_ _equation_ _of_ _homogeneous_ _elevation_ (5a) _–_ (5b) _._ _However,_ _we_ _note_ _that_ _for_ _the_ _het-_ _erogeneous_ _elevation_ _case,_ _the_ _gravity_ _term_ _in_ (3b) _is_ _linear_ _in_ _the_ _pressure_ _p._ _After_ _discretization,_ _this_ _term_ _will_ _introduces_ _an_ _additional_ _term_ _in_ _the_ _position_ _of_ _Kqp_ _in_ (11) _._ _This_ _new_ _term_ _does_ _not_ _change_ _the_ _structure_ _of_ _the_ _model_ _that_ _we_ _obtained_ _in_ (11) _._ _The_ _structure_ _we_ _refer_ _to_ _here_ _is_ _the_ _block_ _structure_ _of_ _the_ _matrices_ _involved_ _in_ _describing_ _the_ _equation_ _as_ _well_ _as_ _the_ _sparsity_ _pattern_ _of_ _all_ _Jacobians_ _of_ _the_ _nonlinear_ _functions._ Note that we impose the boundary condition (6) by using the prescribed pressure at the inflow point and the given mass flow at the outflow point. However one can also impose a negative mass flow at the outflow point making it an inflow point, and for more complex topology of the network with more than one supply node, it can happen that the gas flows out at a so called inflow point. Computational results in the numerical experiment show this. ### 3 Network Modeling Within this paper, we focus on passive networks to demonstrate how advanced numerical linear algebra can benefit the fast simulation of such a network. When we say passive network we mean a network that does not contain active elements, such as compressors, valves, etc. [21]. This simplification allows us to maintain a differential algebraic model without combinatorial aspects. For the modeling of the network with compressors and valves we refer to [17, 22]. In this section, we introduce a new scheme for the modeling of the passive networks. The abstract gas network is described by a directed graph _G_ = ( _E,_ _N_ ) _,_ (13) where _E_ denotes the set of edges, which contains the pipes in the gas network. _N_ represents the set of nodes, which consist of the set of supply nodes _Ns_, demand nodes _Nd_, and interior nodes _N_ 0 of the network. Here, the supply nodes represent the set of nodes in the network where gas is injected into the network or more precisely where the pressure is given, and the demand nodes form a set of nodes where the gas is extracted, where an outgoing flux is described and interior nodes are the rest. We assume from now on that demand nodes and supply nodes are the only boundary nodes. That means they are only connected to one pipe. If supply or demand nodes exist that are connected to more than one edge, we add a short pipe to that node and declare the new node as the demand or supply node and the old one becomes an interior node. Sometimes interior nodes are called junction nodes [23], but for us junction nodes are more specific. Definition 3.1. _The_ _nodes_ _inside_ _a_ _graph_ _G,_ _which_ _connect_ _at_ _least_ _three_ _edges,_ _are_ _called_ _junction_ _nodes._ 6 Denote _Nj_ _⊂N_ the set of junction nodes of a given graph _G_ . Since in our graph _Ns ∪Nd_ is equal to the set of boundary nodes, we have _Nj_ _⊂N_ 0. From now on we will assume that besides our original graph _G_, we also have the graph _G_ <sup>˜</sup>, which is the graph created from _G_ by smoothing out the vertices _N_ 0 _\Nj_ . Smoothing the vertex _w_, which is connected to the edges _e_ 1 and _e_ 2, is the operation which removes _w_ as well as both edges and adds a new edge to the starting and end points of the pair. This edge can be given the direction of any of the two removed edges. Here, it is emphasized that only vertices that connect exactly two edges can be smoothed. This is however the case for the vertices in _N_ 0 _\Nj_ . This means our new graph _G_ <sup>˜</sup> = ( _E_ <sup>˜</sup> _,_ _N_ ˜ ) is a directed graph, which only has demand nodes, supply nodes and junction nodes in the sense of Definition 3.1. 10 1 9 2 8 3 7 4 5 6 Figure 4: A typical gas network An example network is shown in Figure 4. Here, nodes 1 and 10 denote the supply nodes, node 6 represents the demand node. According to Definition 3.1, only node 4 in Figure 4 is a junction node. This means we can replace this graph by the smoothed graph given in Figure 5 1 2 3 Figure 5: Smoothed network of Figure 4 with an ordering of the pipes. By making use of the smoothed graph, the number of algebraic constraints is kept small, while the edges which represent several pipes become long. More details on the number of algebraic constraints will be presented in Proposition 3.1 at the end of this section. For each such long pipe _i ∈_ _E_ <sup>˜</sup>, we have the set of variables _p_ <sup>(</sup> 1 <sup>_i_</sup> <sup>)</sup> <sup>_, . . ., p_</sup> <sup>(</sup> _n_ <sup>_i_</sup> <sup>()</sup> <sup>_i_</sup> <sup>)</sup> <sup>and</sup> <sup>_q_</sup> 1 <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <sup>_, . . ., q_</sup> _n_ <sup>(</sup> <sup>_i_</sup> <sup>()</sup> <sup>_i_</sup> <sup>)</sup> <sup>that</sup> <sup>represent</sup> <sup>the</sup> <sup>discrete</sup> <sup>(</sup> 1 <sup>_i_</sup> <sup>)</sup> <sup>_, . . ., p_</sup> <sup>(</sup> _n_ <sup>_i_</sup> <sup>()</sup> <sup>_i_</sup> <sup>)</sup> <sup>and</sup> <sup>_q_</sup> 1 <sup>(</sup> <sup>_i_</sup> <sup>)</sup> pipe _i ∈_ _E_ <sup>˜</sup>, we have the set of variables _p_ <sup>(</sup> 1 <sup>_i_</sup> <sup>)</sup> <sup>_, . . ., p_</sup> <sup>(</sup> _n_ <sup>_i_</sup> <sup>()</sup> <sup>_i_</sup> <sup>)</sup> <sup>and</sup> <sup>_q_</sup> 1 <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <sup>_, . . ., q_</sup> _n_ <sup>(</sup> <sup>_i_</sup> <sup>()</sup> <sup>_i_</sup> <sup>)</sup> <sup>that</sup> <sup>represent</sup> <sup>the</sup> <sup>discrete</sup> analog of _p_ and _q_, respectively. Here _n_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> is the number of discretization points in a certain edge. The smoothed out nodes of the original graph are merely discretization points. We will denote _p_ <sup>(</sup> 1 <sup>_i_</sup> <sup>)</sup> = _p_ <sup>(</sup> _s_ <sup>_i_</sup> <sup>)</sup> and _qn_ <sup>(</sup> <sup>_i_</sup> <sup>()</sup> <sup>_i_</sup> <sup>)</sup> <sup>=</sup> <sup>_q_</sup> _d_ <sup>(</sup> <sup>_i_</sup> <sup>),</sup> <sup>for</sup> <sup>now,</sup> <sup>as</sup> <sup>they</sup> <sup>are</sup> <sup>boundary</sup> <sup>conditions</sup> <sup>in</sup> <sup>a</sup> <sup>one</sup> <sup>pipe</sup> <sup>system.</sup> <sup>(</sup> 1 <sup>_i_</sup> <sup>)</sup> = _p_ <sup>(</sup> _s_ <sup>_i_</sup> <sup>)</sup> <sup>(</sup> _s_ <sup>_i_</sup> <sup>)</sup> and _qn_ <sup>(</sup> <sup>_i_</sup> <sup>()</sup> <sup>_i_</sup> <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _n_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <sup>=</sup> <sup>_q_</sup> _d_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _d_ <sup>(</sup> <sup>_i_</sup> <sup>),</sup> <sup>for</sup> <sup>now,</sup> <sup>as</sup> <sup>they</sup> <sup>are</sup> <sup>boundary</sup> <sup>conditions</sup> <sup>in</sup> <sup>a</sup> <sup>one</sup> <sup>pipe</sup> <sup>system.</sup> Remark 3.1. _Our_ _gas_ _network_ _is_ _modeled_ _by_ _a_ _directed_ _graph_ _G_ = ( _E,_ _N_ ) _,_ _where_ _the_ _set_ _of_ _boundary_ _nodes_ _is_ _equal_ _to_ _the_ _union_ _of_ _supply_ _nodes_ _and_ _demand_ _nodes._ _All_ _edges_ _E_ _are_ _pipes,_ _and_ _an_ _edge_ _attached_ _to_ _a_ _supply_ _node_ _is_ _called_ _a_ _supply_ _pipe,_ _while_ _an_ _edge_ _attached_ _to_ _a_ _demand_ _node_ _is_ _called_ _a_ _demand_ _pipe._ _A_ _supply_ _pipe_ _is_ _directed_ _away_ _from_ _the_ _supply_ _node_ _and_ _a_ _demand_ _pipe_ _is_ _directed_ _towards_ _the_ _demand_ _node._ _By_ _smoothing_ _of_ _this_ _graph_ _as_ _explained_ _above,_ _we_ _also_ _get_ _a_ _directed_ _graph_ _G_ <sup>˜</sup> = ( _E_ <sup>˜</sup> _,_ _N_ ˜ ) _,_ _whose_ _interior_ _nodes_ _are_ _all_ _junction_ _nodes_ _in_ _the_ _sense_ _of_ _Definition_ _3.1._ _In_ _G_ <sup>˜</sup> _,_ _supply_ _edges_ _and_ _demand_ _edges_ _still_ _exist,_ _and_ _they_ _should_ _be_ _directed_ _as_ _above,_ _but_ _are_ _possibly_ _longer._ 3.1 Nodal Conditions There are two types of constraints concerning the connection of edges, namely the pressure constraint, and the mass flow constraint. These two types of constraints represent the equality of the dynamic pressure and conservation of mass at junction nodes [24]. The so-called pressure nodal condition describes the pressure equality among pipes connected 7 at a same junction node, which is given by _p_ <sup>(</sup> _n_ <sup>_i_</sup> <sup>()</sup> _s_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> <sup>_,_</sup> <sup>if</sup> <sup>a</sup> <sup>node</sup> <sup>connects</sup> <sup>the</sup> <sup>incoming</sup> <sup>pipe</sup> <sup>_i_</sup> <sup>and</sup> <sup>the</sup> <sup>outgoing</sup> <sup>pipe</sup> <sup>_j_</sup> <sup>.</sup> (14) <sup>(</sup> _n_ <sup>_i_</sup> <sup>()</sup> <sup>_i_</sup> <sup>)</sup> <sup>=</sup> <sup>_p_</sup> _s_ <sup>(</sup> <sup>_j_</sup> <sup>)</sup> The pressure nodal condition states that the pressure at the end of the outflow pipes should equal the pressure at the beginning of the inflow pipes that connect to the same junction node and ensures that the there is only one pressure value at each node. The second type of nodal condition i.e., the mass flow nodal condition, states the conservation of mass flow at the junction nodes, and it is given by - _qd_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> = _i∈Ik_ _i∈Ok_ _q_ 1 <sup>(</sup> <sup>_i_</sup> <sup>)</sup> for every node _k_, (15) where _Ik_ is the set of edges incoming the node _k_ and _Ok_ the set of edges outgoing of node _k_ . Equation (15) states that the inflow at the junction node _k_ should equal to the outflow at the same junction node _k_ . 3.2 Network Assembly In the discretized model (11) describing the dynamics of gas transported along one single pipe the variables _p_ 1 = _ps_ and _qn_ = _pd_ are given by the boundary condition, i.e., the prescribed pressure at the input node, and the prescribed mass flow at the demand node. For the network all variables including _p_ <sup>(</sup> _s_ <sup>_i_</sup> <sup>)</sup> and _qd_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> are treated as variables and we add the algebraic constraints (14)–(15) to the system. We take the network in Figure 4, whose smoothed graph, with edge ordering is given by Figure 5 as an example to build the full DAE system. For each pipe we have the pipe dynamics of the discretized system given by (11). The supply pressure for pipe 1 and 2 is given as well as the demand flux for pipe 3. This means we have the extra variables _p_ <sup>(3)</sup> _s_ <sup>_, q_</sup> _d_ <sup>(1)</sup> <sup>_, q_</sup> _d_ <sup>(2).</sup> <sup>We will first use</sup> the fact that _p_ <sup>(3)</sup> _s_ is equal to _p_ <sup>(1)</sup> _n_ <sup>(1)</sup> <sup>and</sup> <sup>replace</sup> <sup>it</sup> <sup>in</sup> <sup>the</sup> <sup>equation.</sup> <sup>We</sup> <sup>will</sup> <sup>then</sup> <sup>still</sup> <sup>have</sup> <sup>to</sup> <sup>make</sup> <sup>(</sup> _s_ <sup>_i_</sup> <sup>)</sup> and _qd_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <sup>(3)</sup> _s_ <sup>_, q_</sup> _d_ <sup>(1)</sup> <sup>(3)</sup> _s_ is equal to _p_ <sup>(1)</sup> _n_ <sup>(1)</sup> _d_ <sup>(1)</sup> <sup>_, q_</sup> _d_ <sup>(2)</sup> <sup>(1)</sup> _n_ <sup>(1)</sup> <sup>and</sup> <sup>replace</sup> <sup>it</sup> <sup>in</sup> <sup>the</sup> <sup>equation.</sup> <sup>We</sup> <sup>will</sup> <sup>then</sup> <sup>still</sup> <sup>have</sup> <sup>to</sup> <sup>make</sup> sure that _p_ <sup>(1)</sup> _n_ <sup>(1)</sup> _n_ <sup>(1)</sup> <sup>=</sup> <sup>_p_</sup> <sup>(2)</sup> _n_ <sup>(2)</sup> <sup>(2)</sup> _n_ <sup>(2)</sup> <sup>and also that the incoming flux at the junction is equal to the outgoing flux.</sup> To summarize _qd_ <sup>(1)</sup> _d_ <sup>(1)</sup> <sup>_, q_</sup> _d_ <sup>(2)</sup> _d_ <sup>(2)</sup> are the added variables as _p_ <sup>(3)</sup> _s_ <sup>(3)</sup> _s_ was replaced directly and _qd_ <sup>(1)</sup> _d_ <sup>(1)</sup> + _qd_ <sup>(2)</sup> _d_ <sup>(2)</sup> = _q_ 1 <sup>(3)</sup> <sup>(1)</sup> _n_ <sup>1</sup> <sup>=</sup> <sup>_p_</sup> <sup>(2)</sup> _n_ <sup>2</sup> _p_ <sup>(1)</sup> _n_ <sup>1</sup> 1 <sup>(3)</sup> <sup>_,_</sup> <sup>(2)</sup> _n_ <sup>2</sup> <sup>_,_</sup> (16) are the added algebraic constraints. By using the single pipe model (11), we obtain the mathematical model for the network in Figure 4 and 5,  _M_ <sup>(1)</sup>   _u_ <sup>(1)</sup>   _K_ <sup>(1)</sup> _B_ <sup>(1)</sup>   _u_ <sup>(1)</sup>   _K_ <sup>(1)</sup> _Bq_ <sup>(1)</sup>     _M_ <sup>(1)</sup>      = + _e_ 3 1 1 _e_ 1 _e_ 2 0 _q_ _K_ <sup>(2)</sup> _Bq_ <sup>(2)</sup>  _u_ <sup>(1)</sup> _u_ <sup>(2)</sup> _u_ <sup>(3)</sup> _qd_ <sup>(1)</sup> _qd_ <sup>(2)</sup>  _M_ <sup>(2)</sup> _d_  _u_ <sup>(1)</sup> _u_ <sup>(2)</sup> _u_ <sup>(3)</sup> _qd_ <sup>(1)</sup> _qd_ <sup>(2)</sup> _M_ <sup>(3)</sup> 0  0 _<u>∂</u>_ _∂t_ ¯ _p_ <sup>(3)</sup> _K_ <sup>(3)</sup>   _K_ <sup>(2)</sup> _q_ _B_ ¯ _p_ <sup>(3)</sup> _K_ <sup>(3)</sup> _d_ - <u>��</u> <u>�</u> M Here _u_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> = [ _p_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, q_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> ] and <u>�</u> <u>��</u> <u>�</u> K _Bp_ <sup>(1)</sup>   _G_ 1( _u_ <sup>(1)</sup> _, p_ <sup>(1)</sup> _s_  _p_   _qd_ <sup>(3)</sup> +     - _p_ <sup>(1)</sup> _s_ _s_ _p_ <sup>(2)</sup> _s_ + _q_ 0 0 _G_ 1( _u_ <sup>(1)</sup> _, p_ <sup>(1)</sup> _s_ <sup>)</sup> _G_ 2( _u_ <sup>(2)</sup> _, p_ <sup>(2)</sup> _s_ <sup>)</sup> 0 0 _Bp_ <sup>(2)</sup>  _G_ 2( _u_ <sup>(2)</sup> _, p_ <sup>(2)</sup> _s_ <sup>)</sup> _G_ 3( _u_ <sup>(3)</sup> _,_ ¯ _e_ 3 _u_ <sup>(1)</sup> )  0 0 _Bq_ <sup>(3)</sup> _._ _s_ <u>�</u> <u>��</u> <u>�</u> g ( _∗_ ) (17) <u>�</u> �� <u>�</u> B _p_ <u>����</u> B _q_ _,_ and _B_ <sup>¯</sup> _p_ <sup>3</sup> _Gi_ ( _u_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, ps_ <sup>(</sup> <sup>_i_</sup> <sup>)) =</sup> - 0 _g_ ( _p_ <sup>(</sup> _s_ <sup>_i_</sup> <sup>)</sup> <sup>_, p_</sup> <sup>(</sup> <sup>(</sup> _s_ <sup>_i_</sup> <sup>)</sup> <sup>_, p_</sup> <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <sup>_, q_</sup> <sup>(</sup> <sup>_i_</sup> <sup>))</sup> �0 _,_ 0 _, . . .,_ _,_ 1 _,_ 0 _,_ _. . .,_ - _⊗Bp_ <sup>3</sup> <sup>_._</sup> (18) _p_ <sup>3</sup> <sup>=</sup> 8 The mass flow nodal condition is represented by the 4th block row in (17), and the pressure nodal condition is given by the 5th block row and also the (3, 1) block of K in (17). The row vectors _e_ 1, _e_ 2, and _e_ 3 are just elementary vectors with 1 or _−_ 1 on a certain position and zeros elsewhere, which select the corresponding variables for the nodal conditions (14)–(15). Note that the matrix K in (17) is not uniquely defined. This is because we use _p_ <sup>(3)</sup> _s_ <sup>(1)</sup> _n_ <sup>(1).</sup> <sup>(3)</sup> _s_ = _p_ <sup>(1)</sup> _n_ We can also employ _p_ <sup>(3)</sup> _s_ <sup>(2)</sup> _n_ <sup>(2),</sup> <sup>and</sup> <sup>this</sup> <sup>in</sup> <sup>turn</sup> <sup>moves</sup> <sup>_B_</sup> <sup>¯</sup> _p_ <sup>(3)</sup> <sup>(3)</sup> _s_ = _p_ <sup>(2)</sup> _n_ We can also employ _p_ <sup>(3)</sup> _s_ = _p_ <sup>(2)</sup> _n_ <sup>(2),</sup> <sup>and</sup> <sup>this</sup> <sup>in</sup> <sup>turn</sup> <sup>moves</sup> <sup>_B_</sup> <sup>¯</sup> _p_ <sup>(3)</sup> from the (3, 1) block to the (3, 2) block of K . Although we need extra variables for both, the pressure and mass flow, to assemble a global network model, we only introduce extra mass flow variables explicitly while the extra pressure variables can be obtained via applying some pressure nodal conditions directly. This reduces the redundancy in the network modeling. There is a degenerate case that a network has only one long pipe, i.e., this network has one supply node and one demand node, but no junction node. For such a degenerate network, which is equivalent to one pipe, we do not need to introduce extra variables since we already have the left and right boundary conditions. For a non-degenerate network, we have the following proposition. Proposition 3.1. _Suppose_ _that_ _the_ _network_ _G_ <sup>˜</sup> = ( _E_ <sup>˜</sup> _,_ _N_ <sup>˜</sup> ) _is_ _a_ _connected_ _graph_ _as_ _in_ _Remark_ _3.1,_ _and_ _has_ _ns_ _supply_ _pipes,_ _nd_ _demand_ _pipes,_ _and_ _nj_ _junction_ _pipes._ _Here_ _junction_ _pipes_ _are_ _edges_ _of_ _the_ _smoothed_ _graph_ _that_ _are_ _not_ _supply_ _pipes_ _or_ _demand_ _pipes._ _Then_ _the_ _following_ _relation_ _between_ _the_ _number_ _of_ _extra_ _variables_ _ne_ _and_ _the_ _number_ _of_ _extra_ _algebraic_ _constraints_ _na_ _of_ _the_ _mathematical_ _model_ _holds:_ _ne_ = _na_ = _ns_ + _nj._ _Proof._ As stated before, we only introduce extra variables for the mass flow of each supply and junction pipe, since the extra pressure variables are directly included at the process of network assembling. Then we have _ne_ = _ns_ + _nj,_ which is due to the fact that the mass flows at the demand pipes are already prescribed. The algebraic constraints are obtained via applying nodal conditions at the junction nodes. Suppose that the junction node _i_ has _n_ <sup>(</sup> in <sup>_i_</sup> <sup>)</sup> <sup>injection</sup> <sup>pipes,</sup> <sup>and</sup> <sup>_n_</sup> out <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <sup>outflow</sup> <sup>pipes,</sup> <sup>then</sup> <sup>we</sup> <sup>need</sup> ( _n_ <sup>(</sup> in <sup>_i_</sup> <sup>)</sup> <sup>_−_</sup> <sup>1)</sup> <sup>equality</sup> <sup>constraints</sup> <sup>to</sup> <sup>apply</sup> <sup>the</sup> <sup>pressure</sup> <sup>nodal</sup> <sup>conditions</sup> <sup>for</sup> <sup>injection</sup> <sup>pipes</sup> <sup>since</sup> <sup>the</sup> pressure nodal conditions for outflow pipes are directly applied at the network assembling. We have one algebraic constraint to prescribe the mass flow nodal condition for junction node _i_ . Therefore, we need _n_ <sup>(</sup> in <sup>_i_</sup> <sup>)</sup> <sup>algebraic</sup> <sup>constraints</sup> <sup>for</sup> <sup>junction</sup> <sup>node</sup> <sup>_i_</sup> <sup>.</sup> <sup>The</sup> <sup>sum</sup> <sup>over</sup> <sup>all</sup> <sup>the</sup> <sup>junction</sup> <sup>nodes</sup> <sup>of</sup> <sup>the</sup> network gives the overall number of algebraic constraints: <sup>(</sup> in <sup>_i_</sup> <sup>)</sup> <sup>injection</sup> <sup>pipes,</sup> <sup>and</sup> <sup>_n_</sup> out <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _n_ <sup>(</sup> in <sup>_i_</sup> <sup>)</sup> <sup>_._</sup> _na_ = _i_ On the other hand, _i_ _n_ <sup>(</sup> in <sup>_i_</sup> <sup>)</sup> <sup>=</sup> <sup>_ns_</sup> <sup>+</sup> <sup>_nj,_</sup> as incoming pipes are never demand pipes and the sum over all incoming pipes is the number of all supply and all junction pipes. Proposition 3.1 states that the total number of extra variables is equal to the total number of algebraic constraints. This is very important for us to simulate the network model in the form of (17), which will be shown in the next section. ### 4 Fast Numerical Methods for Simulation With the help of our modeling we can represent the gas network as in (17). In general the number of algebraic equation will be much smaller than the number of differential equation in this description. In this section, we will introduce fast numerical algorithms for the simulation of such a model. 9 4.1 Numerical Algorithms to Solve Differential Algebraic Equations Here, we reuse the notation from (17) with simplifications. We obtain the general mathematical model, _M∂tx_ = _Kx_ + _Bu_ ( _t_ ) + _f_ ( _x, u_ ( _t_ )) _,_ (19) where the mass matrix _M_ is singular when there is at least one junction node, and the right hand side function _f_ is nonlinear. In general, the mathematical model (19) is a large system of nonlinear DAE, where the size of the DAE (19) is proportional to the length of the overall pipes in the network. To solve/simulate such a DAE model is challenging and possibly slow. Related work either focuses on exploiting the DAE structure such that the differential part and the algebraic part are decoupled, and one can solve these two parts separately [4], or reducing the so-called tractability index [23]. Here, we propose a fast numerical method by directly tracking the expensive numerical linear algebra. To simulate the DAE model (19), we discretize in time using the implicit Euler method, and at time step _k_, we have _M_ <sup>_<u>xk −</u>_</sup> <sup>_<u>xk−</u>_</sup> <sup>1</sup> = _Kx_ <sup>_k_</sup> + _Bu_ <sup>_k_</sup> + _f_ ( _x_ <sup>_k_</sup> _, u_ <sup>_k_</sup> ) _,_ _τ_ i.e., we need to solve the following nonlinear system of equations, _F_ ( _x_ ) = ( _M_ _−_ _τK_ ) _x −_ _τf_ ( _x, u_ <sup>_k_</sup> ) _−_ _Mx_ <sup>_k−_</sup> <sup>1</sup> _−_ _τBu_ <sup>_k_</sup> = 0 _,_ (20) at each time step _k_ to compute the solution _x_ <sup>_k_</sup> . To solve such a nonlinear equation for the simulation of gas networks, some related work [25,26] treats the nonlinear term _f_ ( _x, u_ <sup>_k_</sup> ) explicitly, i.e., _f_ ( _x_ <sup>_k_</sup> _, u_ <sup>_k_</sup> ) _≈_ _f_ ( _x_ <sup>_k−_</sup> <sup>1</sup> _, u_ <sup>_k_</sup> ) since the input _u_ <sup>_k_</sup> is known. This explicit approximation of the nonlinear term reduces the computational complexity, and yields a linear system. However, this approximation can lead to the necessity for smaller and smaller time steps. Here, we treat this nonlinear term implicitly and apply Newton’s method to solve the nonlinear system (20) to study the nonlinear dynamics of the network. Newton’s method is described by Algorithm 1. Algorithm 1 Newton’s method to solve (20) 1: Input: maximal number of Newton steps _n_ max, stop tolerance _ε_ 0, initial guess _x_ 0 2: _m_ = 0 3: while _m ≤_ _n_ max & _∥F_ ( _x_ ) _∥≥_ _ε_ 0 do _<u>∂</u>_ 4: Compute the Jacobian matrix _DF_ ( _xm_ ) = _∂x_ <sup>_F_</sup> <sup>_|x_</sup> <sup>=</sup> <sup>_xm_</sup> 5: Solve _F_ ( _xm_ ) + _DF_ ( _xm_ )( _x −_ _xm_ ) = 0 6: _m ←_ _m_ + 1, _xm_ _←_ _x_ 7: end while 8: Output: solution _x ≈_ _xm_ The biggest challenge for Algorithm 1 is to solve the linear system in line 5 at each Newton iteration, since the Jacobian matrix _DF_ ( _xm_ ) is large. Krylov subspace methods such as the generalized minimal residual (GMRES) method [27] or induced dimension reduction (IDR(s)) method [28] are then appropriate to solve such a system. To accelerate the convergence of such a Krylov subspace method, we need to apply a preconditioning technique by exploiting the structure of the Jacobian matrix _DF_ ( _x_ ). 4.2 Matrix Structure The Jacobian matrix _DF_ ( _x_ ) = ( _M_ _−_ _τK_ ) + _τ_ <sup>_<u>∂</u>_</sup> (21) _∂x_ <sup>_f_</sup> <sup>(</sup> <sup>_x, u_</sup> <sup>)</sup> <sup>_,_</sup> where the matrices _M_ and _K_ are two-by-two block matrices, and _,_ _K_ = 0 10 - _K_ 11 _K_ 12 _K_ 21 _K_ 22 _._ (22) _M_ = - _M_ ¯ Here _M_ <sup>¯</sup> is block-diagonal, and the second block row of _A_ comes from the algebraic constraints of the networks by applying the nodal conditions introduced in Section 3. The size of _A_ 11 is much bigger than the size of _A_ 22 since _A_ 11 comes from the discretization of the isothermal Euler equations over all the edges of the smoothed network, while the size of _A_ 22 is equal to _ns_ + _nj_ according to Proposition 3.1. Moreover, the partial derivative of the nonlinear term _∂x∂_ <sup>_f_</sup> <sup>(</sup> <sup>_x, u_</sup> <sup>)</sup> <sup>has</sup> the following structure _<u>∂</u>_ _∂x_ <sup>_f_</sup> <sup>=</sup> - _Df_ 0� _,_ (23) 0 0 since the nonlinear term only acts on the differential part of the DAE (17). If the graph _G_ <sup>˜</sup> is directed in a certain way and ordered a certain way, we can show that the first block of the Jacobian matrix is block lower triangular. Lemma 4.1. _Given_ _a_ _graph_ _with_ _directed_ _and_ _undirected_ _edges,_ _such_ _that_ _the_ _directed_ _edges_ _do_ _not_ _create_ _cycles,_ _we_ _can_ _always_ _direct_ _the_ _undirected_ _edges_ _such_ _that_ _the_ _resulting_ _graph_ _is_ _a_ _directed_ _acyclic_ _graph_ _(DAG)._ _Proof._ Take such a graph and remove all undirected edges. This results in a graph that may not be connected. However, it is a DAG so that we can order the nodes in a topological ordering [29]. Applying such a topological ordering to the original graph, direct the undirected edges according to that topological ordering, which induces another DAG. This means, even by fixing the direction of the supply and demand pipes, we can redirect all the other edges in our graph _G_ <sup>˜</sup> such that the resulting graph is a DAG. This is not unique, however induces unique directions in the original graph. Here, we use an example network to show how to build such a DAG. 1 2 3 4 5 6 7 (a) DAG with node ordering 2 5 8 1 1 2 3 3 4 6 5 6 7 4 7 (b) edges ordering and node ordering of DAG Figure 6: An illustrative network example of a DAG The network in Figure 6(a) is a smoothed graph that represents a gas network. Only the direction of the supply and demand pipes are fixed. We start ordering the nodes of the graph from the supply nodes, and end up with the demand nodes, which gives a topological ordering of the nodes. Now, we can plot the graph along a line as in Figure 6(b). The directions of the undirected edges of the graph are picked up by pointing away from lower order nodes to higher order nodes, which induces a DAG. Lemma 4.2. _Given_ _a_ _DAG,_ _we_ _can_ _order_ _the_ _edges_ _in_ _such_ _a_ _way_ _that_ _at_ _every_ _node_ _all_ _incoming_ _edges_ _have_ _a_ _lower_ _order_ _as_ _all_ _the_ _outgoing_ _edges,_ _or_ _it_ _doesn’t_ _have_ _an_ _incoming_ _edge._ _We_ _call_ _this_ _ordering_ _direction_ _following_ _(DF)_ _ordering_ _Proof._ Since we have a DAG, there exist a topological ordering of the nodes. This means if an edge goes from node _a_ to node _b_, then _b_ has a higher order than _a_ . We now order the edges, by their starting node. This means an edge has a higher order if its starting node has a higher order. If two edges have the same starting node, then it doesn’t matter in which order we list them, we just pick one. Once we have this ordering of the edges based on the order of the nodes we ensure that all outgoing edges at a node have a higher order as all the incoming edge of a node. Note that the DF ordering is not unique. A DF ordering example of the network in Figure 6(a) is given by Figure 6(b), where the index above each edge is the order of such an edge. 11 Definition 4.1. _(Smoothed direction following (SDF) gas network graph) This is a directed acyclic_ _graph,_ _whose_ _boundary_ _nodes_ _are_ _supply_ _or_ _demand_ _nodes,_ _directions_ _are_ _away_ _from_ _supply_ _nodes_ _and_ _towards_ _demand_ _nodes._ _All_ _edges_ _are_ _sorted_ _with_ _the_ _DF_ _ordering_ _and_ _there_ _are_ _no_ _nodes_ _in_ _the_ _graph_ _that_ _connect_ _exactly_ _two_ _edges._ From now on, we assume that our modeling is such that _G_ <sup>˜</sup> is a SDF gas network graph. Then we have the following proposition to illustrate the structure of the partial derivative of the nonlinear term (23). Proposition 4.3. _Given_ _a_ _SDF_ _gas_ _network_ _graph_ _we_ _can_ _construct_ _the_ _DAE_ _system_ _in_ _such_ _a_ _way_ _that_ _Df_ _in_ (23) _has_ _a_ _block_ _lower-triangular_ _structure._ _Proof._ The block of _f_ corresponding to the _i_ -th pipe has the structure, _fi_ = _Gi_ = - 0 _,_ _g_ ( _p_ in _, p_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, q_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> ) where the structure of _g_ ( _p_ in _, p_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _, q_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> ) is given by (12). Here _p_ in = _ps,_ when _i_ -th pipe is a supply pipe _,_ _p_ <sup>(</sup> out <sup>_j_</sup> <sup>)</sup> <sup>_,_</sup> where pipe _j_ is a selected incoming pipe into the node where pipe _i_ is outgoing _._ By the selected ordering, we always have _j_ _<_ _i_ . Then the upper triangular blocks of _Df_ are 0. The diagonal blocks are given by �0 0 0 _,_ _<u>g</u>_ <u>(</u> _<u>p</u>_ <u>in</u> _<u>,p</u>_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _<u>,q</u>_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <u>)</u> 0 _∂p_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _<u>g</u>_ <u>(</u> _<u>p</u>_ <u>in</u> _<u>,p</u>_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> _<u>,q</u>_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <u>)</u> _∂q_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> which is again block lower triangular and in particular, with an easy structure of the diagonal blocks, since <sup>_<u>g</u>_</sup> <sup><u>(</u></sup> <sup>_<u>p</u>_</sup> <sup><u>in</u></sup> <sup>_<u>,p</u>_</sup> <sup>(</sup> <sup>_i_</sup> <sup>)</sup> <sup>_<u>,q</u>_</sup> <sup>(</sup> <sup>_i_</sup> <sup>))</sup> in our discretization is tridiagonal. _∂q_ <sup>(</sup> <sup>_i_</sup> <sup>)</sup> Similar to Proposition 4.3, we can also show that the (1 _,_ 1) block of _K_ in (22) has a lowertriangular block structure. Proposition 4.4. _Given_ _an_ _SDF_ _gas_ _network_ _graph,_ _K_ 11 _in_ (22) _is_ _also_ _block_ _lower-triangular_ _structure._ _Proof._ For the _i_ -th block row of _K_ 11, the off-diagonal blocks are zero if the _i_ -th pipe is a supply pipe. If the _i_ -th pipe is not a supply pipe and connected with other pipes, then the off-diagonal block ( _i,_ _j_ ) is nonzero if the _j_ -th pipe corresponds to one of the flow injection pipes of the _i_ -th pipe. This is because the pressure nodal condition (14) is applied for the _i_ -th pipe. According to Definition 4.1, we can pick the pressure condition for the _i_ -th pipe by any injecting pipe _j_, which are all of lower order and therefore ensure _i > j_, and this completes the proof. If we partition the Jacobian matrix (21) by a 2-by-2 block structure as in (22), then we have the following theorem to illustrate the structure of the (1 _,_ 1) block of the Jacobian matrix. Theorem 4.5. _Given_ _an_ _SDF_ _gas_ _network_ _graph_ _we_ _are_ _able_ _to_ _model_ _the_ _system_ _in_ _such_ _a_ _way,_ _that_ _the_ (1 _,_ 1) _block_ _of_ _the_ _Jacobian_ _matrix_ (21) _has_ _a_ _block_ _lower-triangular_ _structure._ _Proof._ According to (21)–(23), the (1 _,_ 1) block of the Jacobian matrix _DF_ ( _x_ ) is, _M_ ¯ _−_ _τK_ 11 + _τDf_ _._ According to Proposition 4.3 and Proposition 4.4, _K_ 11 and _Df_ are block lower-triangular matrices. Since _M_ <sup>¯</sup> is a block diagonal matrix, this completes the proof. 12 Next, we use a benchmark network from [30], shown in Figure 7 to show the structure of the Jacobian matrix _DF_ ( _x_ ) of the first Newton iteration for the first time step, i.e., _DF_ ( _x_ <sup>1</sup> 1 <sup>)</sup> <sup>before</sup> Jacobian matrix _DF_ ( _x_ ) of the first Newton iteration for the first time step, i.e., _DF_ ( _x_ <sup>1</sup> 1 <sup>)</sup> <sup>before</sup> and after applying the DF ordering. The network parameters are also given in [30]. We set the mesh size for the FVM discretization to be 20 meters, i.e., _h_ = 20. The sparsity pattern of _DF_ ( _x_ <sup>1</sup> 1 <sup>)</sup> mesh size for the FVM discretization to be 20 meters, i.e., _h_ = 20. The sparsity pattern of _DF_ ( _x_ <sup>1</sup> 1 <sup>)</sup> before and after the DF ordering are given by Figure 8. Figure 7: Big benchmark network in [30] 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 <u>10</u> <sup>5</sup> 0 0.5 1 1.5 2 nz = 700829 10 <sup>5</sup> (a) without DF ordering 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 <u>10</u> <sup>5</sup> 0 0.5 1 1.5 2 nz = 700829 10 <sup>5</sup> (b) with DF ordering Figure 8: Sparsity pattern of _J_ without and with DF ordering Figure 8 shows that the Jacobian matrix _DF_ ( _x_ ) is a sparse matrix. After applying the DF ordering, the (1 _,_ 1) block has a block lower-triangular structure, and the size of the (1 _,_ 1) block is much bigger than the (2 _,_ 2) block. For the case when the mesh size is 20 meters, the (1 _,_ 1) block is a 200 _,_ 348 _×_ 200 _,_ 348 block lower-triangular matrix while the size of the (2 _,_ 2) block is 417 _×_ 417. In general, the size of the (2 _,_ 2) block of the Jacobian matrix is fixed since it equals the number of algebraic constraints. According to Proposition 3.1, it equals _ns_ + _nj_, where _ns_ is the number of supply pipes and _nj_ is the number of junction pipes. The size of the (1 _,_ 1) block depends on the mesh size and equals twice the total pipeline length divided by the mesh size. Therefore, it is much bigger than _ns_ + _nj_, if the total length of the pipelines is much larger compared to the mesh size. 4.3 Preconditioning Technique The specific structure of the Jacobian matrix can be exploited to solve the Jacobian system fast for the simulation of the gas network. Recall that to simulate the discretized gas network 13 model, we need to apply Algorithm 1, while we need to solve a Jacobian system at each Newton iteration for each time step _k_ ( _k_ = 1 _,_ 2 _,_ _· · ·_ _, nt_ ). To solve the Jacobian system, we exploit the 2-by-2 structure of the Jacobian matrix. Here we write the Jacobian matrix _DF_ ( _x_ ) as _DF_ ( _x_ ) = - _DF_ 11 _DF_ 12� _._ _DF_ 21 _DF_ 22 Note that the Jacobian matrix _DF_ ( _x_ ) has a special structure, which is called _generalized_ _saddle-_ _point_ _structure_ [31]. This enables us to make use of the preconditioning techniques designed for the generalized saddle-point systems to solve the Jacobian system. Generalized saddle-point systems come from many applications, such as computational fluid dynamics [32], PDE-constrained optimization [33], optimal flow control [34]. Many efforts have been dedicated to the efficient numerical solution of such systems using preconditioning techniques [35–39], we recommend [31,40] for a general survey of preconditioning generalized saddle-point systems. We can compute a block LU factorization by _DF_ ( _x_ ) = - _DF_ 11 �� _I_ _DF_ <sup>_−_</sup> 11 <sup>1</sup> <sup>_DF_</sup> 12 _DF_ 21 _S_ _I_ _._ (24) Here _S_ = _DF_ 22 _−_ _DF_ 21 _DF_ <sup>_−_</sup> 11 <sup>1</sup> <sup>_DF_</sup> 12 <sup>is</sup> <sup>the</sup> <sup>Schur</sup> <sup>complement</sup> <sup>of</sup> <sup>_DF_</sup> <sup>(</sup> <sup>_x_</sup> <sup>).</sup> <sup>According</sup> <sup>to</sup> <sup>Theorem</sup> <sup>4.5,</sup> _DF_ 11 has a block lower-triangular structure, and the size of _DF_ 22 is much smaller than _DF_ 11. Therefore, we can compute the Schur complement _S_ by block forward substitution, and apply the following preconditioner, _,_ (25) _P_ = - _DF_ 11 _DF_ 21 _S_ to solve the Jacobian system using a preconditioned Krylov solver. Associated with the block LU factorization (24), we can immediately see that the preconditioned spectrum _λ_ ( _P_ <sup>_−_</sup> <sup>1</sup> _DF_ ( _x_ )) = _{_ 1 _}_ . Moreover, the minimal polynomial of the preconditioned matrix _P_ <sup>_−_</sup> <sup>1</sup> _DF_ ( _x_ ) has degree 2, so that a method like generalized minimum residual (GMRES) [27] would converge in at most two steps [31]. At each iteration of the Krylov solver, we need to solve the system - _r_ 1� _,_ _r_ 2 - _DF_ 11 _DF_ 21 _S_ �� _y_ 1 _y_ 2 = which can be solved easily since _DF_ 11 is a block lower-triangular system, and _S_ = _DF_ 22 _−_ _DF_ 21 _DF_ <sup>_−_</sup> 11 <sup>1</sup> <sup>_DF_</sup> 12 <sup>can</sup> <sup>be</sup> <sup>computed</sup> <sup>directly</sup> <sup>since</sup> <sup>the</sup> <sup>size</sup> <sup>of</sup> <sup>_S_</sup> <sup>is</sup> <sup>much</sup> <sup>smaller</sup> <sup>than</sup> <sup>_DF_</sup> 11 <sup>.</sup> <sup>Note</sup> that at each time step _k_, we need to solve a nonlinear system using Newton’s method, and we need to apply a preconditioned Krylov subspace method to solve a Jacobian system at each Newton iteration. For such a preconditioned Krylov solver, we need to compute the Schur complement _S_ at each Newton iteration. This can still be computationally expensive for gas network simulation within a certain time horizon. We can further simplify the preconditioner by applying a fixed preconditioner _P_ 1 for all Newton iterations and all time steps, i.e., we choose _P_ 1 = - _DF_ 1 11 _DF_ <sup>1</sup> 21 _S_ <sup>1</sup> _,_ (26) where _P_ 1 comes from the block LU factorization of the Jacobian matrix _DF_ <sup>1</sup> where _P_ 1 comes from the block LU factorization of the Jacobian matrix _DF_ <sup>1</sup> <sup>(</sup> <sup>_x_</sup> <sup>1) of the first Newton</sup> iteration for the first time step, and _S_ <sup>1</sup> = _DF_ <sup>1</sup> 22 <sup>_−_</sup> <sup>_D_</sup> _F_ <sup>1</sup> 21 <sup>(</sup> <sup>_D_</sup> _F_ <sup>1</sup> 11 <sup>)</sup> <sup>_−_</sup> <sup>1</sup> <sup>_D_</sup> _F_ <sup>1</sup> 12 <sup>.</sup> <sup>Note</sup> <sup>that</sup> <sup>for</sup> <sup>the</sup> <sup>precon-</sup> ditioner _P_ 1, we just need to compute the Schur complement once and use it for all the Newton iterations of all time steps. Next, we show the performance of the DF ordering for the Schur complement _S_ <sup>1</sup> computation. Again, we use the network given in Figure 7 as an example and perform a FVM discretization of the network using different mesh sizes. We report the computational results in Table 1, where all timings are given in seconds. Here, _h_ is the mesh size, and # _DF_ represents the size of the Jacobian matrix _DF_ given by (24). The computations of ( _DF_ <sup>1</sup> 11 <sup>)</sup> <sup>_−_</sup> <sup>1</sup> <sup>are</sup> <sup>performed</sup> <sup>using</sup> <sup>the</sup> <sup>MATLAB</sup> _F_ <sup>1</sup> 22 <sup>_−_</sup> <sup>_D_</sup> _F_ <sup>1</sup> _F_ <sup>1</sup> 21 <sup>(</sup> <sup>_D_</sup> _F_ <sup>1</sup> _F_ <sup>1</sup> 11 <sup>)</sup> <sup>_−_</sup> <sup>1</sup> <sup>_D_</sup> _F_ <sup>1</sup> matrix _DF_ given by (24). The computations of ( _DF_ <sup>1</sup> 11 <sup>)</sup> <sup>_−_</sup> <sup>1</sup> <sup>are</sup> <sup>performed</sup> <sup>using</sup> <sup>the</sup> <sup>MATLAB</sup> `backslash` operator for both cases. We have noticed that for medium problem sizes, the advantage of computing _S_ <sup>1</sup> using the block lower-triangular structure obtained from the DF ordering over that without using the DF 14 ordering is not very obvious. This is due to the fact that while computing _S_ <sup>1</sup> using the block lowertriangular structure of _DF_ <sup>1</sup> 11 <sup>obtained from the DF ordering, MATLAB has an overhead calling the</sup> block forward substitution. This overhead is comparable with the hardcore computation time for medium problem sizes. When the problem size gets bigger, this overhead is less comparable with the hardcore computation time, which is demonstrated by the results in Table 1. We believe that the advantage of computations with the DF ordering over computations without the DF ordering will become more apparent once we use a tailored high performance computation implementation. Table 1: Computational time (seconds) for Schur complement _S_ <sup>1</sup> _h_ # _DF_ with DF without DF 20 2,01e+05 8 _,_ 12 8,75 10 3,97e+05 17 _,_ 84 19,14 5 7,91e+05 38 _,_ 44 41,75 2.5 1,58e+06 81 _,_ 42 87,77 Since _P_ 1 is a good preconditioner for _DF_ <sup>1</sup> Since _P_ 1 is a good preconditioner for _DF_ <sup>1</sup> <sup>(</sup> <sup>_x_</sup> <sup>1),</sup> <sup>it</sup> <sup>is</sup> <sup>also</sup> <sup>a</sup> <sup>good</sup> <sup>preconditioner</sup> <sup>to</sup> <sup>the</sup> <sup>Jacobian</sup> matrix _DF_ ( _x_ ) at the other Newton iterations and other time steps, if close to _DF_ <sup>1</sup> <sup>(</sup> <sup>_x_</sup> <sup>1).</sup> <sup>This</sup> <sup>is</sup> matrix _DF_ ( _x_ ) at the other Newton iterations and other time steps, if close to _DF_ <sup>1</sup> <sup>(</sup> <sup>_x_</sup> <sup>1).</sup> <sup>This</sup> <sup>is</sup> true for the gas networks since the Jacobian matrix (21) has two parts, i.e., the linear part and the linearized part. The linear part is dominant since it models the transportation phenomenon of the gas while the nonlinear term acts as the friction term for such a transportation. This makes _P_ 1 a good preconditioner for solving the Jacobian systems for all Newton steps of all time steps, as it will be demonstrated by numerical experiments in the next section. Note that if we keep updating the preconditioner (25) more often than simply using a single preconditioner _P_ 1 in (26), we will obtain better performance for the preconditioned Krylov solver, which in turn needs more time for preconditioner computation. A compromise has to be made to achieve the optimal performance for the gas network simulation in the term of total computational time. pre-compute S <sup>1</sup> applying the preconditioner P1 No preconditioned Newton's method Algorithm 1 next time step start FVM discretization of (7a)(7b) DF ordering of network smoothed edges assembling DAE system (17) time discretization nonlinear system(18) time step Nt reached Yes end Figure 9: Computational diagram for gas network simulation By applying the preconditioner _P_ 1 in (26), we show the computational diagram to illustrate 15 the process of gas network simulation in Figure 9. ### 5 Numerical Results In this section, we report the performance of our numerical algorithms for the simulation of the gas networks. We apply our numerical algorithms to the benchmark problems of several gas networks given in [4,15,23,25] to show the performance of our methods. All numerical experiments are performed in MATLAB 2017a on a desktop with Intel(R) Core(TM)2 Quad CPU Q8400 of 2.66GHz, 8 GB memory and the Linux 4.9.0-6-amd64 kernel. 5.1 Comparison of Discretization Methods In this section, we compare the performance of the finite volume method (FVM) with that of the finite difference method (FDM) for the discretization of the gas networks. We apply both the FVM and FDM to a pipeline network illustrated in Figure 10. Parameter settings for this pipeline network are given in [4]. Figure 10: Pipeline network in [23] We discretize the pipeline network using FVM and FDM with different mesh sizes, and the discretized pipeline networks result in ordinary differential equations (ODEs) since there is no algebraic constraint. We simulate the ODE systems using the routine `ode15s` in MATLAB over the time horizon [0 _,_ 10 <sup>5</sup> ] with the same setting of the initial condition for the ODEs. The computational results are given in Figure 11, where the _x_ -axis represents the mesh sizes in meters. FVM FDM 1000 250 100 50 25 mesh sizes (b) total timing 8 _,_ 000 6 _,_ 000 4 _,_ 000 2 _,_ 000 0 FVM FDM 1000 250 100 50 25 mesh sizes (a) time steps 500 400 300 200 100 0 Figure 11: Comparison of FVM and FDM for a single pipe network Figure 11(a) shows the number of time steps that `ode15s` uses to simulate the ODEs given by FVM and FDM discretization over the time horizon [0 _,_ 10 <sup>5</sup> ]. One can see that for a given mesh size, we need less time steps for the ODE given by the FVM discretization than the ODE given by the FDM discretization which results in less total computation time for the simulation of the ODE given by the FVM discretization, which is also shown in Figure 11(b). The background mechanism is not clear since `ode15s` behaves like a black-box. Next, we use another network to show that with the same mesh, the model given by the FVM discretization gives more accurate results than the FDM discretization. The test network is given in Figure 12, where the network parameters are given in [23]. We use the FVM and FDM methods to discretize the network in Figure 12 and apply the computational method depicted in Figure 9. 16 We choose different mesh sizes for the discretization, and fix the step size for the time discretization to be one second, i.e., _τ_ = 1. We plot the mass flow at the supply node 57 in Figure 13. The mass flow at node 57 computed by using different discretized DAE models (20) is plotted in Figure 13(a), showing similar dynamical behavior of the different models. However, when we look at the dynamics of the mass flow at the first 5 seconds, we can see quite a big difference in Figure 13(b). With the mesh refinement, the solutions of the model given by both the FVM and the FDM discretizations converge. Moreover, we can infer that we can use a bigger mesh size for the FVM discretization than for the FDM discretization to get the same accuracy. 57 37 31 Figure 12: Medium size network The computational results given by Figure 11 and Figure 13 show that when we use the same mesh size to discretize the network, the model given by the FVM discretization is more accurate than the model by the FDM discretization. To get the same model accuracy, we can use a bigger mesh size to discretize the network by FVM than that by FDM. This in turn yields a smaller model given by the FVM discretization than the model given by the FDM discretization. This in turn means that the FVM discretized model is easier to solve than the FDM discretized model. 400 350 300 250 200 150 100 50 0 20 40 60 80 100 time(s) (a) supply flow at node 57 380 370 360 350 340 330 320 310 1 2 3 4 time(s) (b) zoomed supply flow at node 57 Figure 13: Comparison of FVM and FDM for a medium network We also plot the condition number of the Jacobian matrix ( _κ_ ( _DF_ )) of all the Newton iterations for the first time step with a mesh size _h_ = 60 to discretize the DAE, which are given in Figure 14. It illustrates that the condition number of the Jacobian matrix of the FVM discretized model is about 10 times smaller than the condition number of the Jacobian matrix of the FDM discretized model, which makes solving such a FVM discretized model easier than solving a FDM discretized model. Computational results in Figure 11–14 show that the finite volume method has a big advantage 17 over the finite difference method. When using the same mesh size for discretization, FVM gives a more accurate model than the FDM discretization. Moreover, the Jacobian matrix from the FVM discretized model has a better condition number than the Jacobian matrix from the FDM discretized model, which makes it easier to simulate the FVM discretized model. To get the same model accuracy, the size of the FVM discretized model is smaller than the size of the FDM discretized model, and it is therefore computationally cheap. For the comparison of the finite element method (FEM) with FDM for the gas network simulation, we refer to an early study in [11], where the authors preferred FDM due to the comparable accuracy with FEM and less computational time. FVM FDM 10 <sup>8</sup> 10 <sup>7</sup> <sup>_._</sup> <sup>5</sup> 1st 2nd 3rd 4th Newton iter. Figure 14: Condition number of the Jacobian matrix, 1st time step, _h_ = 60 5.2 Change of flow direction The basis of our modeling is a directed graph, with the implicit assumption that the gas flow follows that direction. However, the flow direction may change due to the change of operation conditions of the gas network. In this part, we show that the direction is just a theoretical construction but that the gas is allowed to flow in either direction meaning that the mass flow can be negative and does not influence the performance of our methods. The change of the flow direction does not change the mathematical formulation of algebraic constraints. Therefore, the structure of the system stays unchanged with respect to the change of the flow direction. This means that we do not require the foreknowledge of the flow direction. First, we test two different cases, which corresponds to two different flow direction profiles of the network, cf. Figure 4. Case 1 corresponds to _p_ <sup>(1)</sup> _s_ = _p_ <sup>(2)</sup> _s_ = 30 bar, and _qd_ = 30 kg/s while case 2 corresponds to _p_ <sup>1</sup> _s_ <sup>= 30</sup> <sup>bar,</sup> <sup>_p_</sup> <sup>2</sup> _s_ <sup>= 20</sup> <sup>bar,</sup> <sup>and</sup> <sup>_qd_</sup> <sup>= 30</sup> <sup>kg/s.</sup> <sup>We</sup> <sup>plot</sup> <sup>the</sup> <sup>mass</sup> <sup>flow</sup> <sup>at</sup> <sup>the</sup> <sup>supply</sup> <sup>(1)</sup> _s_ = _p_ <sup>(2)</sup> _s_ 2 corresponds to _p_ <sup>1</sup> _s_ <sup>= 30</sup> <sup>bar,</sup> <sup>_p_</sup> <sup>2</sup> _s_ <sup>= 20</sup> <sup>bar,</sup> <sup>and</sup> <sup>_qd_</sup> <sup>= 30</sup> <sup>kg/s.</sup> <sup>We</sup> <sup>plot</sup> <sup>the</sup> <sup>mass</sup> <sup>flow</sup> <sup>at</sup> <sup>the</sup> <sup>supply</sup> pipe 1 and 2 in Figures 15–16. Figure 15 shows that the mass flow at both supply nodes approaches the steady state after oscillation for a short while, and both input mass flows have a positive sign. This represents that both supply nodes inject gas flow into the network to supply gas to the demand node 6. After changing the operation condition of the network, e.g., changing the pressure at supply nodes, the mass flow is redistributed as shown in Figure 16. The mass flow at supply node 10 becomes negative after a few seconds and remains negative after the network reaches steady state. For this case, the supply pipe at node 10 acts as a demand pipe since gas flows out of the network there. For both cases, the equality _qs_ <sup>1</sup> <sup>+</sup> <sup>_q_</sup> _s_ <sup>2</sup> <sup>= �</sup> <sup>_qd_</sup> <sup>holds</sup> <sup>which</sup> <sup>can</sup> <sup>be</sup> <sup>easily</sup> <sup>see</sup> <sup>by</sup> <sup>looking</sup> <sup>at</sup> <sup>the</sup> <sup>steady</sup> state solution. We also apply two different cases to a more complicated network given in Figure 12 to test the robustness of our methods. Case 1 corresponds to _p_ <sup>55</sup> _s_ <sup>=</sup> <sup>_p_</sup> <sup>56</sup> _s_ <sup>= 50</sup> <sup>_._</sup> <sup>5</sup> <sup>bar,</sup> <sup>_p_</sup> <sup>57</sup> _s_ <sup>= 50</sup> <sup>_._</sup> <sup>8</sup> <sup>bar</sup> <sup>while</sup> <sup>case</sup> 2 has _p_ <sup>55</sup> _s_ = _p_ <sup>56</sup> _s_ = 50 _._ 5 bar, and _p_ <sup>57</sup> _s_ = 50 _._ 0 bar. The demand of gas at the demand nodes is the _s_ <sup>1</sup> <sup>+</sup> <sup>_q_</sup> _s_ <sup>2</sup> <sup>56</sup> _s_ = 50 _._ 5 bar, and _p_ <sup>57</sup> _s_ <sup>55</sup> _s_ <sup>=</sup> <sup>_p_</sup> <sup>56</sup> _s_ <sup>56</sup> _s_ <sup>= 50</sup> <sup>_._</sup> <sup>5</sup> <sup>bar,</sup> <sup>_p_</sup> <sup>57</sup> _s_ 2 has _p_ <sup>55</sup> _s_ = _p_ <sup>56</sup> _s_ = 50 _._ 5 bar, and _p_ <sup>57</sup> _s_ = 50 _._ 0 bar. The demand of gas at the demand nodes is the same for both cases. We show the mass flow at the pipe that connects node 31 and 37, which also connects two sub-networks. The mass flow for the pipe 31 _→_ 37 for different cases is shown in Figure 17. The initial conditions of the gas network for the simulation of the two different cases 18 are set the same. 120 100 80 60 40 20 0 -20 -40 450 400 350 300 250 200 150 100 50 0 200 400 600 800 1000 time(s) (a) mass flow at node 1 100 80 60 40 20 0 -20 -40 0 200 400 600 800 1000 time(s) (b) mass flow at node 10 Figure 15: Mass flow at supply nodes for case 1 50 qs qd 0 0 200 400 600 800 1000 time(s) (a) mass flow at node 1 0 qs -50 qd -100 -150 -200 -250 -300 -350 -400 -450 0 200 400 600 800 1000 time(s) (b) mass flow at node 10 Figure 16: Mass flow at supply nodes for case 2 40 in out 20 0 -20 -40 40 in out 20 -60 0 200 400 600 800 1000 time(s) (a) case 1 0 -20 -40 -60 0 200 400 600 800 1000 time(s) (b) case 2 Figure 17: Mass flow for the pipe 31 _→_ 37 The simulation results in Figure 17 show that the flow direction at pipe 31 _→_ 37 changes for the above two cases. The steady state of the mass flow for the two cases shows that the flow can travel in a direction opposite to the prescribed flow direction, and the inflow at node 31 is equal to the outflow at node 37 for the steady state. The imbalance between the inflow and outflow in the transient process is necessary to build the pressure profile of the network. 19 Computational results in Figure 15–17 show that the gas can flow in the opposite direction as the directed graph suggests. We do not need to introduce another set of variables and switch to another model when the flow changes direction. 5.3 Convergence Comparison After the FDF ordering, we apply Algorithm 1 to solve the nonlinear equation (20) at each time step. Newton’s method requires the computation of the Jacobian matrix at each iteration, which is typically expensive. We try to reduce the cost of computing the Jacobian matrix, and we approximate the nonlinear term <sup>_<u>q</u>_</sup> _<u>m</u>_ <sup>_k_</sup> _q_ <sup>_<u>|kq</u>_</sup> _<u>m</u>_ <sup>_k_</sup> <sup>_<u>|</u>_</sup> at the _m_ -th Newton iteration of time step _k_ as, _<u>m</u>_ <sup>_k_</sup> <sup>_<u>|q</u>_</sup> _<u>m</u>_ <sup>_k_</sup> <sup>_<u>|q</u>_</sup> _<u>m</u>_ <sup>_k_</sup> <sup>_<u>|</u>_</sup> _qm_ <sup>_k_</sup> at the _m_ -th Newton iteration of time step _k_ as, _qm_ <sup>_k_</sup> _<u>m</u>_ <sup>_k_</sup> <sup>_|q_</sup> _<u>m</u>_ <sup>_k_</sup> _._ <sup>_|q_</sup> _<u>m</u>_ <sup>_k_</sup> _<u>−</u>_ <u>1</u> <sup>_|_</sup> _p_ <sup>_k_</sup> _m−_ 1 _≈_ <sup>_<u>q</u>_</sup> _<u>m</u>_ <sup>_k_</sup> _<u>m</u>_ <sup>_k_</sup> <sup>_<u>|q</u>_</sup> _<u>m</u>_ <sup>_k_</sup> <sup>_<u>|q</u>_</sup> _<u>m</u>_ <sup>_k_</sup> <sup>_<u>|</u>_</sup> _._ _p_ <sup>_k_</sup> _m_ _m−_ 1 This approximation avoids computing the partial derivatives of the nonlinear term, and results in a diagonal coefficient matrix for the linearization. We apply this approximation to solve the nonlinear equation iteratively, and this is the Picard iteration. Here, we study the convergence of both Newton’s method and the Picard method for solving (20). We plot the 2-norm of the nonlinear residual, i.e., _∥F_ _∥_ 2 of the first and 50-est time step at each Newton and Picard iteration. Both Newton and Picard iteration start with the same initial condition and the time step size for both methods is set as _τ_ = 1. We first study the convergence for the simulation of the network shown in Figure 12. We discretize this network using the finite volume method with mesh size _h_ = 50, and both Newton’s method and the Picard method are stopped when _∥F_ _∥_ 2 _≤_ 10 <sup>_−_</sup> <sup>5</sup> . The results given in Figure 18 show that both the Newton and Picard iteration have a fast convergence rate. However, the Picard method takes more than twice the number of iterations to reach the same stopping criterion. This means that we need to solve more than twice as many linear systems for the Picard method than for Newton’s method, while solving such a linear system is the most time consuming part of such a nonlinear iteration. Moreover, the sizes of the linear systems at each Newton and Picard iteration are the same. The additional cost from the Picard method is much bigger than the cost saved from the simplification of the derivatives computation. This makes the Picard method not as practical as Newton’s method for solving such a nonlinear system. Next, we test on a bigger network given in Figure 7. We also discretize this network with the finite volume method with _h_ = 50 _m_, and we stop both the Newton and Picard iteration when _∥F_ _∥_ 2 _≤_ 10 <sup>_−_</sup> <sup>4</sup> . The results are given by Figure 19. Again, we observe similar convergence behavior for Newton’s method and the Picard method with the convergence results shown in Figure 18. The Picard method needs more than twice the number of linear system solves than Newton’s method. When we need more accurate simulations of a gas network, smaller mesh sizes are necessary increasing the difference in the computational effort. 10 <sup>4</sup> 10 <sup>1</sup> 10 <sup>_−_</sup> <sup>2</sup> 10 <sup>_−_</sup> <sup>5</sup> 10 <sup>_−_</sup> <sup>8</sup> 0 2 4 6 8 # iter. (b) 50th time step Newton Picard 10 <sup>5</sup> 10 <sup>2</sup> 10 <sup>_−_</sup> <sup>1</sup> 10 <sup>_−_</sup> <sup>4</sup> 10 <sup>_−_</sup> <sup>7</sup> Newton Picard 0 5 10 15 # iter. (a) 1st time step Figure 18: Convergence comparison for network in Figure 12 20 Newton Picard 0 2 4 6 # iter. (b) 50th time step 10 <sup>5</sup> 10 <sup>2</sup> 10 <sup>_−_</sup> <sup>1</sup> 10 <sup>_−_</sup> <sup>4</sup> 10 <sup>_−_</sup> <sup>7</sup> 10 <sup>7</sup> 10 <sup>4</sup> 10 <sup>1</sup> 10 <sup>_−_</sup> <sup>2</sup> 10 <sup>_−_</sup> <sup>5</sup> Newton Picard 0 10 20 30 40 # iter. (a) 1st time step Figure 19: Convergence comparison for network in Figure 7 Computational results in Figures 18 and 19 show that for the simulation of gas networks, Newton’s method is superior to the Picard method in both the computational complexity and the convergence rate. 5.4 Preconditioning Performance As introduced in the previous section, the biggest challenge for applying Algorithm 1 to simulate a gas network lies in the effort spent to solve the linear system at each Newton iteration. For largescale networks, we need smaller mesh sizes to discretize such networks and this results in larger sizes of the DAEs. Therefore, we need to employ iterative solvers to compute the solution of such a large-scale linear system at each Newton iteration, while preconditioning is essential to accelerate the convergence of such iterative solvers. In this part, we study the performance of the preconditioner (26). We test the performance of the preconditioner for the network in Figure 7 using different mesh sizes for the finite volume discretization. At each Newton (outer) iteration, we solve a linear system by applying an (inner) Krylov solver, e.g., the IDR(s) solver [28, 41], and this is called NewtonKrylov method. Note that the Newton-Krylov method is an inexact Newton method, and at each Newton iteration, we apply the IDR(s) method to solve the linear system up to an accuracy _εtol_, i.e., _∥F_ ( _xm_ ) + _DF_ ( _xm_ )( _x −_ _xm_ ) _∥≤_ _εtol∥F_ ( _xm_ ) _∥,_ where _εtol_ is related to the forcing term for an inexact Newton’s method [42]. Since Newton-Krylov method is inexact, we show its convergence with respect to different tolerances of the Krylov solver, i.e., _∥F_ _∥_ 2 with respect to different settings of _εtol_ . We use the “true” residual computed by using a direct method, i.e., the `backslash` operator implemented in MATLAB for comparison. We report the computational results for the FVM discretization with mesh sizes of 50 and 40, and the time step size _τ_ is set to be 1. For the convergence rate of the inexact Newton method with respect to _εtol_, we refer to [43]. The computational results of the nonlinear residual _∥F_ _∥_ 2 in Figure 20 for two different mesh sizes show that the accuracy of the inner iteration loop can be set relatively low while the convergence of the outer iteration can still be comparable with more accurate inner loop iterations. The convergence properties of the Newton iteration for the first time step are the same if the inner loop is solved accurately, or the inner loop is solved up to an accuracy of 10 <sup>_−_</sup> <sup>6</sup> or 10 <sup>_−_</sup> <sup>4</sup> . If the inner loop is solved up to an accuracy of 10 <sup>_−_</sup> <sup>3</sup>, only one more Newton iteration is needed. Moreover, the convergence behavior of the Newton iteration for different inner loop solution tolerances are the same for the 10-th time step. If lower inner loop accuracy is used, less computational effort is needed. This reduces the computational complexity. The number of IDR(4) iterations for different inner loop tolerances are reported in Figure 21–22. 21 direct method IDR(4), _εtol_ = 10 <sup>_−_</sup> <sup>6</sup> IDR(4), _εtol_ = 10 <sup>_−_</sup> <sup>4</sup> IDR(4), _εtol_ = 10 <sup>_−_</sup> <sup>3</sup> 0 1 2 3 4 # Newton iter. (b) _h_ = 50, 10-th time step direct method IDR(4), _ε_ tol = 10 <sup>_−_</sup> <sup>6</sup> IDR(4), _ε_ tol = 10 <sup>_−_</sup> <sup>4</sup> IDR(4), _ε_ tol = 10 <sup>_−_</sup> <sup>3</sup> 0 1 2 3 4 # Newton iter. (d) _h_ = 40, 10-th time step 10 <sup>6</sup> 10 <sup>3</sup> 10 <sup>0</sup> 10 <sup>_−_</sup> <sup>3</sup> direct method IDR(4), _εtol_ = 10 <sup>_−_</sup> <sup>6</sup> IDR(4), _εtol_ = 10 <sup>_−_</sup> <sup>4</sup> IDR(4), _εtol_ = 10 <sup>_−_</sup> <sup>3</sup> 10 <sup>_−_</sup> <sup>6</sup> 0 2 4 6 8 10 # Newton iter. (a) _h_ = 50, 1st time step 10 <sup>6</sup> 10 <sup>4</sup> 10 <sup>2</sup> 10 <sup>0</sup> 10 <sup>_−_</sup> <sup>2</sup> 10 <sup>_−_</sup> <sup>4</sup> 10 <sup>6</sup> 10 <sup>4</sup> 10 <sup>2</sup> 10 <sup>0</sup> 10 <sup>_−_</sup> <sup>2</sup> 10 <sup>_−_</sup> <sup>4</sup> 10 <sup>6</sup> 10 <sup>3</sup> 10 <sup>0</sup> 10 <sup>_−_</sup> <sup>3</sup> direct method IDR(4), _ε_ tol = 10 <sup>_−_</sup> <sup>6</sup> IDR(4), _ε_ tol = 10 <sup>_−_</sup> <sup>4</sup> IDR(4), _ε_ tol = 10 <sup>_−_</sup> <sup>3</sup> 10 <sup>_−_</sup> <sup>6</sup> 0 2 4 6 8 10 # Newton iter. (c) _h_ = 40, 1st time step Figure 20: Nonlinear residual at the first and tenth time step 6 4 2 _<mark>ε</mark>_ tol <mark>= 10</mark> <sup>_−_</sup> <sup>6</sup> _<mark>ε</mark>_ tol <mark>= 10</mark> <sup>_−_</sup> <sup>4</sup> _<mark>ε</mark>_ tol <mark>= 10</mark> <sup>_−_</sup> <sup>3</sup> 0 1 2 3 4 5 6 7 8 9 10 Newton iter. (a) _h_ = 50 6 4 2 _<mark>ε</mark>_ tol <mark>= 10</mark> <sup>_−_</sup> <sup>6</sup> _<mark>ε</mark>_ tol <mark>= 10</mark> <sup>_−_</sup> <sup>4</sup> _<mark>ε</mark>_ tol <mark>= 10</mark> <sup>_−_</sup> <sup>3</sup> 0 1 2 3 4 5 6 7 8 9 10 Newton iter. (b) _h_ = 40 Figure 21: Number of IDR(4) iterations at the first time step The computational results in Figure 21(a) show that the total number of IDR(4) iterations (47) for _ε_ tol = 10 <sup>_−_</sup> <sup>6</sup> is almost twice the total number of IDR(4) iterations (24) for _ε_ tol = 10 <sup>_−_</sup> <sup>3</sup> . This 22 demonstrates that the computational work for the first time step can be reduced to almost 50% since the most time consuming part inside each Newton iteration is the IDR(4) solver. Similar results are shown by Figure 21(b). As the system gets closer to steady state, less Newton iterations are needed, and the IDR(4) solver also needs less iterations, as shown in Figure 22. At this stage, IDR(4) with _ε_ tol = 10 <sup>_−_</sup> <sup>3</sup> still needs less work than the IDR(4) with _ε_ tol = 10 <sup>_−_</sup> <sup>6</sup> but is no longer as significant. 3 2 _ε_ tol = 10 <sup>_−_</sup> <sup>6</sup> _ε_ tol = 10 <sup>_−_</sup> <sup>4</sup> _ε_ tol = 10 <sup>_−_</sup> <sup>3</sup> 1 2 3 4 Newton iter. (a) _h_ = 50 3 2 _ε_ tol = 10 <sup>_−_</sup> <sup>6</sup> _ε_ tol = 10 <sup>_−_</sup> <sup>4</sup> _ε_ tol = 10 <sup>_−_</sup> <sup>3</sup> 1 2 3 4 Newton iter. (b) _h_ = 40 Figure 22: Number of IDR(4) iterations at the 10-th time step We have already observed that the performance of our modeling is robust and convergence of the preconditioned Krylov solver happens quickly. Next, we report the computational time for computing the preconditioner _P_ 1 and applying the preconditioned IDR(4) solver of the first Newton step for the first time step for different FVM discretization mesh sizes. We solve the Jacobian system up to an accuracy of 10 <sup>_−_</sup> <sup>4</sup>, and the computational results are given by Table 2. Here “-” represents running out of memory, # _DF_ represents the size of the Jacobian system, _tS_ 1 denotes the time to compute the Schur complement in _P_ 1, and all the time are measured in seconds. Table 2: Computational time for the 1st Newton iteration _h_ # _DF_ _tS_ 1 IDR(4) `backslash` 40 1,03e+05 3 _._ 85 0,25 0,13 20 2,01e+05 8 _,_ 12 0,52 0,36 10 3,97e+05 17 _,_ 84 1,06 1,18 5 7,91e+05 38 _,_ 44 2,13 1054,62 2.5 1,58e+06 81 _,_ 42 4,34 The computational results in Table 2 show the advantage of our preconditioner in solving the large-scale Jacobian system over the direct solver. The time to solve the preconditioned system using the IDR(4) solver scales linearly with the system size, and is much smaller than the time to apply the direct solver when the mesh sizes are smaller than 20. For large-scale Jacobian systems, the direct solver either takes up too much CPU time or fails to solve the Jacobian system due to running out of memory. For smaller Jacobian systems, the direct solver shows the advantage over preconditioned Krylov solvers. This is primarily because there is a big overhead when applying the preconditioned IDR(4) solver while the `backslash` operator is highly optimal for smaller systems. 23 The time to compute the Schur complement in preconditioner _P_ 1 scales almost linearly with the system sizes. ### 6 Conclusions In this paper, we studied the modeling and simulation of pipeline gas networks. We applied the finite volume method (FVM) to discretize the incompressible isothermal Euler equation, and compared it with the finite difference method (FDM). Numerical results show the advantage of the FVM over the FDM. To model gas networks, we introduced the SDF gas network, which represents the topology of the network interconnection and reduces the size of the algebraic constraints of the resulting differential algebraic equation (DAE) compared with current research. To simulate such a DAE system, we proposed the _direction_ _following_ (DF) ordering of the edges of the SDF network. Through such an DF ordering, we exploited the structure of the system matrix and proposed an efficient preconditioner to solve the DAE. Numerical results show the advantage of our algorithms. ### References [1] A. Osiadacz. Simulation of transient gas flows in networks. _Internat._ _J._ _Numer._ _Methods_ _Fluids_, 4(1):13–24, 1984. [2] A. Osiadacz. _Simulation_ _and_ _analysis_ _of_ _gas_ _networks_ . Gulf Publishing, Houston, TX, 1987. [3] W. Q. Tao and H. C. Ti. Transient analysis of gas pipeline network. _Chem._ _Eng._ _J._, 69(1):47 - 52, 1998. [4] S. Grundel, N. Hornung, and S. Roggendorf. Numerical aspects of model order reduction for gas transportation networks. In _Simulation-Driven_ _Modeling_ _and_ _Optimization_, volume 153 of _Springer_ _Proceedings_ _in_ _Mathematics_ _&_ _Statistics_, pages 1–28. 2016. [5] M. Gugat, F. M. Hante, M. Hirsch-Dick, and G. Leugering. Stationary states in gas networks. _Netw._ _Heterog._ _Media_, 10(2):295–320, 2015. [6] M. C. Steinbach. On PDE solution in transient optimization of gas networks. _J._ _Comput._ _Appl._ _Math._, 203(2):345 - 361, 2007. [7] A. Zlotnik, M. Chertkov, and S. Backhaus. Optimal control of transient flow in natural gas networks. In _2015_ _54th_ _IEEE_ _Conference_ _on_ _Decision_ _and_ _Control_ _(CDC)_, pages 4563–4570, Dec 2015. [8] F. M. Hante, G. Leugering, A. Martin, L. Schewe, and M. Schmidt. _Challenges_ _in_ _optimal_ _control_ _problems_ _for_ _gas_ _and_ _fluid_ _flow_ _in_ _networks_ _of_ _pipes_ _and_ _canals:_ _from_ _modeling_ _to_ _industrial_ _applications_, pages 77–122. Springer Verlag, Singapore, 2017. [9] J. Zhou and M. A. Adewumi. Simulation of transients in natural gas pipelines using hybrid TVD schemes. _Internat._ _J._ _Numer._ _Methods_ _Fluids_, 32(4):407–437, 2000. [10] H. Egger. A robust conservative mixed finite element method for isentropic compressible flow on pipe networks. _SIAM_ _J._ _Sci._ _Comput._, 40(1):A108–A129, 2018. [11] A. J. Osiadacz and M. Yedroudj. A comparison of a finite element method and a finite difference method for transient simulation of a gas pipeline. _Appl._ _Math._ _Model._, 13(2):79–85, 1989. [12] M. Chaczykowski. Sensitivity of pipeline gas flow model to the selection of the equation of state. _Chem._ _Eng._ _Res._ _Des._, 87(12):1596 - 1603, 2009. [13] A. Herr´an-Gonz´alez, J. M. De La Cruz, B. De Andr´es-Toro, and J. L. Risco-Mart´ın. Modeling and simulation of a gas distribution pipeline network. _Appl._ _Math._ _Model._, 33(3):1584 - 1600, 2009. 24 [14] M. Herty, J. Mohring, and V. Sachers. A new model for gas flow in pipe networks. _Math._ _Methods_ _Appl._ _Sci._, 33(7):845–855, 2010. [15] S. Grundel, N. Hornung, B. Klaassen, P. Benner, and T. Clees. Computing surrogates for gas network simulation using model order reduction. In _Surrogate-Based_ _Modeling_ _and_ _Optimiz-_ _ation_, Applications in Engineering, pages 189–212. 2013. [16] A. F¨ugenschuh, B. Geißler, R. Gollmer, A. Morsi, J. R¨ovekamp, M. Schmidt, K. Spreckelsen, and M.C. Steinbach. _Chapter_ _2:_ _Physical_ _and_ _technical_ _fundamentals_ _of_ _gas_ _networks_, pages 17–43. Society for Industrial and Applied Mathematics, Philadelphia, 2015. [17] P. Benner, S. Grundel, C. Himpe, C. Huck, T. Streubel, and C. Tischendorf. _Differential-_ _Algebraic_ _Equations_ _Forum_, chapter Gas Network Benchmark Models. Springer, Berlin, Heidelberg, 2018. [18] H. Egger, T. Kugler, and N. Strogies. Parameter identification in a semilinear hyperbolic system. _Inverse_ _Probl._, 33(5):055022, 2017. [19] E. F. Toro and S. J. Billett. Centred TVD schemes for hyperbolic conservation laws. _IMA_ _J._ _Numer._ _Anal._, 20(1):47–79, 2000. [20] C. Johnson and J. Pitk¨aranta. An analysis of the discontinuous Galerkin method for a scalar hyperbolic equation. _Math._ _Comp._, 46(173):1–26, 1986. [21] T. G. Grand´on, H. Heitsch, and R. Henrion. A joint model of probabilistic/robust constraints for gas transport management in stationary networks. _Comput._ _Manag._ _Sci._, 14(3):443–460, 2017. [22] M. Herty. Modeling, simulation and optimization of gas networks with compressors. _Netw._ _Heterog._ _Media_, 2(1):81–97, 2007. [23] S. Grundel, L. Jansen, N. Hornung, T. Clees, C. Tischendorf, and P. Benner. Model order reduction of differential algebraic equations arising from the simulation of gas transport networks. In _Progress_ _in_ _Differential-Algebraic_ _Equations_, Differential-Algebraic Equations Forum, pages 183–205. 2014. [24] M. Herty. Coupling conditions for networked systems of Euler equations. _SIAM_ _J._ _Sci._ _Comput._, 30(3):1596–1612, 2008. [25] S. Grundel and L. Jansen. Efficient simulation of transient gas networks using IMEX integ ration schemes and MOR methods. In _2015_ _54th_ _IEEE_ _Conference_ _on_ _Decision_ _and_ _Control_ _(CDC)_, pages 4579–4584, 2015. [26] U. M. Ascher, S. J. Ruuth, and B. Wetton. Implicit-explicit methods for time-dependent partial differential equations. _SIAM_ _J._ _Numer._ _Anal._, 32(3):797–823, 1995. [27] Y. Saad. _Iterative_ _Methods_ _for_ _Sparse_ _Linear_ _Systems_ . Society for Industrial and Applied Mathematics, Philadelphia, 2003. [28] P. Sonneveld and M. B. van Gijzen. IDR(s): A family of simple and fast algorithms for solving large nonsymmetric systems of linear equations. _SIAM_ _J._ _Sci._ _Comput._, 31(2):1035– 1062, 2008. [29] J. Bang-Jensen and G. Z. Gutin. _Digraphs:_ _theory,_ _algorithms_ _and_ _applications_ . Springer Verlag London, London, 2008. [30] S. Roggendorf. Model order reduction for linearized systems arising from the simulation of gas transportation networks. Master’s thesis, Rheinischen Friedrich-Wilhelms-Universit¨at Bonn, Germany, 2015. [31] M. Benzi, G. H. Golub, and J. Liesen. Numerical solution of saddle point problems. _Acta_ _Numer._, 14:1–137, 2005. 25 [32] H. Elman, D. Silvester, and A. Wathen. _Finite_ _Elements_ _and_ _Fast_ _Iterative_ _Solvers_ . Oxford University Press, New York, June 2014. [33] T. Rees. _Preconditioning_ _Iterative_ _Methods_ _for_ _PDE-Constrained_ _Optimization_ . PhD thesis, University of Oxford, 2010. [34] Y. Qiu. _Preconditioning_ _Optimal_ _Flow_ _Control_ _Problems_ _Using_ _Multilevel_ _Sequentially_ _Semiseparable_ _Matrix_ _Computations_ . PhD thesis, Delft Institute of Applied Mathematics, Delft University of Technology, 2015. [35] J. W. Pearson. On the development of parameter-robust preconditioners and commutator arguments for solving Stokes control problems. _Electron._ _Trans._ _Numer._ _Anal._, 44:53–72, 2015. [36] M. Porcelli, V. Simoncini, and M. Tani. Preconditioning of active-set Newton methods for PDE-constrained optimal control problems. _SIAM_ _J._ _Sci._ _Comput._, 37(5):S472–S502, 2015. [37] M. Wathen, C. Greif, and D. Sch¨otzau. Preconditioners for mixed finite element discretizations of incompressible MHD equations. _SIAM_ _J._ _Sci._ _Comput._, 39(6):A2993–A3013, 2017. [38] J. Pestana and A. J. Wathen. Natural preconditioning and iterative methods for saddle point systems. _SIAM_ _Rev._, 57(1):71–91, 2015. [39] M. Stoll and T. Breiten. A low-rank in time approach to PDE-constrained optimization. _SIAM_ _J._ _Sci._ _Comput._, 37(1):B1–B29, January 2015. [40] A. J. Wathen. Preconditioning. _Acta_ _Numer._, 24:329–376, 2015. [41] M. B. van Gijzen and P. Sonneveld. Algorithm 913: An elegant IDR(s) variant that efficiently exploits biorthogonality properties. _ACM_ _Trans._ _Math._ _Software_, 38(1):5:1–5:19, 2011. [42] C. Kelley. _Solving_ _Nonlinear_ _Equations_ _with_ _Newton’s_ _Method_ . Society for Industrial and Applied Mathematics, Philadelphia, 2003. [43] R. Dembo, S. Eisenstat, and T. Steihaug. Inexact Newton methods. _SIAM_ _J._ _Numer._ _Anal._, 19(2):400–408, 1982. 26

섹션 본문

섹션 본문이 없습니다.

참고문헌

참고문헌 정보가 없습니다.