Skip to content

Commit

Permalink
[SLD] Add feeder node and library component for batteries (#511)
Browse files Browse the repository at this point in the history
* Add battery component in component libraries
* draw batteries in SLD
* update test references
* take batteries into consideration in VoltageLevelRawBuilder

Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com>
Co-authored-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: BenoitJeanson <benoit.jeanson@rte-france.com>
  • Loading branch information
2 people authored and BenoitJeanson committed May 2, 2023
1 parent eb81860 commit 4c0ddce
Show file tree
Hide file tree
Showing 72 changed files with 662 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ public void visitGenerator(Generator generator) {
addTerminalNode(NodeFactory.createGenerator(graph, generator.getId(), generator.getNameOrId()), generator.getTerminal());
}

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

@Override
public void visitShuntCompensator(ShuntCompensator sc) {
FeederNode feederNode = isCapacitor(sc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ public FeederNode createGenerator(String id, int order, Direction direction) {
return fn;
}

public FeederNode createBattery(String id) {
return createBattery(id, 0, null);
}

public FeederNode createBattery(String id, int order, Direction direction) {
FeederNode fn = NodeFactory.createBattery(voltageLevelGraph, id, id);
commonFeederSetting(fn, id, order, direction);
return fn;
}

public FeederNode createFeederLineNode(String id, String otherVlId, NodeSide side, int order, Direction direction) {
FeederNode fln = NodeFactory.createFeederLineNode(voltageLevelGraph, id + "_" + side, id, id, side, getVoltageLevelInfosFromId.apply(otherVlId));
commonFeederSetting(fln, id, order, direction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public final class ComponentTypeName {
public static final String BUSBAR_SECTION = "BUSBAR_SECTION";
public static final String BREAKER = "BREAKER";
public static final String DISCONNECTOR = "DISCONNECTOR";
public static final String BATTERY = "BATTERY";
public static final String BUS_CONNECTION = "BUS_CONNECTION";
public static final String GENERATOR = "GENERATOR";
public static final String LINE = "LINE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public static FeederNode createGenerator(VoltageLevelGraph graph, String id, Str
return createFeederInjectionNode(graph, id, name, ComponentTypeName.GENERATOR);
}

public static FeederNode createBattery(VoltageLevelGraph graph, String id, String name) {
return createFeederInjectionNode(graph, id, name, ComponentTypeName.BATTERY);
}

public static FeederNode createLoad(VoltageLevelGraph graph, String id, String name) {
return createFeederInjectionNode(graph, id, name, ComponentTypeName.LOAD);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.sld-wire {stroke: var(--sld-vl-color, #c80000); fill: none}
/* Stroke --sld-vl-color with fallback blue */
.sld-load {stroke: var(--sld-vl-color, blue); fill: none}
.sld-battery {stroke: var(--sld-vl-color, blue); fill: none}
.sld-generator {stroke: var(--sld-vl-color, blue); fill: none}
.sld-two-wt {stroke: var(--sld-vl-color, blue); fill: none}
.sld-three-wt {stroke: var(--sld-vl-color, blue); fill: none}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@
"fileName" : "load.svg"
} ],
"styleClass" : "sld-load"
}, {
"type" : "BATTERY",
"anchorPoints" : [ {
"x" : 0,
"y" : -4,
"orientation" : "VERTICAL"
}, {
"x" : 0,
"y" : 5,
"orientation" : "VERTICAL"
} ],
"size" : {
"width" : 16.0,
"height" : 10.0
},
"transformations" : {},
"subComponents" : [ {
"name" : "BATTERY",
"fileName" : "battery.svg"
} ],
"styleClass" : "sld-battery"
}, {
"type" : "GENERATOR",
"anchorPoints" : [ {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.sld-busbar-section {stroke: var(--sld-vl-color, black); stroke-width: 3; fill: none}
.sld-wire {stroke: var(--sld-vl-color, #c80000); fill: none}
.sld-load {fill: var(--sld-vl-color, blue)}
.sld-battery {fill: var(--sld-vl-color, blue)}
.sld-generator {fill: var(--sld-vl-color, blue)}
.sld-winding {fill: var(--sld-vl-color, blue)}
.sld-capacitor {fill: var(--sld-vl-color, blue)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,32 @@
],
"styleClass": "sld-load"
},
{
"type": "BATTERY",
"anchorPoints": [
{
"x": 0,
"y": -4.5,
"orientation": "VERTICAL"
},
{
"x": 0,
"y": 6,
"orientation": "VERTICAL"
}
],
"size": {
"width": 16.0,
"height": 12.0
},
"subComponents": [
{
"name": "BATTERY",
"fileName": "battery.svg"
}
],
"styleClass": "sld-battery"
},
{
"type": "GENERATOR",
"anchorPoints": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ protected static void createGenerator(VoltageLevel vl, String id, String name, S
addFeederPosition(gen, feederName, feederOrder, direction);
}

protected static void createBattery(VoltageLevel vl, String id, String name, String feederName, Integer feederOrder,
ConnectablePosition.Direction direction, int node,
double minP, double maxP,
double targetP, double targetQ) {
Battery battery = vl.newBattery()
.setId(id)
.setName(name)
.setNode(node)
.setMinP(minP)
.setMaxP(maxP)
.setTargetP(targetP)
.setTargetQ(targetQ)
.add();
addFeederPosition(battery, feederName, feederOrder, direction);
}

protected static void createShunt(VoltageLevel vl, String id, String name, String feederName, Integer feederOrder,
ConnectablePosition.Direction direction, int node,
double bPerSection, int maximumSectionCount, int currentSectionCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,4 +533,19 @@ public static Network createNetworkWithFlatSections() {
createSwitch(vl, "d223b", "d223b", SwitchKind.DISCONNECTOR, false, false, false, 9, 5);
return network;
}

public static Network createNetworkWithBatteries() {
Network network = Network.create("TestBatteries", "test");
Substation substation = createSubstation(network, "s", "s", Country.FR);
VoltageLevel vl = createVoltageLevel(substation, "vl1", "vl1", TopologyKind.NODE_BREAKER, 380, 10);
createBusBarSection(vl, "bbs11", "bbs11", 0, 1, 1);
createSwitch(vl, "d1b", "d1b", SwitchKind.DISCONNECTOR, true, false, false, 1, 2);
createSwitch(vl, "b1", "b1", SwitchKind.BREAKER, true, false, false, 0, 1);
createBattery(vl, "batt1", "batt1", "batt1", null, ConnectablePosition.Direction.TOP, 2, 1, 10, 5, 5);
createSwitch(vl, "d2b", "d2b", SwitchKind.DISCONNECTOR, true, true, false, 3, 4);
createSwitch(vl, "b2", "b2", SwitchKind.BREAKER, true, true, false, 0, 3);
createBattery(vl, "batt2", "batt2", "batt2", null, ConnectablePosition.Direction.BOTTOM, 4, 3, 10, 6, 6);
return network;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2023, 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.iidm;

import com.powsybl.sld.builders.NetworkGraphBuilder;
import com.powsybl.sld.model.graphs.VoltageLevelGraph;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.assertEquals;

/**
* @author Sophie Frasnedo <sophie.frasnedo at rte-france.com>
*/
public class TestBattery extends AbstractTestCaseIidm {

@Before
public void setUp() throws IOException {
network = CreateNetworksUtil.createNetworkWithBatteries();
graphBuilder = new NetworkGraphBuilder(network);
}

@Test
public void test() {
// build graph
VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph("vl1");

// Run layout
voltageLevelGraphLayout(g);

// write SVG and compare to reference
assertEquals(toString("/TestBatteries.svg"), toSVG(g, "/TestBatteries.svg"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public void test() {
ComponentLibrary cvg = ComponentLibrary.find("Convergence").orElse(null);
assertNotNull(cvg);
assertEquals("Convergence", cvg.getName());
assertEquals(19, cvg.getComponentsSize().size());
assertEquals(20, cvg.getComponentsSize().size());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright (c) 2023, 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.raw;

import com.powsybl.sld.builders.VoltageLevelRawBuilder;
import com.powsybl.sld.library.FlatDesignLibrary;
import com.powsybl.sld.library.ResourcesComponentLibrary;
import com.powsybl.sld.model.graphs.VoltageLevelGraph;
import com.powsybl.sld.model.nodes.BusNode;
import com.powsybl.sld.model.nodes.FeederNode;
import com.powsybl.sld.model.nodes.SwitchNode;
import com.powsybl.sld.svg.BasicStyleProvider;
import org.junit.Before;
import org.junit.Test;

import static com.powsybl.sld.model.coordinate.Direction.TOP;
import static org.junit.Assert.assertEquals;

/**
* @author Sophie Frasnedo <sophie.frasnedo at rte-france.com>
*/
public class TestAddBatteries extends AbstractTestCaseRaw {

@Before
public void setUp() {
VoltageLevelRawBuilder vlBuilder = rawGraphBuilder.createVoltageLevelBuilder("vl", 380);
BusNode bbs = vlBuilder.createBusBarSection("bbs", 1, 1);
FeederNode battery1 = vlBuilder.createBattery("batt1", 0, TOP);
SwitchNode d1 = vlBuilder.createSwitchNode(SwitchNode.SwitchKind.DISCONNECTOR, "d1", false, false);
SwitchNode b1 = vlBuilder.createSwitchNode(SwitchNode.SwitchKind.BREAKER, "b1", false, false);
FeederNode battery2 = vlBuilder.createBattery("batt2");
SwitchNode d2 = vlBuilder.createSwitchNode(SwitchNode.SwitchKind.DISCONNECTOR, "d2", false, false);
SwitchNode b2 = vlBuilder.createSwitchNode(SwitchNode.SwitchKind.BREAKER, "b2", false, false);
vlBuilder.connectNode(bbs, b1);
vlBuilder.connectNode(b1, d1);
vlBuilder.connectNode(d1, battery1);
vlBuilder.connectNode(bbs, b2);
vlBuilder.connectNode(b2, d2);
vlBuilder.connectNode(d2, battery2);
}

@Override
protected ResourcesComponentLibrary getResourcesComponentLibrary() {
return new FlatDesignLibrary();
}

@Test
public void test() {
VoltageLevelGraph g = rawGraphBuilder.buildVoltageLevelGraph("vl");
voltageLevelGraphLayout(g);
assertEquals(toString("/TestBatteriesRaw.svg"),
toSVG(g, "/TestBatteriesRaw.svg", getRawLabelProvider(), new BasicStyleProvider()));
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 4c0ddce

Please sign in to comment.