Skip to content

Commit

Permalink
Add HDVC line management into ZoneGraph
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas ADAM <tadam@silicom.fr>
  • Loading branch information
tadam50 authored and flo-dup committed Jun 7, 2023
1 parent a7cea1c commit db75ac7
Show file tree
Hide file tree
Showing 5 changed files with 638 additions and 436 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public final class Networks {

private static final String SUBSTATION_1_ID = "Substation1";

private static final String SUBSTATION_2_ID = "Substation2";

private static final String VOLTAGELEVEL_ID = "VoltageLevel";

private static final String VOLTAGELEVEL_1_ID = "VoltageLevel1";
Expand Down Expand Up @@ -429,7 +431,7 @@ public static Network createNetworkWithHvdcLine() {
.setVoltageRegulatorOn(true)
.add();
Substation substation2 = network.newSubstation()
.setId("Substation2")
.setId(SUBSTATION_2_ID)
.setCountry(Country.FR)
.add();
VoltageLevel voltageLevel2 = substation2.newVoltageLevel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,23 +650,49 @@ private void addBranchEdges(Graph graph, List<? extends Branch<?>> branches) {
if (!linesIds.contains(branch.getId())) {
Terminal t1 = branch.getTerminal1();
Terminal t2 = branch.getTerminal2();

VoltageLevel vl1 = t1.getVoltageLevel();
VoltageLevel vl2 = t2.getVoltageLevel();

VoltageLevelGraph g1 = graph.getVoltageLevel(vl1.getId());
VoltageLevelGraph g2 = graph.getVoltageLevel(vl2.getId());

if (g1 != null && g2 != null) {
Node n1 = g1.getNode(branch.getId() + "_" + branch.getSide(t1).name());
Node n2 = g2.getNode(branch.getId() + "_" + branch.getSide(t2).name());
graph.addLineEdge(branch.getId(), n1, n2);
String nodeId1 = branch.getId() + "_" + branch.getSide(t1).name();
String nodeId2 = branch.getId() + "_" + branch.getSide(t2).name();
if (addLineEdge(graph, branch.getId(), t1, t2, nodeId1, nodeId2)) {
linesIds.add(branch.getId());
}
}
});
}

private void addHvdcLineEdges(Graph graph, List<HvdcLine> lines) {
Set<String> linesIds = new HashSet<>();
lines.forEach(line -> {
if (!linesIds.contains(line.getId())) {
HvdcConverterStation<?> cvs1 = line.getConverterStation1();
HvdcConverterStation<?> cvs2 = line.getConverterStation2();
Terminal t1 = cvs1.getTerminal();
Terminal t2 = cvs2.getTerminal();
String nodeId1 = cvs1.getId();
String nodeId2 = cvs2.getId();

if (addLineEdge(graph, line.getId(), t1, t2, nodeId1, nodeId2)) {
linesIds.add(line.getId());
}
}
});
}

private boolean addLineEdge(Graph graph, String lineId, Terminal t1, Terminal t2, String nodeId1, String nodeId2) {
VoltageLevel vl1 = t1.getVoltageLevel();
VoltageLevel vl2 = t2.getVoltageLevel();

VoltageLevelGraph g1 = graph.getVoltageLevel(vl1.getId());
VoltageLevelGraph g2 = graph.getVoltageLevel(vl2.getId());

boolean isNotNull = g1 != null && g2 != null;
if (isNotNull) {
Node n1 = g1.getNode(nodeId1);
Node n2 = g2.getNode(nodeId2);
graph.addLineEdge(lineId, n1, n2);
}
return isNotNull;
}

private void add2wtEdges(VoltageLevelGraph graph, List<TwoWindingsTransformer> twoWindingsTransformers) {
for (TwoWindingsTransformer transfo : twoWindingsTransformers) {
Node n1 = graph.getNode(transfo.getId() + "_" + Branch.Side.ONE);
Expand Down Expand Up @@ -772,5 +798,12 @@ private void buildZoneGraph(ZoneGraph zoneGraph, List<Substation> zone) {
.flatMap(voltageLevel -> voltageLevel.getConnectableStream(Line.class))
.filter(NetworkGraphBuilder::isNotInternalToSubstation)
.collect(Collectors.toList()));

// Add snake edges between different HVDC lines in the same zone
addHvdcLineEdges(zoneGraph, zone.stream().flatMap(Substation::getVoltageLevelStream)
.flatMap(voltageLevel -> voltageLevel.getConnectableStream(VscConverterStation.class))
.map(HvdcConverterStation::getHvdcLine)
.distinct()
.collect(Collectors.toList()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
package com.powsybl.sld.iidm;

import com.powsybl.diagram.test.Networks;
import com.powsybl.iidm.network.Bus;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.Substation;
import com.powsybl.iidm.network.TopologyKind;
import com.powsybl.iidm.network.*;
import com.powsybl.sld.builders.NetworkGraphBuilder;
import com.powsybl.sld.layout.*;
import com.powsybl.sld.model.graphs.ZoneGraph;
Expand Down Expand Up @@ -163,16 +160,44 @@ public static Network createDiamond() {
createLine(subJ10, subK10);
createLine(subK10, subD10);

// HDVCLine between A 230 & B 230
String vlId = String.format("%s %.0f", subA.getId(), 230.0);
String busId = String.format("%s %s", vlId, "Bus");
network.getVoltageLevel(vlId).newVscConverterStation()
.setId("Converter1")
.setConnectableBus(busId)
.setBus(busId)
.setLossFactor(0.011f)
.setVoltageSetpoint(405.0)
.setVoltageRegulatorOn(true)
.add();
vlId = String.format("%s %.0f", subB.getId(), 230.0);
busId = String.format("%s %s", vlId, "Bus");
network.getVoltageLevel(vlId).newVscConverterStation()
.setId("Converter2")
.setConnectableBus(busId)
.setBus(busId)
.setLossFactor(0.011f)
.setReactivePowerSetpoint(123)
.setVoltageRegulatorOn(false)
.add();
network.newHvdcLine()
.setId("HvdcLine")
.setConverterStationId1("Converter1")
.setConverterStationId2("Converter2")
.setR(1)
.setNominalV(400)
.setConvertersMode(HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER)
.setMaxP(300.0)
.setActivePowerSetpoint(280)
.add();

return network;
}

@Test
void testHorizontal() {
// build zone graph
// network = NetworkFactory.createTestCase11Network();
// List<String> zone = Arrays.asList("subst");
// ZoneGraph g = new NetworkGraphBuilder(network).buildZoneGraph(zone);

network = createDiamond();
List<String> zone = Arrays.asList("A", "B", "C", "D", "E");
ZoneGraph g = new NetworkGraphBuilder(network).buildZoneGraph(zone);
Expand Down
Loading

0 comments on commit db75ac7

Please sign in to comment.