From fb8d952e2b208d7fbf01a8206edbcbcab20aaf0f Mon Sep 17 00:00:00 2001 From: Lisrte Date: Wed, 15 May 2024 10:45:46 +0200 Subject: [PATCH 1/3] Various refactors (#345) * Add equipment id to default model warning/report * Remove deprecated and other minors errors * Refactor ModelConfigsJsonDeserializer * Fix test, checkstyle; replace AtomicReference with anonymous object Signed-off-by: lisrte --- .../dynawo/commons/dynawologs/LogUtils.java | 2 +- .../dynaflow/DynaFlowParametersTest.java | 36 +++---- .../dynaflow/DynaFlowProviderTest.java | 8 +- .../JsonDynaFlowParametersSerializerTest.java | 32 +++---- .../powsybl/dynawaltz/dsl/DslReports.groovy | 2 +- .../DynaWaltzGroovyCurvesSupplierTest.java | 2 +- .../dsl/EventModelsSupplierTest.java | 2 +- .../ModelConfigsJsonDeserializer.java | 96 +++++++++---------- .../defaultmodels/DefaultModelsHandler.java | 4 +- dynawaltz/src/main/resources/models.json | 44 ++++----- .../dynawaltz/DynaWaltzProviderTest.java | 5 +- .../builders/ModelConfigLoaderTest.java | 12 +-- .../DefaultModelHandlerTest.java | 2 +- .../com/powsybl/dynawo/it/DynaFlowTest.java | 8 +- .../com/powsybl/dynawo/it/DynaWaltzTest.java | 2 +- 15 files changed, 125 insertions(+), 132 deletions(-) diff --git a/commons/src/main/java/com/powsybl/dynawo/commons/dynawologs/LogUtils.java b/commons/src/main/java/com/powsybl/dynawo/commons/dynawologs/LogUtils.java index cefcccdf9..06c2f0a34 100644 --- a/commons/src/main/java/com/powsybl/dynawo/commons/dynawologs/LogUtils.java +++ b/commons/src/main/java/com/powsybl/dynawo/commons/dynawologs/LogUtils.java @@ -27,7 +27,7 @@ private LogUtils() { public static Optional createLog(String severity, String message) { if (severity == null) { - LOGGER.warn("Inconsistent log entry (modelName: '{}', message: '{}')", severity, message); + LOGGER.warn("Inconsistent log entry (message: '{}')", message); } else { if (emptyMessage(message)) { LOGGER.debug("Empty message, the entry will be skipped : {}", message); diff --git a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java index 52347e736..ad6dd9447 100644 --- a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java +++ b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowParametersTest.java @@ -193,7 +193,7 @@ void checkAllParametersAssignedToString() { @Test void defaultParametersSerialization() throws IOException { LoadFlowParameters lfParameters = LoadFlowParameters.load(platformConfig); - lfParameters.setNoGeneratorReactiveLimits(true); + lfParameters.setUseReactiveLimits(false); lfParameters.setPhaseShifterRegulationOn(false); DynaFlowParameters dynaFlowParameters = new DynaFlowParameters(); @@ -212,25 +212,25 @@ void defaultParametersSerialization() throws IOException { @Test void parametersSerialization() throws IOException { LoadFlowParameters lfParameters = LoadFlowParameters.load(platformConfig); - lfParameters.setNoGeneratorReactiveLimits(true); + lfParameters.setUseReactiveLimits(false); lfParameters.setPhaseShifterRegulationOn(false); - DynaFlowParameters dynaFlowParameters = new DynaFlowParameters(); - dynaFlowParameters.setSvcRegulationOn(true); - dynaFlowParameters.setShuntRegulationOn(false); - dynaFlowParameters.setAutomaticSlackBusOn(true); - dynaFlowParameters.setDsoVoltageLevel(32.4); - dynaFlowParameters.setActivePowerCompensation(ActivePowerCompensation.P); - dynaFlowParameters.setSettingPath("path/to/settingFile"); - dynaFlowParameters.setAssemblingPath("path/to/assemblingFile"); - dynaFlowParameters.setStartTime(0.); - dynaFlowParameters.setStopTime(100.); - dynaFlowParameters.setPrecision(0.); - dynaFlowParameters.setTimeOfEvent(10.); - dynaFlowParameters.setChosenOutputs(Collections.singletonList(OutputTypes.STEADYSTATE.name())); - dynaFlowParameters.setTimeStep(2.6); - dynaFlowParameters.setStartingPointMode(StartingPointMode.WARM); - dynaFlowParameters.setMergeLoads(false); + DynaFlowParameters dynaFlowParameters = new DynaFlowParameters() + .setSvcRegulationOn(true) + .setShuntRegulationOn(false) + .setAutomaticSlackBusOn(true) + .setDsoVoltageLevel(32.4) + .setActivePowerCompensation(ActivePowerCompensation.P) + .setSettingPath("path/to/settingFile") + .setAssemblingPath("path/to/assemblingFile") + .setStartTime(0.) + .setStopTime(100.) + .setPrecision(0.) + .setTimeOfEvent(10.) + .setChosenOutputs(Collections.singletonList(OutputTypes.STEADYSTATE.name())) + .setTimeStep(2.6) + .setStartingPointMode(StartingPointMode.WARM) + .setMergeLoads(false); lfParameters.addExtension(DynaFlowParameters.class, dynaFlowParameters); Path workingDir = fileSystem.getPath("dynaflow/workingDir"); diff --git a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java index e04371357..ff68bbb7a 100644 --- a/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java +++ b/dynaflow/src/test/java/com/powsybl/dynaflow/DynaFlowProviderTest.java @@ -35,6 +35,8 @@ import static com.powsybl.commons.test.ComparisonUtils.compareXml; import static com.powsybl.dynaflow.DynaFlowConstants.*; +import static com.powsybl.loadflow.LoadFlowResult.Status.FAILED; +import static com.powsybl.loadflow.LoadFlowResult.Status.FULLY_CONVERGED; import static org.junit.jupiter.api.Assertions.*; /** @@ -134,7 +136,7 @@ void testWithoutMergeLoads() throws Exception { ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(fileSystem.getPath("/working-dir"), 1), commandExecutor, ForkJoinPool.commonPool()); LoadFlowResult result = dynaFlowSimulation.run(network, computationManager, params); assertNotNull(result); - assertTrue(result.isOk()); + assertEquals(FULLY_CONVERGED, result.getStatus()); InputStream pReferenceOutput = getClass().getResourceAsStream("/output.xiidm"); Network expectedNetwork = NetworkSerDe.read(pReferenceOutput); @@ -155,7 +157,7 @@ void testWithMergeLoads() throws Exception { ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(fileSystem.getPath("/working-dir"), 1), commandExecutor, ForkJoinPool.commonPool()); LoadFlowResult result = dynaFlowSimulation.run(network, computationManager, params); assertNotNull(result); - assertTrue(result.isOk()); + assertEquals(FULLY_CONVERGED, result.getStatus()); InputStream pReferenceOutput = getClass().getResourceAsStream("/output.xiidm"); Network expectedNetwork = NetworkSerDe.read(pReferenceOutput); @@ -175,7 +177,7 @@ void testFail() throws Exception { ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(fileSystem.getPath("/working-dir"), 1), commandExecutor, ForkJoinPool.commonPool()); LoadFlowResult result = dynaFlowSimulation.run(network, computationManager, params); assertNotNull(result); - assertFalse(result.isOk()); + assertEquals(FAILED, result.getStatus()); } @Test diff --git a/dynaflow/src/test/java/com/powsybl/dynaflow/json/JsonDynaFlowParametersSerializerTest.java b/dynaflow/src/test/java/com/powsybl/dynaflow/json/JsonDynaFlowParametersSerializerTest.java index fcc5c4982..f81e5cadc 100644 --- a/dynaflow/src/test/java/com/powsybl/dynaflow/json/JsonDynaFlowParametersSerializerTest.java +++ b/dynaflow/src/test/java/com/powsybl/dynaflow/json/JsonDynaFlowParametersSerializerTest.java @@ -69,24 +69,24 @@ void roundTripParameters() throws IOException { InMemoryPlatformConfig platformConfig = new InMemoryPlatformConfig(fileSystem); LoadFlowParameters parameters = LoadFlowParameters.load(platformConfig); - parameters.setNoGeneratorReactiveLimits(true); + parameters.setUseReactiveLimits(false); parameters.setPhaseShifterRegulationOn(false); - DynaFlowParameters params = new DynaFlowParameters(); - params.setSvcRegulationOn(true); - params.setShuntRegulationOn(false); - params.setAutomaticSlackBusOn(true); - params.setDsoVoltageLevel(54.23); - params.setActivePowerCompensation(DynaFlowConstants.ActivePowerCompensation.P); - params.setSettingPath("path/to/settingFile"); - params.setAssemblingPath("path/to/assemblingFile"); - params.setStartTime(0.); - params.setStopTime(100.); - params.setPrecision(0.); - params.setTimeOfEvent(10.); - params.setChosenOutputs(Collections.singletonList(DynaFlowConstants.OutputTypes.STEADYSTATE.name())); - params.setTimeStep(2.6); - params.setStartingPointMode(DynaFlowConstants.StartingPointMode.WARM); + DynaFlowParameters params = new DynaFlowParameters() + .setSvcRegulationOn(true) + .setShuntRegulationOn(false) + .setAutomaticSlackBusOn(true) + .setDsoVoltageLevel(54.23) + .setActivePowerCompensation(DynaFlowConstants.ActivePowerCompensation.P) + .setSettingPath("path/to/settingFile") + .setAssemblingPath("path/to/assemblingFile") + .setStartTime(0.) + .setStopTime(100.) + .setPrecision(0.) + .setTimeOfEvent(10.) + .setChosenOutputs(Collections.singletonList(DynaFlowConstants.OutputTypes.STEADYSTATE.name())) + .setTimeStep(2.6) + .setStartingPointMode(DynaFlowConstants.StartingPointMode.WARM); parameters.addExtension(DynaFlowParameters.class, params); diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DslReports.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DslReports.groovy index 9f28bce91..3b071e602 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DslReports.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DslReports.groovy @@ -7,7 +7,7 @@ */ package com.powsybl.dynawaltz.dsl -import com.powsybl.commons.report.ReportNode; +import com.powsybl.commons.report.ReportNode /** * @author Laurent Issertial {@literal } diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyCurvesSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyCurvesSupplierTest.java index 613e2c139..cd04ca96e 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyCurvesSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynaWaltzGroovyCurvesSupplierTest.java @@ -90,7 +90,7 @@ private static Stream provideFileError() { private List validateGroovyExtension() { List extensions = GroovyExtension.find(CurveGroovyExtension.class, DynaWaltzProvider.NAME); assertEquals(1, extensions.size()); - assertTrue(extensions.get(0) instanceof DynaWaltzCurveGroovyExtension); + assertInstanceOf(DynaWaltzCurveGroovyExtension.class, extensions.get(0)); return extensions; } diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java index 224310852..5b4b57ed3 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java @@ -111,7 +111,7 @@ faultTime should be strictly positive (0.0) 'staticId' field value 'SVC2' not found for equipment type(s) GENERATOR/LOAD 'deltaP' field is not set Model Step_SVC2 cannot be instantiated - """), + """), Arguments.of("/eventWarnings/missingDisconnectionEquipment.groovy", EurostagTutorialExample1Factory.create(), """ + DSL tests diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsJsonDeserializer.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsJsonDeserializer.java index 31536a9f4..fb8489c49 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsJsonDeserializer.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsJsonDeserializer.java @@ -11,12 +11,11 @@ import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.powsybl.commons.json.JsonUtil; import java.io.IOException; import java.util.*; -import static com.fasterxml.jackson.core.JsonToken.VALUE_STRING; - /** * @author Laurent Issertial {@literal } */ @@ -32,69 +31,60 @@ public Map deserialize(JsonParser parser, DeserializationC while (parser.nextToken() != JsonToken.END_OBJECT) { String category = parser.getCurrentName(); parser.nextToken(); - configMap.put(category, deserializeModelConfigs(parser)); + configMap.put(category, parseModelConfigs(parser)); } return configMap; } - private ModelConfigs deserializeModelConfigs(JsonParser parser) throws IOException { - String defaultLib = null; - Map libs = null; - while (parser.nextToken() != JsonToken.END_OBJECT) { - switch (parser.getCurrentName()) { - case "defaultLib": - defaultLib = parser.getValueAsString(); - break; - case "libs": - libs = deserializeLibsMap(parser); - break; - default: - throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); + private static ModelConfigs parseModelConfigs(JsonParser parser) { + var parsingContext = new Object() { + String defaultLib = null; + final Map libs = new HashMap<>(); + }; + JsonUtil.parseObject(parser, name -> + switch (name) { + case "defaultLib" -> { + parsingContext.defaultLib = parser.nextTextValue(); + yield true; + } + case "libs" -> { + JsonUtil.parseObjectArray(parser, mc -> parsingContext.libs.put(mc.name(), mc), ModelConfigsJsonDeserializer::parseModelConfig); + yield true; + } + default -> false; } - } - return new ModelConfigs(libs, defaultLib); + ); + return new ModelConfigs(parsingContext.libs, parsingContext.defaultLib); } - private Map deserializeLibsMap(JsonParser parser) throws IOException { - Map libs = new HashMap<>(); - while (parser.nextToken() != JsonToken.END_ARRAY) { - parser.nextToken(); + private static ModelConfig parseModelConfig(JsonParser parser) { + var parsingContext = new Object() { String lib = null; String alias = null; String internalModelPrefix = null; List properties = Collections.emptyList(); - while (parser.nextToken() != JsonToken.END_OBJECT) { - switch (parser.getCurrentName()) { - case "lib": - lib = parser.getValueAsString(); - break; - case "properties": - properties = deserializeProperties(parser); - break; - case "internalModelPrefix": - internalModelPrefix = parser.getValueAsString(); - break; - case "alias": - alias = parser.getValueAsString(); - break; - default: - throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); + }; + JsonUtil.parseObject(parser, name -> + switch (parser.getCurrentName()) { + case "lib" -> { + parsingContext.lib = parser.nextTextValue(); + yield true; } + case "properties" -> { + parsingContext.properties = JsonUtil.parseStringArray(parser); + yield true; + } + case "internalModelPrefix" -> { + parsingContext.internalModelPrefix = parser.nextTextValue(); + yield true; + } + case "alias" -> { + parsingContext.alias = parser.nextTextValue(); + yield true; + } + default -> false; } - ModelConfig modelConfig = new ModelConfig(lib, alias, internalModelPrefix, properties); - libs.put(modelConfig.name(), modelConfig); - } - return libs; - } - - private List deserializeProperties(JsonParser parser) throws IOException { - List properties = new ArrayList<>(); - JsonToken token; - while ((token = parser.nextToken()) != JsonToken.END_ARRAY) { - if (token == VALUE_STRING) { - properties.add(parser.getValueAsString().toUpperCase()); - } - } - return properties; + ); + return new ModelConfig(parsingContext.lib, parsingContext.alias, parsingContext.internalModelPrefix, parsingContext.properties); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/defaultmodels/DefaultModelsHandler.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/defaultmodels/DefaultModelsHandler.java index e7c4deba8..97ff99424 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/defaultmodels/DefaultModelsHandler.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/defaultmodels/DefaultModelsHandler.java @@ -38,9 +38,9 @@ public T getDefaultModel(Identifiable equipment, Class c return connectableClass.cast(defaultModel); } if (throwException) { - throw new PowsyblException("Default model " + defaultModel.getClass().getSimpleName() + " does not implement " + connectableClass.getSimpleName() + " interface"); + throw new PowsyblException("Default model " + defaultModel.getClass().getSimpleName() + " for " + equipment.getId() + " does not implement " + connectableClass.getSimpleName() + " interface"); } else { - LOGGER.warn("Default model {} does not implement {} interface", defaultModel.getClass().getSimpleName(), connectableClass.getSimpleName()); + LOGGER.warn("Default model {} for {} does not implement {} interface", defaultModel.getClass().getSimpleName(), equipment.getId(), connectableClass.getSimpleName()); return null; } } diff --git a/dynawaltz/src/main/resources/models.json b/dynawaltz/src/main/resources/models.json index 0f785ad16..36de2cb56 100644 --- a/dynawaltz/src/main/resources/models.json +++ b/dynawaltz/src/main/resources/models.json @@ -16,7 +16,7 @@ { "lib": "GeneratorSynchronousFourWindingsGoverPropVRPropInt", "properties": [ - "Controllable" + "CONTROLLABLE" ] }, { @@ -31,13 +31,13 @@ { "lib": "GeneratorSynchronousFourWindingsPmConstVRNordicTfo", "properties": [ - "Transformer" + "TRANSFORMER" ] }, { "lib": "GeneratorSynchronousFourWindingsProportionalRegulations", "properties": [ - "Controllable" + "CONTROLLABLE" ] }, { @@ -64,13 +64,13 @@ { "lib": "GeneratorSynchronousThreeWindingsGoverNordicVRNordicTfo", "properties": [ - "Transformer" + "TRANSFORMER" ] }, { "lib": "GeneratorSynchronousThreeWindingsGoverPropVRPropInt", "properties": [ - "Controllable" + "CONTROLLABLE" ] }, { @@ -79,13 +79,13 @@ { "lib": "GeneratorSynchronousThreeWindingsPmConstVRNordicTfo", "properties": [ - "Transformer" + "TRANSFORMER" ] }, { "lib": "GeneratorSynchronousThreeWindingsProportionalRegulations", "properties": [ - "Controllable" + "CONTROLLABLE" ] } ] @@ -99,7 +99,7 @@ { "lib": "GeneratorPV", "properties": [ - "Controllable" + "CONTROLLABLE" ] }, { @@ -140,25 +140,25 @@ { "lib": "HvdcPVDangling", "properties": [ - "Dangling" + "DANGLING" ] }, { "lib": "HvdcPVDanglingDiagramPQ", "properties": [ - "Dangling" + "DANGLING" ] }, { "lib": "HvdcPTanPhiDangling", "properties": [ - "Dangling" + "DANGLING" ] }, { "lib": "HvdcPTanPhiDanglingDiagramPQ", "properties": [ - "Dangling" + "DANGLING" ] } ] @@ -175,13 +175,13 @@ { "lib": "HvdcVSCDanglingP", "properties": [ - "Dangling" + "DANGLING" ] }, { "lib": "HvdcVSCDanglingUdc", "properties": [ - "Dangling" + "DANGLING" ] } ] @@ -214,7 +214,7 @@ { "lib": "LoadAlphaBeta", "properties": [ - "Controllable" + "CONTROLLABLE" ] }, { @@ -318,14 +318,14 @@ "lib": "WTG4AWeccCurrentSource", "internalModelPrefix": "WTG4A", "properties": [ - "Synchronized" + "SYNCHRONIZED" ] }, { "lib": "WTG4BWeccCurrentSource", "internalModelPrefix": "WTG4B", "properties": [ - "Synchronized" + "SYNCHRONIZED" ] }, { @@ -340,14 +340,14 @@ "lib": "PhotovoltaicsWeccCurrentSource", "internalModelPrefix": "photovoltaics", "properties": [ - "Synchronized" + "SYNCHRONIZED" ] }, { "lib": "PhotovoltaicsWeccVoltageSource", "internalModelPrefix": "photovoltaics", "properties": [ - "Synchronized" + "SYNCHRONIZED" ] } ] @@ -358,19 +358,19 @@ { "lib": "GridFormingConverterDroopControl", "properties": [ - "Synchronized" + "SYNCHRONIZED" ] }, { "lib": "GridFormingConverterMatchingControl", "properties": [ - "Synchronized" + "SYNCHRONIZED" ] }, { "lib": "GridFormingConverterDispatchableVirtualOscillatorControl", "properties": [ - "Synchronized" + "SYNCHRONIZED" ] } ] diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzProviderTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzProviderTest.java index 7f2a4ba5d..68e334a32 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzProviderTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/DynaWaltzProviderTest.java @@ -33,6 +33,7 @@ import java.util.concurrent.ForkJoinPool; import static com.powsybl.commons.report.ReportNode.NO_OP; +import static com.powsybl.dynamicsimulation.DynamicSimulationResult.Status.FAILURE; import static org.junit.jupiter.api.Assertions.*; /** @@ -146,7 +147,7 @@ void testFail() throws Exception { CurvesSupplier.empty(), network.getVariantManager().getWorkingVariantId(), computationManager, DynamicSimulationParameters.load(), NO_OP); assertNotNull(result); - assertFalse(result.isOk()); + assertEquals(FAILURE, result.getStatus()); } @Test @@ -160,7 +161,7 @@ void testWithoutCurves() throws Exception { new CurvesSupplierMock(), network.getVariantManager().getWorkingVariantId(), computationManager, DynamicSimulationParameters.load(), NO_OP); assertNotNull(result); - assertFalse(result.isOk()); + assertEquals(FAILURE, result.getStatus()); } @Test diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderTest.java index a5a1bb725..336014f43 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderTest.java @@ -35,17 +35,17 @@ void loadConfigTest() throws IOException { "libs": [ { "lib": "PhotovoltaicsWeccCurrentSource", - "alias": "WeccCs", + "alias": "Wecc", "internalModelPrefix": "WTG4A", "properties": [ - "Synchronized" + "SYNCHRONIZED" ] }, { "lib": "WT4BWeccCurrentSource", "properties": [ - "Synchronized", - "Controllable" + "SYNCHRONIZED", + "CONTROLLABLE" ] }, { @@ -64,12 +64,12 @@ void loadConfigTest() throws IOException { assertThat(configs.keySet()).containsExactlyInAnyOrder("synchronousGenerators"); ModelConfigs synchroGens = configs.get("synchronousGenerators"); assertThat(synchroGens.getSupportedLibs()).containsExactlyInAnyOrder( - "WeccCs", + "Wecc", "WT4BWeccCurrentSource", "WT4AWeccCurrentSource"); ModelConfig defaultModel = new ModelConfig("WT4BWeccCurrentSource", null, null, List.of("SYNCHRONIZED", "CONTROLLABLE")); assertThat(listModelConfigs(synchroGens)).containsExactlyInAnyOrder( - new ModelConfig("PhotovoltaicsWeccCurrentSource", "WeccCs", "WTG4A", List.of("SYNCHRONIZED")), + new ModelConfig("PhotovoltaicsWeccCurrentSource", "Wecc", "WTG4A", List.of("SYNCHRONIZED")), defaultModel, new ModelConfig("WT4AWeccCurrentSource", null, null, Collections.emptyList())); assertEquals(defaultModel, synchroGens.getDefaultModelConfig()); diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/defaultmodels/DefaultModelHandlerTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/defaultmodels/DefaultModelHandlerTest.java index d0d8fe2c9..edad8b862 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/defaultmodels/DefaultModelHandlerTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/defaultmodels/DefaultModelHandlerTest.java @@ -54,7 +54,7 @@ void noInterfaceImplementationLog() { void noInterfaceImplementationException() { Generator gen = network.getGenerator("GEN"); PowsyblException pe = assertThrows(PowsyblException.class, () -> defaultModelHandler.getDefaultModel(gen, LoadModel.class, true)); - assertEquals("Default model DefaultGenerator does not implement LoadModel interface", pe.getMessage()); + assertEquals("Default model DefaultGenerator for GEN does not implement LoadModel interface", pe.getMessage()); } @Test diff --git a/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynaFlowTest.java b/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynaFlowTest.java index bf9244c38..06755bfb1 100644 --- a/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynaFlowTest.java +++ b/dynawo-integration-tests/src/test/java/com/powsybl/dynawo/it/DynaFlowTest.java @@ -40,8 +40,8 @@ import java.util.List; import java.util.Objects; +import static com.powsybl.loadflow.LoadFlowResult.ComponentResult.Status.CONVERGED; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Geoffroy Jamgotchian {@literal } @@ -81,15 +81,15 @@ void testLf() throws IOException { LoadFlowResult result = loadFlowProvider.run(network, computationManager, VariantManagerConstants.INITIAL_VARIANT_ID, loadFlowParameters, reportNode) .join(); - assertTrue(result.isOk()); assertEquals(1, result.getComponentResults().size()); LoadFlowResult.ComponentResult componentResult = result.getComponentResults().get(0); - assertEquals(LoadFlowResult.ComponentResult.Status.CONVERGED, componentResult.getStatus()); - assertEquals("B4", componentResult.getSlackBusId()); + assertEquals(CONVERGED, componentResult.getStatus()); + assertEquals("B4", componentResult.getSlackBusResults().get(0).getId()); StringWriter sw = new StringWriter(); reportNode.print(sw); System.out.println(sw); + InputStream refStream = Objects.requireNonNull(getClass().getResourceAsStream("/loadflow_timeline_report.txt")); String refLogExport = TestUtil.normalizeLineSeparator(new String(ByteStreams.toByteArray(refStream), StandardCharsets.UTF_8)); String logExport = TestUtil.normalizeLineSeparator(sw.toString()); 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 88362c577..9c7d7f802 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 @@ -87,7 +87,7 @@ void testIeee14() { assertEquals(DynamicSimulationResult.Status.SUCCESS, result.getStatus()); assertTrue(result.getStatusText().isEmpty()); assertEquals(41, result.getCurves().size()); - DoubleTimeSeries ts1 = (DoubleTimeSeries) result.getCurve("_GEN____1_SM_generator_UStatorPu"); + DoubleTimeSeries ts1 = result.getCurve("_GEN____1_SM_generator_UStatorPu"); assertEquals("_GEN____1_SM_generator_UStatorPu", ts1.getMetadata().getName()); assertEquals(587, ts1.toArray().length); List timeLine = result.getTimeLine(); From cae788204ec44827f1e469ca1f2a140a390ff8d3 Mon Sep 17 00:00:00 2001 From: Lisrte Date: Wed, 15 May 2024 10:53:36 +0200 Subject: [PATCH 2/3] Prevent dynamic model instanciation from fictitious loads (#343) - Check if load is fictitious before creating dynamic model - Refactor HvdcVsc check - Add unit tests Signed-off-by: lisrte --- .../AbstractEquipmentModelBuilder.java | 8 +++- .../dynawaltz/models/hvdc/HvdcVscBuilder.java | 10 ++--- .../loads/AbstractLoadModelBuilder.java | 9 ++++- .../powsybl/dynawaltz/models/HvdcTest.java | 11 ++++++ .../powsybl/dynawaltz/models/LoadTest.java | 39 +++++++++++++++++++ 5 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 dynawaltz/src/test/java/com/powsybl/dynawaltz/models/LoadTest.java diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractEquipmentModelBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractEquipmentModelBuilder.java index 54435c474..18fe04d67 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractEquipmentModelBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractEquipmentModelBuilder.java @@ -13,6 +13,7 @@ import com.powsybl.iidm.network.Network; import java.util.Objects; +import java.util.function.Predicate; /** * @author Laurent Issertial {@literal } @@ -23,6 +24,7 @@ public abstract class AbstractEquipmentModelBuilder, R protected String parameterSetId; protected final ModelConfig modelConfig; protected final BuilderEquipment builderEquipment; + private Predicate equipmentPredicates = eq -> Objects.equals(network, eq.getNetwork()); protected AbstractEquipmentModelBuilder(Network network, ModelConfig modelConfig, IdentifiableType equipmentType, ReportNode reportNode) { super(network, reportNode); @@ -72,7 +74,11 @@ protected void checkData() { protected abstract T findEquipment(String staticId); protected boolean checkEquipment(T equipment) { - return Objects.equals(network, equipment.getNetwork()); + return equipmentPredicates.test(equipment); + } + + protected void addEquipmentPredicate(Predicate predicate) { + equipmentPredicates = equipmentPredicates.and(predicate); } public T getEquipment() { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscBuilder.java index 33d34382e..bbc361573 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscBuilder.java @@ -12,12 +12,10 @@ import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.BuilderReports; -import com.powsybl.iidm.network.HvdcConverterStation; -import com.powsybl.iidm.network.HvdcLine; -import com.powsybl.iidm.network.IdentifiableType; -import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.*; import java.util.Set; +import java.util.function.Predicate; /** * @author Laurent Issertial {@literal } @@ -26,6 +24,7 @@ public class HvdcVscBuilder extends AbstractHvdcBuilder { private static final String CATEGORY = "hvdcVsc"; private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + private static final Predicate IS_VSC = eq -> HvdcConverterStation.HvdcType.VSC == eq.getConverterStation1().getHvdcType(); public static HvdcVscBuilder of(Network network) { return of(network, ReportNode.NO_OP); @@ -54,6 +53,7 @@ public static Set getSupportedLibs() { protected HvdcVscBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { super(network, modelConfig, "VSC " + IdentifiableType.HVDC_LINE, reportNode); + addEquipmentPredicate(IS_VSC); } @Override @@ -71,7 +71,7 @@ public HvdcVsc build() { @Override protected HvdcLine findEquipment(String staticId) { HvdcLine line = network.getHvdcLine(staticId); - return HvdcConverterStation.HvdcType.VSC == line.getConverterStation1().getHvdcType() ? line : null; + return line != null && IS_VSC.test(line) ? line : null; } @Override diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/AbstractLoadModelBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/AbstractLoadModelBuilder.java index 057442dd9..bf7ff2695 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/AbstractLoadModelBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/AbstractLoadModelBuilder.java @@ -14,18 +14,23 @@ import com.powsybl.iidm.network.Load; import com.powsybl.iidm.network.Network; +import java.util.function.Predicate; + /** * @author Laurent Issertial {@literal } */ public abstract class AbstractLoadModelBuilder> extends AbstractEquipmentModelBuilder { + private static final Predicate IS_NOT_FICTITIOUS = eq -> !eq.isFictitious(); + protected AbstractLoadModelBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { super(network, modelConfig, IdentifiableType.LOAD, reportNode); + addEquipmentPredicate(IS_NOT_FICTITIOUS); } @Override protected Load findEquipment(String staticId) { - return network.getLoad(staticId); + Load load = network.getLoad(staticId); + return load != null && IS_NOT_FICTITIOUS.test(load) ? load : null; } - } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/HvdcTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/HvdcTest.java index d5a49dbe9..ce94b9aa9 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/HvdcTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/HvdcTest.java @@ -18,6 +18,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * @author Laurent Issertial {@literal } @@ -58,4 +59,14 @@ void testDanglingConnectedStation() { assertEquals(1, hvdcVscDangling.getConnectedStations().size()); assertEquals(line.getConverterStation1(), hvdcVscDangling.getConnectedStations().get(0)); } + + @Test + void vscDynamicModelOnLCC() { + Network network = HvdcTestNetwork.createLcc(); + assertNull(HvdcVscBuilder.of(network) + .dynamicModelId("hvdc") + .staticId("L") + .parameterSetId("HVDC") + .build()); + } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/LoadTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/LoadTest.java new file mode 100644 index 000000000..0db1eab23 --- /dev/null +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/LoadTest.java @@ -0,0 +1,39 @@ +/** + * 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.dynawaltz.models; + +import com.powsybl.dynawaltz.models.loads.BaseLoadBuilder; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.test.NoEquipmentNetworkFactory; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; + +/** + * @author Laurent Issertial {@literal } + */ +class LoadTest { + + @Test + void loadFictitious() { + Network network = NoEquipmentNetworkFactory.create(); + network.getVoltageLevel("vl1").newLoad() + .setId("LOAD") + .setBus("busA") + .setConnectableBus("busA") + .setFictitious(true) + .setP0(600.0) + .setQ0(200.0) + .add(); + assertNull(BaseLoadBuilder.of(network) + .dynamicModelId("load") + .staticId("L") + .parameterSetId("LAB") + .build()); + } +} From 23d2bd75d63b93a733f9e1fab87e82e8e599d8fa Mon Sep 17 00:00:00 2001 From: Lisrte Date: Fri, 17 May 2024 11:46:29 +0200 Subject: [PATCH 3/3] Check measurement point are connected (#342) Signed-off-by: lisrte --- .../dsl/DynamicModelsSupplierTest.java | 2 +- .../dynawaltz/builders/BuildersUtil.java | 28 +++++++++++++--- .../models/buses/ActionConnectionPoint.java | 2 +- .../models/ActionConnectionPointTest.java | 33 +++++++++++++++++++ ...hangerBlockingAutomationSystemXmlTest.java | 14 ++++---- .../TapChangerAutomationSystemXmlTest.java | 2 +- ...hangerBlockingAutomationSystemXmlTest.java | 14 ++++---- 7 files changed, 75 insertions(+), 20 deletions(-) create mode 100644 dynawaltz/src/test/java/com/powsybl/dynawaltz/models/ActionConnectionPointTest.java diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java index de01d2460..8e91c52da 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java @@ -142,7 +142,7 @@ private static Stream provideAutomationSystemModelData() { Arguments.of("/dynamicModels/overloadManagementTwoLevels.groovy", DynamicTwoLevelsOverloadManagementSystem.class, EurostagTutorialExample1Factory.create(), "AM_NHV1_NHV2_1", "CLA", "CurrentLimitAutomatonTwoLevels"), Arguments.of("/dynamicModels/tapChanger.groovy", TapChangerAutomationSystem.class, EurostagTutorialExample1Factory.create(), "TC", "tc", "TapChangerAutomaton"), Arguments.of("/dynamicModels/tapChangerBlockingBusBar.groovy", TapChangerBlockingAutomationSystem.class, FourSubstationsNodeBreakerFactory.create(), "ZAB", "ZAB", "TapChangerBlockingAutomaton2"), - Arguments.of("/dynamicModels/tapChangerBlocking.groovy", TapChangerBlockingAutomationSystem.class, EurostagTutorialExample1Factory.create(), "ZAB", "ZAB", "TapChangerBlockingAutomaton3"), + Arguments.of("/dynamicModels/tapChangerBlocking.groovy", TapChangerBlockingAutomationSystem.class, EurostagTutorialExample1Factory.createWithLFResults(), "ZAB", "ZAB", "TapChangerBlockingAutomaton3"), Arguments.of("/dynamicModels/phaseShifterI.groovy", PhaseShifterIAutomationSystem.class, EurostagTutorialExample1Factory.create(), "PS_NGEN_NHV1", "ps", "PhaseShifterI"), Arguments.of("/dynamicModels/phaseShifterP.groovy", PhaseShifterPAutomationSystem.class, EurostagTutorialExample1Factory.create(), "PS_NGEN_NHV1", "ps", "PhaseShifterP"), Arguments.of("/dynamicModels/underVoltage.groovy", UnderVoltageAutomationSystem.class, EurostagTutorialExample1Factory.create(), "UV_GEN", "uv", "UnderVoltageAutomaton") diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuildersUtil.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuildersUtil.java index b6acfaf13..f1b6178a6 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuildersUtil.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuildersUtil.java @@ -7,9 +7,7 @@ */ package com.powsybl.dynawaltz.builders; -import com.powsybl.iidm.network.Identifiable; -import com.powsybl.iidm.network.IdentifiableType; -import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.*; /** * @author Laurent Issertial {@literal } @@ -21,8 +19,28 @@ public final class BuildersUtil { private BuildersUtil() { } + /** + * Returns the ActionConnectionPoint (bus or busbar section) identified by the staticId parameter + * Verifies the point is energized and in main connected component, if not returns null + * @param network the network containing the ActionConnectionPoint + * @param staticId the identifiable id + * @return the energized action connection point if found, null instead + */ public static Identifiable getActionConnectionPoint(Network network, String staticId) { - Identifiable point = network.getBusbarSection(staticId); - return point != null ? point : network.getBusBreakerView().getBus(staticId); + BusbarSection busbarSection = network.getBusbarSection(staticId); + if (busbarSection != null) { + return isEnergizedBus(busbarSection.getTerminal().getBusBreakerView().getBus()) ? busbarSection : null; + } + Bus bus = network.getBusBreakerView().getBus(staticId); + return isEnergizedBus(bus) ? bus : null; + } + + /** + * Verifies a bus is energized and in main connected component + * @param bus the reviewed bus + * @return true if energized, false if not + */ + private static boolean isEnergizedBus(Bus bus) { + return bus != null && !Double.isNaN(bus.getV()) && bus.isInMainConnectedComponent(); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/ActionConnectionPoint.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/ActionConnectionPoint.java index 9bb2d8d2a..2a1d7ef2e 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/ActionConnectionPoint.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/ActionConnectionPoint.java @@ -12,7 +12,7 @@ import java.util.Optional; /** - * Interface for buses used by automatons for measure or event for various actions + * Interface for buses and busbar sections used by automatons for measure or event for various actions * @author Laurent Issertial {@literal } */ public interface ActionConnectionPoint extends Model { diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/ActionConnectionPointTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/ActionConnectionPointTest.java new file mode 100644 index 000000000..724616312 --- /dev/null +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/ActionConnectionPointTest.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2024, 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.dynawaltz.models; + +import com.powsybl.dynawaltz.builders.BuildersUtil; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; +import com.powsybl.iidm.network.test.HvdcTestNetwork; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNull; +/** + * @author Laurent Issertial {@literal } + */ +class ActionConnectionPointTest { + + @Test + void voltageOffBus() { + Network network = EurostagTutorialExample1Factory.create(); + assertNull(BuildersUtil.getActionConnectionPoint(network, "NGEN")); + } + + @Test + void voltageOffBusBarSection() { + Network network = HvdcTestNetwork.createBase(); + assertNull(BuildersUtil.getActionConnectionPoint(network, "BBS1")); + } +} diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomationSystemXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomationSystemXmlTest.java index e10b80a9b..6b1073c6f 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomationSystemXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomationSystemXmlTest.java @@ -10,8 +10,6 @@ import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystemBuilder; import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder; import com.powsybl.dynawaltz.models.loads.LoadOneTransformerBuilder; -import com.powsybl.iidm.network.Bus; -import com.powsybl.iidm.network.VoltageLevel; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -26,10 +24,14 @@ class EmptyTapChangerBlockingAutomationSystemXmlTest extends AbstractDynamicMode @Override protected void setupNetwork() { - network = EurostagTutorialExample1Factory.create(); - VoltageLevel vlload = network.getVoltageLevel("VLLOAD"); - Bus nload = network.getBusBreakerView().getBus("NLOAD"); - vlload.newLoad().setId("LOAD2").setBus(nload.getId()).setConnectableBus(nload.getId()).setP0(600.0).setQ0(200.0).add(); + network = EurostagTutorialExample1Factory.createWithLFResults(); + network.getVoltageLevel("VLLOAD").newLoad() + .setId("LOAD2") + .setBus("NLOAD") + .setConnectableBus("NLOAD") + .setP0(600.0) + .setQ0(200.0) + .add(); } @Override diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemXmlTest.java index 47fe9ca54..16456732a 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemXmlTest.java @@ -26,7 +26,7 @@ class TapChangerAutomationSystemXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { - network = EurostagTutorialExample1Factory.create(); + network = EurostagTutorialExample1Factory.createWithLFResults(); VoltageLevel vlload = network.getVoltageLevel("VLLOAD"); Bus nload = network.getBusBreakerView().getBus("NLOAD"); vlload.newLoad().setId("LOAD2").setBus(nload.getId()).setConnectableBus(nload.getId()).setP0(600.0).setQ0(200.0).add(); diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomationSystemXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomationSystemXmlTest.java index a793eb8d0..9b313b9c9 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomationSystemXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomationSystemXmlTest.java @@ -12,8 +12,6 @@ import com.powsybl.dynawaltz.models.loads.LoadTwoTransformersTapChangersBuilder; import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder; -import com.powsybl.iidm.network.Bus; -import com.powsybl.iidm.network.VoltageLevel; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -31,10 +29,14 @@ class TapChangerBlockingAutomationSystemXmlTest extends AbstractDynamicModelXmlT @Override protected void setupNetwork() { - network = EurostagTutorialExample1Factory.create(); - VoltageLevel vlload = network.getVoltageLevel("VLLOAD"); - Bus nload = network.getBusBreakerView().getBus("NLOAD"); - vlload.newLoad().setId("LOAD2").setBus(nload.getId()).setConnectableBus(nload.getId()).setP0(600.0).setQ0(200.0).add(); + network = EurostagTutorialExample1Factory.createWithLFResults(); + network.getVoltageLevel("VLLOAD").newLoad() + .setId("LOAD2") + .setBus("NLOAD") + .setConnectableBus("NLOAD") + .setP0(600.0) + .setQ0(200.0) + .add(); } @Override