A Numerically Validated Approach to Modeling Water Hammer Phenomena Using Partial Differential Equations and Switched Differential-Algebraic Equations

Water distribution networks are susceptible to abrupt pressure fluctuations and spikes due to rapid adjustments in valve and pump settings. A common occurrence resulting from the sudden closure of a valve, known as water hammer, can potentially cause damage to various components within the network if not adequately addressed. Traditionally, water hammer phenomena have been modeled using a set of hyperbolic partial differential equations (PDEs). This study introduces a simplified model that employs switched differential-algebraic equations (DAEs). Recognized for their capacity to generate infinite peaks in response to sudden structural changes, switched DAEs provide mathematical representations of infinite peaks, manifested as Dirac impulses. This modeling approach offers the potential for more straightforward analyses of complex water networks in future research. To validate the proposed technique, a numerical comparison was conducted between the PDEand DAE-based models, using a basic configuration consisting of two reservoirs, a pipe, and a valve.


Introduction
Hydraulic transients are an inherent occurrence in water distribution networks, arising from intentional or accidental alterations in the network configuration, which result in immediate structural changes.These sudden modifications can have profound consequences on flow regimes, encompassing issues such as pump malfunctions or even severe pipeline failures.Conventionally, the flow of water in pipes has been mathematically represented by a system of nonlinear hyperbolic balance laws, commonly referred to as partial differential equations (PDEs) [1], wherein sudden structural changes lead to large peaks and fast transients in the solution.
Switched differential algebraic equations (DAEs) have been proposed as a framework to model these rapid transients.The concept of switched DAEs was initially developed for modeling electrical circuits [2], enabling an accurate mathematical representation of peaks and fast transients using Dirac impulses and jumps.This study focuses on the phenomenon known as water hammer, occurring due to abrupt velocity changes in pipelines, leading to significant increases in pressure.Water hammer is typically triggered by the rapid closure of valves, pump shutdowns, or pump restarts.It has been suggested that pressure spikes observed in PDE simulations can be effectively approximated using an appropriate switched DAE model.

Switched Differential Algebraic Equations (DAEs)
A DAE takes the following form: where, (E p , A p ) ∈ R n×n , p ∈ {1, • • • , P}, P ∈ N and σ : R → {1, • • • , P} is considered a piecewise constant, termed the switching signal.It is assumed to be right continuous and to have locally finitely many jumps. https://doi.org/10.56578/jii010201 For the existence and uniqueness of solutions in both switched and non-switched DAEs, reliance is placed on a notion of regularity for matrix pairs.This regularity condition ensures that the matrices involved in the DAE satisfy certain properties and exhibit well-behaved characteristics.
A commonly used regularity notion for matrix pairs is based on the concept of regularity indices.These indices provide information about the differential and algebraic aspects of the system, crucial for determining the solvability of the DAE.The differential index represents the highest order of differentiation appearing in the differential equations, while the algebraic index represents the highest order of algebraic dependence in the system.
A matrix pair (E p , A p ) is considered regular with index (v, µ) if the following conditions hold: 1.The matrix pair (E p , A p ) has a constant rank V for all p ∈ 1, . . ., P. The matrix Ap satisfies the rank condition rank (Ap − λE p ) ≤ µ for all p ∈ 1, . . ., P and all λ ∈ C [3].
These regularity indices, (v, µ), provide important insights into the solvability and stability of the DAE.By analyzing these indices, conditions under which a unique solution exists can be determined, and effective numerical methods for solving the DAE can be developed.
Proposition 1 (QWF, c.f. [4]).A matrix pair (E, A) ∈ R n×n × R n×n is regular if and only if there exist invertible transformation matrices S, T ∈ R n×n , which put (E, A) into QWF with n 1 := n − n 2 is some matrix and I is the identity matrix of the appropriate size.The paper structure is as follows.Section 1 establishes the definition of the water network and its constituent elements as a graph, introducing the mathematical models for pipes, reservoirs, and valves.Section 2 provides a concise overview of the mathematical preliminaries concerning conservation laws and switched differential-algebraic equations (DAEs).In Section 3, a comprehensive analysis of a simple water network that demonstrates the occurrence of water hammer is conducted, deriving both the corresponding partial differential equation (PDE) model and the switched DAE model for this network.Finally, Section 4 presents a numerical comparison between the PDE and switched DAE models.

Mathematical Modeling of Water Network
A finite undirected graph, denoted as (V, E), provides an efficient means of representing the structure of water distribution networks.This graph-based approach effectively captures the organization of the network, where the set V embodies the nodes and E ⊆ V × V corresponds to the edges that interconnect these nodes.In water distribution networks, each edge e ∈ E signifies a distinct pipe, facilitating the transmission of water between nodes.Conversely, the nodes v ∈ V comprise various network components, including junctions, pumps, valves, and reservoirs, each functioning as connection points or endpoints for the pipes.By employing this graph-based representation, the network's topology and connectivity can be accurately portrayed.The comprehensive framework formed by the nodes and edges enables modeling and examination of the interactions between diverse network components.This, in turn, permits the analysis and simulation of network dynamics, such as flow patterns and pressure fluctuations, while accounting for the interconnected pipes and associated components.Utilizing a graph-based representation yields valuable insights into the behavior of water distribution networks, facilitating a deeper understanding of the relationships between different components.This approach serves as a potent tool for analyzing network performance, optimizing its operation, and addressing challenges like water hammer and pressure variations [5].
In the following sections, a detailed overview of the modeling approach for the various components present in a water network is presented.The primary aim is to accurately capture the behavior and dynamics of these elements to enhance the understanding of the system as a whole.The models predominantly focus on pressure and flow variables, which are interconnected at the pipe endpoints.The specific type of node being represented determines the nature of this interconnection, as pressure and flow interact accordingly.Thorough analysis and modeling of these variables foster valuable insights into the functioning and performance of the water network.
To capture the intricate interactions within the water distribution system effectively, it is essential to consider the distinct characteristics of each network element.The nodes within the network encompass diverse entities such as junctions, pumps, valves, and reservoirs, collectively forming the set of nodes, denoted as V .Conversely, the pipes in the network are represented by the set of edges, denoted as E, forming a finite undirected graph (V, E).
Each edge e in E corresponds to an individual pipe within the water network, while the nodes v in V function as connection points or endpoints for these pipes.The nodes play a pivotal role in regulating and controlling the flow of water throughout the network [6].
In the modeling approach, particular attention is devoted to the physical quantities of pressure and flow.The values of pressure and flow at the pipe endpoints are interconnected, with the specific relationship depending on the nature of the node being considered.Furthermore, the modeling of flow within the pipes accounts for water density.Although water is typically assumed to be an incompressible fluid with a constant density, the focus is on accurately capturing the water hammer effect.To accomplish this, the slight compressibility of water is acknowledged and incorporated into the modeling framework to capture the dynamic behavior of the system [7].
By integrating these essential elements and variables into the models, a robust framework for simulating and analyzing water distribution networks is provided.This approach enables the examination of the impact of various factors, such as abrupt velocity changes, valve closures, pump shutdowns, and restarts, on the occurrence of pressure peaks and water hammer phenomena.Through these simulations, the efficacy of the modeling approach in approximating and understanding the system's behavior under diverse operational conditions is demonstrated.

Models of Water Flow in Pipe
Water flow in pipes can be characterized by two distinct models, contingent on whether the compressibility of water is taken into account.These models cater to different purposes and offer varying levels of accuracy, making them suitable for diverse analysis scenarios.A brief overview of both models is provided in this section.
1. Compressible Flow Model: In scenarios where the compressibility of water is considered, the density and mass flow rate of water are treated as variables that vary spatially.This implies that as water flows through the pipe, its density can change due to pressure variations.Compressible flow models involve the utilization of partial differential equations, such as the continuity equation, Navier-Stokes equation (momentum equation), and energy equation, to describe the conservation of mass, momentum, and energy.Numerical methods, such as computational fluid dynamics (CFD), are employed to solve these equations and analyze water behavior under different conditions, including transient phenomena like water hammer [8].
2. Incompressible Flow Model: In practical engineering applications, it is often deemed acceptable to model water as an incompressible fluid when studying the qualitative behavior of flow, particularly in large networks like water distribution systems.In this model, water is assumed to have constant density regardless of pressure changes.The governing equations for incompressible flow are simplified by treating the density as a constant, eliminating it from the equations.The continuity equation, which ensures the conservation of mass flow rate along the flow direction, is the primary equation used in this model.These simplified equations are more straightforward to solve and provide a reasonable approximation for steady-state and low-speed flows [9].
It is noteworthy that although the incompressible flow model neglects density variation, it still captures many essential flow characteristics, including flow rates, pressure drops, and hydraulic behavior, in most practical scenarios.However, for accurate analysis of transient phenomena like water hammer or high-speed flows, the compressible flow model, which accounts for water's compressibility, becomes necessary.Both models possess their own advantages and limitations, and the choice between them hinges on the specific application and the desired level of accuracy.The selection of the appropriate model is determined by the nature of the problem and the level of detail required for analysis.

Compressible flow in a pipe
Following [2], the pressure law for compressible fluids is employed: where, K ω > 0 denotes the bulk modulus, P a > 0 represents the atmospheric pressure, and ρ ω a > 0 is the density.Furthermore, the bulk modulus is connected to the speed of sound c > 0, as follows: It is noted that β ω := 1/K is the compressibility coefficient.In this study, a pipe uniformly filled with water is examined, possessing a positive mass density function denoted as (x, t) and a mass flux function denoted as q ω (x, t), both defined on the interval [0, L] × +.The objective is to model the compressible flow of water in the pipe using a balance law of the following nature: with the pressure law P : R + → R + given by ( 2) and where c f > 0 is the friction against the pipe wall and D > 0 is the diameter of the pipe.The initial condition for ( 4) is: It is assumed that an initial flow function q 0 (x) and an initial pressure function p 0 (x) exist, defined on the interval [0, L].The initial condition for water flow in a pipe is given implicitly in terms of pressure, reflecting its significance as a fundamental physical quantity in water networks.When pipes are connected to other elements in the network, additional boundary conditions are imposed to capture the behavior at the network boundaries.These boundary conditions depend on the specific configuration and characteristics of the interconnected elements [10], ensuring accurate representation of system dynamics.Including these boundary conditions is essential for modeling the flow dynamics and analyzing the behavior of water distribution networks.The inclusion of other network components introduces further constraints and equations that need to be satisfied for an accurate representation of the overall system dynamics.By expressing the initial condition in terms of the pressure, a more consistent and comprehensive representation of the interconnected pipes and their interactions with other network elements is ensured.This approach allows for capturing the complex dynamics and interactions within the water network, taking into account the pressure variations and their effects on the overall system behavior.Thus, the choice of an implicit initial condition in terms of the pressure provides a more suitable and physically relevant representation when considering the connections between individual pipes and other components in a water distribution network.

Quasi stationary water flow model
For an initial flow function q 0 : [0, L] and an initial pressure function p L : [0, L] → R + , the problem with an implicit initial condition given in terms of pressure rather than density is considered.This choice is motivated by the significance of pressure as a fundamental physical quantity, especially when the pipes are interconnected with other elements of the water distribution network.In such cases, additional boundary conditions are introduced as the individual pipes interface with the broader network [5]:

Reservoir
Within the water network graph, a reservoir functions as a node, contributing to the overall system dynamics.Characterized by unrestricted mass flow and a predetermined pressure value, the reservoir plays an essential role.When a pipe is connected to the left side of a reservoir, a boundary condition affecting the pressure behavior at the pipe's starting point is introduced, as demonstrated in the PDE model (4).This connection also imposes constraints on the variable P 0 within the ODE model (6).These constraints govern the initial conditions and the reservoir's subsequent evolution, impacting the flow characteristics and pressure distribution throughout the water network.Understanding the interaction between a reservoir and its connected pipe is therefore crucial for comprehending the system's behavior.

Valve
To maintain simplicity, a modeling approach incorporating a valve with a reservoir, as depicted in Figure 1, is adopted.This integration facilitates accounting for the valve's behavior within the system while preserving a straightforward framework.The valve-reservoir combination imposes specific algebraic constraints that regulate their interaction.These constraints establish relationships between various variables and introduce additional conditions that affect the system's dynamics.By incorporating the valve and reservoir as a unified model, their interconnected effects can be effectively examined, and their implications on the overall behavior of the water network can be assessed.where, P ω V , Q ω V denotes the flow pressure through the valve and P D is the pressure of the reservoir located.

A Review of a Simple Water Distribution System
A simple water distribution system is investigated, consisting of an upstream reservoir with a fixed pressure P U , a single conduit with a fixed length L, and a valve connected to a downstream reservoir with pressure P .P D < P U , as shown in Figure 2.

Figure 2. Simple set up for water hammer
The described scenario, involving the abrupt closure of a valve, represents a typical situation in which water hammer can occur in a system.The objective is to evaluate the effectiveness of the PDE model and the switched DAE model in capturing the water hammer effect within this specific network architecture.To achieve this, solution concepts employed by both approaches to address this water network problem are discussed first.By examining and comparing various proposed solution methods, the capability of each model to accurately represent and explain the water hammer phenomenon can be assessed.

PDE Solution Framework
The balance law in the pipe is considered in conjunction with the pressure law (2).
and for u = (ρ ω , q) ∈ U , The initial condition is given by (5), where the initial density ρ ω 0 is induced by the typically considered initial pressure p 0 via the invertible pressure law.The boundary conditions in terms of the Figure 2 is given by It is crucial to emphasize that the discontinuity resulting from the switch affects only the boundary condition.Consequently, the well-posedness analysis can be performed independently for each mode.This is feasible because the partial differential equation (PDE) can effectively be "restarted" at t = t S , using the final value of the solution on the interval [0, t S ] as the initial condition.As a result, the conditions for well-posedness, such as strict hyperbolicity, genuine nonlinearity, and S-Lipschitz continuity [6], can be examined independently of the valve's state.This approach allows for assessing the well-posedness of each mode individually and investigating their behavior as self-contained entities, ultimately providing a more comprehensive understanding of the system's dynamics.With initial and boundary conditions imposed as constants, it is evident that Eq. ( 7) holds.The Jacobian of the flux function in the equation can be expressed as follows [11]: and invoking the pressure law (2) we see that P ′ (ρ) = K ρa > 0 independently of ρ.Hence the eigenvalues of A(ρ, q) are Hence, λ 1 (u) > λ 2 (u) for all u = (ρ, q) ∈ U and hence (4) with pressure law ( 2) is strictly hyper-bolic.The eigenvectors of A(u) are . Hence and analogously Consequently, genuine nonlinearity is established.Clearly S is locally Lipschitz continuous.The wellposedness of the boundaries follows from [6] since for the open valve situation, and for the closed valve it holds, as we are in a subsonic case i.e., Therefore, it is reasonable to expect that numerical simulations will yield accurate approximations of the solutions to the corresponding initial/boundary value problem for both the compressible and incompressible fluid models.Numerical methods, such as finite difference, finite element, or finite volume techniques, can be employed to discretize the governing equations and solve them numerically.In numerical simulations, the continuous domain of the pipe network is typically discretized into a finite grid or mesh.The governing equations are then approximated using discretization schemes, which transform the partial differential equations into a system of algebraic equations that can be solved numerically.The accuracy of the numerical approximation depends on factors such as the grid resolution, the choice of numerical scheme, and the time integration method [11].
It is important to emphasize that numerical simulations provide valuable insights and predictions, but they are approximations of the actual system behavior.The accuracy of the results relies on the accuracy of the mathematical model, the quality of the numerical discretization, and the appropriate selection of model parameters and boundary conditions.Validation of the numerical simulations is essential to ensure the reliability of the results.This can be achieved by comparing the numerical solutions with experimental data or analytical solutions, whenever available.Sensitivity analyses and convergence studies can also be conducted to assess the robustness and accuracy of the numerical methods.
In conclusion, numerical simulations play a crucial role in the study of water flow in pipe networks, enabling the investigation of complex system behavior, analysis of different scenarios, and optimization of network design and operation.Through numerical simulations, engineers and researchers can gain valuable insights into the dynamics of water distribution systems and make informed decisions for efficient and reliable water supply.

Switched DAE Framework
The quasi-stationary model ( 6), in conjunction with the valve-dependent boundary conditions (valve open on [0, t S ) and valve closed on [t s , ∞)), for a setup resembling the one illustrated in Figure 2, gives rise to a switched differential-algebraic equation (DAE) represented by: where, x = (Q, P 0 , P L ) ⊤ , and where, It is worth noting that the switched DAE (8) contains a nonlinear term g σ (x), which makes it unsuitable for direct application of the distributional solution framework discussed in Section 1.1.Previous studies, such as LibeTren12, have examined nonlinear switched DAEs; however, these approaches inherently exclude the incorporation of Dirac impulses in x.Since capturing the water hammer effect requires the presence of Dirac impulses in the solution x of (8), the evaluation of g σ (x) in general becomes unclear (e.g., the determination of the sine of a Dirac impulse).
Lemma 2. Consider the nonlinear initial-trajectory problem (ITP) where either (E, A) = (E 1 , A 1 ) or (E, A) = (E 2 , A 2 ) and g(x) = g 1 (x) = g 2 (x) as in (9).Then for every initial trajectory x 0 ∈ (D pw C ∞ ) 3 and every inhomogeneity f induced by a piecewise-smooth function, there exists a unique solution of the ITP in the sense of Definition 1.
which is equivalent to P 0 = −f 2 , P L = −f 3 and The Ordinary Differential Equation (ODE) (6) ensures the existence and uniqueness of local solutions, even in scenarios where the right-hand side lacks global Lipschitz continuity.This guarantee hinges significantly on the presence of a negative sign in the quadratic term.This negative term, acting as a form of a stabilizing influence, curtails any tendency for the solution to grow unbounded.It provides a sort of damping mechanism, enabling the solution to stay well-regulated.
Indeed, the absence of global Lipschitz continuity could complicate the analysis.However, the unique structure of the ODE empowers us to affirm the existence and uniqueness of solutions across all times.The presence of the negative sign in the quadratic term precludes the solution from diverging or showing unbounded growth, thereby maintaining the solution's well-behaved nature.
In the context of the Initial Transition Problem (ITP), this theorem of existence and uniqueness carries over directly from the ODE.Even if there are discrepancies in the initial conditions, signified by P 0 and P L , that result in a discontinuity in the solution, they only manifest as simple jumps in the solution without impacting its overall existence and uniqueness.
Therefore, despite the lack of global Lipschitz continuity, the unique characteristics of the ODE and the negative sign in the quadratic term ensure the global existence and uniqueness of solutions.The ITP manages any discrepancies in the initial values via simple jumps, thereby preserving the overall well-posedness of the problem. Case For the corresponding ITP with initial trajectory x 0 = Q 0 , P 0 0 , P 0 L we can directly derive the following unique solution: , where, δ 0 denotes the Dirac impulse located at t = 0.
Corollary 3. The switched nonlinear DAE ( 8), ( 9) has for every initial condition Q(0) = Q 0 ∈ R a unique solution in the sense of Definition given in the study [1].In particular, the jump and the Dirac impulse in P L at t S are given by:

Comparison of Both Modeling Approaches
The ultimate objective of this study is to establish a rigorous proof of convergence, in an appropriate sense, between the solution (q, P (ρ)) of the balance law given by Eqns.( 2), ( 4), ( 5), (7), and the solutions (Q, P 0 , P L ) of the switched DAE represented by Eqns.( 8), (9), as the compressibility coefficient β ω approaches zero.In this context, the focus lies on analyzing the abrupt change and Dirac impulse in pressure resulting from the closure of the valve.Specifically, it is assumed that the initial condition specified in Eq. ( 5) ensures the solution of the PDE the interval [0, t S ) remains stationary.In other words, both the spatial and temporal components, denoted by q(t, x), become constant once the valve is closed, and the dynamics within the pipe stabilize.
For the numerical simulations, a third-order HEOC (High-Order Essentially Non-Oscillatory Conservative) scheme, as described in the study [7], is employed.The upper portion of Figure 3 illustrates the results for the pressure values at the valve over the time interval [0.4s, 4s] with initial values [12][13][14].
and pipe parameters A significant surge in pressure is observed immediately following the switching time, denoted as t S = 0.5 s.Subsequently, the pressure exhibits periodic settling to a new equilibrium value.The frequency of this periodic behavior is dependent on the length of the pipe, represented by L (larger L corresponds to a lower frequency), and the speed of sound, which is higher for pipes with smaller compressibility coefficients β ω .
To facilitate a comparison between the results, it is necessary to approximate the pressure value p(t, L) as t approaches infinity.Instead of running the simulation for an extensive duration, a settling time ϵ > 0 is employed, and the average of p(t, L) is computed over the interval (t S + ϵ, T ], where T > t S + ϵ denotes the total duration of the simulation.The value predicted by the switched DAE is In Table 1 the relative error between PL and P L t + S is presented for decreasing compressibility coefficients β ω . For the largest value of β ω , the value P L t + S is found to be a very good approximation of PL , and the approximation improves for decreasing β ω .To compare the peak in p(t, L) immediately after the valve closure with the Dirac impulse P L [t S ] that occurs at the switching time, the approximation of a Dirac impulse can be employed.Recall that a Dirac impulse δ ts at t s > 0 can be approximated by a sequence of functions denoted as δ ϵ ts (t).These functions satisfy the conditions δ ϵ ts (t) = 0 for t ̸ = [t s , t s + ϵ] and ts+ϵ ts δ ϵ ts (t)dt = 1.
p(t, L) = P imp t S δ ε (t) + PL , t ∈ (t S , T ] , hence we can approximate the magnitude of the "smoothed-out" Dirac impulse occurring in the PDE model as follows: The Dirac impulse induced by the switched DAE is (see Corollary 3): In order to evaluate P imp t S for comparison, we will proceed in the following manner: We will evaluate the steady state of (10) alongwith f given in (9) for t ∈ (0, t s ): to get steady state put ( Q = 0) then substituting c 1 = 0.0393, c 2 = 1.0188e −04 , and P U , P D from numerical setup we get: A comparison between P imp t S and P imp t S for different values of the compressibility coefficient β ω at tS is presented in Table 2.The accuracy of the approximation is not very high for large values of β ω .However, as the compressibility coefficient β ω decreases, the accuracy of the approximation improves significantly.
It is crucial to note that the selection of ε directly affects the accuracy of the approximation.This is demonstrated in Table 3, which showcases the relationship between the choice of ε and the accuracy of the approximation.
However, it is important to emphasize that the qualitative trend of the error decreasing as the compressibility coefficient decreases remains consistent.While the precise values presented in Table 3 may differ, the general observation of a decreasing error with decreasing compressibility coefficient remains valid.

Conclusion
In this research, a novel method for water hammer modelling using switched differential-algebraic equations (DAEs) is proposed.This method was juxtaposed with a more complex compressible nonlinear system of balance laws.Validation of the model was achieved by performing numerical simulations of the partial differential equations (PDE) model, which substantiated the hypothesis that the switched DAE model could effectively approximate the PDE model under low compressibility coefficients.
Future endeavours will revolve around two crucial aspects.One concerns the establishment of a rigorous proof of convergence, which is expected to validate the switched DAE model's suitability for approximating the more intricate compressible nonlinear system of balance laws.It is postulated that such a formal proof will elevate the trustworthiness and applicability of the switched DAE model, thereby advancing its practical use in water hammer phenomena analysis.
Simultaneously, it is intended to broaden the investigation to encapsulate more complex scenarios, such as larger networks.It is well-documented that water hammer incidents often transpire within intricate piping systems, thus, necessitating the consideration of multiple pipes and nodes.By venturing into these larger networks, an enriched comprehension of water hammer dynamics in practical applications can be developed.This expansion will necessitate the incorporation of additional variables, for instance, junction conditions and network topology, to depict accurately the complex hydraulic behaviour observed in large-scale systems.
The ultimate aspiration is to enhance predictive capabilities and formulate effective strategies for mitigating the deleterious effects of water hammer in real-world scenarios.The amalgamation of the switched DAE model and numerical simulations of the PDE model proffers a promising blueprint for understanding and managing water hammer phenomena, irrespective of the system's complexity.

Data Availability
Not applicable.

Figure 1 .
Figure 1.Valve in combination with reservoir

Table 3 .
Error comparison with different ε