Skip to content

Commit

Permalink
Log dynaflow parameters before running simulation (#368)
Browse files Browse the repository at this point in the history
Signed-off-by: BOUHOURS Antoine <[email protected]>
  • Loading branch information
antoinebhs authored Jul 3, 2024
1 parent 04969cc commit 6a1e6cf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dynaflow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<groupId>${project.groupId}</groupId>
<artifactId>powsybl-dynawo-commons</artifactId>
</dependency>
<dependency>
<groupId>de.vandermeer</groupId>
<artifactId>asciitable</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import com.powsybl.loadflow.LoadFlowParameters;
import com.powsybl.dynaflow.DynaFlowConstants.ActivePowerCompensation;
import com.powsybl.dynaflow.DynaFlowConstants.StartingPointMode;
import de.vandermeer.asciitable.AsciiTable;
import de.vandermeer.asciitable.CWC_LongestWord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.*;
Expand All @@ -33,6 +37,8 @@
*/
public class DynaFlowParameters extends AbstractExtension<LoadFlowParameters> {

private static final Logger LOGGER = LoggerFactory.getLogger(DynaFlowParameters.class);

/**
* Inner class dedicated to Security Analysis (SA) namespace
*/
Expand Down Expand Up @@ -353,6 +359,25 @@ private static void load(DynaFlowParameters parameters, ModuleConfig config) {
config.getOptionalBooleanProperty(MERGE_LOADS).ifPresent(parameters::setMergeLoads);
}

public static void log(LoadFlowParameters parameters, DynaFlowParameters parametersExt) {
if (LOGGER.isInfoEnabled()) {
AsciiTable at = new AsciiTable();
at.addRule();
at.addRow("Name", "Value");
at.addRule();
for (var e : parameters.toMap().entrySet()) {
at.addRow(e.getKey(), e.getValue());
}
for (var e : parametersExt.createMapFromParameters().entrySet()) {
at.addRow(e.getKey(), Objects.toString(e.getValue(), ""));
}
at.addRule();
at.getRenderer().setCWC(new CWC_LongestWord());
at.setPaddingLeftRight(1, 1);
LOGGER.info("Parameters:\n{}", at.render());
}
}

public void update(Map<String, String> properties) {
Objects.requireNonNull(properties);
Optional.ofNullable(properties.get(SVC_REGULATION_ON)).ifPresent(prop -> setSvcRegulationOn(Boolean.parseBoolean(prop)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public CompletableFuture<LoadFlowResult> run(Network network, ComputationManager
Objects.requireNonNull(workingStateId);
Objects.requireNonNull(loadFlowParameters);
DynaFlowParameters dynaFlowParameters = getParametersExt(loadFlowParameters);
DynaFlowParameters.log(loadFlowParameters, dynaFlowParameters);
DynaFlowConfig config = Objects.requireNonNull(configSupplier.get());
ExecutionEnvironment env = new ExecutionEnvironment(config.createEnv(), WORKING_DIR_PREFIX, config.isDebug());
Command versionCmd = getVersionCommand(config);
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<java.version>17</java.version>
<powsybl-core.version>6.4.0-RC2</powsybl-core.version>
<groovy.version>4.0.14</groovy.version> <!-- used for groovy-json but also for groovydoc (dynawaltz-dsl) -->
<asciitable.version>0.3.2</asciitable.version>
<sonar.coverage.jacoco.xmlReportPaths>
../distribution/target/site/jacoco-aggregate/jacoco.xml,
</sonar.coverage.jacoco.xmlReportPaths>
Expand Down Expand Up @@ -150,6 +151,11 @@
<artifactId>groovy-json</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>de.vandermeer</groupId>
<artifactId>asciitable</artifactId>
<version>${asciitable.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit 6a1e6cf

Please sign in to comment.