Skip to content

Commit

Permalink
Bump to powsybl-core 6.3.0-alpha-1 (#338)
Browse files Browse the repository at this point in the history
Signed-off-by: lisrte <[email protected]>
  • Loading branch information
Lisrte authored Mar 25, 2024
1 parent 8201ac5 commit d878c78
Show file tree
Hide file tree
Showing 81 changed files with 883 additions and 881 deletions.
33 changes: 16 additions & 17 deletions commons/src/main/java/com/powsybl/dynawo/commons/CommonReports.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
*/
package com.powsybl.dynawo.commons;

import com.powsybl.commons.reporter.Report;
import com.powsybl.commons.reporter.Reporter;
import com.powsybl.commons.reporter.TypedValue;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.commons.report.TypedValue;
import com.powsybl.dynawo.commons.dynawologs.LogEntry;
import com.powsybl.dynawo.commons.timeline.TimelineEntry;

Expand All @@ -24,27 +23,27 @@ public final class CommonReports {
private CommonReports() {
}

public static Reporter createDynawoLogReporter(Reporter reporter) {
return reporter.createSubReporter("dynawoLog", "Dynawo Log");
public static ReportNode createDynawoLogReportNode(ReportNode reportNode) {
return reportNode.newReportNode()
.withMessageTemplate("dynawoLog", "Dynawo Log")
.add();
}

public static void reportTimelineEntry(Reporter reporter, TimelineEntry timelineEntry) {
reporter.report(Report.builder()
.withKey("dynawoTimelineEntry")
.withDefaultMessage("[t=${time}] ${message} on equipment '${identifiableId}'")
public static void reportTimelineEntry(ReportNode reportNode, TimelineEntry timelineEntry) {
reportNode.newReportNode()
.withMessageTemplate("dynawoTimelineEntry", "[t=${time}] ${message} on equipment '${identifiableId}'")
.withTypedValue("time", timelineEntry.time(), TIME_MS)
.withTypedValue("identifiableId", timelineEntry.modelName(), ID)
.withValue("message", timelineEntry.message())
.withUntypedValue("message", timelineEntry.message())
.withSeverity(TypedValue.TRACE_SEVERITY)
.build());
.add();
}

public static void reportLogEntry(Reporter reporter, LogEntry logEntry) {
reporter.report(Report.builder()
.withKey("dynawoLogEntry")
.withDefaultMessage("${message}")
.withValue("message", logEntry.message())
public static void reportLogEntry(ReportNode reportNode, LogEntry logEntry) {
reportNode.newReportNode()
.withMessageTemplate("dynawoLogEntry", "${message}")
.withUntypedValue("message", logEntry.message())
.withSeverity(logEntry.severity())
.build());
.add();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package com.powsybl.dynawo.commons.dynawologs;

import com.powsybl.commons.reporter.TypedValue;
import com.powsybl.commons.report.TypedValue;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package com.powsybl.dynawo.commons.dynawologs;

import com.powsybl.commons.reporter.TypedValue;
import com.powsybl.commons.report.TypedValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package com.powsybl.dynawo.commons.dynawologs;

import com.powsybl.commons.reporter.TypedValue;
import com.powsybl.commons.report.TypedValue;
import org.junit.jupiter.api.Test;

import java.net.URISyntaxException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.powsybl.commons.extensions.Extension;
import com.powsybl.commons.extensions.ExtensionJsonSerializer;
import com.powsybl.commons.parameters.Parameter;
import com.powsybl.commons.reporter.Reporter;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.computation.*;
import com.powsybl.dynaflow.json.DynaFlowConfigSerializer;
import com.powsybl.dynaflow.json.JsonDynaFlowParametersSerializer;
Expand Down Expand Up @@ -110,7 +110,7 @@ public String getVersion() {

@Override
public CompletableFuture<LoadFlowResult> run(Network network, ComputationManager computationManager, String workingStateId,
LoadFlowParameters loadFlowParameters, Reporter reporter) {
LoadFlowParameters loadFlowParameters, ReportNode reportNode) {
Objects.requireNonNull(network);
Objects.requireNonNull(computationManager);
Objects.requireNonNull(workingStateId);
Expand All @@ -120,7 +120,7 @@ public CompletableFuture<LoadFlowResult> run(Network network, ComputationManager
ExecutionEnvironment env = new ExecutionEnvironment(config.createEnv(), WORKING_DIR_PREFIX, config.isDebug());
Command versionCmd = getVersionCommand(config);
DynawoUtil.requireDynaMinVersion(env, computationManager, versionCmd, DYNAFLOW_LAUNCHER_PROGRAM_NAME, true);
return computationManager.execute(env, new DynaFlowHandler(network, workingStateId, dynaFlowParameters, loadFlowParameters, config, reporter));
return computationManager.execute(env, new DynaFlowHandler(network, workingStateId, dynaFlowParameters, loadFlowParameters, config, reportNode));
}

@Override
Expand Down Expand Up @@ -181,16 +181,16 @@ private static class DynaFlowHandler extends AbstractExecutionHandler<LoadFlowRe
private final DynaFlowParameters dynaFlowParameters;
private final LoadFlowParameters loadFlowParameters;
private final DynaFlowConfig config;
private final Reporter reporter;
private final ReportNode reportNode;

public DynaFlowHandler(Network network, String workingStateId, DynaFlowParameters dynaFlowParameters, LoadFlowParameters loadFlowParameters, DynaFlowConfig config, Reporter reporter) {
public DynaFlowHandler(Network network, String workingStateId, DynaFlowParameters dynaFlowParameters, LoadFlowParameters loadFlowParameters, DynaFlowConfig config, ReportNode reportNode) {
this.network = network;
this.workingStateId = workingStateId;
this.dynaFlowParameters = dynaFlowParameters;
this.loadFlowParameters = loadFlowParameters;
this.config = config;
this.dynawoInput = this.dynaFlowParameters.isMergeLoads() ? LoadsMerger.mergeLoads(this.network) : this.network;
this.reporter = reporter;
this.reportNode = reportNode;
}

@Override
Expand Down Expand Up @@ -236,12 +236,12 @@ public LoadFlowResult after(Path workingDir, ExecutionReport report) {
}

private void reportTimeLine(Path workingDir) {
Reporter dfReporter = Reports.createDynaFlowReporter(reporter, network.getId());
ReportNode dfReportNode = DynaflowReports.createDynaFlowReportNode(reportNode, network.getId());
Path timelineFile = workingDir.resolve(DYNAFLOW_OUTPUTS_FOLDER)
.resolve(DYNAWO_TIMELINE_FOLDER)
.resolve(DYNAFLOW_TIMELINE_FILE);
List<TimelineEntry> tl = new XmlTimeLineParser().parse(timelineFile);
tl.forEach(e -> CommonReports.reportTimelineEntry(dfReporter, e));
tl.forEach(e -> CommonReports.reportTimelineEntry(dfReportNode, e));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.powsybl.commons.json.JsonUtil;
import com.powsybl.commons.reporter.Reporter;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.computation.*;
import com.powsybl.contingency.ContingenciesProvider;
import com.powsybl.contingency.Contingency;
Expand Down Expand Up @@ -135,11 +135,11 @@ public boolean removeInterceptor(SecurityAnalysisInterceptor interceptor) {
public CompletableFuture<SecurityAnalysisReport> run(String workingVariantId,
SecurityAnalysisParameters securityAnalysisParameters,
ContingenciesProvider contingenciesProvider,
Reporter reporter) {
ReportNode reportNode) {
Objects.requireNonNull(workingVariantId);
Objects.requireNonNull(securityAnalysisParameters);
Objects.requireNonNull(contingenciesProvider);
Objects.requireNonNull(reporter);
Objects.requireNonNull(reportNode);

DynaFlowConfig config = Objects.requireNonNull(configSupplier.get());
ExecutionEnvironment env = new ExecutionEnvironment(config.createEnv(), WORKING_DIR_PREFIX, config.isDebug());
Expand Down Expand Up @@ -174,8 +174,8 @@ public SecurityAnalysisReport after(Path workingDir, ExecutionReport report) thr
// Report the timeline events from the timeline files written by dynawo
Path timelineDir = workingDir.resolve(DYNAWO_TIMELINE_FOLDER);
contingencies.forEach(c -> {
Reporter contingencyReporter = Reports.createDynaFlowTimelineReporter(reporter, c.getId());
getTimeline(timelineDir, c).forEach(e -> CommonReports.reportTimelineEntry(contingencyReporter, e));
ReportNode contingencyReportNode = DynaflowReports.createDynaFlowTimelineReportNode(reportNode, c.getId());
getTimeline(timelineDir, c).forEach(e -> CommonReports.reportTimelineEntry(contingencyReportNode, e));
});

return new SecurityAnalysisReport(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
package com.powsybl.dynaflow;

import com.google.auto.service.AutoService;
import com.powsybl.commons.reporter.Reporter;
import com.powsybl.action.Action;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.computation.ComputationManager;
import com.powsybl.contingency.ContingenciesProvider;
import com.powsybl.dynawo.commons.PowsyblDynawoVersion;
import com.powsybl.iidm.network.Network;
import com.powsybl.security.*;
import com.powsybl.security.action.Action;
import com.powsybl.security.interceptors.SecurityAnalysisInterceptor;
import com.powsybl.security.limitreduction.LimitReduction;
import com.powsybl.security.monitor.StateMonitor;
import com.powsybl.security.strategy.OperatorStrategy;
import org.slf4j.Logger;
Expand Down Expand Up @@ -57,7 +58,8 @@ public CompletableFuture<SecurityAnalysisReport> run(Network network,
List<OperatorStrategy> operatorStrategies,
List<Action> actions,
List<StateMonitor> monitors,
Reporter reporter) {
List<LimitReduction> limitReductions,
ReportNode reportNode) {
if (detector != null) {
LOG.error("LimitViolationDetector is not used in Dynaflow implementation.");
}
Expand All @@ -70,11 +72,14 @@ public CompletableFuture<SecurityAnalysisReport> run(Network network,
if (actions != null && !actions.isEmpty()) {
LOG.error("Actions are not implemented in Dynaflow");
}
if (limitReductions != null && !limitReductions.isEmpty()) {
LOG.error("Limit reductions are not implemented in Dynaflow");
}
DynaFlowSecurityAnalysis securityAnalysis = new DynaFlowSecurityAnalysis(network, filter, computationManager, configSupplier);
interceptors.forEach(securityAnalysis::addInterceptor);

Reporter dfsaReporter = Reports.createDynaFlowSecurityAnalysisReporter(reporter, network.getId());
return securityAnalysis.run(workingVariantId, parameters, contingenciesProvider, dfsaReporter);
ReportNode dfsaReportNode = DynaflowReports.createDynaFlowSecurityAnalysisReportNode(reportNode, network.getId());
return securityAnalysis.run(workingVariantId, parameters, contingenciesProvider, dfsaReportNode);
}

@Override
Expand Down
40 changes: 40 additions & 0 deletions dynaflow/src/main/java/com/powsybl/dynaflow/DynaflowReports.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2023, 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/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.dynaflow;

import com.powsybl.commons.report.ReportNode;

/**
* @author Florian Dupuy {@literal <florian.dupuy at rte-france.com>}
*/
public final class DynaflowReports {

private DynaflowReports() {
}

public static ReportNode createDynaFlowReportNode(ReportNode reportNode, String networkId) {
return reportNode.newReportNode()
.withMessageTemplate("dynaflow", "Dynaflow loadflow on network '${networkId}'")
.withUntypedValue("networkId", networkId)
.add();
}

public static ReportNode createDynaFlowSecurityAnalysisReportNode(ReportNode reportNode, String networkId) {
return reportNode.newReportNode()
.withMessageTemplate("dynaflowSa", "Dynaflow security analysis on network '${networkId}'")
.withUntypedValue("networkId", networkId)
.add();
}

public static ReportNode createDynaFlowTimelineReportNode(ReportNode reportNode, String contingencyId) {
return reportNode.newReportNode()
.withMessageTemplate("dynaflowSaContingency", "Contingency '${contingencyId}'")
.withUntypedValue("contingencyId", contingencyId)
.add();
}
}
37 changes: 0 additions & 37 deletions dynaflow/src/main/java/com/powsybl/dynaflow/Reports.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"twtSplitShuntAdmittance" : false,
"shuntCompensatorVoltageControlOn" : false,
"readSlackBus" : true,
"writeSlackBus" : false,
"writeSlackBus" : true,
"dc" : false,
"distributedSlack" : true,
"balanceType" : "PROPORTIONAL_TO_GENERATION_P_MAX",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"twtSplitShuntAdmittance" : false,
"shuntCompensatorVoltageControlOn" : false,
"readSlackBus" : true,
"writeSlackBus" : false,
"writeSlackBus" : true,
"dc" : false,
"distributedSlack" : true,
"balanceType" : "PROPORTIONAL_TO_GENERATION_P_MAX",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
*/
package com.powsybl.dynawaltz.dsl

import com.powsybl.commons.report.ReportNode;

import com.powsybl.commons.reporter.Reporter
/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
final class Reporters {
final class DslReports {

private Reporters() {
private DslReports() {
}

static Reporter createModelBuilderReporter(Reporter reporter, String name) {
reporter.createSubReporter("DSLModelBuilder",
'DSL model builder for ${name}',
"name", name)
static ReportNode createModelBuilderReportNode(ReportNode reportNode, String name) {
reportNode.newReportNode()
.withMessageTemplate("DSLModelBuilder", 'DSL model builder for ${name}')
.withUntypedValue("name", name)
.add()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package com.powsybl.dynawaltz.dsl

import com.google.auto.service.AutoService
import com.powsybl.commons.reporter.Reporter
import com.powsybl.commons.report.ReportNode
import com.powsybl.dsl.DslException
import com.powsybl.dynamicsimulation.Curve
import com.powsybl.dynamicsimulation.groovy.CurveGroovyExtension
Expand Down Expand Up @@ -79,7 +79,7 @@ class DynaWaltzCurveGroovyExtension implements CurveGroovyExtension {
}

@Override
void load(Binding binding, Consumer<Curve> consumer, Reporter reporter) {
void load(Binding binding, Consumer<Curve> consumer, ReportNode reportNode) {
binding.curve = { Closure<Void> closure ->
def cloned = closure.clone()
CurvesSpec curveSpec = new CurvesSpec()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package com.powsybl.dynawaltz.dsl

import com.google.auto.service.AutoService
import com.powsybl.commons.reporter.Reporter
import com.powsybl.commons.report.ReportNode
import com.powsybl.dynamicsimulation.DynamicModel
import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension
import com.powsybl.dynawaltz.DynaWaltzProvider
Expand All @@ -18,6 +18,7 @@ import com.powsybl.dynawaltz.builders.ModelConfigsHandler
import com.powsybl.iidm.network.Network

import java.util.function.Consumer

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
Expand All @@ -42,13 +43,13 @@ class DynaWaltzDynamicModelGroovyExtension implements DynamicModelGroovyExtensio


@Override
void load(Binding binding, Consumer<DynamicModel> consumer, Reporter reporter) {
void load(Binding binding, Consumer<DynamicModel> consumer, ReportNode reportNode) {
builderConfigs.forEach {conf ->
conf.libs.forEach {lib ->
binding.setVariable(lib , { Closure<Void> closure ->
def cloned = closure.clone()
ModelBuilder<DynamicModel> builder = conf.builderConstructor
.createBuilder(binding.getVariable("network") as Network, lib, Reporters.createModelBuilderReporter(reporter, lib))
.createBuilder(binding.getVariable("network") as Network, lib, DslReports.createModelBuilderReportNode(reportNode, lib))
cloned.delegate = builder
cloned()
builder.build()?.tap {
Expand Down
Loading

0 comments on commit d878c78

Please sign in to comment.