Skip to content
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

Upgrade to core 5.2.0-RC1 #754

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@

<jafama.version>2.3.2</jafama.version>
<slf4jtoys.version>1.6.3</slf4jtoys.version>
<graphviz-builder.version>1.0.12</graphviz-builder.version>

<powsybl-core.version>5.2.0-alpha-1</powsybl-core.version>
<powsybl-core.version>5.2.0-RC1</powsybl-core.version>
</properties>

<build>
Expand Down Expand Up @@ -108,7 +107,6 @@
<dependency>
<groupId>org.anarres.graphviz</groupId>
<artifactId>graphviz-builder</artifactId>
<version>${graphviz-builder.version}</version>
</dependency>

<dependency>
Expand Down
59 changes: 20 additions & 39 deletions src/main/java/com/powsybl/openloadflow/OpenLoadFlowParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters

public static final boolean VOLTAGE_PER_REACTIVE_POWER_CONTROL_DEFAULT_VALUE = false;

public static final double DC_POWER_FACTOR_DEFAULT_VALUE = 1.0;

public static final boolean SVC_VOLTAGE_MONITORING_DEFAULT_VALUE = true;

public static final VoltageInitModeOverride VOLTAGE_INIT_MODE_OVERRIDE_DEFAULT_VALUE = VoltageInitModeOverride.NONE;
Expand Down Expand Up @@ -136,8 +134,6 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters

public static final String SHUNT_VOLTAGE_CONTROL_MODE_PARAM_NAME = "shuntVoltageControlMode";

public static final String DC_POWER_FACTOR_PARAM_NAME = "dcPowerFactor";

public static final String MIN_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME = "minPlausibleTargetVoltage";

public static final String MAX_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME = "maxPlausibleTargetVoltage";
Expand Down Expand Up @@ -188,7 +184,6 @@ private static <E extends Enum<E>> List<Object> getEnumPossibleValues(Class<E> e
new Parameter(VOLTAGE_INIT_MODE_OVERRIDE_PARAM_NAME, ParameterType.STRING, "Voltage init mode override", VOLTAGE_INIT_MODE_OVERRIDE_DEFAULT_VALUE.name(), getEnumPossibleValues(VoltageInitModeOverride.class)),
new Parameter(TRANSFORMER_VOLTAGE_CONTROL_MODE_PARAM_NAME, ParameterType.STRING, "Transformer voltage control mode", TRANSFORMER_VOLTAGE_CONTROL_MODE_DEFAULT_VALUE.name(), getEnumPossibleValues(TransformerVoltageControlMode.class)),
new Parameter(SHUNT_VOLTAGE_CONTROL_MODE_PARAM_NAME, ParameterType.STRING, "Shunt voltage control mode", SHUNT_VOLTAGE_CONTROL_MODE_DEFAULT_VALUE.name(), getEnumPossibleValues(ShuntVoltageControlMode.class)),
new Parameter(DC_POWER_FACTOR_PARAM_NAME, ParameterType.DOUBLE, "DC approximation power factor", DC_POWER_FACTOR_DEFAULT_VALUE),
new Parameter(MIN_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME, ParameterType.DOUBLE, "Min plausible target voltage", LfNetworkParameters.MIN_PLAUSIBLE_TARGET_VOLTAGE_DEFAULT_VALUE),
new Parameter(MAX_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME, ParameterType.DOUBLE, "Max plausible target voltage", LfNetworkParameters.MAX_PLAUSIBLE_TARGET_VOLTAGE_DEFAULT_VALUE),
new Parameter(MIN_REALISTIC_VOLTAGE_PARAM_NAME, ParameterType.DOUBLE, "Min realistic voltage", NewtonRaphsonParameters.DEFAULT_MIN_REALISTIC_VOLTAGE),
Expand Down Expand Up @@ -284,8 +279,6 @@ public enum LowImpedanceBranchMode {

private ShuntVoltageControlMode shuntVoltageControlMode = SHUNT_VOLTAGE_CONTROL_MODE_DEFAULT_VALUE;

private double dcPowerFactor = DC_POWER_FACTOR_DEFAULT_VALUE;

private double minPlausibleTargetVoltage = LfNetworkParameters.MIN_PLAUSIBLE_TARGET_VOLTAGE_DEFAULT_VALUE;

private double maxPlausibleTargetVoltage = LfNetworkParameters.MAX_PLAUSIBLE_TARGET_VOLTAGE_DEFAULT_VALUE;
Expand Down Expand Up @@ -551,15 +544,6 @@ public OpenLoadFlowParameters setShuntVoltageControlMode(ShuntVoltageControlMode
return this;
}

public double getDcPowerFactor() {
return dcPowerFactor;
}

public OpenLoadFlowParameters setDcPowerFactor(double dcPowerFactor) {
this.dcPowerFactor = dcPowerFactor;
return this;
}

public double getMinPlausibleTargetVoltage() {
return minPlausibleTargetVoltage;
}
Expand Down Expand Up @@ -736,7 +720,6 @@ public static OpenLoadFlowParameters load(PlatformConfig platformConfig) {
.setVoltageInitModeOverride(config.getEnumProperty(VOLTAGE_INIT_MODE_OVERRIDE_PARAM_NAME, VoltageInitModeOverride.class, VOLTAGE_INIT_MODE_OVERRIDE_DEFAULT_VALUE))
.setTransformerVoltageControlMode(config.getEnumProperty(TRANSFORMER_VOLTAGE_CONTROL_MODE_PARAM_NAME, TransformerVoltageControlMode.class, TRANSFORMER_VOLTAGE_CONTROL_MODE_DEFAULT_VALUE))
.setShuntVoltageControlMode(config.getEnumProperty(SHUNT_VOLTAGE_CONTROL_MODE_PARAM_NAME, ShuntVoltageControlMode.class, SHUNT_VOLTAGE_CONTROL_MODE_DEFAULT_VALUE))
.setDcPowerFactor(config.getDoubleProperty(DC_POWER_FACTOR_PARAM_NAME, DC_POWER_FACTOR_DEFAULT_VALUE))
.setMinPlausibleTargetVoltage(config.getDoubleProperty(MIN_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME, LfNetworkParameters.MIN_PLAUSIBLE_TARGET_VOLTAGE_DEFAULT_VALUE))
.setMaxPlausibleTargetVoltage(config.getDoubleProperty(MAX_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME, LfNetworkParameters.MAX_PLAUSIBLE_TARGET_VOLTAGE_DEFAULT_VALUE))
.setMinRealisticVoltage(config.getDoubleProperty(MIN_REALISTIC_VOLTAGE_PARAM_NAME, NewtonRaphsonParameters.DEFAULT_MIN_REALISTIC_VOLTAGE))
Expand Down Expand Up @@ -805,8 +788,6 @@ public OpenLoadFlowParameters update(Map<String, String> properties) {
.ifPresent(prop -> this.setTransformerVoltageControlMode(TransformerVoltageControlMode.valueOf(prop)));
Optional.ofNullable(properties.get(SHUNT_VOLTAGE_CONTROL_MODE_PARAM_NAME))
.ifPresent(prop -> this.setShuntVoltageControlMode(ShuntVoltageControlMode.valueOf(prop)));
Optional.ofNullable(properties.get(DC_POWER_FACTOR_PARAM_NAME))
.ifPresent(prop -> this.setDcPowerFactor(Double.parseDouble(prop)));
Optional.ofNullable(properties.get(MIN_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME))
.ifPresent(prop -> this.setMinPlausibleTargetVoltage(Double.parseDouble(prop)));
Optional.ofNullable(properties.get(MAX_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME))
Expand Down Expand Up @@ -864,7 +845,6 @@ public Map<String, Object> toMap() {
map.put(VOLTAGE_INIT_MODE_OVERRIDE_PARAM_NAME, voltageInitModeOverride);
map.put(TRANSFORMER_VOLTAGE_CONTROL_MODE_PARAM_NAME, transformerVoltageControlMode);
map.put(SHUNT_VOLTAGE_CONTROL_MODE_PARAM_NAME, shuntVoltageControlMode);
map.put(DC_POWER_FACTOR_PARAM_NAME, dcPowerFactor);
map.put(MIN_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME, minPlausibleTargetVoltage);
map.put(MAX_PLAUSIBLE_TARGET_VOLTAGE_PARAM_NAME, maxPlausibleTargetVoltage);
map.put(MIN_REALISTIC_VOLTAGE_PARAM_NAME, minRealisticVoltage);
Expand Down Expand Up @@ -919,7 +899,7 @@ public static void logDc(LoadFlowParameters parameters, OpenLoadFlowParameters p
LOGGER.info("Balance type: {}", parameters.getBalanceType());
LOGGER.info("Plausible active power limit: {}", parametersExt.getPlausibleActivePowerLimit());
LOGGER.info("Connected component mode: {}", parameters.getConnectedComponentMode());
LOGGER.info("DC power factor: {}", parametersExt.getDcPowerFactor());
LOGGER.info("DC power factor: {}", parameters.getDcPowerFactor());
LOGGER.info("Debug directory: {}", parametersExt.getDebugDir());
}

Expand Down Expand Up @@ -1158,7 +1138,8 @@ public static boolean equals(LoadFlowParameters parameters1, LoadFlowParameters
parameters1.isDcUseTransformerRatio() == parameters2.isDcUseTransformerRatio() &&
parameters1.getCountriesToBalance().equals(parameters2.getCountriesToBalance()) &&
parameters1.getConnectedComponentMode() == parameters2.getConnectedComponentMode() &&
parameters1.isHvdcAcEmulation() == parameters2.isHvdcAcEmulation();
parameters1.isHvdcAcEmulation() == parameters2.isHvdcAcEmulation() &&
parameters1.getDcPowerFactor() == parameters2.getDcPowerFactor();
if (!equals) {
return false;
}
Expand Down Expand Up @@ -1190,7 +1171,6 @@ public static boolean equals(LoadFlowParameters parameters1, LoadFlowParameters
extension1.getVoltageInitModeOverride() == extension2.getVoltageInitModeOverride() &&
extension1.getTransformerVoltageControlMode() == extension2.getTransformerVoltageControlMode() &&
extension1.getShuntVoltageControlMode() == extension2.getShuntVoltageControlMode() &&
extension1.getDcPowerFactor() == extension2.getDcPowerFactor() &&
extension1.getMinPlausibleTargetVoltage() == extension2.getMinPlausibleTargetVoltage() &&
extension1.getMaxPlausibleTargetVoltage() == extension2.getMaxPlausibleTargetVoltage() &&
extension1.getMinRealisticVoltage() == extension2.getMinRealisticVoltage() &&
Expand All @@ -1210,21 +1190,23 @@ public static boolean equals(LoadFlowParameters parameters1, LoadFlowParameters

public static LoadFlowParameters clone(LoadFlowParameters parameters) {
Objects.requireNonNull(parameters);
LoadFlowParameters parameters2 = new LoadFlowParameters(parameters.getVoltageInitMode(),
parameters.isTransformerVoltageControlOn(),
parameters.isUseReactiveLimits(),
parameters.isPhaseShifterRegulationOn(),
parameters.isTwtSplitShuntAdmittance(),
parameters.isShuntCompensatorVoltageControlOn(),
parameters.isReadSlackBus(),
parameters.isWriteSlackBus(),
parameters.isDc(),
parameters.isDistributedSlack(),
parameters.getBalanceType(),
parameters.isDcUseTransformerRatio(),
new HashSet<>(parameters.getCountriesToBalance()),
parameters.getConnectedComponentMode(),
parameters.isHvdcAcEmulation());
LoadFlowParameters parameters2 = new LoadFlowParameters()
.setVoltageInitMode(parameters.getVoltageInitMode())
.setTransformerVoltageControlOn(parameters.isTransformerVoltageControlOn())
.setUseReactiveLimits(parameters.isUseReactiveLimits())
.setPhaseShifterRegulationOn(parameters.isPhaseShifterRegulationOn())
.setTwtSplitShuntAdmittance(parameters.isTwtSplitShuntAdmittance())
.setShuntCompensatorVoltageControlOn(parameters.isShuntCompensatorVoltageControlOn())
.setReadSlackBus(parameters.isReadSlackBus())
.setWriteSlackBus(parameters.isWriteSlackBus())
.setDc(parameters.isDc())
.setDistributedSlack(parameters.isDistributedSlack())
.setBalanceType(parameters.getBalanceType())
.setDcUseTransformerRatio(parameters.isDcUseTransformerRatio())
.setCountriesToBalance(new HashSet<>(parameters.getCountriesToBalance()))
.setConnectedComponentMode(parameters.getConnectedComponentMode())
.setHvdcAcEmulation(parameters.isHvdcAcEmulation())
.setDcPowerFactor(parameters.getDcPowerFactor());

OpenLoadFlowParameters extension = parameters.getExtension(OpenLoadFlowParameters.class);
if (extension != null) {
Expand All @@ -1244,7 +1226,6 @@ public static LoadFlowParameters clone(LoadFlowParameters parameters) {
.setVoltageInitModeOverride(extension.getVoltageInitModeOverride())
.setTransformerVoltageControlMode(extension.getTransformerVoltageControlMode())
.setShuntVoltageControlMode(extension.getShuntVoltageControlMode())
.setDcPowerFactor(extension.getDcPowerFactor())
.setMinPlausibleTargetVoltage(extension.getMinPlausibleTargetVoltage())
.setMaxPlausibleTargetVoltage(extension.getMaxPlausibleTargetVoltage())
.setMinRealisticVoltage(extension.getMinRealisticVoltage())
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/powsybl/openloadflow/network/LfAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ private static Optional<LfAction> create(LoadAction action, LfNetwork lfNetwork,
LfBus lfBus = lfNetwork.getBusById(bus.getId());
double activePowerShift = 0;
double reactivePowerShift = 0;
Optional<Double> activePowerValue = action.getActivePowerValue();
Optional<Double> reactivePowerValue = action.getReactivePowerValue();
OptionalDouble activePowerValue = action.getActivePowerValue();
OptionalDouble reactivePowerValue = action.getReactivePowerValue();
if (activePowerValue.isPresent()) {
activePowerShift = action.isRelativeValue() ? activePowerValue.get() : activePowerValue.get() - load.getP0();
activePowerShift = action.isRelativeValue() ? activePowerValue.getAsDouble() : activePowerValue.getAsDouble() - load.getP0();
}
if (reactivePowerValue.isPresent()) {
reactivePowerShift = action.isRelativeValue() ? reactivePowerValue.get() : reactivePowerValue.get() - load.getQ0();
reactivePowerShift = action.isRelativeValue() ? reactivePowerValue.getAsDouble() : reactivePowerValue.getAsDouble() - load.getQ0();
}
// In case of a power shift, we suppose that the shift on a load P0 is exactly the same on the variable active power
// of P0 that could be described in a LoadDetail extension.
Expand Down Expand Up @@ -199,14 +199,14 @@ private static Optional<LfAction> create(SwitchAction action, LfNetwork lfNetwor
private static Optional<LfAction> create(GeneratorAction action, LfNetwork lfNetwork) {
LfGenerator generator = lfNetwork.getGeneratorById(action.getGeneratorId());
if (generator != null) {
Optional<Double> activePowerValue = action.getActivePowerValue();
OptionalDouble activePowerValue = action.getActivePowerValue();
Optional<Boolean> relativeValue = action.isActivePowerRelativeValue();
if (relativeValue.isPresent() && activePowerValue.isPresent()) {
double deltaTargetP;
if (relativeValue.get().equals(Boolean.TRUE)) {
deltaTargetP = activePowerValue.get() / PerUnit.SB;
deltaTargetP = activePowerValue.getAsDouble() / PerUnit.SB;
} else {
deltaTargetP = activePowerValue.get() / PerUnit.SB - generator.getInitialTargetP();
deltaTargetP = activePowerValue.getAsDouble() / PerUnit.SB - generator.getInitialTargetP();
}
var generatorChange = new GeneratorChange(generator, deltaTargetP);
return Optional.of(new LfAction(action.getId(), null, null, null, null, generatorChange));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ SecurityAnalysisReport runSync(String workingVariantId, SecurityAnalysisParamete

List<SensitivityVariableSet> variableSets = Collections.emptyList();
SensitivityAnalysisParameters sensitivityAnalysisParameters = new SensitivityAnalysisParameters();
sensitivityAnalysisParameters.setLoadFlowParameters(securityAnalysisParameters.getLoadFlowParameters());
LoadFlowParameters loadFlowParameters = securityAnalysisParameters.getLoadFlowParameters();
sensitivityAnalysisParameters.setLoadFlowParameters(loadFlowParameters);

ContingencyContext contingencyContext = new ContingencyContext(null, ContingencyContextType.ALL);
String variableId = network.getLoads().iterator().next().getId();

DefaultLimitViolationDetector detector = new DefaultLimitViolationDetector(1.0f, EnumSet.allOf(LoadingLimitType.class));

// CosPhi for DC power to current conversion
OpenLoadFlowParameters parametersExt = OpenLoadFlowParameters.get(securityAnalysisParameters.getLoadFlowParameters());
DcSecurityAnalysisContext context = new DcSecurityAnalysisContext(securityAnalysisParameters, contingencies, detector, parametersExt.getDcPowerFactor());
DcSecurityAnalysisContext context = new DcSecurityAnalysisContext(securityAnalysisParameters, contingencies, detector, loadFlowParameters.getDcPowerFactor());
SensitivityFactorReader factorReader = handler -> {
for (Branch<?> b : network.getBranches()) {
SensitivityFactor f = new SensitivityFactor(SensitivityFunctionType.BRANCH_ACTIVE_POWER_1, b.getId(), SensitivityVariableType.INJECTION_ACTIVE_POWER,
Expand Down
Loading