LinkRegistry#
module wntr.network.model
- class LinkRegistry[source]#
Bases:
Registry
A registry for links.
- add_pipe(name, start_node_name, end_node_name, length=304.8, diameter=0.3048, roughness=100, minor_loss=0.0, initial_status='OPEN', check_valve=False)[source]#
Adds a pipe to the water network model.
- 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.
length (float, optional) – Length of the pipe.
diameter (float, optional) – Diameter of the pipe.
roughness (float, optional) – Pipe roughness coefficient.
minor_loss (float, optional) – Pipe minor loss coefficient.
initial_status (string, optional) – Pipe initial status. Options are ‘OPEN’ or ‘CLOSED’.
check_valve (bool, optional) – True if the pipe has a check valve. False if the pipe does not have a check valve.
- add_pump(name, start_node_name, end_node_name, pump_type='POWER', pump_parameter=50.0, speed=1.0, pattern=None, initial_status='OPEN')[source]#
Adds a pump to the water network model.
- 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.
pump_type (string, optional) – Type of information provided for a pump. Options are ‘POWER’ or ‘HEAD’.
pump_parameter (float or string) – For a POWER pump, the pump power (float). For a HEAD pump, the head curve name (string).
speed (float) – Relative speed setting (1.0 is normal speed)
pattern (string) – Name of the speed pattern
initial_status (str or LinkStatus) – Pump initial status. Options are ‘OPEN’ or ‘CLOSED’.
- add_usage(key, *args)#
add args to usage[key]
- add_valve(name, start_node_name, end_node_name, diameter=0.3048, valve_type='PRV', minor_loss=0.0, initial_setting=0.0, initial_status='ACTIVE')[source]#
Adds a valve to the water network model.
- 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.
diameter (float, optional) – Diameter of the valve.
valve_type (string, optional) – Type of valve. Options are ‘PRV’, ‘PSV’, ‘PBV’, ‘FCV’, ‘TCV’, and ‘GPV’
minor_loss (float, optional) – Pipe minor loss coefficient.
initial_setting (float or string, optional) – Valve initial setting. Pressure setting for PRV, PSV, or PBV. Flow setting for FCV. Loss coefficient for TCV. Name of headloss curve for GPV.
initial_status (string or LinkStatus) – Valve initial status. Options are ‘OPEN’, ‘CLOSED’, or ‘ACTIVE’
- check_valves()[source]#
Generator to get all pipes with check valves
- Yields:
name (str) – The name of the pipe
link (Pipe) – The pipe object
- clear() None. Remove all items from D. #
- clear_usage(key)#
if key in usage, clear usage[key]
- fcvs()[source]#
Generator to get all FCVs
- Yields:
name (str) – The name of the valve
link (FCValve) – The valve object
- get(k[, d]) D[k] if k in D, else d. d defaults to None. #
- get_usage(key)#
Get a set of items using an object by key.
- Returns:
Set of (name, typestr) of the external object using the item
- Return type:
set of 2-tuples
- gpvs()[source]#
Generator to get all GPVs
- Yields:
name (str) – The name of the valve
link (GPValve) – The valve object
- head_pumps()[source]#
Generator to get all head pumps
- Yields:
name (str) – The name of the pump
link (HeadPump) – The pump object
- items() a set-like object providing a view on D's items #
- keys() a set-like object providing a view on D's keys #
- orphaned()#
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:
The names of any orphaned items
- Return type:
- pbvs()[source]#
Generator to get all PBVs
- Yields:
name (str) – The name of the valve
link (PBValve) – The valve object
- pipes()[source]#
Generator to get all pipes
- Yields:
name (str) – The name of the pipe
link (Pipe) – The pipe object
- 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.
- power_pumps()[source]#
Generator to get all power pumps
- Yields:
name (str) – The name of the pump
link (PowerPump) – The pump object
- prvs()[source]#
Generator to get all PRVs
- Yields:
name (str) – The name of the valve
link (PRValve) – The valve object
- psvs()[source]#
Generator to get all PSVs
- Yields:
name (str) – The name of the valve
link (PSValve) – The valve object
- pumps()[source]#
Generator to get all pumps
- Yields:
name (str) – The name of the pump
link (Pump) – The pump object
- remove_usage(key, *args)#
remove args from usage[key]
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D #
- tcvs()[source]#
Generator to get all TCVs
- Yields:
name (str) – The name of the valve
link (TCValve) – The valve object
- to_dict()#
Dictionary representation of the registry
- to_list()#
List representation of the registry
- unused()#
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:
The names of any unused objects in the registry
- Return type:
- 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
- usage()#
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
- values() an object providing a view on D's values #
- valves()[source]#
Generator to get all valves
- Yields:
name (str) – The name of the valve
link (Valve) – The valve object
- property fcv_names#
A list of all fcv names
- property gpv_names#
A list of all gpv names
- property head_pump_names#
A list of all head pump names
- property pbv_names#
A list of all pbv names
- property pipe_names#
A list of all pipe names
- property power_pump_names#
A list of all power pump names
- property prv_names#
A list of all prv names
- property psv_names#
A list of all psv names
- property pump_names#
A list of all pump names
- property tcv_names#
A list of all tcv names
- property valve_names#
A list of all valve names