com.powsybl.iidm.network.Generator类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(14.7k)|赞(0)|评价(0)|浏览(149)

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

Generator介绍

[英]A power generator.

To create a generator, see GeneratorAdder
[中]发电机。
要创建生成器,请参见GeneratorAdder

代码示例

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

/**
 * @param writerMo
 * @param modContext
 * @param modelicaModelsList
 * @param modelicaSim
 * @param sourceSim
 * @throws IOException
 */
private void exportGeneratorsAsFixedInjections(Writer writerMo, ModExportContext modContext, List<String> modelicaModelsList, SimulatorInst modelicaSim, SimulatorInst sourceSim) throws IOException {
  // Export Generators as Fixed Inyections
  if ((generatorsInyections.size() != 0) && (!generatorsInyections.isEmpty())) {
    LOGGER.info("EXPORTING GENERATORS AS FIXED INYECTIONS");
    for (Generator generator : generatorsInyections) {
      LOGGER.info("\t Exporting generator inyection " + generator.getId());
      ConnectBusInfo busInfo = findBus(generator.getTerminal(), generator.getId());
      GeneratorRecord generatorRecord = ModelConverter.getModelicaRecord(generator, busInfo, modContext, _ddbManager, modelicaSim, sourceSim, true, SNREF, this.paramsDictionary, this._sourceEngine);
      this.addRecord(generatorRecord, writerMo, modContext, _ddbManager, modelicaSim);
    }
  }
}

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

@Override
protected void writeRootElementAttributes(Generator g, VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException {
  context.getWriter().writeAttribute("energySource", g.getEnergySource().name());
  XmlUtil.writeDouble("minP", g.getMinP(), context.getWriter());
  XmlUtil.writeDouble("maxP", g.getMaxP(), context.getWriter());
  XmlUtil.writeDouble("ratedS", g.getRatedS(), context.getWriter());
  context.getWriter().writeAttribute("voltageRegulatorOn", Boolean.toString(g.isVoltageRegulatorOn()));
  XmlUtil.writeDouble("targetP", g.getTargetP(), context.getWriter());
  XmlUtil.writeDouble("targetV", g.getTargetV(), context.getWriter());
  XmlUtil.writeDouble("targetQ", g.getTargetQ(), context.getWriter());
  writeNodeOrBus(null, g.getTerminal(), context);
  writePQ(null, g.getTerminal(), context.getWriter());
}

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

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

@Override
  public void visitGenerator(Generator generator) {
    if (generator.isVoltageRegulatorOn()) {
      decoratedBus.regulatingGenerator++;
      decoratedBus.maxP += generator.getMaxP();
      decoratedBus.minP += generator.getMinP();
      decoratedBus.targetP += generator.getTargetP();
    }
  }
});

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

public static double getRedispatchPMax(Generator generator, float redispatchLimitsPercentage) {
  double redispatchPMax = generator.getMaxP();
  if (generator.getTargetP() < generator.getMinP()) {
    redispatchPMax = generator.getMinP() + redispatchLimitsPercentage * 0.01 * generator.getMaxP();
  } else {
    redispatchPMax = generator.getTargetP() + redispatchLimitsPercentage * 0.01 * generator.getMaxP();
  }
  return generator.getMaxP() > redispatchPMax ? redispatchPMax : generator.getMaxP();
}

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

public static double getNominalPower(Generator generator) {
  Objects.requireNonNull(generator, "generator is null");
  double nominalPower = Double.NaN;
  double pMax = generator.getMaxP();
  double qMax = generator.getReactiveLimits().getMaxQ(generator.getTargetP());
  nominalPower = Math.sqrt(Math.pow(pMax, 2) + Math.pow(qMax, 2));
  return nominalPower;
}

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

LOGGER.warn("not in main component, skipping Generator: {}", g.getId());
  continue;
ConnectionBus bus = ConnectionBus.fromTerminal(g.getTerminal(), config, fakeNodes);
double pgen = g.getTargetP();
double qgen = g.getTargetQ();
double pgmin = g.getMinP();
double pgmax = g.getMaxP();
boolean isQminQmaxInverted = g.getReactiveLimits().getMinQ(pgen) > g.getReactiveLimits().getMaxQ(pgen);
if (isQminQmaxInverted) {
  LOGGER.warn("inverted qmin {} and qmax {} values for generator {}", g.getReactiveLimits().getMinQ(pgen), g.getReactiveLimits().getMaxQ(pgen), g.getId());
  qgen = -g.getTerminal().getQ();
boolean isVoltageRegulatorOn = g.isVoltageRegulatorOn();
if (config.isSpecificCompatibility() && (g.getTargetP() < 0.0001) && (g.getMinP() > 0.0001)) {
  isVoltageRegulatorOn = false;
  LOGGER.warn("out of bound regulating generator {}, targetP {}, minP {} : turn off its voltage regulation", g.getId(), g.getTargetP(), g.getMinP());
double qgmin = (config.isNoGeneratorMinMaxQ() || isQminQmaxInverted) ? -9999 : g.getReactiveLimits().getMinQ(pgen);
double qgmax = (config.isNoGeneratorMinMaxQ() || isQminQmaxInverted) ? 9999 : g.getReactiveLimits().getMaxQ(pgen);
EsgRegulatingMode mode = (isQminQmaxInverted && !Double.isNaN(qgen)) ? EsgRegulatingMode.NOT_REGULATING :
    (isVoltageRegulatorOn && g.getTargetV() >= 0.1 ? EsgRegulatingMode.REGULATING : EsgRegulatingMode.NOT_REGULATING);
double vregge = (isQminQmaxInverted && !Double.isNaN(qgen)) ? Double.NaN : (isVoltageRegulatorOn ? g.getTargetV() : Double.NaN);
float qgensh = 1.f;
ConnectionBus regulatingBus = ConnectionBus.fromTerminal(g.getRegulatingTerminal(), config, fakeNodes);

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

double redispatchPMin = redispatchLimits.containsKey(generator.getId()) ? redispatchLimits.get(generator.getId()).getPMin() : generator.getMinP();
double redispatchPMax = redispatchLimits.containsKey(generator.getId()) ? redispatchLimits.get(generator.getId()).getPMax() : generator.getMaxP();
double newP = newP(generator, deltaP, parameters.getParticipationFactor().get(generator.getId()), totalPartecipationFactor);
    network.getStateManager().getWorkingStateId(), generator.getId(), generator.getTerminal().getP(), newP,
    generator.getMinP(), generator.getMaxP(), redispatchPMin, redispatchPMax);
redispactchedP += -newP + generator.getTerminal().getP();
generator.getTerminal().setP(newP);
generator.setTargetP(-newP);

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

@Override
public void visitGenerator(Generator generator) {
  terminals.add(generator.getTerminal());
}

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

@Override
public double scale(Network n, double asked) {
  Objects.requireNonNull(n);
  Generator g = n.getGenerator(id);
  double done = 0;
  if (g != null) {
    Terminal t = g.getTerminal();
    if (!t.isConnected()) {
      connectGenerator(g);
    }
    done = Math.min(asked, g.getMaxP() - g.getTargetP());
    double oldTargetP = g.getTargetP();
    g.setTargetP(g.getTargetP() + done);
    LOGGER.info("Change active power setpoint of {} from {} to {} (pmax={})",
        g.getId(), oldTargetP, g.getTargetP(), g.getMaxP());
  } else {
    LOGGER.warn("Generator {} not found", id);
  }
  return done;
}

代码示例来源: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 (g.isVoltageRegulatorOn()) {
  double oldP = g.getTargetP();
  LOGGER.trace(" gen {} - P:{} -> P:{}", g.getId(), oldP, gs.p);
  g.setTargetP(-gs.p);
  g.getTerminal().setP(gs.p);
} else {
  double oldP = g.getTargetP();
  double oldQ = g.getTargetQ();
  LOGGER.trace(" gen {} - P:{}, Q:{} -> P:{}, Q:{} ", g.getId(), oldP, oldQ, gs.p, gs.q);
  g.setTargetP(-gs.p)
      .setTargetQ(-gs.q);
  g.getTerminal().setP(gs.p)
      .setQ(gs.q);

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

Generator generator = network.getGenerator(generatorId);
if (generator != null) {
  GeneratorData generatorData = new GeneratorData(generator.getId());
  Bus generatorBus = generator.getTerminal().getBusBreakerView().getBus();
  if (generatorBus == null) {
    generatorBus = generator.getTerminal().getBusBreakerView().getConnectableBus();
    LOGGER.warn("Skipping generator " + generator.getId() + ": not connected/connectable to a bus");
    continue;
  generatorData.setConnected(NetworkUtils.isConnected(generator));
  generatorData.setActvePower(generator.getTerminal().getP());
  generatorData.setReactvePower(generator.getTerminal().getQ());
  generatorData.setMinActivePower(generator.getMinP());
  generatorData.setMaxActivePower(generator.getMaxP());
  generatorData.setMinReactivePower(generator.getReactiveLimits().getMinQ(generator.getTargetP()));
  generatorData.setMaxReactivePower(generator.getReactiveLimits().getMaxQ(generator.getTargetP()));
  generatorData.setNominalPower(MCSNetworkUtils.getNominalPower(generator));
  generatorData.setRenewableEnergySource(MCSNetworkUtils.getRenewableEnergySource(generator));
  generatorData.setFuelType(MCSNetworkUtils.getFuelType(generator));
  generatorData.setDispatchable(MCSNetworkUtils.isDispatchable(generator));
  generatorData.setCountry(generator.getTerminal().getVoltageLevel().getSubstation().getCountry());
  generatorsData.add(generatorData);
  LOGGER.debug(generatorData.toString());

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

srcGen.getId(), -srcSv.p, newTargetP,
    -srcSv.q, newTargetQ, srcSv.u, newTargetV);
double newMinP = -fct.apply(new StateVariable(-srcGen.getMinP(), srcSv.q, srcSv.u, srcSv.theta)).p;
double newMaxP = -fct.apply(new StateVariable(-srcGen.getMaxP(), srcSv.q, srcSv.u, srcSv.theta)).p;
    srcGen.getId(), srcGen.getMinP(), srcGen.getMaxP(), newMinP, newMaxP);
String srcGenId = srcGen.getId();
String srcGenName = srcGen.getName();
EnergySource srcGenEnergySource = srcGen.getEnergySource();
boolean secGenVoltageRegulatorOn = srcGen.isVoltageRegulatorOn();
srcGen.remove();
if (srcGen.getReactiveLimits() != null) {
  switch (srcGen.getReactiveLimits().getKind()) {
    case MIN_MAX: {
      MinMaxReactiveLimits limits = srcGen.getReactiveLimits(MinMaxReactiveLimits.class);
      double newMinQ = config.isNoReactiveLimits() ? -INFINITE_REACTIVE_LIMIT : -fct.apply(new StateVariable(srcSv.p, -limits.getMinQ(), srcSv.u, srcSv.theta)).q;
      double newMaxQ = config.isNoReactiveLimits() ? INFINITE_REACTIVE_LIMIT : -fct.apply(new StateVariable(srcSv.p, -limits.getMaxQ(), srcSv.u, srcSv.theta)).q;
      LOGGER.trace("Resizing reactive limits of '{}': [{}, {}] -> [{}, {}]",
          lvGen.getId(), limits.getMinQ(), limits.getMaxQ(), newMinQ, newMaxQ);
      lvGen.newMinMaxReactiveLimits()
          .setMinQ(newMinQ)
          .setMaxQ(newMaxQ)
      ReactiveCapabilityCurve curve = srcGen.getReactiveLimits(ReactiveCapabilityCurve.class);
      ReactiveCapabilityCurveAdder rcca = lvGen.newReactiveCapabilityCurve();

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

protected static void reintegrateLfState(Network network, String workingStateId, boolean onlyVoltage) {
  network.getStateManager().setWorkingState(workingStateId);
  for (Generator g : network.getGenerators()) {
    Terminal t = g.getTerminal();
    if (!onlyVoltage) {
      if (!Double.isNaN(t.getP())) {
        double oldTargetP = g.getTargetP();
        double newTargetP = -t.getP();
        if (oldTargetP != newTargetP) {
          g.setTargetP(newTargetP);
          LOGGER.debug("LF result reintegration: targetP {} -> {}", oldTargetP, newTargetP);
        double oldTargetQ = g.getTargetQ();
        double newTargetQ = -t.getQ();
        if (oldTargetQ != newTargetQ) {
          g.setTargetQ(newTargetQ);
          LOGGER.debug("LF result reintegration: targetQ {} -> {}", oldTargetQ, newTargetQ);
    if (b != null) {
      if (!Double.isNaN(b.getV())) {
        double oldV = g.getTargetV();
        double newV = b.getV();
        if (oldV != newV) {
          g.setTargetV(newV);
          LOGGER.debug("LF result reintegration: targetV {} -> {}", oldV, newV);

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

while (itrG.hasNext()) {
  Generator gen = itrG.next();
  if (gen.getTargetP() > 0.0) {
    generationMW += gen.getTargetP();
  } else {
    loadMW += gen.getTargetP();
  generationMVAR += gen.getTargetQ();
  if (gen.getMinP() > 0.0) {
    minimumGenerationMW += gen.getMinP();
  if (gen.getMaxP() > 0.0) {
    maximumGenerationMW += gen.getMaxP();
  minimumGenerationMVAR += gen.getReactiveLimits().getMinQ((float) 0);
  maximumGenerationMVAR += gen.getReactiveLimits().getMaxQ((float) 0);
  if (gen.isVoltageRegulatorOn()) {
    desiredVoltage = gen.getTargetV() / baseKV;
    typeBus = 1; // PV bus
    generationMVAR = 0.0;

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

@Override
public String getId() {
  return generator.getId();
}

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

protected void updateSlackBusData(Bus bus, Integer busIndex, SlackBusData slackBusData) {
  if (bus.getGenerators() == null) {
    return;
  }
  //...slackbus has at least one generator connected
  for (Generator generator : bus.getGenerators()) {
    //...which has a generator with voltage regulator on
    if (!generator.isVoltageRegulatorOn()) {
      continue;
    }
    //...assure the generator is the one connected to the bus (and not on the aggregated buses)
    if (!generator.getTerminal().getBusBreakerView().getBus().getId().equals(bus.getId())) {
      return;
    }
    //...candidate slackbus
    if (slackBusData.getSlackBusIndex() == -1) {
      slackBusData.setSlackBusIndex(busIndex);
      slackBusData.setSlackBusGenerator(generator);
      return;
    }
    //...choice the generator with the largest TargetP
    if (generator.getTargetP() > slackBusData.getSlackBusGenerator().getTargetP()) {
      slackBusData.setSlackBusIndex(busIndex);
      slackBusData.setSlackBusGenerator(generator);
    }
  }
}

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

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

相关文章