-
Notifications
You must be signed in to change notification settings - Fork 8
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
Handle all connected components of a network #295
Conversation
…a LfNetwork and executing a loadflow. Signed-off-by: Bertrand Rix <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature should be configurable (OpenLoadFlowParameters)
@geofjamg Yes, what should be the default behavior ? Loading all connected components or only the main one ? |
Only the main one. |
…it a part of LfNetworkParameters. Signed-off-by: Bertrand Rix <[email protected]>
…DefaultOpenLoadflowConfig. Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add tests for sure, for simple load flows but also for secruity analysis and sensitivity analysis. I am not sure the code is robust enough because sometimes we just take the first synchronous component of the main connected component and we want to keep that. @geofjamg do you agree?
src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java
Outdated
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysis.java
Outdated
Show resolved
Hide resolved
@@ -42,7 +42,9 @@ public DcLoadFlowEngine(LfNetwork network, MatrixFactory matrixFactory, boolean | |||
} | |||
|
|||
public DcLoadFlowEngine(Object network, DcLoadFlowParameters parameters, Reporter reporter) { | |||
LfNetworkParameters lfNetworkParameters = new LfNetworkParameters(parameters.getSlackBusSelector(), false, false, false, false, parameters.getPlausibleActivePowerLimit(), false); | |||
LfNetworkParameters lfNetworkParameters = new LfNetworkParameters(parameters.getSlackBusSelector(), false, false, false, false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful here as we have in the code a LfNetwork network = networks.get(0);
that says that we only deal with the first synchronous component. Do we want to do better here? Handle several synchronous components? Handle several connected components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I made some changes in the code : I replaced all the get(0) I could find in the code by the use of a filter on the network num on what is defined as the "main num". I use the constant parameter ComponentConstants.MAIN_NUM provided by the core for that.
This is just a begining while waiting to see what we do with several connected components more largely.
public DcLoadFlowParameters(SlackBusSelector slackBusSelector, MatrixFactory matrixFactory, boolean setVToNan) { | ||
this(slackBusSelector, matrixFactory, false, true, false, LoadFlowParameters.BalanceType.PROPORTIONAL_TO_GENERATION_P_MAX, false, | ||
ParameterConstants.PLAUSIBLE_ACTIVE_POWER_LIMIT_DEFAULT_VALUE, false, setVToNan); | ||
ParameterConstants.PLAUSIBLE_ACTIVE_POWER_LIMIT_DEFAULT_VALUE, false, setVToNan, ParameterConstants.LOAD_MAIN_CONNECTED_COMPONENT_ONLY_DEFAULT_VALUE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java
Outdated
Show resolved
Hide resolved
…ntOnly to be more user friendly. Signed-off-by: Bertrand Rix <[email protected]>
…vity analysis. Signed-off-by: Bertrand Rix <[email protected]>
…twork instead of get(0). Signed-off-by: Bertrand Rix <[email protected]>
… not exist. Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
…is only handling the main CC. Signed-off-by: Bertrand Rix <[email protected]>
…rk. Update testMultipleConnectedComponentsDCAllComponents test. Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
@@ -68,10 +72,17 @@ private static double getActivePowerMismatch(Collection<LfBus> buses) { | |||
|
|||
public DcLoadFlowResult run(Reporter reporter) { | |||
// only process main (largest) connected component | |||
LfNetwork network = networks.get(0); | |||
LfNetwork network = networks.stream().filter(n -> n.getNum() == ComponentConstants.MAIN_NUM).findAny().orElseThrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need the main synchronous component here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create a method for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After our discussion : on lfNetwork I will use the existing connected component num and store the synchronous component num at loading, I will then update all filter I added to filter on CC num and SC num with MAIN_NUM value instead of just filter on CC num.
…onent filter. Signed-off-by: Bertrand Rix <[email protected]>
6d8be2e
to
bb9e415
Compare
…network. Just test the computation is ok, only the main cc is computed. Signed-off-by: Bertrand Rix <[email protected]>
this.slackBusSelector = Objects.requireNonNull(slackBusSelector); | ||
} | ||
|
||
public int getNum() { | ||
return num; | ||
public int getNumCC() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for this, I know that you are close to become totally crazy but... you are right, we need both NumCC
and NumSC
, but from now when you want to log or store results linked to a LfNetwork, you really have to put the pair and not just NumCC
. It will lead to change a bit some logs to be clear. But the big change will be in powsybl-core
because the object LoadFlowResult
only has one getComponentNum()
. So it means that if you want to serenely finish this PR, you have to create a new feature in powsybl-core
(so a new PR).
Signed-off-by: Bertrand Rix <[email protected]>
@@ -47,7 +48,7 @@ void testLineCurrentLimits() { | |||
Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits(); | |||
List<LfNetwork> lfNetworks = LfNetwork.load(network, new MostMeshedSlackBusSelector()); | |||
assertEquals(1, lfNetworks.size()); | |||
LfNetwork lfNetwork = lfNetworks.get(0); | |||
LfNetwork lfNetwork = lfNetworks.stream().filter(n -> n.getNumCC() == ComponentConstants.MAIN_NUM && n.getNumSC() == ComponentConstants.MAIN_NUM).findAny().orElseThrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These is boiler plate code. We have it everywhere in unit tests. Either we move it to a utility class of better we can just rely on the fact that first network is always the (main, main) one.
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
9a2a03e
to
c6d8435
Compare
src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Anne Tilloy <[email protected]>
Signed-off-by: Anne Tilloy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
src/main/java/com/powsybl/openloadflow/ac/outerloop/AcloadFlowEngine.java
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
src/main/java/com/powsybl/openloadflow/network/impl/LfNetworkLoaderImpl.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Florian Dupuy <[email protected]>
Signed-off-by: Anne Tilloy <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try handling all the connected components in a network when building a LfNetwork and executing a loadflow.
Please check if the PR fulfills these requirements (please use
'[x]'
to check the checkboxes, or submit the PR and then click the checkboxes)What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Introduce a boolean value in the network loader to chose to load only the main connected component of a network, or all connected components.
What is the current behavior? (You can also link to an open issue here)
Only the main connected component was loaded.
What is the new behavior (if this is a feature change)?
All connected components can now be loaded.
Does this PR introduce a breaking change or deprecate an API? If yes, check the following: