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

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

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

Terminal.getP介绍

[英]Get the active power in MW injected at the terminal.

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

代码示例

代码示例来源: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: itesla/ipst

private double newP(Generator generator, double deltaP, double participationFactor, double totalPartecipationFactor) {
  return generator.getTerminal().getP() - deltaP * participationFactor / totalPartecipationFactor;
}

代码示例来源:origin: com.powsybl/powsybl-action-util

@Override
public double initialValue(Network n) {
  Objects.requireNonNull(n);
  Generator g = n.getGenerator(id);
  return g != null && !Double.isNaN(g.getTerminal().getP()) ? g.getTerminal().getP() : 0;
}

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

private boolean filteredGenerator(Generator g, boolean isFiltered) {
  if (isFiltered) {
    if (!Double.isNaN(g.getTerminal().getP()) && ((-g.getTerminal().getP() > g.getMaxP()) || (-g.getTerminal().getP() < g.getMinP()))) {
      return true;
    }
  }
  return false;
}

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

private boolean filteredGenerator(Generator g) {
  if (configExport.getGensPQfilter()) {
    if (!Double.isNaN(g.getTerminal().getP()) && ((-g.getTerminal().getP() > g.getMaxP()) || (-g.getTerminal().getP() < g.getMinP()))) {
      return true;
    }
  }
  return false;
}

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

public void setNanLeg1P() {
  Mockito.when(leg1Terminal.getP()).thenReturn(Double.NaN);
}

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

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

代码示例来源: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 addBranchSideData(LinkedHashMap<String, Double> branchesData, String branchId, Terminal terminal, double currentLimit) {
  branchesData.put(getAttributeKey(branchId, terminal.getVoltageLevel().getId(), HistoDbAttr.I.name()), terminal.getI());
  branchesData.put(getAttributeKey(branchId, terminal.getVoltageLevel().getId(), HistoDbAttr.P.name()), terminal.getP());
  branchesData.put(getAttributeKey(branchId, terminal.getVoltageLevel().getId(), "IMAX"), currentLimit);
}

代码示例来源: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

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-security-analysis-api

@Override
public void onPreContingencyResult(RunningContext context, LimitViolationsResult preContingencyResult) {
  for (LimitViolation limitViolation : preContingencyResult.getLimitViolations()) {
    if (limitViolation.getLimitType() == LimitViolationType.CURRENT) {
      Branch branch = context.getNetwork().getBranch(limitViolation.getSubjectId());
      double preContingencyValue = branch.getTerminal(limitViolation.getSide()).getP();
      limitViolation.addExtension(ActivePowerExtension.class, new ActivePowerExtension(preContingencyValue));
    }
  }
}

代码示例来源: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: itesla/ipst

public static boolean isRedispatchable(Generator generator, float redispatchLimitsPercentage) {
  return (generator.getTerminal().getBusBreakerView().getBus() != null)  // is connected
      && (generator.getEnergySource() == EnergySource.HYDRO || generator.getEnergySource() == EnergySource.THERMAL) // is hydro or thermal
      && (generator.getTerminal().getP() < 0) // inject power
      && (generator.isVoltageRegulatorOn()) // has voltage regulator on
      && (generator.getTargetP() <= getRedispatchPMax(generator, redispatchLimitsPercentage)
        && generator.getTargetP() >= getRedispatchPMin(generator, redispatchLimitsPercentage)); // target P is within redispatch limits
      //&& (generator.getTargetP() <= generator.getMaxP() && generator.getTargetP() >= generator.getMinP()) // target P is within limits
}

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

@Override
  public void onPostContingencyResult(RunningContext context, PostContingencyResult postContingencyResult) {
    String workingStateId = context.getNetwork().getVariantManager().getWorkingVariantId();

    for (LimitViolation limitViolation : postContingencyResult.getLimitViolationsResult().getLimitViolations()) {
      if (limitViolation.getLimitType() == LimitViolationType.CURRENT) {
        Branch branch = context.getNetwork().getBranch(limitViolation.getSubjectId());

        context.getNetwork().getVariantManager().setWorkingVariant(context.getInitialStateId());
        limitViolation.addExtension(CurrentExtension.class, new CurrentExtension(branch.getTerminal(limitViolation.getSide()).getI()));
        double preContingencyValue = branch.getTerminal(limitViolation.getSide()).getP();

        context.getNetwork().getVariantManager().setWorkingVariant(workingStateId);
        double postContingencyValue = branch.getTerminal(limitViolation.getSide()).getP();

        limitViolation.addExtension(ActivePowerExtension.class, new ActivePowerExtension(preContingencyValue, postContingencyValue));
      }
    }
  }
}

代码示例来源: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: 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())
    );
  }
}

相关文章