wntr.network.base module¶
The wntr.network.base module includes base classes for network elements and the network model.
Contents
|
Base class for nodes. |
|
Base class for links. |
|
Base class for registries. |
|
Enum class for node types. |
|
Enum class for link types. |
|
Enum class for link statuses. |
Base class for water network models. |
|
|
Base class for the subject in an observer design pattern. |
|
Base class for the observer in an observer design pattern. |
- class wntr.network.base.Subject[source]¶
Bases:
object
Base class for the subject in an observer design pattern.
- class wntr.network.base.Observer[source]¶
Bases:
object
Base class for the observer in an observer design pattern.
- class wntr.network.base.Node(wn, name)[source]¶
Bases:
object
Base class for nodes.
For details about the different subclasses, see one of the following:
Junction
,Tank
, andReservoir
Constructor
This is an abstract class and should not be instantiated directly.
- Parameters
wn (
WaterNetworkModel
) – WaterNetworkModel objectname (string) – Name of the node (must be unique among nodes of all types)
Attributes
The name of the node (read only)
The node type (read only)
The node coordinates, (x,y)
The initial quality (concentration) at the node
A tag or label for the node
Read-only simulation results
The following attributes are read-only. The values are the final calculated value from a simulation.
(read-only) the current simulation head at the node (total head)
(read-only) the current simulation demand at the node (actual demand)
(read-only) the current simulation leak demand at the node
(read-only) the current simulation leak status at the node
(read-only) the current simulation leak area at the node
(read-only) the current simulation leak discharge coefficient
- property head¶
(read-only) the current simulation head at the node (total head)
- Type
float
- property demand¶
(read-only) the current simulation demand at the node (actual demand)
- Type
float
- property pressure¶
(read-only) the current simulation pressure at the node
- Type
float
- property quality¶
(read-only) the current simulation quality at the node
- Type
float
- property leak_demand¶
(read-only) the current simulation leak demand at the node
- Type
float
- property leak_status¶
(read-only) the current simulation leak status at the node
- Type
bool
- property leak_area¶
(read-only) the current simulation leak area at the node
- Type
float
- property leak_discharge_coeff¶
(read-only) the current simulation leak discharge coefficient
- Type
float
- property node_type¶
The node type (read only)
- Type
str
- property name¶
The name of the node (read only)
- Type
str
- property tag¶
A tag or label for the node
- Type
str
- property initial_quality¶
The initial quality (concentration) at the node
- Type
float
- property coordinates¶
The node coordinates, (x,y)
- Type
tuple
- class wntr.network.base.Link(wn, link_name, start_node_name, end_node_name)[source]¶
Bases:
object
Base class for links.
For details about the different subclasses, see one of the following:
Pipe
,Pump
, andValve
Constructor
This is an abstract class and should not be instantiated directly.
- Parameters
wn (
WaterNetworkModel
) – WaterNetworkModel objectlink_name (string) – Name of the link
start_node_name (string) – Name of the start node
end_node_name (string) – Name of the end node
Attributes
The link name (read-only)
the link type (read only)
The start node object.
The name of the start node (read only)
The end node object.
The name of the end node (read only)
The initial status (Opened, Closed, Active) of the Link
The initial setting for the link (if Active)
A tag or label for this link
A list of curve points, in the direction of start node to end node.
Read-only simulation results
The following attributes are read-only. The values are the final calculated value from a simulation.
(read-only) current simulated flow through the link
(read-only) current simulated headloss
(read-only) current simulated average link quality
(abstract) current status of the link
(read-only) current simulated setting of the link
- property link_type¶
the link type (read only)
- Type
str
- property initial_status¶
The initial status (Opened, Closed, Active) of the Link
- Type
- property initial_setting¶
The initial setting for the link (if Active)
- Type
float
- property start_node_name¶
The name of the start node (read only)
- Type
str
- property end_node_name¶
The name of the end node (read only)
- Type
str
- property name¶
The link name (read-only)
- Type
str
- property flow¶
(read-only) current simulated flow through the link
- Type
float
- property velocity¶
(read-only) current simulated velocity through the link
- Type
float
- abstract property status¶
(abstract) current status of the link
- Type
- property quality¶
(read-only) current simulated average link quality
- Type
float
- property headloss¶
(read-only) current simulated headloss
- Type
float
- property setting¶
(read-only) current simulated setting of the link
- Type
float
- property tag¶
A tag or label for this link
- Type
str
- property 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.base.Registry(wn)[source]¶
Bases:
collections.abc.MutableMapping
Base class for registries.
- Parameters
wn (
WaterNetworkModel
) – WaterNetworkModel object
- usage()[source]¶
Generator to get the usage for all objects in the registry
- Yields
key (str) – The name of the object in the registry
value (tuple of (str, str)) – Tuple of (name, typestr) of the external items using the object
- get_usage(key)[source]¶
Get a set of items using an object by key.
- Returns
set of 2-tuples – Set of (name, typestr) of the external object using the item
- orphaned()[source]¶
Get a list of orphaned usages.
If removed without appropriate checks, it is possible that a some other item will point to an object that has been deleted. (This is why the user should always use the “remove_*” methods). This method returns a list of names for objects that are referenced, but no longer exist.
- Returns
set – The names of any orphaned items
- unused()[source]¶
Get a list of items which are unused by other objects in the model.
In most cases, this method will give little information. For nodes, however, this method could be important to identify a node which has become completely disconnected from the network. For patterns or curves, it may be used to find extra patterns or curves that are no longer necessary (or which the user forgot ot assign). It is not terribly useful for links.
- Returns
set – The names of any unused objects in the registry
- clear() None. Remove all items from D. ¶
- get(k[, d]) D[k] if k in D, else d. d defaults to None. ¶
- items() a set-like object providing a view on D's items ¶
- keys() a set-like object providing a view on D's keys ¶
- pop(k[, d]) v, remove specified key and return the corresponding value. ¶
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair ¶
as a 2-tuple; but raise KeyError if D is empty.
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D ¶
- update([E, ]**F) None. Update D from mapping/iterable E and F. ¶
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values ¶
- class wntr.network.base.NodeType(value)[source]¶
Bases:
enum.IntEnum
Enum class for node types.
Enum Members
node is a junction
node is a reservoir
node is a tank
- Junction = 0¶
node is a junction
- Reservoir = 1¶
node is a reservoir
- Tank = 2¶
node is a tank
- class wntr.network.base.LinkType(value)[source]¶
Bases:
enum.IntEnum
Enum class for link types.
Enum Members
pipe with a check valve
pipe with no check valve
a pump of any type
a pressure reducing valve
a pressure sustaining valve
a pressure breaker valve
a flow control valve
a throttle control valve
a general purpose valve
a valve of any type
- CV = 0¶
pipe with a check valve
- Pipe = 1¶
pipe with no check valve
- Pump = 2¶
a pump of any type
- PRV = 3¶
a pressure reducing valve
- PSV = 4¶
a pressure sustaining valve
- PBV = 5¶
a pressure breaker valve
- FCV = 6¶
a flow control valve
- TCV = 7¶
a throttle control valve
- GPV = 8¶
a general purpose valve
- Valve = 9¶
a valve of any type
- class wntr.network.base.LinkStatus(value)[source]¶
Bases:
enum.IntEnum
Enum class for link statuses.
Warning
This is NOT the class for determining output status from an EPANET binary file. The class for output status is wntr.epanet.util.LinkTankStatus.
Enum Members
pipe/valve/pump is closed
pipe/valve/pump is open
valve is partially open or pump has a specific setting
pipe has a check valve
alias for Opened
- Closed = 0¶
pipe/valve/pump is closed
- Open = 1¶
alias for Opened
- Opened = 1¶
pipe/valve/pump is open
- Active = 2¶
valve is partially open or pump has a specific setting
- CV = 3¶
pipe has a check valve