From 65568c867aa3f51d2bdb87b3bf3960946d2c3f67 Mon Sep 17 00:00:00 2001 From: lisrte Date: Wed, 5 Jun 2024 16:56:59 +0200 Subject: [PATCH 1/3] Add Shunt dynamic models Signed-off-by: lisrte --- .../builders/ModelConfigLoaderImpl.java | 2 + .../dynawaltz/models/shunts/BaseShunt.java | 55 +++++++++++++++ .../models/shunts/BaseShuntBuilder.java | 69 +++++++++++++++++++ .../dynawaltz/models/shunts/ShuntBuilder.java | 69 +++++++++++++++++++ .../dynawaltz/models/shunts/ShuntModel.java | 1 + dynawaltz/src/main/resources/models.json | 11 +++ .../builders/DefaultLibBuilderTest.java | 3 + .../dynawaltz/xml/ShuntModelXmlTest.java | 42 +++++++++++ dynawaltz/src/test/resources/shunt_dyd.xml | 8 +++ 9 files changed, 260 insertions(+) create mode 100644 dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShunt.java create mode 100644 dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java create mode 100644 dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntBuilder.java create mode 100644 dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.java create mode 100644 dynawaltz/src/test/resources/shunt_dyd.xml diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java index a2c1bdb06..45b1d527c 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java @@ -22,6 +22,7 @@ import com.powsybl.dynawaltz.models.hvdc.HvdcVscBuilder; import com.powsybl.dynawaltz.models.lines.LineBuilder; import com.powsybl.dynawaltz.models.loads.*; +import com.powsybl.dynawaltz.models.shunts.ShuntBuilder; import com.powsybl.dynawaltz.models.svarcs.BaseStaticVarCompensatorBuilder; import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; @@ -54,6 +55,7 @@ public final class ModelConfigLoaderImpl implements ModelConfigLoader { new BuilderConfig(LoadOneTransformerTapChangerBuilder::of, LoadOneTransformerTapChangerBuilder::getSupportedLibs), new BuilderConfig(LoadTwoTransformersBuilder::of, LoadTwoTransformersBuilder::getSupportedLibs), new BuilderConfig(LoadTwoTransformersTapChangersBuilder::of, LoadTwoTransformersTapChangersBuilder::getSupportedLibs), + new BuilderConfig(ShuntBuilder::of, ShuntBuilder::getSupportedLibs), new BuilderConfig(BaseStaticVarCompensatorBuilder::of, BaseStaticVarCompensatorBuilder::getSupportedLibs), new BuilderConfig(GeneratorFictitiousBuilder::of, GeneratorFictitiousBuilder::getSupportedLibs), new BuilderConfig(SynchronizedGeneratorBuilder::of, SynchronizedGeneratorBuilder::getSupportedLibs), diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShunt.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShunt.java new file mode 100644 index 000000000..bef1810db --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShunt.java @@ -0,0 +1,55 @@ +/** + * 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.shunts; + +import com.powsybl.dynawaltz.models.AbstractEquipmentBlackBoxModel; +import com.powsybl.dynawaltz.models.VarConnection; +import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; +import com.powsybl.dynawaltz.models.macroconnections.MacroConnectionsAdder; +import com.powsybl.iidm.network.ShuntCompensator; + +import java.util.List; + +/** + * @author Laurent Issertial {@literal } + */ +public class BaseShunt extends AbstractEquipmentBlackBoxModel implements ShuntModel { + + protected BaseShunt(String dynamicModelId, ShuntCompensator svarc, String parameterSetId, String lib) { + super(dynamicModelId, parameterSetId, svarc, lib); + } + + @Override + public void createMacroConnections(MacroConnectionsAdder adder) { + adder.createTerminalMacroConnections(this, equipment.getTerminal(), this::getVarConnectionsWith); + } + + private List getVarConnectionsWith(EquipmentConnectionPoint connected) { + return List.of(new VarConnection("shunt_terminal", connected.getTerminalVarName())); + } + + @Override + public String getSwitchOffSignalEventVarName() { + return "shunt_switchOffSignal2"; + } + + @Override + public String getStateVarName() { + return "shunt_state"; + } + + @Override + public String getIsCapacitorVarName() { + return "shunt_isCapacitor"; + } + + @Override + public String getIsAvailableVarName() { + return "shunt_isAvailable"; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java new file mode 100644 index 000000000..97f247862 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java @@ -0,0 +1,69 @@ +/** + * 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.shunts; + +import com.powsybl.commons.report.ReportNode; +import com.powsybl.dynawaltz.builders.*; +import com.powsybl.iidm.network.IdentifiableType; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.ShuntCompensator; + +import java.util.Set; + +/** + * @author Laurent Issertial {@literal } + */ +public class BaseShuntBuilder extends AbstractEquipmentModelBuilder { + + private static final String CATEGORY = "BASE_SHUNT"; + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + + public static BaseShuntBuilder of(Network network) { + return of(network, ReportNode.NO_OP); + } + + public static BaseShuntBuilder of(Network network, ReportNode reportNode) { + return new BaseShuntBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reportNode); + } + + public static BaseShuntBuilder of(Network network, String lib) { + return of(network, lib, ReportNode.NO_OP); + } + + public static BaseShuntBuilder of(Network network, String lib, ReportNode reportNode) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); + if (modelConfig == null) { + BuilderReports.reportLibNotFound(reportNode, BaseShuntBuilder.class.getSimpleName(), lib); + return null; + } + return new BaseShuntBuilder(network, modelConfig, reportNode); + } + + public static Set getSupportedLibs() { + return MODEL_CONFIGS.getSupportedLibs(); + } + + protected BaseShuntBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { + super(network, modelConfig, IdentifiableType.STATIC_VAR_COMPENSATOR, reportNode); + } + + @Override + protected ShuntCompensator findEquipment(String staticId) { + return network.getShuntCompensator(staticId); + } + + @Override + public BaseShunt build() { + return isInstantiable() ? new BaseShunt(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib()) : null; + } + + @Override + protected BaseShuntBuilder self() { + return this; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntBuilder.java new file mode 100644 index 000000000..4bd172846 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntBuilder.java @@ -0,0 +1,69 @@ +/** + * 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.shunts; + +import com.powsybl.commons.report.ReportNode; +import com.powsybl.dynawaltz.builders.*; +import com.powsybl.iidm.network.IdentifiableType; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.ShuntCompensator; + +import java.util.Set; + +/** + * @author Laurent Issertial {@literal } + */ +public class ShuntBuilder extends AbstractEquipmentModelBuilder { + + public static final String CATEGORY = "BASE_SHUNT"; + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + + public static ShuntBuilder of(Network network) { + return of(network, ReportNode.NO_OP); + } + + public static ShuntBuilder of(Network network, ReportNode reportNode) { + return new ShuntBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reportNode); + } + + public static ShuntBuilder of(Network network, String lib) { + return of(network, lib, ReportNode.NO_OP); + } + + public static ShuntBuilder of(Network network, String lib, ReportNode reportNode) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); + if (modelConfig == null) { + BuilderReports.reportLibNotFound(reportNode, ShuntBuilder.class.getSimpleName(), lib); + return null; + } + return new ShuntBuilder(network, modelConfig, reportNode); + } + + public static Set getSupportedLibs() { + return MODEL_CONFIGS.getSupportedLibs(); + } + + protected ShuntBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { + super(network, modelConfig, IdentifiableType.SHUNT_COMPENSATOR, reportNode); + } + + @Override + protected ShuntCompensator findEquipment(String staticId) { + return network.getShuntCompensator(staticId); + } + + @Override + public BaseShunt build() { + return isInstantiable() ? new BaseShunt(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib()) : null; + } + + @Override + protected ShuntBuilder self() { + return this; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntModel.java index bf816bccc..87f33d71f 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntModel.java @@ -13,6 +13,7 @@ * @author Laurent Issertial {@literal } */ public interface ShuntModel extends InjectionModel { + String getStateVarName(); String getIsCapacitorVarName(); diff --git a/dynawaltz/src/main/resources/models.json b/dynawaltz/src/main/resources/models.json index 145fb6eaa..adc864e1d 100644 --- a/dynawaltz/src/main/resources/models.json +++ b/dynawaltz/src/main/resources/models.json @@ -424,6 +424,17 @@ } ] }, + "BASE_SHUNT": { + "defaultLib": "ShuntB", + "libs": [ + { + "lib": "ShuntB" + }, + { + "lib": "ShuntBWithSections" + } + ] + }, "staticVarCompensators": { "defaultLib": "StaticVarCompensator", "libs": [ diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java index 0699124df..a1f44d08d 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java @@ -21,6 +21,7 @@ import com.powsybl.dynawaltz.models.hvdc.HvdcVscBuilder; import com.powsybl.dynawaltz.models.lines.LineBuilder; import com.powsybl.dynawaltz.models.loads.*; +import com.powsybl.dynawaltz.models.shunts.ShuntBuilder; import com.powsybl.dynawaltz.models.svarcs.BaseStaticVarCompensatorBuilder; import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; import com.powsybl.iidm.network.Network; @@ -71,6 +72,8 @@ void testDefaultLibEquipments() { // HVDC assertNotNull(HvdcPBuilder.of(NETWORK)); assertNotNull(HvdcVscBuilder.of(NETWORK)); + // Shunt + assertNotNull(ShuntBuilder.of(NETWORK)); // Static var comp assertNotNull(BaseStaticVarCompensatorBuilder.of(NETWORK)); } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.java new file mode 100644 index 000000000..bcf5c2c42 --- /dev/null +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.java @@ -0,0 +1,42 @@ +/** + * 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.xml; + +import com.powsybl.dynawaltz.models.shunts.BaseShuntBuilder; +import com.powsybl.iidm.network.test.ShuntTestCaseFactory; +import org.junit.jupiter.api.Test; +import org.xml.sax.SAXException; + +import javax.xml.stream.XMLStreamException; +import java.io.IOException; + +/** + * @author Laurent Issertial {@literal } + */ +class ShuntModelXmlTest extends AbstractDynamicModelXmlTest { + + @Override + protected void setupNetwork() { + network = ShuntTestCaseFactory.create(); + } + + @Override + protected void addDynamicModels() { + dynamicModels.add(BaseShuntBuilder.of(network) + .dynamicModelId("BBM_SHUNT") + .staticId("SHUNT") + .parameterSetId("sh") + .build()); + } + + @Test + void writeModel() throws SAXException, IOException, XMLStreamException { + DydXml.write(tmpDir, context); + validate("dyd.xsd", "shunt_dyd.xml", tmpDir.resolve(DynaWaltzConstants.DYD_FILENAME)); + } +} diff --git a/dynawaltz/src/test/resources/shunt_dyd.xml b/dynawaltz/src/test/resources/shunt_dyd.xml new file mode 100644 index 000000000..09865d333 --- /dev/null +++ b/dynawaltz/src/test/resources/shunt_dyd.xml @@ -0,0 +1,8 @@ + + + + + + + + From e2dfb75fde4eaf0fbedd1406fbcbc6e68beec40d Mon Sep 17 00:00:00 2001 From: lisrte Date: Thu, 27 Jun 2024 13:20:00 +0200 Subject: [PATCH 2/3] Add test coverage Signed-off-by: lisrte --- .../builders/ModelConfigLoaderImpl.java | 4 +- .../dynawaltz/models/shunts/ShuntBuilder.java | 69 ------------------- .../builders/DefaultLibBuilderTest.java | 46 ++++++++++++- .../dynawaltz/xml/DisconnectEventXmlTest.java | 6 ++ .../dynawaltz/xml/ShuntModelXmlTest.java | 2 +- .../src/test/resources/disconnect_dyd.xml | 13 ++-- 6 files changed, 62 insertions(+), 78 deletions(-) delete mode 100644 dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntBuilder.java diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java index 45b1d527c..5dc10119b 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java @@ -22,7 +22,7 @@ import com.powsybl.dynawaltz.models.hvdc.HvdcVscBuilder; import com.powsybl.dynawaltz.models.lines.LineBuilder; import com.powsybl.dynawaltz.models.loads.*; -import com.powsybl.dynawaltz.models.shunts.ShuntBuilder; +import com.powsybl.dynawaltz.models.shunts.BaseShuntBuilder; import com.powsybl.dynawaltz.models.svarcs.BaseStaticVarCompensatorBuilder; import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; @@ -55,7 +55,7 @@ public final class ModelConfigLoaderImpl implements ModelConfigLoader { new BuilderConfig(LoadOneTransformerTapChangerBuilder::of, LoadOneTransformerTapChangerBuilder::getSupportedLibs), new BuilderConfig(LoadTwoTransformersBuilder::of, LoadTwoTransformersBuilder::getSupportedLibs), new BuilderConfig(LoadTwoTransformersTapChangersBuilder::of, LoadTwoTransformersTapChangersBuilder::getSupportedLibs), - new BuilderConfig(ShuntBuilder::of, ShuntBuilder::getSupportedLibs), + new BuilderConfig(BaseShuntBuilder::of, BaseShuntBuilder::getSupportedLibs), new BuilderConfig(BaseStaticVarCompensatorBuilder::of, BaseStaticVarCompensatorBuilder::getSupportedLibs), new BuilderConfig(GeneratorFictitiousBuilder::of, GeneratorFictitiousBuilder::getSupportedLibs), new BuilderConfig(SynchronizedGeneratorBuilder::of, SynchronizedGeneratorBuilder::getSupportedLibs), diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntBuilder.java deleted file mode 100644 index 4bd172846..000000000 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/ShuntBuilder.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * 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.shunts; - -import com.powsybl.commons.report.ReportNode; -import com.powsybl.dynawaltz.builders.*; -import com.powsybl.iidm.network.IdentifiableType; -import com.powsybl.iidm.network.Network; -import com.powsybl.iidm.network.ShuntCompensator; - -import java.util.Set; - -/** - * @author Laurent Issertial {@literal } - */ -public class ShuntBuilder extends AbstractEquipmentModelBuilder { - - public static final String CATEGORY = "BASE_SHUNT"; - private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); - - public static ShuntBuilder of(Network network) { - return of(network, ReportNode.NO_OP); - } - - public static ShuntBuilder of(Network network, ReportNode reportNode) { - return new ShuntBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reportNode); - } - - public static ShuntBuilder of(Network network, String lib) { - return of(network, lib, ReportNode.NO_OP); - } - - public static ShuntBuilder of(Network network, String lib, ReportNode reportNode) { - ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); - if (modelConfig == null) { - BuilderReports.reportLibNotFound(reportNode, ShuntBuilder.class.getSimpleName(), lib); - return null; - } - return new ShuntBuilder(network, modelConfig, reportNode); - } - - public static Set getSupportedLibs() { - return MODEL_CONFIGS.getSupportedLibs(); - } - - protected ShuntBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { - super(network, modelConfig, IdentifiableType.SHUNT_COMPENSATOR, reportNode); - } - - @Override - protected ShuntCompensator findEquipment(String staticId) { - return network.getShuntCompensator(staticId); - } - - @Override - public BaseShunt build() { - return isInstantiable() ? new BaseShunt(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib()) : null; - } - - @Override - protected ShuntBuilder self() { - return this; - } -} diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java index a1f44d08d..5294978c8 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java @@ -21,7 +21,7 @@ import com.powsybl.dynawaltz.models.hvdc.HvdcVscBuilder; import com.powsybl.dynawaltz.models.lines.LineBuilder; import com.powsybl.dynawaltz.models.loads.*; -import com.powsybl.dynawaltz.models.shunts.ShuntBuilder; +import com.powsybl.dynawaltz.models.shunts.BaseShuntBuilder; import com.powsybl.dynawaltz.models.svarcs.BaseStaticVarCompensatorBuilder; import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; import com.powsybl.iidm.network.Network; @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * @author Laurent Issertial {@literal } @@ -36,6 +37,7 @@ class DefaultLibBuilderTest { private static final Network NETWORK = SvcTestCaseFactory.create(); + private static final String WRONG_LIB = "wrongLib"; @Test void testDefaultLibAutomatons() { @@ -73,9 +75,49 @@ void testDefaultLibEquipments() { assertNotNull(HvdcPBuilder.of(NETWORK)); assertNotNull(HvdcVscBuilder.of(NETWORK)); // Shunt - assertNotNull(ShuntBuilder.of(NETWORK)); + assertNotNull(BaseShuntBuilder.of(NETWORK)); // Static var comp assertNotNull(BaseStaticVarCompensatorBuilder.of(NETWORK)); } + @Test + void testWrongLibAutomatons() { + assertNull(UnderVoltageAutomationSystemBuilder.of(NETWORK, WRONG_LIB)); + assertNull(TapChangerBlockingAutomationSystemBuilder.of(NETWORK, WRONG_LIB)); + assertNull(TapChangerAutomationSystemBuilder.of(NETWORK, WRONG_LIB)); + assertNull(DynamicOverloadManagementSystemBuilder.of(NETWORK, WRONG_LIB)); + assertNull(DynamicTwoLevelsOverloadManagementSystemBuilder.of(NETWORK, WRONG_LIB)); + assertNull(PhaseShifterIAutomationSystemBuilder.of(NETWORK, WRONG_LIB)); + assertNull(PhaseShifterPAutomationSystemBuilder.of(NETWORK, WRONG_LIB)); + } + + @Test + void testWrongLibEquipments() { + // Load + assertNull(BaseLoadBuilder.of(NETWORK, WRONG_LIB)); + assertNull(LoadOneTransformerBuilder.of(NETWORK, WRONG_LIB)); + assertNull(LoadOneTransformerTapChangerBuilder.of(NETWORK, WRONG_LIB)); + assertNull(LoadTwoTransformersBuilder.of(NETWORK, WRONG_LIB)); + assertNull(LoadTwoTransformersTapChangersBuilder.of(NETWORK, WRONG_LIB)); + // Bus + assertNull(StandardBusBuilder.of(NETWORK, WRONG_LIB)); + assertNull(InfiniteBusBuilder.of(NETWORK, WRONG_LIB)); + // Transformer + assertNull(TransformerFixedRatioBuilder.of(NETWORK, WRONG_LIB)); + // Line + assertNull(LineBuilder.of(NETWORK, WRONG_LIB)); + // Generator + assertNull(GeneratorFictitiousBuilder.of(NETWORK, WRONG_LIB)); + assertNull(SynchronizedGeneratorBuilder.of(NETWORK, WRONG_LIB)); + assertNull(SynchronousGeneratorBuilder.of(NETWORK, WRONG_LIB)); + assertNull(WeccBuilder.of(NETWORK, WRONG_LIB)); + assertNull(GridFormingConverterBuilder.of(NETWORK, WRONG_LIB)); + // HVDC + assertNull(HvdcPBuilder.of(NETWORK, WRONG_LIB)); + assertNull(HvdcVscBuilder.of(NETWORK, WRONG_LIB)); + // Shunt + assertNull(BaseShuntBuilder.of(NETWORK, WRONG_LIB)); + // Static var comp + assertNull(BaseStaticVarCompensatorBuilder.of(NETWORK, WRONG_LIB)); + } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectEventXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectEventXmlTest.java index 35f6e961a..a5a5dd348 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectEventXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectEventXmlTest.java @@ -9,6 +9,7 @@ import com.powsybl.dynawaltz.models.events.EventDisconnectionBuilder; import com.powsybl.dynawaltz.models.generators.GeneratorFictitiousBuilder; +import com.powsybl.dynawaltz.models.shunts.BaseShuntBuilder; import com.powsybl.iidm.network.Bus; import com.powsybl.iidm.network.VoltageLevel; import com.powsybl.iidm.network.test.SvcTestCaseFactory; @@ -46,6 +47,11 @@ protected void addDynamicModels() { .staticId("G1") .parameterSetId("GF") .build()); + dynamicModels.add(BaseShuntBuilder.of(network) + .dynamicModelId("BBM_SHUNT") + .staticId("SH1") + .parameterSetId("BS") + .build()); eventModels.add(EventDisconnectionBuilder.of(network) .staticId("G1") .startTime(1) diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.java index bcf5c2c42..72d52e489 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/ShuntModelXmlTest.java @@ -27,7 +27,7 @@ protected void setupNetwork() { @Override protected void addDynamicModels() { - dynamicModels.add(BaseShuntBuilder.of(network) + dynamicModels.add(BaseShuntBuilder.of(network, "ShuntB") .dynamicModelId("BBM_SHUNT") .staticId("SHUNT") .parameterSetId("sh") diff --git a/dynawaltz/src/test/resources/disconnect_dyd.xml b/dynawaltz/src/test/resources/disconnect_dyd.xml index 5daadbbf6..b82fe3c27 100644 --- a/dynawaltz/src/test/resources/disconnect_dyd.xml +++ b/dynawaltz/src/test/resources/disconnect_dyd.xml @@ -3,14 +3,18 @@ + - + + + + @@ -20,8 +24,8 @@ - - + + @@ -29,8 +33,9 @@ + - + From 3556a20d0f11801b54fb39dbdf16c0e298722f16 Mon Sep 17 00:00:00 2001 From: lisrte Date: Thu, 27 Jun 2024 13:30:55 +0200 Subject: [PATCH 3/3] Fix merge Add documentation Signed-off-by: lisrte --- docs/dynamic_simulation/dynamic-models-dsl.md | 1 + .../com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/dynamic_simulation/dynamic-models-dsl.md b/docs/dynamic_simulation/dynamic-models-dsl.md index 505219171..1b4a0ba8a 100644 --- a/docs/dynamic_simulation/dynamic-models-dsl.md +++ b/docs/dynamic_simulation/dynamic-models-dsl.md @@ -68,6 +68,7 @@ The list is statically loaded via [ModelConfigLoader](https://javadoc.io/doc/com Ultimately, all groovy scripts call dedicated builders that can be used directly by developers. ### Equipments * BaseStaticVarCompensatorBuilder +* BaseShuntBuilder * HvdcPBuilder * HvdcVscBuilder * GeneratorFictitiousBuilder diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java index 97f247862..707062186 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/shunts/BaseShuntBuilder.java @@ -20,7 +20,7 @@ */ public class BaseShuntBuilder extends AbstractEquipmentModelBuilder { - private static final String CATEGORY = "BASE_SHUNT"; + public static final String CATEGORY = "BASE_SHUNT"; private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static BaseShuntBuilder of(Network network) { @@ -49,7 +49,7 @@ public static Set getSupportedLibs() { } protected BaseShuntBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { - super(network, modelConfig, IdentifiableType.STATIC_VAR_COMPENSATOR, reportNode); + super(network, modelConfig, IdentifiableType.SHUNT_COMPENSATOR, reportNode); } @Override