Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log dynaflow parameters before running simulation #368

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading