Skip to content

Commit

Permalink
Modified tests to keep same behaviour with HVDC line resistance in AC…
Browse files Browse the repository at this point in the history
… Emulation
  • Loading branch information
SylvestreSakti committed Jul 10, 2024
1 parent a15c4e7 commit 00ec727
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/test/java/com/powsybl/openloadflow/EquationsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ void hvdcTest() {
Mockito.doReturn(false).when(hvdc).isDisabled();
Mockito.doReturn(DROOP).when(hvdc).getDroop();
Mockito.doReturn(P_0).when(hvdc).getP0();
Mockito.doReturn(0d).when(hvdc).getR();
Mockito.doReturn(Double.MAX_VALUE).when(hvdc).getPMaxFromCS1toCS2();
Mockito.doReturn(Double.MAX_VALUE).when(hvdc).getPMaxFromCS2toCS1();
LfVscConverterStationImpl station1 = Mockito.mock(LfVscConverterStationImpl.class, new RuntimeExceptionAnswer());
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowVscTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,20 @@ void testHvdcPowerAcEmulation() {
LoadFlow.Runner loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider(new DenseMatrixFactory()));
LoadFlowResult result = loadFlowRunner.run(network, new LoadFlowParameters());
assertTrue(result.isFullyConverged());
// AC Emulation takes into account cable loss
assertActivePowerEquals(198.158, network.getHvdcConverterStation("cs2").getTerminal());
assertActivePowerEquals(-193.799, network.getHvdcConverterStation("cs3").getTerminal());
assertActivePowerEquals(-304.359, network.getGenerator("g1").getTerminal());
assertActivePowerEquals(300.0, network.getLoad("l4").getTerminal());
}

@Test
void testHvdcPowerAcEmulationWithoutR() {
Network network = HvdcNetworkFactory.createHvdcLinkedByTwoLinesAndSwitch();
network.getHvdcLine("hvdc23").setR(0d); //Removing resistance to ignore cable loss
LoadFlow.Runner loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider(new DenseMatrixFactory()));
LoadFlowResult result = loadFlowRunner.run(network, new LoadFlowParameters());
assertTrue(result.isFullyConverged());
assertActivePowerEquals(198.158, network.getHvdcConverterStation("cs2").getTerminal());
assertActivePowerEquals(-193.822, network.getHvdcConverterStation("cs3").getTerminal());
assertActivePowerEquals(-304.335, network.getGenerator("g1").getTerminal());
Expand Down Expand Up @@ -450,6 +464,7 @@ void testAcEmuWithOperationalLimits() {
Network network = HvdcNetworkFactory.createHvdcLinkedByTwoLinesAndSwitch(HvdcConverterStation.HvdcType.VSC);
// without limit p=195
network.getHvdcLine("hvdc23")
.setR(0d) //Removing resistance to ignore cable loss
.newExtension(HvdcOperatorActivePowerRangeAdder.class)
.withOprFromCS2toCS1(180)
.withOprFromCS1toCS2(170)
Expand Down Expand Up @@ -482,6 +497,7 @@ void testAcEmuAndPMax() {
Network network = HvdcNetworkFactory.createHvdcLinkedByTwoLinesAndSwitch(HvdcConverterStation.HvdcType.VSC);
// without limit p=195
network.getHvdcLine("hvdc23")
.setR(0d) //Removing resistance to ignore cable loss
.setMaxP(170);

LoadFlow.Runner loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider(new DenseMatrixFactory()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,7 @@ void testVSCLossAcEmulation() {
// but other converter station keeps its voltage control capability.
// remedial action re-enables the ac emulation of the hvdc line.
Network network = HvdcNetworkFactory.createHvdcLinkedByTwoLinesAndSwitch(HvdcConverterStation.HvdcType.VSC);
network.getHvdcLine("hvdc23").setR(0d); //Removing resistance to ignore cable loss
List<Contingency> contingencies = List.of(new Contingency("contingency", new LineContingency("l12")));
List<Action> actions = List.of(new SwitchAction("action", "s2", false));
List<OperatorStrategy> operatorStrategies = List.of(new OperatorStrategy("strategy",
Expand Down Expand Up @@ -1330,6 +1331,7 @@ void testHvdcDisconnectedThenConnectedByStrategy() {
List<StateMonitor> monitors = createNetworkMonitors(network);

// with AC emulation first
network.getHvdcLine("hvdc23").setR(0d); //Removing resistance to ignore cable loss in AC emulation
SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, new SecurityAnalysisParameters(),
operatorStrategies, actions, ReportNode.NO_OP);

Expand All @@ -1349,6 +1351,7 @@ void testHvdcDisconnectedThenConnectedByStrategy() {
// without AC emulation
SecurityAnalysisParameters parameters = new SecurityAnalysisParameters();
parameters.getLoadFlowParameters().setHvdcAcEmulation(false);
network.getHvdcLine("hvdc23").setR(0.1d); //Putting back resistance of the cable to keep same old behaviour
SecurityAnalysisResult result2 = runSecurityAnalysis(network, contingencies, monitors, parameters,
operatorStrategies, actions, ReportNode.NO_OP);

Expand Down

0 comments on commit 00ec727

Please sign in to comment.