1 Introduction

The isothermal Euler equations are a well-known model for gas flow in pipelines. They form a quasilinear system of hyperbolic partial differential equations. For the range of flows that occurs in the operation of gas networks, often a simpler model is sufficient. In this paper we study a semilinear model that is derived from the isothermal Euler equations and generates reasonable states for sufficiently small Mach numbers and sufficiently high gas pressures without abrupt changes. We present some analytical solutions of the semilinear model. The analytical example solutions help to improve the understanding of the model. For example, the semilinear model has some ghost-solutions that are outside of the range where the model is physically valid. These are traveling waves that travel with the speed of sound. For all subsonic velocities, there exist exponential traveling waves solutions. Moreover, for certain parameters there also exist exponential profiles that travel with constant acceleration. These new example solutions complement the product solutions already presented in Gugat and Ulbrich (2017).

As a first step in the optimization of gas networks, it makes sense to consider stationary optimization, see Schmidt et al. (2016). However, since supply and demand are functions of time, the dynamic control for gas pipeline systems allows a more efficient operation. In Groß et al. (2018), instationary flows are considered as a sequence of stationary gas flows. In our paper, the stationary flows for the semilinear model are given in Sect. 4.

A comparison between transient optimal control and multi-period optimization of steady states is presented in Sect. 5 using a simplified example. The discussion clarifies the differences between optimal states that are obtained as solutions of the dynamic optimal control problem and optimal states that are generated with the steady state approach. If the problem data have only small variability as a function of time, the quasi-static approach is very useful. However, for problem data with large variations the dynamic model has some advantages.

In Grimm et al. (2019) a multilevel model of the European entry-exit gas market is studied where the transmission system operator (TSO) sets maximal technical capacities at the first level. At the fourth level, the TSO minimizes transport cost. Both levels require to take into consideration the transient dynamics of the gas flow in the networks as soon as the consumer demand varies with time.

Questions about the robustness of the gas transmission system including effects on the power grid are studied in Ahumada-Paras et al. (2021). The simulation of gas networks coupled to power grids is studied in Fokken et al. (2019). State and parameter estimation for gas pipeline networks is considered in Sundar and Zlotnik (2019).

This paper has the following structure. In Sect. 2 we present the isothermal Euler equations. In Sect. 3 we derive the semilinear model and present some analytical solutions. In Sect. 4 we consider the stationary solutions of the semilinear model. In Sect. 5, we show how in a dynamic optimal control problem non-monotone pressure profiles can occur, whereas for a quasi-static control, the pressure profiles along a horizontal pipe are always monotone.

In Sect. 6 we present an illustration of the errors caused by a finite differences discretization of the partial differential equation. Moreover, we

show that optimal steady states generated with the quasi-static approach in general do not converge to the optimal state for the PDE-constrained optimal control problem. This is a contribution to the discussion of the limits of the multi-period steady state approach. The quasi-static model is not suitable if the problem data change rapidly over time.

2 The isothermal Euler equations

Let an interval \([0,\, L ]\) be given that represents a pipe e of length L. Let \(D >0\) denote the diameter of the pipe, \(\lambda _{fric} (x) \ge 0\) the space-dependent Lipschitz continuous friction coefficient and \(\varphi (x)\in (-\infty ,\,\infty )\) the space-dependent Lipschitz continuous slope. Define

\(s_{lope}(x) =\sin (\varphi (x)\,)\) and \(\theta (x) = \frac{\lambda _{fric} (x)}{D }\). Let g denote the gravitational constant. Let \(\rho >0\) denote the gas density, \(p >0\) the pressure and q the mass flow rate. We assume that we have an ideal gas that satisfies the state equation

$$\begin{aligned} p = R^e_s \, T^e\,\rho , \end{aligned}$$
(1)

where \(R^e_s\) is the gas constant and \(T^e\) is the temperature. We study the well–known isothermal Euler equations

$$\begin{aligned} \left\{ \begin{array}{l} \rho _t + q_x = 0, \\ q_t + \left( p + \frac{(q )^2}{\rho } \right) _x = - \frac{1}{2} \theta \frac{q \; |q |}{\rho } - \rho \, g \, s _{lope} \end{array} \right. \end{aligned}$$
(2)

that govern the flow through a single pipe (see for example Banda et al. 2006). In our analysis also the velocity

$$\begin{aligned} v = \frac{q }{\rho } \end{aligned}$$

and the speed of sound c that is given by

$$\begin{aligned} \left( \frac{1}{c } \right) ^2 = \frac{\partial \rho }{\partial p } = \frac{1}{ R^e_s\, T^e} \end{aligned}$$
(3)

appear. Thus we have

$$\begin{aligned} c = \sqrt{R^e_s\, T^e}. \end{aligned}$$

For the Mach number M this yields

$$\begin{aligned} M = \frac{v }{c } = c \; \frac{q }{p }. \end{aligned}$$
(4)

We consider the case of subsonic flow where the absolute value of the velocity of the gas is strictly less than the speed of sound in the gas, that is for the Mach number we have

$$\begin{aligned} |M |<1. \end{aligned}$$

This is the case that is relevant for gas transportation networks where upper bounds for the velocity of the gas are prescribed in the operation of the gas pipelines. In order to state (2) in terms of the dimensionless Mach-number M and the pressure p, we observe that

$$\begin{aligned} \rho= & {} \frac{1}{c^2} \, p , \\ q= & {} \frac{1}{c } \, M \,p . \end{aligned}$$

Hence if \(M \not =0\) the first equation of (2) yields

$$\begin{aligned} \mathrm{ln}(p )_t + (c \, M ) \,\mathrm{ln}(|M | \, p )_ x =0. \end{aligned}$$
(5)

Moreover, the second equation of (2) yields

$$\begin{aligned}&\frac{1}{p } (p \, M )_t + c \, \left( 1 - M^2 \right) \, \frac{p _x}{p } + 2\, c \, \frac{ M }{p } (p \, M )_x\\&\quad = - \frac{1}{2} \theta \, c \; M \,|M | - g \, s _{lope}\,\frac{1}{c }. \end{aligned}$$

3 The semilinear model for slow subsonic flow

Since \(\mathrm{ln}(p )_t = \frac{p _t}{p }\), if the pressure p is sufficiently high and \(p_t\) is bounded, \(\mathrm{ln}(p )_t\) is small. Equation (5) implies that if \(\mathrm{ln}(p )_t\) is small (for example, close to a stationary state), the product \((c \, M ) \,\mathrm{ln}(|M | \, p )_ x\) is small. If the Mach number has a small absolute value, \(1 - (M )^2\) is close to 1. Therefore if the pressure p is sufficiently large and \(p_t\) is bounded and for nonzero Mach numbers with small absolute value we can approximate the solution of the second equation of (2) by the solution of the equation

$$\begin{aligned} \mathrm{ln}(p \, |M |)_t + \frac{c }{M } \, \mathrm{ln}(p )_x = - \frac{1}{2} \theta \, c \; |M | - g \, s_{lope}\,\frac{1}{c } \, \frac{1}{M }. \end{aligned}$$
(6)

Define the left-hand side of (6) as \(L_1 =\mathrm{ln}(p \, |M |)_t + \frac{c }{M } \, \mathrm{ln}(p )_x\). Define \(L_2 =\mathrm{ln}(p \, |M |)_t +\frac{c }{M } \left( 1 - (M )^2 \right) \,\mathrm{ln}(p )_x +2\, c \, M \,\mathrm{ln}(p \, |M |)_x.\) Let a solution of (2) with \(M\not =0\) be given. Then we have

$$\begin{aligned} L_2 =-\frac{1}{2} \theta \, c \; |M | - g \, s _{lope}\,\frac{1}{c } \, \frac{1}{M } \end{aligned}$$
(7)

and (5) is also satisfied. Note that the right-hand sides of (6) and (7) are equal. For the difference \(E:= L_1 -L_2\) of the left-hand sides of (6) and (7) we have

$$\begin{aligned} E = c \, M \,\mathrm{ln}(p )_x + 2\, \mathrm{ln}(p )_t \end{aligned}$$

which is small if the time derivative and the Mach number are sufficiently small and the pressure is sufficiently large. For \(M \not =0\), define the matrix

$$\begin{aligned} A (M ) = c \left( \begin{array}{cc} 0 &{} M \\ \frac{1}{M } &{} 0 \end{array} \right) . \end{aligned}$$

In matrix notation we obtain from (5) and (6) the model

$$\begin{aligned} \left( \begin{array}{c} \mathrm{ln}(p ) \\ \mathrm{ln}(|M | \, p ) \end{array} \right) _t + A (M ) \, \left( \begin{array}{c} \mathrm{ln}(p ) \\ \mathrm{ln}(|M | \, p ) \end{array} \right) _x = \left( \begin{array}{c} 0 \\ - \frac{ \theta }{2}\, c \, |M | - \frac{g \, s_{lope}}{c \, M } \end{array} \right) . \end{aligned}$$
(8)

Note that the eigenvalues of the system matrix A(M) are \(-c\) and c. In particular, they are constant.

Remark 1

The eigenvalues of the quasilinear system (2) are \(v + c\) and \(v - c\). This implies that the error in the eigenvalues can only be small as long as |v| (the absolute value of the Mach number M) is sufficiently small.

Since the first equation in (2) has not been modified, also (8) guarantees the conservation of mass. In terms of the physical variables p and q, the model (8) can be stated as the well–known semilinear model (see for example Herty et al. 2009; Gugat et al. 2018)

$$\begin{aligned} \left\{ \begin{array}{l} \frac{1}{ c^2} \, p _t + q_x = 0, \\ q_t + p_x = - \frac{1}{2} \theta \, c^2 \,\frac{q \; |q |}{p } - g \, s_{lope} \, \frac{p }{ c^2}. \end{array} \right. \end{aligned}$$
(9)

Note that (9) is semilinear since the system matrix is constant whereas (8) is stated in quasilinear form.

3.1 Analytical solutions of the semilinear model

Now we present several transient analytical solutions of (9).

Example 1

Assume that \(c >0\) and

$$\begin{aligned} \theta \, c^2 - 2\, g \, s_{lope} =0. \end{aligned}$$
(10)

For a function \(\alpha _e \in L^\infty (-\infty ,\, \infty )\) with \(\alpha _e < 0\) consider the Cauchy problem with (9) and the initial conditions

$$\begin{aligned}p (0,\, x) = -c \, \alpha _e(x),\; q (0,\, x) = \alpha _e(x). \end{aligned}$$

Then for \(t\ge 0\) the solution of the Cauchy problem is given by the traveling waves solution

$$\begin{aligned} p (t,\, x) = -c \, \alpha _e(x + c \, t),\; q (t,\, x) = \alpha _e(x + c \, t). \end{aligned}$$
(11)

This can be seen as follows. We have \(\frac{1}{ c^2} \, p_t = - \, \alpha _e'(x + c \, t) = - q_x (t,\, x)\), hence the first equation in (9) holds. Moreover, we have

$$\begin{aligned} q_t + p_x = c \, \alpha _e'(x + c \, t) - c \, \alpha _e'(x + c \, t) =0. \end{aligned}$$

Since \(\frac{q \; |q |}{p } = \frac{1}{c } \, \alpha _e(x + c \, t)\), due to assumption (10) we have

$$\begin{aligned}&\frac{1}{2} \theta \, c^2 \,\frac{q \; |q |}{p } + g \, s_{lope} \, \frac{p }{ c^2}\\&\quad = \frac{1}{2} \theta \, {c } \, \alpha _e(x + c \, t) - g \, s_{lope} \, \frac{1}{c } \, \alpha _e(x + c \, t) =0. \end{aligned}$$

Hence also the second equation of (9) holds. In Example 1, the solution is traveling with the velocity c and an arbitrary wave profile. In the next Example 2, we present a solution that is traveling with a velocity v with \(|v|<c\).

Example 2

Now we present a parametric family of traveling waves solution where the velocity \(v\in (-c ,\, c )\) is a real parameter. Note however, in contrast to Example 1 and Example 6 below, traveling waves with these subsonic velocities only exist with a special shape given by the exponential function.

Let a number \(\rho _0>0\) be given and define

$$\begin{aligned} \nu = \frac{1}{2}\, \theta \, v \, |v| + g \, s_{lope} . \end{aligned}$$
(12)

Consider the Cauchy problem with (9) and the initial conditions

$$\begin{aligned} p (0,\, x)= & {} c^2 \, \rho _0 \, \exp \left( \nu \, \frac{1}{c^2 - v^2} ( - x)\right) ,\\ q (0,\, x)= & {} v\, \rho _0 \, \exp \left( \nu \, \frac{1}{c^2 - v^2} ( - x)\right) . \end{aligned}$$

Then for \(t\ge 0\) the solution of the Cauchy problem is given by the traveling waves solution

$$\begin{aligned} p (t,\, x)= & {} c^2 \, \rho _0 \, \exp \left( \nu \, \frac{1}{c^2 - v^2} ( vt - x)\right) , \end{aligned}$$
(13)
$$\begin{aligned} q (t,\, x)= & {} v\, \rho _0 \, \exp \left( \nu \, \frac{1}{c^2 - v^2} ( v t - x)\right) . \end{aligned}$$
(14)

This can be seen as follows. We have

$$\begin{aligned} \frac{1}{ c^2} \, p_t = \rho _0 \, \frac{ \nu \,v }{c^2 - v^2} \exp \left( \nu \, \frac{1}{c^2 - v^2} ( vt - x)\right) = - q_x, \end{aligned}$$

hence the first equation in (9) holds. Moreover, we have

$$\begin{aligned} q_t + p_x= & {} \rho _0 \left( \frac{ \nu \,v^2 }{c^2 - v^2} - \frac{ \nu \,c^2 }{c^2 - v^2} \right) \exp \left( \nu \, \frac{1}{c^2 - v^2} ( vt - x)\right) \\= & {} - \rho _0 \, \nu \exp \left( \nu \, \frac{1}{c^2 - v^2} ( vt - x)\right) , \end{aligned}$$

and using the definition of \(\nu\) in (12) we obtain

$$\begin{aligned}&\frac{1}{2} \theta \, c^2 \,\frac{q \; |q |}{p } + g \, s_{lope} \, \frac{p }{ c^2}\\&\quad =\frac{1}{2} \theta \, v\, |v| \,\rho _0 \, \exp \left( \nu \, \frac{1}{c^2 - v^2} ( vt - x)\right) + g \, s_{lope} \, \rho _0 \, \exp \left( \nu \, \frac{1}{c^2 - v^2} ( vt - x)\right) \\&\quad =\rho _0 \left( \frac{1}{2} \theta \, v\, |v| \, + g \, s_{lope} \right) \, \exp \left( \nu \, \frac{1}{c^2 - v^2} ( vt - x)\right) \\&\quad = \rho _0\,\nu \, \exp \left( \nu \, \frac{1}{c^2 - v^2} ( vt - x)\right) . \end{aligned}$$

Hence also the second equation of (9) holds.

Example 3

For certain parameters, system (9) also has exponential wave solutions that travel with increasing speed with constant acceleration. This can happen for sufficiently small values of \(\theta\) if the gas flows downwards with constant slope. Let \(\beta = - \frac{\theta }{2}\). Assume that

$$\begin{aligned} g\, s_{lope} + c^2 \, \beta \ge 0. \end{aligned}$$

Let real numbers \(C_2 \le 0\) and \(C_3\) be given. Define

$$\begin{aligned} \lambda = - c^2 \,\beta - g\, s_{lope} \le 0 \end{aligned}$$

and the time-dependent velocity of the traveling pressure–wave profile

$$\begin{aligned} V(t)= \frac{1}{2}\, \lambda \, t^2 + C_2 \, t + C_3. \end{aligned}$$

Let \(v(t)= V'(t)\). Then the Cauchy problem for (9) with the initial conditions

$$\begin{aligned} q (0,\, x) = C_2\,\exp (\beta \, ( x - C_3)) ,\; p (0,\, x) = { c^2} \,\exp (\beta \, ( x -C_3)) \end{aligned}$$

has the solution

$$\begin{aligned} p (t,\, x)= & {} { c^2} \, \exp (\beta ( x - V(t)),\\ q (t,\, x)= & {} v (t) \, \exp (\beta ( x - V(t)) . \end{aligned}$$

This can be seen as follows. It is easy to check that the initial conditions for \(t=0\) hold. For \(t\ge 0\) we have

$$\begin{aligned} \frac{1}{ c^2}\, p_t + q_x = - \beta \, V'(t) \frac{p}{c^2} + \beta \, q = 0 \end{aligned}$$

hence the first equation in (9) holds. Moreover,

$$\begin{aligned} q_t + p_x =\left[ (c^2 - v(t)^2) \, \beta \, + \lambda \right] \exp (\beta ( x - V(t)). \end{aligned}$$

On the other hand, since \(v(t) \le 0\), we have

$$\begin{aligned} - \frac{1}{2} \theta \, q \,|q| \, \frac{c^2}{p} - g \, s_{lope} \, \frac{p}{c^2} =\,\left[ \frac{1}{2} \theta \,v(t)^2 - g \, s_{lope} \right] \, \exp (\beta ( x - V(t)). \end{aligned}$$

Thus the second equation in (9) holds if

$$\begin{aligned} (c^2 - v(t)^2) \, \beta \, + \lambda =\frac{1}{2} \theta \, v(t)^2 - g \, s_{lope} . \end{aligned}$$

Since \(\frac{1}{2} \theta = - \beta\), this equation holds if

$$\begin{aligned} c^2 \, \beta \, + \lambda = - g \, s_{lope} . \end{aligned}$$

But this is equivalent to the definition of \(\lambda\).

Note that the velocity is decreasing and if \(\lambda <0\) or \(C_2<0\) it is strictly decreasing and the solution becomes supersonic after finite time. On the other hand, if \(|\lambda |\) and \(|C_2|\) are sufficiently small, the velocity remains arbitrarily small for an arbitrarily long given finite time interval.

Example 4

There are also solutions with constant pressure where the flow rate is increasing. Assume that

$$\begin{aligned} s_{lope} < 0. \end{aligned}$$
(15)

Let a constant pressure value \(p >0\) and a real number \(\alpha \ge 0\) be given. Define the parameters

$$\begin{aligned} A= & {} \sqrt{2} \, \frac{p }{c^2}\, \sqrt{\frac{g\, | s_{lope} |}{\theta }}, \end{aligned}$$
(16)
$$\begin{aligned} \beta= & {} \frac{\sqrt{2}}{2} \, \sqrt{ \theta \, g\, | s_{lope} |}. \end{aligned}$$
(17)

Then \(A \,\beta = \frac{p }{c^2} g \, | s_{lope} | = \frac{\theta \,c^2}{2 \, p }\, A^2\).

Consider the Cauchy problem with (9) and the initial conditions

$$\begin{aligned}p (0,\, x) = p ,\; q (0,\, x) = A \, \tanh (\alpha ). \end{aligned}$$

Then the solution of the Cauchy problem is the constant pressure p and the increasing flow rate

$$\begin{aligned} q (t) = A \, \tanh (\alpha + \beta \, t). \end{aligned}$$

This can be seen as follows. We have

$$\begin{aligned} \frac{1}{c^2}\, p_t + q_x = 0 \end{aligned}$$

hence the first equation in (9) holds. Moreover,

$$\begin{aligned} q_t +p_x = \frac{A\, \beta }{\cosh ^2(\alpha + \beta \, t)} =A\, \beta - A\, \beta \, \tanh ^2(\alpha + \beta \, t). \end{aligned}$$

Moreover, since \(\alpha + \beta \, t\ge 0\) we have

$$\begin{aligned}&- \frac{1}{2} \theta \, c^2 \,\frac{q \; |q |}{p } - g \, s_{lope} \, \frac{p }{ c^2}\\&\quad = - \frac{1}{2\, p } \theta \, c^2 \,A^2 \, \tanh ^2(\alpha + \beta \, t) + g \,| s_{lope} | \, \frac{p }{ c^2}\\&\quad = A\,\beta - A\, \beta \, \tanh ^2(\alpha + \beta \, t) = q_t +p_x. \end{aligned}$$

Thus the second equation in (9) holds. For the Mach number we obtain

$$\begin{aligned}M (t) = \frac{c \, A}{p } \tanh (\alpha + \beta \, t) = \frac{\sqrt{2}}{c } \, \sqrt{\frac{g\, | s_{lope} |}{\theta }} \tanh (\alpha + \beta \, t). \end{aligned}$$

In particular, the Mach number is uniformly bounded and since it is increasing as an upper bound we have the limit

$$\begin{aligned} \lim _{t\rightarrow \infty } M (t) = \frac{\sqrt{2}}{c } \, \sqrt{\frac{g\, | s_{lope} |}{\theta }}. \end{aligned}$$

Hence if this limit is less than 1, the flow remains subsonic all the time. In particular, for suitable data it remains within the range where the model is valid. This situation occurs if for a moderately sloped pipe the gas flows downward along the pipe. Then without additional compressor action, the flow is driven by gravity and in the limit approaches a constant stationary state.

Note that in this solution the flow rate q changes permanently with time. So the behavior is completely different from stationary states, where the value of q is fixed all the time.

Example 5

Now we present a solution that is initially given by the trigonometric tangent function. Let (15) hold, A be as in (16) and \(\beta\) as in (17). Let a real number \(\alpha <0\) be given. As long as t satisfies \(\alpha + \beta \, t \in (-\pi /2,\,0 )\), that is

$$\begin{aligned}t \in \left( \frac{1}{\beta } \left( - \frac{\pi }{2} - \alpha \right) ,\, - \frac{\alpha }{\beta } \right) \end{aligned}$$

the constant pressure p with the increasing flow rate

$$\begin{aligned} q (t) = A \, \tan (\alpha + \beta \, t) \end{aligned}$$

solve (9). This can be seen as follows. It is easy to check that the first equation in (9) holds. Moreover we have

$$\begin{aligned} q_t +p_x = \frac{A\, \beta }{\cos ^2(\alpha + \beta \, t)} = A\, \beta \, \tan ^2(\alpha + \beta \, t) + A\, \beta . \end{aligned}$$

In addition, if \(\alpha + \beta \, t \in (-\pi /2,\, 0 )\) we have

$$\begin{aligned} - \frac{1}{2} \theta \, c^2 \,\frac{q \; |q |}{p } - g \, s_{lope} \, \frac{p }{ c^2}= & {} \frac{1}{2\, p } \theta \, c^2 \,A^2 \, \tan ^2(\alpha + \beta \, t) + g \,| s_{lope} | \, \frac{p }{ c^2}\\= & {} A\, \beta \, \tan ^2(\alpha + \beta \, t) + A\,\beta = q_t +p_x. \end{aligned}$$

Thus the second equation in (9) holds.

Note that at the time where \(\alpha + \beta \, t =0\), the sign of q(t) changes. This means that the direction of the gas flow changes. For \(\alpha + \beta \, t \ge 0\), the solution continues with the flow rate given by the hyperbolic tangent function as in Example 4.

Product solutions of (9) are given in Lemma 3 in Gugat and Ulbrich (2017).

Example 6

For certain parameter values, the semilinear model (9) has traveling waves solutions that travel with the speed of sound c. Note that this analytical solution is not within the range of parameters where the model is physically valid. We discuss this example since it shows that nonphysical solutions exist. Unwanted solutions of this type can be avoided by additional constraints on the range of the pressure values and the gas velocities/Mach numbers in the optimal control problems. With appropriate bounds these additional constraints reduce the size of the feasible set in such a way that only states within the physical range of the model are admitted.

Similarly as in (10) assume that

$$\begin{aligned} \theta \, c^2 + 2\, g \, s_{lope} =0. \end{aligned}$$
(18)

For a function \(\alpha _e \in L^\infty (-\infty ,\, \infty )\) with \(\alpha _e >0\) consider the Cauchy problem with (9) and the initial conditions

$$\begin{aligned}p (0,\, x) = c \, \alpha _e(x),\; q (0,\, x) = \alpha _e(x). \end{aligned}$$

Then for \(t\ge 0\) the solution of the Cauchy problem is given by the traveling waves solution

$$\begin{aligned} p (t,\, x) = c \, \alpha _e(x- c \, t),\; q (t,\, x) = \alpha _e(x - c \, t). \end{aligned}$$
(19)

This is similar as in Example 1, but with a different sign. This can be seen as follows. We have \(\frac{1}{ c^2} \, p_t = - \alpha _e'(x- c \, t) = - q_x (t,\, x)\), hence the first equation in (9) holds. Moreover, we have

$$\begin{aligned} q_t + p_x = - c \, \alpha _e'(x- c \, t) + c\, \alpha _e'(x- c \, t) =0. \end{aligned}$$

Since \(\frac{q \; |q |}{p } = \frac{1}{c} \, \alpha _e(x- c \, t)\), due to assumption (18) we have

$$\begin{aligned}&\frac{1}{2} \theta \, c^2 \,\frac{q \; |q |}{p } + g \, s_{lope} \, \frac{p }{ c^2}\\&\quad = \frac{1}{2} \theta \, c \, \alpha _e(x- c \, t) + g \, s_{lope} \, \frac{1}{c} \, \, \alpha _e(x- c \, t) =0. \end{aligned}$$

Hence also the second equation of (9) holds.

4 The stationary states

In this section, the stationary states for (9) are studied. The stationary solutions of the quasilinear system (2) have been studied in Gugat et al. (2015). We present the stationary states for the semilinear model not only for horizontal pipes, but also for pipes with non-zero slopes. The details are presented in Gugat et al. (2021).

For the stationary states, there exists a constant \(C_s\) such that \(c \, |q| = C_s\). If \(s_{lope} =0\) (that is for a horizontal pipe), we have \(\left( \frac{(p )^2}{2} \right) _x = - \frac{1}{2}\, \mathrm{sign}(M ) \, \theta \, C_s^2.\) Note that if \(M>0\), p is decreasing along the pipe and if \(M<0\), the gas flows in the opposite direction and p is increasing along the pipe. We obtain the well-known Weymouth equation

$$\begin{aligned} \frac{p (x)^2}{2} - \frac{p(0)^2}{2} = - \frac{1}{2}\, \mathrm{sign}(M ) \, \theta \, C_s^2\, x, \end{aligned}$$

(see for example Herty et al. 2009, equation (6)). If \(M >0\), the equation has real solutions only as long as x is sufficiently small. This implies that the model is well–defined only as long as the length L of the pipe is sufficiently small. Also for the quasilinear system (2) a blow up of the derivative for the stationary states occurs after a finite length, see (Gugat et al. 2015). Note that for the stationary states with \(q>0\), the gas velocity is increasing along the pipe and the blow up occurs at the point where the flow becomes sonic, that is when the gas velocity reaches the speed of sound c. Hence this point is outside of the range of validity of the semilinear model.

Now we consider the case that \(s_{lope} <0\). Similarly as for horizontal pipes, for a stationary state the flow rate q is constant along the pipe. We only obtain a stationary pressure that is constant along the pipe if the source term on the right-hand side of (9) vanishes. This is the case for a constant flow rate \({\bar{q}}>0\) and the constant pressure \({\bar{p}}>0\) with

$$\begin{aligned} {\bar{p}}^2 = \frac{ c^4 \, \theta \, |{\bar{q}}|^2}{ 2 \, g \, | s_{lope} | }. \end{aligned}$$
(20)

We also have the non-constant stationary solutions with \({\bar{q}}>0\) and

$$\begin{aligned} p (x) = {\bar{p}} \; \sqrt{ 1 + {\hat{C}} \, \exp \left( 2 \, g \,\frac{ | s_{lope} | }{c^2}\, x\right) }. \end{aligned}$$
(21)

with a real number \({\hat{C}}\) such that \(p (0) ={\bar{p}} \; \sqrt{ 1 + {\hat{C}}}\). This can be verified by checking that \(({\bar{q}}, p (x))\) satisfies (9).

5 A comparison between transient optimal control and multi-period optimization of steady states

While for demand functions that change very slowly in time, it makes sense to consider a quasi-static model, since at each moment the system state is very close to a steady state, for demand functions that move more rapidly with time, in general the state cannot be represented by a sequence of stationary states,

An overview over the range of gas demand, for example the daily demand range, can be found in Gupta et al. (2019). Note that the domestic demand is strongly weather related, it depends for example on the temperature, see also (Hribar et al. 2019).

As in Gupta et al. (2019), as an approximation of the shape of the demand profiles (in \(m^3/h\)) for 22 hours (from 0:00 to 22:00) we use the sum of three Gaussian kernels

$$\begin{aligned} q^{desi}(t) = \sum _{k=1}^3 a_k \,\exp \left( - \left( \frac{t- b_k}{c_k}\right) ^2 \right) . \end{aligned}$$

Suitable values of \((a_k, b_k, c_k)_{k=1}^3\) are given in Table IV in Gupta et al. (2019). Figure IV in Gupta et al. (2019) shows peak demands at 12:00 and 18:00. After the last peak, the demand decreases rapidly. Details for the testbed setup used for Gupta et al. (2019) are given in Mishra et al. (2016). Of course the total gas consumption on the time interval can easily be obtained by integrating \(q^{desi}\).

In order to compare the transient optimal control approach and the quasi-static optimization of steady states, let us first derive a PDE that is further simplified. From (9), under the assumptions that the second partial derivatives exist, \(s_{lope}= 0\) and \(\theta =0\) we obtain

$$\begin{aligned} q_{xx} = - \frac{1}{c^2} p_{tx} = \frac{1}{c^2} q_{tt} . \end{aligned}$$

Hence we arrive at the wave equation

$$\begin{aligned} q_{tt} = c^2\, q_{xx}. \end{aligned}$$

In order to determine a corresponding pressure, we use the first equation in (9), that is \(p_t = - c^2 \, q_x\). For \(x\in [0,\, L]\) this yields

$$\begin{aligned} p (t,\, x) = p (0, x) + \int \limits _0^t p_t(s,\, x)\, ds = p (0, x) - c^2 \, \int \limits _0^t q_x(s,\, x)\, ds. \end{aligned}$$
(22)

In order to come to a clear comparison of transient versus multi-period steady-state modeling we consider the problem to satisfy the consumer demand at the end \(x=L\) of a single pipe with inflow at the end \(x=0\). We consider the time interval \([0,\, T]\). Let a desired pressure value \(p^{desi}>0\) be given. This is the desired pressure value at the point where the gas enters the system. Let the continuous initial flow \(q_0\), the corresponding time derivative \(q_1\) and the continuous initial pressure \(p_0\) with \(p_0(0)=p^{desi}\) be given. If the gas is initially at rest, we have \(q_0=0\) and \(q_1=0\). We state this problem in the form of the optimal control problem

$$\begin{aligned} {\mathbf{(OCP(T))}} \left\{ \begin{array}{l} \min _{u \in L^2(0,\, T)} \int \limits _0^T | u(t) - p^{desi} |^2\, dt \\ q (0, x) = q_0(x), \; q_t(0, \, x) = q_1(x),\; p(0, \, x) = p_0(x), \\ q_{tt} = c^2\, q_{xx},\\ p (t,\, x) = p_0(x) - c^2 \, \int \limits _0^t q_x(s,\, x)\, ds, \\ p (t,\, 0) = u(t), \; q (t, \, L ) = q^{desi}(t) . \end{array} \right. \end{aligned}$$
(23)

The corresponding N-step steady-state model for a time grid \(\{t_1^{(N)},\, t_2^{(N)},\, \ldots ,\, t_N^{(N)}\}\subset [0, T]\) is

$$\begin{aligned} {\mathbf{(SSM(N))}} \left\{ \begin{array}{l} \min _{u\in {\mathbb {R}}^N} \sum _{k=1}^N | u_k - p^{desi} |^2 \\ q (t_k^{(N)}) = q^{desi}(t_k^{(N)}), \; p(t_k^{(N)},\, 0)= u_k, \\ p_x(t_k^{(N)},x) = - \frac{1}{2} \theta \, c^2 \,\frac{q(t_k^{(N)}) \; |q(t_k^{(N)})|}{p(t_k^{(N)},x)}. \end{array} \right. \end{aligned}$$
(24)

For the solution of \(\mathbf (SSM(N))\) we obtain optimal the values \(u_k = p^{desi} = p(t_k^{(N)},\, 0)\). The corresponding steady pressures along the pipe are determined by the ordinary differential equation for the steady state that can be solved explicitly, see Sect. 4 and also (Herty et al. 2009). Note that for the steady states that are used in \(\mathbf (SSM(N))\), the pressure is always decreasing along the pipe. For \(\theta =0\), we have \(p_x(t_k^{(N)},x) =0\) and we obtain constant pressure along the pipe for all time steps.

Now we look at the optimal state for \(\mathbf (OCP(T))\). The flow can be represented as the sum of traveling waves, \(q(t,\, x) = \alpha (t- \frac{x}{c}) + \alpha (t+ \frac{x}{c})\). Similar as in D’Alembert’s solution, for \(t\in [0,\frac{L}{c}]\) we define

$$\begin{aligned} \alpha (t) = \frac{1}{2c} \int \limits _0^{ct} q_1(x)\, dx + \frac{1}{2} \left( q_0(ct) - q_0(0) \right) . \end{aligned}$$

For \(t\in [-\frac{L}{c},0)\) we define \(\alpha (t) = - \frac{1}{2c} \int _0^{-ct} q_1(x)\, dx + \frac{1}{2} \left( q_0(-ct) - q_0(0) \right)\). Then the initial conditions hold. For \(t>\frac{L}{c}\) we define

$$\begin{aligned} \alpha (t) = q^{desi}\left( t- \frac{L}{c} \right) - \alpha \left( t- 2\frac{L}{c} \right) . \end{aligned}$$
(25)

Then the boundary condition \(q (t, \, L ) = q^{desi}(t)\) is satisfied.

For the pressure along the pipe, due to (22) we have

$$\begin{aligned}p (t,\, x)= & {} p_0(x) - c \, \int \limits _0^t - \alpha '\left( s- \frac{x}{c}\right) + \alpha '\left( s+ \frac{x}{c} \right) \, ds\\= & {} p_0(x) - c \, \left[ - \alpha \left( s- \frac{x}{c}\right) + \alpha \left( s + \frac{x}{c}\right) \right] |_{s=0}^t\\= & {} p_0(x) + c \, \left[ \alpha \left( t- \frac{x}{c} \right) - \alpha \left( t + \frac{x}{c}\right) - \alpha \left( -\frac{x}{c} \right) + \alpha \left( \frac{x}{c} \right) \right] . \end{aligned}$$

For the spatial derivative this yields

$$\begin{aligned} p_x(t,\, x) = p_0'(x) - \alpha '\left( t- \frac{x}{c} \right) - \alpha '\left( t + \frac{x}{c} \right) + \alpha '\left( -\frac{x}{c} \right) + \alpha '\left( \frac{x}{c} \right) . \end{aligned}$$
(26)

For the pressure at \(x=0\), we obtain

$$\begin{aligned}p(t,\, 0)= p(0,\, 0) - c^2 \, \int \limits _0^t q_x(s,\, 0)\, ds = p_0(0) - c \, \int \limits _0^t - \alpha '(s) + \alpha '(s) \, ds = p^{desi}. \end{aligned}$$

Let us assume that \(p_0'(x) =0\), that is initially the pressure is constant. This makes sense since, as stated in Gupta et al. (2019), from 12:00 h to 03:00 h, there is no significant flow inside the pipelines. Thus we can also assume \(q_0=0\) and \(q_1=0\). Then the variation of the spatial derivative \(p_x\) along the pipe depends on the variations of the derivative of \(q^{desi}\) with time. Since these can be quite large, in particular close to the peaks, for the dynamic PDE model the pressure can be both in increasing and decreasing along the pipe. This is in contrast to the quasi-static model.

For the sake of illustration, let us look at an example.

Example 7

Let a frequency \(\omega >0\) and \(\eta >0\) be given. Assume that \(q_0 = q_1 = 0\) and \(\frac{L}{c} = \frac{2\pi }{\omega }\). For \(t>0\) we consider the varying demand

$$\begin{aligned} q^{desi}(t) = \eta \left( 1 - \cos (\omega \, t)\right) . \end{aligned}$$

Since \(q_0 = q_1 = 0\), for \(t\in (-\frac{L}{c}, \, \frac{L}{c})\) we have \(\alpha (t)=0\).

For \(t\in (\frac{L}{c},\, 3 \frac{L}{c})\), due to (25) we have \(\alpha (t) = \eta \left( 1 - \cos (\omega \, t)\right)\). For \(t\in (3\frac{L}{c},\, 5 \frac{L}{c})\), due to (25) we have \(\alpha (t) = \eta \left( 1 - \cos (\omega \, t) - ( 1 - \cos (\omega \, t) )\right) =0\).

So it turns out that for \(t > - \frac{L}{c}\), \(\alpha\) is \(4 \frac{L}{c}\) periodic with the value zero on half of the time intervals.

To be precise, we have \(\alpha (t) = 0\) for \(t\in (-\frac{L}{c} + 4 \frac{L}{c} \, n , \, \frac{L}{c} + 4 \frac{L}{c} \, n )\), \(n \in \{0,1,2,3,\ldots \}\) and \(\alpha (t) = \eta \left( 1 - \cos (\omega \, t)\right)\) for \(t\in (\frac{L}{c} + 4 \frac{L}{c} \, n , \, 3\frac{L}{c} + 4 \frac{L}{c} \, n )\), \(n \in \{0,1,2,3,\ldots \}\).

For the derivative we obtain \(\alpha '(t) = 0\) for \(t\in (-\frac{L}{c} + 4 \frac{L}{c} \, n , \, \frac{L}{c} + 4 \frac{L}{c} \, n )\), \(n \in \{0,1,2,3,\ldots \}\) and \(\alpha '(t) = \eta \, \omega \, \sin (\omega \, t)\) for \(t\in (\frac{L}{c} + 4 \frac{L}{c} \, n , \, 3\frac{L}{c} + 4 \frac{L}{c} \, n )\), \(n \in \{0,1,2,3,\ldots \}\).

If \(p_0'(L)=0\) for \(t\in (2 \frac{L}{c} + 4 \frac{L}{c} \, n , \, 3\frac{L}{c} + 4 \frac{L}{c} \, n )\) this yields

$$\begin{aligned}p_x(t, \, L)= - \alpha '\left( t- \frac{L}{c} \right) - \alpha '\left( t + \frac{L}{c} \right) = - \eta \,\omega \, \sin (\omega \, t) . \end{aligned}$$

This illustrates the variations of \(p_x\) for the solution of \(\mathbf (OCP(T))\).

In contrast to this, for the solution of \(\mathbf (SSM(N))\) with the quasi-static approach the pressure p is always decreasing along the pipe.

Figure 1 shows the pressure waves for the optimal state for \(\mathbf (OCP(T))\) for \(p^{desi} = 10^6 Pa\), \(c=340m/s\) and \(L=1000m\), \(\eta =1000\). Note that the pressure profiles are not always monotone along the pipe.

Fig. 1
figure 1

The optimal pressure p for \(\mathbf (OCP(T))\) in Example 7

It is important to emphasize that the PDE model is particularly relevant for dynamic situations, for example if a gas power plant is started. For long-term planning problems (say for 12 months, see for example Aras and Aras 2004) the quasi-static approach can be justified.

6 Comparison between discretized transient optimal control and multi-period optimization of steady states

In Sect. 6.1 we compare numerical results obtained by discretized models with the solutions obtained by the PDE model. In Sect. 6.2 we compare results that are obtained from a quasi-static approach with the solutions obtained by the PDE model and show that refinement of the time grid in the quasi-static approach does not lead to convergence to the optimal state.

6.1 Comparison of the solutions of the PDE with the solutions for discretized models

As in Sect. 5 we consider a problem of optimal nodal profile control, where the profile desired by the consumer at the output node is given. We look for boundary controls such that for the generated flow the distance of the values at the output node to the desired profile is as small as possible.

Problems of optimal dynamic control for gas pipeline systems are studied in Osiadacz and Chaczykowski (2016) with the linear heat equation as a model for the system dynamics. In Krug et al. (2020), the time-domain decomposition for a general class of optimal control problems governed by semilinear hyperbolic systems is presented which could also be applied to gas network problems.

Let us start with the transient solution with constant pressure in Example 4 where the hyperbolic tangent appears. We consider a sloped pipe that goes slightly downwards, that is, (15) holds.

Let \(\alpha \ge 0\) be given. Define the desired pressure as \(p_d\) and the desired outflow rate at the output node \(x=L\) as

$$\begin{aligned} q_d(t) = A \, \tanh (\alpha + \beta \, t) \end{aligned}$$

with A as in (16) and \(\beta\) as in (17).

The control problem is to find an input pressure \(p ( t, \, 0)\) that minimizes

$$\begin{aligned} \int \limits _0^T (p (t, \, 0) - p_d )^2 \, dt \end{aligned}$$

subject to

$$\begin{aligned} p (0, x)= & {} p_d,\ q (0, x) = A \, \tanh (\alpha )\\ q (t, \, L )= & {} q_d(t) \end{aligned}$$

for all \(t\in [0, \, T]\) and (9). So the problem is to control the input pressure in such a way that the generated output pressure is as close as possible to the given desired value. From Example 4 we know that the optimal value of this problem is zero, that is the desired pressure value can be reached exactly. The analytical solution for the flow q for Example 4 is shown in Fig. 2. Note that the grid in Fig. 2 is not a discretization grid.

Fig. 2
figure 2

The analytical solution for the flow q for Example 4

For our computations we discretize the time horizon \([0, \, T]\) and the spatial domain \([0, \, L ]\) equidistantly by

$$\begin{aligned} t_k&= k \Delta t, \quad \Delta t = \frac{T}{K}&\text {for } k = 0, \ldots , K,\\ x_n&= n \Delta x, \quad \Delta x = \frac{L }{N}&\text {for } n = 0, \ldots , N \end{aligned}$$

with \(K, N \in {\mathbb {N}}\). We introduce the notation \(p_{k,n} = p(t_k, x_n)\).

Now we fully discretize the equations in (9) by using the implicit Euler method for the time and the explicit and implicit finite difference method for the space:

$$\begin{aligned} \begin{aligned} \frac{1}{ c^2} \, \frac{p_{k+1, n} - p_{k, n}}{\Delta t} + \frac{q_{k+1, n+1} - q_{k+1, n}}{\Delta x} ={}&0, \\ \frac{q_{k+1, n+1} - q_{k, n+1}}{\Delta t} + \frac{p_{k+1, n+1} - p_{k+1, n}}{\Delta x} ={}&- \frac{1}{2} \theta \, c^2 \,\frac{q_{k+1, n+1} \; |q_{k+1, n+1}|}{p_{k+1, n+1}}\\&\quad -\, g \, s_{lope} \, \frac{p_{k+1, n+1}}{ c^2}. \end{aligned} \end{aligned}$$
(27)

This discretization resembles of a first-order upwind scheme where we consider the location of the boundary data instead of the sign of the characteristic speeds.

To approximate the objective function we simply use the right Riemann sum

$$\begin{aligned} \sum _{k = 1}^K (p_{k,0} - p_d)^2 \end{aligned}$$
(28)

since \(p_{k,0} = p(0, x) = p_d\) is given data.

The optimization problem now reads

$$\begin{aligned} \begin{aligned} \min \quad&\sum _{k = 1}^K (p_{k,0} - p_d)^2\\ \text {subject to} \quad&p_{0,n} = p_d,&n = 1, \ldots , N,\\&q_{0,n} = A \tanh (\alpha ),&n = 1, \ldots , N,\\&q_{k,N} = q_d(t_k),&k = 1, \ldots , K,\\&(27),&k = 0, \ldots , K-1, n = 0, \ldots , N-1. \end{aligned} \end{aligned}$$
(29)

For the computations we have chosen the parameters \(\alpha = 0\), \(c = 340 \frac{m}{s}\), \(g = 9.81 \frac{m}{s^2}\), \(L = 2 \times 10^4m\), \(p = 5 \times 10^6 Pa\), \(s_{lope} \approx -0.0017\), \(T = 300s\), and \(\theta \approx 0.0117 \frac{1}{m}\) which yields \(A \approx 73.9026\frac{kg}{m^2s}\) and \(\beta \approx 0.01 \frac{1}{s}\). For the discretization \(K = 10\) time and \(N = 10\) spatial steps were used.

We used MATLAB and its function “fmincon” to solve (29) and then plot the results. For the flow Fig. 2 shows the analytical solution \(q(t, x) = A \, \tanh (\alpha + \beta \, t)\) and Fig. 3 shows its numerical counterpart. In the case of the pressure the numerical solution shows a small but noticeable difference to the constant analytical solution \(p(t, x) = p\), as can be seen in Fig. 4. This is due to the errors that are made by discretizing the problem. The objective function value of the solution is 0.1165, so note that it is quite small compared to the value of p.

Fig. 3
figure 3

The numerical solution for the flow q for Example 4

Fig. 4
figure 4

The numerical solution for the pressure for Example 4

6.2 The quasi-static approach

For the corresponding N-periodic quasi-static we need a time grid

$$\begin{aligned} \{t_1^{(N)},\, t_2^{(N)},\, \ldots ,\, t_N^{(N)}\}\subset [0, T] \end{aligned}$$

with \(t_1^{(N)}< t_2^{(N)} < \cdots t_N^{(N)}\). In the quasi-static approach, the flow rate is constant along the pipe. Hence the optimization problem is to minimize

$$\begin{aligned} \min _{u \in {{\mathbb {R}}^N}} \sum _{k=1}^N | u_k - p_{d} |^2 \end{aligned}$$

subject to \(p(t_k^{(N)},\, 0) = u_k\), \(q(t_k^{(N)}) = A \, \tanh (\alpha + \beta \, t_k^{(N)})\),

$$\begin{aligned} p_x(t_k^{(N)},x) = - \frac{1}{2} \theta \, c^2 \,\frac{q(t_k^{(N)}) \; |q(t_k^{(N)})|}{p(t_k^{(N)},x)} - g \, s_{lope} \, \frac{p(t_k^{(N)},\, x)}{ c^2}. \end{aligned}$$
(30)

It is easy to see that for the solution we have the pressure values

$$\begin{aligned} p(t_k^{(N)},\, 0) = p_{d} \end{aligned}$$

at \(x=0\). In the quasi-static model the generated pressure along the pipe is given by the steady state that is determined by the ordinary differential equation (30). As described in Sect. 4, we can only have a constant steady state if (20) holds with \({\overline{p}}\) in (20) replaced by \(p_{d}\) and \({\overline{q}}\) in (20) replaced by \(A \, \tanh (\alpha + \beta \, t_k^{(N)})\). Due to the definition of A in (16), this yields the equation \(p_d^2 = p_d^2 \, \tanh (\alpha + \beta \, t_k^{(N)})\). Since we have \(\tanh (\alpha + \beta \, t_k^{(N)})<1\), such a solution cannot exist.

In other words, for the stationary states the pressure is never constant along the pipe in the time grid. To be precise, the pressure \(p( t_{k^*}^{(N)} , x)\) is given by (21). Define

$$\begin{aligned} {\tilde{p}}(t) = \frac{ c^2 \, \sqrt{\theta } \, A \, \tanh (\alpha + \beta \, t) }{\sqrt{ 2 \, g \, | s_{lope} |} }. \end{aligned}$$

Due to the definition of A in (16) we have \({\tilde{p}}(t) = p_d\, \tanh (\alpha + \beta \, t)\).

Define \({\hat{C}}(t)\) such that \(p_d = {\tilde{p}}(t) \; \sqrt{ 1 + {\hat{C}}(t) }.\) Then we have

$$\begin{aligned} {\hat{C}}(t) = \frac{ p_d^2 }{ {\tilde{p}}(t)^2 } - 1 = \frac{ 1 }{ \tanh ^2(\alpha + \beta \, t) } - 1 >0 \end{aligned}$$

and

$$\begin{aligned} p (t,\, x) = {\tilde{p}}(t) \; \sqrt{ 1 + {\hat{C}}(t) \, \exp \left( 2 \, g \,\frac{ | s_{lope} | }{c^2}\, x\right) }. \end{aligned}$$

Hence we have for \(x\in (0,\, L]\)

$$\begin{aligned} p (t_k^{(N)},\, x) - p_d ={\tilde{p}}(t_k^{(N)}) \; \left[ \sqrt{ 1 + {\hat{C}}(t_k^{(N)}) \, \exp \left( 2 \, g \,\frac{ | s_{lope} | }{c^2}\, x\right) } - \sqrt{ 1 + {\hat{C}}(t_k^{(N)}) }\right] >0. \end{aligned}$$

Therefore, for \(N\rightarrow \infty\), the error in the approximation of the constant optimal pressure \(p_d\) will not converge to zero with refinement of the grid, that is for all \(x\in (0, L]\) we have

$$\begin{aligned} \lim _{N\rightarrow \infty } \min _{k\in \{1,\ldots ,N\}} \left| p (t_k^{(N)},\, x) - p_d\right| >0. \end{aligned}$$

Hence the quasi-static model does not lead to approximations that converge to the correct optimal state, for which the pressure is constant along the pipe.

7 Conclusions

We have presented examples that illustrate the dynamic behavior of the gas flow in pipes. In the examples, instationary analytical solutions are presented. Numerical examples illustrate that a reasonable discretization can approximate the dynamical behavior with a small numerical error. We have shown that in general, the multi-period steady state approach is unable to capture this dynamic behavior. We have presented an example where the optimal states generated with the multi-period steady state approach do not converge to the optimal transient state. Moreover, we have illustrated that in a dynamic situation with rapidly varying demand, pressure profiles can occur that are non-monotone along the pipe (see in particular Example 7).