private Scalable getScalable(Network n) { Objects.requireNonNull(n); Identifiable identifiable = n.getIdentifiable(id); if (identifiable instanceof Generator) { return new GeneratorScalable(id); } else { throw new PowsyblException("Unable to create a scalable from " + identifiable.getClass()); } }
protected static Terminal readTerminalRef(Network network, String id, String side) { Identifiable identifiable = network.getIdentifiable(id); if (identifiable instanceof Injection) { return ((Injection) identifiable).getTerminal(); } else if (identifiable instanceof Branch) { return side.equals(Branch.Side.ONE.name()) ? ((Branch) identifiable).getTerminal1() : ((Branch) identifiable).getTerminal2(); } else if (identifiable instanceof ThreeWindingsTransformer) { ThreeWindingsTransformer twt = (ThreeWindingsTransformer) identifiable; return twt.getTerminal(ThreeWindingsTransformer.Side.valueOf(side)); } else { throw new AssertionError("Unexpected Identifiable instance: " + identifiable.getClass()); } } }
private static void updateInjection(XMLStreamReader reader, Network network) { String id = reader.getAttributeValue(null, "id"); double p = XmlUtil.readOptionalDoubleAttribute(reader, "p"); double q = XmlUtil.readOptionalDoubleAttribute(reader, "q"); Injection inj = (Injection) network.getIdentifiable(id); inj.getTerminal().setP(p).setQ(q); }
private static VoltageLevel getVoltageLevel(LimitViolation limitViolation, Network network) { Objects.requireNonNull(network); Objects.requireNonNull(limitViolation); Identifiable identifiable = network.getIdentifiable(limitViolation.getSubjectId()); if (identifiable instanceof Branch) { Branch branch = (Branch) identifiable; return branch.getTerminal(limitViolation.getSide()).getVoltageLevel(); } else if (identifiable instanceof Injection) { Injection injection = (Injection) identifiable; return injection.getTerminal().getVoltageLevel(); } else if (identifiable instanceof VoltageLevel) { return (VoltageLevel) identifiable; } else if (identifiable instanceof Bus) { Bus bus = (Bus) identifiable; return bus.getVoltageLevel(); } else { throw new AssertionError("Unexpected identifiable type: " + identifiable.getClass()); } }
Identifiable identifiable = network.getIdentifiable(id2); if (identifiable == null) { throw new PowsyblException("Identifiable " + id2 + " not found");
Injection injection = (Injection) network.getIdentifiable(refMachineName); if (injection == null) { throw new RuntimeException("id: " + eq.getCimId() + ", name: " + machineName + ", coupling parameter " + parName + "=" + parValue + " - could not find any injection with id: " + refMachineName);
private static void updateBranch(XMLStreamReader reader, Network network) { String id = reader.getAttributeValue(null, "id"); double p1 = XmlUtil.readOptionalDoubleAttribute(reader, "p1"); double q1 = XmlUtil.readOptionalDoubleAttribute(reader, "q1"); double p2 = XmlUtil.readOptionalDoubleAttribute(reader, "p2"); double q2 = XmlUtil.readOptionalDoubleAttribute(reader, "q2"); Branch branch = (Branch) network.getIdentifiable(id); branch.getTerminal1().setP(p1).setQ(q1); branch.getTerminal2().setP(p2).setQ(q2); }
private void addSubjectInfo(RunningContext context, LimitViolationsResult result) { for (LimitViolation violation : result.getLimitViolations()) { Identifiable identifiable = context.getNetwork().getIdentifiable(violation.getSubjectId()); if (identifiable instanceof Branch) { Branch branch = (Branch) identifiable; Set<Country> countries = new TreeSet<>(); countries.add(branch.getTerminal1().getVoltageLevel().getSubstation().getCountry()); countries.add(branch.getTerminal2().getVoltageLevel().getSubstation().getCountry()); Set<Double> nominalVoltages = new TreeSet<>(); nominalVoltages.add(branch.getTerminal1().getVoltageLevel().getNominalV()); nominalVoltages.add(branch.getTerminal2().getVoltageLevel().getNominalV()); violation.addExtension(SubjectInfoExtension.class, new SubjectInfoExtension(countries, nominalVoltages)); } else if (identifiable instanceof VoltageLevel) { VoltageLevel vl = (VoltageLevel) identifiable; violation.addExtension(SubjectInfoExtension.class, new SubjectInfoExtension(vl.getSubstation().getCountry(), vl.getNominalV())); } } }
if (ctg.getEquipments() != null) { for (Equipment eq:ctg.getEquipments().getEquipment()) { if (network.getIdentifiable(eq.getId()) != null) { ctgIds.add(c.getId()); break; if (network.getIdentifiable(con.getEquipment()) != null) { constraints.add(new ConstraintImpl(con.getEquipment(), con.getValue(), XmlActionsContingenciesUtils.getConstraintType(con.getType()))); } else if (tieLines.containsKey(con.getEquipment())) {
@Test public void run() { Network network = EurostagTutorialExample1Factory.create(); ((Bus) network.getIdentifiable("NHV1")).setV(380.0); ((Bus) network.getIdentifiable("NHV2")).setV(380.0); network.getLine("NHV1_NHV2_1").getTerminal1().setP(560.0).setQ(550.0); network.getLine("NHV1_NHV2_1").getTerminal2().setP(560.0).setQ(550.0);
.add(); ((Bus) network.getIdentifiable("NHV1")).setV(380).getVoltageLevel().setLowVoltageLimit(400).setHighVoltageLimit(500); ((Bus) network.getIdentifiable("NHV2")).setV(380).getVoltageLevel().setLowVoltageLimit(300).setHighVoltageLimit(500);