wntr.sim.core module

class wntr.sim.core.WaterNetworkSimulator(wn=None, mode='DD')[source]

Bases: object

Base water network simulator class.

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

get_node_demand(node_name[, start_time, …]) Calculates the demands at a node based on the demand pattern.
get_node_demand(node_name, start_time=None, end_time=None)[source]

Calculates the demands at a node based on the demand pattern.

Parameters:

node_name : string

Name of the node.

start_time : float

The start time of the demand values requested. Default is 0 sec.

end_time : float

The end time of the demand values requested. Default is the simulation end time in sec.

Returns:

demand_list : list of floats

A list of demand values at each hydraulic timestep.

class wntr.sim.core.WNTRSimulator(wn, mode='DD')[source]

Bases: wntr.sim.core.WaterNetworkSimulator

WNTR simulator class. The WNTR simulator uses a custom newton solver and linear solvers from scipy.sparse.

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

get_node_demand(node_name[, start_time, …]) Calculates the demands at a node based on the demand pattern.
run_sim([solver_options, convergence_error]) Run an extended period simulation (hydraulics only).
run_sim(solver_options={}, convergence_error=True)[source]

Run an extended period simulation (hydraulics only).

Parameters:

solver_options: dict

Solver options are specified using the following dictionary keys:

  • MAXITER: the maximum number of iterations for each hydraulic solve (each timestep and trial) (default = 100)
  • TOL: tolerance for the hydraulic equations (default = 1e-6)
  • BT_RHO: the fraction by which the step length is reduced at each iteration of the line search (default = 0.5)
  • BT_MAXITER: the maximum number of iterations for each line search (default = 20)
  • BACKTRACKING: whether or not to use a line search (default = True)
  • BT_START_ITER: the newton iteration at which a line search should start being used (default = 2)

convergence_error: bool (optional)

If convergence_error is True, an error will be raised if the simulation does not converge. If convergence_error is False, a warning will be issued and results.error_code will be set to 2 if the simulation does not converge. Default = True.