From d9b9ed251850493cf01d1e258196cef5e05d5016 Mon Sep 17 00:00:00 2001 From: Philippe Edwards Date: Mon, 5 Jun 2023 15:14:17 +0200 Subject: [PATCH 1/4] bump powsybl to 5.3.0-alpha-2 --- .../util/cgmes/CgmesBranchHelper.java | 25 ++++++++---------- .../util/iidm/IidmCnecElementHelper.java | 14 ++++------ .../util/ucte/UcteConnectableCollection.java | 25 +++++++++++++++--- .../ucte/UcteContingencyElementHelper.java | 1 + .../util/ucte/UcteFlowElementHelper.java | 26 ++++++++++++++----- .../contingency/CimContingencyCreator.java | 10 +++++++ .../VoltageMonitoringTest.java | 6 ++--- pom.xml | 4 +-- .../RaoParametersYamlConfigTest.java | 2 +- .../RaoParameters_config_withExtensions.json | 22 +++++++++++++--- .../RaoParameters_config_withOLFParams.json | 22 +++++++++++++--- ...rameters_config_withPartialExtensions.json | 22 +++++++++++++--- ...aoParameters_config_withoutExtensions.json | 22 +++++++++++++--- .../config_withOpenLoadFlowExtension.yml | 2 +- .../parameters/RaoParameters_2P_v2.json | 6 ++--- .../RaoParameters_oneIteration_v2.json | 6 ++--- 16 files changed, 154 insertions(+), 61 deletions(-) diff --git a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/cgmes/CgmesBranchHelper.java b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/cgmes/CgmesBranchHelper.java index fe62f74ae7..57fdb2b68a 100644 --- a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/cgmes/CgmesBranchHelper.java +++ b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/cgmes/CgmesBranchHelper.java @@ -52,20 +52,17 @@ protected void interpret(Network network) { branch = network.getBranch(mrId); if (Objects.isNull(branch)) { // check if it's a half line - for (Line line : network.getLines()) { - if (line.isTieLine()) { - TieLine tieLine = (TieLine) line; - if (tieLine.getHalf1().getId().equals(mrId)) { - isHalfLine = true; - tieLineSide = Branch.Side.ONE; - branch = line; - return; - } else if (tieLine.getHalf2().getId().equals(mrId)) { - isHalfLine = true; - tieLineSide = Branch.Side.TWO; - branch = line; - return; - } + for (TieLine tieLine : network.getTieLines()) { + if (tieLine.getDanglingLine1().getId().equals(mrId)) { + isHalfLine = true; + tieLineSide = Branch.Side.ONE; + branch = tieLine; + return; + } else if (tieLine.getDanglingLine2().getId().equals(mrId)) { + isHalfLine = true; + tieLineSide = Branch.Side.TWO; + branch = tieLine; + return; } } } diff --git a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/iidm/IidmCnecElementHelper.java b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/iidm/IidmCnecElementHelper.java index cece9e4962..da0512b16b 100644 --- a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/iidm/IidmCnecElementHelper.java +++ b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/iidm/IidmCnecElementHelper.java @@ -108,9 +108,6 @@ private void interpretWithNetwork(Network network) { if (interpretAsNetworkIdentifiable(network)) { return; } - if (interpretAsHalfLine(network)) { - return; - } invalidate(format("branch %s was not found in the Network", branchId)); } @@ -131,6 +128,9 @@ private boolean interpretAsNetworkIdentifiable(Network network) { checkBranchNominalVoltage((Branch) cnecElement); checkBranchCurrentLimits((Branch) cnecElement); } else if (cnecElement instanceof DanglingLine) { + if (((DanglingLine) cnecElement).isPaired()) { + return interpretAsHalfLine(network); + } checkDanglingLineNominalVoltage((DanglingLine) cnecElement); checkDanglingLineCurrentLimits((DanglingLine) cnecElement); } else { @@ -140,11 +140,7 @@ private boolean interpretAsNetworkIdentifiable(Network network) { } private boolean interpretAsHalfLine(Network network) { - Optional tieLine = network.getBranchStream() - .filter(TieLine.class::isInstance) - .map(TieLine.class::cast) - .filter(b -> b.getHalf1().getId().equals(branchId) || b.getHalf2().getId().equals(branchId)) - .findAny(); + Optional tieLine = ((DanglingLine) network.getIdentifiable(branchId)).getTieLine(); if (tieLine.isEmpty()) { return false; @@ -152,7 +148,7 @@ private boolean interpretAsHalfLine(Network network) { this.branchIdInNetwork = tieLine.get().getId(); this.isHalfLine = true; - this.halfLineSide = tieLine.get().getHalf1().getId().equals(branchId) ? Branch.Side.ONE : Branch.Side.TWO; + this.halfLineSide = tieLine.get().getDanglingLine1().getId().equals(branchId) ? Branch.Side.ONE : Branch.Side.TWO; checkBranchNominalVoltage(tieLine.get()); checkTieLineCurrentLimits(tieLine.get()); // todo: check if halfLine can be inverted in CGMES format diff --git a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java index fb7fe86417..03fc03d77a 100644 --- a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java +++ b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java @@ -52,7 +52,7 @@ UcteMatchingResult lookForConnectable(String fromNodeId, String toNodeId, String In such cases, both connectables fit the same from/to/suffix. But instead of returning a UcteMatchingRule.severalPossibleMatch(), which is reserved for ambiguous situations with wildcards, this - method returns the connectable with the id in the same order than the the ones given in argument of the method. + method returns the connectable with the id in the same order as the ones given in argument of the method. */ UcteMatchingResult ucteMatchingResult = lookForMatch(fromNodeId, toNodeId, suffix, connectableTypes); @@ -122,7 +122,22 @@ private UcteMatchingResult lookForMatchWithinCollection(String fromNodeId, Strin if (matchedConnetables.size() == 1) { return matchedConnetables.get(0); - } else if (matchedConnetables.size() > 1) { + } else if (matchedConnetables.size() == 2) { + Identifiable identifiable1 = matchedConnetables.get(0).getIidmIdentifiable(); + Identifiable identifiable2 = matchedConnetables.get(1).getIidmIdentifiable(); + + if (identifiable1 instanceof DanglingLine && identifiable2 instanceof TieLine) { + if (tieLineContainsDanglingLine((TieLine) identifiable2, (DanglingLine) identifiable1)) { + return matchedConnetables.get(1); + } + } else if (identifiable2 instanceof DanglingLine && identifiable1 instanceof TieLine) { + if (tieLineContainsDanglingLine((TieLine) identifiable1, (DanglingLine) identifiable2)) { + return matchedConnetables.get(0); + } + } + return UcteMatchingResult.severalPossibleMatch(); + + } else if (matchedConnetables.size() > 2) { return UcteMatchingResult.severalPossibleMatch(); } else { return UcteMatchingResult.notFound(); @@ -137,6 +152,10 @@ private UcteMatchingResult lookForMatchWithinCollection(String fromNodeId, Strin } } + private boolean tieLineContainsDanglingLine(TieLine tieLine, DanglingLine danglingLine) { + return tieLine.getDanglingLine1().equals(danglingLine) || tieLine.getDanglingLine2().equals(danglingLine); + } + private void addBranches(Network network) { network.getBranchStream().forEach(branch -> { String from = getNodeName(branch.getTerminal1().getBusBreakerView().getConnectableBus().getId()); @@ -172,7 +191,7 @@ private void addBranches(Network network) { } private void addDanglingLines(Network network) { - network.getDanglingLineStream().forEach(danglingLine -> { + network.getDanglingLineStream().filter(danglingLine -> !danglingLine.isPaired()).forEach(danglingLine -> { // A dangling line is an Injection with a generator convention. // After an UCTE import, the flow on the dangling line is therefore always from the X_NODE to the other node. String xNode = danglingLine.getUcteXnodeCode(); diff --git a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteContingencyElementHelper.java b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteContingencyElementHelper.java index d2c7a3dbff..544b08550a 100644 --- a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteContingencyElementHelper.java +++ b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteContingencyElementHelper.java @@ -85,6 +85,7 @@ private void interpretWithNetworkAnalyzer(UcteNetworkAnalyzer ucteNetworkAnalyze } Identifiable networkElement = ucteMatchingResult.getIidmIdentifiable(); + this.connectableIdInNetwork = networkElement.getId(); } diff --git a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteFlowElementHelper.java b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteFlowElementHelper.java index 1160c5a6e8..0a93c83522 100644 --- a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteFlowElementHelper.java +++ b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteFlowElementHelper.java @@ -140,19 +140,33 @@ protected void interpretWithNetworkAnalyzer(UcteNetworkAnalyzer networkAnalyzer) this.connectableIdInNetwork = networkElement.getId(); if (networkElement instanceof TieLine) { - this.isHalfLine = true; - this.halfLineSide = ucteMatchingResult.getSide() == TWO ? Branch.Side.TWO : Branch.Side.ONE; - checkBranchNominalVoltage((TieLine) networkElement); - checkTieLineCurrentLimits((TieLine) networkElement); + interpretTieLine((TieLine) networkElement, ucteMatchingResult.getSide() == TWO ? Branch.Side.TWO : Branch.Side.ONE); } else if (networkElement instanceof Branch) { checkBranchNominalVoltage((Branch) networkElement); checkBranchCurrentLimits((Branch) networkElement); } else if (networkElement instanceof DanglingLine) { - checkDanglingLineNominalVoltage((DanglingLine) networkElement); - checkDanglingLineCurrentLimits((DanglingLine) networkElement); + DanglingLine danglingLine = (DanglingLine) networkElement; + if (danglingLine.getTieLine().isPresent()) { + TieLine tieLine = danglingLine.getTieLine().get(); + this.connectableIdInNetwork = tieLine.getId(); + Branch.Side side = tieLine.getDanglingLine1() == danglingLine ? Branch.Side.ONE : Branch.Side.TWO; + // dangling line convention is x node to terminal, so dl 1 is towards terminal 1 (opposite) and dl 2 is towards terminal 2 (direct) + this.isInvertedInNetwork = tieLine.getDanglingLine1() == danglingLine ? !isInvertedInNetwork : isInvertedInNetwork; + interpretTieLine(tieLine, side); + } else { + checkDanglingLineNominalVoltage(danglingLine); + checkDanglingLineCurrentLimits(danglingLine); + } } } + private void interpretTieLine(TieLine tieLine, Branch.Side side) { + this.isHalfLine = true; + this.halfLineSide = side; + checkBranchNominalVoltage(tieLine); + checkTieLineCurrentLimits(tieLine); + } + private void checkTieLineCurrentLimits(TieLine tieLine) { if (tieLine.getCurrentLimits(Branch.Side.ONE).isPresent()) { this.currentLimitLeft = tieLine.getCurrentLimits(Branch.Side.ONE).orElseThrow().getPermanentLimit(); diff --git a/data/crac-creation/crac-creator-cim/src/main/java/com/farao_community/farao/data/crac_creation/creator/cim/crac_creator/contingency/CimContingencyCreator.java b/data/crac-creation/crac-creator-cim/src/main/java/com/farao_community/farao/data/crac_creation/creator/cim/crac_creator/contingency/CimContingencyCreator.java index fbdd1415f8..0a43925fb6 100644 --- a/data/crac-creation/crac-creator-cim/src/main/java/com/farao_community/farao/data/crac_creation/creator/cim/crac_creator/contingency/CimContingencyCreator.java +++ b/data/crac-creation/crac-creator-cim/src/main/java/com/farao_community/farao/data/crac_creation/creator/cim/crac_creator/contingency/CimContingencyCreator.java @@ -13,6 +13,7 @@ import com.farao_community.farao.data.crac_creation.creator.cim.crac_creator.CimCracCreationContext; import com.farao_community.farao.data.crac_creation.creator.cim.xsd.*; import com.farao_community.farao.data.crac_creation.util.cgmes.CgmesBranchHelper; +import com.powsybl.iidm.network.DanglingLine; import com.powsybl.iidm.network.Identifiable; import com.powsybl.iidm.network.Network; @@ -105,10 +106,19 @@ private String getNetworkElementIdInNetwork(String networkElementIdInCrac) { CgmesBranchHelper cgmesBranchHelper = new CgmesBranchHelper(networkElementIdInCrac, network); if (cgmesBranchHelper.isValid()) { networkElementId = cgmesBranchHelper.getIdInNetwork(); + networkElement = cgmesBranchHelper.getBranch(); } } else { networkElementId = networkElement.getId(); } + + if (networkElement instanceof DanglingLine) { + DanglingLine danglingLine = (DanglingLine) networkElement; + if (danglingLine.getTieLine().isPresent()) { + networkElementId = danglingLine.getTieLine().get().getId(); + } + } + return networkElementId; } diff --git a/monitoring/voltage-monitoring/src/test/java/com/farao_community/farao/monitoring/voltage_monitoring/VoltageMonitoringTest.java b/monitoring/voltage-monitoring/src/test/java/com/farao_community/farao/monitoring/voltage_monitoring/VoltageMonitoringTest.java index 6ba66c7ea2..3a2a9a040f 100644 --- a/monitoring/voltage-monitoring/src/test/java/com/farao_community/farao/monitoring/voltage_monitoring/VoltageMonitoringTest.java +++ b/monitoring/voltage-monitoring/src/test/java/com/farao_community/farao/monitoring/voltage_monitoring/VoltageMonitoringTest.java @@ -272,11 +272,11 @@ void testCurativeStatesConstraints() { assertEquals(400., voltageMonitoringResult.getMaxVoltage(vc2), VOLTAGE_TOLERANCE); assertTrue(Double.isNaN(voltageMonitoringResult.getMinVoltage(vc1b))); assertTrue(Double.isNaN(voltageMonitoringResult.getMaxVoltage(vc1b))); - assertEquals(399., voltageMonitoringResult.getMinVoltage(vc2b), VOLTAGE_TOLERANCE); - assertEquals(399., voltageMonitoringResult.getMaxVoltage(vc2b), VOLTAGE_TOLERANCE); + assertEquals(400., voltageMonitoringResult.getMinVoltage(vc2b), VOLTAGE_TOLERANCE); + assertEquals(400., voltageMonitoringResult.getMaxVoltage(vc2b), VOLTAGE_TOLERANCE); assertEquals(List.of("Network element VL2 at state coL1 - curative has a voltage of 368 - 368 kV.", "Network element VL3 at state coL2 - curative has a voltage of 400 - 400 kV.", - "Network element VL3 at state coL1L2 - curative has a voltage of 399 - 399 kV."), + "Network element VL3 at state coL1L2 - curative has a voltage of 400 - 400 kV."), voltageMonitoringResult.printConstraints()); } diff --git a/pom.xml b/pom.xml index 3d71542a05..300390a179 100644 --- a/pom.xml +++ b/pom.xml @@ -138,9 +138,9 @@ 1.0.0 3.5.10 2.0.7 - 5.2.0-RC1 + 5.3.0-alpha-2 2.2.0 - 1.0.1 + 1.2.0-SNAPSHOT 1.7.30 1.5.0 2.8.1 diff --git a/ra-optimisation/rao-api/src/test/java/com/farao_community/farao/rao_api/parameters/RaoParametersYamlConfigTest.java b/ra-optimisation/rao-api/src/test/java/com/farao_community/farao/rao_api/parameters/RaoParametersYamlConfigTest.java index 874742b613..2febf0a4d0 100644 --- a/ra-optimisation/rao-api/src/test/java/com/farao_community/farao/rao_api/parameters/RaoParametersYamlConfigTest.java +++ b/ra-optimisation/rao-api/src/test/java/com/farao_community/farao/rao_api/parameters/RaoParametersYamlConfigTest.java @@ -302,7 +302,7 @@ void testConfigWithOpenLoadFlowExtension() throws IOException { assertNotNull(olfParams); assertEquals(0.444, olfParams.getMinPlausibleTargetVoltage(), DOUBLE_TOLERANCE); assertEquals(1.444, olfParams.getMaxPlausibleTargetVoltage(), DOUBLE_TOLERANCE); - assertEquals(111, olfParams.getMaxIteration(), DOUBLE_TOLERANCE); + assertEquals(111, olfParams.getMaxNewtonRaphsonIterations(), DOUBLE_TOLERANCE); // Compare to json roundTripTest(parameters, JsonRaoParameters::write, JsonRaoParameters::read, "/RaoParameters_config_withOLFParams.json"); diff --git a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withExtensions.json b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withExtensions.json index 22fd8c0450..ccbefee015 100644 --- a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withExtensions.json +++ b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withExtensions.json @@ -90,18 +90,25 @@ "lowImpedanceBranchMode" : "REPLACE_BY_ZERO_IMPEDANCE_LINE", "loadPowerFactorConstant" : false, "plausibleActivePowerLimit" : 5000.0, + "newtonRaphsonStoppingCriteriaType" : "UNIFORM_CRITERIA", + "maxActivePowerMismatch" : 0.01, + "maxReactivePowerMismatch" : 0.01, + "maxVoltageMismatch" : 1.0E-4, + "maxAngleMismatch" : 1.0E-5, + "maxRatioMismatch" : 1.0E-5, + "maxSusceptanceMismatch" : 1.0E-4, "slackBusPMaxMismatch" : 1.0, "voltagePerReactivePowerControl" : false, - "maxIteration" : 30, + "maxNewtonRaphsonIterations" : 15, + "maxOuterLoopIterations" : 20, "newtonRaphsonConvEpsPerEq" : 1.0E-4, "voltageInitModeOverride" : "NONE", "transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", "shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", - "dcPowerFactor" : 1.0, "minPlausibleTargetVoltage" : 0.8, "maxPlausibleTargetVoltage" : 1.2, "minRealisticVoltage" : 0.5, - "maxRealisticVoltage" : 1.5, + "maxRealisticVoltage" : 2.0, "lowImpedanceThreshold" : 1.0E-8, "reactiveRangeCheckMode" : "MAX", "networkCacheEnabled" : false, @@ -111,7 +118,14 @@ "debugDir" : null, "incrementalTransformerVoltageControlOuterLoopMaxTapShift" : 3, "secondaryVoltageControl" : false, - "reactiveLimitsMaxPqPvSwitch" : 3 + "reactiveLimitsMaxPqPvSwitch" : 3, + "phaseShifterControlMode" : "CONTINUOUS_WITH_DISCRETISATION", + "alwaysUpdateNetwork" : false, + "mostMeshedSlackBusSelectorMaxNominalVoltagePercentile" : 95.0, + "reportedFeatures" : [ ], + "slackBusCountryFilter" : [ ], + "actionableSwitchesIds" : [ ], + "asymmetrical" : false } } }, diff --git a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withOLFParams.json b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withOLFParams.json index ffbf528926..80be12130b 100644 --- a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withOLFParams.json +++ b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withOLFParams.json @@ -78,18 +78,25 @@ "lowImpedanceBranchMode" : "REPLACE_BY_ZERO_IMPEDANCE_LINE", "loadPowerFactorConstant" : false, "plausibleActivePowerLimit" : 5000.0, + "newtonRaphsonStoppingCriteriaType" : "UNIFORM_CRITERIA", + "maxActivePowerMismatch" : 0.01, + "maxReactivePowerMismatch" : 0.01, + "maxVoltageMismatch" : 1.0E-4, + "maxAngleMismatch" : 1.0E-5, + "maxRatioMismatch" : 1.0E-5, + "maxSusceptanceMismatch" : 1.0E-4, "slackBusPMaxMismatch" : 1.0, "voltagePerReactivePowerControl" : false, - "maxIteration" : 111, + "maxNewtonRaphsonIterations" : 111, + "maxOuterLoopIterations" : 20, "newtonRaphsonConvEpsPerEq" : 1.0E-4, "voltageInitModeOverride" : "NONE", "transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", "shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", - "dcPowerFactor" : 1.0, "minPlausibleTargetVoltage" : 0.444, "maxPlausibleTargetVoltage" : 1.444, "minRealisticVoltage" : 0.5, - "maxRealisticVoltage" : 1.5, + "maxRealisticVoltage" : 2.0, "lowImpedanceThreshold" : 1.0E-8, "reactiveRangeCheckMode" : "MAX", "networkCacheEnabled" : false, @@ -99,7 +106,14 @@ "debugDir" : null, "incrementalTransformerVoltageControlOuterLoopMaxTapShift" : 3, "secondaryVoltageControl" : false, - "reactiveLimitsMaxPqPvSwitch" : 3 + "reactiveLimitsMaxPqPvSwitch" : 3, + "phaseShifterControlMode" : "CONTINUOUS_WITH_DISCRETISATION", + "alwaysUpdateNetwork" : false, + "mostMeshedSlackBusSelectorMaxNominalVoltagePercentile" : 95.0, + "reportedFeatures" : [ ], + "slackBusCountryFilter" : [ ], + "actionableSwitchesIds" : [ ], + "asymmetrical" : false } } }, diff --git a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withPartialExtensions.json b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withPartialExtensions.json index ab884b5d60..36387d4838 100644 --- a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withPartialExtensions.json +++ b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withPartialExtensions.json @@ -90,18 +90,25 @@ "lowImpedanceBranchMode" : "REPLACE_BY_ZERO_IMPEDANCE_LINE", "loadPowerFactorConstant" : false, "plausibleActivePowerLimit" : 5000.0, + "newtonRaphsonStoppingCriteriaType" : "UNIFORM_CRITERIA", + "maxActivePowerMismatch" : 0.01, + "maxReactivePowerMismatch" : 0.01, + "maxVoltageMismatch" : 1.0E-4, + "maxAngleMismatch" : 1.0E-5, + "maxRatioMismatch" : 1.0E-5, + "maxSusceptanceMismatch" : 1.0E-4, "slackBusPMaxMismatch" : 1.0, "voltagePerReactivePowerControl" : false, - "maxIteration" : 30, + "maxNewtonRaphsonIterations" : 15, + "maxOuterLoopIterations" : 20, "newtonRaphsonConvEpsPerEq" : 1.0E-4, "voltageInitModeOverride" : "NONE", "transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", "shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", - "dcPowerFactor" : 1.0, "minPlausibleTargetVoltage" : 0.8, "maxPlausibleTargetVoltage" : 1.2, "minRealisticVoltage" : 0.5, - "maxRealisticVoltage" : 1.5, + "maxRealisticVoltage" : 2.0, "lowImpedanceThreshold" : 1.0E-8, "reactiveRangeCheckMode" : "MAX", "networkCacheEnabled" : false, @@ -111,7 +118,14 @@ "debugDir" : null, "incrementalTransformerVoltageControlOuterLoopMaxTapShift" : 3, "secondaryVoltageControl" : false, - "reactiveLimitsMaxPqPvSwitch" : 3 + "reactiveLimitsMaxPqPvSwitch" : 3, + "phaseShifterControlMode" : "CONTINUOUS_WITH_DISCRETISATION", + "alwaysUpdateNetwork" : false, + "mostMeshedSlackBusSelectorMaxNominalVoltagePercentile" : 95.0, + "reportedFeatures" : [ ], + "slackBusCountryFilter" : [ ], + "actionableSwitchesIds" : [ ], + "asymmetrical" : false } } }, diff --git a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withoutExtensions.json b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withoutExtensions.json index b6c3df2ed1..9c8508a56f 100644 --- a/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withoutExtensions.json +++ b/ra-optimisation/rao-api/src/test/resources/RaoParameters_config_withoutExtensions.json @@ -90,18 +90,25 @@ "lowImpedanceBranchMode" : "REPLACE_BY_ZERO_IMPEDANCE_LINE", "loadPowerFactorConstant" : false, "plausibleActivePowerLimit" : 5000.0, + "newtonRaphsonStoppingCriteriaType" : "UNIFORM_CRITERIA", + "maxActivePowerMismatch" : 0.01, + "maxReactivePowerMismatch" : 0.01, + "maxVoltageMismatch" : 1.0E-4, + "maxAngleMismatch" : 1.0E-5, + "maxRatioMismatch" : 1.0E-5, + "maxSusceptanceMismatch" : 1.0E-4, "slackBusPMaxMismatch" : 1.0, "voltagePerReactivePowerControl" : false, - "maxIteration" : 30, + "maxNewtonRaphsonIterations" : 15, + "maxOuterLoopIterations" : 20, "newtonRaphsonConvEpsPerEq" : 1.0E-4, "voltageInitModeOverride" : "NONE", "transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", "shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", - "dcPowerFactor" : 1.0, "minPlausibleTargetVoltage" : 0.8, "maxPlausibleTargetVoltage" : 1.2, "minRealisticVoltage" : 0.5, - "maxRealisticVoltage" : 1.5, + "maxRealisticVoltage" : 2.0, "lowImpedanceThreshold" : 1.0E-8, "reactiveRangeCheckMode" : "MAX", "networkCacheEnabled" : false, @@ -111,7 +118,14 @@ "debugDir" : null, "incrementalTransformerVoltageControlOuterLoopMaxTapShift" : 3, "secondaryVoltageControl" : false, - "reactiveLimitsMaxPqPvSwitch" : 3 + "reactiveLimitsMaxPqPvSwitch" : 3, + "phaseShifterControlMode" : "CONTINUOUS_WITH_DISCRETISATION", + "alwaysUpdateNetwork" : false, + "mostMeshedSlackBusSelectorMaxNominalVoltagePercentile" : 95.0, + "reportedFeatures" : [ ], + "slackBusCountryFilter" : [ ], + "actionableSwitchesIds" : [ ], + "asymmetrical" : false } } }, diff --git a/ra-optimisation/rao-api/src/test/resources/config_withOpenLoadFlowExtension.yml b/ra-optimisation/rao-api/src/test/resources/config_withOpenLoadFlowExtension.yml index b5aad972d0..6f33c0df49 100644 --- a/ra-optimisation/rao-api/src/test/resources/config_withOpenLoadFlowExtension.yml +++ b/ra-optimisation/rao-api/src/test/resources/config_withOpenLoadFlowExtension.yml @@ -12,4 +12,4 @@ load-flow-default-parameters: open-loadflow-default-parameters: minPlausibleTargetVoltage: 0.444 maxPlausibleTargetVoltage: 1.444 - maxIteration: 111 \ No newline at end of file + maxNewtonRaphsonIterations: 111 \ No newline at end of file diff --git a/ra-optimisation/search-tree-rao/src/test/resources/parameters/RaoParameters_2P_v2.json b/ra-optimisation/search-tree-rao/src/test/resources/parameters/RaoParameters_2P_v2.json index edf6e6b9e1..b60d900b7c 100644 --- a/ra-optimisation/search-tree-rao/src/test/resources/parameters/RaoParameters_2P_v2.json +++ b/ra-optimisation/search-tree-rao/src/test/resources/parameters/RaoParameters_2P_v2.json @@ -58,7 +58,7 @@ "sensitivity-parameters" : { "version" : "1.0", "load-flow-parameters" : { - "version" : "1.8", + "version" : "1.9", "voltageInitMode" : "UNIFORM_VALUES", "transformerVoltageControlOn" : false, "phaseShifterRegulationOn" : false, @@ -74,6 +74,7 @@ "countriesToBalance" : [ "PL", "NL", "IT", "ES", "BA", "MK", "AT", "ME", "FR", "UA", "AL", "TR", "SK", "CH", "GR", "PT", "BE", "CZ", "HR", "SI", "RO", "RS", "DE", "BG", "HU" ], "connectedComponentMode" : "MAIN", "hvdcAcEmulation" : true, + "dcPowerFactor" : 1.0, "extensions" : { "open-load-flow-parameters" : { "slackBusSelectionMode" : "MOST_MESHED", @@ -84,12 +85,11 @@ "plausibleActivePowerLimit" : 10000.0, "slackBusPMaxMismatch" : 1.0, "voltagePerReactivePowerControl" : false, - "maxIteration" : 30, + "maxNewtonRaphsonIterations" : 30, "newtonRaphsonConvEpsPerEq" : 1.0E-4, "voltageInitModeOverride" : "NONE", "transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", "shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", - "dcPowerFactor" : 1.0, "minPlausibleTargetVoltage" : 0.8, "maxPlausibleTargetVoltage" : 1.2, "minRealisticVoltage" : 0.5, diff --git a/ra-optimisation/search-tree-rao/src/test/resources/parameters/RaoParameters_oneIteration_v2.json b/ra-optimisation/search-tree-rao/src/test/resources/parameters/RaoParameters_oneIteration_v2.json index 381086e27a..8e4583352f 100644 --- a/ra-optimisation/search-tree-rao/src/test/resources/parameters/RaoParameters_oneIteration_v2.json +++ b/ra-optimisation/search-tree-rao/src/test/resources/parameters/RaoParameters_oneIteration_v2.json @@ -58,7 +58,7 @@ "sensitivity-parameters" : { "version" : "1.0", "load-flow-parameters" : { - "version" : "1.8", + "version" : "1.9", "voltageInitMode" : "UNIFORM_VALUES", "transformerVoltageControlOn" : false, "phaseShifterRegulationOn" : false, @@ -74,6 +74,7 @@ "countriesToBalance" : [ "PL", "NL", "IT", "ES", "BA", "MK", "AT", "ME", "FR", "UA", "AL", "TR", "SK", "CH", "GR", "PT", "BE", "CZ", "HR", "SI", "RO", "RS", "DE", "BG", "HU" ], "connectedComponentMode" : "MAIN", "hvdcAcEmulation" : true, + "dcPowerFactor" : 1.0, "extensions" : { "open-load-flow-parameters" : { "slackBusSelectionMode" : "MOST_MESHED", @@ -84,12 +85,11 @@ "plausibleActivePowerLimit" : 10000.0, "slackBusPMaxMismatch" : 1.0, "voltagePerReactivePowerControl" : false, - "maxIteration" : 1, + "maxNewtonRaphsonIterations" : 1, "newtonRaphsonConvEpsPerEq" : 1.0E-4, "voltageInitModeOverride" : "NONE", "transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", "shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL", - "dcPowerFactor" : 1.0, "minPlausibleTargetVoltage" : 0.8, "maxPlausibleTargetVoltage" : 1.2, "minRealisticVoltage" : 0.5, From 5360674b0438c8b42d1e63770ea6163b606a30df Mon Sep 17 00:00:00 2001 From: Philippe Edwards Date: Wed, 7 Jun 2023 15:14:16 +0200 Subject: [PATCH 2/4] update to release versions --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 300390a179..653b20b41f 100644 --- a/pom.xml +++ b/pom.xml @@ -138,9 +138,9 @@ 1.0.0 3.5.10 2.0.7 - 5.3.0-alpha-2 + 5.3.0 2.2.0 - 1.2.0-SNAPSHOT + 1.2.0 1.7.30 1.5.0 2.8.1 From 96caf7f14c4827dc8df9afaa6589a495c5e89c19 Mon Sep 17 00:00:00 2001 From: Philippe Edwards Date: Thu, 8 Jun 2023 16:03:12 +0200 Subject: [PATCH 3/4] fix code smells and update powsybl entsoe version --- .../util/ucte/UcteConnectableCollection.java | 39 ++++++++++--------- .../util/ucte/UcteFlowElementHelper.java | 29 ++++++++------ .../contingency/CimContingencyCreator.java | 8 ++-- pom.xml | 2 +- 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java index 03fc03d77a..2b22e264f2 100644 --- a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java +++ b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java @@ -115,29 +115,16 @@ private UcteMatchingResult lookForMatchWithinCollection(String fromNodeId, Strin if (fromNodeId.endsWith(UcteUtils.WILDCARD_CHARACTER) || toNodeId.endsWith(UcteUtils.WILDCARD_CHARACTER)) { // if the nodes contains wildCards, we have to look for all possible match - List matchedConnetables = ucteConnectables.stream() + List matchedConnectables = ucteConnectables.stream() .filter(ucteConnectable -> ucteConnectable.doesMatch(fromNodeId, toNodeId, suffix, connectableTypes)) .map(ucteConnectable -> ucteConnectable.getUcteMatchingResult(fromNodeId, toNodeId, suffix, connectableTypes)) .collect(Collectors.toList()); - if (matchedConnetables.size() == 1) { - return matchedConnetables.get(0); - } else if (matchedConnetables.size() == 2) { - Identifiable identifiable1 = matchedConnetables.get(0).getIidmIdentifiable(); - Identifiable identifiable2 = matchedConnetables.get(1).getIidmIdentifiable(); - - if (identifiable1 instanceof DanglingLine && identifiable2 instanceof TieLine) { - if (tieLineContainsDanglingLine((TieLine) identifiable2, (DanglingLine) identifiable1)) { - return matchedConnetables.get(1); - } - } else if (identifiable2 instanceof DanglingLine && identifiable1 instanceof TieLine) { - if (tieLineContainsDanglingLine((TieLine) identifiable1, (DanglingLine) identifiable2)) { - return matchedConnetables.get(0); - } - } - return UcteMatchingResult.severalPossibleMatch(); - - } else if (matchedConnetables.size() > 2) { + if (matchedConnectables.size() == 1) { + return matchedConnectables.get(0); + } else if (matchedConnectables.size() == 2) { + return checkIfTieLineOrSeveralMatch(matchedConnectables); + } else if (matchedConnectables.size() > 2) { return UcteMatchingResult.severalPossibleMatch(); } else { return UcteMatchingResult.notFound(); @@ -152,6 +139,20 @@ private UcteMatchingResult lookForMatchWithinCollection(String fromNodeId, Strin } } + private UcteMatchingResult checkIfTieLineOrSeveralMatch(List matchedConnectables) { + Identifiable identifiable1 = matchedConnectables.get(0).getIidmIdentifiable(); + Identifiable identifiable2 = matchedConnectables.get(1).getIidmIdentifiable(); + + if (identifiable1 instanceof DanglingLine && identifiable2 instanceof TieLine && + tieLineContainsDanglingLine((TieLine) identifiable2, (DanglingLine) identifiable1)) { + return matchedConnectables.get(1); + } else if (identifiable2 instanceof DanglingLine && identifiable1 instanceof TieLine && + tieLineContainsDanglingLine((TieLine) identifiable1, (DanglingLine) identifiable2)) { + return matchedConnectables.get(0); + } + return UcteMatchingResult.severalPossibleMatch(); + } + private boolean tieLineContainsDanglingLine(TieLine tieLine, DanglingLine danglingLine) { return tieLine.getDanglingLine1().equals(danglingLine) || tieLine.getDanglingLine2().equals(danglingLine); } diff --git a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteFlowElementHelper.java b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteFlowElementHelper.java index 0a93c83522..b609d3a88f 100644 --- a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteFlowElementHelper.java +++ b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteFlowElementHelper.java @@ -14,6 +14,7 @@ import com.powsybl.iidm.network.TieLine; import java.util.Objects; +import java.util.Optional; import static com.farao_community.farao.data.crac_creation.util.ucte.UcteConnectable.Side.TWO; import static java.lang.String.format; @@ -145,18 +146,7 @@ protected void interpretWithNetworkAnalyzer(UcteNetworkAnalyzer networkAnalyzer) checkBranchNominalVoltage((Branch) networkElement); checkBranchCurrentLimits((Branch) networkElement); } else if (networkElement instanceof DanglingLine) { - DanglingLine danglingLine = (DanglingLine) networkElement; - if (danglingLine.getTieLine().isPresent()) { - TieLine tieLine = danglingLine.getTieLine().get(); - this.connectableIdInNetwork = tieLine.getId(); - Branch.Side side = tieLine.getDanglingLine1() == danglingLine ? Branch.Side.ONE : Branch.Side.TWO; - // dangling line convention is x node to terminal, so dl 1 is towards terminal 1 (opposite) and dl 2 is towards terminal 2 (direct) - this.isInvertedInNetwork = tieLine.getDanglingLine1() == danglingLine ? !isInvertedInNetwork : isInvertedInNetwork; - interpretTieLine(tieLine, side); - } else { - checkDanglingLineNominalVoltage(danglingLine); - checkDanglingLineCurrentLimits(danglingLine); - } + interpretDanglingLine((DanglingLine) networkElement); } } @@ -184,6 +174,21 @@ protected void checkBranchNominalVoltage(Branch branch) { this.nominalVoltageRight = branch.getTerminal2().getVoltageLevel().getNominalV(); } + private void interpretDanglingLine(DanglingLine danglingLine) { + Optional optionalTieLine = danglingLine.getTieLine(); + if (optionalTieLine.isPresent()) { + TieLine tieLine = optionalTieLine.get(); + this.connectableIdInNetwork = tieLine.getId(); + Branch.Side side = tieLine.getDanglingLine1() == danglingLine ? Branch.Side.ONE : Branch.Side.TWO; + // dangling line convention is x node to terminal, so dl 1 is towards terminal 1 (opposite) and dl 2 is towards terminal 2 (direct) + this.isInvertedInNetwork = tieLine.getDanglingLine1() == danglingLine ? !isInvertedInNetwork : isInvertedInNetwork; + interpretTieLine(tieLine, side); + } else { + checkDanglingLineNominalVoltage(danglingLine); + checkDanglingLineCurrentLimits(danglingLine); + } + } + protected void checkDanglingLineNominalVoltage(DanglingLine danglingLine) { this.nominalVoltageLeft = danglingLine.getTerminal().getVoltageLevel().getNominalV(); this.nominalVoltageRight = nominalVoltageLeft; diff --git a/data/crac-creation/crac-creator-cim/src/main/java/com/farao_community/farao/data/crac_creation/creator/cim/crac_creator/contingency/CimContingencyCreator.java b/data/crac-creation/crac-creator-cim/src/main/java/com/farao_community/farao/data/crac_creation/creator/cim/crac_creator/contingency/CimContingencyCreator.java index 0a43925fb6..cdbf588f73 100644 --- a/data/crac-creation/crac-creator-cim/src/main/java/com/farao_community/farao/data/crac_creation/creator/cim/crac_creator/contingency/CimContingencyCreator.java +++ b/data/crac-creation/crac-creator-cim/src/main/java/com/farao_community/farao/data/crac_creation/creator/cim/crac_creator/contingency/CimContingencyCreator.java @@ -16,11 +16,13 @@ import com.powsybl.iidm.network.DanglingLine; import com.powsybl.iidm.network.Identifiable; import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.TieLine; import static com.farao_community.farao.data.crac_creation.creator.cim.crac_creator.CimConstants.CONTINGENCY_SERIES_BUSINESS_TYPE; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -113,9 +115,9 @@ private String getNetworkElementIdInNetwork(String networkElementIdInCrac) { } if (networkElement instanceof DanglingLine) { - DanglingLine danglingLine = (DanglingLine) networkElement; - if (danglingLine.getTieLine().isPresent()) { - networkElementId = danglingLine.getTieLine().get().getId(); + Optional optionalTieLine = ((DanglingLine) networkElement).getTieLine(); + if (optionalTieLine.isPresent()) { + networkElementId = optionalTieLine.get().getId(); } } diff --git a/pom.xml b/pom.xml index 653b20b41f..0ac2f173d6 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,7 @@ 3.5.10 2.0.7 5.3.0 - 2.2.0 + 2.4.0 1.2.0 1.7.30 1.5.0 From bfd5d1e780620e6fa4c7a54a45365f9b20277325 Mon Sep 17 00:00:00 2001 From: Philippe Edwards Date: Thu, 8 Jun 2023 16:24:36 +0200 Subject: [PATCH 4/4] removed unnecessary check --- .../util/ucte/UcteConnectableCollection.java | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java index 2b22e264f2..b3faed269a 100644 --- a/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java +++ b/data/crac-creation/crac-creation-util/src/main/java/com/farao_community/farao/data/crac_creation/util/ucte/UcteConnectableCollection.java @@ -123,7 +123,7 @@ private UcteMatchingResult lookForMatchWithinCollection(String fromNodeId, Strin if (matchedConnectables.size() == 1) { return matchedConnectables.get(0); } else if (matchedConnectables.size() == 2) { - return checkIfTieLineOrSeveralMatch(matchedConnectables); + return UcteMatchingResult.severalPossibleMatch(); } else if (matchedConnectables.size() > 2) { return UcteMatchingResult.severalPossibleMatch(); } else { @@ -139,24 +139,6 @@ private UcteMatchingResult lookForMatchWithinCollection(String fromNodeId, Strin } } - private UcteMatchingResult checkIfTieLineOrSeveralMatch(List matchedConnectables) { - Identifiable identifiable1 = matchedConnectables.get(0).getIidmIdentifiable(); - Identifiable identifiable2 = matchedConnectables.get(1).getIidmIdentifiable(); - - if (identifiable1 instanceof DanglingLine && identifiable2 instanceof TieLine && - tieLineContainsDanglingLine((TieLine) identifiable2, (DanglingLine) identifiable1)) { - return matchedConnectables.get(1); - } else if (identifiable2 instanceof DanglingLine && identifiable1 instanceof TieLine && - tieLineContainsDanglingLine((TieLine) identifiable1, (DanglingLine) identifiable2)) { - return matchedConnectables.get(0); - } - return UcteMatchingResult.severalPossibleMatch(); - } - - private boolean tieLineContainsDanglingLine(TieLine tieLine, DanglingLine danglingLine) { - return tieLine.getDanglingLine1().equals(danglingLine) || tieLine.getDanglingLine2().equals(danglingLine); - } - private void addBranches(Network network) { network.getBranchStream().forEach(branch -> { String from = getNodeName(branch.getTerminal1().getBusBreakerView().getConnectableBus().getId());