Skip to content

Commit

Permalink
Introduce hvdc state save and restore for AC emulation after continge…
Browse files Browse the repository at this point in the history
…ncy (#688)

Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
  • Loading branch information
annetill authored and flo-dup committed Jan 10, 2023
1 parent e4879d5 commit 15db0f8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/powsybl/openloadflow/network/HvdcState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.openloadflow.network;

/**
* @author Anne Tilloy <anne.tilloy at rte-france.com>
*/
public class HvdcState extends ElementState<LfHvdc> {

public HvdcState(LfHvdc hvdc) {
super(hvdc);
}

public static HvdcState save(LfHvdc hvdc) {
return new HvdcState(hvdc);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,27 @@ public class NetworkState {

private final List<BranchState> branchStates;

protected NetworkState(List<BusState> busStates, List<BranchState> branchStates) {
private final List<HvdcState> hvdcStates;

protected NetworkState(List<BusState> busStates, List<BranchState> branchStates, List<HvdcState> hvdcStates) {
this.busStates = Objects.requireNonNull(busStates);
this.branchStates = Objects.requireNonNull(branchStates);
this.hvdcStates = Objects.requireNonNull(hvdcStates);
}

public static NetworkState save(LfNetwork network) {
Objects.requireNonNull(network);
LOGGER.trace("Saving network state");
List<BusState> busStates = ElementState.save(network.getBuses(), BusState::save);
List<BranchState> branchStates = ElementState.save(network.getBranches(), BranchState::save);
return new NetworkState(busStates, branchStates);
List<HvdcState> hvdcStates = ElementState.save(network.getHvdcs(), HvdcState::save);
return new NetworkState(busStates, branchStates, hvdcStates);
}

public void restore() {
LOGGER.trace("Restoring network state");
ElementState.restore(busStates);
ElementState.restore(branchStates);
ElementState.restore(hvdcStates);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1194,4 +1194,30 @@ void testPredefinedResults4() {
assertEquals(0, result.getBranchFlow1SensitivityValue("l23", "l23", "l12"), LoadFlowAssert.DELTA_POWER);
assertEquals(Double.NaN, result.getBranchFlow1SensitivityValue("l23", "l23", "l23"), LoadFlowAssert.DELTA_POWER);
}

@Test
void testRestoreAfterContingencyOnHvdc() {
Network network = HvdcNetworkFactory.createWithHvdcInAcEmulation();
network.getGeneratorStream().forEach(gen -> gen.setMaxP(2 * gen.getMaxP()));
network.getHvdcLine("hvdc34").newExtension(HvdcAngleDroopActivePowerControlAdder.class)
.withDroop(180)
.withP0(0.f)
.withEnabled(true)
.add();

SensitivityAnalysisParameters sensiParameters = createParameters(false, "b1_vl_0", true);
sensiParameters.getLoadFlowParameters().getExtension(OpenLoadFlowParameters.class).setSlackBusPMaxMismatch(0.001);

List<SensitivityFactor> factors = createFactorMatrix(Stream.of("g1", "g5").map(network::getGenerator).collect(Collectors.toList()),
Stream.of("l12", "l25", "l56").map(network::getBranch).collect(Collectors.toList()));

List<Contingency> contingencies = List.of(new Contingency("hvdc34", new HvdcLineContingency("hvdc34")),
new Contingency("l45", new BranchContingency("l45")));

SensitivityAnalysisResult result = sensiRunner.run(network, factors, contingencies, Collections.emptyList(), sensiParameters);

assertEquals(0.269, result.getBranchFlow1SensitivityValue("l45", "g1", "l12"), LoadFlowAssert.DELTA_POWER);
assertEquals(0.356, result.getBranchFlow1SensitivityValue("l45", "g1", "l25"), LoadFlowAssert.DELTA_POWER);
assertEquals(-0.144, result.getBranchFlow1SensitivityValue("l45", "g1", "l56"), LoadFlowAssert.DELTA_POWER);
}
}

0 comments on commit 15db0f8

Please sign in to comment.