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

Voltage magnitude initialization #392

Merged
merged 45 commits into from
Dec 13, 2021
Merged

Voltage magnitude initialization #392

merged 45 commits into from
Dec 13, 2021

Conversation

geofjamg
Copy link
Member

@geofjamg geofjamg commented Dec 3, 2021

Signed-off-by: Geoffroy Jamgotchian [email protected]

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
No

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

What is the current behavior? (You can also link to an open issue here)
In some cases where we have a large grid and many transformers with a voltage ratio far from 1pu, the starting point (1pu, 0°) is not able to make the Newton Raphson converge.

What is the new behavior (if this is a feature change)?
We added a new algorithm to find a better voltage magnitude starting point.

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)

geofjamg and others added 20 commits December 2, 2021 23:44
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]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
# Conflicts:
#	src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java
#	src/test/resources/debug-parameters.json
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 [WIP] Voltage magnitude initialization Voltage magnitude initialization Dec 5, 2021
@geofjamg geofjamg requested a review from annetill December 5, 2021 12:16
geofjamg and others added 4 commits December 5, 2021 14:21
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@@ -43,6 +43,14 @@

public static final boolean VOLTAGE_PER_REACTIVE_POWER_CONTROL_DEFAULT_VALUE = false;

public enum VoltageInitMode {
Copy link
Member

Choose a reason for hiding this comment

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

I understand now that it is an extension of VoltageInitMode of LoadFlowParameters, but it was not obvious the first time. So, the usage was not clear, especially with NONE. And what is happening if on LoadFlowParameters with choose PREVIOUS_VALUES and on OLFParameters we choose FULL_VOLTAGE. I think that the best solution is to put everything on LoadFlowParameters side. What do you think ?

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as mode is not NONE, it overrides the LoadFlowParameters one.
Maybe we should rename the enum and parameter name to be more clear?
I would not add it to LoadFlowParameters as it is something that probably won't be in any other LF. Maybe also I would prefer to remove DC_VALUE and move it to LF specific parameters.

Copy link
Member

Choose a reason for hiding this comment

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

What you be the better names? For DC_VALUE, indeed as it is shared by at least two implementations, we can keep it as it is, no?

double r = 0;
for (LfBranch neighborBranch : neighborBranches) {
PiModel piModel = neighborBranch.getPiModel();
b += Math.abs(1 / piModel.getX()); // to void issue with negative reactances
Copy link
Member

Choose a reason for hiding this comment

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

You neglect B1 and B2 here, right? It could be worst righting it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

How to mix it with 1/x ? there is no real branch model in that system. It is just a very raw and approximative proportionality law which is I think good enough to find a decent starting point.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I get that.

Copy link
Member

Choose a reason for hiding this comment

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

Be careful, we have some non impedant lines with an X equal to zero. I have met an issue on test testWith3GeneratorsAndNonImpedantBranch.

Copy link
Member

@annetill annetill Dec 9, 2021

Choose a reason for hiding this comment

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

I am not sure that the good condition is piModel.getX() equals to zero. Maybe, but not sure here, we have to rely also on branch.isSpanningTreeEdge(). But it means that we can have zero impedance line that are not in the spanning tree, so another fix is needed for that branches.

//
// there are 2 types of equations:
// for PV buses: target_v = v_i where i is the bus number
// for other buses: 0 = sum_j(b_j * v_j) / sum_j(b_j) - v_i where j are buses neighbors of bus i and b is 1 / x
Copy link
Member

Choose a reason for hiding this comment

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

You miss to take into account ratios in our comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

equationSystem.createEquation(bus.getNum(), InitVmEquationType.BUS_TARGET_V)
.addTerm(v);
} else {
equationSystem.createEquation(bus.getNum(), InitVmEquationType.BUS_ZERO)
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand here why we don't have any susceptance and any ratio. It seems that you use them only to compute the derivative. Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

The InitVmBusEquationTerm equation term represents the sum at a given bus (I didn't use multiple equation term). So you will find the susceptance and ratio in the derivative calculation in this class.

Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@geofjamg geofjamg requested a review from annetill December 7, 2021 13:27
@geofjamg geofjamg changed the title Voltage magnitude initialization [WIP] Voltage magnitude initialization Dec 8, 2021
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 [WIP] Voltage magnitude initialization Voltage magnitude initialization Dec 8, 2021
@geofjamg
Copy link
Member Author

geofjamg commented Dec 8, 2021

@annetill I added support to non impedant branches, does it solve your issues?

It seems to only work if non impedant branch is not connected to a PV bus, otherwise PV bus voltage value is modified...

It is not working on Terna and on NGESO networks because it falls in exception Susceptance sum is zero.

Is it better now?

Signed-off-by: Geoffroy Jamgotchian <[email protected]>
private static boolean isZeroImpedanceBranch(LfBranch branch) {
return branch.getBus1() != null
&& branch.getBus2() != null
&& branch.getPiModel().getX() == 0;
Copy link
Member

Choose a reason for hiding this comment

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

My first think here is to use better branch.isSpanningTreeEdge() to avoid cycle. It is what we have done for the AC equation system.

variables.add(variableSet.getVariable(neighborBus.getNum(), InitVmVariableType.BUS_V));
}
}
if (bs == 0) { // should never happen
Copy link
Member

Choose a reason for hiding this comment

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

I fall in that with Energinet D10 network.

geofjamg and others added 8 commits December 9, 2021 13:40
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]>
@geofjamg geofjamg requested a review from annetill December 13, 2021 07:23
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
Signed-off-by: Geoffroy Jamgotchian <[email protected]>

private final TDoubleArrayList der;

private static boolean isConnected(LfBranch branch) {
Copy link
Member

Choose a reason for hiding this comment

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

Could it be interested to move this method as a method of LfBranch ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

&& branch.getBus2() != null;
}

private static Map<LfBus, List<LfBranch>> findNeighbors(LfBus bus) {
Copy link
Member

Choose a reason for hiding this comment

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

Same remark with this method ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: Geoffroy Jamgotchian <[email protected]>
@geofjamg geofjamg requested a review from annetill December 13, 2021 08:14
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

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

89.0% 89.0% Coverage
0.0% 0.0% Duplication

@geofjamg geofjamg merged commit cdd3e75 into main Dec 13, 2021
@geofjamg geofjamg deleted the init_v_mag branch December 13, 2021 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants