-
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
Network listener #215
Network listener #215
Conversation
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
# Conflicts: # src/main/java/com/powsybl/openloadflow/network/LfNetwork.java # src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysis.java
|
||
// also create an inactive equation to have a1 variable constant | ||
LfBranch controller = phaseControl.getController(); | ||
equationSystem.createEquation(controller.getNum(), EquationType.BRANCH_ALPHA1) |
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.
The equation type BRANCH_ALPHA1
you introduce recently is in fact very confusing for me as we already a variable type BRANCH_ALPHA1
. And here I am not sure to get what you have in mind to add these lines.
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.
It is to keep the same matrix size?
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 reverted the phase control refactoring. I will add it in another PR and will explain better why.
|
||
@Override | ||
public void onPhaseControlModeChange(DiscretePhaseControl phaseControl, DiscretePhaseControl.Mode oldMode, DiscretePhaseControl.Mode newMode) { | ||
boolean on = newMode != DiscretePhaseControl.Mode.OFF; |
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.
Here, the code on master is:
LfBranch controllerBranch = branch.getDiscretePhaseControl().getController();
Variable a1 = context.getVariableSet().getVariable(controllerBranch.getNum(), VariableType.BRANCH_ALPHA1);
a1.setActive(false);
Equation t = context.getEquationSystem().createEquation(branch.getNum(), EquationType.BRANCH_P);
t.setActive(false);
Why we don't have any variable management?
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 reverted the phase control refactoring. I will add it in another PR and will explain better why.
|
||
for (LfBranch controllerBranch : bus.getDiscreteVoltageControl().getControllers()) { | ||
// de-activate r1 variable | ||
Variable r1 = variableSet.getVariable(controllerBranch.getNum(), VariableType.BRANCH_RHO1); |
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.
Here you manage the variable BRANCH_RHO1
, so why BRANCH_ALPHA1
has disappeared?
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 reverted the phase control refactoring. I will add it in another PR and will explain better why.
@@ -450,4 +451,21 @@ private void reactivateEquations(List<Equation> deactivatedEquations, List<Equat | |||
return connectivity; | |||
} | |||
|
|||
/** |
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.
Why do you have these "new" lines?
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.
they are old lines in fact which have been moved recently, so they can be removed
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.
No more new lines
@@ -450,4 +451,21 @@ private void reactivateEquations(List<Equation> deactivatedEquations, List<Equat | |||
return connectivity; | |||
} | |||
|
|||
/** |
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.
they are old lines in fact which have been moved recently, so they can be removed
@@ -350,6 +373,70 @@ public static EquationSystem create(LfNetwork network, VariableSet variableSet, | |||
createBusEquations(network, variableSet, creationParameters, equationSystem); | |||
createBranchEquations(network, variableSet, creationParameters, equationSystem); | |||
|
|||
network.addListener(new LfNetworkListener() { | |||
@Override | |||
public void onVoltageControlChange(LfBus bus, boolean oldVoltageControl, boolean newVoltageControl) { |
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.
oldVoltageControl not very necessary as we always have oldVoltageControl == !newVoltageControl
, but conform to other methods so...
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.
Agree this is ugly, I removed oldVoltageControl
@@ -350,6 +373,70 @@ public static EquationSystem create(LfNetwork network, VariableSet variableSet, | |||
createBusEquations(network, variableSet, creationParameters, equationSystem); | |||
createBranchEquations(network, variableSet, creationParameters, equationSystem); | |||
|
|||
network.addListener(new LfNetworkListener() { |
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'm not very fond of anonymous classes, don't you think this one is big enough to be explicit?
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.
Ok, I moved everything in a AcEquationSystemUpdater
class.
*/ | ||
public abstract class AbstractElement { | ||
|
||
protected final LfNetwork network; |
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.
Should we give the access to the whole LfNetwork to all elements or wouldn't a Supplier<LfNetworkListener>
be enough?
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 think it could be useful to go back to network from an element
@@ -18,17 +20,16 @@ | |||
/** | |||
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com> | |||
*/ | |||
public class LfShuntImpl implements LfShunt { | |||
public class LfShuntImpl extends AbstractElement implements LfShunt { |
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.
For now there's no use for LfShuntImpl
to extend AbstractElement
, but I suppose you're anticipating some feature?
I'm asking as if we don't extend it, it would give more consistency to AbstractElement
in a way (and some more LfBus
/ LfBranch
common methods could be added)
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.
Honestly, I only added AbstractElement to fix a Sonar duplicated code issue at the moment. But for sure we can probably share more code. I Propose to do it in an other PR as it was really not the aim of this one.
# Conflicts: # src/main/java/com/powsybl/openloadflow/ac/outerloop/AcloadFlowEngine.java # src/main/java/com/powsybl/openloadflow/ac/outerloop/OuterLoopContext.java # src/main/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysis.java # src/main/java/com/powsybl/openloadflow/util/BusState.java
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
@annetill @floriand-e2r I removed the phase control refactoring from this PR to only keep the listener part. So this PR now """"only""""" contains code move and is supposed to be functionnally equivalent. I will create to dedicated PR to refactor the AC equation system to avoid variable de-activation. |
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.
It is really pretty like this and for sure more easy to use as the AC equation system is hidden. We have to make an issue not to forget to implement it for DC equation system when we will be able to have a regulation on phase tap changers.
Please check if the PR fulfills these requirements (please use
'[x]'
to check the checkboxes, or submit the PR and then click the checkboxes)Does this PR already have an issue describing the problem ? If so, link to this issue using
'#XXX'
and skip the restNo
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
feature
What is the new behavior (if this is a feature change)?
In order to centralize, network modification to equation system change, a listener has been added to the LF network and is used by AC equation system to auto update
Does this PR introduce a breaking change or deprecate an API? If yes, check the following:
Other information:
(if any of the questions/checkboxes don't apply, please delete them entirely)