hydraulic_simulation

Generic functions needed for the hydraulic simulations.

solve_hydraulics(net: Network, fluid: Fluid, controller: Controller = None, compute_hydrostatic: bool = True, compute_singular: bool = False, affine_fd: bool = False, warm_guess: bool = False, max_iters: int = 100, error_threshold: float = 100, damping_factor: float = 1, decreasing: bool = False, adaptive: bool = True, verbose: int = 1, ts_id: int = None, **kwargs) dict[source]

Runs a steady-state hydraulic simulation of the network. The procedure is based on a modified loop method, which solves for the equation:

\[\mathbf{B}\phi(\mathbf{B}^T\mathbf{\tilde{\dot m}}) = \mathbf{0}\]

where:

  • \(\mathbf{B}\) is the cycle matrix of the network graph

  • \(\mathbf{\tilde{\dot m}}\) is the vector of cycle mass flows

  • \(\phi\) is a function relating mass flow and pressure difference

Using the Newton-Raphson method.

The function returns a dictionary with the results of the simulation and details on the convergence of each Newton step. Mass flow, pressure differences and nodal pressures of the input Network are also modified in place with the results of the simulation.

Parameters:
  • net (Network) – Network to be simulated.

  • fluid (Fluid) – Working fluid to be used.

  • controller (Controller, optional) – Controller object. The default is None.

  • compute_hydrostatic (bool, optional) – Whether to consider hydrostatic pressure. The default is True.

  • compute_singular (bool, optional) – Not implemented. The default is False.

  • affine_fd (bool, optional) – Whether to use an affine function for pipe pressure losses in the transitional flow regime.. The default is False.

  • warm_guess (bool, optional) – Not implemented. The default is False.

  • max_iters (int, optional) – Maximum number of iterations for the solver. The default is 100.

  • error_threshold (float, optional) – Error threshold for the solver in Pa. The default is 100.

  • damping_factor (float, optional) – Damping factor for the Newton iterations. The default is 1.

  • decreasing (bool, optional) – Whether to reduce the damping factor at each Newton iteration. The default is False.

  • adaptive (bool, optional) – Whether to reduce the damping factor on plateau. The default is True.

  • verbose (int, optional) – Controls the verbosity of the simulation. The default is 1.

  • ts_id (int, optional) – Specifies the ID of the current time-step. The default is None.

  • **kwargs – Arbitrary keyword arguments.

Returns:

Dictionary with the simulation results.

Return type:

dict