Skip to content

Commit

Permalink
Merge branch 'main' into 3windingsTranformersInSensi
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
  • Loading branch information
flo-dup committed Nov 23, 2022
2 parents a422296 + cef23de commit 386f1a5
Show file tree
Hide file tree
Showing 32 changed files with 315 additions and 256 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,18 @@ It supports contingencies of type:
## Getting started

Running a load flow with PowSyBl Open Load Flow is easy. First let's start loading a IEEE 14 bus network. We first add a few Maven
dependencies to respectively have access to network model, IEEE test networks, PowSyBl platform configuration and simple logging
capabilities:
dependencies to respectively have access to network model, IEEE test networks and simple logging capabilities:

```xml
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-iidm-impl</artifactId>
<version>4.10.0</version>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-ieee-cdf-converter</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-config-classic</artifactId>
<version>4.10.0</version>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -113,7 +107,7 @@ After adding a last Maven dependency on Open Load Flow implementation:
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-open-loadflow</artifactId>
<version>0.23.1</version>
<version>0.24.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</parent>

<artifactId>powsybl-open-loadflow</artifactId>
<version>0.24.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>

<name>powsybl open loadflow</name>
<description>An open source loadflow based on PowSyBl</description>
Expand Down
59 changes: 31 additions & 28 deletions src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters

public static final boolean LOAD_POWER_FACTOR_CONSTANT_DEFAULT_VALUE = false;

public static final boolean ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_DEFAULT_VALUE = true;

/**
* Slack bus maximum active power mismatch in MW: 1 Mw => 10^-2 in p.u
*/
Expand All @@ -79,8 +77,6 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters

public static final String PLAUSIBLE_ACTIVE_POWER_LIMIT_PARAM_NAME = "plausibleActivePowerLimit";

public static final String ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_NAME = "addRatioToLinesWithDifferentNominalVoltageAtBothEnds";

public static final String SLACK_BUS_P_MAX_MISMATCH_NAME = "slackBusPMaxMismatch";

public static final String VOLTAGE_PER_REACTIVE_POWER_CONTROL_NAME = "voltagePerReactivePowerControl";
Expand All @@ -103,14 +99,15 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters

public static final String MAX_REALISTIC_VOLTAGE_NAME = "maxRealisticVoltage";

public static final String REACTIVE_RANGE_CHECK_MODE_NAME = "reactiveRangeCheckMode";

public static final List<String> SPECIFIC_PARAMETERS_NAMES = List.of(SLACK_BUS_SELECTION_PARAM_NAME,
SLACK_BUSES_IDS_PARAM_NAME,
LOW_IMPEDANCE_BRANCH_MODE_PARAM_NAME,
VOLTAGE_REMOTE_CONTROL_PARAM_NAME,
THROWS_EXCEPTION_IN_CASE_OF_SLACK_DISTRIBUTION_FAILURE_PARAM_NAME,
LOAD_POWER_FACTOR_CONSTANT_PARAM_NAME,
PLAUSIBLE_ACTIVE_POWER_LIMIT_PARAM_NAME,
ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_NAME,
SLACK_BUS_P_MAX_MISMATCH_NAME,
VOLTAGE_PER_REACTIVE_POWER_CONTROL_NAME,
REACTIVE_POWER_REMOTE_CONTROL_PARAM_NAME,
Expand All @@ -122,7 +119,8 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters
MIN_PLAUSIBLE_TARGET_VOLTAGE_NAME,
MAX_PLAUSIBLE_TARGET_VOLTAGE_NAME,
MIN_REALISTIC_VOLTAGE_NAME,
MAX_REALISTIC_VOLTAGE_NAME);
MAX_REALISTIC_VOLTAGE_NAME,
REACTIVE_RANGE_CHECK_MODE_NAME);

public enum VoltageInitModeOverride {
NONE,
Expand Down Expand Up @@ -159,8 +157,6 @@ public enum LowImpedanceBranchMode {

private double plausibleActivePowerLimit = LfNetworkParameters.PLAUSIBLE_ACTIVE_POWER_LIMIT_DEFAULT_VALUE;

private boolean addRatioToLinesWithDifferentNominalVoltageAtBothEnds = ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_DEFAULT_VALUE;

private double slackBusPMaxMismatch = SLACK_BUS_P_MAX_MISMATCH_DEFAULT_VALUE;

private boolean voltagePerReactivePowerControl = VOLTAGE_PER_REACTIVE_POWER_CONTROL_DEFAULT_VALUE;
Expand All @@ -185,6 +181,14 @@ public enum LowImpedanceBranchMode {

private double maxRealisticVoltage = NewtonRaphsonParameters.DEFAULT_MAX_REALISTIC_VOLTAGE;

public enum ReactiveRangeCheckMode {
MIN_MAX,
MAX,
TARGET_P
}

private ReactiveRangeCheckMode reactiveRangeCheckMode = LfNetworkParameters.REACTIVE_RANGE_CHECK_MODE_DEFAULT_VALUE;

@Override
public String getName() {
return "open-load-flow-parameters";
Expand Down Expand Up @@ -270,15 +274,6 @@ public OpenLoadFlowParameters setSlackBusPMaxMismatch(double pSlackBusPMaxMismat
return this;
}

public boolean isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds() {
return addRatioToLinesWithDifferentNominalVoltageAtBothEnds;
}

public OpenLoadFlowParameters setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(boolean addRatioToLinesWithDifferentNominalVoltageAtBothEnds) {
this.addRatioToLinesWithDifferentNominalVoltageAtBothEnds = addRatioToLinesWithDifferentNominalVoltageAtBothEnds;
return this;
}

public boolean isVoltagePerReactivePowerControl() {
return voltagePerReactivePowerControl;
}
Expand Down Expand Up @@ -378,6 +373,15 @@ public OpenLoadFlowParameters setMaxRealisticVoltage(double maxRealisticVoltage)
return this;
}

public ReactiveRangeCheckMode getReactiveRangeCheckMode() {
return reactiveRangeCheckMode;
}

public OpenLoadFlowParameters setReactiveRangeCheckMode(ReactiveRangeCheckMode reactiveRangeCheckMode) {
this.reactiveRangeCheckMode = reactiveRangeCheckMode;
return this;
}

public static OpenLoadFlowParameters load() {
return load(PlatformConfig.defaultConfig());
}
Expand All @@ -395,7 +399,6 @@ public static OpenLoadFlowParameters load(PlatformConfig platformConfig) {
)
.setLoadPowerFactorConstant(config.getBooleanProperty(LOAD_POWER_FACTOR_CONSTANT_PARAM_NAME, LOAD_POWER_FACTOR_CONSTANT_DEFAULT_VALUE))
.setPlausibleActivePowerLimit(config.getDoubleProperty(PLAUSIBLE_ACTIVE_POWER_LIMIT_PARAM_NAME, LfNetworkParameters.PLAUSIBLE_ACTIVE_POWER_LIMIT_DEFAULT_VALUE))
.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(config.getBooleanProperty(ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_NAME, ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_DEFAULT_VALUE))
.setSlackBusPMaxMismatch(config.getDoubleProperty(SLACK_BUS_P_MAX_MISMATCH_NAME, SLACK_BUS_P_MAX_MISMATCH_DEFAULT_VALUE))
.setVoltagePerReactivePowerControl(config.getBooleanProperty(VOLTAGE_PER_REACTIVE_POWER_CONTROL_NAME, VOLTAGE_PER_REACTIVE_POWER_CONTROL_DEFAULT_VALUE))
.setReactivePowerRemoteControl(config.getBooleanProperty(REACTIVE_POWER_REMOTE_CONTROL_PARAM_NAME, REACTIVE_POWER_REMOTE_CONTROL_DEFAULT_VALUE))
Expand All @@ -407,7 +410,8 @@ public static OpenLoadFlowParameters load(PlatformConfig platformConfig) {
.setMinPlausibleTargetVoltage(config.getDoubleProperty(MIN_PLAUSIBLE_TARGET_VOLTAGE_NAME, LfNetworkParameters.MIN_PLAUSIBLE_TARGET_VOLTAGE_DEFAULT_VALUE))
.setMaxPlausibleTargetVoltage(config.getDoubleProperty(MAX_PLAUSIBLE_TARGET_VOLTAGE_NAME, LfNetworkParameters.MAX_PLAUSIBLE_TARGET_VOLTAGE_DEFAULT_VALUE))
.setMinRealisticVoltage(config.getDoubleProperty(MIN_REALISTIC_VOLTAGE_NAME, NewtonRaphsonParameters.DEFAULT_MIN_REALISTIC_VOLTAGE))
.setMaxRealisticVoltage(config.getDoubleProperty(MAX_REALISTIC_VOLTAGE_NAME, NewtonRaphsonParameters.DEFAULT_MAX_REALISTIC_VOLTAGE)));
.setMaxRealisticVoltage(config.getDoubleProperty(MAX_REALISTIC_VOLTAGE_NAME, NewtonRaphsonParameters.DEFAULT_MAX_REALISTIC_VOLTAGE))
.setReactiveRangeCheckMode(config.getEnumProperty(REACTIVE_RANGE_CHECK_MODE_NAME, ReactiveRangeCheckMode.class, LfNetworkParameters.REACTIVE_RANGE_CHECK_MODE_DEFAULT_VALUE)));
return parameters;
}

Expand All @@ -430,8 +434,6 @@ public OpenLoadFlowParameters update(Map<String, String> properties) {
.ifPresent(prop -> this.setLoadPowerFactorConstant(Boolean.parseBoolean(prop)));
Optional.ofNullable(properties.get(PLAUSIBLE_ACTIVE_POWER_LIMIT_PARAM_NAME))
.ifPresent(prop -> this.setPlausibleActivePowerLimit(Double.parseDouble(prop)));
Optional.ofNullable(properties.get(ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_NAME))
.ifPresent(prop -> this.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(Boolean.parseBoolean(prop)));
Optional.ofNullable(properties.get(SLACK_BUS_P_MAX_MISMATCH_NAME))
.ifPresent(prop -> this.setSlackBusPMaxMismatch(Double.parseDouble(prop)));
Optional.ofNullable(properties.get(VOLTAGE_PER_REACTIVE_POWER_CONTROL_NAME))
Expand All @@ -456,6 +458,8 @@ public OpenLoadFlowParameters update(Map<String, String> properties) {
.ifPresent(prop -> this.setMinRealisticVoltage(Double.parseDouble(prop)));
Optional.ofNullable(properties.get(MAX_REALISTIC_VOLTAGE_NAME))
.ifPresent(prop -> this.setMaxRealisticVoltage(Double.parseDouble(prop)));
Optional.ofNullable(properties.get(REACTIVE_RANGE_CHECK_MODE_NAME))
.ifPresent(prop -> this.setReactiveRangeCheckMode(ReactiveRangeCheckMode.valueOf(prop)));
return this;
}

Expand All @@ -469,7 +473,6 @@ public String toString() {
", lowImpedanceBranchMode=" + lowImpedanceBranchMode +
", loadPowerFactorConstant=" + loadPowerFactorConstant +
", plausibleActivePowerLimit=" + plausibleActivePowerLimit +
", addRatioToLinesWithDifferentNominalVoltageAtBothEnds=" + addRatioToLinesWithDifferentNominalVoltageAtBothEnds +
", slackBusPMaxMismatch=" + slackBusPMaxMismatch +
", voltagePerReactivePowerControl=" + voltagePerReactivePowerControl +
", reactivePowerRemoteControl=" + reactivePowerRemoteControl +
Expand All @@ -482,6 +485,7 @@ public String toString() {
", maxPlausibleTargetVoltage=" + maxPlausibleTargetVoltage +
", minRealisticVoltage=" + minRealisticVoltage +
", maxRealisticVoltage=" + maxRealisticVoltage +
", reactiveRangeCheckMode=" + reactiveRangeCheckMode +
')';
}

Expand Down Expand Up @@ -515,7 +519,6 @@ public static void logDc(LoadFlowParameters parameters, OpenLoadFlowParameters p
LOGGER.info("Distributed slack: {}", parameters.isDistributedSlack());
LOGGER.info("Balance type: {}", parameters.getBalanceType());
LOGGER.info("Plausible active power limit: {}", parametersExt.getPlausibleActivePowerLimit());
LOGGER.info("Add ratio to lines with different nominal voltage at both ends: {}", parametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds());
LOGGER.info("Connected component mode: {}", parameters.getConnectedComponentMode());
LOGGER.info("DC power factor: {}", parametersExt.getDcPowerFactor());
}
Expand All @@ -537,7 +540,6 @@ public static void logAc(LoadFlowParameters parameters, OpenLoadFlowParameters p
LOGGER.info("Transformer voltage control: {}", parameters.isTransformerVoltageControlOn());
LOGGER.info("Load power factor constant: {}", parametersExt.isLoadPowerFactorConstant());
LOGGER.info("Plausible active power limit: {}", parametersExt.getPlausibleActivePowerLimit());
LOGGER.info("Add ratio to lines with different nominal voltage at both ends: {}", parametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds());
LOGGER.info("Slack bus Pmax mismatch: {}", parametersExt.getSlackBusPMaxMismatch());
LOGGER.info("Connected component mode: {}", parameters.getConnectedComponentMode());
LOGGER.info("Voltage per reactive power control: {}", parametersExt.isVoltagePerReactivePowerControl());
Expand All @@ -548,6 +550,7 @@ public static void logAc(LoadFlowParameters parameters, OpenLoadFlowParameters p
LOGGER.info("Max plausible target voltage: {}", parametersExt.getMaxPlausibleTargetVoltage());
LOGGER.info("Min realistic voltage: {}", parametersExt.getMinRealisticVoltage());
LOGGER.info("Max realistic voltage: {}", parametersExt.getMaxRealisticVoltage());
LOGGER.info("Reactive range check mode: {}", parametersExt.getReactiveRangeCheckMode());
}

static VoltageInitializer getVoltageInitializer(LoadFlowParameters parameters, LfNetworkParameters networkParameters, MatrixFactory matrixFactory, Reporter reporter) {
Expand Down Expand Up @@ -597,7 +600,6 @@ static LfNetworkParameters getNetworkParameters(LoadFlowParameters parameters, O
.setTwtSplitShuntAdmittance(parameters.isTwtSplitShuntAdmittance())
.setBreakers(breakers)
.setPlausibleActivePowerLimit(parametersExt.getPlausibleActivePowerLimit())
.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(parametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds())
.setComputeMainConnectedComponentOnly(parameters.getConnectedComponentMode() == LoadFlowParameters.ConnectedComponentMode.MAIN)
.setCountriesToBalance(parameters.getCountriesToBalance())
.setDistributedOnConformLoad(parameters.isDistributedSlack() && parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD)
Expand All @@ -610,7 +612,8 @@ static LfNetworkParameters getNetworkParameters(LoadFlowParameters parameters, O
.setReactiveLimits(!parameters.isNoGeneratorReactiveLimits())
.setHvdcAcEmulation(parameters.isHvdcAcEmulation())
.setMinPlausibleTargetVoltage(parametersExt.getMinPlausibleTargetVoltage())
.setMaxPlausibleTargetVoltage(parametersExt.getMaxPlausibleTargetVoltage());
.setMaxPlausibleTargetVoltage(parametersExt.getMaxPlausibleTargetVoltage())
.setReactiveRangeCheckMode(parametersExt.getReactiveRangeCheckMode());
}

public static AcLoadFlowParameters createAcParameters(Network network, LoadFlowParameters parameters, OpenLoadFlowParameters parametersExt,
Expand Down Expand Up @@ -680,7 +683,6 @@ public static DcLoadFlowParameters createDcParameters(LoadFlowParameters paramet
.setTwtSplitShuntAdmittance(false)
.setBreakers(false)
.setPlausibleActivePowerLimit(parametersExt.getPlausibleActivePowerLimit())
.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(parametersExt.isAddRatioToLinesWithDifferentNominalVoltageAtBothEnds())
.setComputeMainConnectedComponentOnly(parameters.getConnectedComponentMode() == LoadFlowParameters.ConnectedComponentMode.MAIN)
.setCountriesToBalance(parameters.getCountriesToBalance())
.setDistributedOnConformLoad(parameters.isDistributedSlack() && parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD)
Expand All @@ -693,7 +695,8 @@ public static DcLoadFlowParameters createDcParameters(LoadFlowParameters paramet
.setReactiveLimits(false)
.setHvdcAcEmulation(false) // FIXME
.setMinPlausibleTargetVoltage(parametersExt.getMinPlausibleTargetVoltage())
.setMaxPlausibleTargetVoltage(parametersExt.getMaxPlausibleTargetVoltage());
.setMaxPlausibleTargetVoltage(parametersExt.getMaxPlausibleTargetVoltage())
.setReactiveRangeCheckMode(ReactiveRangeCheckMode.MAX); // not useful for DC.

var equationSystemCreationParameters = new DcEquationSystemCreationParameters(true,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ enum GeneratorControlType {
OFF, REMOTE_REACTIVE_POWER, VOLTAGE
}

enum ReactiveRangeMode {
MIN, MAX, TARGET_P
}

String getId();

String getOriginalId();
Expand Down Expand Up @@ -51,7 +55,7 @@ enum GeneratorControlType {

double getMaxQ();

double getMaxRangeQ();
double getRangeQ(ReactiveRangeMode reactiveRangeMode);

default boolean isParticipating() {
return false;
Expand Down
Loading

0 comments on commit 386f1a5

Please sign in to comment.