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.
check_infeasibility  
check_jac  
check_jac_for_zero_rows  
get_demand_or_head_residual  
get_headloss_residual  
get_leak_demand_residual  
get_leak_poly_coeffs  
get_pdd_poly1_coeffs  
get_pdd_poly2_coeffs  
get_pump_line_params  
get_pump_poly_coefficients  
get_results  
initialize_demand  
initialize_flow  
initialize_head  
initialize_leak_demand  
initialize_results_dict  
print_jacobian  
print_jacobian_nonzeros  
reset_isolated_junctions  
save_results  
set_isolated_junctions_and_links  
set_network_inputs_by_id  
store_results_in_network  
update_network_previous_values  
update_tank_heads  
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.
check_infeasibility  
check_jac  
check_jac_for_zero_rows  
get_demand_or_head_residual  
get_headloss_residual  
get_leak_demand_residual  
get_leak_poly_coeffs  
get_pdd_poly1_coeffs  
get_pdd_poly2_coeffs  
get_pump_line_params  
get_pump_poly_coefficients  
get_results  
initialize_demand  
initialize_flow  
initialize_head  
initialize_leak_demand  
initialize_results_dict  
print_jacobian  
print_jacobian_nonzeros  
reset_isolated_junctions  
save_results  
set_isolated_junctions_and_links  
set_network_inputs_by_id  
store_results_in_network  
update_network_previous_values  
update_tank_heads  
get_hydraulic_equations(x)[source]

Get hydraulic equations.

Parameters:
x : numpy array

values of heads, demands, flows, and leak flowrates

Returns:
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

Returns:
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

Returns:
A tuple with the smoothing polynomail coefficients starting with the cubic term.