From 46ba0d20ec1d531d67224c2f1966eb9d4c4fee69 Mon Sep 17 00:00:00 2001 From: lisrte Date: Fri, 4 Oct 2024 17:20:43 +0200 Subject: [PATCH] Move model GeneratorPVFixed from synchronized generator to base generator Rename GeneratorFictitiousBuilder to BaseGeneratorBuilder Update documentation Signed-off-by: lisrte --- docs/dynamic_simulation/dynamic-models-dsl.md | 2 +- .../builders/ModelConfigLoaderImpl.java | 2 +- ...Builder.java => BaseGeneratorBuilder.java} | 20 ++++----- .../src/main/resources/models.json | 6 +-- .../powsybl/dynawo/ModelsSimplifierTest.java | 6 +-- .../powsybl/dynawo/builders/BuildersTest.java | 4 +- .../dynawo/xml/BaseGeneratorModelXmlTest.java | 41 +++++++++++++++++++ .../dynawo/xml/DisconnectEventXmlTest.java | 4 +- .../dynawo/xml/DynamicModelsXmlTest.java | 4 +- .../powsybl/dynawo/xml/DynawoTestUtil.java | 4 +- .../src/test/resources/generator_dyd.xml | 16 ++++++++ 11 files changed, 83 insertions(+), 26 deletions(-) rename dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/{GeneratorFictitiousBuilder.java => BaseGeneratorBuilder.java} (65%) create mode 100644 dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/BaseGeneratorModelXmlTest.java create mode 100644 dynawo-simulation/src/test/resources/generator_dyd.xml diff --git a/docs/dynamic_simulation/dynamic-models-dsl.md b/docs/dynamic_simulation/dynamic-models-dsl.md index 1015bad37..c588245f6 100644 --- a/docs/dynamic_simulation/dynamic-models-dsl.md +++ b/docs/dynamic_simulation/dynamic-models-dsl.md @@ -75,7 +75,7 @@ Ultimately, all groovy scripts call dedicated builders that can be used directly * BaseShuntBuilder * HvdcPBuilder * HvdcVscBuilder -* GeneratorFictitiousBuilder +* BaseGeneratorBuilder * SignalNGeneratorBuilder * SynchronizedGeneratorBuilder * SynchronousGeneratorBuilder diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/builders/ModelConfigLoaderImpl.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/builders/ModelConfigLoaderImpl.java index 9d589b4a2..a1b326259 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/builders/ModelConfigLoaderImpl.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/builders/ModelConfigLoaderImpl.java @@ -62,7 +62,7 @@ public final class ModelConfigLoaderImpl implements ModelConfigLoader { new BuilderConfig(LoadTwoTransformersTapChangersBuilder.CATEGORY, LoadTwoTransformersTapChangersBuilder::of, LoadTwoTransformersTapChangersBuilder::getSupportedModelInfos), new BuilderConfig(BaseShuntBuilder.CATEGORY, BaseShuntBuilder::of, BaseShuntBuilder::getSupportedModelInfos), new BuilderConfig(BaseStaticVarCompensatorBuilder.CATEGORY, BaseStaticVarCompensatorBuilder::of, BaseStaticVarCompensatorBuilder::getSupportedModelInfos), - new BuilderConfig(GeneratorFictitiousBuilder.CATEGORY, GeneratorFictitiousBuilder::of, GeneratorFictitiousBuilder::getSupportedModelInfos), + new BuilderConfig(BaseGeneratorBuilder.CATEGORY, BaseGeneratorBuilder::of, BaseGeneratorBuilder::getSupportedModelInfos), new BuilderConfig(SynchronizedGeneratorBuilder.CATEGORY, SynchronizedGeneratorBuilder::of, SynchronizedGeneratorBuilder::getSupportedModelInfos), new BuilderConfig(SynchronousGeneratorBuilder.CATEGORY, SynchronousGeneratorBuilder::of, SynchronousGeneratorBuilder::getSupportedModelInfos), new BuilderConfig(WeccBuilder.CATEGORY, WeccBuilder::of, WeccBuilder::getSupportedModelInfos), diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/GeneratorFictitiousBuilder.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/BaseGeneratorBuilder.java similarity index 65% rename from dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/GeneratorFictitiousBuilder.java rename to dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/BaseGeneratorBuilder.java index f9964d092..2d1029f83 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/GeneratorFictitiousBuilder.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/BaseGeneratorBuilder.java @@ -17,30 +17,30 @@ /** * @author Laurent Issertial {@literal } */ -public class GeneratorFictitiousBuilder extends AbstractGeneratorBuilder { +public class BaseGeneratorBuilder extends AbstractGeneratorBuilder { public static final String CATEGORY = "BASE_GENERATOR"; private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); - public static GeneratorFictitiousBuilder of(Network network) { + public static BaseGeneratorBuilder of(Network network) { return of(network, ReportNode.NO_OP); } - public static GeneratorFictitiousBuilder of(Network network, ReportNode reportNode) { - return new GeneratorFictitiousBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reportNode); + public static BaseGeneratorBuilder of(Network network, ReportNode reportNode) { + return new BaseGeneratorBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reportNode); } - public static GeneratorFictitiousBuilder of(Network network, String modelName) { + public static BaseGeneratorBuilder of(Network network, String modelName) { return of(network, modelName, ReportNode.NO_OP); } - public static GeneratorFictitiousBuilder of(Network network, String modelName, ReportNode reportNode) { + public static BaseGeneratorBuilder of(Network network, String modelName, ReportNode reportNode) { ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(modelName); if (modelConfig == null) { - BuilderReports.reportModelNotFound(reportNode, GeneratorFictitiousBuilder.class.getSimpleName(), modelName); + BuilderReports.reportModelNotFound(reportNode, BaseGeneratorBuilder.class.getSimpleName(), modelName); return null; } - return new GeneratorFictitiousBuilder(network, modelConfig, reportNode); + return new BaseGeneratorBuilder(network, modelConfig, reportNode); } public static Collection getSupportedModelInfos() { @@ -54,7 +54,7 @@ public static Collection getSupportedModelInfos(DynawoVersion dynawoV return MODEL_CONFIGS.getModelInfos(dynawoVersion); } - protected GeneratorFictitiousBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { + protected BaseGeneratorBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) { super(network, modelConfig, reportNode); } @@ -64,7 +64,7 @@ public BaseGenerator build() { } @Override - protected GeneratorFictitiousBuilder self() { + protected BaseGeneratorBuilder self() { return this; } } diff --git a/dynawo-simulation/src/main/resources/models.json b/dynawo-simulation/src/main/resources/models.json index e779f4980..8ce5597d7 100644 --- a/dynawo-simulation/src/main/resources/models.json +++ b/dynawo-simulation/src/main/resources/models.json @@ -5,6 +5,9 @@ { "lib": "GeneratorFictitious", "doc": "Fictitious generator (behaves in a similar way as an alpha-beta load)" + }, + { + "lib": "GeneratorPVFixed" } ] }, @@ -232,9 +235,6 @@ ], "doc": "Generator with fixed active power and voltage targets. The reactive power output changes over time in order to follow the voltage target (when it is not possible to do so, the reactive power is set to the minimum or maximum value). The active power outputs may vary in order to mimic frequency regulation" }, - { - "lib": "GeneratorPVFixed" - }, { "lib": "GeneratorPVDiagramPQ" } diff --git a/dynawo-simulation/src/test/java/com/powsybl/dynawo/ModelsSimplifierTest.java b/dynawo-simulation/src/test/java/com/powsybl/dynawo/ModelsSimplifierTest.java index f3792e7f4..acf9dfaea 100644 --- a/dynawo-simulation/src/test/java/com/powsybl/dynawo/ModelsSimplifierTest.java +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/ModelsSimplifierTest.java @@ -12,7 +12,7 @@ import com.powsybl.commons.report.ReportNode; import com.powsybl.dynamicsimulation.DynamicSimulationParameters; import com.powsybl.dynawo.models.generators.BaseGenerator; -import com.powsybl.dynawo.models.generators.GeneratorFictitiousBuilder; +import com.powsybl.dynawo.models.generators.BaseGeneratorBuilder; import com.powsybl.dynawo.models.loads.BaseLoadBuilder; import com.powsybl.dynawo.models.transformers.TransformerFixedRatioBuilder; import com.powsybl.dynawo.models.BlackBoxModel; @@ -51,7 +51,7 @@ void simplifyModels() { DynamicSimulationParameters parameters = DynamicSimulationParameters.load(); DynawoSimulationParameters dynawoParameters = DynawoSimulationParameters.load().setUseModelSimplifiers(true); List dynamicModels = List.of( - GeneratorFictitiousBuilder.of(network) + BaseGeneratorBuilder.of(network) .dynamicModelId("BBM_GEN") .staticId("GEN") .parameterSetId("GPV") @@ -86,7 +86,7 @@ public static class ModelsSimplifierSubstitution implements ModelsSubstitutionSi public Function getModelSubstitutionFunction(Network network, DynawoSimulationParameters dynawoSimulationParameters, ReportNode reportNode) { return m -> { if ("BBM_GEN".equalsIgnoreCase(m.getDynamicModelId()) && m instanceof BaseGenerator gen) { - return GeneratorFictitiousBuilder.of(network) + return BaseGeneratorBuilder.of(network) .dynamicModelId("newModel") .staticId(gen.getStaticId()) .parameterSetId("G") diff --git a/dynawo-simulation/src/test/java/com/powsybl/dynawo/builders/BuildersTest.java b/dynawo-simulation/src/test/java/com/powsybl/dynawo/builders/BuildersTest.java index 0ad09892b..be1992b04 100644 --- a/dynawo-simulation/src/test/java/com/powsybl/dynawo/builders/BuildersTest.java +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/builders/BuildersTest.java @@ -68,7 +68,7 @@ void testDefaultLibEquipments() { // Line assertNotNull(LineBuilder.of(NETWORK)); // Generator - assertNotNull(GeneratorFictitiousBuilder.of(NETWORK)); + assertNotNull(BaseGeneratorBuilder.of(NETWORK)); assertNotNull(SynchronizedGeneratorBuilder.of(NETWORK)); assertNotNull(SynchronousGeneratorBuilder.of(NETWORK)); assertNotNull(WeccBuilder.of(NETWORK)); @@ -110,7 +110,7 @@ void testWrongLibEquipments() { // Line assertNull(LineBuilder.of(NETWORK, WRONG_LIB)); // Generator - assertNull(GeneratorFictitiousBuilder.of(NETWORK, WRONG_LIB)); + assertNull(BaseGeneratorBuilder.of(NETWORK, WRONG_LIB)); assertNull(SynchronizedGeneratorBuilder.of(NETWORK, WRONG_LIB)); assertNull(SynchronousGeneratorBuilder.of(NETWORK, WRONG_LIB)); assertNull(WeccBuilder.of(NETWORK, WRONG_LIB)); diff --git a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/BaseGeneratorModelXmlTest.java b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/BaseGeneratorModelXmlTest.java new file mode 100644 index 000000000..3443a34c7 --- /dev/null +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/BaseGeneratorModelXmlTest.java @@ -0,0 +1,41 @@ +/** + * 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.xml; + +import com.powsybl.dynawo.models.generators.BaseGeneratorBuilder; +import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; +import org.junit.jupiter.api.Test; +import org.xml.sax.SAXException; + +import java.io.IOException; + +/** + * @author Laurent Issertial {@literal } + */ +class BaseGeneratorModelXmlTest extends AbstractDynamicModelXmlTest { + + @Override + protected void setupNetwork() { + network = EurostagTutorialExample1Factory.create(); + } + + @Override + protected void addDynamicModels() { + dynamicModels.add(BaseGeneratorBuilder.of(network, "GeneratorPVFixed") + .dynamicModelId("BBM_GEN") + .staticId("GEN") + .parameterSetId("g") + .build()); + } + + @Test + void writeModel() throws SAXException, IOException { + DydXml.write(tmpDir, context); + validate("dyd.xsd", "generator_dyd.xml", tmpDir.resolve(DynawoSimulationConstants.DYD_FILENAME)); + } +} diff --git a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DisconnectEventXmlTest.java b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DisconnectEventXmlTest.java index b50bd6614..0f3051068 100644 --- a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DisconnectEventXmlTest.java +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DisconnectEventXmlTest.java @@ -8,7 +8,7 @@ package com.powsybl.dynawo.xml; import com.powsybl.dynawo.models.events.EventDisconnectionBuilder; -import com.powsybl.dynawo.models.generators.GeneratorFictitiousBuilder; +import com.powsybl.dynawo.models.generators.BaseGeneratorBuilder; import com.powsybl.dynawo.models.shunts.BaseShuntBuilder; import com.powsybl.iidm.network.Bus; import com.powsybl.iidm.network.VoltageLevel; @@ -42,7 +42,7 @@ protected void setupNetwork() { @Override protected void addDynamicModels() { - dynamicModels.add(GeneratorFictitiousBuilder.of(network) + dynamicModels.add(BaseGeneratorBuilder.of(network) .dynamicModelId("BBM_GEN") .staticId("G1") .parameterSetId("GF") diff --git a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DynamicModelsXmlTest.java b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DynamicModelsXmlTest.java index fb3b85350..02a601bd9 100644 --- a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DynamicModelsXmlTest.java +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DynamicModelsXmlTest.java @@ -12,7 +12,7 @@ import com.powsybl.dynawo.DynawoSimulationContext; import com.powsybl.dynawo.DynawoSimulationParameters; import com.powsybl.dynawo.commons.DynawoVersion; -import com.powsybl.dynawo.models.generators.GeneratorFictitiousBuilder; +import com.powsybl.dynawo.models.generators.BaseGeneratorBuilder; import com.powsybl.dynawo.models.lines.LineModel; import com.powsybl.dynawo.models.loads.BaseLoad; import com.powsybl.dynawo.models.loads.BaseLoadBuilder; @@ -48,7 +48,7 @@ void writeDynamicModelWithLoadsAndOnlyOneFictitiousGenerator() throws SAXExcepti DynamicSimulationParameters parameters = DynamicSimulationParameters.load(); DynawoSimulationParameters dynawoParameters = DynawoSimulationParameters.load(); dynamicModels.clear(); - dynamicModels.add(GeneratorFictitiousBuilder.of(network) + dynamicModels.add(BaseGeneratorBuilder.of(network) .dynamicModelId("BBM_GEN6") .staticId("GEN6") .parameterSetId("GF") diff --git a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DynawoTestUtil.java b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DynawoTestUtil.java index 30e53581c..60864f20c 100644 --- a/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DynawoTestUtil.java +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/xml/DynawoTestUtil.java @@ -12,7 +12,7 @@ import com.powsybl.dynawo.models.BlackBoxModel; import com.powsybl.dynawo.models.automationsystems.overloadmanagments.DynamicOverloadManagementSystemBuilder; import com.powsybl.dynawo.models.events.EventDisconnectionBuilder; -import com.powsybl.dynawo.models.generators.GeneratorFictitiousBuilder; +import com.powsybl.dynawo.models.generators.BaseGeneratorBuilder; import com.powsybl.dynawo.models.generators.SynchronizedGeneratorBuilder; import com.powsybl.dynawo.models.generators.SynchronousGeneratorBuilder; import com.powsybl.dynawo.models.lines.LineBuilder; @@ -113,7 +113,7 @@ void setup() { .parameterSetId("GSTW") .build()); } else if (g.getId().equals("GEN6")) { - dynamicModels.add(GeneratorFictitiousBuilder.of(network) + dynamicModels.add(BaseGeneratorBuilder.of(network) .dynamicModelId("BBM_" + g.getId()) .staticId(g.getId()) .parameterSetId("GF") diff --git a/dynawo-simulation/src/test/resources/generator_dyd.xml b/dynawo-simulation/src/test/resources/generator_dyd.xml new file mode 100644 index 000000000..8d32a3166 --- /dev/null +++ b/dynawo-simulation/src/test/resources/generator_dyd.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +