powsybl / powsybl-core

A framework to build power system oriented software
https://www.powsybl.org
Mozilla Public License 2.0
124 stars 40 forks source link

Add connect/disconnect on Tie Lines and HVDC Lines #3072

Closed rolnico closed 3 months ago

rolnico commented 3 months ago

Please check if the PR fulfills these requirements

Does this PR already have an issue describing the problem? No

What kind of change does this PR introduce? Bug fix + new Feature

What is the current behavior? If you use for example a ConnectableConnection on a non-existing connectable or on a TieLine (which is not a Connectable), the application of the NetworkModification will crash due to a null pointer exception. This is due to the fact that only Connectables are managed since Tie Lines and HVDC Lines do not have connect/disconnect methods.

What is the new behavior (if this is a feature change)? Tie Lines and HVDC Lines now have connect and disconnect methods implemented. Network modification for connection and disconnection now also work with Tie Lines and HVDC Lines.

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

If yes, please check if the following requirements are fulfilled

What changes might users need to make in their application due to this PR? (migration steps)

If you had your own implementation for HVDC Lines, you now need to implement the following methods:

    boolean connectConverterStations();
    boolean connectConverterStations(Predicate<Switch> isTypeSwitchToOperate);
    boolean connectConverterStations(Predicate<Switch> isTypeSwitchToOperate, TwoSides side);
    boolean disconnectConverterStations();
    boolean disconnectConverterStations(Predicate<Switch> isSwitchOpenable);
    boolean disconnectConverterStations(Predicate<Switch> isSwitchOpenable, TwoSides side);

If you had your own implementation for Tie Lines, you now need to implement the following methods:

    boolean connectDanglingLines();
    boolean connectDanglingLines(Predicate<Switch> isTypeSwitchToOperate);
    boolean connectDanglingLines(Predicate<Switch> isTypeSwitchToOperate, TwoSides side);
    boolean disconnectDanglingLines();
    boolean disconnectDanglingLines(Predicate<Switch> isSwitchOpenable);
    boolean disconnectDanglingLines(Predicate<Switch> isSwitchOpenable, TwoSides side);
rolnico commented 3 months ago

This is another possible solution that would close https://github.com/powsybl/powsybl-core/pull/3069

rolnico commented 3 months ago

Should the Tie Line and HVDC Line become Connectables ?

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
3 New issues
0 Accepted issues

Measures
0 Security Hotspots
93.6% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud