本文整理了Java中com.powsybl.iidm.network.Network
类的一些代码示例,展示了Network
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Network
类的具体详情如下:
包路径:com.powsybl.iidm.network.Network
类名称:Network
[英]A power network model.
To create a new network, use NetworkFactory.
The network is initially created with one variant identified by VariantManagerConstants.INITIAL_VARIANT_ID
. VariantManager is responsible for variant management and is accessible from the network thanks to #getVariantManager().
Instances of Network
are not thread safe except for attributes depending of the variant (always specified in the javadoc) if VariantManager#allowVariantMultiThreadAccess(boolean) is set to true.
[中]电力网络模型。
要创建新网络,请使用NetworkFactory。
该网络最初由一个由[$0$]标识的变体创建。VariantManager负责变体管理,可通过#getVariantManager()从网络访问。
如果VariantManager#allowVariantMultiThreadAccess(布尔值)设置为true,则Network
的实例不是线程安全的,除了取决于变量的属性(始终在javadoc中指定)之外。
代码示例来源:origin: itesla/ipst
@Override
public synchronized List<Contingency> getContingencies() {
LOGGER.info("Network {}: getting contingencies", network.getId());
return contingenciesActionsDbClient.getContingencies(network);
}
代码示例来源:origin: itesla/ipst
private void numberOfElements() {
System.out.println("Buses = " + Identifiables.sort(_network.getBusBreakerView().getBuses()).size());
System.out.println("Lines = " + Identifiables.sort(_network.getLines()).size());
System.out.println("Trafos = " + Identifiables.sort(_network.getTwoWindingsTransformers()).size());
List<TwoWindingsTransformer> fixedTranformers = new ArrayList<TwoWindingsTransformer>();
List<TwoWindingsTransformer> detailedTranformers = new ArrayList<TwoWindingsTransformer>();
for (TwoWindingsTransformer trafo : Identifiables.sort(_network.getTwoWindingsTransformers())) {
if ((trafo.getRatioTapChanger() == null) && (trafo.getPhaseTapChanger() == null)) {
fixedTranformers.add(trafo);
System.out.println("Detailed Trafos = " + detailedTranformers.size());
System.out.println("Loads = " + Identifiables.sort(_network.getLoads()).size());
System.out.println("Shutns = " + Identifiables.sort(_network.getShunts()).size());
System.out.println("Machines = " + Identifiables.sort(_network.getGenerators()).size());
int numMachines = Identifiables.sort(_network.getGenerators()).size();
int numGens = _ddbManager.findEquipmentAllCount();
int numFixInyec = numMachines - numGens;
代码示例来源:origin: itesla/ipst
public void looseConstraints(String stateId, float margin, boolean applyToBaseCase) {
if (network.getStateManager().getStateIds().contains(stateId)) {
String workingStateId = network.getStateManager().getWorkingStateId();
network.getStateManager().setWorkingState(stateId);
List<LimitViolation> violations = Security.checkLimits(network);
looseConstraints(stateId, violations, margin, applyToBaseCase);
network.getStateManager().setWorkingState(workingStateId);
} else {
throw new RuntimeException("No " + stateId + " in network " + network.getId() + ": cannot loose constraints");
}
}
代码示例来源:origin: com.powsybl/powsybl-security-analysis-api
public NetworkMetadata(Network network) {
Objects.requireNonNull(network);
this.id = network.getId();
this.sourceFormat = network.getSourceFormat();
this.caseDate = network.getCaseDate();
this.forecastDistance = network.getForecastDistance();
}
代码示例来源:origin: com.powsybl/powsybl-ampl-converter
public static String getTableTitle(Network network, String tableName) {
return tableName + " (" + network.getId() + "/" + network.getVariantManager().getWorkingVariantId() + ")";
}
代码示例来源:origin: itesla/ipst
for (Generator g : network.getGenerators()) {
g.getTerminal().setP(Float.NaN).setQ(Float.NaN);
for (Load l : network.getLoads()) {
l.getTerminal().setP(Float.NaN).setQ(Float.NaN);
for (ShuntCompensator sc : network.getShunts()) {
sc.getTerminal().setP(Float.NaN).setQ(Float.NaN);
for (DanglingLine dl : network.getDanglingLines()) {
dl.getTerminal().setP(Float.NaN).setQ(Float.NaN);
for (Line l : network.getLines()) {
l.getTerminal1().setP(Float.NaN).setQ(Float.NaN);
l.getTerminal2().setP(Float.NaN).setQ(Float.NaN);
for (TwoWindingsTransformer twt : network.getTwoWindingsTransformers()) {
twt.getTerminal1().setP(Float.NaN).setQ(Float.NaN);
twt.getTerminal2().setP(Float.NaN).setQ(Float.NaN);
for (ThreeWindingsTransformer twt : network.getThreeWindingsTransformers()) {
twt.getLeg1().getTerminal().setP(Float.NaN).setQ(Float.NaN);
twt.getLeg2().getTerminal().setP(Float.NaN).setQ(Float.NaN);
twt.getLeg3().getTerminal().setP(Float.NaN).setQ(Float.NaN);
for (Bus b : network.getBusBreakerView().getBuses()) {
b.setV(Float.NaN);
b.setAngle(Float.NaN);
代码示例来源:origin: itesla/ipst
public void load(Network network, HistoDbClient histoDbClient) throws IOException, InterruptedException {
Set<HistoDbAttributeId> attributeIds = new LinkedHashSet<>();
for (Load l : network.getLoads()) {
if (l.getLoadType() != LoadType.FICTITIOUS) {
attributeIds.add(new HistoDbNetworkAttributeId(l.getId(), HistoDbAttr.P));
}
}
for (DanglingLine dl : network.getDanglingLines()) {
attributeIds.add(new HistoDbNetworkAttributeId(dl.getId(), HistoDbAttr.P0));
}
for (Generator g : network.getGenerators()) {
attributeIds.add(new HistoDbNetworkAttributeId(g.getId(), HistoDbAttr.P));
}
HistoDbStats stats = histoDbClient.queryStats(attributeIds, histoInterval, HistoDbHorizon.SN, true);
for (Load l : network.getLoads()) {
String id = l.getId();
loadLimits.put(id, range(id, HistoDbAttr.P, stats));
}
for (DanglingLine dl : network.getDanglingLines()) {
String id = dl.getId();
danglingLineLimits.put(id, range(id, HistoDbAttr.P0, stats));
}
for (Generator g : network.getGenerators()) {
String id = g.getId();
generatorLimits.put(id, range(id, HistoDbAttr.P, stats));
}
}
代码示例来源:origin: com.powsybl/powsybl-iidm-xml-converter
writer.writeAttribute("id", n.getId());
writer.writeAttribute("caseDate", n.getCaseDate().toString());
writer.writeAttribute("forecastDistance", Integer.toString(n.getForecastDistance()));
writer.writeAttribute("sourceFormat", n.getSourceFormat());
BusFilter filter = BusFilter.create(n, options);
Anonymizer anonymizer = options.isAnonymized() ? new SimpleAnonymizer() : null;
NetworkXmlWriterContext context = new NetworkXmlWriterContext(anonymizer, writer, options, filter);
for (Substation s : n.getSubstations()) {
SubstationXml.INSTANCE.write(s, null, context);
for (Line l : n.getLines()) {
if (!filter.test(l)) {
continue;
for (HvdcLine l : n.getHvdcLines()) {
if (!filter.test(l.getConverterStation1()) || !filter.test(l.getConverterStation2())) {
continue;
代码示例来源:origin: itesla/ipst
public static void applyInjections(Network network, String stateId, Map<String, Float> injections) {
Objects.requireNonNull(network);
Objects.requireNonNull(stateId);
Objects.requireNonNull(injections);
String originalStateId = network.getStateManager().getWorkingStateId();
network.getStateManager().setWorkingState(stateId);
injections.keySet().forEach(injection -> {
Load load = network.getLoad(injection);
if (load != null) {
double oldP = load.getTerminal().getP();
LOGGER.debug("Network {}, state {}: incrementing P of load {} from {} to {}",
network.getId(), network.getStateManager().getWorkingStateId(), injection, oldP, oldP + injections.get(injection));
load.getTerminal().setP(oldP + injections.get(injection));
load.setP0(oldP + injections.get(injection));
} else {
Generator generator = network.getGenerator(injection);
if (generator != null) {
double oldP = generator.getTerminal().getP();
LOGGER.debug("Network {}, state {}: incrementing P of generator {} from {} to {}",
network.getId(), network.getStateManager().getWorkingStateId(), injection, oldP, oldP + injections.get(injection));
generator.getTerminal().setP(oldP + injections.get(injection));
generator.setTargetP(-oldP - injections.get(injection));
} else {
LOGGER.error("No load or generator with id {} in network {}: cannot apply the injection", injection, network.getId());
}
}
});
network.getStateManager().setWorkingState(originalStateId);
}
代码示例来源:origin: itesla/ipst
text = "New";
filename = network.getName() + "_" + text;
LOGGER.info("# Name Q (MVAR) TargetQ P (MVAR) TargetP");
LOGGER.info("#------------ ---------------- -------------- ---------------- --------------");
for (Generator gen : network.getGenerators()) {
LOGGER.info(String.format("%s %15.8f %15.8f %15.8f %15.8f", gen.getId(), gen.getTerminal().getQ(), gen.getTargetQ(), gen.getTerminal().getP(), gen.getTargetP()));
LOGGER.info("# Name V (kV) Angle (Degrees) ");
LOGGER.info("#------------ --------------- --------------- ");
for (Bus bus : network.getBusBreakerView().getBuses()) {
LOGGER.info(String.format("%s %15.8f %15.8f", bus.getId(), bus.getV(), bus.getAngle()));
LOGGER.info("# Name From To From To ");
LOGGER.info("#------------------------ --------------- --------------- --------------- --------------- ");
for (Line line : network.getLines()) {
LOGGER.info(String.format("%s %15.8f %15.8f %15.8f %15.8f", line.getId(), line.getTerminal1().getQ(), line.getTerminal2().getQ(), line.getTerminal1().getP(), line.getTerminal2().getP()));
LOGGER.info("# Name From To From To ");
LOGGER.info("#------------------------ --------------- --------------- --------------- --------------- ");
for (Branch trafo : network.getTwoWindingsTransformers()) {
LOGGER.info(String.format("%s %15.8f %15.8f %15.8f %15.8f", trafo.getId(), trafo.getTerminal1().getQ(), trafo.getTerminal2().getQ(), trafo.getTerminal1().getP(), trafo.getTerminal2().getP()));
代码示例来源:origin: com.powsybl/powsybl-cgmes-conversion
for (Bus b : n.getBusBreakerView().getBuses()) {
PropertyBag p = new PropertyBag(SV_VOLTAGE_PROPERTIES);
p.put("angle", fs(b.getAngle()));
for (Load l : n.getLoads()) {
powerFlows.add(createPowerFlowProperties(cgmes, l.getTerminal()));
for (Generator g : n.getGenerators()) {
powerFlows.add(createPowerFlowProperties(cgmes, g.getTerminal()));
for (ShuntCompensator s : n.getShuntCompensators()) {
powerFlows.add(createPowerFlowProperties(cgmes, s.getTerminal()));
for (ShuntCompensator s : n.getShuntCompensators()) {
PropertyBag p = new PropertyBag(SV_SHUNTCOMPENSATORSECTIONS_PROPERTIES);
p.put("continuousSections", is(s.getCurrentSectionCount()));
for (TwoWindingsTransformer t : n.getTwoWindingsTransformers()) {
PropertyBag p = new PropertyBag(SV_TAPSTEP_PROPERTIES);
代码示例来源:origin: itesla/ipst
public DataMiningFacadeParams(Network network, boolean generationSampled, boolean boundariesSampled, Interval interval) {
gensIds = new ArrayList<>();
if (generationSampled) {
for (Generator gen : network.getGenerators()) {
if (gen.getEnergySource().isIntermittent()) {
gensIds.add(gen.getId());
}
}
}
// it seems that elements order in iidm model is not the same
// after two subsequent network initialization from file
Collections.sort(gensIds);
loadsIds = new ArrayList<>();
for (Load load : network.getLoads()) {
loadsIds.add(load.getId());
}
Collections.sort(loadsIds);
danglingLinesIds = new ArrayList<>();
if (boundariesSampled) {
for (DanglingLine dl : network.getDanglingLines()) {
danglingLinesIds.add(dl.getId());
}
}
Collections.sort(danglingLinesIds);
countries = EnumSet.copyOf(network.getCountries());
this.interval = interval;
}
代码示例来源:origin: itesla/ipst
public static ArrayList<String> getGeneratorsIds(Network network) {
Objects.requireNonNull(network, "network is null");
ArrayList<String> generatorsIds = new ArrayList<String>();
for (Generator generator : network.getGenerators()) {
generatorsIds.add(generator.getId());
}
Collections.sort(generatorsIds);
return generatorsIds;
}
代码示例来源: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
public VoltageLevel getVoltageLevelByEsgId(String esgId) {
String voltageLevelId = fakeNodesMap.inverse().get(esgId);
return voltageLevelId != null ? network.getVoltageLevel(voltageLevelId) : null;
}
代码示例来源:origin: itesla/ipst
@Override
public List<CommandExecution> before(Path workingDir) throws IOException {
network.getStateManager().setWorkingState(workingStateId);
context = EurostagStabilization.this.before(workingDir);
return Collections.singletonList(createCommandExecution());
}
代码示例来源: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 static BranchParallelIndexes build(Network network, EurostagEchExportConfig config, EurostagFakeNodes fakeNodes) {
Multimap<String, Identifiable> map = HashMultimap.create();
for (Branch branch : Iterables.concat(network.getLines(), network.getTwoWindingsTransformers())) {
ConnectionBus bus1 = ConnectionBus.fromTerminal(branch.getTerminal1(), config, fakeNodes);
ConnectionBus bus2 = ConnectionBus.fromTerminal(branch.getTerminal2(), config, fakeNodes);
for (VoltageLevel vl : network.getVoltageLevels()) {
for (Switch s : EchUtil.getSwitches(vl, config)) {
Bus bus1 = EchUtil.getBus1(vl, s.getId(), config);
代码示例来源:origin: com.powsybl/powsybl-iidm-api
public static Map<String, String> getExecutionTags(Network network) {
return ImmutableMap.of("variant", network.getVariantManager().getWorkingVariantId());
}
代码示例来源:origin: com.powsybl/powsybl-action-util
@Override
public void listGenerators(Network n, List<Generator> generators, List<String> notFoundGenerators) {
Objects.requireNonNull(n);
Objects.requireNonNull(generators);
Generator g = n.getGenerator(id);
if (g != null) {
generators.add(g);
} else {
if (notFoundGenerators != null) {
notFoundGenerators.add(id);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!