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 zero impedance subgraph #718

Merged
merged 98 commits into from
Mar 31, 2023
Merged

Fix zero impedance subgraph #718

merged 98 commits into from
Mar 31, 2023

Conversation

geofjamg
Copy link
Member

@geofjamg geofjamg commented Feb 1, 2023

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • 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 ? If so, link to this issue using '#XXX' and skip the rest

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

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

Does this PR introduce a breaking change or deprecate an API? If yes, check the following:

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

(if any of the questions/checkboxes don't apply, please delete them entirely)

Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@geofjamg geofjamg changed the title Fix zero impedance subgraph [WIP] Fix zero impedance subgraph Feb 1, 2023
geofjamg and others added 23 commits February 15, 2023 21:38
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/network/GraphVizGraphBuilder.java
#	src/main/java/com/powsybl/openloadflow/network/LfNetworkListenerTracer.java
#	src/test/resources/nb.dot
#	src/test/resources/sim1.dot
#	src/test/resources/sim1_disconnected.dot
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@geofjamg
Copy link
Member Author

@annetill most of the code is here. There is still some failing tests but help would be welcome to finish the work.

  • Some unit test are not relevant anymore and need to be updated as they have been designed with the check done at loading time.
  • I suspect some tests to be wrong.
  • There is an issue with the shunt + gen controlling same bus (not same var and eq), so there is a bug somewhere.
  • we miss a lot of new unit test to test various spanning tree configurations.
  • ...

Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Anne Tilloy <[email protected]>
@@ -12,8 +12,10 @@
*/
public class ShuntVoltageControl extends DiscreteVoltageControl<LfShunt> {

private static final int PRIORITY = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Indeed we have the hypothesis in main branch that transformers have an highest priority than shunts, but maybe we have to rethink about it. Or make it configurable one day...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it should better be configurable

@@ -177,8 +136,8 @@ public void updateSlackBuses() {
}

private void invalidateZeroImpedanceNetworks() {
Copy link
Member

Choose a reason for hiding this comment

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

Your work is really impressive but I think that maybe we have to rethink in a next PR in having just one status for zero impedance line, for DC and for AC calculation. I am not sure it is possible...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I see than this badly designed but a better solution is not clear to me. To handle in a next work.

geofjamg and others added 8 commits March 28, 2023 17:40
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/test/java/com/powsybl/openloadflow/ac/NonImpedantBranchDisablingTest.java
Signed-off-by: Anne Tilloy <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@geofjamg geofjamg changed the title [WIP] Fix zero impedance subgraph Fix zero impedance subgraph Mar 29, 2023
Signed-off-by: Anne Tilloy <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
if (voltageControls.size() > 1) {
// we take the highest target voltage (why not...) and in case of equality the voltage control
// with the first controlled bus ID by alpha sort
voltageControls.sort(Comparator.<VoltageControl<?>>comparingDouble(VoltageControl::getTargetValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to sort, you can take the min instead (or the max if you revert your comparator, not sure what's clearer!), and then you don't need to check voltageControls size, the loop reducing to something like

voltageControls.stream().max(vcComparator).ifPresent(mainVc -> linkAllVoltageControls(mainVc, voltageControls));

for (VoltageControl<?> vc : zb.getVoltageControls()) {
voltageControlsByType.computeIfAbsent(vc.getType(), k -> new ArrayList<>())
.add(vc);
vc.getMergedDependentVoltageControls().clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than giving access to the list we could have VoltageControl::getMergedDependentVoltageControlStream() and VoltageControl::clearMergedDependentVoltageControls()

.setActive(true);
}

// activate distribution equation and deactivate control equation at all enabled controller buses except one (first)
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment does not correspond exactly to what's done (the except one is only for distribution equation)

Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Mar 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 12 Code Smells

92.6% 92.6% Coverage
0.0% 0.0% Duplication

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.

Nice job! 🎉

@flo-dup flo-dup merged commit cd1136b into main Mar 31, 2023
@flo-dup flo-dup deleted the fix_zero_imp_subgraph branch March 31, 2023 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants