Skip to content

Commit

Permalink
Refactor default outer loop config (#708)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
  • Loading branch information
geofjamg authored Jan 23, 2023
1 parent 038c1a2 commit 6371e1f
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/main/java/com/powsybl/openloadflow/DefaultOuterLoopConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,47 @@
*/
public class DefaultOuterLoopConfig implements OuterLoopConfig {

private static OuterLoop createTransformerVoltageControlOuterLoop(OpenLoadFlowParameters parametersExt) {
switch (parametersExt.getTransformerVoltageControlMode()) {
case WITH_GENERATOR_VOLTAGE_CONTROL:
return new SimpleTransformerVoltageControlOuterLoop();
case AFTER_GENERATOR_VOLTAGE_CONTROL:
return new TransformerVoltageControlOuterLoop();
case INCREMENTAL_VOLTAGE_CONTROL:
return new IncrementalTransformerVoltageControlOuterLoop();
default:
throw new IllegalStateException("Unknown transformer voltage control mode: " + parametersExt.getTransformerVoltageControlMode());
}
}

private static OuterLoop createDistributedSlackOuterLoop(LoadFlowParameters parameters, OpenLoadFlowParameters parametersExt) {
ActivePowerDistribution activePowerDistribution = ActivePowerDistribution.create(parameters.getBalanceType(), parametersExt.isLoadPowerFactorConstant());
return new DistributedSlackOuterLoop(activePowerDistribution, parametersExt.isThrowsExceptionInCaseOfSlackDistributionFailure(), parametersExt.getSlackBusPMaxMismatch());
}

@Override
public List<OuterLoop> configure(LoadFlowParameters parameters, OpenLoadFlowParameters parametersExt) {
List<OuterLoop> outerLoops = new ArrayList<>(5);
// primary frequency control
if (parameters.isDistributedSlack()) {
ActivePowerDistribution activePowerDistribution = ActivePowerDistribution.create(parameters.getBalanceType(), parametersExt.isLoadPowerFactorConstant());
outerLoops.add(new DistributedSlackOuterLoop(activePowerDistribution, parametersExt.isThrowsExceptionInCaseOfSlackDistributionFailure(), parametersExt.getSlackBusPMaxMismatch()));
}
if (parameters.isPhaseShifterRegulationOn()) {
outerLoops.add(new PhaseControlOuterLoop());
outerLoops.add(createDistributedSlackOuterLoop(parameters, parametersExt));
}
// primary voltage control
if (parametersExt.isSvcVoltageMonitoring()) {
outerLoops.add(new MonitoringVoltageOuterLoop());
}
if (parameters.isUseReactiveLimits()) {
outerLoops.add(new ReactiveLimitsOuterLoop());
}
// phase shifter control
if (parameters.isPhaseShifterRegulationOn()) {
outerLoops.add(new PhaseControlOuterLoop());
}
// transformer voltage control
if (parameters.isTransformerVoltageControlOn()) {
if (parametersExt.getTransformerVoltageControlMode() == OpenLoadFlowParameters.TransformerVoltageControlMode.WITH_GENERATOR_VOLTAGE_CONTROL) {
outerLoops.add(new SimpleTransformerVoltageControlOuterLoop());
} else if (parametersExt.getTransformerVoltageControlMode() == OpenLoadFlowParameters.TransformerVoltageControlMode.AFTER_GENERATOR_VOLTAGE_CONTROL) {
outerLoops.add(new TransformerVoltageControlOuterLoop());
} else if (parametersExt.getTransformerVoltageControlMode() == OpenLoadFlowParameters.TransformerVoltageControlMode.INCREMENTAL_VOLTAGE_CONTROL) {
outerLoops.add(new IncrementalTransformerVoltageControlOuterLoop());
} else {
throw new IllegalStateException("Unknown transformer voltage control mode: " + parametersExt.getTransformerVoltageControlMode());
}
outerLoops.add(createTransformerVoltageControlOuterLoop(parametersExt));
}
// shunt compensator voltage control
if (parameters.isShuntCompensatorVoltageControlOn()) {
outerLoops.add(new ShuntVoltageControlOuterLoop());
}
Expand Down

0 comments on commit 6371e1f

Please sign in to comment.