Skip to content

Commit

Permalink
Merge branch 'main' into add_dynawaltz_security_analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <[email protected]>
  • Loading branch information
flo-dup committed Mar 11, 2024
2 parents 3c2de3d + a8dd905 commit bfd8115
Show file tree
Hide file tree
Showing 121 changed files with 1,845 additions and 1,384 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ for (Generator gen : network.generators) {
}
for (Line line : network.lines) {
CurrentLimitAutomaton {
OverloadManagementSystem {
dynamicModelId "BBM_" + line.id
parameterSetId "CLA"
controlledQuadripole line.id
controlledBranch line.id
iMeasurement line.id
iMeasurementSide TwoSides.TWO
}
Expand Down
5 changes: 1 addition & 4 deletions dynawaltz-dsl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<description>DSL for DynaWaltz</description>

<properties>
<groovydoc.attach>true</groovydoc.attach>
<groovydoc.classifier>javadoc</groovydoc.classifier>
</properties>

Expand All @@ -30,10 +31,6 @@
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.powsybl.dynamicsimulation.groovy.DynamicModelGroovyExtension
import com.powsybl.dynawaltz.DynaWaltzProvider
import com.powsybl.dynawaltz.builders.BuilderConfig
import com.powsybl.dynawaltz.builders.ModelBuilder
import com.powsybl.dynawaltz.builders.ModelConfigs
import com.powsybl.dynawaltz.builders.ModelConfigsHandler
import com.powsybl.iidm.network.Network

import java.util.function.Consumer
Expand All @@ -27,7 +27,7 @@ class DynaWaltzDynamicModelGroovyExtension implements DynamicModelGroovyExtensio
private final List<BuilderConfig> builderConfigs

DynaWaltzDynamicModelGroovyExtension() {
builderConfigs = ModelConfigs.getInstance().getBuilderConfigs()
builderConfigs = ModelConfigsHandler.getInstance().getBuilderConfigs()
}

@Override
Expand All @@ -40,6 +40,7 @@ class DynaWaltzDynamicModelGroovyExtension implements DynamicModelGroovyExtensio
builderConfigs.stream().flatMap { it -> it.libs}.toList() as List<String>
}


@Override
void load(Binding binding, Consumer<DynamicModel> consumer, Reporter reporter) {
builderConfigs.forEach {conf ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.powsybl.dynamicsimulation.groovy.EventModelGroovyExtension
import com.powsybl.dynawaltz.DynaWaltzProvider
import com.powsybl.dynawaltz.builders.EventBuilderConfig
import com.powsybl.dynawaltz.builders.ModelBuilder
import com.powsybl.dynawaltz.builders.ModelConfigs
import com.powsybl.dynawaltz.builders.ModelConfigsHandler
import com.powsybl.iidm.network.Network

import java.util.function.Consumer
Expand All @@ -27,7 +27,7 @@ class DynaWaltzEventModelGroovyExtension implements EventModelGroovyExtension {
private final List<EventBuilderConfig> builderConfigs

DynaWaltzEventModelGroovyExtension() {
builderConfigs = ModelConfigs.getInstance().getEventBuilderConfigs()
builderConfigs = ModelConfigsHandler.getInstance().getEventBuilderConfigs()
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import com.powsybl.dynawaltz.DynaWaltzProvider;
import com.powsybl.dynawaltz.models.BlackBoxModel;
import com.powsybl.dynawaltz.models.EquipmentBlackBoxModel;
import com.powsybl.dynawaltz.models.automatons.*;
import com.powsybl.dynawaltz.models.automatons.currentlimits.CurrentLimitAutomaton;
import com.powsybl.dynawaltz.models.automatons.currentlimits.CurrentLimitTwoLevelsAutomaton;
import com.powsybl.dynawaltz.models.automatons.phaseshifters.PhaseShifterIAutomaton;
import com.powsybl.dynawaltz.models.automatons.phaseshifters.PhaseShifterPAutomaton;
import com.powsybl.dynawaltz.models.automationsystems.*;
import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicOverloadManagementSystem;
import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicTwoLevelsOverloadManagementSystem;
import com.powsybl.dynawaltz.models.automationsystems.phaseshifters.PhaseShifterIAutomationSystem;
import com.powsybl.dynawaltz.models.automationsystems.phaseshifters.PhaseShifterPAutomationSystem;
import com.powsybl.dynawaltz.models.buses.InfiniteBus;
import com.powsybl.dynawaltz.models.buses.StandardBus;
import com.powsybl.dynawaltz.models.generators.*;
Expand Down Expand Up @@ -66,8 +66,8 @@ void testEquipmentDynamicModels(String groovyScriptName, Class<? extends Equipme
}

@ParameterizedTest(name = "{0}")
@MethodSource("provideAutomatonModelData")
void testAutomatonDynamicModels(String groovyScriptName, Class<? extends BlackBoxModel> modelClass, Network network, String dynamicId, String parameterId, String lib) {
@MethodSource("provideAutomationSystemModelData")
void testAutomationSystemDynamicModels(String groovyScriptName, Class<? extends BlackBoxModel> modelClass, Network network, String dynamicId, String parameterId, String lib) {
DynamicModelsSupplier supplier = new GroovyDynamicModelsSupplier(getResourceAsStream(groovyScriptName), EXTENSIONS);
List<DynamicModel> dynamicModels = supplier.get(network);
assertEquals(1, dynamicModels.size());
Expand Down Expand Up @@ -135,16 +135,16 @@ private static Stream<Arguments> provideEquipmentModelData() {
);
}

private static Stream<Arguments> provideAutomatonModelData() {
private static Stream<Arguments> provideAutomationSystemModelData() {
return Stream.of(
Arguments.of("/dynamicModels/currentLimit.groovy", CurrentLimitAutomaton.class, EurostagTutorialExample1Factory.create(), "AM_NHV1_NHV2_1", "CLA", "CurrentLimitAutomaton"),
Arguments.of("/dynamicModels/currentLimitTwoLevels.groovy", CurrentLimitTwoLevelsAutomaton.class, EurostagTutorialExample1Factory.create(), "AM_NHV1_NHV2_1", "CLA", "CurrentLimitAutomatonTwoLevels"),
Arguments.of("/dynamicModels/tapChanger.groovy", TapChangerAutomaton.class, EurostagTutorialExample1Factory.create(), "TC", "tc", "TapChangerAutomaton"),
Arguments.of("/dynamicModels/tapChangerBlockingBusBar.groovy", TapChangerBlockingAutomaton.class, FourSubstationsNodeBreakerFactory.create(), "ZAB", "ZAB", "TapChangerBlockingAutomaton2"),
Arguments.of("/dynamicModels/tapChangerBlocking.groovy", TapChangerBlockingAutomaton.class, EurostagTutorialExample1Factory.create(), "ZAB", "ZAB", "TapChangerBlockingAutomaton3"),
Arguments.of("/dynamicModels/phaseShifterI.groovy", PhaseShifterIAutomaton.class, EurostagTutorialExample1Factory.create(), "PS_NGEN_NHV1", "ps", "PhaseShifterI"),
Arguments.of("/dynamicModels/phaseShifterP.groovy", PhaseShifterPAutomaton.class, EurostagTutorialExample1Factory.create(), "PS_NGEN_NHV1", "ps", "PhaseShifterP"),
Arguments.of("/dynamicModels/underVoltage.groovy", UnderVoltageAutomaton.class, EurostagTutorialExample1Factory.create(), "UV_GEN", "uv", "UnderVoltageAutomaton")
Arguments.of("/dynamicModels/overloadManagement", DynamicOverloadManagementSystem.class, EurostagTutorialExample1Factory.create(), "AM_NHV1_NHV2_1", "CLA", "CurrentLimitAutomaton"),
Arguments.of("/dynamicModels/overloadManagementTwoLevels.groovy", DynamicTwoLevelsOverloadManagementSystem.class, EurostagTutorialExample1Factory.create(), "AM_NHV1_NHV2_1", "CLA", "CurrentLimitAutomatonTwoLevels"),
Arguments.of("/dynamicModels/tapChanger.groovy", TapChangerAutomationSystem.class, EurostagTutorialExample1Factory.create(), "TC", "tc", "TapChangerAutomaton"),
Arguments.of("/dynamicModels/tapChangerBlockingBusBar.groovy", TapChangerBlockingAutomationSystem.class, FourSubstationsNodeBreakerFactory.create(), "ZAB", "ZAB", "TapChangerBlockingAutomaton2"),
Arguments.of("/dynamicModels/tapChangerBlocking.groovy", TapChangerBlockingAutomationSystem.class, EurostagTutorialExample1Factory.create(), "ZAB", "ZAB", "TapChangerBlockingAutomaton3"),
Arguments.of("/dynamicModels/phaseShifterI.groovy", PhaseShifterIAutomationSystem.class, EurostagTutorialExample1Factory.create(), "PS_NGEN_NHV1", "ps", "PhaseShifterI"),
Arguments.of("/dynamicModels/phaseShifterP.groovy", PhaseShifterPAutomationSystem.class, EurostagTutorialExample1Factory.create(), "PS_NGEN_NHV1", "ps", "PhaseShifterP"),
Arguments.of("/dynamicModels/underVoltage.groovy", UnderVoltageAutomationSystem.class, EurostagTutorialExample1Factory.create(), "UV_GEN", "uv", "UnderVoltageAutomaton")
);
}

Expand Down Expand Up @@ -213,39 +213,39 @@ private static Stream<Arguments> provideWarningsModel() {
"""
+ DSL tests
+ Groovy Dynamic Models Supplier
+ DSL model builder for CurrentLimitAutomaton
'iMeasurement' field value 'NGEN' not found for equipment type(s) Quadripole
+ DSL model builder for OverloadManagementSystem
'iMeasurement' field value 'NGEN' not found for equipment type(s) BRANCH
Model CLA_NGEN cannot be instantiated
"""),
Arguments.of("/warnings/claMissingMeasurementSide.groovy", EurostagTutorialExample1Factory.create(),
"""
+ DSL tests
+ Groovy Dynamic Models Supplier
+ DSL model builder for CurrentLimitAutomaton
+ DSL model builder for OverloadManagementSystem
'iMeasurementSide' field is not set
Model CLA_NGEN cannot be instantiated
"""),
Arguments.of("/warnings/claMissingControlled.groovy", EurostagTutorialExample1Factory.create(),
"""
+ DSL tests
+ Groovy Dynamic Models Supplier
+ DSL model builder for CurrentLimitAutomaton
'controlledQuadripole' field value 'GEN' not found for equipment type(s) Quadripole
+ DSL model builder for OverloadManagementSystem
'controlledBranch' field value 'GEN' not found for equipment type(s) BRANCH
Model CLA_NGEN cannot be instantiated
"""),
Arguments.of("/warnings/cla2MissingMeasurement2.groovy", EurostagTutorialExample1Factory.create(),
"""
+ DSL tests
+ Groovy Dynamic Models Supplier
+ DSL model builder for CurrentLimitAutomatonTwoLevels
'iMeasurement2' field value 'NGEN' not found for equipment type(s) Quadripole
+ DSL model builder for TwoLevelsOverloadManagementSystem
'iMeasurement2' field value 'NGEN' not found for equipment type(s) BRANCH
Model CLA_NGEN cannot be instantiated
"""),
Arguments.of("/warnings/cla2MissingMeasurementSide2.groovy", EurostagTutorialExample1Factory.create(),
"""
+ DSL tests
+ Groovy Dynamic Models Supplier
+ DSL model builder for CurrentLimitAutomatonTwoLevels
+ DSL model builder for TwoLevelsOverloadManagementSystem
'iMeasurement2Side' field is not set
Model CLA_NGEN cannot be instantiated
"""),
Expand All @@ -264,9 +264,8 @@ private static Stream<Arguments> provideWarningsModel() {
+ DSL tests
+ Groovy Dynamic Models Supplier
+ DSL model builder for TapChangerBlockingAutomaton
'uMeasurements' field value 'LOAD' not found for equipment type(s) BUS/BUSBAR_SECTION
'uMeasurements' field value 'Wrong_ID' not found for equipment type(s) BUS/BUSBAR_SECTION
'uMeasurements' field value 'NGEN_NHV1' not found for equipment type(s) BUS/BUSBAR_SECTION
'uMeasurements' field value '[LOAD, Wrong_ID]' not found for equipment type(s) BUS/BUSBAR_SECTION
'uMeasurements' field value '[NGEN_NHV1]' not found for equipment type(s) BUS/BUSBAR_SECTION
'uMeasurements' list is empty
Model ZAB cannot be instantiated
"""),
Expand All @@ -275,8 +274,9 @@ private static Stream<Arguments> provideWarningsModel() {
+ DSL tests
+ Groovy Dynamic Models Supplier
+ DSL model builder for TapChangerBlockingAutomaton
'uMeasurements' field value 'GEN' not found for equipment type(s) LOAD/TWO_WINDINGS_TRANSFORMER
'transformers' list is empty
'transformers' field value 'GEN' not found for equipment type(s) TWO_WINDINGS_TRANSFORMER/LOAD, id will be used as pure dynamic model id
'uMeasurements' field value 'GEN' not found for equipment type(s) BUS/BUSBAR_SECTION
'uMeasurements' list is empty
Model ZAB cannot be instantiated
"""),
Arguments.of("/warnings/hvdcVscWrongStaticType.groovy", HvdcTestNetwork.createLcc(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void assertEventModel(AbstractEvent em, String dynamicId, String equipmentStatic

private static Stream<Arguments> provideEventModelData() {
return Stream.of(
Arguments.of("/eventModels/quadripoleDisconnection.groovy", EventQuadripoleDisconnection.class, EurostagTutorialExample1Factory.create(), "NHV1_NHV2_1", "Disconnect_NHV1_NHV2_1", "EventQuadripoleDisconnection", 4),
Arguments.of("/eventModels/branchDisconnection.groovy", EventBranchDisconnection.class, EurostagTutorialExample1Factory.create(), "NHV1_NHV2_1", "Disconnect_NHV1_NHV2_1", "EventQuadripoleDisconnection", 4),
Arguments.of("/eventModels/equipmentDisconnection.groovy", EventInjectionDisconnection.class, EurostagTutorialExample1Factory.create(), "GEN", "Disconnect_GEN", null, 1),
Arguments.of("/eventModels/hvdcDisconnection.groovy", EventHvdcDisconnection.class, HvdcTestNetwork.createVsc(), "L", "Disconnect_L", null, 2),
Arguments.of("/eventModels/nodeFault.groovy", NodeFaultEvent.class, EurostagTutorialExample1Factory.create(), "NGEN", "NodeFault_NGEN", "NodeFault", 1),
Expand Down Expand Up @@ -124,7 +124,7 @@ faultTime should be strictly positive (0.0)
+ DSL tests
+ Groovy Event Models Supplier
+ DSL model builder for Disconnect
'disconnectSide' field is set but GENERATOR GEN does not possess this option
'disconnectOnly' field is set but GENERATOR GEN does not possess this option
Model Disconnect_GEN cannot be instantiated
""")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
/**
* @author Marcos de Miguel {@literal <demiguelm at aia.es>}
*/
class Ieee14CurrentLimitAutomatonTest extends AbstractIeeeTest {
class Ieee14DynamicOverloadManagementSystemTest extends AbstractIeeeTest {

@BeforeEach
void setup() throws IOException {
super.setup(
"/ieee14-currentlimitautomaton/config/models.par",
"/ieee14-currentlimitautomaton/config/network.par", "8",
"/ieee14-currentlimitautomaton/config/solvers.par", "2",
"/ieee14-currentlimitautomaton/powsybl-inputs/IEEE14.iidm",
"/ieee14-currentlimitautomaton/powsybl-inputs/dynamicModels.groovy",
"/ieee14-currentlimitautomaton/powsybl-inputs/eventModels.groovy",
"/ieee14-currentlimitautomaton/powsybl-inputs/curves.groovy",
"/ieee14-overloadmanagementsystem/config/models.par",
"/ieee14-overloadmanagementsystem/config/network.par", "8",
"/ieee14-overloadmanagementsystem/config/solvers.par", "2",
"/ieee14-overloadmanagementsystem/powsybl-inputs/IEEE14.iidm",
"/ieee14-overloadmanagementsystem/powsybl-inputs/dynamicModels.groovy",
"/ieee14-overloadmanagementsystem/powsybl-inputs/eventModels.groovy",
"/ieee14-overloadmanagementsystem/powsybl-inputs/curves.groovy",
0, 50
);
}
Expand All @@ -44,6 +44,6 @@ void testSimulation() throws Exception {

@Override
public String getWorkingDirName() {
return "ieee14-currentlimitautomaton";
return "ieee14-overloadmanagementsystem";
}
}
2 changes: 1 addition & 1 deletion dynawaltz-dsl/src/test/resources/dynamicModels.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ for (Generator gen : network.generators) {
}

for (Line line : network.lines) {
CurrentLimitAutomaton {
OverloadManagementSystem {
dynamicModelId "BBM_" + line.id
parameterSetId "CLA"
iMeasurement line.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ package dynamicModels

import com.powsybl.iidm.network.TwoSides

CurrentLimitAutomaton {
OverloadManagementSystem {
dynamicModelId "AM_NHV1_NHV2_1"
parameterSetId "CLA"
controlledQuadripole "NHV1_NHV2_2"
controlledBranch "NHV1_NHV2_2"
iMeasurement "NHV1_NHV2_1"
iMeasurementSide TwoSides.TWO
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ package dynamicModels

import com.powsybl.iidm.network.TwoSides

CurrentLimitAutomatonTwoLevels {
TwoLevelsOverloadManagementSystem {
dynamicModelId "AM_NHV1_NHV2_1"
parameterSetId "CLA"
controlledQuadripole "NHV1_NHV2_2"
controlledBranch "NHV1_NHV2_2"
iMeasurement1 "NHV1_NHV2_1"
iMeasurement1Side TwoSides.TWO
iMeasurement2 "NGEN_NHV1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

package dynamicModels

List[] measurements = [["OldId", "NGEN", "NHV1"], ["NHV1", "OldId"], ["NHV2"]]

TapChangerBlockingAutomaton {
dynamicModelId "ZAB"
parameterSetId "ZAB"
uMeasurements ["OldId", "NGEN", "NHV1"], ["NHV1", "OldId"], ["NHV2"]
uMeasurements measurements
transformers "NGEN_NHV1", "NHV2_NLOAD", "LOAD"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

package dynamicModels

def measurements = ["S1VL2_BBS1", "OldId", "S3VL1_BBS"]

TapChangerBlockingAutomaton {
dynamicModelId "ZAB"
parameterSetId "ZAB"
uMeasurements "S1VL2_BBS1", "OldId", "S3VL1_BBS"
uMeasurements measurements
transformers "TWT", "LD1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<dyn:connect var1="omegaRef_grp_@INDEX@" var2="generator_omegaRefPu"/>
<dyn:connect var1="running_grp_@INDEX@" var2="generator_running"/>
</dyn:macroConnector>
<dyn:macroConnector id="MC_EventQuadripoleDisconnection-DefaultLine">
<dyn:macroConnector id="MC_EventBranchDisconnection-DefaultLine">
<dyn:connect var1="event_state1_value" var2="@NAME@_state_value"/>
</dyn:macroConnector>
<dyn:macroStaticReference id="MSR_LoadAlphaBeta">
Expand Down Expand Up @@ -119,5 +119,5 @@
<dyn:macroConnect connector="MC_DYNModelOmegaRef-DefaultBusOfFrequencySynchronized" id1="FREQ_SYNC" index1="3" id2="NETWORK" name2="_GEN____6_SM"/>
<dyn:macroConnect connector="MC_DYNModelOmegaRef-GeneratorSynchronousThreeWindingsProportionalRegulations" id1="FREQ_SYNC" index1="4" id2="_GEN____8_SM"/>
<dyn:macroConnect connector="MC_DYNModelOmegaRef-DefaultBusOfFrequencySynchronized" id1="FREQ_SYNC" index1="4" id2="NETWORK" name2="_GEN____8_SM"/>
<dyn:macroConnect connector="MC_EventQuadripoleDisconnection-DefaultLine" id1="Disconnect__BUS____1-BUS____5-1_AC" id2="NETWORK" name2="_BUS____1-BUS____5-1_AC"/>
<dyn:macroConnect connector="MC_EventBranchDisconnection-DefaultLine" id1="Disconnect__BUS____1-BUS____5-1_AC" id2="NETWORK" name2="_BUS____1-BUS____5-1_AC"/>
</dyn:dynamicModelsArchitecture>
Loading

0 comments on commit bfd8115

Please sign in to comment.