private static void connectGenerator(Generator g) { Terminal t = g.getTerminal(); t.connect(); if (g.isVoltageRegulatorOn()) { Bus bus = t.getBusView().getBus(); if (bus != null) { // set voltage setpoint to the same as other generators connected to the bus double targetV = bus.getGeneratorStream().findFirst().map(Generator::getTargetV).orElse(Double.NaN); // if no other generator connected to the bus, set voltage setpoint to network voltage if (Double.isNaN(targetV) && !Double.isNaN(bus.getV())) { g.setTargetV(bus.getV()); } } } LOGGER.info("Connecting {}", g.getId()); } }
for (Bus b : network.getBusView().getBuses()) { long load = Math.round(b.getLoadStream().mapToDouble(Load::getP0).sum()); long maxGeneration = Math.round(b.getGeneratorStream().mapToDouble(Generator::getMaxP).sum()); String busId = getBusId(b); Node n = new Node()