Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed PST Flow Regulation on non impedant branch causing exception #816

Merged
merged 10 commits into from
Jul 18, 2023
Merged
4 changes: 2 additions & 2 deletions src/main/java/com/powsybl/openloadflow/network/LfNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ public void fix(boolean minImpedance, double lowImpedanceThreshold) {
branch.setMinZ(lowImpedanceThreshold);
}
} else {
// zero impedance controller phase shifter is not supported
// zero impedance phase shifter controller or controlled branch is not supported
branches.stream()
.filter(LfBranch::isPhaseController)
.filter(b -> b.isPhaseController() || b.isPhaseControlled())
.forEach(branch -> branch.setMinZ(lowImpedanceThreshold));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ public boolean isConnectedAtBothSides() {
@Override
public void setMinZ(double lowImpedanceThreshold) {
for (LoadFlowModel loadFlowModel : List.of(LoadFlowModel.AC, LoadFlowModel.DC)) {
if (piModel.setMinZ(lowImpedanceThreshold, loadFlowModel)) {
if (piModel.setMinZ(lowImpedanceThreshold, loadFlowModel) ||
(LoadFlowModel.DC.equals(loadFlowModel) && isZeroImpedance(loadFlowModel))) {
// Note: For DC load flow model, the min impedance has already been set by AC load flow model but
// the zero impedance field must still be updated.
LOGGER.trace("Branch {} has a low impedance in {}, set to min {}", getId(), loadFlowModel, lowImpedanceThreshold);
zeroImpedanceContextByModel.get(loadFlowModel).zeroImpedance = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,15 +621,16 @@ void activePowerflowControlAndNonImpedantPhaseShifterTest() {
assertActivePowerEquals(-112.019, line2.getTerminal2());
assertEquals(2, t2wt.getPhaseTapChanger().getTapPosition());

line1.setR(0).setX(0);
line1.setR(0.0).setX(0.0);
t2wt.setR(2.0).setX(100.0);
t2wt.getPhaseTapChanger()
.setRegulationTerminal(line1.getTerminal1())
.setTapPosition(0);
LoadFlowResult result2 = loadFlowRunner.run(network, parameters);

assertTrue(result.isOk());
assertActivePowerEquals(-12.006, line1.getTerminal1());
assertActivePowerEquals(112.197, line2.getTerminal1());
assertEquals(0, t2wt.getPhaseTapChanger().getTapPosition());
assertTrue(result2.isOk());
assertActivePowerEquals(100.0, line1.getTerminal1());
assertActivePowerEquals(0.0, line2.getTerminal1());
assertEquals(1, t2wt.getPhaseTapChanger().getTapPosition());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,17 @@ void validationLevelTest5() {
PowsyblException e = assertThrows(PowsyblException.class, () -> Networks.load(network, new FirstSlackBusSelector()));
assertEquals("Only STEADY STATE HYPOTHESIS validation level of the network is supported", e.getMessage());
}

@Test
void testMinImpedance() {
network = EurostagTutorialExample1Factory.create();
network.getLine("NHV1_NHV2_1").setR(0.0).setX(0.0).setB1(0.0).setB2(0.0).setG1(0.0).setG2(0.0);
List<LfNetwork> lfNetworks = Networks.load(network, new FirstSlackBusSelector());
LfBranch line = lfNetworks.get(0).getBranchById("NHV1_NHV2_1");
assertTrue(line.isZeroImpedance(LoadFlowModel.AC));
assertTrue(line.isZeroImpedance(LoadFlowModel.DC));
line.setMinZ(10); // for both AC and DC load flow model
assertFalse(line.isZeroImpedance(LoadFlowModel.AC));
assertFalse(line.isZeroImpedance(LoadFlowModel.DC));
}
}