Skip to content

Commit

Permalink
Add base generator model (#388)
Browse files Browse the repository at this point in the history
Move model GeneratorPVFixed from synchronized generator to base generator
Rename GeneratorFictitiousBuilder to BaseGeneratorBuilder
Update documentation

Signed-off-by: lisrte <[email protected]>
  • Loading branch information
Lisrte authored Oct 9, 2024
1 parent 8117594 commit 84c2f7f
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 28 deletions.
2 changes: 1 addition & 1 deletion docs/dynamic_simulation/dynamic-models-dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Ultimately, all groovy scripts call dedicated builders that can be used directly
* BaseShuntBuilder
* HvdcPBuilder
* HvdcVscBuilder
* GeneratorFictitiousBuilder
* BaseGeneratorBuilder
* SignalNGeneratorBuilder
* SynchronizedGeneratorBuilder
* SynchronousGeneratorBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public class GeneratorFictitiousBuilder extends AbstractGeneratorBuilder<GeneratorFictitiousBuilder> {
public class BaseGeneratorBuilder extends AbstractGeneratorBuilder<BaseGeneratorBuilder> {

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<ModelInfo> getSupportedModelInfos() {
Expand All @@ -54,7 +54,7 @@ public static Collection<ModelInfo> 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);
}

Expand All @@ -64,7 +64,7 @@ public BaseGenerator build() {
}

@Override
protected GeneratorFictitiousBuilder self() {
protected BaseGeneratorBuilder self() {
return this;
}
}
6 changes: 3 additions & 3 deletions dynawo-simulation/src/main/resources/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{
"lib": "GeneratorFictitious",
"doc": "Fictitious generator (behaves in a similar way as an alpha-beta load)"
},
{
"lib": "GeneratorPVFixed"
}
]
},
Expand Down Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +51,7 @@ void simplifyModels() {
DynamicSimulationParameters parameters = DynamicSimulationParameters.load();
DynawoSimulationParameters dynawoParameters = DynawoSimulationParameters.load().setUseModelSimplifiers(true);
List<BlackBoxModel> dynamicModels = List.of(
GeneratorFictitiousBuilder.of(network)
BaseGeneratorBuilder.of(network)
.dynamicModelId("BBM_GEN")
.staticId("GEN")
.parameterSetId("GPV")
Expand Down Expand Up @@ -86,7 +86,7 @@ public static class ModelsSimplifierSubstitution implements ModelsSubstitutionSi
public Function<BlackBoxModel, BlackBoxModel> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import com.powsybl.dynawo.models.buses.InfiniteBusBuilder;
import com.powsybl.dynawo.models.buses.StandardBusBuilder;
import com.powsybl.dynawo.models.generators.*;
import com.powsybl.dynawo.models.loads.*;
import com.powsybl.dynawo.models.hvdc.HvdcPBuilder;
import com.powsybl.dynawo.models.hvdc.HvdcVscBuilder;
import com.powsybl.dynawo.models.lines.LineBuilder;
import com.powsybl.dynawo.models.loads.*;
import com.powsybl.dynawo.models.shunts.BaseShuntBuilder;
import com.powsybl.dynawo.models.svarcs.BaseStaticVarCompensatorBuilder;
import com.powsybl.dynawo.models.transformers.TransformerFixedRatioBuilder;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -152,7 +152,7 @@ void testNotInstantiableEquipment() {
// Line
assertNull(LineBuilder.of(NETWORK).build());
// Generator
assertNull(GeneratorFictitiousBuilder.of(NETWORK).build());
assertNull(BaseGeneratorBuilder.of(NETWORK).build());
assertNull(SynchronizedGeneratorBuilder.of(NETWORK).build());
assertNull(SynchronousGeneratorBuilder.of(NETWORK).build());
assertNull(WeccBuilder.of(NETWORK).build());
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <laurent.issertial at rte-france.com>}
*/
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 16 additions & 0 deletions dynawo-simulation/src/test/resources/generator_dyd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<dyn:dynamicModelsArchitecture xmlns:dyn="http://www.rte-france.com/dynawo">
<dyn:blackBoxModel id="BBM_GEN" lib="GeneratorPVFixed" parFile="models.par" parId="g" staticId="GEN">
<dyn:macroStaticRef id="MSR_GeneratorPVFixed"/>
</dyn:blackBoxModel>
<dyn:macroConnector id="MC_GeneratorPVFixed-DefaultEquipmentConnectionPoint">
<dyn:connect var1="generator_terminal" var2="@STATIC_ID@@NODE@_ACPIN"/>
<dyn:connect var1="generator_switchOffSignal1" var2="@STATIC_ID@@NODE@_switchOff"/>
</dyn:macroConnector>
<dyn:macroStaticReference id="MSR_GeneratorPVFixed">
<dyn:staticRef var="generator_PGenPu" staticVar="p"/>
<dyn:staticRef var="generator_QGenPu" staticVar="q"/>
<dyn:staticRef var="generator_state" staticVar="state"/>
</dyn:macroStaticReference>
<dyn:macroConnect connector="MC_GeneratorPVFixed-DefaultEquipmentConnectionPoint" id1="BBM_GEN" id2="NETWORK"/>
</dyn:dynamicModelsArchitecture>

0 comments on commit 84c2f7f

Please sign in to comment.