Skip to content

Commit

Permalink
filter out invalid contingencies in Eurostag impact analysis and expo…
Browse files Browse the repository at this point in the history
…rt tool
  • Loading branch information
CBiasuzzi committed Nov 12, 2018
1 parent 9125017 commit f63fd62
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public void run(CommandLine line, ToolRunningContext context) throws Exception {
try (BufferedWriter writer = Files.newBufferedWriter(outputDir.resolve(PRE_FAULT_SEQ_FILE_NAME), StandardCharsets.UTF_8)) {
scenario.writePreFaultSeq(writer, PRE_FAULT_SAC_FILE_NAME);
}
ContingenciesProvider contingenciesProvider = defaultConfig.newFactoryImpl(ContingenciesProviderFactory.class).create();
ContingenciesProvider contingenciesProvider = new FilterValidContingenciesProvider(defaultConfig.newFactoryImpl(ContingenciesProviderFactory.class).create());

scenario.writeFaultSeqArchive(contingenciesProvider.getContingencies(network), network, dictionary, faultNum -> FAULT_SEQ_FILE_NAME.replace(com.powsybl.computation.CommandConstants.EXECUTION_NUMBER_PATTERN, Integer.toString(faultNum)))
.as(ZipExporter.class).exportTo(outputDir.resolve(ALL_SCENARIOS_ZIP_FILE_NAME).toFile());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public EurostagImpactAnalysis(Network network, ComputationManager computationMan
this.network = network;
this.computationManager = computationManager;
this.priority = priority;
this.contingenciesProvider = contingenciesProvider;
this.contingenciesProvider = new FilterValidContingenciesProvider(contingenciesProvider);
this.config = config;
this.exportConfig = exportConfig;
allCmd = createCommand(ALL_SCENARIOS_ZIP_FILE_NAME, WP43_ALL_CONFIGS_ZIP_FILE_NAME);
Expand Down Expand Up @@ -499,7 +499,7 @@ private Command before(SimulationState state, Set<String> contingencyIds, Path w
}
} else {
// filter contingencies
for (Contingency c : contingenciesProvider.getContingencies(network)) {
for (Contingency c : allContingencies) {
if (contingencyIds.contains(c.getId())) {
contingencies.add(c);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2018, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package eu.itesla_project.eurostag;

import com.powsybl.contingency.ContingenciesProvider;
import com.powsybl.contingency.Contingency;
import com.powsybl.iidm.network.Network;

import java.util.List;

/**
* @author Christian Biasuzzi <christian.biasuzzi@techrain.it>
*/
public class FilterValidContingenciesProvider implements ContingenciesProvider {

final ContingenciesProvider wrappedProvider;

public FilterValidContingenciesProvider(ContingenciesProvider wrappedProvider) {
this.wrappedProvider = wrappedProvider;
}

@Override
public List<Contingency> getContingencies(Network network) {
return Contingency.checkValidity(wrappedProvider.getContingencies(network), network);
}
}

0 comments on commit f63fd62

Please sign in to comment.