Skip to content

Commit

Permalink
Signal n models (#373)
Browse files Browse the repository at this point in the history
* Add Signal N and signal N generators
* Add integration tests
* Add documentation

Signed-off-by: lisrte <[email protected]>
  • Loading branch information
Lisrte authored Jul 18, 2024
1 parent 62780e7 commit a4cea8d
Show file tree
Hide file tree
Showing 18 changed files with 620 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/dynamic_simulation/dynamic-models-dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Ultimately, all groovy scripts call dedicated builders that can be used directly
* HvdcPBuilder
* HvdcVscBuilder
* GeneratorFictitiousBuilder
* SignalNGeneratorBuilder
* SynchronizedGeneratorBuilder
* SynchronousGeneratorBuilder
* WeccBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,34 @@ private void checkFirstTimeLineEvent(TimelineEvent event, double time, String mo
assertEquals(modelName, event.modelName());
assertEquals(message, event.message());
}

@Test
void testIEEE14SignalN() {
Network network = Network.read(new ResourceDataSource("IEEE14", new ResourceSet("/ieee14", "IEEE14.iidm")));

GroovyDynamicModelsSupplier dynamicModelsSupplier = new GroovyDynamicModelsSupplier(
getResourceAsStream("/ieee14/signal_n/dynamicModels.groovy"),
GroovyExtension.find(DynamicModelGroovyExtension.class, DynawoSimulationProvider.NAME));
GroovyEventModelsSupplier eventModelsSupplier = new GroovyEventModelsSupplier(
getResourceAsStream("/ieee14/disconnectline/eventModels.groovy"),
GroovyExtension.find(EventModelGroovyExtension.class, DynawoSimulationProvider.NAME));

dynawoSimulationParameters.setModelsParameters(ParametersXml.load(getResourceAsStream("/ieee14/signal_n/IEEE14.par")))
.setNetworkParameters(ParametersXml.load(getResourceAsStream("/ieee14/signal_n/IEEE14.par"), "Network"))
.setSolverParameters(ParametersXml.load(getResourceAsStream("/ieee14/signal_n/IEEE14.par"), "SimplifiedSolver"))
.setLogLevelFilter(DynawoSimulationParameters.LogLevel.DEBUG)
.setSolverType(DynawoSimulationParameters.SolverType.SIM)
.setTimelineExportMode(DynawoSimulationParameters.ExportMode.XML);

DynamicSimulationResult result = provider.run(network, dynamicModelsSupplier, eventModelsSupplier, CurvesSupplier.empty(),
VariantManagerConstants.INITIAL_VARIANT_ID, computationManager, parameters, NO_OP)
.join();

assertEquals(DynamicSimulationResult.Status.SUCCESS, result.getStatus());
assertTrue(result.getStatusText().isEmpty());
assertEquals(0, result.getCurves().size());
List<TimelineEvent> timeLine = result.getTimeLine();
assertEquals(1, timeLine.size());
checkFirstTimeLineEvent(timeLine.get(0), 10, "_BUS____1-BUS____5-1_AC", "LINE : opening on side 2");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 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 ieee14.disconnectline

import com.powsybl.iidm.network.TwoSides

Expand Down
118 changes: 118 additions & 0 deletions dynawo-integration-tests/src/test/resources/ieee14/signal_n/IEEE14.par
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<parametersSet xmlns="http://www.rte-france.com/dynawo">
<set id="Network">
<par type="DOUBLE" name="capacitor_no_reclosing_delay" value="300"/>
<par type="DOUBLE" name="dangling_line_currentLimit_maxTimeOperation" value="90"/>
<par type="DOUBLE" name="line_currentLimit_maxTimeOperation" value="90"/>
<par type="DOUBLE" name="load_Tp" value="90"/>
<par type="DOUBLE" name="load_Tq" value="90"/>
<par type="DOUBLE" name="load_alpha" value="1"/>
<par type="DOUBLE" name="load_alphaLong" value="0"/>
<par type="DOUBLE" name="load_beta" value="2"/>
<par type="DOUBLE" name="load_betaLong" value="0"/>
<par type="BOOL" name="load_isControllable" value="false"/>
<par type="BOOL" name="load_isRestorative" value="false"/>
<par type="DOUBLE" name="load_zPMax" value="100"/>
<par type="DOUBLE" name="load_zQMax" value="100"/>
<par type="DOUBLE" name="reactance_no_reclosing_delay" value="0"/>
<par type="DOUBLE" name="transformer_currentLimit_maxTimeOperation" value="90"/>
<par type="DOUBLE" name="transformer_t1st_HT" value="60"/>
<par type="DOUBLE" name="transformer_t1st_THT" value="30"/>
<par type="DOUBLE" name="transformer_tNext_HT" value="10"/>
<par type="DOUBLE" name="transformer_tNext_THT" value="10"/>
<par type="DOUBLE" name="transformer_tolV" value="0.015"/>
</set>
<set id="GenericRestorativeLoad">
<par type="DOUBLE" name="load_Alpha" value="1.5"/>
<par type="DOUBLE" name="load_Beta" value="2.5"/>
<par type="DOUBLE" name="load_UMaxPu" value="1.05"/>
<par type="DOUBLE" name="load_UMinPu" value="0.95"/>
<par type="DOUBLE" name="load_tFilter" value="10"/>
<reference type="DOUBLE" name="load_P0Pu" origData="IIDM" origName="p_pu"/>
<reference type="DOUBLE" name="load_Q0Pu" origData="IIDM" origName="q_pu"/>
<reference type="DOUBLE" name="load_U0Pu" origData="IIDM" origName="v_pu"/>
<reference type="DOUBLE" name="load_UPhase0" origData="IIDM" origName="angle_pu"/>
</set>
<set id="Generator1">
<par type="DOUBLE" name="generator_PMin" value="0"/>
<par type="DOUBLE" name="generator_PMax" value="1090"/>
<par type="DOUBLE" name="generator_PNom" value="1090"/>
<par type="DOUBLE" name="generator_QMin" value="-10000"/>
<par type="DOUBLE" name="generator_QMax" value="10000"/>
<par type="DOUBLE" name="generator_KGover" value="1"/>
<reference name="generator_P0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_Q0Pu" origData="IIDM" origName="q_pu" type="DOUBLE"/>
<reference name="generator_U0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
<reference name="generator_PRef0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_URef0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
</set>
<set id="Generator2">
<par type="DOUBLE" name="generator_PMin" value="0"/>
<par type="DOUBLE" name="generator_PMax" value="1008"/>
<par type="DOUBLE" name="generator_PNom" value="1008"/>
<par type="DOUBLE" name="generator_QMin" value="-10000"/>
<par type="DOUBLE" name="generator_QMax" value="10000"/>
<par type="DOUBLE" name="generator_KGover" value="1"/>
<reference name="generator_P0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_Q0Pu" origData="IIDM" origName="q_pu" type="DOUBLE"/>
<reference name="generator_U0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
<reference name="generator_PRef0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_URef0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
</set>
<set id="Generator3">
<par type="DOUBLE" name="generator_PMin" value="0"/>
<par type="DOUBLE" name="generator_PMax" value="1485"/>
<par type="DOUBLE" name="generator_PNom" value="1485"/>
<par type="DOUBLE" name="generator_QMin" value="-10000"/>
<par type="DOUBLE" name="generator_QMax" value="10000"/>
<par type="DOUBLE" name="generator_KGover" value="1"/>
<reference name="generator_P0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_Q0Pu" origData="IIDM" origName="q_pu" type="DOUBLE"/>
<reference name="generator_U0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
<reference name="generator_PRef0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_URef0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
</set>
<set id="Generator6">
<par type="DOUBLE" name="generator_PMin" value="0"/>
<par type="DOUBLE" name="generator_PMax" value="74.4"/>
<par type="DOUBLE" name="generator_PNom" value="74.4"/>
<par type="DOUBLE" name="generator_QMin" value="-10000"/>
<par type="DOUBLE" name="generator_QMax" value="10000"/>
<par type="DOUBLE" name="generator_KGover" value="1"/>
<reference name="generator_P0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_Q0Pu" origData="IIDM" origName="q_pu" type="DOUBLE"/>
<reference name="generator_U0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
<reference name="generator_PRef0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_URef0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
</set>
<set id="Generator8">
<par type="DOUBLE" name="generator_PMin" value="0"/>
<par type="DOUBLE" name="generator_PMax" value="228"/>
<par type="DOUBLE" name="generator_PNom" value="228"/>
<par type="DOUBLE" name="generator_QMin" value="-10000"/>
<par type="DOUBLE" name="generator_QMax" value="10000"/>
<par type="DOUBLE" name="generator_KGover" value="1"/>
<reference name="generator_P0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_Q0Pu" origData="IIDM" origName="q_pu" type="DOUBLE"/>
<reference name="generator_U0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
<reference name="generator_UPhase0" origData="IIDM" origName="angle_pu" type="DOUBLE"/>
<reference name="generator_PRef0Pu" origData="IIDM" origName="p_pu" type="DOUBLE"/>
<reference name="generator_URef0Pu" origData="IIDM" origName="v_pu" type="DOUBLE"/>
</set>
<set id="DisconnectLine">
<par type="DOUBLE" name="event_tEvent" value="100"/>
<par type="BOOL" name="event_disconnectOrigin" value="true"/>
<par type="BOOL" name="event_disconnectExtremity" value="true"/>
</set>
<set id="SimplifiedSolver">
<par type="DOUBLE" name="hMin" value="1"/>
<par type="DOUBLE" name="hMax" value="10"/>
<par type="DOUBLE" name="kReduceStep" value="0.5"/>
<par type="INT" name="maxNewtonTry" value="10"/>
<par type="STRING" name="linearSolverName" value="KLU"/>
</set>
</parametersSet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* 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 ieee14.signal_n

GeneratorPVSignalN {
staticId "_GEN____1_SM"
parameterSetId "Generator1"
}

GeneratorPVSignalN {
staticId "_GEN____2_SM"
parameterSetId "Generator2"
}

GeneratorPVSignalN {
staticId "_GEN____3_SM"
parameterSetId "Generator3"
}

GeneratorPVSignalN {
staticId "_GEN____6_SM"
parameterSetId "Generator6"
}

GeneratorPVSignalN {
staticId "_GEN____8_SM"
parameterSetId "Generator8"
}

for (load in network.loads) {
LoadAlphaBetaRestorative {
staticId load.id
parameterSetId "GenericRestorativeLoad"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
import com.powsybl.dynawo.models.buses.AbstractBus;
import com.powsybl.dynawo.models.defaultmodels.DefaultModelsHandler;
import com.powsybl.dynawo.models.events.ContextDependentEvent;
import com.powsybl.dynawo.models.frequencysynchronizers.FrequencySynchronizedModel;
import com.powsybl.dynawo.models.frequencysynchronizers.FrequencySynchronizerModel;
import com.powsybl.dynawo.models.frequencysynchronizers.OmegaRef;
import com.powsybl.dynawo.models.frequencysynchronizers.SetPoint;
import com.powsybl.dynawo.models.frequencysynchronizers.*;
import com.powsybl.dynawo.models.macroconnections.MacroConnect;
import com.powsybl.dynawo.models.macroconnections.MacroConnectionsAdder;
import com.powsybl.dynawo.models.macroconnections.MacroConnector;
Expand Down Expand Up @@ -102,7 +99,7 @@ public DynawoSimulationContext(Network network, String workingVariantId, List<Bl
.filter(DynawoCurve.class::isInstance)
.map(DynawoCurve.class::cast)
.toList();
this.frequencySynchronizer = setupFrequencySynchronizer(dynamicModels.stream().anyMatch(AbstractBus.class::isInstance) ? SetPoint::new : OmegaRef::new);
this.frequencySynchronizer = setupFrequencySynchronizer();
this.macroConnectionsAdder = new MacroConnectionsAdder(this::getDynamicModel,
this::getPureDynamicModel,
macroConnectList::add,
Expand Down Expand Up @@ -135,11 +132,25 @@ private Stream<BlackBoxModel> simplifyModels(Stream<BlackBoxModel> inputBbm, Rep
return outputBbm;
}

private FrequencySynchronizerModel setupFrequencySynchronizer(Function<List<FrequencySynchronizedModel>, FrequencySynchronizerModel> fsConstructor) {
return fsConstructor.apply(dynamicModels.stream()
.filter(FrequencySynchronizedModel.class::isInstance)
.map(FrequencySynchronizedModel.class::cast)
.toList());
private FrequencySynchronizerModel setupFrequencySynchronizer() {
List<SignalNModel> signalNModels = filterDynamicModels(SignalNModel.class);
List<FrequencySynchronizedModel> frequencySynchronizedModels = filterDynamicModels(FrequencySynchronizedModel.class);
boolean hasSpecificBuses = dynamicModels.stream().anyMatch(AbstractBus.class::isInstance);
boolean hasSignalNModel = !signalNModels.isEmpty();
if (!frequencySynchronizedModels.isEmpty() && hasSignalNModel) {
throw new PowsyblException("Signal N and frequency synchronized generators cannot be used with one another");
}
if (hasSignalNModel) {
return new SignalN(signalNModels);
}
return hasSpecificBuses ? new SetPoint(frequencySynchronizedModels) : new OmegaRef(frequencySynchronizedModels);
}

private <T extends Model> List<T> filterDynamicModels(Class<T> modelClass) {
return dynamicModels.stream()
.filter(modelClass::isInstance)
.map(modelClass::cast)
.toList();
}

public Network getNetwork() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public final class ModelConfigLoaderImpl implements ModelConfigLoader {
new BuilderConfig(SynchronizedGeneratorBuilder.CATEGORY, SynchronizedGeneratorBuilder::of, SynchronizedGeneratorBuilder::getSupportedModelInfos),
new BuilderConfig(SynchronousGeneratorBuilder.CATEGORY, SynchronousGeneratorBuilder::of, SynchronousGeneratorBuilder::getSupportedModelInfos),
new BuilderConfig(WeccBuilder.CATEGORY, WeccBuilder::of, WeccBuilder::getSupportedModelInfos),
new BuilderConfig(GridFormingConverterBuilder.CATEGORY, GridFormingConverterBuilder::of, GridFormingConverterBuilder::getSupportedModelInfos));
new BuilderConfig(GridFormingConverterBuilder.CATEGORY, GridFormingConverterBuilder::of, GridFormingConverterBuilder::getSupportedModelInfos),
new BuilderConfig(SignalNGeneratorBuilder.CATEGORY, SignalNGeneratorBuilder::of, SignalNGeneratorBuilder::getSupportedModelInfos));

private static final Stream<EventBuilderConfig> EVENT_BUILDER_CONFIGS = Stream.of(
new EventBuilderConfig(EventActivePowerVariationBuilder::of, EventActivePowerVariationBuilder.getEventModelInfo()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 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.models.buses;

import com.powsybl.dynawo.models.Model;

/**
* View of signal N equipment from the bus to which it is connected
* Used by Signal N in order to get phi var name
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public interface BusOfSignalNModel extends Model {

String getPhiVarName();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.models.buses;

import java.util.List;
import com.powsybl.dynawo.models.defaultmodels.AbstractDefaultModel;
import com.powsybl.dynawo.models.macroconnections.MacroConnectAttribute;
import com.powsybl.dynawo.xml.DynawoSimulationXmlConstants;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public class DefaultBusOfSignalN extends AbstractDefaultModel implements BusOfSignalNModel {

private final String signalNEquipmentStaticId;

public DefaultBusOfSignalN(String staticId, String signalNEquipmentStaticId) {
super(staticId);
this.signalNEquipmentStaticId = signalNEquipmentStaticId;
}

@Override
public String getName() {
return "DefaultBusOfSignalN";
}

public String getPhiVarName() {
return "@@NAME@@@NODE@_phi_value";
}

@Override
public List<MacroConnectAttribute> getMacroConnectToAttributes() {
return List.of(
MacroConnectAttribute.of("id2", DynawoSimulationXmlConstants.NETWORK),
MacroConnectAttribute.of("name2", signalNEquipmentStaticId)
);
}
}
Loading

0 comments on commit a4cea8d

Please sign in to comment.