Skip to content

Commit

Permalink
Security analysis API + simple implementation based on load flow + co…
Browse files Browse the repository at this point in the history
…mmand line tool
  • Loading branch information
geofjamg committed Oct 17, 2016
1 parent 4f5ab70 commit 56bf910
Show file tree
Hide file tree
Showing 13 changed files with 534 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class LoadFlowParameters {
public class LoadFlowParameters implements Cloneable {

private static final VoltageInitMode DEFAULT_VOLTAGE_INIT_MODE = VoltageInitMode.UNIFORM_VALUES;
private static final boolean DEFAULT_TRANSFORMER_VOLTAGE_CONTROL_ON = false;
Expand Down Expand Up @@ -73,6 +73,13 @@ public LoadFlowParameters() {
this(DEFAULT_VOLTAGE_INIT_MODE, DEFAULT_TRANSFORMER_VOLTAGE_CONTROL_ON, DEFAULT_NO_GENERATOR_REACTIVE_LIMITS, DEFAULT_PHASE_SHIFTER_REGULATION_ON);
}

public LoadFlowParameters(LoadFlowParameters other) {
voltageInitMode = other.voltageInitMode;
transformerVoltageControlOn = other.transformerVoltageControlOn;
noGeneratorReactiveLimits = other.noGeneratorReactiveLimits;
phaseShifterRegulationOn = other.phaseShifterRegulationOn;
}

public VoltageInitMode getVoltageInitMode() {
return voltageInitMode;
}
Expand Down Expand Up @@ -116,6 +123,11 @@ protected Map<String, Object> toMap() {
"phaseShifterRegulationOn", phaseShifterRegulationOn);
}

@Override
public LoadFlowParameters clone() {
return new LoadFlowParameters(this);
}

@Override
public String toString() {
return toMap().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
import eu.itesla_project.commons.tools.Tool;
import eu.itesla_project.computation.ComputationManager;
import eu.itesla_project.computation.local.LocalComputationManager;
import eu.itesla_project.contingency.Contingency;
import eu.itesla_project.iidm.import_.Importer;
import eu.itesla_project.iidm.import_.Importers;
import eu.itesla_project.loadflow.api.LoadFlowFactory;
import eu.itesla_project.security.StaticSecurityAnalysis;
import eu.itesla_project.security.LimitViolation;
import eu.itesla_project.modules.contingencies.ContingenciesAndActionsDatabaseClient;
import eu.itesla_project.contingency.Contingency;
import eu.itesla_project.modules.offline.OfflineConfig;
import eu.itesla_project.modules.rules.*;
import eu.itesla_project.security.*;
import eu.itesla_project.simulation.securityindexes.SecurityIndexType;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
Expand Down Expand Up @@ -235,8 +234,8 @@ public void run(CommandLine line) throws Exception {

System.out.println("running security analysis...");

StaticSecurityAnalysis securityAnalysis = new StaticSecurityAnalysis(network, loadFlowFactory, computationManager);
Map<String, List<LimitViolation>> violationsPerContingency = securityAnalysis.run(contingencies);
SecurityAnalysis securityAnalysis = new SecurityAnalysisImpl(network, computationManager, loadFlowFactory);
SecurityAnalysisResult securityAnalysisResult = securityAnalysis.runAsync(network1 -> contingencies).join();

System.out.println("checking rules...");

Expand All @@ -246,9 +245,10 @@ public void run(CommandLine line) throws Exception {

Map<String, OverloadStatus> statusPerContingency = new HashMap<>();

for (Contingency contingency : contingencies) {
List<LimitViolation> violations = violationsPerContingency.get(contingency.getId());
boolean lfOk = violations != null && violations.isEmpty();
for (PostContingencyResult postContingencyResult : securityAnalysisResult.getPostContingencyResults()) {
Contingency contingency = postContingencyResult.getContingency();
boolean lfOk = postContingencyResult.isComputationOk()
&& postContingencyResult.getLimitViolations().isEmpty() ;
Map<SecurityIndexType, SecurityRuleCheckStatus> offlineRuleCheck = offlineRuleCheckPerContingency.get(contingency.getId());
boolean offlineRuleOk = offlineRuleCheck != null && offlineRuleCheck.get(SecurityIndexType.TSO_OVERLOAD) == SecurityRuleCheckStatus.OK;
statusPerContingency.put(contingency.getId(), new OverloadStatus(offlineRuleOk, lfOk));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ static LimitViolationFilter load(PlatformConfig platformConfig) {

private float minBaseVoltage;

public LimitViolationFilter(Set<LimitViolationType> violationTypes) {
this(violationTypes, DEFAULT_MIN_BASE_VOLTAGE);
}

public LimitViolationFilter() {
this(DEFAULT_VIOLATION_TYPES, DEFAULT_MIN_BASE_VOLTAGE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2016, 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.security;

import eu.itesla_project.contingency.Contingency;

import java.util.List;
import java.util.Objects;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian@ at rte-france.com>
*/
public class PostContingencyResult extends PreContingencyResult {

private final Contingency contingency;

public PostContingencyResult(Contingency contingency, boolean computationOk, List<LimitViolation> limitViolations) {
super(computationOk, limitViolations);
this.contingency = Objects.requireNonNull(contingency);
}

public Contingency getContingency() {
return contingency;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2016, 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.security;

import java.util.List;
import java.util.Objects;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class PreContingencyResult {

private final boolean computationOk;

private final List<LimitViolation> limitViolations;

public PreContingencyResult(boolean computationOk, List<LimitViolation> limitViolations) {
this.computationOk = computationOk;
this.limitViolations = Objects.requireNonNull(limitViolations);
}

public boolean isComputationOk() {
return computationOk;
}

public List<LimitViolation> getLimitViolations() {
return limitViolations;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2016, 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.security;

import eu.itesla_project.contingency.ContingenciesProvider;
import eu.itesla_project.loadflow.api.LoadFlowParameters;

import java.util.concurrent.CompletableFuture;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface SecurityAnalysis {

CompletableFuture<SecurityAnalysisResult> runAsync(ContingenciesProvider contingenciesProvider, String workingStateId, LoadFlowParameters parameters);

CompletableFuture<SecurityAnalysisResult> runAsync(ContingenciesProvider contingenciesProvider, String workingStateId);

CompletableFuture<SecurityAnalysisResult> runAsync(ContingenciesProvider contingenciesProvider);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2016, 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.security;

import eu.itesla_project.computation.ComputationManager;
import eu.itesla_project.iidm.network.Network;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface SecurityAnalysisFactory {

SecurityAnalysis create(Network network, ComputationManager computationManager, int priority);

}

0 comments on commit 56bf910

Please sign in to comment.