Skip to content

Commit

Permalink
DC security analysis: RHS is not invalidated (#1042)
Browse files Browse the repository at this point in the history
Signed-off-by: Anne Tilloy <[email protected]>
  • Loading branch information
annetill authored Jun 10, 2024
1 parent b5831dd commit d91090b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public void onTapPositionChange(LfBranch branch, int oldPosition, int newPositio
public void onShuntSusceptanceChange(LfShunt shunt, double b) {
invalidateValues();
}

@Override
public void onDisableChange(LfElement element, boolean disabled) {
for (var equationTerm : equationSystem.getEquationTerms(element.getType(), element.getNum())) {
if (equationTerm.hasRhs()) {
invalidateValues();
}
}
}
};

public TargetVector(LfNetwork network, EquationSystem<V, E> equationSystem, Initializer<V, E> initializer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3185,4 +3185,58 @@ void testLimitReductions() {
assertEquals(1000., limitViolations.get(0).getLimit(), 0.0001);
assertEquals(945.51416, limitViolations.get(0).getValue(), 0.0001);
}

@Test
void testPhaseTapChangerContingency() {
Network network = PhaseControlFactory.createNetworkWithT2wt();
TwoWindingsTransformer pst = network.getTwoWindingsTransformer("PS1");
pst.getPhaseTapChanger().setTapPosition(2);

network.newLine().setId("L3")
.setConnectableBus1("B1")
.setBus1("B1")
.setConnectableBus2("B2")
.setBus2("B2")
.setR(4.0)
.setX(200.0)
.add();

network.newLine().setId("L4")
.setConnectableBus1("B3")
.setBus1("B3")
.setConnectableBus2("B2")
.setBus2("B2")
.setR(4.0)
.setX(200.0)
.add();

LoadFlowParameters lfParameters = new LoadFlowParameters()
.setDc(true);

List<Contingency> contingencies = List.of(Contingency.twoWindingsTransformer("PS1"));
List<StateMonitor> monitors = createAllBranchesMonitors(network);
SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, lfParameters);
// pre-contingency tests
PreContingencyResult preContingencyResult = result.getPreContingencyResult();
assertEquals(7.623, preContingencyResult.getNetworkResult().getBranchResult("L1").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(56.503, preContingencyResult.getNetworkResult().getBranchResult("L2").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(7.623, preContingencyResult.getNetworkResult().getBranchResult("L3").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(28.252, preContingencyResult.getNetworkResult().getBranchResult("L4").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(84.755, preContingencyResult.getNetworkResult().getBranchResult("PS1").getP1(), LoadFlowAssert.DELTA_POWER);
// post-contingency tests
PostContingencyResult ps1ContingencyResult = getPostContingencyResult(result, "PS1");
assertEquals(50.0, ps1ContingencyResult.getNetworkResult().getBranchResult("L1").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(0.0, ps1ContingencyResult.getNetworkResult().getBranchResult("L2").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(50.0, ps1ContingencyResult.getNetworkResult().getBranchResult("L3").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(0.0, ps1ContingencyResult.getNetworkResult().getBranchResult("L4").getP1(), LoadFlowAssert.DELTA_POWER);

// we compare with a dc load flow
pst.getTerminal1().disconnect();
pst.getTerminal2().disconnect();
LoadFlow.run(network, lfParameters);
assertActivePowerEquals(50.0, network.getBranch("L1").getTerminal1());
assertActivePowerEquals(0.0, network.getBranch("L2").getTerminal1());
assertActivePowerEquals(50.0, network.getBranch("L3").getTerminal1());
assertActivePowerEquals(0.0, network.getBranch("L4").getTerminal1());
}
}

0 comments on commit d91090b

Please sign in to comment.