diff --git a/dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/DynamicModelsSupplierTest.java b/dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/DynamicModelsSupplierTest.java index c83e3430d..48d51f139 100644 --- a/dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/DynamicModelsSupplierTest.java +++ b/dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/DynamicModelsSupplierTest.java @@ -130,7 +130,7 @@ private static Stream provideEquipmentModelData() { Arguments.of("/dynamicModels/loadTwoTransformersTapChangers.groovy", LoadTwoTransformersTapChangers.class, EurostagTutorialExample1Factory.create(), "LOAD", "LOAD", "LTT", "LoadTwoTransformersTapChangers"), Arguments.of("/dynamicModels/infiniteBus.groovy", InfiniteBus.class, HvdcTestNetwork.createVsc(), "B1", "BBM_BUS", "b", "InfiniteBusWithVariations"), Arguments.of("/dynamicModels/line.groovy", StandardLine.class, EurostagTutorialExample1Factory.create(), "NHV1_NHV2_1", "BBM_NHV1_NHV2_1", "LINE", "Line"), - Arguments.of("/dynamicModels/genFictitious.groovy", GeneratorFictitious.class, EurostagTutorialExample1Factory.create(), "GEN", "BBM_GEN", "GF", "GeneratorFictitious"), + Arguments.of("/dynamicModels/genFictitious.groovy", BaseGenerator.class, EurostagTutorialExample1Factory.create(), "GEN", "BBM_GEN", "GF", "GeneratorFictitious"), Arguments.of("/dynamicModels/gen.groovy", SynchronousGenerator.class, EurostagTutorialExample1Factory.create(), "GEN", "BBM_GEN", "GSFWPR", "GeneratorSynchronousThreeWindings"), Arguments.of("/dynamicModels/genControllable.groovy", SynchronousGeneratorControllable.class, EurostagTutorialExample1Factory.create(), "GEN", "BBM_GEN", "GSFWPR", "GeneratorSynchronousFourWindingsProportionalRegulations"), Arguments.of("/dynamicModels/omegaGen.groovy", SynchronizedGenerator.class, EurostagTutorialExample1Factory.create(), "GEN", "BBM_GEN", "GPQ", "GeneratorPQ"), diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/frequencysynchronizers/FrequencySynchronizedModel.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/frequencysynchronizers/FrequencySynchronizedModel.java index e90e6b3ce..aa87c8c81 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/frequencysynchronizers/FrequencySynchronizedModel.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/frequencysynchronizers/FrequencySynchronizedModel.java @@ -36,7 +36,9 @@ default double getWeightGen(DynawoSimulationParameters dynawoSimulationParameter return 0; } - String getOmegaRefPuVarName(); + default String getOmegaRefPuVarName() { + return "generator_omegaRefPu"; + } String getRunningVarName(); diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/AbstractGenerator.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/BaseGenerator.java similarity index 91% rename from dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/AbstractGenerator.java rename to dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/BaseGenerator.java index f7327ceb9..bc3976398 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/AbstractGenerator.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/BaseGenerator.java @@ -21,14 +21,14 @@ * @author Marcos de Miguel {@literal } * @author Laurent Issertial {@literal } */ -public abstract class AbstractGenerator extends AbstractEquipmentBlackBoxModel implements GeneratorModel { +public class BaseGenerator extends AbstractEquipmentBlackBoxModel implements GeneratorModel { protected static final List VAR_MAPPING = Arrays.asList( new VarMapping("generator_PGenPu", "p"), new VarMapping("generator_QGenPu", "q"), new VarMapping("generator_state", "state")); - protected AbstractGenerator(String dynamicModelId, Generator generator, String parameterSetId, String lib) { + protected BaseGenerator(String dynamicModelId, Generator generator, String parameterSetId, String lib) { super(dynamicModelId, parameterSetId, generator, lib); } diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/GeneratorFictitious.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/GeneratorFictitious.java deleted file mode 100644 index b9986e0b7..000000000 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/GeneratorFictitious.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2022, 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/. - */ -package com.powsybl.dynawo.models.generators; - -import com.powsybl.iidm.network.Generator; - -/** - * @author Dimitri Baudrier {@literal } - * @author Laurent Issertial {@literal } - */ -public class GeneratorFictitious extends AbstractGenerator { - - protected GeneratorFictitious(String dynamicModelId, Generator generator, String parameterSetId, String lib) { - super(dynamicModelId, generator, parameterSetId, lib); - } -} 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/GeneratorFictitiousBuilder.java index 63087e054..2359d048f 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/GeneratorFictitiousBuilder.java @@ -51,8 +51,8 @@ protected GeneratorFictitiousBuilder(Network network, ModelConfig modelConfig, R } @Override - public GeneratorFictitious build() { - return isInstantiable() ? new GeneratorFictitious(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib()) : null; + public BaseGenerator build() { + return isInstantiable() ? new BaseGenerator(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib()) : null; } @Override diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SignalNGenerator.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SignalNGenerator.java index 4ca5c2b07..a51c55a25 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SignalNGenerator.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SignalNGenerator.java @@ -15,7 +15,7 @@ /** * @author Laurent Issertial {@literal } */ -public class SignalNGenerator extends AbstractGenerator implements SignalNModel { +public class SignalNGenerator extends BaseGenerator implements SignalNModel { protected SignalNGenerator(String dynamicModelId, Generator generator, String parameterSetId, String lib) { super(dynamicModelId, generator, parameterSetId, lib); diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SynchronizedGenerator.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SynchronizedGenerator.java index 1d425c3e9..a18021dce 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SynchronizedGenerator.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SynchronizedGenerator.java @@ -19,7 +19,7 @@ * @author Dimitri Baudrier {@literal } * @author Laurent Issertial {@literal } */ -public class SynchronizedGenerator extends AbstractGenerator implements FrequencySynchronizedModel { +public class SynchronizedGenerator extends BaseGenerator implements FrequencySynchronizedModel { protected SynchronizedGenerator(String dynamicModelId, Generator generator, String parameterSetId, String generatorLib) { super(dynamicModelId, generator, parameterSetId, generatorLib); @@ -33,18 +33,6 @@ public List getOmegaRefVarConnections() { ); } - @Override - public List getSetPointVarConnections() { - return List.of( - new VarConnection("setPoint_setPoint", getOmegaRefPuVarName()) - ); - } - - @Override - public String getOmegaRefPuVarName() { - return "generator_omegaRefPu"; - } - @Override public Bus getConnectableBus() { return BusUtils.getConnectableBus(equipment); diff --git a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SynchronousGenerator.java b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SynchronousGenerator.java index e61d3f524..b1f37580c 100644 --- a/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SynchronousGenerator.java +++ b/dynawo-simulation/src/main/java/com/powsybl/dynawo/models/generators/SynchronousGenerator.java @@ -8,6 +8,9 @@ import com.powsybl.dynawo.DynawoSimulationParameters; 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.Generator; import java.util.Arrays; @@ -17,7 +20,7 @@ /** * @author Florian Dupuy {@literal } */ -public class SynchronousGenerator extends SynchronizedGenerator { +public class SynchronousGenerator extends BaseGenerator implements FrequencySynchronizedModel { private final EnumGeneratorComponent generatorComponent; @@ -31,7 +34,7 @@ public String getTerminalVarName() { return generatorComponent.getTerminalVarName(); } - public String getOmegaPuVarName() { + private String getOmegaPuVarName() { return "generator_omegaPu"; } @@ -50,4 +53,9 @@ public double getWeightGen(DynawoSimulationParameters dynawoSimulationParameters double sNom = dynawoSimulationParameters.getModelParameters(getParameterSetId()).getDouble("generator_SNom"); return h * sNom; } + + @Override + public Bus getConnectableBus() { + return BusUtils.getConnectableBus(equipment); + } } 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 85dd1509e..f3792e7f4 100644 --- a/dynawo-simulation/src/test/java/com/powsybl/dynawo/ModelsSimplifierTest.java +++ b/dynawo-simulation/src/test/java/com/powsybl/dynawo/ModelsSimplifierTest.java @@ -11,7 +11,7 @@ import com.google.common.collect.Lists; import com.powsybl.commons.report.ReportNode; import com.powsybl.dynamicsimulation.DynamicSimulationParameters; -import com.powsybl.dynawo.models.generators.AbstractGenerator; +import com.powsybl.dynawo.models.generators.BaseGenerator; import com.powsybl.dynawo.models.generators.GeneratorFictitiousBuilder; import com.powsybl.dynawo.models.loads.BaseLoadBuilder; import com.powsybl.dynawo.models.transformers.TransformerFixedRatioBuilder; @@ -85,7 +85,7 @@ public static class ModelsSimplifierSubstitution implements ModelsSubstitutionSi @Override public Function getModelSubstitutionFunction(Network network, DynawoSimulationParameters dynawoSimulationParameters, ReportNode reportNode) { return m -> { - if ("BBM_GEN".equalsIgnoreCase(m.getDynamicModelId()) && m instanceof AbstractGenerator gen) { + if ("BBM_GEN".equalsIgnoreCase(m.getDynamicModelId()) && m instanceof BaseGenerator gen) { return GeneratorFictitiousBuilder.of(network) .dynamicModelId("newModel") .staticId(gen.getStaticId())