private String getBusId(Bus bus) { return bus == null ? null : bus.getId(); }
public boolean test(Bus b) { return buses == null || buses.contains(b.getId()); }
private static String getBusId(Bus bus) { return bus.getId().replace('-', '_').replace("=", "_"); }
protected void addToAdjacencyList(Bus bus1, Bus bus2, Map<String, Integer> id2num, TIntArrayList[] adjacencyList) { if (bus1 != null && bus2 != null) { int busNum1 = id2num.get(bus1.getId()); int busNum2 = id2num.get(bus2.getId()); adjacencyList[busNum1].add(busNum2); adjacencyList[busNum2].add(busNum1); } }
private int getBusNum(Bus bus) { return bus == null ? -1 : mapper.getInt(AmplSubset.BUS, bus.getId()); }
private static Bus selectSlackbusCriteria1(Network network, EurostagEchExportConfig config, Set<String> busesToAvoid) { return StreamSupport.stream(EchUtil.getBuses(network, config).spliterator(), false) .sorted((b1, b2) -> b1.getId().compareTo(b2.getId())) .filter(b -> !busesToAvoid.contains(b.getId()) && b.getConnectedComponent() != null && b.getConnectedComponent().getNum() == ComponentConstants.MAIN_NUM) .map(b -> decorate(b)) .filter(db -> db.regulatingGenerator > 0 && db.maxP > 100) // only keep bus with a regulating generator and a pmax > 100 MW .sorted((db1, db2) -> Float.compare((db1.maxP - db1.minP) / 2 - db1.targetP, (db2.maxP - db2.minP) / 2 - db2.targetP)) // select first bus with a high margin .limit(1) .map(f -> f.bus) .findFirst() .orElse(null); }
private static void dumpBusesDictionary(Network network, EurostagDictionary dictionary, Path dir, EurostagEchExportConfig exportConfig) throws IOException { try (BufferedWriter os = Files.newBufferedWriter(dir.resolve("dict_buses.csv"), StandardCharsets.UTF_8)) { for (Bus bus : Identifiables.sort(EchUtil.getBuses(network, dictionary.getConfig()))) { if (!(exportConfig.isExportMainCCOnly() && (!EchUtil.isInMainCc(bus)))) { os.write(bus.getId() + ";" + dictionary.getEsgId(bus.getId())); os.newLine(); } } } }
public static int getConnectableBusNum(StringToIntMapper<AmplSubset> mapper, Terminal t) { Bus bus = getConnectableBus(t); return bus == null ? -1 : mapper.getInt(AmplSubset.BUS, bus.getId()); }
public static int getBusNum(StringToIntMapper<AmplSubset> mapper, Terminal t) { Bus bus = getBus(t); return bus == null ? -1 : mapper.getInt(AmplSubset.BUS, bus.getId()); }
private Map<String, List<String>> getBusSwitchMap(VoltageLevel vl) { return vl.getBusBreakerView().getSwitchStream().flatMap(s -> Stream.of( Maps.immutableEntry(vl.getBusBreakerView().getBus1(s.getId()).getId(), s.getId()), Maps.immutableEntry(vl.getBusBreakerView().getBus2(s.getId()).getId(), s.getId()))) .collect(Collectors.toMap(a -> a.getKey(), a -> new ArrayList<>(Collections.singletonList(a.getValue())), (o, n) -> { o.addAll(n); return o; }, HashMap::new)); }
public ConnectLoadRecord(ConnectBusInfo busInfo, Load load) { super(busInfo.getBus().getId(), load.getId()); }
private void busConnection(Terminal t, int busNum) { if (busNum == -1) { t.disconnect(); } else { String busId = mapper.getId(AmplSubset.BUS, busNum); Bus connectable = AmplUtil.getConnectableBus(t); if (connectable != null && connectable.getId().equals(busId)) { t.connect(); } } }
private static void writeBus(Integer index, Bus bus, Bus connectableBus, NetworkXmlWriterContext context) throws XMLStreamException { if (bus != null) { context.getWriter().writeAttribute(BUS + indexToString(index), context.getAnonymizer().anonymizeString(bus.getId())); } if (connectableBus != null) { context.getWriter().writeAttribute(CONNECTABLE_BUS + indexToString(index), context.getAnonymizer().anonymizeString(connectableBus.getId())); } }
static void addBusOfMainCC(Set<String> buses, Network n, ExportOptions options) { // keep bus of main cc if (options.getTopologyLevel() == TopologyLevel.BUS_BRANCH) { for (Bus b : n.getBusView().getBuses()) { if (b.isInMainConnectedComponent()) { buses.add(b.getId()); } } } else { for (Bus b : n.getBusBreakerView().getBuses()) { if (b.isInMainConnectedComponent()) { buses.add(b.getId()); } } } }
public ConnectGeneratorRecord(ConnectBusInfo busInfo, Generator gen, boolean isInyection, SourceEngine sourceEngine) { super(busInfo.getBus().getId(), gen.getId()); this.node1 = busInfo.getBus(); this.node2 = gen; this.isConnected = busInfo.isConnected(); this.isInyection = isInyection; this.sourceEngine = sourceEngine; }
public ConnectCapacitorRecord(ConnectBusInfo busInfo, ShuntCompensator shunt) { super(busInfo.getBus().getId(), shunt.getId()); this.isConnected = busInfo.isConnected(); // this.busInfo = busInfo; this.node1 = busInfo.getBus(); this.node2 = shunt; }
@Override protected void writeRootElementAttributes(Switch s, VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException { super.writeRootElementAttributes(s, vl, context); VoltageLevel.BusBreakerView v = vl.getBusBreakerView(); Bus bus1 = v.getBus1(s.getId()); Bus bus2 = v.getBus2(s.getId()); context.getWriter().writeAttribute("bus1", context.getAnonymizer().anonymizeString(bus1.getId())); context.getWriter().writeAttribute("bus2", context.getAnonymizer().anonymizeString(bus2.getId())); }
public boolean test(Connectable<?> connectable) { if (buses == null) { return true; } for (Terminal t : connectable.getTerminals()) { Bus b = options.getTopologyLevel() == TopologyLevel.BUS_BRANCH ? t.getBusView().getConnectableBus() : t.getBusBreakerView().getConnectableBus(); if (b != null && !buses.contains(b.getId())) { return false; } } return true; } }
private static void fillNodeOrBus(InjectionAdder adder, Terminal terminal) { if (terminal.getVoltageLevel().getTopologyKind() == TopologyKind.NODE_BREAKER) { adder.setNode(terminal.getNodeBreakerView().getNode()); } else { if (terminal.isConnected()) { adder.setBus(terminal.getBusBreakerView().getBus().getId()); } adder.setConnectableBus(terminal.getBusBreakerView().getConnectableBus().getId()); } }
private static void extractLoadsData(Network network, NetworkData networkData) { for (Load load : network.getLoads()) { networkData.addLoadData(new LoadData(load.getId(), (load.getTerminal().getBusBreakerView().getBus() != null) ? load.getTerminal().getBusBreakerView().getBus().getId() : load.getTerminal().getBusBreakerView().getConnectableBus().getId(), load.getTerminal().getBusBreakerView().getBus() != null, load.getTerminal().getVoltageLevel().getNominalV(), load.getTerminal().getP(), load.getTerminal().getQ()) ); } }