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

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

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

Network.getVariantManager介绍

[英]Get the variant manager of the network.
[中]获取网络的变体管理器。

代码示例

代码示例来源: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-security-analysis-api

public SecurityAnalysisResult analyze(Network network, ContingenciesProvider contingenciesProvider, SecurityAnalysisParameters parameters) {
    Objects.requireNonNull(network);
    Objects.requireNonNull(contingenciesProvider);
    Objects.requireNonNull(parameters);

    network.getVariantManager().allowVariantMultiThreadAccess(true);

    SecurityAnalysis securityAnalysis = securityAnalysisFactory.create(network, filter, computationManager, priority);
    interceptors.forEach(securityAnalysis::addInterceptor);

    return securityAnalysis.run(network.getVariantManager().getWorkingVariantId(), parameters, contingenciesProvider).join();
  }
}

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

public static String getTableTitle(Network network, String tableName) {
  return tableName + " (" + network.getId() + "/" + network.getVariantManager().getWorkingVariantId() + ")";
}

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

public static void dumpVariantId(Path workingDir, Network network) throws IOException {
  dumpVariantId(workingDir, network.getVariantManager().getWorkingVariantId());
}

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

@Override
public List<CommandExecution> before(Path workingDir) throws IOException {
  network.getVariantManager().setWorkingVariant(workingStateId);
  copyInputFiles(workingDir);
  return buildCommandExecution();
}

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

@Override
public Network importData(ReadOnlyDataSource dataSource, Properties parameters) {
  Network network = Mockito.mock(Network.class);
  VariantManager variantManager = Mockito.mock(VariantManager.class);
  Mockito.when(variantManager.getWorkingVariantId()).thenReturn("s1");
  Mockito.when(network.getVariantManager()).thenReturn(variantManager);
  return network;
}

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

network.getVariantManager().allowVariantMultiThreadAccess(true);
String currentState = network.getVariantManager().getWorkingVariantId();

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

LoadFlowResult result = loadFlow.run(network.getVariantManager().getWorkingVariantId(), params).join();

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

String workingStateId = network.getVariantManager().getWorkingVariantId();
SensitivityFactorsProviderFactory factorsProviderFactory = defaultConfig.newFactoryImpl(SensitivityFactorsProviderFactory.class);
SensitivityFactorsProvider factorsProvider = factorsProviderFactory.create(sensitivityFactorsFile);

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

network.getVariantManager().allowVariantMultiThreadAccess(true);
securityAnalysis.run(network.getVariantManager().getWorkingVariantId(), parameters, contingencyListProvider)
    .handleAsync((result, throwable) -> {
      if (throwable == null) {

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

network.getVariantManager().setWorkingVariant(workingStateId);
          network.getVariantManager().cloneVariant(VariantManagerConstants.INITIAL_VARIANT_ID, postContStateId);
          network.getVariantManager().setWorkingVariant(postContStateId);
        .thenComposeAsync(aVoid -> loadFlow.run(postContStateId, postContParameters), computationManager.getExecutor())
        .handleAsync((lfResult, throwable) -> {
          network.getVariantManager().setWorkingVariant(postContStateId);
          violationDetector.checkAll(network, resultBuilder::addViolation);
          resultBuilder.endContingency();
          network.getVariantManager().removeVariant(postContStateId);
    network.getVariantManager().setWorkingVariant(workingStateId);
    return resultBuilder.build();
  });

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

@Override
  public void onPostContingencyResult(RunningContext context, PostContingencyResult postContingencyResult) {
    String workingStateId = context.getNetwork().getVariantManager().getWorkingVariantId();

    for (LimitViolation limitViolation : postContingencyResult.getLimitViolationsResult().getLimitViolations()) {
      if (limitViolation.getLimitType() == LimitViolationType.CURRENT) {
        Branch branch = context.getNetwork().getBranch(limitViolation.getSubjectId());

        context.getNetwork().getVariantManager().setWorkingVariant(context.getInitialStateId());
        limitViolation.addExtension(CurrentExtension.class, new CurrentExtension(branch.getTerminal(limitViolation.getSide()).getI()));
        double preContingencyValue = branch.getTerminal(limitViolation.getSide()).getP();

        context.getNetwork().getVariantManager().setWorkingVariant(workingStateId);
        double postContingencyValue = branch.getTerminal(limitViolation.getSide()).getP();

        limitViolation.addExtension(ActivePowerExtension.class, new ActivePowerExtension(preContingencyValue, postContingencyValue));
      }
    }
  }
}

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

private void runSingleAnalysis(ToolRunningContext context, Path caseFile, Path outputCsvFile, Set<String> contingencyIds, ContingenciesProvider contingenciesProvider,
                SimulatorFactory simulatorFactory) throws Exception {
  context.getOutputStream().println("loading case " + caseFile + "...");
  // load the network
  Network network = Importers.loadNetwork(caseFile);
  if (network == null) {
    throw new PowsyblException("Case '" + caseFile + "' not found");
  }
  network.getVariantManager().allowVariantMultiThreadAccess(true);
  Multimap<String, SecurityIndex> securityIndexesPerContingency
      = runImpactAnalysis(network, contingencyIds, context.getShortTimeExecutionComputationManager(),
      simulatorFactory, contingenciesProvider, context.getOutputStream());
  if (securityIndexesPerContingency != null) {
    if (outputCsvFile == null) {
      prettyPrint(securityIndexesPerContingency, context.getOutputStream());
    } else {
      writeCsv(securityIndexesPerContingency, outputCsvFile);
    }
  }
}

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

String stateId = network.getVariantManager().getWorkingVariantId();
String tmpStateId = "phase-shifter-optim-" + UUID.randomUUID();
network.getVariantManager().cloneVariant(stateId, tmpStateId);
try {
  network.getVariantManager().setWorkingVariant(tmpStateId);
  LoadFlowFactory loadFlowFactory = config.getLoadFlowFactoryClass().newInstance();
  LoadFlow loadFlow = loadFlowFactory.create(network, computationManager, 0);
} finally {
  network.getVariantManager().removeVariant(tmpStateId);
  network.getVariantManager().setWorkingVariant(stateId);

代码示例来源:origin: com.powsybl/powsybl-loadflow-results-completion

@Override
public void run(Network network, ComputationManager computationManager) {
  Objects.requireNonNull(network);
  LOGGER.info("Running {} on network {}, state {}", getName(), network.getId(), network.getVariantManager().getWorkingVariantId());
  LOGGER.info("LoadFlowResultsCompletionParameters={}", parameters);
  LOGGER.info("LoadFlowParameters={}", lfParameters);

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

new RunningContext(network, network.getVariantManager().getWorkingVariantId()));

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

@Test
public void failedResult() {
  SecurityAnalysisResultBuilder builder = new SecurityAnalysisResultBuilder(new LimitViolationFilter(),
      new RunningContext(network, network.getVariantManager().getWorkingVariantId()));
  SecurityAnalysisResult res = builder.preContingency().setComputationOk(false).endPreContingency().build();
  assertFalse(res.getPreContingencyResult().isComputationOk());
  assertTrue(res.getPreContingencyResult().getLimitViolations().isEmpty());
  assertTrue(res.getPostContingencyResults().isEmpty());
}

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

@Test
public void exceptions() {
  SecurityAnalysisResultBuilder builder = new SecurityAnalysisResultBuilder(new LimitViolationFilter(),
      new RunningContext(network, network.getVariantManager().getWorkingVariantId()));
  assertThatIllegalStateException().isThrownBy(() -> builder.build());
  List<LimitViolation> violations = Security.checkLimits(network);
  assertThatIllegalStateException().isThrownBy(() -> builder.addViolation(violations.get(0)));
  builder.preContingency()
      .endPreContingency();
  assertThatIllegalStateException().isThrownBy(() -> builder.addViolation(violations.get(0)));
  builder.contingency(new Contingency("contingency"))
      .endContingency();
  assertThatIllegalStateException().isThrownBy(() -> builder.addViolation(violations.get(0)));
}

相关文章