Skip to content

Commit

Permalink
Network update: wrong load Q0 when loadPowerFactorConstant is true an…
Browse files Browse the repository at this point in the history
…d P0 equals zero (#798)

Signed-off-by: Caio Luke <caio.luke@artelys.com>
Signed-off-by: Anne Tilloy <anne.tilloy@rte-france.com>
(cherry picked from commit 42aa220)
  • Loading branch information
caioluke authored and jeandemanged committed Jun 16, 2023
1 parent e9e4f03 commit a35e656
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ void updateState(double diffLoadTargetP, boolean loadPowerFactorConstant) {
init();
for (int i = 0; i < loadsRefs.size(); i++) {
Load load = loadsRefs.get(i).get();
double updatedP0 = (load.getP0() / PerUnit.SB + diffLoadTargetP * participationFactors[i]) * PerUnit.SB;
double updatedQ0 = loadPowerFactorConstant ? getPowerFactor(load) * updatedP0 : load.getQ0();
double diffP0 = diffLoadTargetP * participationFactors[i] * PerUnit.SB;
double updatedP0 = load.getP0() + diffP0;
double updatedQ0 = load.getQ0() + (loadPowerFactorConstant ? getPowerFactor(load) * diffP0 : 0.0);
load.getTerminal().setP(updatedP0);
load.getTerminal().setQ(updatedQ0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
*/
package com.powsybl.openloadflow.ac;

import com.powsybl.iidm.network.Bus;
import com.powsybl.iidm.network.Line;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.ActivePowerControlAdder;
import com.powsybl.loadflow.LoadFlow;
import com.powsybl.loadflow.LoadFlowParameters;
Expand Down Expand Up @@ -162,4 +160,37 @@ void zeroImpedanceToShuntCompensator() {
assertReactivePowerEquals(0.9038788263615884, network.getLine("l23").getTerminal1());
assertActivePowerEquals(0.0, network.getLine("l23").getTerminal1());
}

@Test
void modifiedLoadCaseTest() {
// previous value : l1 (P0, Q0) = (2, 1)
// new values : l1 (P0, Q0) = (0, 1) and
// l2 (P0, Q0) = (2, 0)
network.getLoad("l1").setP0(0);
Load l2 = bus2.getVoltageLevel().newLoad()
.setId("l2")
.setBus("b2")
.setConnectableBus("b2")
.setP0(2)
.setQ0(0)
.add();
l2.getTerminal().setP(2).setQ(0);

parameters = new LoadFlowParameters()
.setReadSlackBus(false)
.setDistributedSlack(true)
.setBalanceType(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD);
OpenLoadFlowParameters.create(parameters)
.setSlackBusSelectionMode(SlackBusSelectionMode.MOST_MESHED)
.setLoadPowerFactorConstant(true);

LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());

Double bus2BalanceQ = bus2.getConnectedTerminalStream().map(Terminal::getQ)
.filter(d -> !Double.isNaN(d))
.reduce(0.0, Double::sum);

assertEquals(0.0, bus2BalanceQ, DELTA_POWER);
}
}

0 comments on commit a35e656

Please sign in to comment.