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

Bus connection status representation bug #521

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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 @@ -237,9 +237,10 @@ private FeederNode createFeederBranchNode(VoltageLevelGraph graph, Branch<?> bra
equipmentId = branch.getId();
NodeSide s = NodeSide.valueOf(side.name());
Branch.Side otherSide = side == Branch.Side.ONE ? Branch.Side.TWO : Branch.Side.ONE;

VoltageLevel vlOtherSide = branch.getTerminal(otherSide).getVoltageLevel();
return NodeFactory.createFeederBranchNode(graph, nodeId, equipmentNameOrId, equipmentId, componentTypeName, s,
new VoltageLevelInfos(vlOtherSide.getId(), vlOtherSide.getNameOrId(), vlOtherSide.getNominalV()));
new VoltageLevelInfos(vlOtherSide.getId(), vlOtherSide.getNameOrId(), vlOtherSide.getNominalV()), !branch.getTerminal(side).isConnected());
}

private FeederNode createFeederVscNode(VoltageLevelGraph graph, HvdcConverterStation<?> hvdcStation) {
Expand All @@ -248,8 +249,8 @@ private FeederNode createFeederVscNode(VoltageLevelGraph graph, HvdcConverterSta
.map(otherStation -> otherStation.getTerminal().getVoltageLevel())
.map(otherVl -> new VoltageLevelInfos(otherVl.getId(), otherVl.getNameOrId(), otherVl.getNominalV()))
.map(otherVlInfo -> NodeFactory.createVscConverterStation(graph, hvdcStation.getId(), hvdcStation.getNameOrId(), hvdcStation.getHvdcLine().getId(),
hvdcStation.getHvdcLine().getConverterStation1() == hvdcStation ? NodeSide.ONE : NodeSide.TWO, otherVlInfo))
.orElseGet(() -> NodeFactory.createVscConverterStationInjection(graph, hvdcStation.getId(), hvdcStation.getNameOrId()));
hvdcStation.getHvdcLine().getConverterStation1() == hvdcStation ? NodeSide.ONE : NodeSide.TWO, otherVlInfo, !hvdcStation.getTerminal().isConnected()))
.orElseGet(() -> NodeFactory.createVscConverterStationInjection(graph, hvdcStation.getId(), hvdcStation.getNameOrId(), !hvdcStation.getTerminal().isConnected()));
}

private Node createInternal2wtSideNode(VoltageLevelGraph graph, TwoWindingsTransformer branch, Branch.Side side) {
Expand All @@ -264,17 +265,18 @@ private FeederNode createFeeder2wtNode(VoltageLevelGraph graph, TwoWindingsTrans
VoltageLevel vlOtherSide = branch.getTerminal(otherSide).getVoltageLevel();
VoltageLevelInfos otherSideVoltageLevelInfos = new VoltageLevelInfos(vlOtherSide.getId(), vlOtherSide.getNameOrId(), vlOtherSide.getNominalV());

boolean disconnected = !branch.getTerminal(side).isConnected();
if (graph.isForVoltageLevelDiagram() && isNotInternalToVoltageLevel(branch)) {
if (!branch.hasPhaseTapChanger()) {
return NodeFactory.createFeeder2WTNode(graph, id, name, equipmentId, NodeSide.valueOf(side.name()), otherSideVoltageLevelInfos);
return NodeFactory.createFeeder2WTNode(graph, id, name, equipmentId, NodeSide.valueOf(side.name()), otherSideVoltageLevelInfos, disconnected);
} else {
return NodeFactory.createFeeder2WTNodeWithPhaseShifter(graph, id, name, equipmentId, NodeSide.valueOf(side.name()), otherSideVoltageLevelInfos);
return NodeFactory.createFeeder2WTNodeWithPhaseShifter(graph, id, name, equipmentId, NodeSide.valueOf(side.name()), otherSideVoltageLevelInfos, disconnected);
}
} else {
if (!branch.hasPhaseTapChanger()) {
return NodeFactory.createFeeder2WTLegNode(graph, id, name, equipmentId, NodeSide.valueOf(side.name()));
return NodeFactory.createFeeder2WTLegNode(graph, id, name, equipmentId, NodeSide.valueOf(side.name()), disconnected);
} else {
return NodeFactory.createFeeder2WTLegNodeWithPhaseShifter(graph, id, name, equipmentId, NodeSide.valueOf(side.name()));
return NodeFactory.createFeeder2WTLegNodeWithPhaseShifter(graph, id, name, equipmentId, NodeSide.valueOf(side.name()), disconnected);
}
}
}
Expand Down Expand Up @@ -319,58 +321,60 @@ NodeSide.TWO, createVoltageLevelInfos(transformer.getLeg2().getTerminal()),
// create first other leg feeder node
String firstOtherLegNodeId = transformer.getId() + "_" + firstOtherLegSide.name();
FeederNode firstOtherLegNode = NodeFactory.createFeeder3WTLegNodeForVoltageLevelDiagram(graph, firstOtherLegNodeId, transformer.getNameOrId(),
transformer.getId(), firstOtherLegSide, voltageLevelInfosBySide.get(firstOtherLegSide));
transformer.getId(), firstOtherLegSide, voltageLevelInfosBySide.get(firstOtherLegSide), false);

// create second other leg feeder node
String secondOtherLegNodeId = transformer.getId() + "_" + secondOtherLegSide.name();
FeederNode secondOtherLegNode = NodeFactory.createFeeder3WTLegNodeForVoltageLevelDiagram(graph, secondOtherLegNodeId, transformer.getNameOrId(),
transformer.getId(), secondOtherLegSide, voltageLevelInfosBySide.get(secondOtherLegSide));
transformer.getId(), secondOtherLegSide, voltageLevelInfosBySide.get(secondOtherLegSide), false);

// create middle node
Middle3WTNode middleNode = NodeFactory.createMiddle3WTNode(graph, transformer.getId(), transformer.getNameOrId(),
vlLegSide, firstOtherLegNode, secondOtherLegNode,
Middle3WTNode middleNode = NodeFactory.createMiddle3WTNode(graph, "MIDDLE_" + transformer.getId() + "_" + side.name(), transformer.getNameOrId(), transformer.getId(),
vlLegSide, firstOtherLegNode,
secondOtherLegNode,
voltageLevelInfosBySide.get(NodeSide.ONE),
voltageLevelInfosBySide.get(NodeSide.TWO),
voltageLevelInfosBySide.get(NodeSide.THREE));
voltageLevelInfosBySide.get(NodeSide.THREE),
connectedToBus3WT(transformer.getTerminal(ThreeWindingsTransformer.Side.ONE), transformer.getTerminal(ThreeWindingsTransformer.Side.TWO), transformer.getTerminal(ThreeWindingsTransformer.Side.THREE)));

add3wtFeeder(middleNode, firstOtherLegNode, secondOtherLegNode, transformer.getTerminal(side));
} else {
// in substation diagram, we only represent the leg node within the voltage level (3wt node will be on the snake line)
String id = transformer.getId() + "_" + side.name();
FeederNode legNode = NodeFactory.createFeeder3WTLegNodeForSubstationDiagram(graph, id, transformer.getNameOrId(), transformer.getId(),
NodeSide.valueOf(side.name()));
NodeSide.valueOf(side.name()), !transformer.getTerminal(side).isConnected());

addTerminalNode(legNode, transformer.getTerminal(side));
}
}

@Override
public void visitLoad(Load load) {
addTerminalNode(NodeFactory.createLoad(graph, load.getId(), load.getNameOrId()), load.getTerminal());
addTerminalNode(NodeFactory.createLoad(graph, load.getId(), load.getNameOrId(), !load.getTerminal().isConnected()), load.getTerminal());
}

@Override
public void visitGenerator(Generator generator) {
addTerminalNode(NodeFactory.createGenerator(graph, generator.getId(), generator.getNameOrId()), generator.getTerminal());
addTerminalNode(NodeFactory.createGenerator(graph, generator.getId(), generator.getNameOrId(), !generator.getTerminal().isConnected()), generator.getTerminal());
}

@Override
public void visitBattery(Battery battery) {
addTerminalNode(NodeFactory.createBattery(graph, battery.getId(), battery.getNameOrId()), battery.getTerminal());
addTerminalNode(NodeFactory.createBattery(graph, battery.getId(), battery.getNameOrId(), !battery.getTerminal().isConnected()), battery.getTerminal());
}

@Override
public void visitShuntCompensator(ShuntCompensator sc) {
FeederNode feederNode = isCapacitor(sc)
? NodeFactory.createCapacitor(graph, sc.getId(), sc.getNameOrId())
: NodeFactory.createInductor(graph, sc.getId(), sc.getNameOrId());
? NodeFactory.createCapacitor(graph, sc.getId(), sc.getNameOrId(), !sc.getTerminal().isConnected())
: NodeFactory.createInductor(graph, sc.getId(), sc.getNameOrId(), !sc.getTerminal().isConnected());
addTerminalNode(feederNode, sc.getTerminal());
}

@Override
public void visitDanglingLine(DanglingLine dl) {
if (!dl.isPaired()) {
addTerminalNode(NodeFactory.createDanglingLine(graph, dl.getId(), dl.getNameOrId()), dl.getTerminal());
addTerminalNode(NodeFactory.createDanglingLine(graph, dl.getId(), dl.getNameOrId(), !dl.getTerminal().isConnected()), dl.getTerminal());
} else {
dl.getTieLine().ifPresent(tieLine -> visitTieLine(tieLine, dl, graph));
}
Expand All @@ -389,7 +393,7 @@ public void visitHvdcConverterStation(HvdcConverterStation<?> converterStation)

@Override
public void visitStaticVarCompensator(StaticVarCompensator svc) {
addTerminalNode(NodeFactory.createStaticVarCompensator(graph, svc.getId(), svc.getNameOrId()), svc.getTerminal());
addTerminalNode(NodeFactory.createStaticVarCompensator(graph, svc.getId(), svc.getNameOrId(), !svc.getTerminal().isConnected()), svc.getTerminal());
}

@Override
Expand Down Expand Up @@ -669,8 +673,13 @@ private void add2wtEdges(VoltageLevelGraph graph, List<TwoWindingsTransformer> t
for (TwoWindingsTransformer transfo : twoWindingsTransformers) {
Node n1 = graph.getNode(transfo.getId() + "_" + Branch.Side.ONE);
Node n2 = graph.getNode(transfo.getId() + "_" + Branch.Side.TWO);
Map<String, Boolean> connectionToBus = new HashMap<>();
Terminal terminal1 = transfo.getTerminal1();
Terminal terminal2 = transfo.getTerminal2();
connectionToBus.put(terminal1.getBusBreakerView().getConnectableBus().getId(), terminal1.isConnected());
connectionToBus.put(terminal2.getBusBreakerView().getConnectableBus().getId(), terminal2.isConnected());
NodeFactory.createInternal2WTNode(graph, transfo.getId(), transfo.getNameOrId(),
n1, n2, transfo.hasPhaseTapChanger());
n1, n2, transfo.hasPhaseTapChanger(), connectionToBus);
}
}

Expand Down Expand Up @@ -709,11 +718,20 @@ private void add3wtEdges(BaseGraph graph, List<ThreeWindingsTransformer> threeWi
return (FeederNode) graph.getVoltageLevel(vlId).getNode(idLeg);
}).collect(Collectors.toList());

NodeFactory.createMiddle3WTNode(graph, transfo.getId(), transfo.getNameOrId(),
feederNodes.get(0), feederNodes.get(1), feederNodes.get(2));
NodeFactory.createMiddle3WTNode(graph, transfo.getId(), transfo.getNameOrId(), transfo.getId(), feederNodes.get(0), feederNodes.get(1), feederNodes.get(2),
connectedToBus3WT(transfo.getTerminal(ThreeWindingsTransformer.Side.ONE), transfo.getTerminal(ThreeWindingsTransformer.Side.TWO), transfo.getTerminal(ThreeWindingsTransformer.Side.THREE)));
});
}

private static Map<String, Boolean> connectedToBus3WT(Terminal terminal1, Terminal terminal2, Terminal terminal3) {
Map<String, Boolean> connectionToBus = new HashMap<>();
connectionToBus.put(terminal1.getBusBreakerView().getConnectableBus().getId(), terminal1.isConnected());
connectionToBus.put(terminal2.getBusBreakerView().getConnectableBus().getId(), terminal2.isConnected());
connectionToBus.put(terminal3.getBusBreakerView().getConnectableBus().getId(), terminal3.isConnected());
return connectionToBus;

}

private SwitchNode createSwitchNodeFromSwitch(VoltageLevelGraph graph, Switch aSwitch) {
Objects.requireNonNull(graph);
Objects.requireNonNull(aSwitch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void addVlBuilder(VoltageLevelRawBuilder vlBuilder) {
public Map<VoltageLevelRawBuilder, FeederNode> createLine(String id, VoltageLevelRawBuilder vl1, VoltageLevelRawBuilder vl2, int order1, int order2,
Direction direction1, Direction direction2) {
Map<VoltageLevelRawBuilder, FeederNode> feederLineNodes = new HashMap<>();
FeederNode feederLineNode1 = vl1.createFeederLineNode(id, vl2.getVoltageLevelInfos().getId(), ONE, order1, direction1);
FeederNode feederLineNode2 = vl2.createFeederLineNode(id, vl1.getVoltageLevelInfos().getId(), TWO, order2, direction2);
FeederNode feederLineNode1 = vl1.createFeederLineNode(id, vl2.getVoltageLevelInfos().getId(), ONE, order1, direction1, false);
FeederNode feederLineNode2 = vl2.createFeederLineNode(id, vl1.getVoltageLevelInfos().getId(), TWO, order2, direction2, false);
feederLineNodes.put(vl1, feederLineNode1);
feederLineNodes.put(vl2, feederLineNode2);
substationGraph.addLineEdge(id, feederLineNode1, feederLineNode2);
Expand All @@ -46,38 +46,43 @@ public Map<VoltageLevelRawBuilder, FeederNode> createLine(String id, VoltageLeve
}

public Map<VoltageLevelRawBuilder, FeederNode> createFeeder2WT(String id, VoltageLevelRawBuilder vl1, VoltageLevelRawBuilder vl2, int order1, int order2,
Direction direction1, Direction direction2) {
Direction direction1, Direction direction2, boolean disconnected1, boolean disconnected2) {
Map<VoltageLevelRawBuilder, FeederNode> f2WTNodes = new HashMap<>();
FeederNode feeder2WtNode1 = vl1.createFeeder2wtLegNode(id, ONE, order1, direction1);
FeederNode feeder2WTNode2 = vl2.createFeeder2wtLegNode(id, TWO, order2, direction2);
FeederNode feeder2WtNode1 = vl1.createFeeder2wtLegNode(id, ONE, order1, direction1, disconnected1);
FeederNode feeder2WTNode2 = vl2.createFeeder2wtLegNode(id, TWO, order2, direction2, disconnected2);
f2WTNodes.put(vl1, feeder2WtNode1);
f2WTNodes.put(vl2, feeder2WTNode2);
NodeFactory.createMiddle2WTNode(substationGraph, id, id, feeder2WtNode1, feeder2WTNode2, vl1.getVoltageLevelInfos(), vl2.getVoltageLevelInfos(), false);
return f2WTNodes;
}

public Map<VoltageLevelRawBuilder, FeederNode> createFeeder2WT(String id, VoltageLevelRawBuilder vl1, VoltageLevelRawBuilder vl2) {
return createFeeder2WT(id, vl1, vl2, 0, 0, null, null);
return createFeeder2WT(id, vl1, vl2, 0, 0, null, null, false, false);
}

public Map<VoltageLevelRawBuilder, FeederNode> createFeeder3WT(String id, VoltageLevelRawBuilder vl1, VoltageLevelRawBuilder vl2, VoltageLevelRawBuilder vl3,
int order1, int order2, int order3,
Direction direction1, Direction direction2, Direction direction3) {
int order1, int order2, int order3,
Direction direction1, Direction direction2, Direction direction3, boolean disconnected1, boolean disconnected2, boolean disconnected3) {
Map<VoltageLevelRawBuilder, FeederNode> f3WTNodes = new HashMap<>();
FeederNode feeder3WTNode1 = vl1.createFeeder3wtLegNode(id, ONE, order1, direction1);
FeederNode feeder3WTNode2 = vl2.createFeeder3wtLegNode(id, TWO, order2, direction2);
FeederNode feeder3WTNode3 = vl3.createFeeder3wtLegNode(id, THREE, order3, direction3);
FeederNode feeder3WTNode1 = vl1.createFeeder3wtLegNode(id, ONE, order1, direction1, disconnected1);
FeederNode feeder3WTNode2 = vl2.createFeeder3wtLegNode(id, TWO, order2, direction2, disconnected2);
FeederNode feeder3WTNode3 = vl3.createFeeder3wtLegNode(id, THREE, order3, direction3, disconnected3);
f3WTNodes.put(vl1, feeder3WTNode1);
f3WTNodes.put(vl2, feeder3WTNode2);
f3WTNodes.put(vl3, feeder3WTNode3);

Map<String, Boolean> connectionToBus = new HashMap<>();
connectionToBus.put("1", !disconnected1);
connectionToBus.put("2", !disconnected2);
connectionToBus.put("3", !disconnected3);

// creation of the middle node and the edges linking the transformer leg nodes to this middle node
NodeFactory.createMiddle3WTNode(substationGraph, id, id, feeder3WTNode1, feeder3WTNode2, feeder3WTNode3);
NodeFactory.createMiddle3WTNode(substationGraph, id, id, id, feeder3WTNode1, feeder3WTNode2, feeder3WTNode3, connectionToBus);

return f3WTNodes;
}

public Map<VoltageLevelRawBuilder, FeederNode> createFeeder3WT(String id, VoltageLevelRawBuilder vl1, VoltageLevelRawBuilder vl2, VoltageLevelRawBuilder vl3) {
return createFeeder3WT(id, vl1, vl2, vl3, 0, 0, 0, null, null, null);
return createFeeder3WT(id, vl1, vl2, vl3, 0, 0, 0, null, null, null, false, false, false);
}
}
Loading