case NODE_BREAKER_TOPOLOGY_ELEMENT_NAME: int nodeCount = XmlUtil.readIntAttribute(context.getReader(), "nodeCount"); vl.getNodeBreakerView().setNodeCount(nodeCount); XmlUtil.readUntilEndElement(NODE_BREAKER_TOPOLOGY_ELEMENT_NAME, context.getReader(), () -> { switch (context.getReader().getLocalName()) {
/** * Creates a standard connection point from a bus bar section, * with a disconnector and a breaker. * * @param bb Bus bar section to connect to * @return Node index of the connection point */ public static int newStandardConnection(BusbarSection bb) { Objects.requireNonNull(bb, "Busbar section is null."); int n = bb.getTerminal().getNodeBreakerView().getNode(); VoltageLevel.NodeBreakerView topo = bb.getTerminal().getVoltageLevel().getNodeBreakerView(); int oldCount = topo.getNodeCount(); topo.setNodeCount(oldCount + 2); topo.newDisconnector() .setId(String.format("disconnector %s-%d", bb.getId(), oldCount)) .setNode1(n) .setNode2(oldCount) .add(); topo.newBreaker() .setId(String.format("breaker %s-%d", bb.getId(), oldCount + 1)) .setNode1(oldCount) .setNode2(oldCount + 1) .add(); return oldCount + 1; } }
/** * Remove switches of components which have no connected equipment, * i.e for which all vertices objects are null. * * @param topo The node-breaker view of a voltage level. */ public static void removeIsolatedSwitches(VoltageLevel.NodeBreakerView topo) { Objects.requireNonNull(topo, "Node breaker topology view is null."); int[] nodes = topo.getNodes(); final TIntSet encountered = new TIntHashSet(); final Set<Switch> encounteredSwitches = new HashSet<>(); for (int n : nodes) { if (encountered.contains(n) || topo.getTerminal(n) == null) { continue; } encountered.add(n); topo.traverse(n, (n1, sw, n2) -> { encountered.add(n2); encounteredSwitches.add(sw); return topo.getTerminal(n2) == null; }); } List<Switch> toRemove = topo.getSwitchStream().filter(sw -> !encounteredSwitches.contains(sw)).collect(Collectors.toList()); for (Switch sw : toRemove) { topo.removeSwitch(sw.getId()); } }
.setTopologyKind(TopologyKind.NODE_BREAKER) .add(); vlC.getNodeBreakerView().setNodeCount(5); BusbarSection busbarSectionD = vlC.getNodeBreakerView().newBusbarSection() .setId("D") .setName("E") .setTopologyKind(TopologyKind.NODE_BREAKER) .add(); vlN.getNodeBreakerView().setNodeCount(23); BusbarSection busbarSectionO = vlN.getNodeBreakerView().newBusbarSection() .setId("O") .setName("E") .setNode(0) .add(); BusbarSection busbarSectionP = vlN.getNodeBreakerView().newBusbarSection() .setId("P") .setName("Q")
.add(); VoltageLevel.NodeBreakerView topology1 = voltageLevel1.getNodeBreakerView(); topology1.setNodeCount(10); BusbarSection voltageLevel1BusbarSection1 = topology1.newBusbarSection() .setId("voltageLevel1BusbarSection1") .setNode(0) .add(); BusbarSection voltageLevel1BusbarSection2 = topology1.newBusbarSection() .setId("voltageLevel1BusbarSection2") .setNode(1) .add(); topology1.newBreaker() .setId("voltageLevel1Breaker1") .setRetained(true) .setQ0(3) .add(); topology1.newDisconnector() .setId("load1Disconnector1") .setOpen(false) .setNode2(3) .add(); topology1.newDisconnector() .setId("load1Breaker1") .setOpen(false) .beginPoint().setP(900.0).setMinQ(300.0).setMaxQ(500.0).endPoint() .add();
.setQ(50.0); VoltageLevel vl2 = network.getVoltageLevel("VL2"); vl2.getNodeBreakerView().setNodeCount(7); vl2.getNodeBreakerView().newDisconnector() .setId("DISC_BBS1_BK2") .setName(DISCONNECTOR_NAME) .setRetained(false) .add(); vl2.getNodeBreakerView().newBreaker() .setId("BK2") .setName(BREAKER_NAME) .setRetained(true) .add(); vl2.getNodeBreakerView().newDisconnector() .setId("DISC_BBS1_BK3") .setName(DISCONNECTOR_NAME) .setRetained(false) .add(); vl2.getNodeBreakerView().newBreaker() .setId("BK3") .setName(BREAKER_NAME)
.setTopologyKind(TopologyKind.NODE_BREAKER) .add(); vl2.getNodeBreakerView().setNodeCount(3); vl2.getNodeBreakerView().newBusbarSection() .setId("BBS1") .setName("BusbarSection") .setNode(0) .add(); vl2.getNodeBreakerView().newDisconnector() .setId("DISC_BBS1_BK1") .setName(DISCONNECTOR_NAME) .setRetained(false) .add(); vl2.getNodeBreakerView().newBreaker() .setId("BK1") .setName(BREAKER_NAME)
private void writeNodeBreakerTopologyInternalConnections(VoltageLevel vl, NetworkXmlWriterContext context) { VoltageLevel.NodeBreakerView topo = vl.getNodeBreakerView(); int[] nodes = topo.getNodes(); // There is no way in IIDM to obtain the list of internal connections, // we have to traverse all connectivity and consider an internal connection // when there are two nodes linked with an edge that does not have an // associated object final TIntSet explored = new TIntHashSet(); for (int n : nodes) { if (explored.contains(n)) { continue; } explored.add(n); topo.traverse(n, (n1, sw, n2) -> { explored.add(n2); if (sw == null) { writeNodeBreakerTopologyInternalConnection(n1, n2, context); } return true; }); } }
@Override protected BusbarSectionAdder createAdder(VoltageLevel vl) { return vl.getNodeBreakerView().newBusbarSection(); }
@Override protected VoltageLevel.NodeBreakerView.SwitchAdder createAdder(VoltageLevel vl) { return vl.getNodeBreakerView().newSwitch(); }
private static void createSwitch(VoltageLevel vl, String id, String name, SwitchKind kind, boolean retained, boolean open, boolean fictitious, int node1, int node2) { vl.getNodeBreakerView().newSwitch() .setId(id) .setName(name) .setKind(kind) .setRetained(retained) .setOpen(open) .setFictitious(fictitious) .setNode1(node1) .setNode2(node2) .add(); }
private void writeNodeBreakerTopology(VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException { context.getWriter().writeStartElement(IIDM_URI, NODE_BREAKER_TOPOLOGY_ELEMENT_NAME); context.getWriter().writeAttribute("nodeCount", Integer.toString(vl.getNodeBreakerView().getNodeCount())); for (BusbarSection bs : vl.getNodeBreakerView().getBusbarSections()) { BusbarSectionXml.INSTANCE.write(bs, null, context); } for (Switch sw : vl.getNodeBreakerView().getSwitches()) { NodeBreakerViewSwitchXml.INSTANCE.write(sw, vl, context); } writeNodeBreakerTopologyInternalConnections(vl, context); context.getWriter().writeEndElement(); }