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

Fix: support of non impedant dangling lines #489

Merged
merged 4 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private LoadFlowResult runAc(Network network, LoadFlowParameters parameters, Rep
parameters.isTransformerVoltageControlOn(),
parameters.isDistributedSlack() && parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD,
parameters.isDistributedSlack() && (parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD ||
parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD) && parametersExt.isLoadPowerFactorConstant());
parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD) && parametersExt.isLoadPowerFactorConstant(), parameters.isDc());
}

LoadFlowResult.ComponentResult.Status status;
Expand Down Expand Up @@ -188,7 +188,7 @@ private LoadFlowResult.ComponentResult processResult(Network network, DcLoadFlow
parameters.isPhaseShifterRegulationOn(),
parameters.isTransformerVoltageControlOn(),
parameters.isDistributedSlack() && parameters.getBalanceType() == LoadFlowParameters.BalanceType.PROPORTIONAL_TO_CONFORM_LOAD,
false);
false, true);
}

return new LoadFlowResultImpl.ComponentResultImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ default List<LfLimit> getLimits2(LimitType type) {

Optional<DiscretePhaseControl> getDiscretePhaseControl();

void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn);
void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn, boolean dc);

boolean isPhaseController();

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/powsybl/openloadflow/network/LfNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ public List<LfHvdc> getHvdcs() {
}

public void updateState(boolean reactiveLimits, boolean writeSlackBus, boolean phaseShifterRegulationOn,
boolean transformerVoltageControlOn, boolean distributedOnConformLoad, boolean loadPowerFactorConstant) {
boolean transformerVoltageControlOn, boolean distributedOnConformLoad, boolean loadPowerFactorConstant,
boolean dc) {
Stopwatch stopwatch = Stopwatch.createStarted();

for (LfHvdc hvdc : hvdcs) {
Expand All @@ -226,7 +227,7 @@ public void updateState(boolean reactiveLimits, boolean writeSlackBus, boolean p
bus.getControllerShunt().ifPresent(LfShunt::updateState);
}
for (LfBranch branch : branches) {
branch.updateState(phaseShifterRegulationOn, transformerVoltageControlOn);
branch.updateState(phaseShifterRegulationOn, transformerVoltageControlOn, dc);
}

stopwatch.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public List<LfLimit> getLimits2(final LimitType type) {
}

@Override
public void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn) {
public void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn, boolean dc) {
branch.getTerminal1().setP(p1.eval() * PerUnit.SB);
branch.getTerminal1().setQ(q1.eval() * PerUnit.SB);
branch.getTerminal2().setP(p2.eval() * PerUnit.SB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ public List<LfLimit> getLimits1(final LimitType type) {
}

@Override
public void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn) {
danglingLine.getTerminal().setP(p.eval() * PerUnit.SB);
danglingLine.getTerminal().setQ(q.eval() * PerUnit.SB);
public void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn, boolean dc) {
if (this.isZeroImpedanceBranch(dc)) {
danglingLine.getTerminal().setP(-getBus2().getP().eval() * PerUnit.SB);
danglingLine.getTerminal().setQ(-getBus2().getQ().eval() * PerUnit.SB);
} else {
danglingLine.getTerminal().setP(p.eval() * PerUnit.SB);
danglingLine.getTerminal().setQ(q.eval() * PerUnit.SB);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public List<LfLimit> getLimits1(final LimitType type) {
}

@Override
public void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn) {
public void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn, boolean dc) {
leg.getTerminal().setP(p.eval() * PerUnit.SB);
leg.getTerminal().setQ(q.eval() * PerUnit.SB);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public List<LfLimit> getLimits2(final LimitType type) {
}

@Override
public void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn) {
public void updateState(boolean phaseShifterRegulationOn, boolean isTransformerVoltageControlOn, boolean dc) {
// nothing to do
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void test() {
void testWithVoltageRegulationOn() {
g1.setTargetQ(0);
g1.setVoltageRegulatorOn(false);
// FIXME: no targetV here?
dl1.getGeneration().setVoltageRegulationOn(true);
dl1.getGeneration().setMinP(0);
dl1.getGeneration().setMaxP(10);
Expand Down Expand Up @@ -176,4 +177,32 @@ void testEquivalentBranch() {
assertVoltageEquals(121.62, network.getBusBreakerView().getBus("BUS_2"));
assertVoltageEquals(0.04, network.getBusBreakerView().getBus("BUS_3"));
}

@Test
void testWithNonImpedantDanglingLine() {
dl1.setR(0.0).setX(0.0);
LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());
assertActivePowerEquals(101.0, dl1.getTerminal());
assertReactivePowerEquals(150.0, dl1.getTerminal());

dl1.getGeneration().setVoltageRegulationOn(true);
dl1.getGeneration().setTargetV(390.0);
dl1.getGeneration().setMinP(0);
dl1.getGeneration().setMaxP(10);
dl1.getGeneration().newMinMaxReactiveLimits()
.setMinQ(-100)
.setMaxQ(100)
.add();
LoadFlowResult result2 = loadFlowRunner.run(network, parameters);
assertTrue(result2.isOk());
assertActivePowerEquals(101.0, dl1.getTerminal());
assertReactivePowerEquals(-33.888, dl1.getTerminal());

parameters.setDc(true);
LoadFlowResult result3 = loadFlowRunner.run(network, parameters);
assertTrue(result3.isOk());
assertActivePowerEquals(101.0, dl1.getTerminal());
assertReactivePowerEquals(Double.NaN, dl1.getTerminal());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void busBreakerAndNonImpedantBranchIssue() {
new AcloadFlowEngine(context)
.run();
}
lfNetwork.updateState(false, false, false, false, false, false);
lfNetwork.updateState(false, false, false, false, false, false, false);
for (Bus bus : network.getBusView().getBuses()) {
assertEquals(400, bus.getV(), 0);
assertEquals(0, bus.getAngle(), 0);
Expand Down Expand Up @@ -113,7 +113,7 @@ void busBreakerAndNonImpedantBranchIssueRef() {
new AcloadFlowEngine(context)
.run();
}
lfNetwork.updateState(false, false, false, false, false, false);
lfNetwork.updateState(false, false, false, false, false, false, false);
assertEquals(-100, network.getGenerator("G1").getTerminal().getQ(), 0);
assertEquals(-100, network.getGenerator("G2").getTerminal().getQ(), 0);
}
Expand Down