Skip to content

Commit

Permalink
debugUnstack (#156)
Browse files Browse the repository at this point in the history
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
  • Loading branch information
BenoitJeanson authored Aug 25, 2020
1 parent db8e24e commit 92bbbbc
Show file tree
Hide file tree
Showing 82 changed files with 9,459 additions and 4,096 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.powsybl.sld.cgmes.dl.conversion.CgmesDLExporter;
import com.powsybl.sld.cgmes.dl.conversion.CgmesDLUtils;
import com.powsybl.sld.layout.*;
import com.powsybl.sld.layout.positionbyclustering.PositionByClustering;
import com.powsybl.sld.layout.positionfromextension.PositionFromExtension;
import com.powsybl.tools.Command;
import com.powsybl.tools.Tool;
import com.powsybl.tools.ToolOptions;
Expand Down Expand Up @@ -46,7 +48,7 @@ public class LayoutToCgmesDlExporterTool implements Tool {

private final Map<String, VoltageLevelLayoutFactory> voltageLevelsLayouts
= ImmutableMap.of("auto-extensions", new PositionVoltageLevelLayoutFactory(new PositionFromExtension()),
DEFAULT_VOLTAGE_LAYOUT, new PositionVoltageLevelLayoutFactory(new PositionFree()));
DEFAULT_VOLTAGE_LAYOUT, new PositionVoltageLevelLayoutFactory(new PositionByClustering()));

private final Map<String, SubstationLayoutFactory> substationsLayouts
= ImmutableMap.of(DEFAULT_SUBSTATION_LAYOUT, new HorizontalSubstationLayoutFactory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.powsybl.sld.cgmes.dl.conversion.CgmesDLUtils;
import com.powsybl.sld.cgmes.dl.iidm.extensions.*;
import com.powsybl.sld.layout.*;
import com.powsybl.sld.layout.positionbyclustering.PositionByClustering;
import com.powsybl.sld.model.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -45,7 +46,7 @@ public LayoutToCgmesExtensionsConverter(SubstationLayoutFactory sFactory, Voltag
}

public LayoutToCgmesExtensionsConverter() {
this(new HorizontalSubstationLayoutFactory(), new PositionVoltageLevelLayoutFactory(new PositionFree()), new LayoutParameters(), true);
this(new HorizontalSubstationLayoutFactory(), new PositionVoltageLevelLayoutFactory(new PositionByClustering()), new LayoutParameters(), true);
}

private boolean isLineNode(Node node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer,

Map<FeederWithSideNode.Side, VoltageLevelInfos> voltageLevelInfosBySide
= ImmutableMap.of(FeederWithSideNode.Side.ONE, createVoltageLevelInfos(transformer.getLeg1().getTerminal()),
FeederWithSideNode.Side.TWO, createVoltageLevelInfos(transformer.getLeg2().getTerminal()),
FeederWithSideNode.Side.THREE, createVoltageLevelInfos(transformer.getLeg3().getTerminal()));
FeederWithSideNode.Side.TWO, createVoltageLevelInfos(transformer.getLeg2().getTerminal()),
FeederWithSideNode.Side.THREE, createVoltageLevelInfos(transformer.getLeg3().getTerminal()));

// create middle node
Middle3WTNode middleNode = new Middle3WTNode(graph, transformer.getId() + "_fictif",
voltageLevelInfosBySide.get(FeederWithSideNode.Side.ONE),
voltageLevelInfosBySide.get(FeederWithSideNode.Side.TWO),
voltageLevelInfosBySide.get(FeederWithSideNode.Side.THREE));
voltageLevelInfosBySide.get(FeederWithSideNode.Side.ONE),
voltageLevelInfosBySide.get(FeederWithSideNode.Side.TWO),
voltageLevelInfosBySide.get(FeederWithSideNode.Side.THREE));

FeederWithSideNode.Side firstOtherLegSide;
FeederWithSideNode.Side secondOtherLegSide;
Expand Down Expand Up @@ -553,19 +553,10 @@ private void addSnakeLines(SubstationGraph graph, Substation substation) {
Node n2 = g2.getNode(id2);

// creation of the middle node and the edges linking the transformer leg nodes to this middle node
String idMiddleNode = n1.getId() + "_" + n2.getId();
VoltageLevelInfos voltageLevelInfos1 = new VoltageLevelInfos(vl1.getId(), vl1.getNameOrId(), vl1.getNominalV());
VoltageLevelInfos voltageLevelInfos2 = new VoltageLevelInfos(vl2.getId(), vl2.getNameOrId(), vl2.getNominalV());

Middle2WTNode middleNode = new Middle2WTNode(null, idMiddleNode, voltageLevelInfos1, voltageLevelInfos2);

TwtEdge edge1 = graph.addEdge(n1, middleNode);
TwtEdge edge2 = graph.addEdge(middleNode, n2);

middleNode.addAdjacentEdge(edge1);
middleNode.addAdjacentEdge(edge2);

graph.addMultiTermNode(middleNode);
graph.addMultiTermNode(Middle2WTNode.create(graph, n1, n2, voltageLevelInfos1, voltageLevelInfos2));
}

// Three windings transformer
Expand All @@ -592,22 +583,11 @@ private void addSnakeLines(SubstationGraph graph, Substation substation) {
Node n3 = g3.getNode(id3);

// creation of the middle node and the edges linking the transformer leg nodes to this middle node
String idMiddleNode = n1.getId() + "_" + n2.getId() + "_" + n3.getId();
VoltageLevelInfos voltageLevelInfos1 = new VoltageLevelInfos(vl1.getId(), vl1.getNameOrId(), vl1.getNominalV());
VoltageLevelInfos voltageLevelInfos2 = new VoltageLevelInfos(vl2.getId(), vl2.getNameOrId(), vl2.getNominalV());
VoltageLevelInfos voltageLevelInfos3 = new VoltageLevelInfos(vl3.getId(), vl3.getNameOrId(), vl3.getNominalV());

Middle3WTNode middleNode = new Middle3WTNode(null, idMiddleNode, voltageLevelInfos1, voltageLevelInfos2, voltageLevelInfos3);

TwtEdge edge1 = graph.addEdge(n1, middleNode);
TwtEdge edge2 = graph.addEdge(middleNode, n2);
TwtEdge edge3 = graph.addEdge(middleNode, n3);

middleNode.addAdjacentEdge(edge1);
middleNode.addAdjacentEdge(edge2);
middleNode.addAdjacentEdge(edge3);

graph.addMultiTermNode(middleNode);
graph.addMultiTermNode(Middle3WTNode.create(graph, n1, n2, n3, voltageLevelInfos1, voltageLevelInfos2, voltageLevelInfos3));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

import com.powsybl.sld.model.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.*;

import static com.powsybl.sld.model.FeederWithSideNode.Side.*;

Expand Down Expand Up @@ -207,7 +204,7 @@ public Map<VoltageLevelBuilder, Feeder2WTLegNode> createFeeder2WT(String id, Vol
Feeder2WTLegNode feeder2WTNode2 = vl2.createFeeder2wtLegNode(id, TWO, order2, direction2);
f2WTNodes.put(vl1, feeder2WtNode1);
f2WTNodes.put(vl2, feeder2WTNode2);
ssGraph.addEdge(feeder2WtNode1, feeder2WTNode2);
ssGraph.addMultiTermNode(Middle2WTNode.create(ssGraph, feeder2WtNode1, feeder2WTNode2, vl1.voltageLevelInfos, vl2.voltageLevelInfos));
return f2WTNodes;
}

Expand All @@ -227,19 +224,8 @@ public Map<VoltageLevelBuilder, Feeder3WTLegNode> createFeeder3WT(String id, Vol
f3WTNodes.put(vl3, feeder3WTNode3);

// creation of the middle node and the edges linking the transformer leg nodes to this middle node
String idMiddleNode = feeder3WTNode1.getId() + "_" + feeder3WTNode2.getId() + "_" + feeder3WTNode3.getId();

Middle3WTNode middleNode = new Middle3WTNode(null, idMiddleNode, feeder3WTNode1.getGraph().getVoltageLevelInfos(), feeder3WTNode2.getGraph().getVoltageLevelInfos(), feeder3WTNode3.getGraph().getVoltageLevelInfos());

TwtEdge edge1 = ssGraph.addEdge(feeder3WTNode1, middleNode);
TwtEdge edge2 = ssGraph.addEdge(middleNode, feeder3WTNode2);
TwtEdge edge3 = ssGraph.addEdge(middleNode, feeder3WTNode3);

middleNode.addAdjacentEdge(edge1);
middleNode.addAdjacentEdge(edge2);
middleNode.addAdjacentEdge(edge3);

ssGraph.addMultiTermNode(middleNode);
ssGraph.addMultiTermNode(Middle3WTNode.create(ssGraph, feeder3WTNode1, feeder3WTNode2, feeder3WTNode3,
vl1.voltageLevelInfos, vl2.voltageLevelInfos, vl3.voltageLevelInfos));

return f3WTNodes;
}
Expand All @@ -257,7 +243,9 @@ public Graph buildVoltageLevelGraph(String id,

public SubstationGraph buildSubstationGraph(String id,
boolean useName) {
return ssBuilders.get(id).getSsGraph();
SubstationGraph ssGraph = ssBuilders.get(id).getSsGraph();
ssGraph.getNodes().sort(Comparator.comparingDouble(g -> -g.getVoltageLevelInfos().getNominalVoltage()));
return ssGraph;
}

//TODO: buildZoneGraph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package com.powsybl.sld.layout;

import com.powsybl.sld.layout.positionfromextension.PositionFromExtension;
import com.powsybl.sld.layout.positionbyclustering.PositionByClustering;
import com.powsybl.sld.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -30,7 +32,7 @@ public BlockOrganizer() {
}

public BlockOrganizer(boolean stack) {
this(new PositionFree(), stack);
this(new PositionByClustering(), stack);
}

public BlockOrganizer(PositionFinder positionFinder) {
Expand Down Expand Up @@ -63,20 +65,14 @@ public void organize(Graph graph) {
if (stack) {
determineStackableBlocks(graph);
}
positionFinder.buildLayout(graph);

graph.getCells().stream()
.filter(c -> c.getType() == Cell.CellType.INTERN)
.forEach(c -> ((InternCell) c).postPositioningSettings());

SubSections subSections = new SubSections(graph);
subSections.handleSpanningBusBar();
LOGGER.debug("Subsections {}", subSections);
List<Subsection> subsections = positionFinder.buildLayout(graph);

graph.getCells().stream()
.filter(cell -> cell instanceof BusCell)
.forEach(cell -> ((BusCell) cell).blockSizing());
new BlockPositionner().determineBlockPositions(graph, subSections);

new BlockPositionner().determineBlockPositions(graph, subsections);
}

/**
Expand Down
Loading

0 comments on commit 92bbbbc

Please sign in to comment.