# wntr.network.elements module¶

The wntr.network.elements module includes elements of a water network model, including junction, tank, reservoir, pipe, pump, valve, pattern, timeseries, demands, curves, and sources.

Contents

 Junction(name, wn) Junction class, inherited from Node. Tank(name, wn) Tank class, inherited from Node. Reservoir(name, wn[, base_head, head_pattern]) Reservoir class, inherited from Node Pipe(name, start_node_name, end_node_name, wn) Pipe class, inherited from Link. Pump(name, start_node_name, end_node_name, wn) Pump class, inherited from Link. HeadPump(name, start_node_name, …) Head pump class, inherited from Pump. PowerPump(name, start_node_name, …) Power pump class, inherited from Pump. Valve(name, start_node_name, end_node_name, wn) Valve class, inherited from Link. PRValve(name, start_node_name, end_node_name, wn) Pressure reducing valve class, inherited from Valve. PSValve(name, start_node_name, end_node_name, wn) Pressure sustaining valve class, inherited from Valve. PBValve(name, start_node_name, end_node_name, wn) Pressure breaker valve class, inherited from Valve. FCValve(name, start_node_name, end_node_name, wn) Flow control valve class, inherited from Valve. TCValve(name, start_node_name, end_node_name, wn) Throttle control valve class, inherited from Valve. GPValve(name, start_node_name, end_node_name, wn) General purpose valve class, inherited from Valve. Pattern(name[, multipliers, time_options, wrap]) Pattern class. TimeSeries(model, base[, pattern_name, category]) Time series class. Demands(patterns, *args) Demands class. Curve(name[, curve_type, points, …]) Curve base class. Source(model, name, node_name, source_type, …) Water quality source class.
class wntr.network.elements.Junction(name, wn)[source]

Bases: wntr.network.base.Node

Junction class, inherited from Node.

Parameters: name : string Name of the junction. wn : WaterNetworkModel WaterNetworkModel object the junction will belong to coordinates tuple: The node coordinates, (x,y) demand float: The current demand at the node head float: The current head at the node initial_quality float: The initial quality (concentration) at the node leak_area float: The leak area at the node leak_demand float: The current demand at the node leak_discharge_coeff float: The leak discharge coefficient leak_status bool: The current leak status at the node name str: The name of the node node_type returns "Junction" tag str: A tag or label for the node

Methods

 add_demand(base, pattern_name[, category]) Add a new demand entry to the Junction add_leak(wn, area[, discharge_coeff, …]) Add a leak control to the water network model remove_leak(wn) Remove a leak control from the water network model todict() Dictionary representation of the node
nominal_pressure = None

float: The nominal pressure attribute is used for pressure-dependent demand simulations. This is the lowest pressure at which the junction receives the full requested demand.

minimum_pressure = None

float: The minimum pressure attribute is used for pressure-dependent demand simulations. Below this pressure, the junction will not receive any water.

leak_status

bool: The current leak status at the node

leak_area

float: The leak area at the node

leak_discharge_coeff

float: The leak discharge coefficient

node_type

returns "Junction"

add_demand(base, pattern_name, category=None)[source]

Add a new demand entry to the Junction

Parameters: base : float The base demand value for this new entry pattern_name : str or None The name of the pattern to use or None for a constant value category : str, optional A category name for this demand
add_leak(wn, area, discharge_coeff=0.75, start_time=None, end_time=None)[source]

Add a leak control to the water network model

Leaks are modeled by:

Q = discharge_coeff*area*sqrt(2*g*h)

where:
Q is the volumetric flow rate of water out of the leak g is the acceleration due to gravity h is the gauge head at the junction, P_g/(rho*g); Note that this is not the hydraulic head (P_g + elevation)
Parameters: wn : WaterNetworkModel Water network model containing the junction with the leak. This information is needed because the WaterNetworkModel object stores all controls, including when the leak starts and stops. area : float Area of the leak in m^2. discharge_coeff : float Leak discharge coefficient; Takes on values between 0 and 1. start_time : int Start time of the leak in seconds. If the start_time is None, it is assumed that an external control will be used to start the leak (otherwise, the leak will not start). end_time : int Time at which the leak is fixed in seconds. If the end_time is None, it is assumed that an external control will be used to end the leak (otherwise, the leak will not end).
remove_leak(wn)[source]

Remove a leak control from the water network model

Parameters: wn : WaterNetworkModel Water network model
coordinates

tuple: The node coordinates, (x,y)

demand

float: The current demand at the node

head

float: The current head at the node

initial_quality

float: The initial quality (concentration) at the node

leak_demand

float: The current demand at the node

name

str: The name of the node

tag

str: A tag or label for the node

todict()

Dictionary representation of the node

class wntr.network.elements.Tank(name, wn)[source]

Bases: wntr.network.base.Node

Tank class, inherited from Node.

Parameters: name : string Name of the tank. wn : WaterNetworkModel WaterNetworkModel object the tank will belong to coordinates tuple: The node coordinates, (x,y) demand float: The current demand at the node head float: The current head at the node init_level The initial tank level at the start of simulation initial_quality float: The initial quality (concentration) at the node leak_area float: The leak area at the node leak_demand float: The current demand at the node leak_discharge_coeff float: The leak discharge coefficient leak_status bool: The current leak status at the node level Returns tank level (head - elevation) name str: The name of the node node_type returns "Tank" tag str: A tag or label for the node vol_curve The volume curve, if defined vol_curve_name Name of the volume curve to use, or None

Methods

 add_leak(wn, area[, discharge_coeff, …]) Add a leak to a tank. remove_leak(wn) Remove a leak from a tank todict() Dictionary representation of the node
head

float: The current head at the node

leak_status

bool: The current leak status at the node

leak_area

float: The leak area at the node

leak_discharge_coeff

float: The leak discharge coefficient

init_level

The initial tank level at the start of simulation

node_type

returns "Tank"

vol_curve

The volume curve, if defined

vol_curve_name

Name of the volume curve to use, or None

level

Returns tank level (head - elevation)

add_leak(wn, area, discharge_coeff=0.75, start_time=None, end_time=None)[source]

Add a leak to a tank. Leaks are modeled by:

Q = discharge_coeff*area*sqrt(2*g*h)

where:
Q is the volumetric flow rate of water out of the leak g is the acceleration due to gravity h is the gauge head at the bottom of the tank, P_g/(rho*g); Note that this is not the hydraulic head (P_g + elevation)

Note that WNTR assumes the leak is at the bottom of the tank.

Parameters: wn: :class:~wntr.network.model.WaterNetworkModel The WaterNetworkModel object containing the tank with the leak. This information is needed because the WaterNetworkModel object stores all controls, including when the leak starts and stops. area: float Area of the leak in m^2. discharge_coeff: float Leak discharge coefficient; Takes on values between 0 and 1. start_time: int Start time of the leak in seconds. If the start_time is None, it is assumed that an external control will be used to start the leak (otherwise, the leak will not start). end_time: int Time at which the leak is fixed in seconds. If the end_time is None, it is assumed that an external control will be used to end the leak (otherwise, the leak will not end).
remove_leak(wn)[source]

Remove a leak from a tank

Parameters: wn: :class:~wntr.network.model.WaterNetworkModel Water network model
coordinates

tuple: The node coordinates, (x,y)

demand

float: The current demand at the node

initial_quality

float: The initial quality (concentration) at the node

leak_demand

float: The current demand at the node

name

str: The name of the node

tag

str: A tag or label for the node

todict()

Dictionary representation of the node

class wntr.network.elements.Reservoir(name, wn, base_head=0.0, head_pattern=None)[source]

Bases: wntr.network.base.Node

Reservoir class, inherited from Node

Parameters: name : string Name of the reservoir. wn : WaterNetworkModel The water network model this reservoir will belong to. base_head : float, optional Base head at the reservoir. Internal units must be meters (m). head_pattern : str, optional Head pattern. base_head The constant head (elevation) for the reservoir, or the base value for a head timeseries coordinates tuple: The node coordinates, (x,y) demand float: The current demand at the node head float: The current head at the node head_pattern_name The name of the multiplier pattern to use for the head timeseries head_timeseries The head timeseries for the reservoir initial_quality float: The initial quality (concentration) at the node leak_area float: The leak area at the node leak_demand float: The current demand at the node leak_discharge_coeff float: The leak discharge coefficient leak_status bool: The current leak status at the node name str: The name of the node node_type returns "Reservoir" tag str: A tag or label for the node

Methods

 todict() Dictionary representation of the node
node_type

returns "Reservoir"

head_timeseries

The head timeseries for the reservoir

base_head

The constant head (elevation) for the reservoir, or the base value for a head timeseries

head_pattern_name

The name of the multiplier pattern to use for the head timeseries

coordinates

tuple: The node coordinates, (x,y)

demand

float: The current demand at the node

head

float: The current head at the node

initial_quality

float: The initial quality (concentration) at the node

leak_area

float: The leak area at the node

leak_demand

float: The current demand at the node

leak_discharge_coeff

float: The leak discharge coefficient

leak_status

bool: The current leak status at the node

name

str: The name of the node

tag

str: A tag or label for the node

todict()

Dictionary representation of the node

class wntr.network.elements.Pipe(name, start_node_name, end_node_name, wn)[source]

Bases: wntr.network.base.Link

Pipe class, inherited from Link.

Parameters: name : string Name of the pipe start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this pipe will belong to. end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Pipe" name str: The link name (read-only) setting float: The current setting of the link start_node Node: The start node object. start_node_name str: The name of the start node (read only) status The current status of the pipe tag str: A tag or label for this link vertices A list of curve points, in the direction of start node to end node.

Methods

 todict() Dictionary representation of the link

returns "Pipe"

status

The current status of the pipe

end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

name

str: The link name (read-only)

setting

float: The current setting of the link

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.Pump(name, start_node_name, end_node_name, wn)[source]

Bases: wntr.network.base.Link

Pump class, inherited from Link.

For details about the different subclasses, please see one of the following: HeadPump and PowerPump

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this pump will belong to. base_speed end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Pump" name str: The link name (read-only) setting Alias to speed for consistency with other link types speed_pattern_name speed_timeseries start_node Node: The start node object. start_node_name str: The name of the start node (read only) status The current status of the pump tag str: A tag or label for this link vertices A list of curve points, in the direction of start node to end node.

Methods

 add_outage(wn, start_time, end_time) Adds a pump outage control to the water network model todict() Dictionary representation of the link
status

The current status of the pump

returns "Pump"

setting

Alias to speed for consistency with other link types

add_outage(wn, start_time, end_time)[source]

Adds a pump outage control to the water network model

Parameters: model : WaterNetworkModel The water network model this outage will belong to. start_time : int The time at which the outage starts. end_time : int The time at which the outage stops.
end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

name

str: The link name (read-only)

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.HeadPump(name, start_node_name, end_node_name, wn)[source]

Head pump class, inherited from Pump.

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this pump will belong to. base_speed end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Pump" name str: The link name (read-only) pump_curve_name Returns the pump curve name pump_type returns "HEAD" setting Alias to speed for consistency with other link types speed_pattern_name speed_timeseries start_node Node: The start node object. start_node_name str: The name of the start node (read only) status The current status of the pump tag str: A tag or label for this link vertices A list of curve points, in the direction of start node to end node.

Methods

 add_outage(wn, start_time, end_time) Adds a pump outage control to the water network model get_design_flow() Returns the design flow value for the pump. get_head_curve_coefficients() Returns the A, B, C coefficients for a 1-point or a 3-point pump curve. todict() Dictionary representation of the link
 get_pump_curve
pump_type

returns "HEAD"

pump_curve_name

Returns the pump curve name

get_head_curve_coefficients()[source]

Returns the A, B, C coefficients for a 1-point or a 3-point pump curve. Coefficient can only be calculated for pump curves.

For a single point curve the coefficients are generated according to the following equation:

A = 4/3 * H_1 B = 1/3 * H_1/Q_1^2 C = 2

For a three point curve the coefficients are generated according to the following equation:

When the first point is a zero flow: (All INP files we have come across)

A = H_1 C = ln((H_1 - H_2)/(H_1 - H_3))/ln(Q_2/Q_3) B = (H_1 - H_2)/Q_2^C

When the first point is not zero, numpy fsolve is called to solve the following system of equation:

H_1 = A - B*Q_1^C H_2 = A - B*Q_2^C H_3 = A - B*Q_3^C

Multi point curves are currently not supported

Parameters: pump_name : string Name of the pump Tuple of pump curve coefficient (A, B, C). All floats.
get_design_flow()[source]

Returns the design flow value for the pump. Equals to the first point on the pump curve.

add_outage(wn, start_time, end_time)

Adds a pump outage control to the water network model

Parameters: model : WaterNetworkModel The water network model this outage will belong to. start_time : int The time at which the outage starts. end_time : int The time at which the outage stops.
end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

returns "Pump"

name

str: The link name (read-only)

setting

Alias to speed for consistency with other link types

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

status

The current status of the pump

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.PowerPump(name, start_node_name, end_node_name, wn)[source]

Power pump class, inherited from Pump.

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this pump will belong to. base_speed end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Pump" name str: The link name (read-only) power Returns the fixed_power value pump_type returns "POWER" setting Alias to speed for consistency with other link types speed_pattern_name speed_timeseries start_node Node: The start node object. start_node_name str: The name of the start node (read only) status The current status of the pump tag str: A tag or label for this link vertices A list of curve points, in the direction of start node to end node.

Methods

 add_outage(wn, start_time, end_time) Adds a pump outage control to the water network model todict() Dictionary representation of the link
pump_type

returns "POWER"

power

Returns the fixed_power value

add_outage(wn, start_time, end_time)

Adds a pump outage control to the water network model

Parameters: model : WaterNetworkModel The water network model this outage will belong to. start_time : int The time at which the outage starts. end_time : int The time at which the outage stops.
end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

returns "Pump"

name

str: The link name (read-only)

setting

Alias to speed for consistency with other link types

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

status

The current status of the pump

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.Valve(name, start_node_name, end_node_name, wn)[source]

Bases: wntr.network.base.Link

Valve class, inherited from Link.

For details about the different subclasses, please see one of the following: PRValve, PSValve, PBValve, FCValve, TCValve, and GPValve.

Parameters: name : string Name of the valve start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this valve will belong to. end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Valve" name str: The link name (read-only) setting float: The current setting of the link start_node Node: The start node object. start_node_name str: The name of the start node (read only) status tag str: A tag or label for this link vertices A list of curve points, in the direction of start node to end node.

Methods

 todict() Dictionary representation of the link

returns "Valve"

end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

name

str: The link name (read-only)

setting

float: The current setting of the link

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.PRValve(name, start_node_name, end_node_name, wn)[source]

Pressure reducing valve class, inherited from Valve.

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this valve will belong to. end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Valve" name str: The link name (read-only) setting float: The current setting of the link start_node Node: The start node object. start_node_name str: The name of the start node (read only) status tag str: A tag or label for this link valve_type returns "PRV" vertices A list of curve points, in the direction of start node to end node.

Methods

 todict() Dictionary representation of the link
valve_type

returns "PRV"

end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

returns "Valve"

name

str: The link name (read-only)

setting

float: The current setting of the link

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.PSValve(name, start_node_name, end_node_name, wn)[source]

Pressure sustaining valve class, inherited from Valve.

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this valve will belong to. end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Valve" name str: The link name (read-only) setting float: The current setting of the link start_node Node: The start node object. start_node_name str: The name of the start node (read only) status tag str: A tag or label for this link valve_type returns "PSV" vertices A list of curve points, in the direction of start node to end node.

Methods

 todict() Dictionary representation of the link
valve_type

returns "PSV"

end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

returns "Valve"

name

str: The link name (read-only)

setting

float: The current setting of the link

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.PBValve(name, start_node_name, end_node_name, wn)[source]

Pressure breaker valve class, inherited from Valve.

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this valve will belong to. end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Valve" name str: The link name (read-only) setting float: The current setting of the link start_node Node: The start node object. start_node_name str: The name of the start node (read only) status tag str: A tag or label for this link valve_type returns "PBV" vertices A list of curve points, in the direction of start node to end node.

Methods

 todict() Dictionary representation of the link
valve_type

returns "PBV"

end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

returns "Valve"

name

str: The link name (read-only)

setting

float: The current setting of the link

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.FCValve(name, start_node_name, end_node_name, wn)[source]

Flow control valve class, inherited from Valve.

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this valve will belong to end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Valve" name str: The link name (read-only) setting float: The current setting of the link start_node Node: The start node object. start_node_name str: The name of the start node (read only) status tag str: A tag or label for this link valve_type returns "FCV" vertices A list of curve points, in the direction of start node to end node.

Methods

 todict() Dictionary representation of the link
valve_type

returns "FCV"

end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

returns "Valve"

name

str: The link name (read-only)

setting

float: The current setting of the link

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.TCValve(name, start_node_name, end_node_name, wn)[source]

Throttle control valve class, inherited from Valve.

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this valve will belong to end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Valve" name str: The link name (read-only) setting float: The current setting of the link start_node Node: The start node object. start_node_name str: The name of the start node (read only) status tag str: A tag or label for this link valve_type returns "TCV" vertices A list of curve points, in the direction of start node to end node.

Methods

 todict() Dictionary representation of the link
valve_type

returns "TCV"

end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

returns "Valve"

name

str: The link name (read-only)

setting

float: The current setting of the link

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.GPValve(name, start_node_name, end_node_name, wn)[source]

General purpose valve class, inherited from Valve.

Parameters: name : string Name of the pump start_node_name : string Name of the start node end_node_name : string Name of the end node wn : WaterNetworkModel The water network model this valve will belong to end_node Node: The end node object. end_node_name str: The name of the end node (read only) flow float: Current flow through the link (read only) headloss_curve headloss_curve_name Returns the pump curve name if pump_type is ‘HEAD’, otherwise returns None initial_setting float: The initial setting for the link (if Active) initial_status LinkStatus: The initial status (Opened, Closed, Active) of the Link link_type returns "Valve" name str: The link name (read-only) setting float: The current setting of the link start_node Node: The start node object. start_node_name str: The name of the start node (read only) status tag str: A tag or label for this link valve_type returns "GPV" vertices A list of curve points, in the direction of start node to end node.

Methods

 todict() Dictionary representation of the link
valve_type

returns "GPV"

headloss_curve_name

Returns the pump curve name if pump_type is ‘HEAD’, otherwise returns None

end_node

Node: The end node object.

end_node_name

str: The name of the end node (read only)

flow

float: Current flow through the link (read only)

initial_setting

float: The initial setting for the link (if Active)

initial_status

LinkStatus: The initial status (Opened, Closed, Active) of the Link

returns "Valve"

name

str: The link name (read-only)

setting

float: The current setting of the link

start_node

Node: The start node object.

start_node_name

str: The name of the start node (read only)

tag

str: A tag or label for this link

todict()

Dictionary representation of the link

vertices

A list of curve points, in the direction of start node to end node.

The vertices should be listed as a list of (x,y) tuples when setting.

class wntr.network.elements.Pattern(name, multipliers=[], time_options=None, wrap=True)[source]

Bases: object

Pattern class.

Parameters: name : string Name of the pattern. multipliers : list A list of multipliers that makes up the pattern. time_options : wntr TimeOptions or tuple The water network model options.time object or a tuple of (pattern_start, pattern_timestep) in seconds. wrap : bool, optional Boolean indicating if the pattern should be wrapped. If True (the default), then the pattern repeats itself forever; if False, after the pattern has been exhausted, it will return 0.0. multipliers Returns the pattern multiplier values time_options Returns the TimeOptions object

Methods

 __call__(time) Returns the pattern value at a specific time at(time) Returns the pattern value at a specific time binary_pattern(name, start_time, end_time, …) Creates a binary pattern (single instance of step up, step down). todict() Dictionary representation of the pattern
classmethod binary_pattern(name, start_time, end_time, step_size, duration, wrap=False)[source]

Creates a binary pattern (single instance of step up, step down).

Parameters: name : string Name of the pattern. start_time : int The time at which the pattern turns “on” (1.0). end_time : int The time at which the pattern turns “off” (0.0). step_size : int Pattern step size. duration : int Total length of the pattern. wrap : bool, optional Boolean indicating if the pattern should be wrapped. If True, then the pattern repeats itself forever; if False (the default), after the pattern has been exhausted, it will return 0.0. A new pattern object with a list of 1’s and 0’s as multipliers.
multipliers

Returns the pattern multiplier values

time_options

Returns the TimeOptions object

todict()[source]

Dictionary representation of the pattern

at(time)[source]

Returns the pattern value at a specific time

Parameters: time : int Time in seconds
class wntr.network.elements.TimeSeries(model, base, pattern_name=None, category=None)[source]

Bases: object

Time series class.

A TimeSeries object contains a base value, Pattern object, and category. The object can be used to store changes in junction demand, source injection, pricing, pump speed, and reservoir head. The class provides methods to calculate values using the base value and a multiplier pattern.

Parameters: base : number A number that represents the baseline value. pattern_registry : PatternRegistry The pattern registry for looking up patterns pattern : str, optional If None, then the value will be constant. Otherwise, the Pattern will be used. (default = None) category : string, optional A category, description, or other name that is useful to the user (default = None). ValueError If base or pattern are invalid types base_value Returns the baseline value. category Returns the category. pattern Returns the Pattern object. pattern_name Returns the name of the pattern.

Methods

 __call__(time) Returns the value at a specific time. at(time) Returns the value at a specific time. get_values(start_time, end_time, time_step) Returns the values for a range of times. todict() Dictionary representation of the time series
base_value

Returns the baseline value.

pattern

Returns the Pattern object.

pattern_name

Returns the name of the pattern.

category

Returns the category.

at(time)[source]

Returns the value at a specific time.

Parameters: time : int Time in seconds
get_values(start_time, end_time, time_step)[source]

Returns the values for a range of times.

Parameters: start_time : int Start time in seconds. end_time : int End time in seconds. time_step : int Time step.
todict()[source]

Dictionary representation of the time series

class wntr.network.elements.Demands(patterns, *args)[source]

Bases: _abcoll.MutableSequence

Demands class.

The Demands object is used to store multiple demands per junction in a list. The class includes specialized demand-specific calls and type checking.

A demand list is a list of demands and can be used with all normal list- like commands.

The demand list does not have any attributes, but can be created by passing in demand objects or demand tuples as (base_demand, pattern, category_name)

Methods

 __call__(time[, category]) Return the total demand at a given time. append(obj) S.append(object) - append object to the end at(time[, category]) Return the total demand at a given time. base_demand_list([category]) Returns a list of the base demands, optionally of a single category. category_list() Returns a list of all the pattern categories. clear() S.clear() - remove all entries count(value) extend(iterable) S.extend(iterable) - extend list by appending elements from the iterable get_values(start_time, end_time, time_step) Returns the values for a range of times. index(value) Raises ValueError if the value is not present. insert(index, obj) S.insert(index, object) - insert object before index pattern_list([category]) Returns a list of the patterns, optionally of a single category. pop([index]) Raise IndexError if list is empty or index is out of range. remove(value) S.remove(value) – remove first occurrence of value. remove_category(category) Remove all demands from a specific category reverse() S.reverse() – reverse IN PLACE to_ts(obj) Time series representation of demands
to_ts(obj)[source]

Time series representation of demands

insert(index, obj)[source]

S.insert(index, object) - insert object before index

append(obj)[source]

S.append(object) - append object to the end

extend(iterable)[source]

S.extend(iterable) - extend list by appending elements from the iterable

clear()[source]

S.clear() - remove all entries

at(time, category=None)[source]

Return the total demand at a given time.

remove_category(category)[source]

Remove all demands from a specific category

base_demand_list(category=None)[source]

Returns a list of the base demands, optionally of a single category.

pattern_list(category=None)[source]

Returns a list of the patterns, optionally of a single category.

category_list()[source]

Returns a list of all the pattern categories.

get_values(start_time, end_time, time_step)[source]

Returns the values for a range of times.

Parameters: start_time : int Start time in seconds end_time : int End time in seconds time_step : int time_step
count(value) → integer -- return number of occurrences of value
index(value) → integer -- return first index of value.

Raises ValueError if the value is not present.

pop([index]) → item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(value)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

class wntr.network.elements.Curve(name, curve_type=None, points=[], original_units=None, current_units='SI', options=None)[source]

Bases: object

Curve base class.

Parameters: name : str Name of the curve. curve_type : str The type of curve: None (unspecified), HEAD, HEADLOSS, VOLUME or EFFICIENCY points : list The points in the curve. List of 2-tuples (x,y) ordered by increasing x original_units : str The units the points were defined in current_units : str The units the points are currently defined in. This MUST be ‘SI’ by the time one of the simulators is run. options : WaterNetworkOptions, optional Water network options to lookup headloss function current_units The current units that the points are in curve_type The type of curve: None (unspecified), HEAD, HEADLOSS, VOLUME or EFFICIENCY name Curve names must be unique among curves num_points Returns the number of points in the curve. original_units The original units the points were written in. points The points in the curve.

Methods

 set_units([original, current]) Set the units flags for the curve. todict() Dictionary representation of the curve
original_units

The original units the points were written in.

current_units

The current units that the points are in

name

Curve names must be unique among curves

points

The points in the curve. List of 2-tuples (x,y) ordered by increasing x

curve_type

The type of curve: None (unspecified), HEAD, HEADLOSS, VOLUME or EFFICIENCY

num_points

Returns the number of points in the curve.

todict()[source]

Dictionary representation of the curve

set_units(original=None, current=None)[source]

Set the units flags for the curve.

Use this after converting the points, if necessary, to indicate that conversion to SI units is complete.

class wntr.network.elements.Source(model, name, node_name, source_type, strength, pattern=None)[source]

Bases: object

Water quality source class.

Parameters: name : string Name of the source. node_name: string Injection node. source_type: string Source type, options = CONCEN, MASS, FLOWPACED, or SETPOINT. strength: float Source strength in Mass/Time for MASS and Mass/Volume for CONCEN, FLOWPACED, or SETPOINT. pattern: Pattern, optional If None, then the value will be constant. Otherwise, the Pattern will be used (default = None). strength_timeseries