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 coupler detection bug #334

Merged
merged 3 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -153,8 +153,13 @@ private static PropagatedContingency create(Network network, Contingency conting

private static boolean isCoupler(Switch s) {
VoltageLevel.NodeBreakerView nbv = s.getVoltageLevel().getNodeBreakerView();
Connectable<?> c1 = nbv.getTerminal1(s.getId()).getConnectable();
Connectable<?> c2 = nbv.getTerminal2(s.getId()).getConnectable();
Terminal terminal1 = nbv.getTerminal1(s.getId());
Terminal terminal2 = nbv.getTerminal2(s.getId());
if (terminal1 == null || terminal2 == null) {
return false; // FIXME: this can be a coupler, a traverser could be used to detect it
}
Connectable<?> c1 = terminal1.getConnectable();
Connectable<?> c2 = terminal2.getConnectable();
return c1 != c2 && c1.getType() == ConnectableType.BUSBAR_SECTION && c2.getType() == ConnectableType.BUSBAR_SECTION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,14 @@ public static Network create() {
.setId("BBS2")
.setNode(1)
.add();
vl1.getNodeBreakerView().newDisconnector()
.setId("D")
.setNode1(0)
.setNode2(6)
.add();
vl1.getNodeBreakerView().newBreaker()
.setId("C")
.setNode1(0)
.setNode1(6)
.setNode2(1)
.add();
vl1.getNodeBreakerView().newBreaker()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@

import com.powsybl.commons.PowsyblException;
import com.powsybl.computation.local.LocalComputationManager;
import com.powsybl.contingency.Contingency;
import com.powsybl.contingency.ContingencyContext;
import com.powsybl.contingency.DanglingLineContingency;
import com.powsybl.contingency.LineContingency;
import com.powsybl.contingency.*;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory;
import com.powsybl.iidm.network.test.PhaseShifterTestCaseFactory;
import com.powsybl.loadflow.LoadFlowParameters;
import com.powsybl.openloadflow.network.DanglingLineFactory;
import com.powsybl.openloadflow.network.FourBusNetworkFactory;
import com.powsybl.openloadflow.network.HvdcNetworkFactory;
import com.powsybl.openloadflow.network.NodeBreakerNetworkFactory;
import com.powsybl.openloadflow.sensi.*;
import com.powsybl.openloadflow.util.LoadFlowAssert;
import com.powsybl.openloadflow.util.PropagatedContingency;
import com.powsybl.sensitivity.SensitivityAnalysisParameters;
import com.powsybl.sensitivity.SensitivityAnalysisResult;
import com.powsybl.sensitivity.SensitivityFactor;
Expand Down Expand Up @@ -775,4 +774,15 @@ void testDanglingLineSensi() {
result = sensiProvider.run(network, Collections.emptyList(), Collections.emptyList(), sensiParameters, factors);
assertEquals(0d, result.getValue(null, "l1", "dl1").getValue(), LoadFlowAssert.DELTA_POWER);
}

@Test
void testContingencyOnOpenLine() {
Network network = NodeBreakerNetworkFactory.create();
List<Contingency> contingencies = List.of(
new Contingency("c1", new BranchContingency("L1"))
);

List<PropagatedContingency> propagatedContingencies = PropagatedContingency.createListForSensitivityAnalysis(network, contingencies);
assertEquals(1, propagatedContingencies.size());
}
}