From 8be285357ef05294d7f184200dcd07b4a65a8f03 Mon Sep 17 00:00:00 2001 From: Lisrte Date: Tue, 2 Jul 2024 16:26:37 +0200 Subject: [PATCH] Add dynawo logs (#354) * Add logLevelFilter parameter * Add specific logs * Add reporters * Add specific logs in integration tests * Add documentation * Remove setDefaultDumpFileParameters Signed-off-by: lisrte --- .../dynawo-configuration.md | 25 ++++++++ .../dynawaltz/dsl/ieee/AbstractIeeeTest.java | 3 +- .../powsybl/dynawaltz/DumpFileParameters.java | 2 +- .../dynawaltz/DynaWaltzParameters.java | 63 +++++++++++++++++-- .../powsybl/dynawaltz/DynaWaltzProvider.java | 22 +++++-- .../powsybl/dynawaltz/DynawaltzReports.java | 16 +++++ .../com/powsybl/dynawaltz/xml/JobsXml.java | 25 +++++--- .../dynawaltz/DynaWaltzParametersTest.java | 19 ++++-- .../powsybl/dynawaltz/xml/JobsXmlTest.java | 12 ++++ .../test/resources/DynaWaltzParameters.json | 2 + dynawaltz/src/test/resources/jobs.xml | 2 +- dynawaltz/src/test/resources/jobsWithDump.xml | 2 +- .../test/resources/jobsWithSpecificLogs.xml | 27 ++++++++ .../com/powsybl/dynawo/it/DynaWaltzTest.java | 16 ++--- 14 files changed, 199 insertions(+), 37 deletions(-) create mode 100644 dynawaltz/src/test/resources/jobsWithSpecificLogs.xml diff --git a/docs/dynamic_simulation/dynawo-configuration.md b/docs/dynamic_simulation/dynawo-configuration.md index f54886c9e..2d9ad5fe9 100644 --- a/docs/dynamic_simulation/dynawo-configuration.md +++ b/docs/dynamic_simulation/dynawo-configuration.md @@ -98,6 +98,25 @@ The default value is `TXT`. `precision` defines the simulation step precision. The default value is `1e-6`. +**log.levelFilter** +`log.levelFilter` defines the log level for Dynawo log. +The default value is `INFO`. +The available `com.powsybl.dynawaltz.DynaWaltzParameters.LogLevel` values are: +- `DEBUG` +- `INFO` +- `WARN` +- `ERROR` + +**log.specificLogs** +`log.specificLogs` defines as a list the specifics logs to return besides the regular Dynawo log. +The default value is an empty list. +The available `com.powsybl.dynawaltz.DynaWaltzParameters.SpecificLog` values are: +- `NETWORK` +- `MODELER` +- `PARAMETERS` +- `VARIABLES` +- `EQUATIONS` + ### Examples **YAML configuration:** @@ -117,6 +136,10 @@ dynawo-default-parameters: mergeLoads: false timeline.exportMode: XML precision: 10e-6 + log.levelFilter: INFO + log.specificLogs: + - NETWORK + - PARAMETERS ``` **XML configuration:** @@ -136,5 +159,7 @@ dynawo-default-parameters: false XML 10e-6 + INFO + NETWORK, PARAMETERS ``` diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee/AbstractIeeeTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee/AbstractIeeeTest.java index a27013195..617f08ecd 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee/AbstractIeeeTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee/AbstractIeeeTest.java @@ -100,8 +100,7 @@ protected void setup(String parametersFile, String networkParametersFile, String dynaWaltzParameters.setModelsParameters(ParametersXml.load(getClass().getResourceAsStream(parametersFile))) .setNetworkParameters(ParametersXml.load(getClass().getResourceAsStream(networkParametersFile), networkParametersId)) .setSolverParameters(ParametersXml.load(getClass().getResourceAsStream(solverParametersFile), solverParametersId)) - .setSolverType(DynaWaltzParameters.SolverType.IDA) - .setDefaultDumpFileParameters(); + .setSolverType(DynaWaltzParameters.SolverType.IDA); } protected DynaWaltzParameters getDynaWaltzSimulationParameters(DynamicSimulationParameters parameters) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DumpFileParameters.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DumpFileParameters.java index e270426a9..8854ddae8 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DumpFileParameters.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DumpFileParameters.java @@ -26,7 +26,7 @@ public record DumpFileParameters(boolean exportDumpFile, boolean useDumpFile, Pa public static final boolean DEFAULT_USE_DUMP = false; public static final String DEFAULT_DUMP_FOLDER = null; public static final String DEFAULT_DUMP_NAME = null; - public static final DumpFileParameters DEFAULT_DUMP_FILE_PARAMETERS = new DumpFileParameters(DEFAULT_EXPORT_DUMP, DEFAULT_USE_DUMP, null, DEFAULT_DUMP_NAME); + private static final DumpFileParameters DEFAULT_DUMP_FILE_PARAMETERS = new DumpFileParameters(DEFAULT_EXPORT_DUMP, DEFAULT_USE_DUMP, null, DEFAULT_DUMP_NAME); public DumpFileParameters { if (useDumpFile) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzParameters.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzParameters.java index 6443dab19..a446cd8dd 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzParameters.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzParameters.java @@ -41,6 +41,7 @@ public class DynaWaltzParameters extends AbstractExtension modelsParameters = new LinkedHashMap<>(); private ParametersSet networkParameters; private ParametersSet solverParameters; @@ -79,9 +108,11 @@ public String getFileExtension() { private boolean mergeLoads = DEFAULT_MERGE_LOADS; private boolean writeFinalState = DEFAULT_WRITE_FINAL_STATE; private boolean useModelSimplifiers = DEFAULT_USE_MODEL_SIMPLIFIERS; - private DumpFileParameters dumpFileParameters = DumpFileParameters.DEFAULT_DUMP_FILE_PARAMETERS; + private DumpFileParameters dumpFileParameters = DumpFileParameters.createDefaultDumpFileParameters(); private double precision = DEFAULT_PRECISION; private ExportMode timelineExportMode = DEFAULT_TIMELINE_EXPORT_MODE; + private LogLevel logLevelFilter = DEFAULT_LOG_LEVEL_FILTER; + private EnumSet specificLogs = EnumSet.noneOf(SpecificLog.class); /** * Loads parameters from the default platform configuration. @@ -122,6 +153,8 @@ public static DynaWaltzParameters load(PlatformConfig platformConfig, FileSystem c.getOptionalBooleanProperty("useModelSimplifiers").ifPresent(parameters::setUseModelSimplifiers); c.getOptionalDoubleProperty("precision").ifPresent(parameters::setPrecision); c.getOptionalEnumProperty("timeline.exportMode", ExportMode.class).ifPresent(parameters::setTimelineExportMode); + c.getOptionalEnumProperty("log.levelFilter", LogLevel.class).ifPresent(parameters::setLogLevelFilter); + c.getOptionalEnumSetProperty("log.specificLogs", SpecificLog.class).ifPresent(parameters::setSpecificLogs); }); return parameters; } @@ -222,11 +255,6 @@ public DynaWaltzParameters setDumpFileParameters(DumpFileParameters dumpFilePara return this; } - public DynaWaltzParameters setDefaultDumpFileParameters() { - this.dumpFileParameters = DumpFileParameters.createDefaultDumpFileParameters(); - return this; - } - public double getPrecision() { return precision; } @@ -244,4 +272,27 @@ public DynaWaltzParameters setTimelineExportMode(ExportMode timelineExportMode) this.timelineExportMode = timelineExportMode; return this; } + + public LogLevel getLogLevelFilter() { + return logLevelFilter; + } + + public DynaWaltzParameters setLogLevelFilter(LogLevel logLevelFilter) { + this.logLevelFilter = logLevelFilter; + return this; + } + + public Set getSpecificLogs() { + return specificLogs; + } + + public DynaWaltzParameters setSpecificLogs(Set specificLogs) { + this.specificLogs = EnumSet.copyOf(specificLogs); + return this; + } + + public DynaWaltzParameters addSpecificLog(SpecificLog specificLog) { + specificLogs.add(specificLog); + return this; + } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzProvider.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzProvider.java index 69720ad2e..a20972ed2 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzProvider.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynaWaltzProvider.java @@ -194,7 +194,7 @@ public DynamicSimulationResult after(Path workingDir, ExecutionReport report) th DynaWaltzParameters parameters = context.getDynaWaltzParameters(); DumpFileParameters dumpFileParameters = parameters.getDumpFileParameters(); - setDynawoLog(outputsFolder); + setDynawoLog(outputsFolder, parameters.getSpecificLogs()); // Error file Path errorFile = workingDir.resolve(ERROR_FILENAME); if (Files.exists(errorFile)) { @@ -224,11 +224,21 @@ public DynamicSimulationResult after(Path workingDir, ExecutionReport report) th return new DynamicSimulationResultImpl(status, statusText, curves, timeline); } - private void setDynawoLog(Path outputsFolder) { - Path logFile = outputsFolder.resolve(LOGS_FOLDER).resolve(LOGS_FILENAME); - if (Files.exists(logFile)) { - ReportNode logReportNode = CommonReports.createDynawoLogReportNode(reportNode); - new CsvLogParser().parse(logFile).forEach(e -> CommonReports.reportLogEntry(logReportNode, e)); + private void setDynawoLog(Path outputsFolder, Set specificLogs) throws IOException { + Path logFolder = outputsFolder.resolve(LOGS_FOLDER); + if (Files.exists(logFolder)) { + Path logFile = logFolder.resolve(LOGS_FILENAME); + if (Files.exists(logFile)) { + ReportNode logReportNode = CommonReports.createDynawoLogReportNode(reportNode); + new CsvLogParser().parse(logFile).forEach(e -> CommonReports.reportLogEntry(logReportNode, e)); + } + for (DynaWaltzParameters.SpecificLog specificLog : specificLogs) { + Path specificLogFile = logFolder.resolve(specificLog.getFileName()); + if (Files.exists(specificLogFile)) { + ReportNode logReport = DynawaltzReports.createDynawoSpecificLogReportNode(reportNode, specificLog); + DynawaltzReports.reportSpecificLogEntry(logReport, Files.readString(specificLogFile)); + } + } } else { LOGGER.warn("Dynawo logs file not found"); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java index f2e65a340..8abd02178 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java @@ -9,6 +9,7 @@ import com.powsybl.commons.report.ReportNode; import com.powsybl.commons.report.TypedValue; +import org.apache.commons.lang3.StringUtils; /** * @author Laurent Issertial {@literal } @@ -72,4 +73,19 @@ public static void reportEmptyListAutomaton(ReportNode reportNode, String automa .withSeverity(TypedValue.WARN_SEVERITY) .add(); } + + public static ReportNode createDynawoSpecificLogReportNode(ReportNode reportNode, DynaWaltzParameters.SpecificLog logType) { + String logTypeName = StringUtils.capitalize(logType.toString().toLowerCase()); + return reportNode.newReportNode() + .withMessageTemplate("dynawo" + logTypeName + "Log", logTypeName + " log") + .add(); + + } + + public static void reportSpecificLogEntry(ReportNode reportNode, String logEntry) { + reportNode.newReportNode() + .withMessageTemplate("dynawoSpecificLogEntry", "${message}") + .withUntypedValue("message", logEntry) + .add(); + } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/xml/JobsXml.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/xml/JobsXml.java index 67c56091f..a0a09c6cf 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/xml/JobsXml.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/xml/JobsXml.java @@ -87,6 +87,7 @@ private static void writeSimulation(XMLStreamWriter writer, DynaWaltzContext con } private static void writeOutput(XMLStreamWriter writer, DynaWaltzContext context) throws XMLStreamException { + DynaWaltzParameters parameters = context.getDynaWaltzParameters(); writer.writeStartElement(DYN_URI, "outputs"); writer.writeAttribute("directory", "outputs"); @@ -95,29 +96,39 @@ private static void writeOutput(XMLStreamWriter writer, DynaWaltzContext context writer.writeAttribute("global", Boolean.toString(false)); writer.writeEmptyElement(DYN_URI, "timeline"); - writer.writeAttribute("exportMode", context.getDynaWaltzParameters().getTimelineExportMode().name()); + writer.writeAttribute("exportMode", parameters.getTimelineExportMode().toString()); writer.writeEmptyElement(DYN_URI, "finalState"); - writer.writeAttribute("exportIIDMFile", Boolean.toString(context.getDynaWaltzParameters().isWriteFinalState())); - writer.writeAttribute("exportDumpFile", Boolean.toString(context.getDynaWaltzParameters().getDumpFileParameters().exportDumpFile())); + writer.writeAttribute("exportIIDMFile", Boolean.toString(parameters.isWriteFinalState())); + writer.writeAttribute("exportDumpFile", Boolean.toString(parameters.getDumpFileParameters().exportDumpFile())); if (context.withCurves()) { writer.writeEmptyElement(DYN_URI, "curves"); writer.writeAttribute("inputFile", DynaWaltzConstants.CRV_FILENAME); - writer.writeAttribute("exportMode", DynaWaltzParameters.ExportMode.CSV.name()); + writer.writeAttribute("exportMode", DynaWaltzParameters.ExportMode.CSV.toString()); } writer.writeStartElement(DYN_URI, "logs"); - writeAppender(writer); + writeAppender(writer, parameters); writer.writeEndElement(); writer.writeEndElement(); } - private static void writeAppender(XMLStreamWriter writer) throws XMLStreamException { + private static void writeAppender(XMLStreamWriter writer, DynaWaltzParameters parameters) throws XMLStreamException { writer.writeEmptyElement(DYN_URI, "appender"); writer.writeAttribute("tag", ""); writer.writeAttribute("file", "dynawaltz.log"); - writer.writeAttribute("lvlFilter", "DEBUG"); + writer.writeAttribute("lvlFilter", parameters.getLogLevelFilter().toString()); + for (DynaWaltzParameters.SpecificLog log : parameters.getSpecificLogs()) { + writeSpecificAppender(writer, log); + } + } + + private static void writeSpecificAppender(XMLStreamWriter writer, DynaWaltzParameters.SpecificLog log) throws XMLStreamException { + writer.writeEmptyElement(DYN_URI, "appender"); + writer.writeAttribute("tag", log.toString()); + writer.writeAttribute("file", log.getFileName()); + writer.writeAttribute("lvlFilter", DynaWaltzParameters.LogLevel.DEBUG.toString()); } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzParametersTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzParametersTest.java index 72aee8ae2..df03b710f 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzParametersTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzParametersTest.java @@ -13,7 +13,9 @@ import com.powsybl.dynamicsimulation.DynamicSimulationParameters; import com.powsybl.dynamicsimulation.json.JsonDynamicSimulationParameters; import com.powsybl.dynawaltz.DynaWaltzParameters.ExportMode; +import com.powsybl.dynawaltz.DynaWaltzParameters.LogLevel; import com.powsybl.dynawaltz.DynaWaltzParameters.SolverType; +import com.powsybl.dynawaltz.DynaWaltzParameters.SpecificLog; import com.powsybl.dynawaltz.parameters.Parameter; import com.powsybl.dynawaltz.parameters.ParameterType; import com.powsybl.dynawaltz.xml.ParametersXml; @@ -24,8 +26,7 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Map; -import java.util.Objects; +import java.util.*; import static org.junit.jupiter.api.Assertions.*; @@ -61,7 +62,9 @@ void checkParameters() throws IOException { boolean useModelSimplifiers = true; double precision = 1e-8; ExportMode timelinExportMode = ExportMode.XML; - initPlatformConfig(networkParametersId, solverType, solverParametersId, mergeLoads, useModelSimplifiers, precision, timelinExportMode); + LogLevel logLevel = LogLevel.WARN; + Set specificLogs = EnumSet.of(SpecificLog.MODELER, SpecificLog.EQUATIONS); + initPlatformConfig(networkParametersId, solverType, solverParametersId, mergeLoads, useModelSimplifiers, precision, timelinExportMode, logLevel, specificLogs); DynaWaltzParameters parameters = DynaWaltzParameters.load(platformConfig, fileSystem); @@ -94,6 +97,8 @@ void checkParameters() throws IOException { assertEquals(useModelSimplifiers, parameters.isUseModelSimplifiers()); assertEquals(precision, parameters.getPrecision()); assertEquals(timelinExportMode, parameters.getTimelineExportMode()); + assertEquals(logLevel, parameters.getLogLevelFilter()); + assertEquals(specificLogs, parameters.getSpecificLogs()); } @Test @@ -116,7 +121,7 @@ void roundTripParametersSerializing() throws IOException { SolverType solverType = SolverType.IDA; String solverParametersId = "solverParametersId"; boolean mergeLoads = false; - initPlatformConfig(networkParametersId, solverType, solverParametersId, mergeLoads, false, 1e-7, ExportMode.TXT); + initPlatformConfig(networkParametersId, solverType, solverParametersId, mergeLoads, false, 1e-7, ExportMode.TXT, LogLevel.INFO, Set.of(SpecificLog.PARAMETERS, SpecificLog.VARIABLES)); DynamicSimulationParameters dynamicSimulationParameters = new DynamicSimulationParameters() .setStartTime(0) @@ -127,7 +132,9 @@ void roundTripParametersSerializing() throws IOException { JsonDynamicSimulationParameters::read, "/DynaWaltzParameters.json"); } - private void initPlatformConfig(String networkParametersId, SolverType solverType, String solverParametersId, boolean mergeLoads, boolean useModelSimplifiers, double precision, ExportMode timelineExportMode) throws IOException { + private void initPlatformConfig(String networkParametersId, SolverType solverType, String solverParametersId, + boolean mergeLoads, boolean useModelSimplifiers, double precision, ExportMode timelineExportMode, + LogLevel logLevel, Set specificLogs) throws IOException { String parametersFile = USER_HOME + "parametersFile"; String networkParametersFile = USER_HOME + "networkParametersFile"; String solverParametersFile = USER_HOME + "solverParametersFile"; @@ -143,6 +150,8 @@ private void initPlatformConfig(String networkParametersId, SolverType solverTyp moduleConfig.setStringProperty("useModelSimplifiers", String.valueOf(useModelSimplifiers)); moduleConfig.setStringProperty("precision", Double.toString(precision)); moduleConfig.setStringProperty("timeline.exportMode", String.valueOf(timelineExportMode)); + moduleConfig.setStringProperty("log.levelFilter", logLevel.toString()); + moduleConfig.setStringListProperty("log.specificLogs", specificLogs.stream().map(SpecificLog::toString).toList()); Files.createDirectories(fileSystem.getPath(USER_HOME)); copyFile("/parametersSet/models.par", parametersFile); diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/JobsXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/JobsXmlTest.java index 25a83d0bd..034326916 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/JobsXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/JobsXmlTest.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.EnumSet; /** * @author Marcos de Miguel {@literal } @@ -42,4 +43,15 @@ void writeJobWithDumpFile() throws SAXException, IOException { validate("jobs.xsd", "jobsWithDump.xml", tmpDir.resolve(DynaWaltzConstants.JOBS_FILENAME)); } + @Test + void writeJobWithSpecificLogs() throws SAXException, IOException { + DynamicSimulationParameters parameters = DynamicSimulationParameters.load(); + DynaWaltzParameters dynawoParameters = DynaWaltzParameters.load() + .setSpecificLogs(EnumSet.allOf(DynaWaltzParameters.SpecificLog.class)); + DynaWaltzContext context = new DynaWaltzContext(network, network.getVariantManager().getWorkingVariantId(), dynamicModels, eventModels, curves, parameters, dynawoParameters); + + JobsXml.write(tmpDir, context); + validate("jobs.xsd", "jobsWithSpecificLogs.xml", tmpDir.resolve(DynaWaltzConstants.JOBS_FILENAME)); + } + } diff --git a/dynawaltz/src/test/resources/DynaWaltzParameters.json b/dynawaltz/src/test/resources/DynaWaltzParameters.json index bb2be0ef0..d3083c91f 100644 --- a/dynawaltz/src/test/resources/DynaWaltzParameters.json +++ b/dynawaltz/src/test/resources/DynaWaltzParameters.json @@ -48,6 +48,8 @@ }, "precision" : 1.0E-7, "timelineExportMode" : "TXT", + "logLevelFilter" : "INFO", + "specificLogs" : [ "PARAMETERS", "VARIABLES" ], "modelsParameters" : [ { "id" : "test", "parameters" : { diff --git a/dynawaltz/src/test/resources/jobs.xml b/dynawaltz/src/test/resources/jobs.xml index 932f6e78f..608bd9985 100644 --- a/dynawaltz/src/test/resources/jobs.xml +++ b/dynawaltz/src/test/resources/jobs.xml @@ -15,7 +15,7 @@ - + diff --git a/dynawaltz/src/test/resources/jobsWithDump.xml b/dynawaltz/src/test/resources/jobsWithDump.xml index 9cb41ea07..49f23b0f5 100644 --- a/dynawaltz/src/test/resources/jobsWithDump.xml +++ b/dynawaltz/src/test/resources/jobsWithDump.xml @@ -16,7 +16,7 @@ - + diff --git a/dynawaltz/src/test/resources/jobsWithSpecificLogs.xml b/dynawaltz/src/test/resources/jobsWithSpecificLogs.xml new file mode 100644 index 000000000..0f4d928ce --- /dev/null +++ b/dynawaltz/src/test/resources/jobsWithSpecificLogs.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynaWaltzTest.java b/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynaWaltzTest.java index 89a42100c..c6fab454b 100644 --- a/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynaWaltzTest.java +++ b/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynaWaltzTest.java @@ -8,6 +8,7 @@ import com.powsybl.commons.datasource.ResourceDataSource; import com.powsybl.commons.datasource.ResourceSet; +import com.powsybl.commons.report.ReportNode; import com.powsybl.dynamicsimulation.*; import com.powsybl.dynamicsimulation.groovy.*; import com.powsybl.dynawaltz.DumpFileParameters; @@ -26,10 +27,12 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.EnumSet; import java.util.List; import java.util.stream.Stream; import static com.powsybl.commons.report.ReportNode.NO_OP; +import static com.powsybl.commons.report.ReportNode.newRootReportNode; import static org.junit.jupiter.api.Assertions.*; /** @@ -78,7 +81,6 @@ void testIeee14() { .setNetworkParameters(networkParameters) .setSolverParameters(solverParameters) .setSolverType(DynaWaltzParameters.SolverType.IDA) - .setDefaultDumpFileParameters() .setTimelineExportMode(DynaWaltzParameters.ExportMode.XML); DynamicSimulationResult result = provider.run(network, dynamicModelsSupplier, eventModelsSupplier, curvesSupplier, @@ -163,7 +165,6 @@ void testSvc() { .setNetworkParameters(networkParameters) .setSolverParameters(solverParameters) .setSolverType(DynaWaltzParameters.SolverType.IDA) - .setDefaultDumpFileParameters() .setPrecision(10e-8); DynamicSimulationResult result = provider.run(network, dynamicModelsSupplier, EventModelsSupplier.empty(), CurvesSupplier.empty(), @@ -189,14 +190,15 @@ void testHvdc() { List modelsParameters = ParametersXml.load(getResourceAsStream("/hvdc/models.par")); ParametersSet networkParameters = ParametersXml.load(getResourceAsStream("/hvdc/network.par"), "8"); ParametersSet solverParameters = ParametersXml.load(getResourceAsStream("/hvdc/solvers.par"), "2"); + ReportNode reportNode = newRootReportNode().withMessageTemplate("testHvdc", "Test HVDC").build(); dynaWaltzParameters.setModelsParameters(modelsParameters) .setNetworkParameters(networkParameters) .setSolverParameters(solverParameters) .setSolverType(DynaWaltzParameters.SolverType.IDA) - .setDefaultDumpFileParameters(); + .setSpecificLogs(EnumSet.allOf(DynaWaltzParameters.SpecificLog.class)); DynamicSimulationResult result = provider.run(network, dynamicModelsSupplier, EventModelsSupplier.empty(), CurvesSupplier.empty(), - VariantManagerConstants.INITIAL_VARIANT_ID, computationManager, parameters, NO_OP) + VariantManagerConstants.INITIAL_VARIANT_ID, computationManager, parameters, reportNode) .join(); assertEquals(DynamicSimulationResult.Status.SUCCESS, result.getStatus()); @@ -230,8 +232,7 @@ void testSmib() { .setNetworkParameters(networkParameters) .setSolverParameters(solverParameters) .setSolverType(DynaWaltzParameters.SolverType.IDA) - .setWriteFinalState(false) - .setDefaultDumpFileParameters(); + .setWriteFinalState(false); DynamicSimulationResult result = provider.run(network, dynamicModelsSupplier, eventModelsSupplier, curvesSupplier, VariantManagerConstants.INITIAL_VARIANT_ID, computationManager, parameters, NO_OP) @@ -260,8 +261,7 @@ void testSimulationError() { dynaWaltzParameters.setModelsParameters(ParametersXml.load(getResourceAsStream("/error/models.par"))) .setNetworkParameters(ParametersXml.load(getResourceAsStream("/error/network.par"), "NETWORK")) .setSolverParameters(ParametersXml.load(getResourceAsStream("/error/solvers.par"), "3")) - .setSolverType(DynaWaltzParameters.SolverType.SIM) - .setDefaultDumpFileParameters(); + .setSolverType(DynaWaltzParameters.SolverType.SIM); DynamicSimulationResult result = provider.run(network, dynamicModelsSupplier, eventModelsSupplier, CurvesSupplier.empty(), VariantManagerConstants.INITIAL_VARIANT_ID, computationManager, parameters, NO_OP)