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

Support of BusbarSectionContingency for everything #667

Merged
merged 32 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fd27023
WIP.
annetill Dec 7, 2022
303b261
Merge.
annetill Dec 8, 2022
04884bb
Save work.
annetill Dec 8, 2022
3398fb7
Merge branch 'main' into busbarsection-contingency
annetill Jan 10, 2023
4e4bb39
Remove everything related to bus.
annetill Jan 11, 2023
a117eac
Add minimal tripping from busbar section contingency
flo-dup Jan 11, 2023
a8ababc
Merge.
annetill Jan 16, 2023
c57717c
Fix comment
flo-dup Jan 16, 2023
820e38b
WIP.
annetill Jan 16, 2023
4d62298
Merge branch 'busbarsection-contingency' of https://github.com/powsyb…
annetill Jan 16, 2023
d4e91e4
Merge branch 'main' into busbarsection-contingency
geofjamg Jan 17, 2023
dcd4583
Merge branch 'main' into busbarsection-contingency
annetill Jan 20, 2023
0db9492
Save
annetill Jan 20, 2023
4136262
WIP
annetill Jan 23, 2023
253f92d
WIP.
annetill Feb 9, 2023
8244ccf
Clean.
annetill Feb 9, 2023
1ee7fa1
Merge.
annetill Feb 9, 2023
247a619
Fix unit test.
annetill Feb 9, 2023
885b7cf
First working version on real test cases.
annetill Feb 9, 2023
991bc8a
Merge branch 'main' into busbarsection-contingency
annetill Feb 10, 2023
04a68c0
Merge branch 'main' into busbarsection-contingency
annetill Feb 15, 2023
43feccb
Merge.
annetill Mar 1, 2023
5d99f7d
Merge.
annetill Mar 23, 2023
80bafdc
Merge branch 'main' into busbarsection-contingency
geofjamg Mar 24, 2023
f7b906e
Clean
annetill Mar 26, 2023
736eba6
Merge branch 'main' into busbarsection-contingency
annetill Mar 27, 2023
c4fff73
Merge branch 'main' into busbarsection-contingency
annetill Mar 29, 2023
8e4298e
Merge branch 'main' into busbarsection-contingency
geofjamg Mar 29, 2023
4173139
Merge branch 'main' into busbarsection-contingency
annetill Mar 31, 2023
1f84ca5
Clean.
annetill Mar 31, 2023
95fbf8d
Merge branch 'main' into busbarsection-contingency
annetill Mar 31, 2023
b95c188
add comments.
annetill Mar 31, 2023
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 @@ -72,6 +72,7 @@ public static ContingencyTripping createContingencyTripping(Network network, Ide
case GENERATOR:
case LOAD:
case SHUNT_COMPENSATOR:
case BUSBAR_SECTION:
return ContingencyTripping.createInjectionTripping(network, (Injection<?>) identifiable);
case THREE_WINDINGS_TRANSFORMER:
return ContingencyTripping.createThreeWindingsTransformerTripping(network, (ThreeWindingsTransformer) identifiable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ private static PropagatedContingency create(Network network, Contingency conting
Identifiable<?> identifiable = getIdentifiable(network, element);
if (contingencyPropagation) {
ContingencyTripping.createContingencyTripping(network, identifiable).traverse(switchesToOpen, terminalsToDisconnect);
} else if (identifiable instanceof BusbarSection) {
ContingencyTripping.createContingencyTripping(network, identifiable).traverse(switchesToOpen, terminalsToDisconnect); // FIXME Florian.
}
terminalsToDisconnect.addAll(getTerminals(identifiable));
if (identifiable instanceof Switch) {
Expand Down Expand Up @@ -278,6 +280,10 @@ private static Identifiable<?> getIdentifiable(Network network, ContingencyEleme
identifiable = network.getThreeWindingsTransformer(element.getId());
identifiableType = "Three windings transformer";
break;
case BUSBAR_SECTION:
identifiable = network.getBusbarSection(element.getId());
identifiableType = "Busbar section";
break;
default:
throw new UnsupportedOperationException("Unsupported contingency element type: " + element.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static Network create() {
.setId("C")
.setNode1(6)
.setNode2(1)
.setRetained(true)
.add();
vl1.getNodeBreakerView().newBreaker()
.setId("B1")
Expand All @@ -99,8 +100,8 @@ public static Network create() {
vl1.newGenerator()
.setId("G")
.setNode(4)
.setMinP(-9999.99)
.setMaxP(9999.99)
.setMinP(0.0)
.setMaxP(1000.0)
.setVoltageRegulatorOn(true)
.setTargetV(398)
.setTargetP(603.77)
Expand Down
5 changes: 1 addition & 4 deletions src/test/java/com/powsybl/openloadflow/sa/LfActionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
import com.powsybl.openloadflow.OpenLoadFlowParameters;
import com.powsybl.openloadflow.ac.outerloop.AcLoadFlowParameters;
import com.powsybl.openloadflow.graph.NaiveGraphConnectivityFactory;
import com.powsybl.openloadflow.network.LfAction;
import com.powsybl.openloadflow.network.LfBus;
import com.powsybl.openloadflow.network.LfNetwork;
import com.powsybl.openloadflow.network.NodeBreakerNetworkFactory;
import com.powsybl.openloadflow.network.*;
import com.powsybl.openloadflow.network.impl.LfNetworkList;
import com.powsybl.openloadflow.network.impl.Networks;
import com.powsybl.openloadflow.network.impl.PropagatedContingency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1591,10 +1591,10 @@ void testSwitchContingency() {

// post-contingency tests
PostContingencyResult postContingencyResult = getPostContingencyResult(result, "C");
assertEquals(3.912, postContingencyResult.getNetworkResult().getBranchResult("L1").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(-3.895, postContingencyResult.getNetworkResult().getBranchResult("L1").getP2(), LoadFlowAssert.DELTA_POWER);
assertEquals(603.769, postContingencyResult.getNetworkResult().getBranchResult("L2").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(-596.104, postContingencyResult.getNetworkResult().getBranchResult("L2").getP2(), LoadFlowAssert.DELTA_POWER);
assertEquals(0.099, postContingencyResult.getNetworkResult().getBranchResult("L1").getP1(), LoadFlowAssert.DELTA_POWER);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I have changed minP and maxP.

assertEquals(-0.083, postContingencyResult.getNetworkResult().getBranchResult("L1").getP2(), LoadFlowAssert.DELTA_POWER);
assertEquals(607.682, postContingencyResult.getNetworkResult().getBranchResult("L2").getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(-599.918, postContingencyResult.getNetworkResult().getBranchResult("L2").getP2(), LoadFlowAssert.DELTA_POWER);
}

@Test
Expand Down Expand Up @@ -2258,4 +2258,68 @@ void testSaDcPhaseTapChangerTapPositionAction() {
assertEquals(network.getLine("S_SO_2").getTerminal1().getP(), brRel.getP1(), LoadFlowAssert.DELTA_POWER);
assertEquals(network.getBranch("S_SO_2").getTerminal2().getP(), brRel.getP2(), LoadFlowAssert.DELTA_POWER);
}

@Test
void testBusBarSectionContingency() {
Network network = createNodeBreakerNetwork();

LoadFlowParameters lfParameters = new LoadFlowParameters();
setSlackBusId(lfParameters, "VL1_1");
SecurityAnalysisParameters securityAnalysisParameters = new SecurityAnalysisParameters();
securityAnalysisParameters.setLoadFlowParameters(lfParameters);

List<Contingency> contingencies = Stream.of("BBS1")
.map(id -> new Contingency(id, new BusbarSectionContingency(id)))
.collect(Collectors.toList());

List<StateMonitor> monitors = createAllBranchesMonitors(network);

SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters);

NetworkResult preContingencyNetworkResult = result.getPreContingencyResult().getNetworkResult();
assertEquals(446.765, preContingencyNetworkResult.getBranchResult("L1").getI1(), LoadFlowAssert.DELTA_I);
assertEquals(446.765, preContingencyNetworkResult.getBranchResult("L2").getI1(), LoadFlowAssert.DELTA_I);

assertEquals(945.514, getPostContingencyResult(result, "BBS1").getNetworkResult().getBranchResult("L2").getI1(), LoadFlowAssert.DELTA_I);
assertNull(getPostContingencyResult(result, "BBS1").getNetworkResult().getBranchResult("L1"));

OpenSecurityAnalysisParameters openSecurityAnalysisParameters = new OpenSecurityAnalysisParameters();
openSecurityAnalysisParameters.setContingencyPropagation(false);
securityAnalysisParameters.addExtension(OpenSecurityAnalysisParameters.class, openSecurityAnalysisParameters);

SecurityAnalysisResult result2 = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters);

NetworkResult preContingencyNetworkResult2 = result2.getPreContingencyResult().getNetworkResult();
assertEquals(446.765, preContingencyNetworkResult2.getBranchResult("L1").getI1(), LoadFlowAssert.DELTA_I);
assertEquals(446.765, preContingencyNetworkResult2.getBranchResult("L2").getI1(), LoadFlowAssert.DELTA_I);

assertEquals(945.514, getPostContingencyResult(result2, "BBS1").getNetworkResult().getBranchResult("L2").getI1(), LoadFlowAssert.DELTA_I);
assertNull(getPostContingencyResult(result2, "BBS1").getNetworkResult().getBranchResult("L1"));
}

@Test
void testDcBusBarSectionContingency() {
Network network = createNodeBreakerNetwork();

LoadFlowParameters lfParameters = new LoadFlowParameters();
lfParameters.setDc(true);
setSlackBusId(lfParameters, "VL1_1");
SecurityAnalysisParameters securityAnalysisParameters = new SecurityAnalysisParameters();
securityAnalysisParameters.setLoadFlowParameters(lfParameters);

List<Contingency> contingencies = Stream.of("BBS1")
.map(id -> new Contingency(id, new BusbarSectionContingency(id)))
.collect(Collectors.toList());

List<StateMonitor> monitors = createAllBranchesMonitors(network);

SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, monitors, securityAnalysisParameters);

NetworkResult preContingencyNetworkResult = result.getPreContingencyResult().getNetworkResult();
assertEquals(433.012, preContingencyNetworkResult.getBranchResult("L1").getI1(), LoadFlowAssert.DELTA_I);
assertEquals(433.012, preContingencyNetworkResult.getBranchResult("L2").getI1(), LoadFlowAssert.DELTA_I);

assertEquals(866.025, getPostContingencyResult(result, "BBS1").getNetworkResult().getBranchResult("L2").getI1(), LoadFlowAssert.DELTA_I);
assertEquals(Double.NaN, getPostContingencyResult(result, "BBS1").getNetworkResult().getBranchResult("L1").getI1(), LoadFlowAssert.DELTA_I);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import com.powsybl.sensitivity.*;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.CompletionException;
import java.util.stream.Collectors;

Expand Down