public VoltageLevel getVoltageLevelByEsgId(String esgId) { String voltageLevelId = fakeNodesMap.inverse().get(esgId); return voltageLevelId != null ? network.getVoltageLevel(voltageLevelId) : null; }
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"); } }
@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())); }
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; }
@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); }
@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); }
@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; }
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()); } }
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()); } }
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; }
for (PossibleTopology possibleTopology : topologyChoice.getPossibleTopologies()) { for (PossibleTopology.Substation possibleSubstation : possibleTopology.getMetaSubstation().getSubstations()) { VoltageLevel vl = network.getVoltageLevel(possibleSubstation.getId()); if (vl == null) { continue;
@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()); } }
@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(); } }
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; } }
new RunningContext(network, network.getVariantManager().getWorkingVariantId())); VoltageLevel vl = network.getVoltageLevel("VLHV1"); vl.getBusView().getBusStream().forEach(b -> b.setV(410));
assert isXNode(tn2) && !isXNode(tn1); String voltageLevelId1 = namingStrategy.getId(tn1.getConnectivityNodeContainer()); VoltageLevel voltageLevel1 = network.getVoltageLevel(voltageLevelId1); boolean ect2isConnected = true; float p0 = 0;
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; } }
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")
public static Network createWithMoreGenerators() { Network network = create(); VoltageLevel vlgen = network.getVoltageLevel(VLGEN); Bus ngen = vlgen.getBusBreakerView().getBus("NGEN");
network.getVoltageLevel(VLGEN).newGenerator() .setId("GEN2") .setBus("NGEN")