# An Analytical Model for the Prediction of Emptying Processes in Single Water Pipelines
## 4 Analytical solution
### Reduction of the Second-Order ODE to a First-Order ODE
#### 4.2.2 Case \(\frac{dL(t)}{dt}\leq 0\) on the Interval \((t_{k+1},t_{k+2}]\)  
Following the same reasoning as in Section 4.2.1, Equation (13) can be expressed as:  
\[-L\frac{d^{2}L}{dt^{2}}=\frac{a}{(L_{T}-L)^{k}}+bL-c\bigg{(}\frac{dL}{dt} \bigg{)}^{2}L-d\bigg{(}\frac{dL}{dt}\bigg{)}^{2}-\frac{p_{atm}^{*}}{\rho_{w}} \tag{30}\]  
By making the substitution \(u=\frac{dt}{dt}\), Equation (30) can be presented as a linear first-order ODE for \(u^{2}\):  
\[\frac{d(u^{2})}{dL}-P(L)u^{2}=Q(L), \tag{31}\]  
where \(P(L)\) and \(Q(L)\) are the functions defined in (19).  
Proceeding analogously to the case where \(\frac{dL}{dt}\geq 0\), and given that \(u_{k+1}:=v(t_{k+1})\)\(=-L^{\prime}(t_{k+1})\)\(=-u(L(t_{k+1}))\), then Equation (31) admits a unique solution expressed as:  
\[u^{2}(L)=u_{k+1}^{2}\cdot\exp(A(L))+\exp(A(L))\cdot B_{2}(L), \tag{32}\]  
where  
\[A(L):=\int_{L_{e,t_{k+1}}}^{L}P(s)\,ds=2c(L-L_{e,t_{k+1}})+2d\ln\left|\frac{L }{L_{e,t_{k+1}}}\right| \tag{33}\]  
and  
\[B_{2}(L):=\int_{L_{e,t_{k+1}}}^{L}Q(s)\exp(-A(s))\,ds. \tag{34}\]  
Note that the expression (32) can be simplified to  
\[u^{2}(L)=\exp(-A(L))\cdot B_{2}(L)\]  
provided that the initial condition satisfies \(u_{k}=-v(t_{k})=0\).  
By applying an analogous reasoning as employed in the derivation of \(B_{1}\), the formula for \(B_{2}\) is obtained.  
Let us call  
\[\mathcal{F}_{j}:=\int_{L_{e,t_{k+1}}}^{L}s^{(-2d+j)-1}\exp(-2 cs)\,ds,\quad \text{for all}\quad j=0,1,2,3,...\]  
This is a family of special integrals (of the lower incomplete gamma functions kind [25]). From Equation (34), it follows that:\[B_{2}(L)=\int_{L_{\
u_{k+1}}}^{L}Q(s)\,\exp(-A(s))\,ds\] \[\qquad\qquad\qquad=\int_{L_{\
u_{k+1}}}^{L}\frac{2p_{atm}^{*}}{\rho_ {w}s}\,\exp(-A(s))\,ds-\int_{L_{\
u_{k+1}}}^{L}2b\exp(-A(s))\,ds\] \[\qquad\qquad\qquad\qquad\qquad\qquad-\int_{L_{\
u_{k+1}}}^{L}\frac {2a}{(L_{T}-s)^{k}s}\,\exp(-A(s))\,ds\] \[\qquad\qquad\qquad=\frac{2p_{atm}^{*}}{\rho_{w}}\exp(2 cL_{\
u_{k+ 1}})(L_{\
u_{k+1}})2^{d}\int_{L_{\
u_{k+1}}}^{L}s^{-(2d+1)}\exp(-2 cs)\,ds-\] \[\qquad\qquad\qquad 2b\exp(2 cL_{\
u_{k+1}})(L_{\
u_{k+1}})2^{d}\int_{L_{ \
u_{k+1}}}^{L}s^{-2d}\exp(-2 cs)\,ds\] \[\qquad\qquad\qquad\qquad\qquad-2a\exp(2 cL_{\
u_{k+1}})(L_{\
u_{k +1}})2^{d}\int_{L_{\
u_{k+1}}}^{L}\frac{1}{(L_{T}-s)^{k}}s^{-2d-1}\exp(-2 cs)\,ds\]  
Then  
\[B_{2}(L)=\exp(2 cL_{\
u_{k+1}})(L_{\
u_{k+1}})2^{d}\left[\frac{2p_{atm}^{*}}{ \rho_{w}}\mathcal{F}_{0}-2b\mathcal{F}_{1}-2a\mathcal{B}\right]\]  
where  
\[\mathcal{B}:=\int_{L_{\
u_{k+1}}}^{L}\frac{1}{(L_{T}-s)^{k}}s^{-2d-1}\exp(-2 cs )\,ds.\]  
Using the power series expansion of the expression \((L_{T}-s)^{-k}\), the integral can be estimated as:  
\[\mathcal{B}:=\int_{L_{\
u_{k+1}}}^{L}\frac{1}{(L_{T}-s)^{k}}s^{-2d-1}\exp(-2 cs )\,ds.\]  
Indeed,  
\[\mathcal{B}= \int_{L_{\
u_{k+1}}}^{L}\sum_{j=0}^{\infty}\binom{-k}{j}\frac{(- 1)^{j}}{(L_{T})^{k+j}}s^{(-2d+j)-1}\!\exp(-2 cs)\,ds\] \[= \sum_{j=0}^{\infty}\binom{-k}{j}\frac{(-1)^{j}}{(L_{T})^{k+j}} \int_{L_{\
u_{k+1}}}^{L}s^{(-2d+j)-1}\!\exp(-2 cs)\,ds\] \[= \sum_{j=0}^{\infty}\binom{-k}{j}\frac{(-1)^{j}}{(L_{T})^{k+j}} \mathcal{F}_{j}\] \[= \sum_{j=0}^{\infty}\frac{\Gamma(k+j)}{\Gamma(j+1)\Gamma(k)} \bigg{(}\frac{1}{L_{T}}\bigg{)}^{k+j}\mathcal{F}_{j}.\]  
Finally,  
\[B_{2}(L)=\exp(2 cL_{\
u_{k+1}})(L_{\
u_{k+1}})2^{d}\bigg{[}\frac {2p_{atm}^{*}}{\rho_{w}}\mathcal{F}_{0}-2b\mathcal{F}_{1}-2a\mathcal{B}\bigg{]}\] \[=\exp(2 cL_{\
u_{k+1}})(L_{\
u_{k+1}})2^{d}\bigg{[}\frac{2p_{atm}^ {*}}{\rho_{w}}\mathcal{F}_{0}-2b\mathcal{F}_{1}-2a\sum_{j=0}^{\infty}\frac{ \Gamma(k+j)}{\Gamma(j+1)\Gamma(k)}\bigg{(}\frac{1}{L_{T}}\bigg{)}^{k+j} \mathcal{F}_{j}\bigg{]}. \tag{35}\]