From b1190848de6a0108c5c7bd4f98f5761005639955 Mon Sep 17 00:00:00 2001 From: lisrte Date: Tue, 8 Oct 2024 16:25:24 +0200 Subject: [PATCH] Add synchronized loads Edit models.json with SYNCHRONIZED properties for "Motor" loads Signed-off-by: lisrte --- .../dynawo/models/loads/BaseLoadBuilder.java | 2 + .../dynawo/models/loads/SynchronizedLoad.java | 50 +++++++++++++++++++ .../src/main/resources/models.json | 20 +++++++- .../powsybl/dynawo/xml/LoadsModelXmlTest.java | 17 ++++--- .../src/test/resources/load_synchronized.xml | 26 ++++++++++ 5 files changed, 108 insertions(+), 7 deletions(-) create mode 100644 dynawo-simulation/src/main/java/com/powsybl/dynawo/models/loads/SynchronizedLoad.java create mode 100644 dynawo-simulation/src/test/resources/load_synchronized.xml diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/loads/BaseLoadBuilder.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/loads/BaseLoadBuilder.java index d363a533f..b745ac0a5 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/loads/BaseLoadBuilder.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/loads/BaseLoadBuilder.java @@ -63,6 +63,8 @@ public BaseLoad build() { if (isInstantiable()) { if (modelConfig.isControllable()) { return new BaseLoadControllable(dynamicModelId, getEquipment(), parameterSetId, modelConfig); + } else if (modelConfig.isSynchronized()) { + return new SynchronizedLoad(dynamicModelId, getEquipment(), parameterSetId, modelConfig); } else { return new BaseLoad(dynamicModelId, getEquipment(), parameterSetId, modelConfig); } diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/loads/SynchronizedLoad.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/loads/SynchronizedLoad.java new file mode 100644 index 000000000..0bf0c1f46 --- /dev/null +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/loads/SynchronizedLoad.java @@ -0,0 +1,50 @@ +/** + * 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.dynawo.models.loads; + +import com.powsybl.dynawo.builders.ModelConfig; +import com.powsybl.dynawo.models.VarConnection; +import com.powsybl.dynawo.models.frequencysynchronizers.FrequencySynchronizedModel; +import com.powsybl.dynawo.models.utils.BusUtils; +import com.powsybl.iidm.network.Bus; +import com.powsybl.iidm.network.Load; + +import java.util.List; + +/** + * @author Laurent Issertial {@literal } + */ +public class SynchronizedLoad extends BaseLoad implements FrequencySynchronizedModel { + + protected SynchronizedLoad(String dynamicModelId, Load load, String parameterSetId, ModelConfig modelConfig) { + super(dynamicModelId, load, parameterSetId, modelConfig); + } + + @Override + public List getOmegaRefVarConnections() { + return List.of( + new VarConnection("omegaRef_grp_@INDEX@_value", getOmegaRefPuVarName()), + new VarConnection("running_grp_@INDEX@", getRunningVarName()) + ); + } + + @Override + public String getOmegaRefPuVarName() { + return "load_omegaRefPu_value"; + } + + @Override + public String getRunningVarName() { + return "load_running"; + } + + @Override + public Bus getConnectableBus() { + return BusUtils.getConnectableBus(equipment); + } +} diff --git a/dynawo-simulation/src/main/resources/models.json b/dynawo-simulation/src/main/resources/models.json index 8ce5597d7..fefbd76cc 100644 --- a/dynawo-simulation/src/main/resources/models.json +++ b/dynawo-simulation/src/main/resources/models.json @@ -459,7 +459,10 @@ "lib": "LoadAlphaBetaRestorativeLimitsRecalc" }, { - "lib": "LoadAlphaBetaMotor" + "lib": "LoadAlphaBetaMotor", + "properties": [ + "SYNCHRONIZED" + ] }, { "lib": "LoadPQ", @@ -475,22 +478,37 @@ }, { "lib": "LoadAlphaBetaMotorFifthOrder", + "properties": [ + "SYNCHRONIZED" + ], "minVersion": "1.7.0" }, { "lib": "LoadAlphaBetaMotorSimplified", + "properties": [ + "SYNCHRONIZED" + ], "minVersion": "1.7.0" }, { "lib": "LoadAlphaBetaThreeMotorFifthOrder", + "properties": [ + "SYNCHRONIZED" + ], "minVersion": "1.7.0" }, { "lib": "LoadAlphaBetaTwoMotorFifthOrder", + "properties": [ + "SYNCHRONIZED" + ], "minVersion": "1.7.0" }, { "lib": "LoadAlphaBetaTwoMotorSimplified", + "properties": [ + "SYNCHRONIZED" + ], "minVersion": "1.7.0" }, { diff --git a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/LoadsModelXmlTest.java b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/LoadsModelXmlTest.java index d2ca79429..48f4ab0e0 100644 --- a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/LoadsModelXmlTest.java +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/LoadsModelXmlTest.java @@ -50,35 +50,40 @@ protected void addDynamicModels(Function< Network, BlackBoxModel> loadConstructo @MethodSource("provideLoads") void writeLoadModel(String dydName, Function< Network, BlackBoxModel> loadConstructor) throws SAXException, IOException { DydXml.write(tmpDir, context); - validate("dyd.xsd", dydName + ".xml", tmpDir.resolve(DynawoSimulationConstants.DYD_FILENAME)); + validate("dyd.xsd", dydName, tmpDir.resolve(DynawoSimulationConstants.DYD_FILENAME)); } private static Stream provideLoads() { return Stream.of( - Arguments.of("load_alpha_beta_dyd", (Function) n -> BaseLoadBuilder.of(n, "LoadAlphaBeta") + Arguments.of("load_alpha_beta_dyd.xml", (Function) n -> BaseLoadBuilder.of(n, "LoadAlphaBeta") .dynamicModelId(DYN_LOAD_NAME) .staticId(LOAD_NAME) .parameterSetId("LAB") .build()), - Arguments.of("load_one_transformer_dyd", (Function) n -> LoadOneTransformerBuilder.of(n, "LoadOneTransformer") + Arguments.of("load_one_transformer_dyd.xml", (Function) n -> LoadOneTransformerBuilder.of(n, "LoadOneTransformer") .dynamicModelId(DYN_LOAD_NAME) .staticId(LOAD_NAME) .parameterSetId("LOT") .build()), - Arguments.of("load_one_transformer_tap_changer_dyd", (Function) n -> LoadOneTransformerTapChangerBuilder.of(n, "LoadOneTransformerTapChanger") + Arguments.of("load_one_transformer_tap_changer_dyd.xml", (Function) n -> LoadOneTransformerTapChangerBuilder.of(n, "LoadOneTransformerTapChanger") .dynamicModelId(DYN_LOAD_NAME) .staticId(LOAD_NAME) .parameterSetId("LOTTC") .build()), - Arguments.of("load_two_transformers_dyd", (Function) n -> LoadTwoTransformersBuilder.of(n, "LoadTwoTransformers") + Arguments.of("load_two_transformers_dyd.xml", (Function) n -> LoadTwoTransformersBuilder.of(n, "LoadTwoTransformers") .dynamicModelId(DYN_LOAD_NAME) .staticId(LOAD_NAME) .parameterSetId("LTT") .build()), - Arguments.of("load_two_transformers_tap_changers_dyd", (Function) n -> LoadTwoTransformersTapChangersBuilder.of(n, "LoadTwoTransformersTapChangers") + Arguments.of("load_two_transformers_tap_changers_dyd.xml", (Function) n -> LoadTwoTransformersTapChangersBuilder.of(n, "LoadTwoTransformersTapChangers") .dynamicModelId(DYN_LOAD_NAME) .staticId(LOAD_NAME) .parameterSetId("LTTTC") + .build()), + Arguments.of("load_synchronized.xml", (Function) n -> BaseLoadBuilder.of(n, "LoadAlphaBetaMotor") + .dynamicModelId(DYN_LOAD_NAME) + .staticId(LOAD_NAME) + .parameterSetId("LAB") .build()) ); } diff --git a/dynawo-simulation/src/test/resources/load_synchronized.xml b/dynawo-simulation/src/test/resources/load_synchronized.xml new file mode 100644 index 000000000..096b713d1 --- /dev/null +++ b/dynawo-simulation/src/test/resources/load_synchronized.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +