com.powsybl.iidm.network.Terminal.getQ()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中com.powsybl.iidm.network.Terminal.getQ()方法的一些代码示例,展示了Terminal.getQ()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Terminal.getQ()方法的具体详情如下:
包路径:com.powsybl.iidm.network.Terminal
类名称:Terminal
方法名:getQ

Terminal.getQ介绍

[英]Get the reactive power in MVAR injected at the terminal.

Depends on the working variant.
[中]获取终端注入的无功功率,单位为MVAR。
取决于工作变量。

代码示例

代码示例来源:origin: itesla/ipst

private static float apparentPower(Terminal terminal) {
  float apparentPower = Float.NaN;
  if (!Double.isNaN(terminal.getP()) && !Double.isNaN(terminal.getQ())) {
    apparentPower = (float) Math.sqrt(Math.pow(terminal.getP(), 2) + Math.pow(terminal.getQ(), 2));
  }
  return apparentPower;
}

代码示例来源:origin: com.powsybl/powsybl-iidm-reducer

private static double checkQ(Terminal terminal) {
    if (!terminal.isConnected()) {
      return 0.0;
    }
    if (Double.isNaN(terminal.getQ())) {
      String connectableId = terminal.getConnectable().getId();
      String voltageLevelId = terminal.getVoltageLevel().getId();
      throw new PowsyblException("The reactive power of '" + connectableId + "' (" + voltageLevelId + ") is not set. Do you forget to compute the flows?");
    }
    return terminal.getQ();
  }
}

代码示例来源:origin: itesla/ipst

if (pf != null) {
  double dp = pf.p - (Double.isNaN(twt.getTerminal1().getP()) ? 0 : twt.getTerminal1().getP());
  double dq = pf.q - (Double.isNaN(twt.getTerminal1().getQ()) ? 0 : twt.getTerminal1().getQ());
  if (dp > 1 || dq > 1) {
    LOGGER.warn("Mismatch detected for {}: {},{}-> {},{}",
        twt.getId(), pf.p, pf.q, twt.getTerminal1().getP(), twt.getTerminal1().getQ());

代码示例来源:origin: com.powsybl/powsybl-loadflow-results-completion

private void completeTerminalData(Terminal terminal, ThreeWindingsTransformer.Side side, TwtData twtData) {
  if (terminal.isConnected() && terminal.getBusView().getBus().isInMainConnectedComponent()) {
    if (Double.isNaN(terminal.getP())) {
      LOGGER.debug("Twt {}, Side {}: setting p = {}", twtData.getId(), side, twtData.getComputedP(side));
      terminal.setP(twtData.getComputedP(side));
    }
    if (Double.isNaN(terminal.getQ())) {
      LOGGER.debug("Twt {}, Side {}: setting q = {}", twtData.getId(), side, twtData.getComputedQ(side));
      terminal.setQ(twtData.getComputedQ(side));
    }
  }
}

代码示例来源:origin: com.powsybl/powsybl-loadflow-results-completion

private void completeTerminalData(Terminal terminal, Side side, BranchData branchData) {
  if (terminal.isConnected() && terminal.getBusView().getBus().isInMainConnectedComponent()) {
    if (Double.isNaN(terminal.getP())) {
      LOGGER.debug("Branch {}, Side {}: setting p = {}", branchData.getId(), side, branchData.getComputedP(side));
      terminal.setP(branchData.getComputedP(side));
    }
    if (Double.isNaN(terminal.getQ())) {
      LOGGER.debug("Branch {}, Side {}: setting q = {}", branchData.getId(), side, branchData.getComputedQ(side));
      terminal.setQ(branchData.getComputedQ(side));
    }
  }
}

代码示例来源:origin: itesla/ipst

private static void fillGeneratorState(Generator g, StateVariable sv) {
  Terminal t = g.getTerminal();
  Bus b = t.getBusBreakerView().getBus();
  if (Double.isNaN(t.getP())) {
    sv.p = 0;
  } else {
    sv.p = t.getP();
  }
  if (Double.isNaN(t.getQ())) {
    sv.q = 0;
  } else {
    sv.q = t.getQ();
  }
  if (b != null && !Double.isNaN(b.getV()) && !Double.isNaN(b.getAngle())) { // generator is connected
    sv.u = b.getV();
    sv.theta = b.getAngle();
  } else {
    sv.u = t.getVoltageLevel().getNominalV();
    sv.theta = 0;
  }
  if (!sv.isValid()) {
    throw new RuntimeException("Invalid sv " + g.getId() + ": " + sv);
  }
}

代码示例来源:origin: itesla/ipst

public Double getQ(String equipment) {
  logger.debug("  network " + network.getName() + " equipment: " + equipment);
  Double returnValue = null;
  EquipmentTypes     eqType = equipmentType(equipment);
  if (eqType != null) {
    switch (eqType) {
      case GEN:
        logger.debug(" equipment == generator");
        returnValue = network.getGenerator(equipment).getTerminal().getQ();
        break;
      case LOAD:
        logger.debug("  equipment == load");
        returnValue = network.getLoad(equipment).getQ0();
        break;
      case LINE:
        logger.debug("  equipment == line");
        if (network.getLine(equipment).getTerminal1() != null) {
          returnValue = network.getLine(equipment).getTerminal1().getQ();
        }
        if (network.getLine(equipment).getTerminal2() != null) {
          returnValue = network.getLine(equipment).getTerminal2().getQ();
        }
        break;
    }
  }
  if (returnValue != null) {
    logger.debug(" RETURN Q: " + returnValue + " for Network: " + network.getName() + " Equipment: " + equipment);
  }
  return  returnValue;
}

代码示例来源:origin: com.powsybl/powsybl-iidm-xml-converter

protected static void writePQ(Integer index, Terminal t, XMLStreamWriter writer) throws XMLStreamException {
  XmlUtil.writeOptionalDouble("p" + indexToString(index), t.getP(), Double.NaN, writer);
  XmlUtil.writeOptionalDouble("q" + indexToString(index), t.getQ(), Double.NaN, writer);
}

代码示例来源:origin: com.powsybl/powsybl-iidm-api

public static void printGeneratorsSetpointDiff(Network network, Logger logger) {
  for (Generator g : network.getGenerators()) {
    double dp = Math.abs(g.getTerminal().getP() + g.getTargetP());
    double dq = Math.abs(g.getTerminal().getQ() + g.getTargetQ());
    double dv = Math.abs(g.getTerminal().getBusBreakerView().getConnectableBus().getV() - g.getTargetV());
    if (dp > 1 || dq > 5 || dv > 0.1) {
      logger.warn("Generator {}: ({}, {}, {}) ({}, {}, {}) -> ({}, {}, {})", g.getId(),
          dp, dq, dv,
          -g.getTargetP(), -g.getTargetQ(), g.getTargetV(),
          g.getTerminal().getP(), g.getTerminal().getQ(), g.getTerminal().getBusBreakerView().getConnectableBus().getV());
    }
  }
}

代码示例来源:origin: itesla/ipst

if (!Double.isNaN(t.getQ())) {
  double oldTargetQ = g.getTargetQ();
  double newTargetQ = -t.getQ();
  if (oldTargetQ != newTargetQ) {
    g.setTargetQ(newTargetQ);

代码示例来源:origin: itesla/ipst

private void update(Terminal t) {
  if (t.getBusView().getBus() != null) {
    p = t.getP();
    q = t.getQ();
    v = t.getBusView().getBus().getV();
    i = t.getI();
  }
}

代码示例来源:origin: com.powsybl/powsybl-cgmes-conversion

private PropertyBag createPowerFlowProperties(CgmesModel cgmes, Terminal terminal) {
  PropertyBag p = new PropertyBag(SV_POWERFLOW_PROPERTIES);
  p.put("p", fs(terminal.getP()));
  p.put("q", fs(terminal.getQ()));
  // TODO If we could store a terminal identifier in IIDM
  // we would not need to obtain it querying CGMES for the related equipment
  p.put(CgmesNames.TERMINAL, cgmes.terminalForEquipment(terminal.getConnectable().getId()));
  return p;
}

代码示例来源:origin: com.powsybl/powsybl-iidm-api

b2 = line.getB2();
p1 = line.getTerminal1().getP();
q1 = line.getTerminal1().getQ();
p2 = line.getTerminal2().getP();
q2 = line.getTerminal2().getQ();

代码示例来源:origin: itesla/ipst

loadData.setReactvePower(load.getTerminal().getQ());
if (load.getTerminal().getBusView().getBus() != null) {
  loadData.setVoltage(load.getTerminal().getBusView().getBus().getV());

代码示例来源:origin: itesla/ipst

binit = svc.getReactivePowerSetPoint();
} else {
  binit = svc.getTerminal().getQ();
  Bus svcBus = EchUtil.getBus(svc.getTerminal(), config);
  if ((svcBus != null) && (Math.abs(svcBus.getV()) > 0.0)) {

代码示例来源:origin: com.powsybl/powsybl-iidm-reducer

private Load replaceBranchByLoad(Branch<?> branch, VoltageLevel vl, Terminal terminal) {
  LoadAdder loadAdder = vl.newLoad()
      .setId(branch.getId())
      .setName(branch.getName())
      .setLoadType(LoadType.FICTITIOUS)
      .setP0(checkP(terminal))
      .setQ0(checkQ(terminal));
  fillNodeOrBus(loadAdder, terminal);
  branch.remove();
  Load load = loadAdder.add();
  load.getTerminal()
      .setP(terminal.getP())
      .setQ(terminal.getQ());
  return load;
}

代码示例来源:origin: com.powsybl/powsybl-iidm-reducer

private void replaceLineByDanglingLine(Line line, VoltageLevel vl, Terminal terminal) {
  Branch.Side side = line.getSide(terminal);
  DanglingLineAdder dlAdder = vl.newDanglingLine()
      .setId(line.getId())
      .setName(line.getName())
      .setR(line.getR() / 2)
      .setX(line.getX() / 2)
      .setB(side == Branch.Side.ONE ? line.getB1() : line.getB2())
      .setG(side == Branch.Side.ONE ? line.getG1() : line.getG2())
      .setP0(checkP(terminal))
      .setQ0(checkQ(terminal));
  fillNodeOrBus(dlAdder, terminal);
  line.remove();
  DanglingLine dl = dlAdder.add();
  dl.getTerminal()
      .setP(terminal.getP())
      .setQ(terminal.getQ());
  observers.forEach(o -> o.lineReplaced(line, dl));
}

代码示例来源:origin: com.powsybl/powsybl-ampl-converter

private void writeDanglingLineMiddleBuses(AmplExportContext context, TableFormatter formatter) throws IOException {
  for (DanglingLine dl : network.getDanglingLines()) {
    Terminal t = dl.getTerminal();
    Bus b = AmplUtil.getBus(dl.getTerminal());
    int middleCcNum = getDanglingLineMiddleBusComponentNum(context, dl);
    if (connectedComponentToExport(middleCcNum)) {
      String middleBusId = getDanglingLineMiddleBusId(dl);
      String middleVlId = getDanglingLineMiddleVoltageLevelId(dl);
      context.busIdsToExport.add(middleBusId);
      int middleBusNum = mapper.getInt(AmplSubset.BUS, middleBusId);
      int middleVlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, middleVlId);
      SV sv = new SV(t.getP(), t.getQ(), b != null ? b.getV() : Double.NaN, b != null ? b.getAngle() : Double.NaN).otherSide(dl);
      double nomV = t.getVoltageLevel().getNominalV();
      double v = sv.getU() / nomV;
      double theta = Math.toRadians(sv.getA());
      formatter.writeCell(variantIndex)
          .writeCell(middleBusNum)
          .writeCell(middleVlNum)
          .writeCell(middleCcNum)
          .writeCell(v)
          .writeCell(theta)
          .writeCell(0.0) // 0 MW injected at dangling line internal bus
          .writeCell(0.0) // 0 MVar injected at dangling line internal bus
          .writeCell(faultNum)
          .writeCell(actionNum)
          .writeCell(middleBusId);
    }
  }
}

代码示例来源:origin: itesla/ipst

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())
    );
  }
}

代码示例来源:origin: itesla/ipst

private static void extractGeneratorsData(Network network, NetworkData networkData) {
    for (Generator generator : network.getGenerators()) {
      networkData.addGeneratorData(new GeneratorData(generator.getId(),
                              (generator.getTerminal().getBusBreakerView().getBus() != null)
                                    ? generator.getTerminal().getBusBreakerView().getBus().getId()
                                    : generator.getTerminal().getBusBreakerView().getConnectableBus().getId(),
                              generator.getTerminal().getBusBreakerView().getBus() != null,
                              apparentPower(generator.getTerminal()),
                              generator.getTerminal().getP(),
                              generator.getTerminal().getQ(),
                              generator.getRatedS(),
                              generator.getReactiveLimits().getMaxQ(generator.getTargetP()),
                              generator.getReactiveLimits().getMinQ(generator.getTargetP()))
//                                                           generator.getReactiveLimits().getMaxQ(generator.getTerminal().getP()),
//                                                           generator.getReactiveLimits().getMinQ(generator.getTerminal().getP()))
      );
    }
  }

相关文章