def add_junction(self, name, base_demand=0.0, demand_pattern=None, elevation=0.0, coordinates=None):
"""
Adds a junction to the water network model.
Parameters
-------------------
name : string
Name of the junction.
base_demand : float
Base demand at the junction.
demand_pattern : string or Pattern
Name of the demand pattern or the actual Pattern object
elevation : float
Elevation of the junction.
coordinates : tuple of floats
X-Y coordinates of the node location.
"""
base_demand = float(base_demand)
elevation = float(elevation)
if not isinstance(demand_pattern, Pattern):
demand_pattern = self.get_pattern(demand_pattern)
junction = Junction(name, base_demand, demand_pattern, elevation)
self._nodes[name] = junction
self._junctions[name] = junction
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:'junction'})
self._num_junctions += 1
评论列表
文章目录