From 8e3e5aac71ed57435fea44018a054f3dedceaef7 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Sun, 13 Aug 2023 23:33:58 +0200 Subject: [PATCH 1/5] Fix small reference flow values instead of strict zero Signed-off-by: Geoffroy Jamgotchian --- ...cSensitivityAnalysisContingenciesTest.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java b/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java index b6aad1bf42..22c1fdd007 100644 --- a/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java +++ b/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java @@ -14,6 +14,7 @@ import com.powsybl.ieeecdf.converter.IeeeCdfNetworkFactory; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.HvdcAngleDroopActivePowerControlAdder; +import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import com.powsybl.iidm.network.test.PhaseShifterTestCaseFactory; import com.powsybl.loadflow.LoadFlowParameters; import com.powsybl.openloadflow.OpenLoadFlowParameters; @@ -2262,4 +2263,63 @@ void testPredefinedResults3() { assertEquals(0, result.getBranchFlow1SensitivityValue("l23", "l23", "l12", SensitivityVariableType.TRANSFORMER_PHASE), LoadFlowAssert.DELTA_POWER); assertEquals(Double.NaN, result.getBranchFlow1SensitivityValue("l23", "l23", "l23", SensitivityVariableType.TRANSFORMER_PHASE), LoadFlowAssert.DELTA_POWER); } + + @Test + void testOneOfTwoSerialLinesContingency() { + Network network = EurostagTutorialExample1Factory.create(); + network.getLine("NHV1_NHV2_1").remove(); + Substation p3 = network.newSubstation() + .setId("P3") + .setCountry(Country.FR) + .add(); + VoltageLevel vlhv3 = p3.newVoltageLevel() + .setId("VLHV3") + .setNominalV(380) + .setTopologyKind(TopologyKind.BUS_BREAKER) + .add(); + vlhv3.getBusBreakerView().newBus() + .setId("NHV3") + .add(); + network.newLine() + .setId("NHV1_NHV2_1_1") + .setVoltageLevel1("VLHV1") + .setBus1("NHV1") + .setVoltageLevel2("VLHV3") + .setBus2("NHV3") + .setR(3.0 / 2) + .setX(33.0 / 2) + .setB1(386E-6 / 4) + .setB2(386E-6 / 3) + .add(); + network.newLine() + .setId("NHV1_NHV2_1_2") + .setVoltageLevel1("VLHV3") + .setBus1("NHV3") + .setVoltageLevel2("VLHV2") + .setBus2("NHV2") + .setR(3.0 / 2) + .setX(33.0 / 2) + .setB1(386E-6 / 4) + .setB2(386E-6 / 3) + .add(); + + SensitivityAnalysisParameters sensiParameters = createParameters(true, "VLLOAD_0"); + + List factors = List.of(new SensitivityFactor( + SensitivityFunctionType.BRANCH_ACTIVE_POWER_1, + "NHV1_NHV2_1_2", + SensitivityVariableType.INJECTION_ACTIVE_POWER, + "GEN", + false, + ContingencyContext.all()) + ); + + List contingencies = List.of(Contingency.line("NHV1_NHV2_1_1")); + + SensitivityAnalysisResult result = sensiRunner.run(network, factors, contingencies, Collections.emptyList(), sensiParameters); + + assertEquals(303.5d, result.getBranchFlow1FunctionReferenceValue("NHV1_NHV2_1_2"), LoadFlowAssert.DELTA_POWER); + // FIXME strict zero would be expected + assertEquals(1.7763568394002505E-13, result.getBranchFlow1FunctionReferenceValue("NHV1_NHV2_1_1", "NHV1_NHV2_1_2"), 0d); + } } From 54266f9981b1a33fca916bd18625bda17e887031 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Sun, 13 Aug 2023 23:44:24 +0200 Subject: [PATCH 2/5] Add doc Signed-off-by: Geoffroy Jamgotchian --- .../sensi/DcSensitivityAnalysisContingenciesTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java b/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java index 22c1fdd007..6123956560 100644 --- a/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java +++ b/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java @@ -2264,6 +2264,15 @@ void testPredefinedResults3() { assertEquals(Double.NaN, result.getBranchFlow1SensitivityValue("l23", "l23", "l23", SensitivityVariableType.TRANSFORMER_PHASE), LoadFlowAssert.DELTA_POWER); } + /** + * NHV1_NHV1 + * -------------------------- + * / \ + * NGEN --- NHV1 NHV2 --- NLOAD + * \ / + * ----------- NHV3 ----------- + * NHV1_NHV2_1 NHV1_NHV2_2 + */ @Test void testOneOfTwoSerialLinesContingency() { Network network = EurostagTutorialExample1Factory.create(); From 7a6ef0b730e607c52ac13dfe2ae497cd73422d97 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Mon, 14 Aug 2023 12:13:33 +0200 Subject: [PATCH 3/5] Fix Signed-off-by: Geoffroy Jamgotchian --- .../openloadflow/sensi/DcSensitivityAnalysis.java | 15 +++++++++++++++ .../DcSensitivityAnalysisContingenciesTest.java | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java b/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java index 2d29ffec9e..261db9beba 100644 --- a/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java +++ b/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java @@ -57,6 +57,7 @@ public class DcSensitivityAnalysis extends AbstractSensitivityAnalysis { private static final double CONNECTIVITY_LOSS_THRESHOLD = 10e-7; + private static final double REFERENCE_FLOW_ZER0_THRESHOLD = 1e-13; private static final class ComputedContingencyElement { @@ -288,12 +289,26 @@ private void createBranchSensitivityValue(LfSensitivityFactor Date: Thu, 31 Aug 2023 16:28:40 +0200 Subject: [PATCH 4/5] Small clean. Signed-off-by: Anne Tilloy --- .../openloadflow/sensi/DcSensitivityAnalysis.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java b/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java index ca7003dcf0..0f0201dedb 100644 --- a/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java +++ b/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java @@ -55,7 +55,7 @@ public class DcSensitivityAnalysis extends AbstractSensitivityAnalysis { private static final double CONNECTIVITY_LOSS_THRESHOLD = 10e-7; - private static final double REFERENCE_FLOW_ZER0_THRESHOLD = 1e-13; + private static final double REFERENCE_FUNCTION_ZER0_THRESHOLD = 1e-13; static final class ComputedContingencyElement { @@ -333,7 +333,7 @@ private void createBranchSensitivityValue(LfSensitivityFactor Date: Thu, 31 Aug 2023 16:34:08 +0200 Subject: [PATCH 5/5] Fix the clean :-) Signed-off-by: Anne Tilloy --- .../powsybl/openloadflow/sensi/DcSensitivityAnalysis.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java b/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java index 0f0201dedb..de18401c6b 100644 --- a/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java +++ b/src/main/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysis.java @@ -55,7 +55,7 @@ public class DcSensitivityAnalysis extends AbstractSensitivityAnalysis { private static final double CONNECTIVITY_LOSS_THRESHOLD = 10e-7; - private static final double REFERENCE_FUNCTION_ZER0_THRESHOLD = 1e-13; + private static final double FUNCTION_REFERENCE_ZER0_THRESHOLD = 1e-13; static final class ComputedContingencyElement { @@ -333,7 +333,7 @@ private void createBranchSensitivityValue(LfSensitivityFactor