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

x33g5p2x  于2022-01-16 转载在 其他  
字(13.1k)|赞(0)|评价(0)|浏览(108)

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

Bus.getV介绍

[英]Get the voltage magnitude of the bus in kV.
[中]获得母线的电压幅值,单位为kV。

代码示例

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

@Override
public double getV() {
  checkValidity();
  for (Bus b : buses) {
    if (!Double.isNaN(b.getV())) {
      return b.getV();
    }
  }
  return Double.NaN;
}

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

/**
 * Constructor to buses that come from the IIDM network.
 * @param bus
 */
public BusRecord(Bus bus) {
  this.bus = bus;
  this.busId = bus.getId();
  if (!Double.isNaN(this.bus.getV())) {
    this.busVoltage = bus.getV() / bus.getVoltageLevel().getNominalV();
    this.busAngle = this.bus.getAngle();
    addParameter(StaticData.V_0, this.busVoltage);
    addParameter(StaticData.ANGLE_0, this.busAngle);
  } else {
    this.busVoltage = Float.NaN;
  }
}

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

/**
 * This implementation takes the voltage value to be checked from the Network.
 */
@Override
public void checkVoltage(Bus bus, Consumer<LimitViolation> consumer) {
  checkVoltage(bus, bus.getV(), consumer);
}

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

/**
 * Create a Dummy  Bus (corresponding to a dangling line)
 * @param writerMo
 * @param modContext
 * @param modelicaModelsList
 * @param modelicaSim
 * @throws IOException
 */
private void exportDanglingBuses(Writer writerMo, ModExportContext modContext, List<String> modelicaModelsList, SimulatorInst modelicaSim) throws IOException {
  if ((dangLinesList.size() != 0) && (!dangLinesList.isEmpty())) {
    for (DanglingLine dl : dangLinesList) {
      Bus knownBus = dl.getTerminal().getBusBreakerView().getBus();
      SV sv = new SV(0, 0,  knownBus.getV(), knownBus.getAngle());
      SV svDangling = sv.otherSide(dl);
      double voltage = svDangling.getU() / knownBus.getVoltageLevel().getNominalV();
      double angle = svDangling.getA();
      String name = "ext_" + dl.getId();
      BusRecord busRecord = ModelConverter.getModelicaRecord(name, voltage, angle, modContext, _ddbManager, modelicaSim);
      this.danglingBuses.add(busRecord);
      this.addRecord(busRecord, writerMo, modContext, _ddbManager, modelicaSim);
    }
  }
}

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

private static double getV(Terminal t) {
  Bus b = t.getBusBreakerView().getBus();
  return b != null ? b.getV() : Double.NaN;
}

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

/**
 * Create a Dummy Load (corresponding to a dangling line)
 * @param writerMo
 * @param modContext
 * @param modelicaModelsList
 * @param modelicaSim
 * @throws IOException
 */
private void exportDanglingLoads(Writer writerMo, ModExportContext modContext, List<String> modelicaModelsList, SimulatorInst modelicaSim) throws IOException {
  if ((dangLinesList.size() != 0) && (!dangLinesList.isEmpty())) {
    for (DanglingLine dl : dangLinesList) {
      Bus knownBus = dl.getTerminal().getBusBreakerView().getBus();
      SV sv = new SV(0, 0,  knownBus.getV(), knownBus.getAngle());
      SV svDangling = sv.otherSide(dl);
      double busVoltage = svDangling.getU() / knownBus.getVoltageLevel().getNominalV();
      double busAngle = svDangling.getA();
      double p0 = dl.getP0();
      double q0 = dl.getQ0();
      String loadId = "ext_" + dl.getId();
      LoadRecord loadRecord = ModelConverter.getModelicaRecord(loadId, p0, q0, busVoltage, busAngle, modContext, _ddbManager, modelicaSim, SNREF, this._sourceEngine);
      this.danglingLoads.add(loadRecord);
      this.addRecord(loadRecord, writerMo, modContext, _ddbManager, modelicaSim);
    }
  }
}

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

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

private void writeBuses(AmplExportContext context, TableFormatter formatter) throws IOException {
  for (Bus b : AmplUtil.getBuses(network)) {
    int ccNum = ConnectedComponents.getCcNum(b);
    if (connectedComponentToExport(ccNum)) {
      String id = b.getId();
      VoltageLevel vl = b.getVoltageLevel();
      context.busIdsToExport.add(id);
      int num = mapper.getInt(AmplSubset.BUS, id);
      int vlNum = mapper.getInt(AmplSubset.VOLTAGE_LEVEL, vl.getId());
      double nomV = vl.getNominalV();
      double v = b.getV() / nomV;
      double theta = Math.toRadians(b.getAngle());
      formatter.writeCell(variantIndex)
          .writeCell(num)
          .writeCell(vlNum)
          .writeCell(ccNum)
          .writeCell(v)
          .writeCell(theta)
          .writeCell(b.getP())
          .writeCell(b.getQ())
          .writeCell(faultNum)
          .writeCell(actionNum)
          .writeCell(id);
      addExtensions(num, b);
    }
  }
}

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

private void visitInjection(Injection inj, TerminalContext context) {
  Terminal t = inj.getTerminal();
  context.update(t);
  if (config.isReplaceMissingValues()) {
    if (Double.isNaN(context.p)) {
      context.p = 0f;
    }
    if (Double.isNaN(context.q)) {
      context.q = 0f;
    }
    if (Double.isNaN(context.v)) {
      // use connectable bus voltage, better than nothing...
      context.v = t.getBusBreakerView().getConnectableBus().getV();
    }
    if (Double.isNaN(context.v)) {
      context.v = 0f; // TODO is there a better value?
    }
    if (Double.isNaN(context.i)) {
      context.i = 0f;
    }
  }
  valueMap.put(new HistoDbNetworkAttributeId(inj.getId(), HistoDbAttr.P), context.p);
  valueMap.put(new HistoDbNetworkAttributeId(inj.getId(), HistoDbAttr.Q), context.q);
  valueMap.put(new HistoDbNetworkAttributeId(inj.getId(), HistoDbAttr.V), context.v);
  valueMap.put(new HistoDbNetworkAttributeId(inj.getId(), HistoDbAttr.I), context.i);
}

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

/**
 * Export IIDM coupling devices connect to Modelica coupling devices connect
 * @param writerMo
 * @param modContext
 * @param modelicaModelsList
 * @param modelicaSim
 * @throws IOException
 */
private void exportConnectCouplingDevices(Writer writerMo, ModExportContext modContext, List<String> modelicaModelsList, SimulatorInst modelicaSim) throws IOException {
  if ((connectCouplingList.size() != 0) && (!connectCouplingList.isEmpty())) {
    LOGGER.info("EXPORTING CONNECT COUPLING DEVICES " + connectCouplingList.size());
    this.addRecord(writerMo, null);
    this.addRecord(writerMo, "// COUPLING DEVICES");
    for (VoltageLevel voltageLevel : connectCouplingList) {
      for (Switch sw : voltageLevel.getBusBreakerView().getSwitches()) {
        LOGGER.info("\t Exporting coupling device connect " + sw.getId());
        Bus bus1 = voltageLevel.getBusBreakerView().getBus1(sw.getId());
        Bus bus2 = voltageLevel.getBusBreakerView().getBus2(sw.getId());
        if (!Double.isNaN(bus1.getV()) && !Double.isNaN(bus2.getV())) {
          ConnectCouplingDevicesRecord couplingDeviceRecord = ModelConverter.getModelicaRecord(sw, bus1, bus2, modContext, _ddbManager, modelicaSim);
          this.addRecord(couplingDeviceRecord, writerMo, modContext, _ddbManager, modelicaSim);
        }
      }
    }
  }
}

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

/**
 * Export IIDM Generators to Modelica Generators-OmegaRef connect
 */
private void exportConnectGlobalVar(Writer writerMo, ModExportContext modContext, List<Injection> identList, GlobalVariable globalVar, SimulatorInst modelicaSim) throws IOException {
  if ((identList.size() != 0) && (!identList.isEmpty())) {
    this.addRecord(writerMo, null);
    for (Injection injection : identList) {
      ConnectBusInfo busInfo = findBus(injection.getTerminal(), injection.getId());
      if (!Double.isNaN(busInfo.getBus().getV()) && busInfo.isConnected()) {
        ConnectGlobalVarRecord record = ModelConverter.getModelicaRecord(injection, globalVar, modContext, _ddbManager, modelicaSim);
        if (record != null) {
          this.addRecord(record, writerMo, modContext, _ddbManager, modelicaSim);
        }
      }
    }
  }
}

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

/**
 * Export IIDM shunts connect to Modelica capacitors connect
 */
private void exportConnectCapacitors(Writer writerMo, ModExportContext modContext, List<String> modelicaModelsList, SimulatorInst modelicaSim) throws IOException {
  if ((connectCapacitorsList.size() != 0) && (!connectCapacitorsList.isEmpty())) {
    LOGGER.info("EXPORTING CONNECT CAPACITORS");
    this.addRecord(writerMo, null);
    this.addRecord(writerMo, "// Connecting Capacitors");
    for (ShuntCompensator capacitor : connectCapacitorsList) {
      LOGGER.info("\t Exporting capacitor connect " + capacitor.getId());
      ConnectBusInfo busInfo = findBus(capacitor.getTerminal(), capacitor.getId());
      if (!Double.isNaN(busInfo.getBus().getV())) {
        if (busInfo.isConnected()) {
          ConnectRecord capacitorConnect = ModelConverter.getModelicaRecord(busInfo, capacitor, modContext, _ddbManager, modelicaSim);
          this.addRecord(capacitorConnect, writerMo, modContext, _ddbManager, modelicaSim);
        }
      }
    }
  }
}

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

@Override
protected void writeRootElementAttributes(Bus b, VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException {
  XmlUtil.writeDouble("v", b.getV(), context.getWriter());
  XmlUtil.writeDouble("angle", b.getAngle(), context.getWriter());
}

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

/**
 * Export IIDM loads connect to Modelica loads connect
 * @param writerMo
 * @param modContext
 * @param modelicaModelsList
 * @param modelicaSim
 * @throws IOException
 */
private void exportConnectLoads(Writer writerMo, ModExportContext modContext, List<String> modelicaModelsList, SimulatorInst modelicaSim) throws IOException {
  if ((connectLoadsList.size() != 0) && (!connectLoadsList.isEmpty())) {
    LOGGER.info("EXPORTING CONNECT LOADS");
    this.addRecord(writerMo, null);
    this.addRecord(writerMo, "// Connecting LOADS");
    for (Load load : connectLoadsList) {
      LOGGER.info("\t Exporting load connect " + load.getId());
      ConnectBusInfo busInfo = findBus(load.getTerminal(), load.getId());
      if (!Double.isNaN(busInfo.getBus().getV())) {
        if (busInfo.isConnected()) {
          ConnectRecord loadConnect = ModelConverter.getModelicaRecord(busInfo, load, modContext, _ddbManager, modelicaSim);
          this.addRecord(loadConnect, writerMo, modContext, _ddbManager, modelicaSim);
        }
      }
    }
  }
}

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

private static double getV(LegBase<?> leg) {
  return leg.getTerminal().isConnected() ? leg.getTerminal().getBusView().getBus().getV() : Double.NaN;
}

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

public LoadRecord(Load load, ConnectBusInfo busInfo, double snref, SourceEngine sourceEngine) {
  this.load = load;
  this.busInfo = busInfo;
  this.loadId = load.getId();
  this.busConnected = busInfo.isConnected();
  this.p0 = this.load.getP0();
  this.q0 = this.load.getQ0();
  this.busVoltage = Double.NaN;
  this.busAngle = Double.NaN;
  this.sourceEngine = sourceEngine;
  if (this.busConnected) {
    if (load.getTerminal().getBusView().getBus() != null) {
      if (!Double.isNaN(load.getTerminal().getBusView().getBus().getV())) {
        busVoltage = load.getTerminal().getBusView().getBus().getV() / load.getTerminal().getVoltageLevel().getNominalV();
      }
      if (!Double.isNaN(load.getTerminal().getBusView().getBus().getAngle())) {
        busAngle = load.getTerminal().getBusView().getBus().getAngle();
      }
    }
    addLfParameters();
  } else {
    LOGGER.warn("Load " + this.getModelicaName() + " disconnected.");
    this.addValue(StaticData.COMMENT + " Load " + this.getModelicaName() + " disconnected.");
  }
  if (this.busVoltage == 0) {
    LOGGER.info("Voltage 0");
  }
}

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

相关文章