Skip to content

Commit

Permalink
suggested fix
Browse files Browse the repository at this point in the history
Signed-off-by: vmouradian <valentin.mouradian@artelys.com>
  • Loading branch information
vmouradian committed Nov 7, 2024
1 parent c6e123a commit 0739fab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static double getReactivePowerControlTarget(LfBranch branch) {

public static void init(Equation<AcVariableType, AcEquationType> equation, LfNetwork network, double[] targets) {
switch (equation.getType()) {
case BUS_TARGET_P:
case BUS_TARGET_P, BUS_DISTR_SLACK_P:
targets[equation.getColumn()] = network.getBus(equation.getElementNum()).getTargetP();
break;

Expand Down Expand Up @@ -118,7 +118,6 @@ public static void init(Equation<AcVariableType, AcEquationType> equation, LfNet
DISTR_SHUNT_B,
DUMMY_TARGET_P,
DUMMY_TARGET_Q,
BUS_DISTR_SLACK_P,
BUS_TARGET_IX_ZERO,
BUS_TARGET_IY_ZERO,
BUS_TARGET_IX_NEGATIVE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,13 +1037,13 @@ private void createMultipleSlackBusesEquations(EquationSystem<AcVariableType, Ac
for (int i = 1; i < slackBuses.size(); i++) {
LfBus slackBus = slackBuses.get(i);
// example for 2 slack buses
// 0 = slack_p1 - slack_p2
// 0 = slack_p1 - slack_p3
// 0 = slack_p2 - slack_p1
// 0 = slack_p3 - slack_p1
equationSystem.createEquation(slackBus, AcEquationType.BUS_DISTR_SLACK_P)
.addTerms(createActiveInjectionTerms(firstSlackBus, equationSystem.getVariableSet()))
.addTerms(createActiveInjectionTerms(slackBus, equationSystem.getVariableSet()).stream()
.addTerms(createActiveInjectionTerms(firstSlackBus, equationSystem.getVariableSet()).stream()
.map(EquationTerm::minus)
.collect(Collectors.toList()));
.toList())
.addTerms(createActiveInjectionTerms(slackBus, equationSystem.getVariableSet()));
// to update open/close terms activation
for (LfBranch branch : slackBus.getBranches()) {
updateBranchEquations(branch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.powsybl.openloadflow.OpenLoadFlowProvider;
import com.powsybl.openloadflow.ac.solver.NewtonRaphsonStoppingCriteriaType;
import com.powsybl.openloadflow.network.EurostagFactory;
import com.powsybl.openloadflow.network.LfBus;
import com.powsybl.openloadflow.network.SlackBusSelectionMode;
import com.powsybl.openloadflow.util.LoadFlowAssert;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -121,17 +120,15 @@ void targetVectorBug() {
LoadFlowResult.ComponentResult componentResult = result.getComponentResults().get(0);
List<LoadFlowResult.SlackBusResult> slackBusResults = componentResult.getSlackBusResults();


TwoWindingsTransformer t2wtLoad = network.getTwoWindingsTransformer("NHV2_NLOAD");
Load load = network.getLoad("LOAD");

// Load is ignored by LF equations only slack goes to this bus
assertEquals(-301.159, t2wtLoad.getTerminal2().getP(), LoadFlowAssert.DELTA_POWER);
assertEquals(-600.710, t2wtLoad.getTerminal2().getP(), LoadFlowAssert.DELTA_POWER);
assertEquals(600.0, load.getTerminal().getP(), LoadFlowAssert.DELTA_POWER);

// Slack bus mismatch is false
// still small difference due to NR conv epsilon per eq
assertEquals(2, slackBusResults.size());
assertEquals(-1.15940, slackBusResults.get(0).getActivePowerMismatch(), LoadFlowAssert.DELTA_POWER);
assertEquals(-1.15940, slackBusResults.get(1).getActivePowerMismatch(), LoadFlowAssert.DELTA_POWER);
assertEquals(-0.711, slackBusResults.get(0).getActivePowerMismatch(), LoadFlowAssert.DELTA_POWER);
assertEquals(-0.711, slackBusResults.get(1).getActivePowerMismatch(), LoadFlowAssert.DELTA_POWER);
}
}

0 comments on commit 0739fab

Please sign in to comment.