private static Set<Set<String>> toTopoSet(VoltageLevel vl, ShortIdDictionary dict) { Set<Set<String>> sets = new HashSet<>(); for (Bus b : vl.getBusView().getBuses()) { final Set<String> set = new HashSet<>(); b.visitConnectedEquipments(new EquipmentTopologyVisitor() { @Override public void visitEquipment(Connectable eq) { set.add(dict != null ? dict.getShortId(eq.getId()) : eq.getId()); } }); sets.add(set); } return sets; }
@Override public Stream<Bus> getBusStream() { return getVoltageLevelStream().flatMap(vl -> vl.getBusView().getBusStream()); }
@Override public void checkVoltage(VoltageLevel voltageLevel, Consumer<LimitViolation> consumer) { voltageLevel.getBusView().getBusStream().forEach(b -> checkVoltage(b, consumer)); }
@Override public Iterable<Bus> getBuses() { return FluentIterable.from(getVoltageLevels()) .transformAndConcat(vl -> vl.getBusView().getBuses()); }
@Override public void checkAll(Network network, Consumer<LimitViolation> consumer) { network.getBranchStream().forEach(b -> checkCurrent(b, consumer)); network.getVoltageLevelStream() .flatMap(v -> v.getBusView().getBusStream()) .forEach(b -> checkVoltage(b, consumer)); }
private void writeBusBranchTopology(VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException { context.getWriter().writeStartElement(IIDM_URI, BUS_BREAKER_TOPOLOGY_ELEMENT_NAME); for (Bus b : vl.getBusView().getBuses()) { if (!context.getFilter().test(b)) { continue; } BusXml.INSTANCE.write(b, null, context); } context.getWriter().writeEndElement(); }
public static Iterable<Bus> getBuses(VoltageLevel vl, EurostagEchExportConfig config) { if (config.isNoSwitch()) { return vl.getBusView().getBuses(); } else { return vl.getBusBreakerView().getBuses(); } }
private static void updateBus(XMLStreamReader reader, VoltageLevel[] vl) { String id = reader.getAttributeValue(null, "id"); double v = XmlUtil.readDoubleAttribute(reader, "v"); double angle = XmlUtil.readDoubleAttribute(reader, "angle"); Bus b = vl[0].getBusBreakerView().getBus(id); if (b == null) { b = vl[0].getBusView().getBus(id); } b.setV(v > 0 ? v : Double.NaN).setAngle(angle); }
@Test //test voltage limit violation public void checkVoltage() { VoltageLevel vl = network.getVoltageLevel("VLHV1"); LimitViolationDetector detector = new DefaultLimitViolationDetector(); List<LimitViolation> violations = new ArrayList<>(); vl.getBusView().getBusStream().forEach(b -> detector.checkVoltage(b, 380, violations::add)); assertEquals(1, violations.size()); LimitViolation violation = violations.get(0); //check that is LimitViolationType.LOW_VOLTAGE limit violation assertEquals(LimitViolationType.LOW_VOLTAGE, violation.getLimitType()); violations.clear(); vl.getBusView().getBusStream().forEach(b -> detector.checkVoltage(b, 520, violations::add)); assertEquals(1, violations.size()); violation = violations.get(0); //check that is LimitViolationType.HIGH_VOLTAGE limit violation assertEquals(LimitViolationType.HIGH_VOLTAGE, violation.getLimitType()); } }
List<String> lvBusIds = Lists.newArrayList(StreamSupport.stream(lvVl.getBusView().getBuses().spliterator(), false).map(b -> b.getId()).collect(Collectors.toCollection(LinkedList::new)).descendingIterator()); for (String lvBusId : lvBusIds) { Bus lvBus = n.getVoltageLevel(lvVlId).getBusView().getBus(lvBusId); if (lvBus == null) { String errMsg = "lvVlId: " + lvVlId + "; lvBus with id: " + lvBusId + " not found";
double vMin = Double.NaN; double vMax = Double.NaN; for (Bus b : vl.getBusView().getBuses()) { if (!Double.isNaN(b.getV())) { vSum += b.getV();
vl.getBusView().getBusStream().forEach(b -> b.setV(410)); vl.getBusView().getBusStream().forEach(b -> b.setV(380)); builder.endContingency(); vl.getBusView().getBusStream().forEach(b -> b.setV(520)); builder.contingency(new Contingency("contingency2")).setComputationOk(true); Security.checkLimits(network).forEach(builder::addViolation);