@Override public void allocateVariantArrayElement(int[] indexes, final int sourceIndex) { super.allocateVariantArrayElement(indexes, sourceIndex); for (int index : indexes) { currentSectionCount.set(index, currentSectionCount.get(sourceIndex)); } }
@Override public void deleteVariantArrayElement(int index) { super.deleteVariantArrayElement(index); // nothing to do }
protected void notifyUpdate(String attribute, Object oldValue, Object newValue) { getNetwork().getListeners().notifyUpdate(this, attribute, oldValue, newValue); }
@Override public Terminal setP(double p) { if (connectable.getType() == ConnectableType.BUSBAR_SECTION) { throw new ValidationException(connectable, "cannot set active power on a busbar section"); } if (!Double.isNaN(p) && connectable.getType() == ConnectableType.SHUNT_COMPENSATOR) { throw new ValidationException(connectable, "cannot set active power on a shunt compensator"); } double oldValue = this.p.set(network.get().getVariantIndex(), p); getConnectable().notifyUpdate("p" + (num != -1 ? num : ""), oldValue, p); return this; }
for (TerminalExt terminal : bus.getTerminals()) { AbstractConnectable connectable = terminal.getConnectable(); label = connectable.getType().toString() + "\\n" + connectable.getId(); writer.append(" ").append(connectable.getId()) .append(" [label=\"").append(label).append("\"]\n"); AbstractConnectable connectable = terminal.getConnectable(); writer.append(" ").append(bus.getId()) .append(" -- ").append(connectable.getId()) .append(" [").append("style=\"").append(terminal.isConnected() ? "solid" : "dotted").append("\"") .append("]\n");
@Override public void extendVariantArraySize(int initVariantArraySize, int number, int sourceIndex) { super.extendVariantArraySize(initVariantArraySize, number, sourceIndex); currentSectionCount.ensureCapacity(currentSectionCount.size() + number); for (int i = 0; i < number; i++) { currentSectionCount.add(currentSectionCount.get(sourceIndex)); } }
@Override public void reduceVariantArraySize(int number) { super.reduceVariantArraySize(number); currentSectionCount.remove(currentSectionCount.size() - number, number); }
@Override public double getI() { if (connectable.getType() == ConnectableType.BUSBAR_SECTION) { return 0; } int variantIndex = network.get().getVariantIndex(); return Math.hypot(p.get(variantIndex), q.get(variantIndex)) / (Math.sqrt(3.) * getV() / 1000); }
@Override public void printTopology(PrintStream out, ShortIdDictionary dict) { out.println("-------------------------------------------------------------"); out.println("Topology of " + BusBreakerVoltageLevel.this.id); Function<ConfiguredBus, String> vertexToString = bus -> { StringBuilder builder = new StringBuilder(); builder.append(bus.getId()) .append(" ["); for (Iterator<TerminalExt> it = bus.getConnectedTerminals().iterator(); it.hasNext(); ) { TerminalExt terminal = it.next(); builder.append(dict != null ? dict.getShortId(terminal.getConnectable().getId()) : terminal.getConnectable().getId()); if (it.hasNext()) { builder.append(", "); } } builder.append("]"); return builder.toString(); }; Function<SwitchImpl, String> edgeToString = aSwitch -> { StringBuilder builder = new StringBuilder(); builder.append("id=").append(aSwitch.getId()) .append(" status=").append(aSwitch.isOpen() ? "open" : "closed"); return builder.toString(); }; graph.print(out, vertexToString, edgeToString); }
@Override public void printTopology(PrintStream out, ShortIdDictionary dict) { out.println("-------------------------------------------------------------"); out.println("Topology of " + NodeBreakerVoltageLevel.this.id); graph.print(out, terminal -> terminal != null ? terminal.getConnectable().toString() : null, null); }
private void exportBuses(Graph g, Multimap<String, Integer> busToNodes, Map<Integer, Node> intToNode) { String[] colors = Colors.generateColorScale(busToNodes.asMap().keySet().size()); int i = 0; for (String key : busToNodes.asMap().keySet()) { Graph newBus = new Graph().id("\"" + key + "\""); newBus.attr(LABEL_ATTRIBUTE, key); for (int nodeInt : busToNodes.get(key)) { Node node = intToNode.get(nodeInt); TerminalExt terminal = graph.getVertexObject(nodeInt); if (terminal != null) { AbstractConnectable connectable = terminal.getConnectable(); String label = nodeInt + "\\n" + connectable.getType().toString() + "\\n" + connectable.getId(); node.attr(LABEL_ATTRIBUTE, label); } node.attr("style", "filled").attr("color", colors[i]); newBus.node(node); } g.subGraph(newBus); i++; } }
@Override public Terminal setQ(double q) { if (connectable.getType() == ConnectableType.BUSBAR_SECTION) { throw new ValidationException(connectable, "cannot set reactive power on a busbar section"); } double oldValue = this.q.set(network.get().getVariantIndex(), q); getConnectable().notifyUpdate("q" + (num != -1 ? num : ""), oldValue, q); return this; }
@Override public void extendVariantArraySize(int initVariantArraySize, int number, int sourceIndex) { super.extendVariantArraySize(initVariantArraySize, number, sourceIndex); if (leg2.getRatioTapChanger() != null) { leg2.getRatioTapChanger().extendVariantArraySize(initVariantArraySize, number, sourceIndex); } if (leg3.getRatioTapChanger() != null) { leg3.getRatioTapChanger().extendVariantArraySize(initVariantArraySize, number, sourceIndex); } }
@Override public void reduceVariantArraySize(int number) { super.reduceVariantArraySize(number); p0.remove(p0.size() - number, number); q0.remove(q0.size() - number, number); }
protected boolean isBusValid(Set<ConfiguredBus> busSet) { int feederCount = 0; int branchCount = 0; for (TerminalExt terminal : FluentIterable.from(busSet).transformAndConcat(ConfiguredBus::getConnectedTerminals)) { AbstractConnectable connectable = terminal.getConnectable(); switch (connectable.getType()) { case LINE: case TWO_WINDINGS_TRANSFORMER: case THREE_WINDINGS_TRANSFORMER: case HVDC_CONVERTER_STATION: branchCount++; feederCount++; break; case DANGLING_LINE: case LOAD: case GENERATOR: case SHUNT_COMPENSATOR: case STATIC_VAR_COMPENSATOR: feederCount++; break; case BUSBAR_SECTION: // must not happend in a bus/breaker topology default: throw new AssertionError(); } } return Networks.isBusValid(branchCount); }
@Override public void attach(TerminalExt terminal, boolean test) { checkTerminal(terminal); if (test) { return; } int node = ((NodeTerminal) terminal).getNode(); if (graph.getVertexObject(node) != null) { throw new ValidationException(terminal.getConnectable(), "an equipment (" + graph.getVertexObject(node).getConnectable().getId() + ") is already connected to node " + node + " of voltage level " + NodeBreakerVoltageLevel.this.id); } // create the link terminal <-> voltage level terminal.setVoltageLevel(NodeBreakerVoltageLevel.this); // create the link terminal <-> graph vertex graph.setVertexObject(node, (NodeTerminal) terminal); }
public void exportTopology(OutputStream os) { Graph g = new Graph().id("\"" + NodeBreakerVoltageLevel.this.id + "\""); Map<Integer, Node> intToNode = new HashMap<>(); Multimap<String, Integer> busToNodes = ArrayListMultimap.create(); for (int n = 0; n < graph.getVertexCount(); n++) { Node node = new Node().id(Integer.toString(n)); intToNode.put(n, node); Bus bus = getCalculatedBusBreakerTopology().getBus(n); if (bus != null) { busToNodes.put(bus.getId(), n); } else { TerminalExt terminal = graph.getVertexObject(n); if (terminal != null) { AbstractConnectable connectable = terminal.getConnectable(); String label = n + "\\n" + connectable.getType().toString() + "\\n" + connectable.getId(); node.attr(LABEL_ATTRIBUTE, label); g.node(node); } } } exportBuses(g, busToNodes, intToNode); exportEdges(g, intToNode); g.writeTo(os); }
@Override public void extendVariantArraySize(int initVariantArraySize, int number, int sourceIndex) { super.extendVariantArraySize(initVariantArraySize, number, sourceIndex); p0.ensureCapacity(p0.size() + number); q0.ensureCapacity(q0.size() + number); for (int i = 0; i < number; i++) { p0.add(p0.get(sourceIndex)); q0.add(q0.get(sourceIndex)); } }
@Override public void allocateVariantArrayElement(int[] indexes, int sourceIndex) { super.allocateVariantArrayElement(indexes, sourceIndex); for (int index : indexes) { p0.set(index, p0.get(sourceIndex)); q0.set(index, q0.get(sourceIndex)); } }
@Override public void reduceVariantArraySize(int number) { super.reduceVariantArraySize(number); p0.remove(p0.size() - number, number); q0.remove(q0.size() - number, number); }