Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bus/breaker topology in case of no connected terminal present #881

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

jeandemanged
Copy link
Member

@jeandemanged jeandemanged commented Nov 1, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

No

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

As reported on Slack by a PyPowSyBl user (many thanks):

Hello everyone, I might have found a bug when using network.get_bus_breaker_topology.
In my network there are 3 buses in one voltage level. The third is only connected via breakers to the other two. My expectation would be, that all 3 buses in network.get_bus_breaker_topology.buses have the same bus_id. But the ones only connected by breakers without additional elements are not linked to any bus whatsoever. Is that intended behaviour or a bug?
Here is a minimal example:

import pypowsybl as pp
import pandas as pd
network = pp.network.create_empty()
network.create_substations(id=['S1', 'S2'])
voltage_levels = pd.DataFrame.from_records(index='id', data=[
    {'substation_id': 'S1', 'id': 'VL1', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 400},
    {'substation_id': 'S2', 'id': 'VL2', 'topology_kind': 'BUS_BREAKER', 'nominal_v': 400},
])
network.create_voltage_levels(voltage_levels)


network.create_buses(id=['B1_1', 'B1_2', 'B1_3', 'B2_1', 'B2_2'], voltage_level_id=['VL1', 'VL1', 'VL1', 'VL2', 'VL2'])
network.create_lines(id='LINE 1', voltage_level1_id='VL1', bus1_id='B1_2',
                     voltage_level2_id='VL2', bus2_id='B2_1',
                     b1=0, b2=0, g1=0, g2=0, r=0.5, x=10)
network.create_switches(pd.DataFrame.from_records(index='id', data=[
    {'voltage_level_id': 'VL1', 'id': 'DISC-BBS1-LOAD', 'kind': 'BREAKER', 'bus1_id': 'B1_1', 'bus2_id': 'B1_2', 'open':False},
    {'voltage_level_id': 'VL1', 'id': 'DISC-BBS2-LOAD', 'kind': 'BREAKER', 'bus1_id': 'B1_1', 'bus2_id': 'B1_3', 'open':False}
]))
network.get_bus_breaker_topology('VL1').buses

# Result
#  	name	bus_id
# id		
# B1_1		
# B1_2		VL1_0
# B1_3

Root cause of the issue is that the existing code assumes that every bus in bus/breaker view has at least one connected non-switch equipment.

What is the new behavior (if this is a feature change)?

We don't assume anymore that every bus in bus/breaker view has at least one connected non-switch equipment.

# Result
#  	name	bus_id
# id		
# B1_1		VL1_0
# B1_2		VL1_0
# B1_3		VL1_0

Does this PR introduce a breaking change or deprecate an API?

  • No

Copy link
Contributor

@flo-dup flo-dup left a comment

Choose a reason for hiding this comment

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

Thanks for having sorted this out!

Copy link

sonarqubecloud bot commented Nov 4, 2024

Copy link

sonarqubecloud bot commented Nov 4, 2024

}
// Didn't find using connected terminals. There is the possibility that the bus has zero connected terminal
// on its own but is still part of a Merged Bus via a closed retained switch. We examine this case below.
// We should probably build something more efficient on powsybl-core side to avoid having
Copy link
Contributor

Choose a reason for hiding this comment

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

A good use case for
powsybl/powsybl-core#3107

you can't get from busbreakerbuses to their busviewbuses

@HugoKulesza HugoKulesza merged commit cf709fe into main Nov 7, 2024
8 checks passed
@HugoKulesza HugoKulesza deleted the fix-bb-topology-no-connected-terminal branch November 7, 2024 09:18
HugoKulesza pushed a commit that referenced this pull request Nov 7, 2024
Signed-off-by: Damien Jeandemange <[email protected]>
(cherry picked from commit cf709fe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR: next-release
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants