Skip to content

Commit

Permalink
add current violation to busbar section
Browse files Browse the repository at this point in the history
Signed-off-by: jamal-khey <[email protected]>
  • Loading branch information
jamal-khey committed Sep 18, 2024
1 parent 621570f commit 9768bfd
Show file tree
Hide file tree
Showing 13 changed files with 660 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public abstract class AbstractTest {

protected boolean debugSvg = true;
protected boolean debugSvg = false;
protected boolean overrideTestReferences = false;

private SvgParameters svgParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.powsybl.sld.model.graphs.*;
import com.powsybl.sld.model.nodes.*;
import com.powsybl.sld.postprocessor.GraphBuildPostProcessor;
import com.powsybl.sld.util.LimitViolationUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -222,7 +223,7 @@ protected abstract void add3wtFeeder(Middle3WTNode middleNode, FeederNode firstO
private FeederNode createFeederLineNode(VoltageLevelGraph graph, Line line, TwoSides side) {
FeederNode feederNode = createFeederBranchNode(graph, line, side, LINE);
if (line.isOverloaded()) {
feederNode.setOverload(true);
feederNode.setLimitExceeded(true);
}
return feederNode;
}
Expand Down Expand Up @@ -286,7 +287,7 @@ private FeederNode createFeeder2wtNode(VoltageLevelGraph graph, TwoWindingsTrans
}

if (branch.isOverloaded()) {
transformerNode.setOverload(true);
transformerNode.setLimitExceeded(true);
}
return transformerNode;
}
Expand Down Expand Up @@ -346,9 +347,9 @@ NodeSide.TWO, createVoltageLevelInfos(transformer.getLeg2().getTerminal()),
voltageLevelInfosBySide.get(NodeSide.THREE));

if (transformer.isOverloaded()) {
middleNode.setOverload(true);
firstOtherLegNode.setOverload(true);
secondOtherLegNode.setOverload(true);
middleNode.setLimitExceeded(true);
firstOtherLegNode.setLimitExceeded(true);
secondOtherLegNode.setLimitExceeded(true);
}
add3wtFeeder(middleNode, firstOtherLegNode, secondOtherLegNode, transformer.getTerminal(side));
} else {
Expand All @@ -357,7 +358,7 @@ NodeSide.TWO, createVoltageLevelInfos(transformer.getLeg2().getTerminal()),
FeederNode legNode = NodeFactory.createFeeder3WTLegNodeForSubstationDiagram(graph, id, transformer.getNameOrId(), transformer.getId(),
NodeSide.valueOf(side.name()));
if (transformer.isOverloaded()) {
legNode.setOverload(true);
legNode.setLimitExceeded(true);
}
addTerminalNode(legNode, transformer.getTerminal(side));
}
Expand Down Expand Up @@ -520,7 +521,10 @@ protected void add3wtFeeder(Middle3WTNode middleNode, FeederNode firstOtherLegNo
@Override
public void visitBusbarSection(BusbarSection busbarSection) {
BusbarSectionPosition extension = busbarSection.getExtension(BusbarSectionPosition.class);
//check if we have a constraint on the busbar section
boolean isConstrained = LimitViolationUtil.detectBusViolations(busbarSection);
BusNode node = NodeFactory.createBusNode(graph, busbarSection.getId(), busbarSection.getNameOrId());
node.setLimitExceeded(isConstrained);
if (extension != null) {
node.setBusBarIndexSectionIndex(extension.getBusbarIndex(), extension.getSectionIndex());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ private void insertNode(Node nodeA, Node nodeToInsert, Node nodeB) {
addEdge(nodeToInsert, nodeA);
}

if (nodeA.isOverloaded() || nodeB.isOverloaded()) {
nodeToInsert.setOverload(true);
if (nodeA.isLimitExceeded() || nodeB.isLimitExceeded()) {
nodeToInsert.setLimitExceeded(true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public abstract class AbstractNode implements Node {

private Orientation orientation;

private boolean isOverload;
private boolean isLimitExceeded;

/**
* Constructor
Expand All @@ -56,7 +56,7 @@ protected AbstractNode(NodeType type, String id, String componentType, boolean f
this.id = Objects.requireNonNull(id);
this.componentType = Objects.requireNonNull(componentType);
this.fictitious = fictitious;
this.isOverload = false;
this.isLimitExceeded = false;
setOrientation(defaultOrientation());
}

Expand Down Expand Up @@ -196,13 +196,13 @@ public void setOrientation(Orientation orientation) {
}

@Override
public boolean isOverloaded() {
return isOverload;
public boolean isLimitExceeded() {
return isLimitExceeded;
}

@Override
public void setOverload(boolean isOverload) {
this.isOverload = isOverload;
public void setLimitExceeded(boolean isLimitExceeded) {
this.isLimitExceeded = isLimitExceeded;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<Node> getNodes() {
}

public boolean isOverloaded() {
return getNode1().isOverloaded() || getNode2().isOverloaded();
return getNode1().isLimitExceeded() || getNode2().isLimitExceeded();
}

public void writeJson(JsonGenerator generator) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ enum NodeType {

Direction getDirection();

boolean isOverloaded();
boolean isLimitExceeded();

void setOverload(boolean isOverloaded);
void setLimitExceeded(boolean isLimitExceeded);

void setDirection(Direction direction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public List<String> getNodeStyles(VoltageLevelGraph graph, Node node, ComponentL
}

// if (node instanceof EquipmentNode equipmentNode && equipmentNode.isOverloaded()) {
if (node.isOverloaded()) {
if (node.isLimitExceeded()) {
return List.of(StyleClassConstants.OVERLOAD_STYLE_CLASS);
}
return Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2019, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.sld.util;

import com.powsybl.iidm.network.BusbarSection;

/**
* @author jamal kheyyad {@literal <jamal.kheyyad at rte-international.com>}
*/
public final class LimitViolationUtil {
private LimitViolationUtil() {
}

// this code is an adaptation of the code from the OpenLoadFlow project
// see the original code at
// LimitViolationManager.java
public static boolean detectBusViolations(BusbarSection bus) {
double nominalV = bus.getTerminal().getVoltageLevel().getNominalV();
double busV = bus.getV();
double highVoltageLimit = bus.getTerminal().getVoltageLevel().getHighVoltageLimit() / nominalV;
double lowVoltageLimit = bus.getTerminal().getVoltageLevel().getLowVoltageLimit() / nominalV;
if (!Double.isNaN(highVoltageLimit) && busV > highVoltageLimit) {
return true;
}
if (!Double.isNaN(lowVoltageLimit) && busV < lowVoltageLimit) {
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
import com.powsybl.iidm.network.test.ThreeWindingsTransformerNetworkFactory;
import com.powsybl.sld.builders.NetworkGraphBuilder;
import com.powsybl.sld.model.graphs.VoltageLevelGraph;
import com.powsybl.sld.svg.styles.AnimatedFeederInfoStyleProvider;
import com.powsybl.sld.svg.styles.StyleProvider;
import com.powsybl.sld.svg.styles.StyleProvidersList;
import com.powsybl.sld.svg.styles.iidm.HighlightLineStateStyleProvider;
import com.powsybl.sld.svg.styles.iidm.TopologicalStyleProvider;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -25,6 +30,11 @@ public void setUp() {
// initialization of networks and graph builder done in each test
}

@Override
public StyleProvider getDefaultDiagramStyleProvider() {
return new StyleProvidersList(new TopologicalStyleProvider(network), new HighlightLineStateStyleProvider(network), new AnimatedFeederInfoStyleProvider(500, 1000));
}

@Test
void testLineOverLoad() {
network = Networks.createNetworkWithLine();
Expand Down Expand Up @@ -67,4 +77,17 @@ void test3WTOverLoad() {
assertEquals(toString("/Test3WTFeederInfoOverLoad.svg"), toSVG(g, "/Test3WTFeederInfoOverLoad.svg"));
}

@Test
void testBusLimitViolation() {
network = Networks.createComplexExternCellOnFourSections();
network.getBusbarSection("bbs3").getTerminal().getBusView().getBus().setV(390);
network.getBusbarSection("bbs3").getTerminal().getVoltageLevel().setHighVoltageLimit(1);
network.getBusbarSection("bbs3").getTerminal().getVoltageLevel().setHighVoltageLimit(0);

graphBuilder = new NetworkGraphBuilder(network);
VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph("vl");
voltageLevelGraphLayout(g);
assertEquals(toString("/TestBusBarHightlight.svg"), toSVG(g, "/TestBusBarHightlight.svg"));
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9768bfd

Please sign in to comment.