Skip to content

Commit

Permalink
Filter out counter-trading RAs from sensitivity computations (#976)
Browse files Browse the repository at this point in the history
Signed-off-by: belthlemar <[email protected]>
  • Loading branch information
phiedw authored and MartinBelthle committed May 28, 2024
1 parent 2febebe commit 052df59
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
5 changes: 5 additions & 0 deletions sensitivity-analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <philippe.edwards at rte-france.com>}
*/
Expand Down Expand Up @@ -89,6 +88,8 @@ private void fillSensitivityVariablesAndGlskIds(Network network, Map<String, Sen
sensitivityVariables.put(hvdcRangeAction.getNetworkElement().getId(), SensitivityVariableType.HVDC_LINE_ACTIVE_POWER);
} else if (ra instanceof InjectionRangeAction injectionRangeAction) {
createPositiveAndNegativeGlsks(injectionRangeAction, sensitivityVariables, glskIds);
} else if (ra instanceof CounterTradeRangeAction counterTradeRangeAction) {
TECHNICAL_LOGS.warn("Unable to compute sensitivity for CounterTradeRangeAction. ({})", counterTradeRangeAction.getId());
} else {
throw new OpenRaoException(String.format("Range action type of %s not implemented yet", ra.getId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.powsybl.openrao.data.cracapi.*;
import com.powsybl.openrao.data.cracapi.cnec.FlowCnec;
import com.powsybl.openrao.data.cracapi.cnec.Side;
import com.powsybl.openrao.data.cracapi.rangeaction.CounterTradeRangeAction;
import com.powsybl.openrao.data.cracapi.rangeaction.HvdcRangeAction;
import com.powsybl.openrao.data.cracapi.rangeaction.RangeAction;
import com.powsybl.openrao.data.cracimpl.utils.CommonCracCreation;
Expand Down Expand Up @@ -274,4 +275,28 @@ void testUnhandledElement() {
OpenRaoException exception = assertThrows(OpenRaoException.class, () -> 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<SensitivityFactor> 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());
}

}
}

0 comments on commit 052df59

Please sign in to comment.