Skip to content

fix double slack distribution in SA DC #1209

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

Merged
merged 4 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -74,7 +74,9 @@ public static double distributeSlack(LfNetwork network, Collection<LfBus> buses,
public static double getActivePowerMismatch(Collection<LfBus> buses) {
double mismatch = 0;
for (LfBus b : buses) {
mismatch += b.getGenerationTargetP() - b.getLoadTargetP();
if (!b.isDisabled()) {
mismatch += b.getGenerationTargetP() - b.getLoadTargetP();
}
}
return -mismatch;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.powsybl.contingency.LoadContingency;
import com.powsybl.iidm.network.Network;
import com.powsybl.loadflow.LoadFlowParameters;
import com.powsybl.loadflow.LoadFlowResult;
import com.powsybl.openloadflow.OpenLoadFlowParameters;
import com.powsybl.openloadflow.network.PhaseControlFactory;
import com.powsybl.openloadflow.network.SlackBusSelectionMode;
Expand Down Expand Up @@ -219,9 +220,9 @@ void testSaDcPhaseTapChangerTapPositionChangeAlphaOnly(boolean dcFastMode) {
assertEquals(network.getTwoWindingsTransformer("PS1").getTerminal2().getP(), brRelPS1.getP2(), LoadFlowAssert.DELTA_POWER);
}

// TODO Does not work in DC mode - to fix in a separate PR
@Test
void testSaDcPhaseTapChangerTapPositionChangeWithConnectivityBreak() {
@ParameterizedTest
@ValueSource(booleans = {false, true})
void testSaDcPhaseTapChangerTapPositionChangeWithConnectivityBreak(boolean fastDcMode) {
Network network = PhaseControlFactory.createNetworkWith3Buses();

List<StateMonitor> monitors = createAllBranchesMonitors(network);
Expand All @@ -235,6 +236,8 @@ void testSaDcPhaseTapChangerTapPositionChangeWithConnectivityBreak() {
OpenLoadFlowParameters.create(parameters)
.setSlackBusId("VL2_0")
.setSlackBusSelectionMode(SlackBusSelectionMode.NAME);
securityAnalysisParameters.getExtension(OpenSecurityAnalysisParameters.class)
.setDcFastMode(fastDcMode);
SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters,
operatorStrategies, actions, ReportNode.NO_OP);

Expand All @@ -254,7 +257,7 @@ void testSaDcPhaseTapChangerTapPositionChangeWithConnectivityBreak() {
// Apply remedial action
network.getTwoWindingsTransformer("PS1").getPhaseTapChanger().setTapPosition(0);

loadFlowRunner.run(network, parameters);
LoadFlowResult lfResult = loadFlowRunner.run(network, parameters);

// Compare results on the line L12
assertEquals(network.getLine("L12").getTerminal1().getP(), brAbsL12.getP1(), LoadFlowAssert.DELTA_POWER);
Expand Down