Skip to content

Commit

Permalink
Remove base case scenario in DSA
Browse files Browse the repository at this point in the history
Signed-off-by: lisrte <[email protected]>
  • Loading branch information
Lisrte authored and flo-dup committed Dec 12, 2024
1 parent ce17eb5 commit 2c946de
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public final class SecurityAnalysisConstants {

public static final String CONTINGENCIES_FILENAME = "contingencies.json";

public static final String BASE_SCENARIO_NAME = "Base";

private SecurityAnalysisConstants() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.List;
import java.util.Map;

import static com.powsybl.dynaflow.SecurityAnalysisConstants.BASE_SCENARIO_NAME;
import static com.powsybl.dynaflow.SecurityAnalysisConstants.CONSTRAINTS_FOLDER;
import static com.powsybl.dynawo.commons.DynawoConstants.AGGREGATED_RESULTS;

Expand Down Expand Up @@ -56,16 +55,10 @@ public static SecurityAnalysisResult createSecurityAnalysisResult(Network networ
private static PreContingencyResult getPreContingencyResult(Network network, LimitViolationFilter violationFilter,
Path constraintsDir, Map<String, Status> scenarioResults) {
NetworkResult networkResult = new NetworkResult(Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
if (scenarioResults.containsKey(BASE_SCENARIO_NAME)) {
return new PreContingencyResult(ResultsUtil.convertToPreStatus(scenarioResults.get(BASE_SCENARIO_NAME)),
getLimitViolationsResult(network, violationFilter, constraintsDir, BASE_SCENARIO_NAME),
networkResult);
} else {
//Dynaflow SA case (see issue #174)
List<LimitViolation> limitViolations = Security.checkLimits(network);
List<LimitViolation> filteredViolations = violationFilter.apply(limitViolations, network);
return new PreContingencyResult(LoadFlowResult.ComponentResult.Status.CONVERGED, new LimitViolationsResult(filteredViolations), networkResult);
}
//Dynaflow SA case (see issue #174)
List<LimitViolation> limitViolations = Security.checkLimits(network);
List<LimitViolation> filteredViolations = violationFilter.apply(limitViolations, network);
return new PreContingencyResult(LoadFlowResult.ComponentResult.Status.CONVERGED, new LimitViolationsResult(filteredViolations), networkResult);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/
package com.powsybl.dynaflow.results;

import com.powsybl.loadflow.LoadFlowResult;
import com.powsybl.security.PostContingencyComputationStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -36,13 +35,6 @@ public static PostContingencyComputationStatus convertToPostStatus(Status status
};
}

public static LoadFlowResult.ComponentResult.Status convertToPreStatus(Status status) {
return switch (status) {
case CONVERGENCE -> LoadFlowResult.ComponentResult.Status.CONVERGED;
case DIVERGENCE, EXECUTION_PROBLEM, CRITERIA_NON_RESPECTED -> LoadFlowResult.ComponentResult.Status.FAILED;
};
}

static Optional<ScenarioResult> createScenarioResult(String id, String status, List<FailedCriterion> failedCriteria) {
if (id == null || status == null || failedCriteria == null) {
LOGGER.warn("Inconsistent scenario result entry (id: '{}', status: '{}', failedCriteria: '{}')", id, status, failedCriteria);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"subjectId" : "_BUS____1-BUS____2-1_AC",
"subjectName" : "BUS 1-BUS 2-1",
"limitType" : "CURRENT",
"limitName" : "PATL",
"limitName" : "permanent",
"limit" : 836.74,
"limitReduction" : 1.0,
"value" : 1248.100487597837,
"value" : 1248.0773003764798,
"side" : "ONE"
} ],
"actionsTaken" : [ ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"version" : "1.7",
"preContingencyResult" : {
"status" : "FAILED",
"status" : "CONVERGED",
"limitViolationsResult" : {
"limitViolations" : [ {
"subjectId" : "_BUS____1-BUS____2-1_AC",
"subjectName" : "BUS 1-BUS 2-1",
"limitType" : "CURRENT",
"limitName" : "PATL",
"limitName" : "permanent",
"limit" : 836.74,
"limitReduction" : 1.0,
"value" : 1248.100487597837,
"value" : 1248.0773003764798,
"side" : "ONE"
} ],
"actionsTaken" : [ ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"version" : "1.7",
"preContingencyResult" : {
"status" : "FAILED",
"status" : "CONVERGED",
"limitViolationsResult" : {
"limitViolations" : [ {
"subjectId" : "_BUS____1-BUS____2-1_AC",
"subjectName" : "BUS 1-BUS 2-1",
"limitType" : "CURRENT",
"limitName" : "PATL",
"limitName" : "permanent",
"limit" : 836.74,
"limitReduction" : 1.0,
"value" : 1248.100487597837,
"value" : 1248.0773003764798,
"side" : "ONE"
} ],
"actionsTaken" : [ ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.nio.file.Path;
import java.util.Objects;

import static com.powsybl.dynaflow.SecurityAnalysisConstants.BASE_SCENARIO_NAME;
import static com.powsybl.dynawo.DynawoSimulationConstants.JOBS_FILENAME;
import static com.powsybl.dynawo.DynawoSimulationConstants.MULTIPLE_JOBS_FILENAME;

Expand All @@ -41,7 +40,6 @@ private static void writeContingencies(XMLStreamWriter writer, SecurityAnalysisC
for (ContingencyEventModels model : context.getContingencyEventModels()) {
writeScenario(writer, model.getId());
}
writeBaseScenario(writer);
writer.writeEndElement();
}

Expand All @@ -50,9 +48,4 @@ private static void writeScenario(XMLStreamWriter writer, String id) throws XMLS
writer.writeAttribute("id", id);
writer.writeAttribute("dydFile", id + ".dyd");
}

private static void writeBaseScenario(XMLStreamWriter writer) throws XMLStreamException {
writer.writeEmptyElement("scenario");
writer.writeAttribute("id", BASE_SCENARIO_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
<scenarios jobsFile="powsybl_dynawo.jobs">
<scenario id="LOAD" dydFile="LOAD.dyd"/>
<scenario id="DisconnectLineGenerator" dydFile="DisconnectLineGenerator.dyd"/>
<scenario id="Base"/>
</scenarios>
</multipleJobs>

0 comments on commit 2c946de

Please sign in to comment.