def add_reservoir(self, name, base_head=0.0, head_pattern=None, coordinates=None):
"""
Adds a reservoir to the water network model.
Parameters
----------
name : string
Name of the reservoir.
base_head : float, optional
Base head at the reservoir.
head_pattern : string or Pattern
Name of the head pattern or the actual Pattern object
coordinates : tuple of floats, optional
X-Y coordinates of the node location.
"""
base_head = float(base_head)
if head_pattern and isinstance(head_pattern, six.string_types):
head_pattern = self.get_pattern(head_pattern)
reservoir = Reservoir(name, base_head, head_pattern)
self._nodes[name] = reservoir
self._reservoirs[name] = reservoir
self._graph.add_node(name)
if coordinates is not None:
self.set_node_coordinates(name, coordinates)
nx.set_node_attributes(self._graph, name='type', values={name:'reservoir'})
self._num_reservoirs += 1
评论列表
文章目录