powsybl-core icon indicating copy to clipboard operation
powsybl-core copied to clipboard

Fix network element deep removal

Open flo-dup opened this issue 2 years ago • 1 comments

Do you want to request a feature or report a bug? Bug

What is the current behavior? PR #1862 (corresponding to issues #1852 & #1857) introduced the feature of topology cleanup after injection removal, but this only works as one may expect with very simple cases of injections connected to one bus only.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

  1. Create a network and a voltage level with following topology: clean1
  2. Use Connectable::remove(true) to remove connectable B with topology cleanup
  3. The result contains switches which are expected to be removed (circled in red): clean2

What is the expected behavior? Circled switches removed

What is the motivation / use case for changing the behavior? Helping the user to remove properly an injection

flo-dup avatar May 20 '22 12:05 flo-dup

After discussion with @geofjamg, the following algorithm is proposed when removing a connectable:

  1. Traverse the voltage level from the corresponding node and remove all the switches (or internal connection) encountered until arriving a) either at a node with more than 2 neighbours: apply step 2. b) or at a bus node, then the traverser should stop
  2. At nodes with more than 2 neighbours, we need to look how the corresponding neighbouring paths end: a) if one (or more) neighbouring path goes to connectables only (no buses), then the traverser should stop b) else: first remove all neighbouring path ending on one or more buses (no connectables), then stop the traverser if there is more than one remaining path, else continue removing switches on the only remaining path until encountering a node with more than 2 neighbours (which this time stops the traversing)

flo-dup avatar May 20 '22 12:05 flo-dup