-
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
Refactoring voltage control #168
Conversation
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 have left the review of abstract lf bus and lf network loader impl for latter. I think that we have to review bases before in having a unique voltage control in case of remote shared control but split it in several voltage control if remote voltage control is desactivated. This solution is not clear enough to be prefer at the current one.
src/main/java/com/powsybl/openloadflow/ac/ReactiveLimitsOuterLoop.java
Outdated
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/network/VoltageControl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/network/VoltageControl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/network/impl/AbstractLfGenerator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/network/impl/LfDanglingLineGenerator.java
Outdated
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/network/impl/LfGeneratorImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/network/impl/LfStaticVarCompensatorImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/powsybl/openloadflow/network/impl/LfVscConverterStationImpl.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
First import of VoltageControl. Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Remove the HashMap previously used Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Done in createVoltageControls, together with various consistency checks Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
AcEquationSystemCreationParameters.voltageRemoteControl now useless thus removed Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Some tests were not included in build check as they were annotated with org.junit.api.Test Code smells corrections Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Nothing done in AbstractLfBus anymore, now in: - AbstractLfGenerator when setting targetV - LfNetworkLoaderImpl when creating controller - controllee links Unit tests are slightly changed as a consequence Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Instead of controllersBus list / controlledBus optional Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
d4f8013
to
d8b3498
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs |
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.
Some small changes. After @geofjamg review, I will perform a functional validation as the feature is central.
} | ||
}); | ||
} | ||
public void setVoltageControl(boolean voltageControl) { |
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 have to renamed ths function for sure. I thought that you can make it using the Mode OFF of the voltageControl ?
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 clear to me too what is the difference between mode of the VoltageControl and property voltageControlEnabled ? Is mode really usefull as mode is kind of result of individual voltage control enable status of all controllers?
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 removed the mode, as VoltageControl
is only structural, the state (voltageControlEnabled
) remains in LfBus
.
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.
setVoltageControl()
is moreover renamed into setVoltageControlEnabled()
if (!(creationParameters.isVoltageRemoteControl() && bus.getControlledBus().isPresent()) && bus.getControllerBuses().isEmpty()) { | ||
equationSystem.createEquation(bus.getNum(), EquationType.BUS_V).addTerm(new BusVoltageEquationTerm(bus, variableSet)); | ||
} | ||
boolean hasLocalControl = bus.isVoltageController() && bus.getVoltageControl().isVoltageControlLocal(); |
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 function could be more clear.
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowTransformerControlTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
@Override | ||
public String getControlledBusId(boolean breakers) { | ||
Terminal terminal = generator.getRegulatingTerminal(); | ||
Bus controlled = breakers ? terminal.getBusBreakerView().getBus() : terminal.getBusView().getBus(); |
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 have to fix this: you have to check if the bus is not null
and not creating the voltage control if it is. We do that for the discrete voltage control.
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.
Done. In the last commit I do it earlier, in the LfGenerator constructor, so that the voltage control is disabled from the start.
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
controllerBusCount++; | ||
} | ||
} | ||
long controllerBusCount = busesById.values().stream().filter(LfBus::isVoltageControllerEnabled).count(); |
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 log is not equivalent to what was count before. Here we just want to know in all voltage control remote and local, how many controlled buses have at least one remote controller and for all controllers how many are remote. This is important if we want to compare.
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.
Corrected, but what was counted before included the voltage controls discarded for too small max reactive ranges and for not started generators... so it's still annoying to compare the results.
@@ -68,7 +68,7 @@ private static void createVoltageControls(LfNetwork lfNetwork, List<LfBus> lfBus | |||
// check target voltage | |||
checkUniqueTargetVControllerBus(lfGenerator, controllerTargetV, controllerBus, generatorControlledBus); | |||
|
|||
if (lfGenerator.hasVoltageControl()) { | |||
if (lfGenerator.hasVoltageControl() && controllerBus.isVoltageControllerEnabled()) { |
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 condition can be done before to avoid not usuful checks ?
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.
Done; in fact some refactoring has been done here, to avoid the null/NaN initialization and the useless checks.
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
if (!voltageRemoteControl && controlledBus != controllerBus) { | ||
// if voltage remote control deactivated and remote control, set local control instead |
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 could be done earlier to have the lfGenerator consistent with the local voltage control, but for now it's easier to do it 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.
Just minor remarks or questions. This is a large refactoring, lots of code has been moved and so this is very difficult to review. But new design looks good and is clearly better than previous one.
controllerBus.setVoltageControl(this); | ||
} | ||
|
||
public boolean isVoltageControlLocal() { |
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 name is not clear, at first read I was thinking it means this is only a local control
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.
Indeed, but in fact we call it only once, to check just after if it is only local! hence I changed its content to return whether it is a local control only.
src/main/java/com/powsybl/openloadflow/network/impl/AbstractLfBus.java
Outdated
Show resolved
Hide resolved
@@ -164,7 +164,7 @@ void testMaxIterationReached() { | |||
parameters.setWriteSlackBus(true); | |||
Network network = EurostagTutorialExample1Factory.create(); | |||
LoadFlow.Runner loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider(new SparseMatrixFactory())); | |||
network.getGenerator("GEN").setTargetV(5); | |||
network.getVoltageLevelStream().forEach(vl -> vl.setNominalV(21)); |
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 ?
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.
That was just a way to get max iteration reached, as setting a target value too far from nominal voltage is not possible anymore. I improved it with a clearer and cleaner change, and added a comment.
@@ -45,7 +45,7 @@ void localTest() { | |||
.setMinP(0) | |||
.setMaxP(200) | |||
.setTargetP(100) | |||
.setTargetV(413) | |||
.setTargetV(23) |
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.
Could you explain why you changed unit tests?
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.
Because the previous test was not real with two generators connected to a 20 kV voltage level and with target V around 400 kV, without any remote regulating terminal.
private final boolean phaseControl; | ||
|
||
private final boolean transformerVoltageControl; | ||
|
||
private final boolean forceA1Var; | ||
|
||
public AcEquationSystemCreationParameters(boolean voltageRemoteControl, boolean phaseControl, boolean transformerVoltageControl) { | ||
this(voltageRemoteControl, phaseControl, transformerVoltageControl, false); | ||
public AcEquationSystemCreationParameters(boolean phaseControl, boolean transformerVoltageControl) { |
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 so remote voltage control de-activation is only managed at network creation.
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.
Indeed, after that we do not need that boolean anymore.
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
// check that targetV has a plausible value (wrong nominal voltage issue) | ||
if (targetV < PlausibleValues.MIN_TARGET_VOLTAGE_PU || targetV > PlausibleValues.MAX_TARGET_VOLTAGE_PU) { | ||
LOGGER.warn("Generator '{}' has an inconsistent target voltage: {} pu", getId(), targetV); | ||
newTargetV = (targetV > PlausibleValues.MAX_TARGET_VOLTAGE_PU) ? PlausibleValues.MAX_TARGET_VOLTAGE_PU : PlausibleValues.MIN_TARGET_VOLTAGE_PU; |
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.
@geofjamg Just tell if if this fix on targetV is okay for you.
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 not!
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
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.
What a great work @floriand-e2r ! Thanks a lot !
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, ...)
Refactoring voltage control to have a structure similar to PhaseDiscreteControl / VoltageDiscreteControl, that is, a "control" object which makes the link between the controller and the controllee.