From 2c946de6bee38c6243954ec3b119788545087f87 Mon Sep 17 00:00:00 2001 From: lisrte Date: Wed, 4 Dec 2024 18:02:39 +0100 Subject: [PATCH] Remove base case scenario in DSA Signed-off-by: lisrte --- .../dynaflow/SecurityAnalysisConstants.java | 2 -- .../dynaflow/results/ContingencyResultsUtils.java | 15 ++++----------- .../com/powsybl/dynaflow/results/ResultsUtil.java | 8 -------- .../convergence/results.json | 4 ++-- .../divergence/results.json | 6 +++--- .../failed-criteria/results.json | 6 +++--- .../dynawo/security/xml/MultipleJobsXml.java | 7 ------- .../src/test/resources/multipleJobs.xml | 1 - 8 files changed, 12 insertions(+), 37 deletions(-) diff --git a/dynaflow/src/main/java/com/powsybl/dynaflow/SecurityAnalysisConstants.java b/dynaflow/src/main/java/com/powsybl/dynaflow/SecurityAnalysisConstants.java index 60ebdcfb0..e50d9b274 100644 --- a/dynaflow/src/main/java/com/powsybl/dynaflow/SecurityAnalysisConstants.java +++ b/dynaflow/src/main/java/com/powsybl/dynaflow/SecurityAnalysisConstants.java @@ -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() { } diff --git a/dynaflow/src/main/java/com/powsybl/dynaflow/results/ContingencyResultsUtils.java b/dynaflow/src/main/java/com/powsybl/dynaflow/results/ContingencyResultsUtils.java index ee19a8cc3..80aeccba2 100644 --- a/dynaflow/src/main/java/com/powsybl/dynaflow/results/ContingencyResultsUtils.java +++ b/dynaflow/src/main/java/com/powsybl/dynaflow/results/ContingencyResultsUtils.java @@ -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; @@ -56,16 +55,10 @@ public static SecurityAnalysisResult createSecurityAnalysisResult(Network networ private static PreContingencyResult getPreContingencyResult(Network network, LimitViolationFilter violationFilter, Path constraintsDir, Map 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 limitViolations = Security.checkLimits(network); - List filteredViolations = violationFilter.apply(limitViolations, network); - return new PreContingencyResult(LoadFlowResult.ComponentResult.Status.CONVERGED, new LimitViolationsResult(filteredViolations), networkResult); - } + //Dynaflow SA case (see issue #174) + List limitViolations = Security.checkLimits(network); + List filteredViolations = violationFilter.apply(limitViolations, network); + return new PreContingencyResult(LoadFlowResult.ComponentResult.Status.CONVERGED, new LimitViolationsResult(filteredViolations), networkResult); } /** diff --git a/dynaflow/src/main/java/com/powsybl/dynaflow/results/ResultsUtil.java b/dynaflow/src/main/java/com/powsybl/dynaflow/results/ResultsUtil.java index 1f06878b0..a642c6f2a 100644 --- a/dynaflow/src/main/java/com/powsybl/dynaflow/results/ResultsUtil.java +++ b/dynaflow/src/main/java/com/powsybl/dynaflow/results/ResultsUtil.java @@ -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; @@ -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 createScenarioResult(String id, String status, List failedCriteria) { if (id == null || status == null || failedCriteria == null) { LOGGER.warn("Inconsistent scenario result entry (id: '{}', status: '{}', failedCriteria: '{}')", id, status, failedCriteria); diff --git a/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/convergence/results.json b/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/convergence/results.json index 55ea04f14..90ddb1f93 100644 --- a/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/convergence/results.json +++ b/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/convergence/results.json @@ -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" : [ ] diff --git a/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/divergence/results.json b/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/divergence/results.json index 2c3b56212..973d7cc56 100644 --- a/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/divergence/results.json +++ b/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/divergence/results.json @@ -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" : [ ] diff --git a/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/failed-criteria/results.json b/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/failed-criteria/results.json index 309a291b2..c591e4cca 100644 --- a/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/failed-criteria/results.json +++ b/dynawo-integration-tests/src/test/resources/ieee14/dynamic-security-analysis/failed-criteria/results.json @@ -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" : [ ] diff --git a/dynawo-security-analysis/src/main/java/com/powsybl/dynawo/security/xml/MultipleJobsXml.java b/dynawo-security-analysis/src/main/java/com/powsybl/dynawo/security/xml/MultipleJobsXml.java index 4494ce0d0..8bf978e69 100644 --- a/dynawo-security-analysis/src/main/java/com/powsybl/dynawo/security/xml/MultipleJobsXml.java +++ b/dynawo-security-analysis/src/main/java/com/powsybl/dynawo/security/xml/MultipleJobsXml.java @@ -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; @@ -41,7 +40,6 @@ private static void writeContingencies(XMLStreamWriter writer, SecurityAnalysisC for (ContingencyEventModels model : context.getContingencyEventModels()) { writeScenario(writer, model.getId()); } - writeBaseScenario(writer); writer.writeEndElement(); } @@ -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); - } } diff --git a/dynawo-security-analysis/src/test/resources/multipleJobs.xml b/dynawo-security-analysis/src/test/resources/multipleJobs.xml index 1ad813292..a2dd210fa 100644 --- a/dynawo-security-analysis/src/test/resources/multipleJobs.xml +++ b/dynawo-security-analysis/src/test/resources/multipleJobs.xml @@ -3,6 +3,5 @@ -