From 052df5935267d316d6753fbc34894afd05ef0600 Mon Sep 17 00:00:00 2001 From: phiedw Date: Thu, 25 Apr 2024 09:09:54 +0200 Subject: [PATCH] Filter out counter-trading RAs from sensitivity computations (#976) Signed-off-by: belthlemar --- sensitivity-analysis/pom.xml | 5 ++++ .../RangeActionSensitivityProvider.java | 9 ++++--- .../RangeActionSensitivityProviderTest.java | 25 +++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/sensitivity-analysis/pom.xml b/sensitivity-analysis/pom.xml index 8f4ac9726c..c0e5e38139 100644 --- a/sensitivity-analysis/pom.xml +++ b/sensitivity-analysis/pom.xml @@ -85,6 +85,11 @@ junit-jupiter test + + org.junit.platform + junit-platform-launcher + test + org.mockito mockito-inline diff --git a/sensitivity-analysis/src/main/java/com/powsybl/openrao/sensitivityanalysis/RangeActionSensitivityProvider.java b/sensitivity-analysis/src/main/java/com/powsybl/openrao/sensitivityanalysis/RangeActionSensitivityProvider.java index c2d59ea537..4b3ec973e6 100644 --- a/sensitivity-analysis/src/main/java/com/powsybl/openrao/sensitivityanalysis/RangeActionSensitivityProvider.java +++ b/sensitivity-analysis/src/main/java/com/powsybl/openrao/sensitivityanalysis/RangeActionSensitivityProvider.java @@ -9,10 +9,7 @@ import com.powsybl.openrao.commons.OpenRaoException; import com.powsybl.openrao.commons.Unit; import com.powsybl.openrao.data.cracapi.cnec.FlowCnec; -import com.powsybl.openrao.data.cracapi.rangeaction.HvdcRangeAction; -import com.powsybl.openrao.data.cracapi.rangeaction.InjectionRangeAction; -import com.powsybl.openrao.data.cracapi.rangeaction.PstRangeAction; -import com.powsybl.openrao.data.cracapi.rangeaction.RangeAction; +import com.powsybl.openrao.data.cracapi.rangeaction.*; import com.powsybl.openrao.sensitivityanalysis.rasensihandler.InjectionRangeActionSensiHandler; import com.powsybl.contingency.Contingency; import com.powsybl.contingency.ContingencyContext; @@ -24,6 +21,8 @@ import java.util.*; import java.util.stream.Collectors; +import static com.powsybl.openrao.commons.logs.OpenRaoLoggerProvider.TECHNICAL_LOGS; + /** * @author Philippe Edwards {@literal } */ @@ -89,6 +88,8 @@ private void fillSensitivityVariablesAndGlskIds(Network network, Map provider.getBasecaseFactors(network)); assertEquals("Range action type of null not implemented yet", exception.getMessage()); } + + @Test + void testCTDoesNotThrow() { + Crac crac = CommonCracCreation.create(); + FlowCnec flowCnec = crac.newFlowCnec() + .withId("cnec") + .withNetworkElement("BBE1AA11 FFR5AA11 1") + .withInstant(PREVENTIVE_INSTANT_ID) + .newThreshold().withMax(1000.).withUnit(Unit.MEGAWATT).withSide(Side.LEFT).add() + .add(); + + Network network = Network.read("TestCase16NodesWithHvdc.xiidm", getClass().getResourceAsStream("/TestCase16NodesWithHvdc.xiidm")); + + RangeAction ctRa = Mockito.mock(CounterTradeRangeAction.class); + RangeActionSensitivityProvider provider = new RangeActionSensitivityProvider(Set.of(ctRa), Set.of(flowCnec), Set.of(Unit.MEGAWATT, Unit.AMPERE)); + + List factors = provider.getBasecaseFactors(network); + assertEquals(2, factors.size()); + for (SensitivityFactor factor : factors) { + // By default if no RA, then use a transformer for computing at least flows. + assertEquals(SensitivityVariableType.TRANSFORMER_PHASE, factor.getVariableType()); + } + + } }