Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Generator Inheritance #378

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static Stream<Arguments> 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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ default double getWeightGen(DynawoSimulationParameters dynawoSimulationParameter
return 0;
}

String getOmegaRefPuVarName();
default String getOmegaRefPuVarName() {
return "generator_omegaRefPu";
}

String getRunningVarName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
* @author Marcos de Miguel {@literal <demiguelm at aia.es>}
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public abstract class AbstractGenerator extends AbstractEquipmentBlackBoxModel<Generator> implements GeneratorModel {
public class BaseGenerator extends AbstractEquipmentBlackBoxModel<Generator> implements GeneratorModel {

protected static final List<VarMapping> 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);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @author Dimitri Baudrier {@literal <dimitri.baudrier at rte-france.com>}
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
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);
Expand All @@ -33,18 +33,6 @@ public List<VarConnection> getOmegaRefVarConnections() {
);
}

@Override
public List<VarConnection> getSetPointVarConnections() {
return List.of(
new VarConnection("setPoint_setPoint", getOmegaRefPuVarName())
);
}

@Override
public String getOmegaRefPuVarName() {
return "generator_omegaRefPu";
}

@Override
public Bus getConnectableBus() {
return BusUtils.getConnectableBus(equipment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +20,9 @@
/**
* @author Florian Dupuy {@literal <florian.dupuy at rte-france.com>}
*/
public class SynchronousGenerator extends SynchronizedGenerator {
public class SynchronousGenerator extends BaseGenerator implements FrequencySynchronizedModel {

private static final String OMEGA_PU_VAR_NAME = "generator_omegaPu";

private final EnumGeneratorComponent generatorComponent;

Expand All @@ -31,14 +36,10 @@ public String getTerminalVarName() {
return generatorComponent.getTerminalVarName();
}

public String getOmegaPuVarName() {
return "generator_omegaPu";
}

@Override
public List<VarConnection> getOmegaRefVarConnections() {
return Arrays.asList(
new VarConnection("omega_grp_@INDEX@", getOmegaPuVarName()),
new VarConnection("omega_grp_@INDEX@", OMEGA_PU_VAR_NAME),
new VarConnection("omegaRef_grp_@INDEX@", getOmegaRefPuVarName()),
new VarConnection("running_grp_@INDEX@", getRunningVarName())
);
Expand All @@ -50,4 +51,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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,7 +85,7 @@ public static class ModelsSimplifierSubstitution implements ModelsSubstitutionSi
@Override
public Function<BlackBoxModel, BlackBoxModel> 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())
Expand Down
Loading