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 DC Load Flow bus imbalance #1138

Merged
merged 23 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
03a6e83
fix lfBus power balance evaluation
vmouradian Nov 28, 2024
ed057df
copyright and author
vmouradian Nov 29, 2024
91830f9
create separated test case
vmouradian Dec 2, 2024
b8d5804
Add LfNetworkLoaderPostProcessor.onLfNetworkLoaded event (#1127)
jeandemanged Nov 22, 2024
99bd583
DC Load Flow reference bus and multi slack support (#1118)
vmouradian Nov 25, 2024
318e503
Move run dc load flow with modified target vector in woodbury (#1126)
p-arvy Nov 26, 2024
bb9ddd5
Refactor separation of post contingency calculations in Woodbury DC S…
p-arvy Nov 26, 2024
839da72
Report buses out of realistic voltage range in sub reports (#1105)
TheMaskedTurtle Nov 27, 2024
3730f5d
add ViolationLocation to LimitViolationManager (#1134)
jamal-khey Dec 2, 2024
1245d89
fictive load on isolated bus keeps hvdc isolated (#1120)
vidaldid-rte Dec 2, 2024
6423fa4
Fix secondary synchronous components in main CC not computed in SA (#…
obrix Dec 2, 2024
a4c78bf
DC Area Interchange Control OuterLoop (#1123)
vmouradian Dec 3, 2024
8d90a80
Bump powsybl-core to v6.6.0-RC1 (#1141)
flo-dup Dec 5, 2024
d269e70
Refactor to allow external AC solvers (#1107)
jeandemanged Dec 5, 2024
5343525
Move classes related to woodbury in fast dc (#1145)
p-arvy Dec 6, 2024
7c11fa5
Delete class MatrixUtil (#1136)
SylvestreSakti Dec 6, 2024
823f409
revert bus power equation logic
vmouradian Dec 6, 2024
3acb883
remove rhs from Equation eval (tmp)
vmouradian Dec 6, 2024
e834440
fix only in ZeroImpedanceFlows (temp)
vmouradian Dec 6, 2024
230d93e
Add draft test with two non impedance lines
vidaldid-rte Dec 6, 2024
7c74dd3
Refacto lhs (#1147)
vidaldid-rte Dec 11, 2024
5be9e64
Add PST Actions in Fast DC Security Analysis (#1095)
p-arvy Dec 11, 2024
97c46f8
Merge branch 'main' into bugfix/pst-non-impedant-branch-bus-imbalance
vidaldid-rte Dec 11, 2024
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 @@ -97,7 +97,8 @@ public double calculateSensi(DenseMatrix dx, int column) {
double dph1 = dx.get(ph1Var.getRow(), column);
double dph2 = dx.get(ph2Var.getRow(), column);
double da1 = a1Var != null ? dx.get(a1Var.getRow(), column) : 0;
return calculateSensi(dph1, dph2, da1);
// - eval(0,0,0) to have an exact epression and remove the constant term of the affine function (wich is 0 in practe because A2 = 0)
return eval(dph1, dph2, da1) - eval(0, 0, 0);
}

protected double ph1(StateVector sv) {
Expand All @@ -116,16 +117,11 @@ protected double ph2() {
return ph2(sv);
}

protected abstract double calculateSensi(double ph1, double ph2, double a1);
protected abstract double eval(double ph1, double ph2, double a1);

@Override
public double eval() {
return calculateSensi(ph1(), ph2(), a1());
}

@Override
public double eval(StateVector sv) {
return calculateSensi(ph1(sv), ph2(sv), a1(sv));
return eval(ph1(), ph2(), a1());
}

protected double a1(StateVector sv) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static ClosedBranchSide1DcFlowEquationTerm create(LfBranch branch, LfBus
}

@Override
protected double calculateSensi(double ph1, double ph2, double a1) {
protected double eval(double ph1, double ph2, double a1) {
double deltaPhase = ph2 - ph1 + A2 - a1;
return -getPower() * deltaPhase;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static ClosedBranchSide2DcFlowEquationTerm create(LfBranch branch, LfBus
}

@Override
protected double calculateSensi(double ph1, double ph2, double a1) {
protected double eval(double ph1, double ph2, double a1) {
double deltaPhase = ph2 - ph1 + A2 - a1;
return getPower() * deltaPhase;
}
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/com/powsybl/openloadflow/equations/Equation.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,16 @@ public double eval() {
for (EquationTerm<V, E> term : terms) {
if (term.isActive()) {
value += term.eval();
if (term.hasRhs()) {
value -= term.rhs();
}
}
}
return value;
}

public double evalLhs() {
double value = 0;
for (EquationTerm<V, E> term : terms) {
if (term.isActive()) {
value += term.evalLhs();
}
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ static <V extends Enum<V> & Quantity, E extends Enum<E> & Quantity> EquationTerm
double eval();

/**
* Evaluate the equation term with an alternative state vector.
* Evaluate equation lhs of the equation term
* @return value of the equation term
*/
default double eval(StateVector sv) {
throw new UnsupportedOperationException("Not implemented");
default double evalLhs() {
return eval() - (hasRhs() ? rhs() : 0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ protected double[] createArray() {
return array;
}

private void eval(double[] array, List<Equation<V, E>> equations) {
private void evalLhs(double[] array, List<Equation<V, E>> equations) {
Arrays.fill(array, 0); // necessary?
for (Equation<V, E> equation : equations) {
array[equation.getColumn()] = equation.eval();
array[equation.getColumn()] = equation.evalLhs();
}
}

Expand All @@ -59,7 +59,7 @@ protected void updateArray(double[] array) {
throw new IllegalArgumentException("Bad equation vector length: " + array.length);
}

eval(array, equations);
evalLhs(array, equations);

LOGGER.debug(PERFORMANCE_MARKER, "Equation vector updated in {} us", stopwatch.elapsed(TimeUnit.MICROSECONDS));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,4 @@ public boolean isActive() {
return getBranchTermStream().anyMatch(EquationTerm::isActive);
}

@Override
public double eval(StateVector sv) {
// The equation is
// rhs = VariableInjectionPart+ branchPart
// with rhs = - (cte injectionPart) (for ex sum of targetQ)
// -branchPart = variableInjectionPart + cteInjectionPart
return -getBranchTermStream().mapToDouble(t -> t.eval(sv)).sum();
}
}
2 changes: 0 additions & 2 deletions src/main/java/com/powsybl/openloadflow/util/Derivable.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import com.powsybl.math.matrix.DenseMatrix;
import com.powsybl.openloadflow.equations.Quantity;
import com.powsybl.openloadflow.equations.StateVector;
import com.powsybl.openloadflow.equations.Variable;

/**
Expand All @@ -23,5 +22,4 @@ public interface Derivable <V extends Enum<V> & Quantity> extends Evaluable {

boolean isActive();

double eval(StateVector sv);
}
47 changes: 47 additions & 0 deletions src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,53 @@ void nonImpedantBranchTest() {
assertEquals(33.3333, network.getLine("L1").getTerminal1().getP(), 0.01);
}

@Test
void nonImpedantBranchAndPhaseShiftingTest() {
Network network = PhaseShifterTestCaseFactory.create();
network.getLine("L2").setX(0).setR(0);
network.getTwoWindingsTransformer("PS1").getPhaseTapChanger().getStep(1).setAlpha(2);
loadFlowRunner.run(network, parameters);

assertEquals(16.5316, network.getLine("L1").getTerminal1().getP(), 0.01);
assertEquals(83.4683, network.getLine("L2").getTerminal1().getP(), 0.01); // Temporary comment : P without fix = 133.87
assertEquals(-83.4683, network.getTwoWindingsTransformer("PS1").getTerminal2().getP(), 0.01);

// With e second zero impedance line and a second load
VoltageLevel vl2 = network.getVoltageLevel("VL2");
vl2.getBusBreakerView().newBus()
.setId("B2Bis")
.add();
vl2.newLoad()
.setId("LD2Bis")
.setConnectableBus("B2Bis")
.setBus("B2Bis")
.setP0(100.0)
.setQ0(50.0)
.add();
network.newLine()
.setId("L2Bis")
.setVoltageLevel1("VL3")
.setConnectableBus1("B3")
.setBus1("B3")
.setVoltageLevel2("VL2")
.setConnectableBus2("B2Bis")
.setBus2("B2Bis")
.setR(0.0)
.setX(0.0)
.setG1(0.0)
.setB1(0.0)
.setG2(0.0)
.setB2(0.0)
.add();
network.getGenerator("G1").setMaxP(500);
LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isFullyConverged());
assertEquals(49.86, network.getLine("L1").getTerminal1().getP(), 0.01);
assertEquals(150.13, network.getTwoWindingsTransformer("PS1").getTerminal1().getP(), 0.01);
assertEquals(0, network.getTwoWindingsTransformer("PS1").getTerminal2().getP() + network.getLine("L2").getTerminal1().getP() + network.getLine("L2Bis").getTerminal1().getP(), 0.01); // Temporary comment : P without fix = 133.87
assertEquals(-200, network.getGenerator("G1").getTerminal().getP());
}

@Test
void multiCcTest() {
Network network = IeeeCdfNetworkFactory.create14();
Expand Down
Loading