# wntr.sim.hydraulics module¶

class wntr.sim.hydraulics.HydraulicModel(wn, mode='DD')[source]

Bases: object

Hydraulic model class.

Parameters: wn : WaterNetworkModel object Water network model mode: string (optional) Specifies whether the simulation will be demand-driven (DD) or pressure dependent demand (PDD), default = DD

Methods

 compute_polynomial_coefficients(x1, x2, f1, …) Method to compute the coefficients of a smoothing polynomial. get_hydraulic_equations(x) Get hydraulic equations. get_jacobian(x) Get jacobian get_node_balance_residual(flow, demand, …) Mass balance at all the nodes set_jacobian_constants() Set the jacobian entries that depend on the network status but do not depend on the value of any variable.
Parameters: wn: WaterNetworkModel mode: str

Methods

 compute_polynomial_coefficients(x1, x2, f1, …) Method to compute the coefficients of a smoothing polynomial. get_hydraulic_equations(x) Get hydraulic equations. get_jacobian(x) Get jacobian get_node_balance_residual(flow, demand, …) Mass balance at all the nodes set_jacobian_constants() Set the jacobian entries that depend on the network status but do not depend on the value of any variable.
get_hydraulic_equations(x)[source]

Get hydraulic equations.

Parameters: x : numpy array values of heads, demands, flows, and leak flowrates residuals: numpy array Returns residuals for hyrdaulic equations.
set_jacobian_constants()[source]

Set the jacobian entries that depend on the network status but do not depend on the value of any variable.

ordering is very important here the csr_matrix data is stored by going though all columns of the first row, then all columns of the second row, etc ex: row = [0,1,2,0,1,2,0,1,2] col = [0,0,0,1,1,1,2,2,2] value = [0,1,2,3,4,5,6,7,8] A = sparse.csr_matrix((value,(row,col)),shape=(3,3))

then A=>
0 3 6 1 4 7 2 5 8
and A.data =>
[0, 3, 6, 1, 4, 7, 2, 5, 8]
get_jacobian(x)[source]

Get jacobian

Parameters: x : numpy array values of heads, demands, flows, and leak flowrates Returns ——- jacobian: scipy.sparse.coo_matrix Returns the jacobian headloss equations.
get_node_balance_residual(flow, demand, leak_demand)[source]

Mass balance at all the nodes

Parameters: flow : list of floats List of flow values in each pipe List of residuals of the node mass balances
compute_polynomial_coefficients(x1, x2, f1, f2, df1, df2)[source]

Method to compute the coefficients of a smoothing polynomial.

Parameters: x1: float point on the x-axis at which the smoothing polynomial begins x2: float point on the x-axis at which the smoothing polynomial ens f1: float function evaluated at x1 f2: float function evaluated at x2 df1: float derivative evaluated at x1 df2: float derivative evaluated at x2 A tuple with the smoothing polynomail coefficients starting with the cubic term.