Skip to content

Commit

Permalink
remove cable dist. from MV grid when disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
nesnoj committed Sep 22, 2017
1 parent effb54e commit 1bb0530
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions ding0/core/network/grids.py
Expand Up @@ -132,6 +132,15 @@ def add_cable_distributor(self, cable_dist):
self._cable_distributors.append(cable_dist)
self.graph_add_node(cable_dist)

def remove_cable_distributor(self, cable_dist):
"""Removes a cable distributor from _cable_distributors if existing"""
if cable_dist in self.cable_distributors() and isinstance(cable_dist,
MVCableDistributorDing0):
# remove from array and graph
self._cable_distributors.remove(cable_dist)
if self._graph.has_node(cable_dist):
self._graph.remove_node(cable_dist)

def add_ring(self, ring):
"""Adds a ring to _rings if not already existing"""
if ring not in self._rings and isinstance(ring, RingDing0):
Expand Down
2 changes: 1 addition & 1 deletion ding0/grid/mv_grid/mv_connect.py
Expand Up @@ -518,7 +518,7 @@ def disconnect_node(node, target_obj_result, graph, debug):
neighbor_nodes = graph.neighbors(target_obj_result)

if len(neighbor_nodes) == 2:
graph.remove_node(target_obj_result)
node.grid.remove_cable_distributor(target_obj_result)

branch_length = calc_geo_dist_vincenty(neighbor_nodes[0], neighbor_nodes[1])
graph.add_edge(neighbor_nodes[0], neighbor_nodes[1], branch=BranchDing0(length=branch_length,
Expand Down

2 comments on commit 1bb0530

@gplssm
Copy link
Contributor

@gplssm gplssm commented on 1bb0530 Sep 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add this bug fix to the "what's new" file

@nesnoj
Copy link
Member Author

@nesnoj nesnoj commented on 1bb0530 Sep 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for reminding...done

Please sign in to comment.