Skip to content

Commit

Permalink
Update following dynawo 1.5.0 min version
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <[email protected]>
  • Loading branch information
flo-dup committed Nov 6, 2023
1 parent 71e4382 commit 36e5324
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private DynawoConstants() {
*/
public static final String IIDM_VERSION = IidmXmlVersion.V_1_4.toString(".");

static final String DYNAWO_CMD_NAME = "dynawo";
public static final String DYNAWO_CMD_NAME = "dynawo";

public static final DynawoVersion VERSION_MIN = new DynawoVersion(1, 5, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ public static void writeIidm(Network network, Path file) {
network.write("XIIDM", params, file);
}

public static void requireDynawoMinVersion(ExecutionEnvironment env, ComputationManager computationManager, Command versionCmd, boolean fromErr) {
public static void requireDynaMinVersion(ExecutionEnvironment env, ComputationManager computationManager, Command versionCmd,
String dynaName, boolean fromErr) {
if (!checkDynawoVersion(env, computationManager, versionCmd, fromErr)) {
throw new PowsyblException("DynaFlow version not supported. Must be >= " + DynawoConstants.VERSION_MIN);
throw new PowsyblException(dynaName + " version not supported. Must be >= " + DynawoConstants.VERSION_MIN);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public CompletableFuture<LoadFlowResult> run(Network network, ComputationManager
DynaFlowConfig config = Objects.requireNonNull(configSupplier.get());
ExecutionEnvironment env = new ExecutionEnvironment(config.createEnv(), WORKING_DIR_PREFIX, config.isDebug());
Command versionCmd = getVersionCommand(config);
DynawoUtil.requireDynawoMinVersion(env, computationManager, versionCmd, true);
DynawoUtil.requireDynaMinVersion(env, computationManager, versionCmd, DYNAFLOW_LAUNCHER_PROGRAM_NAME, true);
return computationManager.execute(env, new DynaFlowHandler(network, workingStateId, dynaFlowParameters, loadFlowParameters, config, reporter));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public CompletableFuture<SecurityAnalysisReport> run(String workingVariantId,
DynaFlowConfig config = Objects.requireNonNull(configSupplier.get());
ExecutionEnvironment env = new ExecutionEnvironment(config.createEnv(), WORKING_DIR_PREFIX, config.isDebug());
Command versionCmd = getVersionCommand(config);
DynawoUtil.requireDynawoMinVersion(env, computationManager, versionCmd, true);
DynawoUtil.requireDynaMinVersion(env, computationManager, versionCmd, DynaFlowConstants.DYNAFLOW_LAUNCHER_PROGRAM_NAME, true);
List<Contingency> contingencies = contingenciesProvider.getContingencies(network);
return computationManager.execute(env, new AbstractExecutionHandler<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.powsybl.computation.local.LocalCommandExecutor;
import com.powsybl.computation.local.LocalComputationConfig;
import com.powsybl.computation.local.LocalComputationManager;
import com.powsybl.dynawo.commons.DynawoConstants;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.xml.NetworkXml;
import com.powsybl.loadflow.LoadFlow;
Expand Down Expand Up @@ -189,7 +190,7 @@ void testCallingBadVersionDynaFlow() throws Exception {
LocalCommandExecutor commandExecutor = new EmptyLocalCommandExecutorMock("/dynawo_bad_version.out");
ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(fileSystem.getPath("/working-dir"), 1), commandExecutor, ForkJoinPool.commonPool());
PowsyblException e = assertThrows(PowsyblException.class, () -> dynaFlowSimulation.run(network, computationManager, params));
assertEquals("DynaFlow version not supported. Must be >= 1.3.0", e.getMessage());
assertEquals("dynaflow-launcher version not supported. Must be >= " + DynawoConstants.VERSION_MIN, e.getMessage());
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion dynaflow/src/test/resources/dynawo_version.out
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0 (rev:HEAD-70c5c8e)
1.5.0 (rev:HEAD-32sde112)
2 changes: 1 addition & 1 deletion dynawaltz-dsl/src/test/resources/dynawo_version.out
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0 (rev:HEAD-70c5c8e)
1.5.0 (rev:HEAD-34d5sf2)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.powsybl.dynawaltz.xml.DydXml;
import com.powsybl.dynawaltz.xml.JobsXml;
import com.powsybl.dynawaltz.xml.ParametersXml;
import com.powsybl.dynawo.commons.DynawoConstants;
import com.powsybl.dynawo.commons.DynawoUtil;
import com.powsybl.dynawo.commons.NetworkResultsUpdater;
import com.powsybl.dynawo.commons.PowsyblDynawoVersion;
Expand Down Expand Up @@ -121,7 +122,7 @@ private CompletableFuture<DynamicSimulationResult> run(Network network, DynamicM
network.getVariantManager().setWorkingVariant(workingVariantId);
ExecutionEnvironment execEnv = new ExecutionEnvironment(Collections.emptyMap(), WORKING_DIR_PREFIX, dynaWaltzConfig.isDebug());
Command versionCmd = getVersionCommand(dynaWaltzConfig);
DynawoUtil.requireDynawoMinVersion(execEnv, computationManager, versionCmd, false);
DynawoUtil.requireDynaMinVersion(execEnv, computationManager, versionCmd, DynawoConstants.DYNAWO_CMD_NAME, false);

List<BlackBoxModel> blackBoxModels = dynamicModelsSupplier.get(network).stream()
.filter(BlackBoxModel.class::isInstance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.powsybl.computation.local.LocalComputationConfig;
import com.powsybl.computation.local.LocalComputationManager;
import com.powsybl.dynamicsimulation.*;
import com.powsybl.dynawo.commons.DynawoConstants;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.Substation;
import com.powsybl.iidm.network.TopologyKind;
Expand Down Expand Up @@ -169,7 +170,8 @@ void testCallingBadVersionDynawo() throws Exception {
CurvesSupplier cs = CurvesSupplier.empty();
String wvId = network.getVariantManager().getWorkingVariantId();
DynamicSimulationParameters dsp = DynamicSimulationParameters.load();
assertThrows(PowsyblException.class, () -> dynawoSimulation.run(network, dms, ems, cs, wvId, computationManager, dsp));
PowsyblException e = assertThrows(PowsyblException.class, () -> dynawoSimulation.run(network, dms, ems, cs, wvId, computationManager, dsp));
assertEquals("dynawo version not supported. Must be >= " + DynawoConstants.VERSION_MIN, e.getMessage());
}

private static Network createTestNetwork() {
Expand Down
2 changes: 1 addition & 1 deletion dynawaltz/src/test/resources/dynawo_version.out
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0 (rev:HEAD-70c5c8e)
1.5.0 (rev:HEAD-10c7d8e)
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
*/
public abstract class AbstractDynawoTest {

private static final String DYNAWO_VERSION = "1.4.1";

private static final String DOCKER_IMAGE_ID = "powsybl/java-dynawo:" + DYNAWO_VERSION;
private static final String DOCKER_IMAGE_ID = "powsybl/java-dynawo:2.1.0";

@TempDir
Path localDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void testIeee14() {
assertEquals(41, result.getCurves().size());
DoubleTimeSeries ts1 = (DoubleTimeSeries) result.getCurve("_GEN____1_SM_generator_UStatorPu");
assertEquals("_GEN____1_SM_generator_UStatorPu", ts1.getMetadata().getName());
assertEquals(586, ts1.toArray().length);
assertEquals(587, ts1.toArray().length);
StringTimeSeries timeLine = result.getTimeLine();
assertEquals(1, timeLine.toArray().length);
assertNull(timeLine.toArray()[0]); // FIXME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<parametersSet xmlns="http://www.rte-france.com/dynawo">
<set id="1">
<par type="BOOL" name="generator_UseApproximation" value="false"/>
<par type="INT" name="generator_ExcitationPu" value="1"/>
<par type="DOUBLE" name="generator_md" value="0.215"/>
<par type="DOUBLE" name="generator_mq" value="0.215"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<reference type="DOUBLE" name="load_UPhase0" origData="IIDM" origName="angle_pu"/>
</set>
<set id="GSFWPR_GEN____1_SM">
<par type="BOOL" name="generator_UseApproximation" value="false"/>
<par type="INT" name="generator_ExcitationPu" value="1"/>
<par type="DOUBLE" name="generator_md" value="0.215"/>
<par type="DOUBLE" name="generator_mq" value="0.215"/>
Expand Down Expand Up @@ -61,6 +62,7 @@
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
</set>
<set id="GSFWPR_GEN____2_SM">
<par type="BOOL" name="generator_UseApproximation" value="false"/>
<par type="INT" name="generator_ExcitationPu" value="1"/>
<par type="DOUBLE" name="generator_md" value="0.084"/>
<par type="DOUBLE" name="generator_mq" value="0.084"/>
Expand Down Expand Up @@ -113,6 +115,7 @@
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
</set>
<set id="GSFWPR_GEN____3_SM">
<par type="BOOL" name="generator_UseApproximation" value="false"/>
<par type="INT" name="generator_ExcitationPu" value="1"/>
<par type="DOUBLE" name="generator_md" value="0.05"/>
<par type="DOUBLE" name="generator_mq" value="0.05"/>
Expand Down Expand Up @@ -165,6 +168,7 @@
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
</set>
<set id="GSTWPR_GEN____6_SM">
<par type="BOOL" name="generator_UseApproximation" value="false"/>
<par type="INT" name="generator_ExcitationPu" value="1"/>
<par type="DOUBLE" name="generator_md" value="0.16"/>
<par type="DOUBLE" name="generator_mq" value="0.16"/>
Expand Down Expand Up @@ -215,6 +219,7 @@
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
</set>
<set id="GSTWPR_GEN____8_SM">
<par type="BOOL" name="generator_UseApproximation" value="false"/>
<par type="INT" name="generator_ExcitationPu" value="1"/>
<par type="DOUBLE" name="generator_md" value="0"/>
<par type="DOUBLE" name="generator_mq" value="0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,37 @@
"limitName" : "UInfUmin",
"limit" : 220.0,
"limitReduction" : 1.0,
"value" : 217.0313225683405
"value" : 217.0313224616946
}, {
"subjectId" : "S1VL2_BBS1",
"subjectName" : "S1VL2_BBS1",
"limitType" : "LOW_VOLTAGE",
"limitName" : "UInfUmin",
"limit" : 390.0,
"limitReduction" : 1.0,
"value" : 386.2578554100461
"value" : 386.2578552204803
}, {
"subjectId" : "S1VL2_BBS2",
"subjectName" : "S1VL2_BBS2",
"limitType" : "LOW_VOLTAGE",
"limitName" : "UInfUmin",
"limit" : 390.0,
"limitReduction" : 1.0,
"value" : 386.2578554100461
"value" : 386.2578552204803
}, {
"subjectId" : "S1VL1",
"limitType" : "LOW_VOLTAGE",
"limitName" : "UInfUmin",
"limit" : 220.0,
"limitReduction" : 1.0,
"value" : 217.0313225683405
"value" : 217.0313224616946
}, {
"subjectId" : "S1VL2",
"limitType" : "LOW_VOLTAGE",
"limitName" : "UInfUmin",
"limit" : 390.0,
"limitReduction" : 1.0,
"value" : 386.2578554100461
"value" : 386.2578552204803
} ],
"actionsTaken" : [ ]
},
Expand Down Expand Up @@ -117,37 +117,37 @@
"limitName" : "UInfUmin",
"limit" : 220.0,
"limitReduction" : 1.0,
"value" : 217.86284536089445
"value" : 217.8628453608945
}, {
"subjectId" : "S1VL2_BBS1",
"subjectName" : "S1VL2_BBS1",
"limitType" : "LOW_VOLTAGE",
"limitName" : "UInfUmin",
"limit" : 390.0,
"limitReduction" : 1.0,
"value" : 387.73559734847123
"value" : 387.7355973484713
}, {
"subjectId" : "S1VL2_BBS2",
"subjectName" : "S1VL2_BBS2",
"limitType" : "LOW_VOLTAGE",
"limitName" : "UInfUmin",
"limit" : 390.0,
"limitReduction" : 1.0,
"value" : 387.73559734847123
"value" : 387.7355973484713
}, {
"subjectId" : "S1VL1",
"limitType" : "LOW_VOLTAGE",
"limitName" : "UInfUmin",
"limit" : 220.0,
"limitReduction" : 1.0,
"value" : 217.86284536089445
"value" : 217.8628453608945
}, {
"subjectId" : "S1VL2",
"limitType" : "LOW_VOLTAGE",
"limitName" : "UInfUmin",
"limit" : 390.0,
"limitReduction" : 1.0,
"value" : 387.73559734847123
"value" : 387.7355973484713
} ],
"actionsTaken" : [ ]
},
Expand Down
1 change: 1 addition & 0 deletions dynawo-integration-tests/src/test/resources/smib/SMIB.par
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
</set>
<!-- Generator -->
<set id="5">
<par type="BOOL" name="generator_UseApproximation" value="false"/>
<par type="DOUBLE" name="generator_md" value="0.1"/>
<par type="DOUBLE" name="generator_mq" value="0.1"/>
<par type="DOUBLE" name="generator_nd" value="6"/>
Expand Down
1 change: 1 addition & 0 deletions dynawo-integration-tests/src/test/resources/svc/models.par
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<reference type="DOUBLE" name="load_UPhase0" origData="IIDM" origName="angle_pu"/>
</set>
<set id="GSFWPR_G1">
<par type="BOOL" name="generator_UseApproximation" value="false"/>
<par type="INT" name="generator_ExcitationPu" value="1"/>
<par type="DOUBLE" name="generator_md" value="0.215"/>
<par type="DOUBLE" name="generator_mq" value="0.215"/>
Expand Down

0 comments on commit 36e5324

Please sign in to comment.