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

x33g5p2x  于2022-01-24 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(157)

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

Network.getVoltageLevel介绍

[英]Get a substation voltage level.
[中]获取变电站电压水平。

代码示例

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

public VoltageLevel getVoltageLevelByEsgId(String esgId) {
  String voltageLevelId = fakeNodesMap.inverse().get(esgId);
  return voltageLevelId != null ? network.getVoltageLevel(voltageLevelId) : null;
}

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

private static void updateVoltageLevel(XMLStreamReader reader, Network network, VoltageLevel[] vl) {
  String id = reader.getAttributeValue(null, "id");
  vl[0] = network.getVoltageLevel(id);
  if (vl[0] == null) {
    throw new PowsyblException("Voltage level '" + id + "' not found");
  }
}

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

@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {
  String caseFormat = line.getOptionValue("case-format");
  Path caseDir = Paths.get(line.getOptionValue("case-dir"));
  String[] voltageLevelIds = line.getOptionValue("voltage-level-ids").split(",");
  Importer importer = Importers.getImporter(caseFormat);
  if (importer == null) {
    throw new PowsyblException("Format " + caseFormat + " not supported");
  }
  context.getOutputStream().print("Case name");
  for (String voltageLevelId : voltageLevelIds) {
    context.getOutputStream().print(CSV_SEPARATOR + voltageLevelId);
  }
  context.getOutputStream().println();
  Importers.importAll(caseDir, importer, false, network -> {
    try {
      for (String voltageLevelId : voltageLevelIds) {
        context.getOutputStream().print(CSV_SEPARATOR);
        VoltageLevel vl = network.getVoltageLevel(voltageLevelId);
        if (vl != null) {
          JSONArray toposArray = IIDM2DB.toTopoSet(vl);
          context.getOutputStream().print(toposArray.toString());
        }
      }
      context.getOutputStream().println();
    } catch (Exception e) {
      LOGGER.error(e.toString(), e);
    }
  }, dataSource -> context.getOutputStream().print(dataSource.getBaseName()));
}

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

private VoltageLevel voltageLevel() {
  String cgmesId = p.getId(CgmesNames.VOLTAGE_LEVEL);
  String iidmId = context.namingStrategy().getId(CgmesNames.VOLTAGE_LEVEL, cgmesId);
  return iidmId != null ? context.network().getVoltageLevel(iidmId) : null;
}

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

@Override
public void modify(Network network, ComputationManager computationManager) {
  VoltageLevel vl = network.getVoltageLevel(voltageLevelId);
  if (vl == null) {
    throw new PowsyblException("Voltage level '" + voltageLevelId + "' not found");
  }
  Switch s = vl.getBusBreakerView().getSwitch(breakerId);
  if (s == null) {
    throw new PowsyblException("Breaker '" + breakerId + "' not found");
  }
  s.setOpen(false);
}

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

@Override
public void modify(Network network, ComputationManager computationManager) {
  VoltageLevel vl = network.getVoltageLevel(voltageLevelId);
  if (vl == null) {
    throw new PowsyblException("Voltage level '" + voltageLevelId + "' not found");
  }
  Switch s = vl.getBusBreakerView().getSwitch(breakerId);
  if (s == null) {
    throw new PowsyblException("Breaker '" + breakerId + "' not found");
  }
  s.setOpen(true);
}

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

@Override
public Set<eu.itesla_project.modules.contingencies.Zone> getZones(Network network) {
  Objects.requireNonNull(network, "network is null");
  LOGGER.info("Getting zones for network {}", network.getId());
  Set<eu.itesla_project.modules.contingencies.Zone> res = new HashSet<eu.itesla_project.modules.contingencies.Zone>();
  Zones zones = actionContingencies.getZones();
  if (zones != null) {
    for (Zone z : zones.getZone()) {
      List<eu.itesla_project.modules.contingencies.VoltageLevel> vls = new ArrayList<eu.itesla_project.modules.contingencies.VoltageLevel>();
      for (VoltageLevel vl : z.getVoltageLevels().getVoltageLevel()) {
        if (network.getVoltageLevel(vl.getID()) != null) {
          vls.add(new VoltageLevelImpl(vl.getID(), vl.getLevel()));
        } else {
          LOGGER.warn("Voltage level {} of zone {} does not belong to network {}, skipping it", vl.getID(), z.getName(), network.getId());
        }
      }
      if (vls.size() > 0) {
        eu.itesla_project.modules.contingencies.Zone zone = new ZoneImpl(z.getName(), z.getNumber(), vls, z.getDescription());
        res.add(zone);
      }
    }
  }
  LOGGER.info("Found {} zones for network {}", res.size(), network.getId());
  return res;
}

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

private void setNewLowVoltageLimit(String stateId, LimitViolation violation, float margin, boolean applyToBaseCase) {
  VoltageLevel voltageLevel = network.getVoltageLevel(violation.getSubjectId());
  if (voltageLevel != null) {
    if (violation.getValue() < voltageLevel.getLowVoltageLimit()) { // it could already have been fixed
      double newLimit = getNewLowerLimit(violation, margin);
      LOGGER.debug("State {}: changing low voltage limit of voltage level {}: {} -> {}",
          stateId,
          voltageLevel.getId(),
          violation.getLimit(),
          newLimit);
      voltageLevel.setLowVoltageLimit(newLimit);
      if (applyToBaseCase && !StateManagerConstants.INITIAL_STATE_ID.equals(stateId)) { // change the limit also to basecase
        network.getStateManager().setWorkingState(StateManagerConstants.INITIAL_STATE_ID);
        voltageLevel = network.getVoltageLevel(violation.getSubjectId());
        LOGGER.debug("State {}: changing low voltage limit of voltage level {}: {} -> {}",
              StateManagerConstants.INITIAL_STATE_ID,
              voltageLevel.getId(),
              violation.getLimit(),
              newLimit);
        voltageLevel.setLowVoltageLimit(newLimit);
      }
    }
  } else {
    LOGGER.warn("State {}: cannot change low voltage limit of voltage level {}: no voltage level with this id in the network",
        stateId,
        violation.getSubjectId());
  }
}

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

private void setNewHighVoltageLimit(String stateId, LimitViolation violation, float margin, boolean applyToBaseCase) {
  VoltageLevel voltageLevel = network.getVoltageLevel(violation.getSubjectId());
  if (voltageLevel != null) {
    if (violation.getValue() > voltageLevel.getHighVoltageLimit()) { // it could already have been fixed
      double newLimit = getNewUpperLimit(violation, margin);
      LOGGER.debug("State {}: changing high voltage limit of voltage level {}: {} -> {}",
          stateId,
          voltageLevel.getId(),
          violation.getLimit(),
          newLimit);
      voltageLevel.setHighVoltageLimit(newLimit);
      if (applyToBaseCase && !StateManagerConstants.INITIAL_STATE_ID.equals(stateId)) { // change the limit also to basecase
        network.getStateManager().setWorkingState(StateManagerConstants.INITIAL_STATE_ID);
        voltageLevel = network.getVoltageLevel(violation.getSubjectId());
        LOGGER.debug("State {}: changing high voltage limit of voltage level {}: {} -> {}",
              StateManagerConstants.INITIAL_STATE_ID,
              voltageLevel.getId(),
              violation.getLimit(),
              newLimit);
        voltageLevel.setHighVoltageLimit(newLimit);
        network.getStateManager().setWorkingState(stateId);
      }
    }
  } else {
    LOGGER.warn("State {}: cannot change high voltage limit of voltage level {}: no voltage level with this id in the network",
        stateId,
        violation.getSubjectId());
  }
}

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

public EquipmentTypes  equipmentType(String equipment) {
  if (network.getGenerator(equipment) != null) {
    return EquipmentTypes.GEN;
  }
  if (network.getLoad(equipment) != null) {
    return EquipmentTypes.LOAD;
  }
  if (network.getLine(equipment) != null) {
    return EquipmentTypes.LINE;
  }
  if (network.getTwoWindingsTransformer(equipment) != null) {
    return EquipmentTypes.TWOWINDTRASF;
  }
  if (network.getThreeWindingsTransformer(equipment) != null) {
    return EquipmentTypes.THREEWINDTRASF;
  }
  if (network.getVoltageLevel(equipment) != null) {
    return EquipmentTypes.VOLTAGELEVEL;
  }
  if (network.getShunt(equipment) != null) {
    return EquipmentTypes.SHUNT;
  }
  if (network.getSubstation(equipment) != null) {
    return EquipmentTypes.SUBSTATION;
  }
  logger.warn(" Type not found for equipment:" + equipment + " return NULL");
  return null;
}

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

for (PossibleTopology possibleTopology : topologyChoice.getPossibleTopologies()) {
  for (PossibleTopology.Substation possibleSubstation : possibleTopology.getMetaSubstation().getSubstations()) {
    VoltageLevel vl = network.getVoltageLevel(possibleSubstation.getId());
    if (vl == null) {
      continue;

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

@Test
  //test voltage limit violation
  public void checkVoltage() {
    VoltageLevel vl = network.getVoltageLevel("VLHV1");

    LimitViolationDetector detector = new DefaultLimitViolationDetector();

    List<LimitViolation> violations = new ArrayList<>();
    vl.getBusView().getBusStream().forEach(b -> detector.checkVoltage(b, 380, violations::add));

    assertEquals(1, violations.size());
    LimitViolation violation = violations.get(0);
    //check that is LimitViolationType.LOW_VOLTAGE limit violation
    assertEquals(LimitViolationType.LOW_VOLTAGE, violation.getLimitType());

    violations.clear();
    vl.getBusView().getBusStream().forEach(b -> detector.checkVoltage(b, 520, violations::add));

    assertEquals(1, violations.size());
    violation = violations.get(0);
    //check that is LimitViolationType.HIGH_VOLTAGE limit violation
    assertEquals(LimitViolationType.HIGH_VOLTAGE, violation.getLimitType());
  }
}

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

@Override
public void convert() {
  String baseVoltage = p.getId("BaseVoltage");
  double nominalVoltage = p.asDouble("nominalVoltage");
  double lowVoltageLimit = p.asDouble("lowVoltageLimit");
  double highVoltageLimit = p.asDouble("highVoltageLimit");
  // Missing elements in the boundary file
  if (Double.isNaN(nominalVoltage)) {
    nominalVoltage = (lowVoltageLimit + highVoltageLimit) / 2.0;
    if (Double.isNaN(nominalVoltage)) {
      nominalVoltage = Math.PI;
    }
    missing(String.format("BaseVoltage %s", baseVoltage), nominalVoltage);
  }
  String voltageLevelId = context.namingStrategy().getId("VoltageLevel", id);
  VoltageLevel voltageLevel = context.network().getVoltageLevel(voltageLevelId);
  if (voltageLevel == null) {
    substation.newVoltageLevel()
        .setId(voltageLevelId)
        .setName(name)
        .setEnsureIdUnicity(false)
        .setNominalV(nominalVoltage)
        .setTopologyKind(TopologyKind.BUS_BREAKER)
        .setLowVoltageLimit(lowVoltageLimit)
        .setHighVoltageLimit(highVoltageLimit)
        .add();
  }
}

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

public static Network createWithMoreSVCs() {
    Network network = create();

    network.getVoltageLevel("VL2").newStaticVarCompensator()
        .setId("SVC3")
        .setConnectableBus("B2")
        .setBus("B2")
        .setBmin(0.0002)
        .setBmax(0.0008)
        .setRegulationMode(StaticVarCompensator.RegulationMode.VOLTAGE)
        .setVoltageSetPoint(390)
        .setReactivePowerSetPoint(350)
        .add();

    return network;
  }
}

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

new RunningContext(network, network.getVariantManager().getWorkingVariantId()));
VoltageLevel vl = network.getVoltageLevel("VLHV1");
vl.getBusView().getBusStream().forEach(b -> b.setV(410));

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

assert isXNode(tn2) && !isXNode(tn1);
String voltageLevelId1 = namingStrategy.getId(tn1.getConnectivityNodeContainer());
VoltageLevel voltageLevel1 = network.getVoltageLevel(voltageLevelId1);
boolean ect2isConnected = true;
float p0 = 0;

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

TerminalData(String terminalPropertyName, PropertyBag p, Conversion.Context context) {
  t = context.cgmes().terminal(p.getId(terminalPropertyName));
  String nodeId = context.nodeBreaker() ? t.connectivityNode() : t.topologicalNode();
  this.busId = context.namingStrategy().getId("Bus", nodeId);
  if (context.config().convertBoundary()
      && context.boundary().containsNode(nodeId)) {
    cgmesVoltageLevelId = context.boundaryVoltageLevelId(nodeId);
  } else {
    // cgmesVoltageLevelId may be null if terminal is contained in a Line
    // (happens in boundaries)
    cgmesVoltageLevelId = t.voltageLevel();
  }
  if (cgmesVoltageLevelId != null) {
    iidmVoltageLevelId = context.namingStrategy().getId("VoltageLevel",
        cgmesVoltageLevelId);
    voltageLevel = context.network().getVoltageLevel(iidmVoltageLevelId);
  } else {
    iidmVoltageLevelId = null;
    voltageLevel = null;
  }
}

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

public static Network createVsc() {
  Network network = createBase();
  VoltageLevel vl1 = network.getVoltageLevel("VL1");
  VscConverterStation cs1 = vl1.newVscConverterStation()
      .setId("C1")
      .endPoint()
      .add();
  VoltageLevel vl2 = network.getVoltageLevel("VL2");
  VscConverterStation cs2 = vl2.newVscConverterStation()
      .setId("C2")

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

public static Network createWithMoreGenerators() {
  Network network = create();
  VoltageLevel vlgen = network.getVoltageLevel(VLGEN);
  Bus ngen = vlgen.getBusBreakerView().getBus("NGEN");

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

network.getVoltageLevel(VLGEN).newGenerator()
  .setId("GEN2")
  .setBus("NGEN")

相关文章