diff --git a/README.md b/README.md index 2898af07e..ad67b3cec 100644 --- a/README.md +++ b/README.md @@ -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 } diff --git a/dynawaltz-dsl/pom.xml b/dynawaltz-dsl/pom.xml index 826d1a34b..285f8161d 100644 --- a/dynawaltz-dsl/pom.xml +++ b/dynawaltz-dsl/pom.xml @@ -21,6 +21,7 @@ DSL for DynaWaltz + true javadoc @@ -30,10 +31,6 @@ org.codehaus.gmavenplus gmavenplus-plugin - - org.codehaus.mojo - build-helper-maven-plugin - diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzDynamicModelGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzDynamicModelGroovyExtension.groovy index 2380df6e7..8e00fe363 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzDynamicModelGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzDynamicModelGroovyExtension.groovy @@ -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 @@ -27,7 +27,7 @@ class DynaWaltzDynamicModelGroovyExtension implements DynamicModelGroovyExtensio private final List builderConfigs DynaWaltzDynamicModelGroovyExtension() { - builderConfigs = ModelConfigs.getInstance().getBuilderConfigs() + builderConfigs = ModelConfigsHandler.getInstance().getBuilderConfigs() } @Override @@ -40,6 +40,7 @@ class DynaWaltzDynamicModelGroovyExtension implements DynamicModelGroovyExtensio builderConfigs.stream().flatMap { it -> it.libs}.toList() as List } + @Override void load(Binding binding, Consumer consumer, Reporter reporter) { builderConfigs.forEach {conf -> diff --git a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzEventModelGroovyExtension.groovy b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzEventModelGroovyExtension.groovy index cfe89d56f..1310c7024 100644 --- a/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzEventModelGroovyExtension.groovy +++ b/dynawaltz-dsl/src/main/groovy/com/powsybl/dynawaltz/dsl/DynaWaltzEventModelGroovyExtension.groovy @@ -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 @@ -27,7 +27,7 @@ class DynaWaltzEventModelGroovyExtension implements EventModelGroovyExtension { private final List builderConfigs DynaWaltzEventModelGroovyExtension() { - builderConfigs = ModelConfigs.getInstance().getEventBuilderConfigs() + builderConfigs = ModelConfigsHandler.getInstance().getEventBuilderConfigs() } @Override diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java index 7d23dba53..949001571 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/DynamicModelsSupplierTest.java @@ -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.*; @@ -66,8 +66,8 @@ void testEquipmentDynamicModels(String groovyScriptName, Class modelClass, Network network, String dynamicId, String parameterId, String lib) { + @MethodSource("provideAutomationSystemModelData") + void testAutomationSystemDynamicModels(String groovyScriptName, Class modelClass, Network network, String dynamicId, String parameterId, String lib) { DynamicModelsSupplier supplier = new GroovyDynamicModelsSupplier(getResourceAsStream(groovyScriptName), EXTENSIONS); List dynamicModels = supplier.get(network); assertEquals(1, dynamicModels.size()); @@ -135,16 +135,16 @@ private static Stream provideEquipmentModelData() { ); } - private static Stream provideAutomatonModelData() { + private static Stream 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") ); } @@ -213,15 +213,15 @@ private static Stream 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 """), @@ -229,23 +229,23 @@ private static Stream provideWarningsModel() { """ + 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 """), @@ -264,9 +264,8 @@ private static Stream 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 """), @@ -275,8 +274,9 @@ private static Stream 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(), diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java index 9da3e744f..daae12680 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/EventModelsSupplierTest.java @@ -68,7 +68,7 @@ void assertEventModel(AbstractEvent em, String dynamicId, String equipmentStatic private static Stream 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), @@ -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 """) ); diff --git a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee14/Ieee14CurrentLimitAutomatonTest.java b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee14/Ieee14DynamicOverloadManagementSystemTest.java similarity index 65% rename from dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee14/Ieee14CurrentLimitAutomatonTest.java rename to dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee14/Ieee14DynamicOverloadManagementSystemTest.java index a1477a53b..46c16e084 100644 --- a/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee14/Ieee14CurrentLimitAutomatonTest.java +++ b/dynawaltz-dsl/src/test/java/com/powsybl/dynawaltz/dsl/ieee14/Ieee14DynamicOverloadManagementSystemTest.java @@ -19,18 +19,18 @@ /** * @author Marcos de Miguel {@literal } */ -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 ); } @@ -44,6 +44,6 @@ void testSimulation() throws Exception { @Override public String getWorkingDirName() { - return "ieee14-currentlimitautomaton"; + return "ieee14-overloadmanagementsystem"; } } diff --git a/dynawaltz-dsl/src/test/resources/dynamicModels.groovy b/dynawaltz-dsl/src/test/resources/dynamicModels.groovy index a9849a1ac..b6dfaf2cc 100644 --- a/dynawaltz-dsl/src/test/resources/dynamicModels.groovy +++ b/dynawaltz-dsl/src/test/resources/dynamicModels.groovy @@ -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 diff --git a/dynawaltz-dsl/src/test/resources/dynamicModels/currentLimit.groovy b/dynawaltz-dsl/src/test/resources/dynamicModels/overloadManagement similarity index 88% rename from dynawaltz-dsl/src/test/resources/dynamicModels/currentLimit.groovy rename to dynawaltz-dsl/src/test/resources/dynamicModels/overloadManagement index 3d4ed0531..e11998b3a 100644 --- a/dynawaltz-dsl/src/test/resources/dynamicModels/currentLimit.groovy +++ b/dynawaltz-dsl/src/test/resources/dynamicModels/overloadManagement @@ -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 } diff --git a/dynawaltz-dsl/src/test/resources/dynamicModels/currentLimitTwoLevels.groovy b/dynawaltz-dsl/src/test/resources/dynamicModels/overloadManagementTwoLevels.groovy similarity index 88% rename from dynawaltz-dsl/src/test/resources/dynamicModels/currentLimitTwoLevels.groovy rename to dynawaltz-dsl/src/test/resources/dynamicModels/overloadManagementTwoLevels.groovy index 2d47e3581..8f16bd4b6 100644 --- a/dynawaltz-dsl/src/test/resources/dynamicModels/currentLimitTwoLevels.groovy +++ b/dynawaltz-dsl/src/test/resources/dynamicModels/overloadManagementTwoLevels.groovy @@ -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" diff --git a/dynawaltz-dsl/src/test/resources/dynamicModels/tapChangerBlocking.groovy b/dynawaltz-dsl/src/test/resources/dynamicModels/tapChangerBlocking.groovy index d11424d4b..5d41fb5f0 100644 --- a/dynawaltz-dsl/src/test/resources/dynamicModels/tapChangerBlocking.groovy +++ b/dynawaltz-dsl/src/test/resources/dynamicModels/tapChangerBlocking.groovy @@ -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" } diff --git a/dynawaltz-dsl/src/test/resources/dynamicModels/tapChangerBlockingBusBar.groovy b/dynawaltz-dsl/src/test/resources/dynamicModels/tapChangerBlockingBusBar.groovy index 3372d8f88..1a3274b70 100644 --- a/dynawaltz-dsl/src/test/resources/dynamicModels/tapChangerBlockingBusBar.groovy +++ b/dynawaltz-dsl/src/test/resources/dynamicModels/tapChangerBlockingBusBar.groovy @@ -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" } diff --git a/dynawaltz-dsl/src/test/resources/eventModels/quadripoleDisconnection.groovy b/dynawaltz-dsl/src/test/resources/eventModels/branchDisconnection.groovy similarity index 100% rename from dynawaltz-dsl/src/test/resources/eventModels/quadripoleDisconnection.groovy rename to dynawaltz-dsl/src/test/resources/eventModels/branchDisconnection.groovy diff --git a/dynawaltz-dsl/src/test/resources/ieee14-disconnectline/dynawaltz-inputs/powsybl_dynawaltz.dyd b/dynawaltz-dsl/src/test/resources/ieee14-disconnectline/dynawaltz-inputs/powsybl_dynawaltz.dyd index 0fdd5547b..ff83b9a4d 100644 --- a/dynawaltz-dsl/src/test/resources/ieee14-disconnectline/dynawaltz-inputs/powsybl_dynawaltz.dyd +++ b/dynawaltz-dsl/src/test/resources/ieee14-disconnectline/dynawaltz-inputs/powsybl_dynawaltz.dyd @@ -75,7 +75,7 @@ - + @@ -119,5 +119,5 @@ - + diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/config/models.par b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/config/models.par similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/config/models.par rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/config/models.par diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/config/network.par b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/config/network.par similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/config/network.par rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/config/network.par diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/config/solvers.par b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/config/solvers.par similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/config/solvers.par rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/config/solvers.par diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/ieee14bus.par b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/ieee14bus.par similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/ieee14bus.par rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/ieee14bus.par diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/models.par b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/models.par similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/models.par rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/models.par diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/network.par b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/network.par similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/network.par rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/network.par diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.crv b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.crv similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.crv rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.crv diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.dyd b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.dyd similarity index 97% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.dyd rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.dyd index f778cd73f..c5a160aea 100644 --- a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.dyd +++ b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.dyd @@ -84,7 +84,7 @@ - + @@ -132,5 +132,5 @@ - + diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.jobs b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.jobs similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.jobs rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.jobs diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.xiidm b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.xiidm similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/powsybl_dynawaltz.xiidm rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/powsybl_dynawaltz.xiidm diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/solvers.par b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/solvers.par similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-inputs/solvers.par rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-inputs/solvers.par diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-outputs/curves.csv b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-outputs/curves.csv similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-outputs/curves.csv rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-outputs/curves.csv diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-outputs/timeline.log b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-outputs/timeline.log similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/dynawaltz-outputs/timeline.log rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/dynawaltz-outputs/timeline.log diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/IEEE14.iidm b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/IEEE14.iidm similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/IEEE14.iidm rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/IEEE14.iidm diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/curves.groovy b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/curves.groovy similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/curves.groovy rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/curves.groovy diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/dynamicModels.groovy b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/dynamicModels.groovy similarity index 89% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/dynamicModels.groovy rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/dynamicModels.groovy index 6a5457d7f..5822840a5 100644 --- a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/dynamicModels.groovy +++ b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/dynamicModels.groovy @@ -32,18 +32,18 @@ for (Generator gen : network.generators) { } } -CurrentLimitAutomaton { +OverloadManagementSystem { dynamicModelId "CLA_2_4" parameterSetId "CLA_2_4" - controlledQuadripole "_BUS____2-BUS____4-1_AC" + controlledBranch "_BUS____2-BUS____4-1_AC" iMeasurement "_BUS____2-BUS____4-1_AC" iMeasurementSide TwoSides.TWO } -CurrentLimitAutomaton { +OverloadManagementSystem { dynamicModelId "CLA_2_5" parameterSetId "CLA_2_5" - controlledQuadripole "_BUS____2-BUS____5-1_AC" + controlledBranch "_BUS____2-BUS____5-1_AC" iMeasurement "_BUS____2-BUS____5-1_AC" iMeasurementSide TwoSides.TWO } diff --git a/dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/eventModels.groovy b/dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/eventModels.groovy similarity index 100% rename from dynawaltz-dsl/src/test/resources/ieee14-currentlimitautomaton/powsybl-inputs/eventModels.groovy rename to dynawaltz-dsl/src/test/resources/ieee14-overloadmanagementsystem/powsybl-inputs/eventModels.groovy diff --git a/dynawaltz-dsl/src/test/resources/warnings/cla2MissingMeasurement2.groovy b/dynawaltz-dsl/src/test/resources/warnings/cla2MissingMeasurement2.groovy index 3f9c32d81..199b834c3 100644 --- a/dynawaltz-dsl/src/test/resources/warnings/cla2MissingMeasurement2.groovy +++ b/dynawaltz-dsl/src/test/resources/warnings/cla2MissingMeasurement2.groovy @@ -10,10 +10,10 @@ package warnings import com.powsybl.iidm.network.TwoSides -CurrentLimitAutomatonTwoLevels { +TwoLevelsOverloadManagementSystem { dynamicModelId "CLA_NGEN" parameterSetId "CLA" - controlledQuadripole "NHV1_NHV2_2" + controlledBranch "NHV1_NHV2_2" iMeasurement1 "NHV1_NHV2_1" iMeasurement1Side TwoSides.TWO iMeasurement2 "NGEN" diff --git a/dynawaltz-dsl/src/test/resources/warnings/cla2MissingMeasurementSide2.groovy b/dynawaltz-dsl/src/test/resources/warnings/cla2MissingMeasurementSide2.groovy index bcf6345ea..32eb99e99 100644 --- a/dynawaltz-dsl/src/test/resources/warnings/cla2MissingMeasurementSide2.groovy +++ b/dynawaltz-dsl/src/test/resources/warnings/cla2MissingMeasurementSide2.groovy @@ -10,10 +10,10 @@ package warnings import com.powsybl.iidm.network.TwoSides -CurrentLimitAutomatonTwoLevels { +TwoLevelsOverloadManagementSystem { dynamicModelId "CLA_NGEN" parameterSetId "CLA" - controlledQuadripole "NHV1_NHV2_2" + controlledBranch "NHV1_NHV2_2" iMeasurement1 "NHV1_NHV2_1" iMeasurement1Side TwoSides.TWO iMeasurement2 "NHV1_NHV2_2" diff --git a/dynawaltz-dsl/src/test/resources/warnings/claMissingControlled.groovy b/dynawaltz-dsl/src/test/resources/warnings/claMissingControlled.groovy index 0e7d57c6b..86393d320 100644 --- a/dynawaltz-dsl/src/test/resources/warnings/claMissingControlled.groovy +++ b/dynawaltz-dsl/src/test/resources/warnings/claMissingControlled.groovy @@ -10,10 +10,10 @@ package warnings import com.powsybl.iidm.network.TwoSides -CurrentLimitAutomaton { +OverloadManagementSystem { dynamicModelId "CLA_NGEN" parameterSetId "CLA" - controlledQuadripole "GEN" + controlledBranch "GEN" iMeasurement "NHV1_NHV2_1" iMeasurementSide TwoSides.TWO } diff --git a/dynawaltz-dsl/src/test/resources/warnings/claMissingMeasurement.groovy b/dynawaltz-dsl/src/test/resources/warnings/claMissingMeasurement.groovy index f5e5b3e21..4d6b6c37e 100644 --- a/dynawaltz-dsl/src/test/resources/warnings/claMissingMeasurement.groovy +++ b/dynawaltz-dsl/src/test/resources/warnings/claMissingMeasurement.groovy @@ -10,10 +10,10 @@ package warnings import com.powsybl.iidm.network.TwoSides -CurrentLimitAutomaton { +OverloadManagementSystem { dynamicModelId "CLA_NGEN" parameterSetId "CLA" - controlledQuadripole "NHV1_NHV2_2" + controlledBranch "NHV1_NHV2_2" iMeasurement "NGEN" iMeasurementSide TwoSides.TWO } diff --git a/dynawaltz-dsl/src/test/resources/warnings/claMissingMeasurementSide.groovy b/dynawaltz-dsl/src/test/resources/warnings/claMissingMeasurementSide.groovy index c536f5771..5a9120e09 100644 --- a/dynawaltz-dsl/src/test/resources/warnings/claMissingMeasurementSide.groovy +++ b/dynawaltz-dsl/src/test/resources/warnings/claMissingMeasurementSide.groovy @@ -8,9 +8,9 @@ package warnings -CurrentLimitAutomaton { +OverloadManagementSystem { dynamicModelId "CLA_NGEN" parameterSetId "CLA" - controlledQuadripole "NHV1_NHV2_2" + controlledBranch "NHV1_NHV2_2" iMeasurement "NHV1_NHV2_1" } diff --git a/dynawaltz-dsl/src/test/resources/warnings/tapChangerCompatible.groovy b/dynawaltz-dsl/src/test/resources/warnings/tapChangerCompatible.groovy index fadc96fe4..dedb879b9 100644 --- a/dynawaltz-dsl/src/test/resources/warnings/tapChangerCompatible.groovy +++ b/dynawaltz-dsl/src/test/resources/warnings/tapChangerCompatible.groovy @@ -5,13 +5,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ - package warnings TapChangerBlockingAutomaton { dynamicModelId "ZAB" parameterSetId "ZAB" - uMeasurements "NGEN" + uMeasurements "GEN" transformers "GEN" } diff --git a/dynawaltz-dsl/src/test/resources/warnings/tapChangerMissingBusList.groovy b/dynawaltz-dsl/src/test/resources/warnings/tapChangerMissingBusList.groovy index 036e8aa03..739eb6d00 100644 --- a/dynawaltz-dsl/src/test/resources/warnings/tapChangerMissingBusList.groovy +++ b/dynawaltz-dsl/src/test/resources/warnings/tapChangerMissingBusList.groovy @@ -5,13 +5,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ - package warnings +List[] measurementPoints = [["LOAD", "Wrong_ID"], ["NGEN_NHV1"]] TapChangerBlockingAutomaton { dynamicModelId "ZAB" parameterSetId "ZAB" - uMeasurements ["LOAD", "Wrong_ID"], ["NGEN_NHV1"] + uMeasurements measurementPoints transformers "NGEN_NHV1", "NHV2_NLOAD", "LOAD" } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java index bb2736d3a..927db67a4 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/DynawaltzReports.java @@ -59,7 +59,7 @@ public static void reportDuplicateDynamicId(Reporter reporter, String duplicateI public static void reportEmptyAutomaton(Reporter reporter, String automatonName, String dynamicId, String expectedModels) { reporter.report(Report.builder() .withKey("emptyAutomaton") - .withDefaultMessage("${automatonName} ${dynamicId} equipment is not a ${expectedModels}, the automaton will be skipped") + .withDefaultMessage("${automatonName} ${dynamicId} equipment is not a ${expectedModels}, the automation system will be skipped") .withValue("automatonName", automatonName) .withValue("dynamicId", dynamicId) .withValue("expectedModels", expectedModels) @@ -70,7 +70,7 @@ public static void reportEmptyAutomaton(Reporter reporter, String automatonName, public static void reportEmptyListAutomaton(Reporter reporter, String automatonName, String dynamicId, String expectedModels) { reporter.report(Report.builder() .withKey("emptyListAutomaton") - .withDefaultMessage("None of ${automatonName} ${dynamicId} equipments are ${expectedModels}, the automaton will be skipped") + .withDefaultMessage("None of ${automatonName} ${dynamicId} equipments are ${expectedModels}, the automation system will be skipped") .withValue("automatonName", automatonName) .withValue("dynamicId", dynamicId) .withValue("expectedModels", expectedModels) diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractDynamicModelBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractDynamicModelBuilder.java index eb9949068..35205f032 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractDynamicModelBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractDynamicModelBuilder.java @@ -10,6 +10,8 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.iidm.network.Network; +import java.util.Objects; + /** * @author Laurent Issertial {@literal } */ @@ -20,8 +22,8 @@ public abstract class AbstractDynamicModelBuilder { protected boolean isInstantiable = true; protected AbstractDynamicModelBuilder(Network network, Reporter reporter) { - this.network = network; - this.reporter = reporter; + this.network = Objects.requireNonNull(network); + this.reporter = Objects.requireNonNull(reporter); } protected abstract void checkData(); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractEquipmentModelBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractEquipmentModelBuilder.java index d3fd85281..437440ef2 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractEquipmentModelBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/AbstractEquipmentModelBuilder.java @@ -12,6 +12,8 @@ import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; +import java.util.Objects; + /** * @author Laurent Issertial {@literal } */ @@ -24,7 +26,7 @@ public abstract class AbstractEquipmentModelBuilder, R protected AbstractEquipmentModelBuilder(Network network, ModelConfig modelConfig, IdentifiableType equipmentType, Reporter reporter) { super(network, reporter); - this.modelConfig = modelConfig; + this.modelConfig = Objects.requireNonNull(modelConfig); this.builderEquipment = new BuilderEquipment<>(equipmentType); } @@ -39,6 +41,11 @@ public R staticId(String staticId) { return self(); } + public R equipment(T equipment) { + builderEquipment.addEquipment(equipment, this::checkEquipment); + return self(); + } + public R dynamicModelId(String dynamicModelId) { this.dynamicModelId = dynamicModelId; return self(); @@ -64,6 +71,10 @@ protected void checkData() { protected abstract T findEquipment(String staticId); + protected boolean checkEquipment(T equipment) { + return Objects.equals(network, equipment.getNetwork()); + } + public T getEquipment() { return builderEquipment.getEquipment(); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderEquipment.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderEquipment.java index 119b1271d..1030b2a2a 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderEquipment.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderEquipment.java @@ -12,6 +12,7 @@ import com.powsybl.iidm.network.IdentifiableType; import java.util.function.Function; +import java.util.function.Predicate; /** * Represents an equipment field identified by a static ID in a builder @@ -21,6 +22,11 @@ */ public class BuilderEquipment> { + private static final String DEFAULT_FIELD_NAME = "staticId"; + + private static final String EQUIPMENT_FIELD_NAME = "equipment"; + + protected boolean fromStaticId; protected String staticId; protected T equipment; private final String equipmentType; @@ -37,24 +43,37 @@ public BuilderEquipment(IdentifiableType identifiableType, String fieldName) { } public BuilderEquipment(IdentifiableType identifiableType) { - this(identifiableType, "staticId"); + this(identifiableType, DEFAULT_FIELD_NAME); } public BuilderEquipment(String equipmentType) { - this(equipmentType, "staticId"); + this(equipmentType, DEFAULT_FIELD_NAME); } public void addEquipment(String equipmentId, Function equipmentSupplier) { + fromStaticId = true; staticId = equipmentId; equipment = equipmentSupplier.apply(staticId); } + public void addEquipment(T equipment, Predicate equipmentChecker) { + fromStaticId = false; + staticId = equipment.getId(); + if (equipmentChecker.test(equipment)) { + this.equipment = equipment; + } + } + public boolean checkEquipmentData(Reporter reporter) { if (!hasStaticId()) { Reporters.reportFieldNotSet(reporter, fieldName); return false; } else if (equipment == null) { - Reporters.reportStaticIdUnknown(reporter, fieldName, staticId, equipmentType); + if (fromStaticId) { + Reporters.reportStaticIdUnknown(reporter, fieldName, staticId, equipmentType); + } else { + Reporters.reportDifferentNetwork(reporter, EQUIPMENT_FIELD_NAME, staticId, equipmentType); + } return false; } return true; diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderEquipmentsList.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderEquipmentsList.java new file mode 100644 index 000000000..f69cbbe6d --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderEquipmentsList.java @@ -0,0 +1,86 @@ +/** + * 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.dynawaltz.builders; + +import com.powsybl.commons.reporter.Reporter; +import com.powsybl.iidm.network.Identifiable; +import com.powsybl.iidm.network.IdentifiableType; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.function.Function; + +/** + * @author Laurent Issertial {@literal } + */ +public class BuilderEquipmentsList> { + + private final String equipmentType; + private final String fieldName; + // when set to true equipment ids not found in the network are seen as dynamic ids for automatons and reported as such + private final boolean missingIdsHasDynamicIds; + protected List missingEquipmentIds = new ArrayList<>(); + protected final List equipments = new ArrayList<>(); + + public BuilderEquipmentsList(IdentifiableType identifiableType, String fieldName) { + this(identifiableType.toString(), fieldName, false); + } + + public BuilderEquipmentsList(String equipmentType, String fieldName) { + this(equipmentType, fieldName, false); + } + + public BuilderEquipmentsList(String equipmentType, String fieldName, boolean missingIdsHasDynamicIds) { + this.equipmentType = equipmentType; + this.fieldName = fieldName; + this.missingIdsHasDynamicIds = missingIdsHasDynamicIds; + } + + public void addEquipments(String[] staticIds, Function equipmentsSupplier) { + addEquipments(() -> Arrays.stream(staticIds).iterator(), equipmentsSupplier); + } + + public void addEquipments(Iterable staticIds, Function equipmentsSupplier) { + staticIds.forEach(id -> { + T equipment = equipmentsSupplier.apply(id); + if (equipment != null) { + equipments.add(equipment); + } else { + missingEquipmentIds.add(id); + } + }); + } + + public boolean checkEquipmentData(Reporter reporter) { + boolean emptyList = equipments.isEmpty(); + if (missingEquipmentIds.isEmpty() && emptyList) { + Reporters.reportFieldNotSet(reporter, fieldName); + return false; + } else if (!missingIdsHasDynamicIds) { + missingEquipmentIds.forEach(missingId -> + Reporters.reportStaticIdUnknown(reporter, fieldName, missingId, equipmentType)); + if (emptyList) { + Reporters.reportEmptyList(reporter, fieldName); + } + return !emptyList; + } else { + missingEquipmentIds.forEach(missingId -> + Reporters.reportUnknownStaticIdHandling(reporter, fieldName, missingId, equipmentType)); + return true; + } + } + + public List getEquipments() { + return equipments; + } + + public List getMissingEquipmentIds() { + return missingEquipmentIds; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderIdListEquipmentList.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderIdListEquipmentList.java new file mode 100644 index 000000000..01071cbb1 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuilderIdListEquipmentList.java @@ -0,0 +1,39 @@ +/** + * 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.dynawaltz.builders; + +import com.powsybl.iidm.network.Identifiable; + +import java.util.Collection; +import java.util.Objects; +import java.util.function.Function; + +/** + * @author Laurent Issertial {@literal } + */ +public class BuilderIdListEquipmentList> extends BuilderEquipmentsList { + + public BuilderIdListEquipmentList(String equipmentType, String fieldName) { + super(equipmentType, fieldName); + } + + public void addEquipments(Collection[] staticIdsArray, Function equipmentSupplier) { + for (Collection staticIds : staticIdsArray) { + addEquipment(staticIds, equipmentSupplier); + } + } + + private void addEquipment(Collection staticIds, Function equipmentSupplier) { + staticIds.stream() + .map(equipmentSupplier) + .filter(Objects::nonNull) + .findFirst() + .ifPresentOrElse(equipments::add, + () -> missingEquipmentIds.add(staticIds.toString())); + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuildersUtil.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuildersUtil.java index f10c4bf1a..b6acfaf13 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuildersUtil.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/BuildersUtil.java @@ -8,6 +8,7 @@ package com.powsybl.dynawaltz.builders; import com.powsybl.iidm.network.Identifiable; +import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; /** @@ -15,6 +16,8 @@ */ public final class BuildersUtil { + public static final String MEASUREMENT_POINT_TYPE = IdentifiableType.BUS + "/" + IdentifiableType.BUSBAR_SECTION; + private BuildersUtil() { } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoader.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoader.java index 0fa77d683..2c11d91b6 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoader.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoader.java @@ -24,7 +24,7 @@ public interface ModelConfigLoader { String getModelConfigFileName(); - default Map> loadModelConfigs() { + default Map loadModelConfigs() { try { ObjectMapper objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java index 4b4cb32bc..a2c1bdb06 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderImpl.java @@ -8,13 +8,13 @@ package com.powsybl.dynawaltz.builders; import com.google.auto.service.AutoService; -import com.powsybl.dynawaltz.models.automatons.TapChangerAutomatonBuilder; -import com.powsybl.dynawaltz.models.automatons.TapChangerBlockingAutomatonBuilder; -import com.powsybl.dynawaltz.models.automatons.UnderVoltageAutomatonBuilder; -import com.powsybl.dynawaltz.models.automatons.currentlimits.CurrentLimitAutomatonBuilder; -import com.powsybl.dynawaltz.models.automatons.currentlimits.CurrentLimitTwoLevelsAutomatonBuilder; -import com.powsybl.dynawaltz.models.automatons.phaseshifters.PhaseShifterIAutomatonBuilder; -import com.powsybl.dynawaltz.models.automatons.phaseshifters.PhaseShifterPAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.UnderVoltageAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicOverloadManagementSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicTwoLevelsOverloadManagementSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.phaseshifters.PhaseShifterIAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.phaseshifters.PhaseShifterPAutomationSystemBuilder; import com.powsybl.dynawaltz.models.buses.InfiniteBusBuilder; import com.powsybl.dynawaltz.models.buses.StandardBusBuilder; import com.powsybl.dynawaltz.models.generators.*; @@ -36,13 +36,13 @@ public final class ModelConfigLoaderImpl implements ModelConfigLoader { private static final String MODEL_CONFIG_FILENAME = "models.json"; private static final Stream BUILDER_CONFIGS = Stream.of( - new BuilderConfig(CurrentLimitAutomatonBuilder::of, CurrentLimitAutomatonBuilder::getSupportedLibs), - new BuilderConfig(CurrentLimitTwoLevelsAutomatonBuilder::of, CurrentLimitTwoLevelsAutomatonBuilder::getSupportedLibs), - new BuilderConfig(TapChangerAutomatonBuilder::of, TapChangerAutomatonBuilder::getSupportedLibs), - new BuilderConfig(TapChangerBlockingAutomatonBuilder::of, TapChangerBlockingAutomatonBuilder::getSupportedLibs), - new BuilderConfig(UnderVoltageAutomatonBuilder::of, UnderVoltageAutomatonBuilder::getSupportedLibs), - new BuilderConfig(PhaseShifterPAutomatonBuilder::of, PhaseShifterPAutomatonBuilder::getSupportedLibs), - new BuilderConfig(PhaseShifterIAutomatonBuilder::of, PhaseShifterIAutomatonBuilder::getSupportedLibs), + new BuilderConfig(DynamicOverloadManagementSystemBuilder::of, DynamicOverloadManagementSystemBuilder::getSupportedLibs), + new BuilderConfig(DynamicTwoLevelsOverloadManagementSystemBuilder::of, DynamicTwoLevelsOverloadManagementSystemBuilder::getSupportedLibs), + new BuilderConfig(TapChangerAutomationSystemBuilder::of, TapChangerAutomationSystemBuilder::getSupportedLibs), + new BuilderConfig(TapChangerBlockingAutomationSystemBuilder::of, TapChangerBlockingAutomationSystemBuilder::getSupportedLibs), + new BuilderConfig(UnderVoltageAutomationSystemBuilder::of, UnderVoltageAutomationSystemBuilder::getSupportedLibs), + new BuilderConfig(PhaseShifterPAutomationSystemBuilder::of, PhaseShifterPAutomationSystemBuilder::getSupportedLibs), + new BuilderConfig(PhaseShifterIAutomationSystemBuilder::of, PhaseShifterIAutomationSystemBuilder::getSupportedLibs), new BuilderConfig(StandardBusBuilder::of, StandardBusBuilder::getSupportedLibs), new BuilderConfig(InfiniteBusBuilder::of, InfiniteBusBuilder::getSupportedLibs), new BuilderConfig(TransformerFixedRatioBuilder::of, TransformerFixedRatioBuilder::getSupportedLibs), diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigs.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigs.java index f139af128..87c866562 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigs.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigs.java @@ -7,55 +7,55 @@ */ package com.powsybl.dynawaltz.builders; -import com.google.common.collect.Lists; -import com.powsybl.dynawaltz.models.events.EventActivePowerVariationBuilder; -import com.powsybl.dynawaltz.models.events.EventDisconnectionBuilder; -import com.powsybl.dynawaltz.models.events.NodeFaultEventBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.ServiceLoader; +import java.util.Objects; +import java.util.Set; /** * @author Laurent Issertial {@literal } */ -public final class ModelConfigs { - - private static final ModelConfigs INSTANCE = new ModelConfigs(); - - private final List modelConfigLoaders; - private final Map> modelConfigsMap = new HashMap<>(); - private final List builderConfigs; - private final List eventBuilderConfigs = List.of( - new EventBuilderConfig(EventActivePowerVariationBuilder::of, EventActivePowerVariationBuilder.TAG), - new EventBuilderConfig(EventDisconnectionBuilder::of, EventDisconnectionBuilder.TAG), - new EventBuilderConfig(NodeFaultEventBuilder::of, NodeFaultEventBuilder.TAG)); - - private ModelConfigs() { - modelConfigLoaders = Lists.newArrayList(ServiceLoader.load(ModelConfigLoader.class)); - modelConfigLoaders.forEach(l -> l.loadModelConfigs().forEach( - (cat, modelsMap) -> modelConfigsMap.merge(cat, modelsMap, (map1, map2) -> { - map1.putAll(map2); - return map1; - }) - )); - builderConfigs = modelConfigLoaders.stream().flatMap(ModelConfigLoader::loadBuilderConfigs).toList(); +public class ModelConfigs { + + private static final Logger LOGGER = LoggerFactory.getLogger(ModelConfigs.class); + + private ModelConfig defaultModelConfig; + private final Map modelConfigMap; + + ModelConfigs(Map modelConfigMap, String defaultModelConfigName) { + this.modelConfigMap = Objects.requireNonNull(modelConfigMap); + if (defaultModelConfigName != null) { + this.defaultModelConfig = Objects.requireNonNull(modelConfigMap.get(defaultModelConfigName)); + } + } + + public boolean hasDefaultModelConfig() { + return defaultModelConfig != null; } - public static ModelConfigs getInstance() { - return INSTANCE; + public ModelConfig getDefaultModelConfig() { + return defaultModelConfig; } - public Map getModelConfigs(String categoryName) { - return modelConfigsMap.get(categoryName); + public ModelConfig getModelConfig(String libName) { + return modelConfigMap.get(libName); } - public List getBuilderConfigs() { - return builderConfigs; + public Set getSupportedLibs() { + return modelConfigMap.keySet(); } - public List getEventBuilderConfigs() { - return eventBuilderConfigs; + void addModelConfigs(ModelConfigs modelConfigsToMerge) { + modelConfigMap.putAll(modelConfigsToMerge.modelConfigMap); + if (hasDefaultModelConfig() && modelConfigsToMerge.hasDefaultModelConfig()) { + LOGGER.warn("Default model configs {} & {} found, the first one will be kept", + defaultModelConfig.lib(), + modelConfigsToMerge.getDefaultModelConfig().lib()); + } else if (!hasDefaultModelConfig()) { + defaultModelConfig = modelConfigsToMerge.defaultModelConfig; + } + modelConfigMap.putAll(modelConfigsToMerge.modelConfigMap); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsHandler.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsHandler.java new file mode 100644 index 000000000..284938126 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsHandler.java @@ -0,0 +1,61 @@ +/** + * 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.dynawaltz.builders; + +import com.google.common.collect.Lists; +import com.powsybl.dynawaltz.models.events.EventActivePowerVariationBuilder; +import com.powsybl.dynawaltz.models.events.EventDisconnectionBuilder; +import com.powsybl.dynawaltz.models.events.NodeFaultEventBuilder; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ServiceLoader; + +/** + * @author Laurent Issertial {@literal } + */ +public final class ModelConfigsHandler { + + private static final ModelConfigsHandler INSTANCE = new ModelConfigsHandler(); + + private final Map modelConfigsCat = new HashMap<>(); + + private final List builderConfigs; + private final List eventBuilderConfigs = List.of( + new EventBuilderConfig(EventActivePowerVariationBuilder::of, EventActivePowerVariationBuilder.TAG), + new EventBuilderConfig(EventDisconnectionBuilder::of, EventDisconnectionBuilder.TAG), + new EventBuilderConfig(NodeFaultEventBuilder::of, NodeFaultEventBuilder.TAG)); + + private ModelConfigsHandler() { + List modelConfigLoaders = Lists.newArrayList(ServiceLoader.load(ModelConfigLoader.class)); + modelConfigLoaders.forEach(l -> l.loadModelConfigs().forEach( + (cat, modelsMap) -> modelConfigsCat.merge(cat, modelsMap, (configs1, configs2) -> { + configs1.addModelConfigs(configs2); + return configs1; + }) + )); + builderConfigs = modelConfigLoaders.stream().flatMap(ModelConfigLoader::loadBuilderConfigs).toList(); + } + + public static ModelConfigsHandler getInstance() { + return INSTANCE; + } + + public ModelConfigs getModelConfigs(String categoryName) { + return modelConfigsCat.get(categoryName); + } + + public List getBuilderConfigs() { + return builderConfigs; + } + + public List getEventBuilderConfigs() { + return eventBuilderConfigs; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsJsonDeserializer.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsJsonDeserializer.java index 6b44844a4..31536a9f4 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsJsonDeserializer.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/ModelConfigsJsonDeserializer.java @@ -20,15 +20,15 @@ /** * @author Laurent Issertial {@literal } */ -public class ModelConfigsJsonDeserializer extends StdDeserializer>> { +public class ModelConfigsJsonDeserializer extends StdDeserializer> { public ModelConfigsJsonDeserializer() { super(Map.class); } @Override - public Map> deserialize(JsonParser parser, DeserializationContext context) throws IOException { - Map> configMap = new HashMap<>(); + public Map deserialize(JsonParser parser, DeserializationContext context) throws IOException { + Map configMap = new HashMap<>(); while (parser.nextToken() != JsonToken.END_OBJECT) { String category = parser.getCurrentName(); parser.nextToken(); @@ -37,9 +37,28 @@ public Map> deserialize(JsonParser parser, Dese return configMap; } - private Map deserializeModelConfigs(JsonParser parser) throws IOException { - Map configs = new LinkedHashMap<>(); + private ModelConfigs deserializeModelConfigs(JsonParser parser) throws IOException { + String defaultLib = null; + Map libs = null; + while (parser.nextToken() != JsonToken.END_OBJECT) { + switch (parser.getCurrentName()) { + case "defaultLib": + defaultLib = parser.getValueAsString(); + break; + case "libs": + libs = deserializeLibsMap(parser); + break; + default: + throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); + } + } + return new ModelConfigs(libs, defaultLib); + } + + private Map deserializeLibsMap(JsonParser parser) throws IOException { + Map libs = new HashMap<>(); while (parser.nextToken() != JsonToken.END_ARRAY) { + parser.nextToken(); String lib = null; String alias = null; String internalModelPrefix = null; @@ -63,9 +82,9 @@ private Map deserializeModelConfigs(JsonParser parser) thro } } ModelConfig modelConfig = new ModelConfig(lib, alias, internalModelPrefix, properties); - configs.put(modelConfig.name(), modelConfig); + libs.put(modelConfig.name(), modelConfig); } - return configs; + return libs; } private List deserializeProperties(JsonParser parser) throws IOException { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/Reporters.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/Reporters.java index 08fc8a29e..3e8ac3941 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/Reporters.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/builders/Reporters.java @@ -72,14 +72,36 @@ public static void reportFieldNotSet(Reporter reporter, String fieldName) { public static void reportStaticIdUnknown(Reporter reporter, String fieldName, String staticId, String equipmentType) { reporter.report(Report.builder() - .withKey("staticIdUnknown") + .withKey("unknownStaticIdToDynamic") .withDefaultMessage("'${fieldName}' field value '${staticId}' not found for equipment type(s) ${equipmentType}") .withValue("equipmentType", equipmentType) - .withValue(FIELD_NAME, fieldName).withValue("staticId", staticId) + .withValue(FIELD_NAME, fieldName) + .withValue("staticId", staticId) + .withSeverity(TypedValue.WARN_SEVERITY) + .build()); + } + + public static void reportDifferentNetwork(Reporter reporter, String fieldName, String staticId, String equipmentType) { + reporter.report(Report.builder() + .withKey("wrongNetwork") + .withDefaultMessage("'${fieldName}' field value ${equipmentType} ${staticId} does not belong to the builder network") + .withValue("equipmentType", equipmentType) + .withValue(FIELD_NAME, fieldName) + .withValue("staticId", staticId) .withSeverity(TypedValue.WARN_SEVERITY) .build()); } + public static void reportUnknownStaticIdHandling(Reporter reporter, String fieldName, String staticId, String equipmentType) { + reporter.report(Report.builder() + .withKey("staticIdUnknown") + .withDefaultMessage("'${fieldName}' field value '${staticId}' not found for equipment type(s) ${equipmentType}, id will be used as pure dynamic model id") + .withValue("equipmentType", equipmentType) + .withValue(FIELD_NAME, fieldName).withValue("staticId", staticId) + .withSeverity(TypedValue.INFO_SEVERITY) + .build()); + } + public static void reportCrossThreshold(Reporter reporter, String fieldName, double fieldValue, String threshold) { reporter.report(Report.builder() .withKey("crossThreshold") diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/AbstractPureDynamicBlackBoxModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/AbstractPureDynamicBlackBoxModel.java index 26a8231e7..c22f40400 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/AbstractPureDynamicBlackBoxModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/AbstractPureDynamicBlackBoxModel.java @@ -16,7 +16,7 @@ import static com.powsybl.dynawaltz.xml.DynaWaltzXmlConstants.DYN_URI; /** - * Superclass for automaton and event black box models (model without IIDM static id) + * Superclass for automation system and event black box models (model without IIDM static id) * @author Florian Dupuy {@literal } * @author Laurent Issertial {@literal } */ diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/AbstractAutomatonModelBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/AbstractAutomationSystemModelBuilder.java similarity index 76% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/AbstractAutomatonModelBuilder.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/AbstractAutomationSystemModelBuilder.java index 4abfb9117..b33ae3736 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/AbstractAutomatonModelBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/AbstractAutomationSystemModelBuilder.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons; +package com.powsybl.dynawaltz.models.automationsystems; import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynamicsimulation.DynamicModel; @@ -15,18 +15,20 @@ import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; +import java.util.Objects; + /** * @author Laurent Issertial {@literal } */ -public abstract class AbstractAutomatonModelBuilder> extends AbstractDynamicModelBuilder implements ModelBuilder { +public abstract class AbstractAutomationSystemModelBuilder> extends AbstractDynamicModelBuilder implements ModelBuilder { protected String dynamicModelId; protected String parameterSetId; protected final ModelConfig modelConfig; - protected AbstractAutomatonModelBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { + protected AbstractAutomationSystemModelBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { super(network, reporter); - this.modelConfig = modelConfig; + this.modelConfig = Objects.requireNonNull(modelConfig); } public T dynamicModelId(String dynamicModelId) { @@ -46,7 +48,7 @@ protected void checkData() { isInstantiable = false; } if (parameterSetId == null) { - Reporters.reportFieldNotSet(reporter, "dynamicModelId"); + Reporters.reportFieldNotSet(reporter, "parameterSetId"); isInstantiable = false; } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/QuadripoleModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/BranchModel.java similarity index 86% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/QuadripoleModel.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/BranchModel.java index bafd17e32..23f414582 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/QuadripoleModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/BranchModel.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons; +package com.powsybl.dynawaltz.models.automationsystems; import com.powsybl.dynawaltz.models.Model; import com.powsybl.iidm.network.TwoSides; @@ -13,7 +13,7 @@ /** * @author Laurent Issertial {@literal } */ -public interface QuadripoleModel extends Model { +public interface BranchModel extends Model { String getIVarName(TwoSides side); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerAutomationSystem.java similarity index 90% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomaton.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerAutomationSystem.java index 238a9d956..e5634d7d2 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerAutomationSystem.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons; +package com.powsybl.dynawaltz.models.automationsystems; import com.powsybl.dynawaltz.DynawaltzReports; import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; @@ -24,7 +24,7 @@ /** * @author Laurent Issertial {@literal } */ -public class TapChangerAutomaton extends AbstractPureDynamicBlackBoxModel implements TapChangerModel { +public class TapChangerAutomationSystem extends AbstractPureDynamicBlackBoxModel implements TapChangerModel { private final Load load; private final TransformerSide side; @@ -37,7 +37,7 @@ private enum ConnectionState { NOT_SET } - protected TapChangerAutomaton(String dynamicModelId, String parameterSetId, Load load, TransformerSide side, String lib) { + protected TapChangerAutomationSystem(String dynamicModelId, String parameterSetId, Load load, TransformerSide side, String lib) { super(dynamicModelId, parameterSetId, lib); this.load = Objects.requireNonNull(load); this.side = Objects.requireNonNull(side); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerAutomationSystemBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerAutomationSystemBuilder.java new file mode 100644 index 000000000..0e8c79102 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerAutomationSystemBuilder.java @@ -0,0 +1,85 @@ +/** + * 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 com.powsybl.dynawaltz.models.automationsystems; + +import com.powsybl.commons.reporter.Reporter; +import com.powsybl.dynawaltz.builders.*; +import com.powsybl.dynawaltz.models.TransformerSide; +import com.powsybl.iidm.network.IdentifiableType; +import com.powsybl.iidm.network.Load; +import com.powsybl.iidm.network.Network; + +import java.util.Set; + +/** + * @author Laurent Issertial {@literal } + */ +public class TapChangerAutomationSystemBuilder extends AbstractAutomationSystemModelBuilder { + + private static final String CATEGORY = "tapChangers"; + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + + protected final BuilderEquipment load; + protected TransformerSide side = TransformerSide.NONE; + + public static TapChangerAutomationSystemBuilder of(Network network) { + return of(network, Reporter.NO_OP); + } + + public static TapChangerAutomationSystemBuilder of(Network network, Reporter reporter) { + return new TapChangerAutomationSystemBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); + } + + public static TapChangerAutomationSystemBuilder of(Network network, String lib) { + return of(network, lib, Reporter.NO_OP); + } + + public static TapChangerAutomationSystemBuilder of(Network network, String lib, Reporter reporter) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); + if (modelConfig == null) { + Reporters.reportLibNotFound(reporter, TapChangerAutomationSystemBuilder.class.getSimpleName(), lib); + return null; + } + return new TapChangerAutomationSystemBuilder(network, modelConfig, reporter); + } + + public static Set getSupportedLibs() { + return MODEL_CONFIGS.getSupportedLibs(); + } + + protected TapChangerAutomationSystemBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { + super(network, modelConfig, reporter); + load = new BuilderEquipment<>(IdentifiableType.LOAD); + } + + public TapChangerAutomationSystemBuilder staticId(String staticId) { + load.addEquipment(staticId, network::getLoad); + return self(); + } + + public TapChangerAutomationSystemBuilder side(TransformerSide side) { + this.side = side; + return self(); + } + + @Override + protected void checkData() { + super.checkData(); + isInstantiable &= load.checkEquipmentData(reporter); + } + + @Override + public TapChangerAutomationSystem build() { + return isInstantiable() ? new TapChangerAutomationSystem(dynamicModelId, parameterSetId, load.getEquipment(), side, getLib()) : null; + } + + @Override + protected TapChangerAutomationSystemBuilder self() { + return this; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerBlockingAutomationSystem.java similarity index 72% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomaton.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerBlockingAutomationSystem.java index 4aee1f5c6..42c5586ca 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerBlockingAutomationSystem.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons; +package com.powsybl.dynawaltz.models.automationsystems; import com.powsybl.commons.PowsyblException; import com.powsybl.dynawaltz.DynawaltzReports; @@ -17,8 +17,6 @@ import com.powsybl.dynawaltz.models.transformers.TapChangerModel; import com.powsybl.iidm.network.Identifiable; import com.powsybl.iidm.network.IdentifiableType; -import com.powsybl.iidm.network.Load; -import com.powsybl.iidm.network.TwoWindingsTransformer; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; @@ -27,31 +25,29 @@ /** * @author Laurent Issertial {@literal } */ -public class TapChangerBlockingAutomaton extends AbstractPureDynamicBlackBoxModel { +public class TapChangerBlockingAutomationSystem extends AbstractPureDynamicBlackBoxModel { private static final Set COMPATIBLE_EQUIPMENTS = EnumSet.of(IdentifiableType.LOAD, IdentifiableType.TWO_WINDINGS_TRANSFORMER); private static final int MAX_MEASUREMENTS = 5; - private final List transformers; - private final List loadsWithTransformer; + private final List> tapChangerEquipments; private final List tapChangerAutomatonIds; private final List> uMeasurements; private boolean isConnected = true; - protected TapChangerBlockingAutomaton(String dynamicModelId, String parameterSetId, List transformers, List loadsWithTransformer, List tapChangerAutomatonIds, List> uMeasurements, String lib) { + protected TapChangerBlockingAutomationSystem(String dynamicModelId, String parameterSetId, List> tapChangerEquipments, List tapChangerAutomatonIds, List> uMeasurements, String lib) { super(dynamicModelId, parameterSetId, lib); - this.transformers = Objects.requireNonNull(transformers); - this.loadsWithTransformer = Objects.requireNonNull(loadsWithTransformer); + this.tapChangerEquipments = Objects.requireNonNull(tapChangerEquipments); this.tapChangerAutomatonIds = Objects.requireNonNull(tapChangerAutomatonIds); this.uMeasurements = Objects.requireNonNull(uMeasurements); - if (transformers.isEmpty() && loadsWithTransformer.isEmpty() && tapChangerAutomatonIds.isEmpty()) { + if (tapChangerEquipments.isEmpty() && tapChangerAutomatonIds.isEmpty()) { throw new PowsyblException("No Tap changers to monitor"); } if (uMeasurements.isEmpty()) { throw new PowsyblException("No measurement points"); } if (uMeasurements.size() > MAX_MEASUREMENTS) { - throw new PowsyblException("Tap changer blocking automaton can only handle " + MAX_MEASUREMENTS + " measurement points at the same time"); + throw new PowsyblException("Tap changer blocking automation system can only handle " + MAX_MEASUREMENTS + " measurement points at the same time"); } } @@ -71,13 +67,9 @@ public String getLib() { @Override public void createMacroConnections(MacroConnectionsAdder adder) { - for (TwoWindingsTransformer transformer : transformers) { - adder.createMacroConnections(this, transformer, TapChangerModel.class, this::getVarConnectionsWith); - } int skippedTapChangers = 0; - for (Load load : loadsWithTransformer) { - boolean isSkipped = adder.createMacroConnectionsOrSkip(this, load, TapChangerModel.class, this::getVarConnectionsWith); - if (isSkipped) { + for (Identifiable tc : tapChangerEquipments) { + if (adder.createMacroConnectionsOrSkip(this, tc, TapChangerModel.class, this::getVarConnectionsWith)) { skippedTapChangers++; } } @@ -86,7 +78,7 @@ public void createMacroConnections(MacroConnectionsAdder adder) { skippedTapChangers++; } } - if (!transformers.isEmpty() || skippedTapChangers < (loadsWithTransformer.size() + tapChangerAutomatonIds.size())) { + if (skippedTapChangers < (tapChangerEquipments.size() + tapChangerAutomatonIds.size())) { int i = 1; for (Identifiable measurement : uMeasurements) { adder.createMacroConnections(this, measurement, ActionConnectionPoint.class, this::getVarConnectionsWith, MeasurementPointSuffix.of(i)); @@ -103,7 +95,6 @@ private List getVarConnectionsWith(TapChangerModel connected) { } private List getVarConnectionsWith(ActionConnectionPoint connected, String suffix) { - return connected.getUImpinVarName() .map(uImpinVarName -> List.of(new VarConnection("tapChangerBlocking_UMonitored" + suffix, uImpinVarName))) .orElse(Collections.emptyList()); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerBlockingAutomationSystemBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerBlockingAutomationSystemBuilder.java new file mode 100644 index 000000000..85c698864 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/TapChangerBlockingAutomationSystemBuilder.java @@ -0,0 +1,109 @@ +/** + * 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 com.powsybl.dynawaltz.models.automationsystems; + +import com.powsybl.commons.reporter.Reporter; +import com.powsybl.dynawaltz.builders.*; +import com.powsybl.iidm.network.*; + +import java.util.*; + +import static com.powsybl.dynawaltz.builders.BuildersUtil.MEASUREMENT_POINT_TYPE; + +/** + * @author Laurent Issertial {@literal } + */ +public class TapChangerBlockingAutomationSystemBuilder extends AbstractAutomationSystemModelBuilder { + + private static final String CATEGORY = "tcbs"; + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + private static final String TAP_CHANGER_TYPE = IdentifiableType.TWO_WINDINGS_TRANSFORMER + "/" + IdentifiableType.LOAD; + private static final String U_MEASUREMENTS_FIELD = "uMeasurements"; + private static final String TRANSFORMER_FIELD = "transformers"; + + private final BuilderEquipmentsList> tapChangerEquipments; + private final BuilderIdListEquipmentList> uMeasurementPoints; + + public static TapChangerBlockingAutomationSystemBuilder of(Network network) { + return of(network, Reporter.NO_OP); + } + + public static TapChangerBlockingAutomationSystemBuilder of(Network network, Reporter reporter) { + return new TapChangerBlockingAutomationSystemBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); + } + + public static TapChangerBlockingAutomationSystemBuilder of(Network network, String lib) { + return of(network, lib, Reporter.NO_OP); + } + + public static TapChangerBlockingAutomationSystemBuilder of(Network network, String lib, Reporter reporter) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); + if (modelConfig == null) { + Reporters.reportLibNotFound(reporter, TapChangerBlockingAutomationSystemBuilder.class.getSimpleName(), lib); + return null; + } + return new TapChangerBlockingAutomationSystemBuilder(network, modelConfig, reporter); + } + + public static Set getSupportedLibs() { + return MODEL_CONFIGS.getSupportedLibs(); + } + + protected TapChangerBlockingAutomationSystemBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { + super(network, modelConfig, reporter); + tapChangerEquipments = new BuilderEquipmentsList<>(TAP_CHANGER_TYPE, TRANSFORMER_FIELD, true); + uMeasurementPoints = new BuilderIdListEquipmentList<>(MEASUREMENT_POINT_TYPE, U_MEASUREMENTS_FIELD); + } + + public TapChangerBlockingAutomationSystemBuilder transformers(String... staticIds) { + tapChangerEquipments.addEquipments(staticIds, id -> this.getTapChangerEquipment(network, id)); + return self(); + } + + public TapChangerBlockingAutomationSystemBuilder transformers(Collection staticIds) { + tapChangerEquipments.addEquipments(staticIds, id -> this.getTapChangerEquipment(network, id)); + return self(); + } + + private Identifiable getTapChangerEquipment(Network network, String staticId) { + Identifiable tapChangerEquipment = network.getTwoWindingsTransformer(staticId); + return tapChangerEquipment != null ? tapChangerEquipment : network.getLoad(staticId); + } + + public TapChangerBlockingAutomationSystemBuilder uMeasurements(String... staticIds) { + uMeasurementPoints.addEquipments(staticIds, id -> BuildersUtil.getActionConnectionPoint(network, id)); + return self(); + } + + public TapChangerBlockingAutomationSystemBuilder uMeasurements(Collection staticIds) { + uMeasurementPoints.addEquipments(staticIds, id -> BuildersUtil.getActionConnectionPoint(network, id)); + return self(); + } + + public TapChangerBlockingAutomationSystemBuilder uMeasurements(Collection[] staticIdsArray) { + uMeasurementPoints.addEquipments(staticIdsArray, id -> BuildersUtil.getActionConnectionPoint(network, id)); + return self(); + } + + @Override + protected void checkData() { + super.checkData(); + isInstantiable &= tapChangerEquipments.checkEquipmentData(reporter); + isInstantiable &= uMeasurementPoints.checkEquipmentData(reporter); + } + + @Override + public TapChangerBlockingAutomationSystem build() { + return isInstantiable() ? new TapChangerBlockingAutomationSystem(dynamicModelId, parameterSetId, tapChangerEquipments.getEquipments(), tapChangerEquipments.getMissingEquipmentIds(), uMeasurementPoints.getEquipments(), getLib()) : null; + } + + @Override + protected TapChangerBlockingAutomationSystemBuilder self() { + return this; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/UnderVoltageAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/UnderVoltageAutomationSystem.java similarity index 84% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/UnderVoltageAutomaton.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/UnderVoltageAutomationSystem.java index bc1fd4055..f4bd33b07 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/UnderVoltageAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/UnderVoltageAutomationSystem.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons; +package com.powsybl.dynawaltz.models.automationsystems; import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; import com.powsybl.dynawaltz.models.VarConnection; @@ -20,11 +20,11 @@ /** * @author Laurent Issertial {@literal } */ -public class UnderVoltageAutomaton extends AbstractPureDynamicBlackBoxModel { +public class UnderVoltageAutomationSystem extends AbstractPureDynamicBlackBoxModel { protected final Generator generator; - protected UnderVoltageAutomaton(String dynamicModelId, String parameterSetId, Generator generator, String lib) { + protected UnderVoltageAutomationSystem(String dynamicModelId, String parameterSetId, Generator generator, String lib) { super(dynamicModelId, parameterSetId, lib); this.generator = Objects.requireNonNull(generator); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/UnderVoltageAutomatonBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/UnderVoltageAutomationSystemBuilder.java similarity index 51% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/UnderVoltageAutomatonBuilder.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/UnderVoltageAutomationSystemBuilder.java index 9ba96db9c..a8811d251 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/UnderVoltageAutomatonBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/UnderVoltageAutomationSystemBuilder.java @@ -5,61 +5,61 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons; +package com.powsybl.dynawaltz.models.automationsystems; import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.BuilderEquipment; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Generator; import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** * @author Laurent Issertial {@literal } */ -public class UnderVoltageAutomatonBuilder extends AbstractAutomatonModelBuilder { +public class UnderVoltageAutomationSystemBuilder extends AbstractAutomationSystemModelBuilder { private static final String CATEGORY = "underVoltages"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); protected final BuilderEquipment generator; - public static UnderVoltageAutomatonBuilder of(Network network) { + public static UnderVoltageAutomationSystemBuilder of(Network network) { return of(network, Reporter.NO_OP); } - public static UnderVoltageAutomatonBuilder of(Network network, Reporter reporter) { - return new UnderVoltageAutomatonBuilder(network, LIBS.values().iterator().next(), reporter); + public static UnderVoltageAutomationSystemBuilder of(Network network, Reporter reporter) { + return new UnderVoltageAutomationSystemBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } - public static UnderVoltageAutomatonBuilder of(Network network, String lib) { + public static UnderVoltageAutomationSystemBuilder of(Network network, String lib) { return of(network, lib, Reporter.NO_OP); } - public static UnderVoltageAutomatonBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + public static UnderVoltageAutomationSystemBuilder of(Network network, String lib, Reporter reporter) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { - Reporters.reportLibNotFound(reporter, UnderVoltageAutomatonBuilder.class.getSimpleName(), lib); + Reporters.reportLibNotFound(reporter, UnderVoltageAutomationSystemBuilder.class.getSimpleName(), lib); return null; } - return new UnderVoltageAutomatonBuilder(network, LIBS.get(lib), reporter); + return new UnderVoltageAutomationSystemBuilder(network, MODEL_CONFIGS.getModelConfig(lib), reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } - protected UnderVoltageAutomatonBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { + protected UnderVoltageAutomationSystemBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { super(network, modelConfig, reporter); generator = new BuilderEquipment<>(IdentifiableType.GENERATOR, "generator"); } - public UnderVoltageAutomatonBuilder generator(String staticId) { + public UnderVoltageAutomationSystemBuilder generator(String staticId) { generator.addEquipment(staticId, network::getGenerator); return self(); } @@ -71,12 +71,12 @@ protected void checkData() { } @Override - public UnderVoltageAutomaton build() { - return isInstantiable() ? new UnderVoltageAutomaton(dynamicModelId, parameterSetId, generator.getEquipment(), getLib()) : null; + public UnderVoltageAutomationSystem build() { + return isInstantiable() ? new UnderVoltageAutomationSystem(dynamicModelId, parameterSetId, generator.getEquipment(), getLib()) : null; } @Override - protected UnderVoltageAutomatonBuilder self() { + protected UnderVoltageAutomationSystemBuilder self() { return this; } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/AbstractCurrentLimitAutomatonBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/AbstractOverloadManagementSystemBuilder.java similarity index 70% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/AbstractCurrentLimitAutomatonBuilder.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/AbstractOverloadManagementSystemBuilder.java index 6e90500c9..3df825d9c 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/AbstractCurrentLimitAutomatonBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/AbstractOverloadManagementSystemBuilder.java @@ -5,13 +5,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons.currentlimits; +package com.powsybl.dynawaltz.models.automationsystems.overloadmanagments; import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.BuilderEquipment; import com.powsybl.dynawaltz.builders.ModelConfig; import com.powsybl.dynawaltz.builders.Reporters; -import com.powsybl.dynawaltz.models.automatons.AbstractAutomatonModelBuilder; +import com.powsybl.dynawaltz.models.automationsystems.AbstractAutomationSystemModelBuilder; import com.powsybl.iidm.network.Branch; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.TwoSides; @@ -19,21 +19,21 @@ /** * @author Laurent Issertial {@literal } */ -public abstract class AbstractCurrentLimitAutomatonBuilder> extends AbstractAutomatonModelBuilder { +public abstract class AbstractOverloadManagementSystemBuilder> extends AbstractAutomationSystemModelBuilder { - protected static final String QUADRIPOLE_TYPE = "Quadripole"; + protected static final String BRANCH_TYPE = "BRANCH"; protected final BuilderEquipment> iMeasurement; protected TwoSides iMeasurementSide; protected final BuilderEquipment> controlledEquipment; - protected AbstractCurrentLimitAutomatonBuilder(Network network, ModelConfig modelConfig, Reporter reporter, BuilderEquipment> iMeasurement, BuilderEquipment> controlledEquipment) { + protected AbstractOverloadManagementSystemBuilder(Network network, ModelConfig modelConfig, Reporter reporter, BuilderEquipment> iMeasurement, BuilderEquipment> controlledEquipment) { super(network, modelConfig, reporter); this.iMeasurement = iMeasurement; this.controlledEquipment = controlledEquipment; } - public T controlledQuadripole(String staticId) { + public T controlledBranch(String staticId) { controlledEquipment.addEquipment(staticId, network::getBranch); return self(); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicOverloadManagementSystem.java similarity index 59% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitAutomaton.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicOverloadManagementSystem.java index 18fc69936..3b94ed32a 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicOverloadManagementSystem.java @@ -4,11 +4,11 @@ * 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.dynawaltz.models.automatons.currentlimits; +package com.powsybl.dynawaltz.models.automationsystems.overloadmanagments; import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; import com.powsybl.dynawaltz.models.VarConnection; -import com.powsybl.dynawaltz.models.automatons.QuadripoleModel; +import com.powsybl.dynawaltz.models.automationsystems.BranchModel; import com.powsybl.dynawaltz.models.macroconnections.MacroConnectionsAdder; import com.powsybl.dynawaltz.models.utils.SideUtils; import com.powsybl.iidm.network.Branch; @@ -22,36 +22,36 @@ * @author Marcos de Miguel {@literal } * @author Laurent Issertial {@literal } */ -public class CurrentLimitAutomaton extends AbstractPureDynamicBlackBoxModel { +public class DynamicOverloadManagementSystem extends AbstractPureDynamicBlackBoxModel { protected static final String MEASURE_SUFFIX = "Measure"; protected static final String CONTROL_SUFFIX = "Control"; - protected final Branch measuredQuadripole; + protected final Branch measuredBranch; protected final TwoSides measuredSide; - protected final Branch controlledQuadripole; + protected final Branch controlledBranch; - protected CurrentLimitAutomaton(String dynamicModelId, String parameterSetId, Branch measuredQuadripole, TwoSides measuredSide, Branch controlledQuadripole, String lib) { + protected DynamicOverloadManagementSystem(String dynamicModelId, String parameterSetId, Branch measuredBranch, TwoSides measuredSide, Branch controlledBranch, String lib) { super(dynamicModelId, parameterSetId, lib); - this.measuredQuadripole = Objects.requireNonNull(measuredQuadripole); + this.measuredBranch = Objects.requireNonNull(measuredBranch); this.measuredSide = Objects.requireNonNull(measuredSide); - this.controlledQuadripole = Objects.requireNonNull(controlledQuadripole); + this.controlledBranch = Objects.requireNonNull(controlledBranch); } @Override public void createMacroConnections(MacroConnectionsAdder adder) { - adder.createMacroConnections(this, measuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithMeasuredQuadripole, MEASURE_SUFFIX + SideUtils.getSideSuffix(measuredSide)); - adder.createMacroConnections(this, controlledQuadripole, QuadripoleModel.class, this::getVarConnectionsWithControlledQuadripole, CONTROL_SUFFIX); + adder.createMacroConnections(this, measuredBranch, BranchModel.class, this::getVarConnectionsWithMeasuredBranch, MEASURE_SUFFIX + SideUtils.getSideSuffix(measuredSide)); + adder.createMacroConnections(this, controlledBranch, BranchModel.class, this::getVarConnectionsWithControlledBranch, CONTROL_SUFFIX); } - private List getVarConnectionsWithMeasuredQuadripole(QuadripoleModel connected) { + private List getVarConnectionsWithMeasuredBranch(BranchModel connected) { return Arrays.asList( new VarConnection("currentLimitAutomaton_IMonitored", connected.getIVarName(measuredSide)), new VarConnection("currentLimitAutomaton_AutomatonExists", connected.getDeactivateCurrentLimitsVarName()) ); } - protected List getVarConnectionsWithControlledQuadripole(QuadripoleModel connected) { + protected List getVarConnectionsWithControlledBranch(BranchModel connected) { return List.of(new VarConnection("currentLimitAutomaton_order", connected.getStateVarName())); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicOverloadManagementSystemBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicOverloadManagementSystemBuilder.java new file mode 100644 index 000000000..28e7f6d09 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicOverloadManagementSystemBuilder.java @@ -0,0 +1,80 @@ +/** + * 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 com.powsybl.dynawaltz.models.automationsystems.overloadmanagments; + +import com.powsybl.commons.reporter.Reporter; +import com.powsybl.dynawaltz.builders.BuilderEquipment; +import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; +import com.powsybl.dynawaltz.builders.ModelConfigs; +import com.powsybl.dynawaltz.builders.Reporters; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.TwoSides; + +import java.util.Set; + +/** + * @author Laurent Issertial {@literal } + */ +public class DynamicOverloadManagementSystemBuilder extends AbstractOverloadManagementSystemBuilder { + + private static final String CATEGORY = "overloadManagements"; + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + + public static DynamicOverloadManagementSystemBuilder of(Network network) { + return of(network, Reporter.NO_OP); + } + + public static DynamicOverloadManagementSystemBuilder of(Network network, Reporter reporter) { + return new DynamicOverloadManagementSystemBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); + } + + public static DynamicOverloadManagementSystemBuilder of(Network network, String lib) { + return of(network, lib, Reporter.NO_OP); + } + + public static DynamicOverloadManagementSystemBuilder of(Network network, String lib, Reporter reporter) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); + if (modelConfig == null) { + Reporters.reportLibNotFound(reporter, DynamicOverloadManagementSystemBuilder.class.getSimpleName(), lib); + return null; + } + return new DynamicOverloadManagementSystemBuilder(network, modelConfig, reporter); + } + + public static Set getSupportedLibs() { + return MODEL_CONFIGS.getSupportedLibs(); + } + + protected DynamicOverloadManagementSystemBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { + super(network, modelConfig, reporter, new BuilderEquipment<>(BRANCH_TYPE, "iMeasurement"), + new BuilderEquipment<>(BRANCH_TYPE, "controlledBranch")); + } + + public DynamicOverloadManagementSystemBuilder iMeasurement(String staticId) { + iMeasurement.addEquipment(staticId, network::getBranch); + return self(); + } + + public DynamicOverloadManagementSystemBuilder iMeasurementSide(TwoSides side) { + this.iMeasurementSide = side; + return self(); + } + + @Override + public DynamicOverloadManagementSystem build() { + return isInstantiable() ? new DynamicOverloadManagementSystem(dynamicModelId, parameterSetId, + iMeasurement.getEquipment(), iMeasurementSide, controlledEquipment.getEquipment(), getLib()) + : null; + } + + @Override + protected DynamicOverloadManagementSystemBuilder self() { + return this; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitTwoLevelsAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicTwoLevelsOverloadManagementSystem.java similarity index 54% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitTwoLevelsAutomaton.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicTwoLevelsOverloadManagementSystem.java index 4582e1037..c3c358a03 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitTwoLevelsAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicTwoLevelsOverloadManagementSystem.java @@ -5,10 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons.currentlimits; +package com.powsybl.dynawaltz.models.automationsystems.overloadmanagments; import com.powsybl.dynawaltz.models.VarConnection; -import com.powsybl.dynawaltz.models.automatons.QuadripoleModel; +import com.powsybl.dynawaltz.models.automationsystems.BranchModel; import com.powsybl.dynawaltz.models.macroconnections.MacroConnectionsAdder; import com.powsybl.dynawaltz.models.utils.SideUtils; import com.powsybl.iidm.network.Branch; @@ -21,35 +21,35 @@ /** * @author Laurent Issertial {@literal } */ -public class CurrentLimitTwoLevelsAutomaton extends CurrentLimitAutomaton { +public class DynamicTwoLevelsOverloadManagementSystem extends DynamicOverloadManagementSystem { protected static final String FIRST_MEASURE_SUFFIX = MEASURE_SUFFIX + "1"; protected static final String SECOND_MEASURE_SUFFIX = MEASURE_SUFFIX + "2"; - private final Branch secondMeasuredQuadripole; + private final Branch secondMeasuredBranch; private final TwoSides secondMeasuredSide; - protected CurrentLimitTwoLevelsAutomaton(String dynamicModelId, String parameterSetId, Branch measuredQuadripole, TwoSides measuredSide, Branch secondMeasuredQuadripole, TwoSides secondMeasuredSide, Branch controlledQuadripole, String lib) { - super(dynamicModelId, parameterSetId, measuredQuadripole, measuredSide, controlledQuadripole, lib); - this.secondMeasuredQuadripole = Objects.requireNonNull(secondMeasuredQuadripole); + protected DynamicTwoLevelsOverloadManagementSystem(String dynamicModelId, String parameterSetId, Branch measuredBranch, TwoSides measuredSide, Branch secondMeasuredBranch, TwoSides secondMeasuredSide, Branch controlledBranch, String lib) { + super(dynamicModelId, parameterSetId, measuredBranch, measuredSide, controlledBranch, lib); + this.secondMeasuredBranch = Objects.requireNonNull(secondMeasuredBranch); this.secondMeasuredSide = Objects.requireNonNull(secondMeasuredSide); } @Override public void createMacroConnections(MacroConnectionsAdder adder) { - adder.createMacroConnections(this, measuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithFirstMeasuredQuadripole, FIRST_MEASURE_SUFFIX + SideUtils.getSideSuffix(measuredSide)); - adder.createMacroConnections(this, secondMeasuredQuadripole, QuadripoleModel.class, this::getVarConnectionsWithSecondMeasuredQuadripole, SECOND_MEASURE_SUFFIX + SideUtils.getSideSuffix(secondMeasuredSide)); - adder.createMacroConnections(this, controlledQuadripole, QuadripoleModel.class, this::getVarConnectionsWithControlledQuadripole, CONTROL_SUFFIX); + adder.createMacroConnections(this, measuredBranch, BranchModel.class, this::getVarConnectionsWithFirstMeasuredBranch, FIRST_MEASURE_SUFFIX + SideUtils.getSideSuffix(measuredSide)); + adder.createMacroConnections(this, secondMeasuredBranch, BranchModel.class, this::getVarConnectionsWithSecondMeasuredBranch, SECOND_MEASURE_SUFFIX + SideUtils.getSideSuffix(secondMeasuredSide)); + adder.createMacroConnections(this, controlledBranch, BranchModel.class, this::getVarConnectionsWithControlledBranch, CONTROL_SUFFIX); } - private List getVarConnectionsWithFirstMeasuredQuadripole(QuadripoleModel connected) { + private List getVarConnectionsWithFirstMeasuredBranch(BranchModel connected) { return Arrays.asList( new VarConnection("currentLimitAutomaton_IMonitored1", connected.getIVarName(measuredSide)), new VarConnection("currentLimitAutomaton_AutomatonExists", connected.getDeactivateCurrentLimitsVarName()) ); } - private List getVarConnectionsWithSecondMeasuredQuadripole(QuadripoleModel connected) { + private List getVarConnectionsWithSecondMeasuredBranch(BranchModel connected) { return List.of(new VarConnection("currentLimitAutomaton_IMonitored2", connected.getIVarName(secondMeasuredSide))); } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicTwoLevelsOverloadManagementSystemBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicTwoLevelsOverloadManagementSystemBuilder.java new file mode 100644 index 000000000..47c384fac --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/overloadmanagments/DynamicTwoLevelsOverloadManagementSystemBuilder.java @@ -0,0 +1,106 @@ +/** + * 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 com.powsybl.dynawaltz.models.automationsystems.overloadmanagments; + +import com.powsybl.commons.reporter.Reporter; +import com.powsybl.dynawaltz.builders.BuilderEquipment; +import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; +import com.powsybl.dynawaltz.builders.ModelConfigs; +import com.powsybl.dynawaltz.builders.Reporters; +import com.powsybl.iidm.network.Branch; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.TwoSides; + +import java.util.Set; + +/** + * @author Laurent Issertial {@literal } + */ +public class DynamicTwoLevelsOverloadManagementSystemBuilder extends AbstractOverloadManagementSystemBuilder { + + private static final String CATEGORY = "twoLevelsOverloadManagements"; + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + + protected final BuilderEquipment> iMeasurement2; + protected TwoSides iMeasurement2Side; + + public static DynamicTwoLevelsOverloadManagementSystemBuilder of(Network network) { + return of(network, Reporter.NO_OP); + } + + public static DynamicTwoLevelsOverloadManagementSystemBuilder of(Network network, Reporter reporter) { + return new DynamicTwoLevelsOverloadManagementSystemBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); + } + + public static DynamicTwoLevelsOverloadManagementSystemBuilder of(Network network, String lib) { + return of(network, lib, Reporter.NO_OP); + } + + public static DynamicTwoLevelsOverloadManagementSystemBuilder of(Network network, String lib, Reporter reporter) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); + if (modelConfig == null) { + Reporters.reportLibNotFound(reporter, DynamicTwoLevelsOverloadManagementSystemBuilder.class.getSimpleName(), lib); + return null; + } + return new DynamicTwoLevelsOverloadManagementSystemBuilder(network, modelConfig, reporter); + } + + public static Set getSupportedLibs() { + return MODEL_CONFIGS.getSupportedLibs(); + } + + protected DynamicTwoLevelsOverloadManagementSystemBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { + super(network, modelConfig, reporter, new BuilderEquipment<>(BRANCH_TYPE, "iMeasurement1"), + new BuilderEquipment<>(BRANCH_TYPE, "controlledBranch1")); + iMeasurement2 = new BuilderEquipment<>(BRANCH_TYPE, "iMeasurement2"); + } + + public DynamicTwoLevelsOverloadManagementSystemBuilder iMeasurement1(String staticId) { + iMeasurement.addEquipment(staticId, network::getBranch); + return self(); + } + + public DynamicTwoLevelsOverloadManagementSystemBuilder iMeasurement1Side(TwoSides side) { + this.iMeasurementSide = side; + return self(); + } + + public DynamicTwoLevelsOverloadManagementSystemBuilder iMeasurement2(String staticId) { + iMeasurement2.addEquipment(staticId, network::getBranch); + return self(); + } + + public DynamicTwoLevelsOverloadManagementSystemBuilder iMeasurement2Side(TwoSides side) { + this.iMeasurement2Side = side; + return self(); + } + + @Override + protected void checkData() { + super.checkData(); + isInstantiable &= iMeasurement2.checkEquipmentData(reporter); + if (iMeasurement2Side == null) { + Reporters.reportFieldNotSet(reporter, "iMeasurement2Side"); + isInstantiable = false; + } + } + + @Override + public DynamicTwoLevelsOverloadManagementSystem build() { + return isInstantiable() ? new DynamicTwoLevelsOverloadManagementSystem(dynamicModelId, parameterSetId, + iMeasurement.getEquipment(), iMeasurementSide, iMeasurement2.getEquipment(), iMeasurement2Side, + controlledEquipment.getEquipment(), getLib()) + : null; + } + + @Override + protected DynamicTwoLevelsOverloadManagementSystemBuilder self() { + return this; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/AbstractPhaseShifterAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/AbstractPhaseShifterAutomationSystem.java similarity index 79% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/AbstractPhaseShifterAutomaton.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/AbstractPhaseShifterAutomationSystem.java index 6b0d0e8c1..3dbbb4d3c 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/AbstractPhaseShifterAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/AbstractPhaseShifterAutomationSystem.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons.phaseshifters; +package com.powsybl.dynawaltz.models.automationsystems.phaseshifters; import com.powsybl.dynawaltz.models.AbstractPureDynamicBlackBoxModel; import com.powsybl.dynawaltz.models.VarConnection; @@ -19,11 +19,11 @@ /** * @author Laurent Issertial {@literal } */ -public abstract class AbstractPhaseShifterAutomaton extends AbstractPureDynamicBlackBoxModel { +public abstract class AbstractPhaseShifterAutomationSystem extends AbstractPureDynamicBlackBoxModel { protected final TwoWindingsTransformer transformer; - protected AbstractPhaseShifterAutomaton(String dynamicModelId, TwoWindingsTransformer transformer, String parameterSetId, String lib) { + protected AbstractPhaseShifterAutomationSystem(String dynamicModelId, TwoWindingsTransformer transformer, String parameterSetId, String lib) { super(dynamicModelId, parameterSetId, lib); this.transformer = Objects.requireNonNull(transformer); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/AbstractPhaseShifterModelBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/AbstractPhaseShifterModelBuilder.java similarity index 85% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/AbstractPhaseShifterModelBuilder.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/AbstractPhaseShifterModelBuilder.java index ea754d624..47f20e7a7 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/AbstractPhaseShifterModelBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/AbstractPhaseShifterModelBuilder.java @@ -5,12 +5,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons.phaseshifters; +package com.powsybl.dynawaltz.models.automationsystems.phaseshifters; import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.BuilderEquipment; import com.powsybl.dynawaltz.builders.ModelConfig; -import com.powsybl.dynawaltz.models.automatons.AbstractAutomatonModelBuilder; +import com.powsybl.dynawaltz.models.automationsystems.AbstractAutomationSystemModelBuilder; import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.TwoWindingsTransformer; @@ -18,7 +18,7 @@ /** * @author Laurent Issertial {@literal } */ -abstract class AbstractPhaseShifterModelBuilder> extends AbstractAutomatonModelBuilder { +abstract class AbstractPhaseShifterModelBuilder> extends AbstractAutomationSystemModelBuilder { protected final BuilderEquipment transformer; diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterIAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterIAutomationSystem.java similarity index 80% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterIAutomaton.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterIAutomationSystem.java index faec221c4..39acdbac1 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterIAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterIAutomationSystem.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons.phaseshifters; +package com.powsybl.dynawaltz.models.automationsystems.phaseshifters; import com.powsybl.dynawaltz.models.VarConnection; import com.powsybl.dynawaltz.models.transformers.TransformerModel; @@ -17,9 +17,9 @@ /** * @author Laurent Issertial {@literal } */ -public class PhaseShifterIAutomaton extends AbstractPhaseShifterAutomaton { +public class PhaseShifterIAutomationSystem extends AbstractPhaseShifterAutomationSystem { - protected PhaseShifterIAutomaton(String dynamicModelId, TwoWindingsTransformer transformer, String parameterSetId, String lib) { + protected PhaseShifterIAutomationSystem(String dynamicModelId, TwoWindingsTransformer transformer, String parameterSetId, String lib) { super(dynamicModelId, transformer, parameterSetId, lib); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterIAutomationSystemBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterIAutomationSystemBuilder.java new file mode 100644 index 000000000..0d9dcaa22 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterIAutomationSystemBuilder.java @@ -0,0 +1,65 @@ +/** + * 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 com.powsybl.dynawaltz.models.automationsystems.phaseshifters; + +import com.powsybl.commons.reporter.Reporter; +import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; +import com.powsybl.dynawaltz.builders.ModelConfigs; +import com.powsybl.dynawaltz.builders.Reporters; +import com.powsybl.iidm.network.Network; + +import java.util.Set; + +/** + * @author Laurent Issertial {@literal } + */ +public class PhaseShifterIAutomationSystemBuilder extends AbstractPhaseShifterModelBuilder { + + private static final String CATEGORY = "phaseShiftersI"; + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + + public static PhaseShifterIAutomationSystemBuilder of(Network network) { + return of(network, Reporter.NO_OP); + } + + public static PhaseShifterIAutomationSystemBuilder of(Network network, Reporter reporter) { + return new PhaseShifterIAutomationSystemBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); + } + + public static PhaseShifterIAutomationSystemBuilder of(Network network, String lib) { + return of(network, lib, Reporter.NO_OP); + } + + public static PhaseShifterIAutomationSystemBuilder of(Network network, String lib, Reporter reporter) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); + if (modelConfig == null) { + Reporters.reportLibNotFound(reporter, PhaseShifterIAutomationSystemBuilder.class.getSimpleName(), lib); + return null; + } + return new PhaseShifterIAutomationSystemBuilder(network, modelConfig, reporter); + } + + public static Set getSupportedLibs() { + return MODEL_CONFIGS.getSupportedLibs(); + } + + protected PhaseShifterIAutomationSystemBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { + super(network, modelConfig, reporter); + } + + @Override + public PhaseShifterIAutomationSystem build() { + return isInstantiable() ? new PhaseShifterIAutomationSystem(dynamicModelId, transformer.getEquipment(), parameterSetId, getLib()) : null; + } + + @Override + protected PhaseShifterIAutomationSystemBuilder self() { + return this; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterPAutomaton.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterPAutomationSystem.java similarity index 78% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterPAutomaton.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterPAutomationSystem.java index 6e487f79a..0ab779fe1 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterPAutomaton.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterPAutomationSystem.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * SPDX-License-Identifier: MPL-2.0 */ -package com.powsybl.dynawaltz.models.automatons.phaseshifters; +package com.powsybl.dynawaltz.models.automationsystems.phaseshifters; import com.powsybl.dynawaltz.models.VarConnection; import com.powsybl.dynawaltz.models.transformers.TransformerModel; @@ -17,9 +17,9 @@ /** * @author Laurent Issertial {@literal } */ -public class PhaseShifterPAutomaton extends AbstractPhaseShifterAutomaton { +public class PhaseShifterPAutomationSystem extends AbstractPhaseShifterAutomationSystem { - protected PhaseShifterPAutomaton(String dynamicModelId, TwoWindingsTransformer transformer, String parameterSetId, String lib) { + protected PhaseShifterPAutomationSystem(String dynamicModelId, TwoWindingsTransformer transformer, String parameterSetId, String lib) { super(dynamicModelId, transformer, parameterSetId, lib); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterPAutomationSystemBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterPAutomationSystemBuilder.java new file mode 100644 index 000000000..08661ef81 --- /dev/null +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automationsystems/phaseshifters/PhaseShifterPAutomationSystemBuilder.java @@ -0,0 +1,65 @@ +/** + * 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 com.powsybl.dynawaltz.models.automationsystems.phaseshifters; + +import com.powsybl.commons.reporter.Reporter; +import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; +import com.powsybl.dynawaltz.builders.ModelConfigs; +import com.powsybl.dynawaltz.builders.Reporters; +import com.powsybl.iidm.network.Network; + +import java.util.Set; + +/** + * @author Laurent Issertial {@literal } + */ +public class PhaseShifterPAutomationSystemBuilder extends AbstractPhaseShifterModelBuilder { + + private static final String CATEGORY = "phaseShiftersP"; + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); + + public static PhaseShifterPAutomationSystemBuilder of(Network network) { + return of(network, Reporter.NO_OP); + } + + public static PhaseShifterPAutomationSystemBuilder of(Network network, Reporter reporter) { + return new PhaseShifterPAutomationSystemBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); + } + + public static PhaseShifterPAutomationSystemBuilder of(Network network, String lib) { + return of(network, lib, Reporter.NO_OP); + } + + public static PhaseShifterPAutomationSystemBuilder of(Network network, String lib, Reporter reporter) { + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); + if (modelConfig == null) { + Reporters.reportLibNotFound(reporter, PhaseShifterPAutomationSystemBuilder.class.getSimpleName(), lib); + return null; + } + return new PhaseShifterPAutomationSystemBuilder(network, modelConfig, reporter); + } + + public static Set getSupportedLibs() { + return MODEL_CONFIGS.getSupportedLibs(); + } + + protected PhaseShifterPAutomationSystemBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { + super(network, modelConfig, reporter); + } + + @Override + public PhaseShifterPAutomationSystem build() { + return isInstantiable() ? new PhaseShifterPAutomationSystem(dynamicModelId, transformer.getEquipment(), parameterSetId, getLib()) : null; + } + + @Override + protected PhaseShifterPAutomationSystemBuilder self() { + return this; + } +} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomatonBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomatonBuilder.java deleted file mode 100644 index ce105ad45..000000000 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerAutomatonBuilder.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * 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 com.powsybl.dynawaltz.models.automatons; - -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.dynawaltz.builders.BuilderEquipment; -import com.powsybl.dynawaltz.builders.ModelConfig; -import com.powsybl.dynawaltz.builders.ModelConfigs; -import com.powsybl.dynawaltz.builders.Reporters; -import com.powsybl.dynawaltz.models.TransformerSide; -import com.powsybl.iidm.network.IdentifiableType; -import com.powsybl.iidm.network.Load; -import com.powsybl.iidm.network.Network; - -import java.util.Map; -import java.util.Set; - -/** - * @author Laurent Issertial {@literal } - */ -public class TapChangerAutomatonBuilder extends AbstractAutomatonModelBuilder { - - private static final String CATEGORY = "tapChangers"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); - - protected final BuilderEquipment load; - protected TransformerSide side = TransformerSide.NONE; - - public static TapChangerAutomatonBuilder of(Network network) { - return of(network, Reporter.NO_OP); - } - - public static TapChangerAutomatonBuilder of(Network network, Reporter reporter) { - return new TapChangerAutomatonBuilder(network, LIBS.values().iterator().next(), reporter); - } - - public static TapChangerAutomatonBuilder of(Network network, String lib) { - return of(network, lib, Reporter.NO_OP); - } - - public static TapChangerAutomatonBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); - if (modelConfig == null) { - Reporters.reportLibNotFound(reporter, TapChangerAutomatonBuilder.class.getSimpleName(), lib); - return null; - } - return new TapChangerAutomatonBuilder(network, LIBS.get(lib), reporter); - } - - public static Set getSupportedLibs() { - return LIBS.keySet(); - } - - protected TapChangerAutomatonBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { - super(network, modelConfig, reporter); - load = new BuilderEquipment<>(IdentifiableType.LOAD); - } - - public TapChangerAutomatonBuilder staticId(String staticId) { - load.addEquipment(staticId, network::getLoad); - return self(); - } - - public TapChangerAutomatonBuilder side(TransformerSide side) { - this.side = side; - return self(); - } - - @Override - protected void checkData() { - super.checkData(); - isInstantiable &= load.checkEquipmentData(reporter); - } - - @Override - public TapChangerAutomaton build() { - return isInstantiable() ? new TapChangerAutomaton(dynamicModelId, parameterSetId, load.getEquipment(), side, getLib()) : null; - } - - @Override - protected TapChangerAutomatonBuilder self() { - return this; - } -} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomatonBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomatonBuilder.java deleted file mode 100644 index acaa7aeed..000000000 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/TapChangerBlockingAutomatonBuilder.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * 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 com.powsybl.dynawaltz.models.automatons; - -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.dynawaltz.builders.BuildersUtil; -import com.powsybl.dynawaltz.builders.ModelConfig; -import com.powsybl.dynawaltz.builders.ModelConfigs; -import com.powsybl.dynawaltz.builders.Reporters; -import com.powsybl.iidm.network.Identifiable; -import com.powsybl.iidm.network.Load; -import com.powsybl.iidm.network.Network; -import com.powsybl.iidm.network.TwoWindingsTransformer; - -import java.util.*; - -/** - * @author Laurent Issertial {@literal } - */ -public class TapChangerBlockingAutomatonBuilder extends AbstractAutomatonModelBuilder { - - private static final String CATEGORY = "tcbs"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); - private static final String U_MEASUREMENTS_FIELD = "uMeasurements"; - - private final List loads = new ArrayList<>(); - private final List transformers = new ArrayList<>(); - private final List tapChangerAutomatonIds = new ArrayList<>(); - private List> uMeasurements; - - public static TapChangerBlockingAutomatonBuilder of(Network network) { - return of(network, Reporter.NO_OP); - } - - public static TapChangerBlockingAutomatonBuilder of(Network network, Reporter reporter) { - return new TapChangerBlockingAutomatonBuilder(network, LIBS.values().iterator().next(), reporter); - } - - public static TapChangerBlockingAutomatonBuilder of(Network network, String lib) { - return of(network, lib, Reporter.NO_OP); - } - - public static TapChangerBlockingAutomatonBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); - if (modelConfig == null) { - Reporters.reportLibNotFound(reporter, TapChangerBlockingAutomatonBuilder.class.getSimpleName(), lib); - return null; - } - return new TapChangerBlockingAutomatonBuilder(network, LIBS.get(lib), reporter); - } - - public static Set getSupportedLibs() { - return LIBS.keySet(); - } - - protected TapChangerBlockingAutomatonBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { - super(network, modelConfig, reporter); - } - - public TapChangerBlockingAutomatonBuilder transformers(String... staticIds) { - Arrays.stream(staticIds).forEach(id -> { - Identifiable equipment = network.getIdentifiable(id); - if (equipment == null) { - tapChangerAutomatonIds.add(id); - } else { - switch (equipment.getType()) { - case LOAD -> loads.add((Load) equipment); - case TWO_WINDINGS_TRANSFORMER -> transformers.add((TwoWindingsTransformer) equipment); - default -> Reporters.reportStaticIdUnknown(reporter, U_MEASUREMENTS_FIELD, id, "LOAD/TWO_WINDINGS_TRANSFORMER"); - } - } - }); - return self(); - } - - public TapChangerBlockingAutomatonBuilder uMeasurements(String... staticIds) { - uMeasurements = new ArrayList<>(); - for (String staticId : staticIds) { - Identifiable measurementPoint = BuildersUtil.getActionConnectionPoint(network, staticId); - if (measurementPoint == null) { - Reporters.reportStaticIdUnknown(reporter, U_MEASUREMENTS_FIELD, staticId, "BUS/BUSBAR_SECTION"); - } else { - uMeasurements.add(measurementPoint); - } - } - return self(); - } - - public TapChangerBlockingAutomatonBuilder uMeasurements(List[] staticIdsArray) { - uMeasurements = new ArrayList<>(); - for (List staticIds : staticIdsArray) { - for (String staticId : staticIds) { - Identifiable measurementPoint = BuildersUtil.getActionConnectionPoint(network, staticId); - if (measurementPoint == null) { - Reporters.reportStaticIdUnknown(reporter, U_MEASUREMENTS_FIELD, staticId, "BUS/BUSBAR_SECTION"); - } else { - uMeasurements.add(measurementPoint); - break; - } - } - } - return self(); - } - - @Override - protected void checkData() { - if (uMeasurements == null) { - Reporters.reportFieldNotSet(reporter, U_MEASUREMENTS_FIELD); - isInstantiable = false; - } else if (uMeasurements.isEmpty()) { - Reporters.reportEmptyList(reporter, U_MEASUREMENTS_FIELD); - isInstantiable = false; - } - if (loads.isEmpty() && transformers.isEmpty() && tapChangerAutomatonIds.isEmpty()) { - Reporters.reportEmptyList(reporter, "transformers"); - isInstantiable = false; - } - } - - @Override - public TapChangerBlockingAutomaton build() { - return isInstantiable() ? new TapChangerBlockingAutomaton(dynamicModelId, parameterSetId, transformers, loads, tapChangerAutomatonIds, uMeasurements, getLib()) : null; - } - - @Override - protected TapChangerBlockingAutomatonBuilder self() { - return this; - } -} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitAutomatonBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitAutomatonBuilder.java deleted file mode 100644 index f3a941edb..000000000 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitAutomatonBuilder.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * 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 com.powsybl.dynawaltz.models.automatons.currentlimits; - -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.dynawaltz.builders.BuilderEquipment; -import com.powsybl.dynawaltz.builders.ModelConfig; -import com.powsybl.dynawaltz.builders.ModelConfigs; -import com.powsybl.dynawaltz.builders.Reporters; -import com.powsybl.iidm.network.Network; -import com.powsybl.iidm.network.TwoSides; - -import java.util.Map; -import java.util.Set; - -/** - * @author Laurent Issertial {@literal } - */ -public class CurrentLimitAutomatonBuilder extends AbstractCurrentLimitAutomatonBuilder { - - private static final String CATEGORY = "clas"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); - - public static CurrentLimitAutomatonBuilder of(Network network) { - return of(network, Reporter.NO_OP); - } - - public static CurrentLimitAutomatonBuilder of(Network network, Reporter reporter) { - return new CurrentLimitAutomatonBuilder(network, LIBS.values().iterator().next(), reporter); - } - - public static CurrentLimitAutomatonBuilder of(Network network, String lib) { - return of(network, lib, Reporter.NO_OP); - } - - public static CurrentLimitAutomatonBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); - if (modelConfig == null) { - Reporters.reportLibNotFound(reporter, CurrentLimitAutomatonBuilder.class.getSimpleName(), lib); - return null; - } - return new CurrentLimitAutomatonBuilder(network, LIBS.get(lib), reporter); - } - - public static Set getSupportedLibs() { - return LIBS.keySet(); - } - - protected CurrentLimitAutomatonBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { - super(network, modelConfig, reporter, new BuilderEquipment<>(QUADRIPOLE_TYPE, "iMeasurement"), - new BuilderEquipment<>(QUADRIPOLE_TYPE, "controlledQuadripole")); - } - - public CurrentLimitAutomatonBuilder iMeasurement(String staticId) { - iMeasurement.addEquipment(staticId, network::getBranch); - return self(); - } - - public CurrentLimitAutomatonBuilder iMeasurementSide(TwoSides side) { - this.iMeasurementSide = side; - return self(); - } - - @Override - public CurrentLimitAutomaton build() { - return isInstantiable() ? new CurrentLimitAutomaton(dynamicModelId, parameterSetId, - iMeasurement.getEquipment(), iMeasurementSide, controlledEquipment.getEquipment(), getLib()) - : null; - } - - @Override - protected CurrentLimitAutomatonBuilder self() { - return this; - } -} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitTwoLevelsAutomatonBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitTwoLevelsAutomatonBuilder.java deleted file mode 100644 index 891f17b48..000000000 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/currentlimits/CurrentLimitTwoLevelsAutomatonBuilder.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * 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 com.powsybl.dynawaltz.models.automatons.currentlimits; - -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.dynawaltz.builders.BuilderEquipment; -import com.powsybl.dynawaltz.builders.ModelConfig; -import com.powsybl.dynawaltz.builders.ModelConfigs; -import com.powsybl.dynawaltz.builders.Reporters; -import com.powsybl.iidm.network.Branch; -import com.powsybl.iidm.network.Network; -import com.powsybl.iidm.network.TwoSides; - -import java.util.Map; -import java.util.Set; - -/** - * @author Laurent Issertial {@literal } - */ -public class CurrentLimitTwoLevelsAutomatonBuilder extends AbstractCurrentLimitAutomatonBuilder { - - private static final String CATEGORY = "clasTwoLevels"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); - - protected final BuilderEquipment> iMeasurement2; - protected TwoSides iMeasurement2Side; - - public static CurrentLimitTwoLevelsAutomatonBuilder of(Network network) { - return of(network, Reporter.NO_OP); - } - - public static CurrentLimitTwoLevelsAutomatonBuilder of(Network network, Reporter reporter) { - return new CurrentLimitTwoLevelsAutomatonBuilder(network, LIBS.values().iterator().next(), reporter); - } - - public static CurrentLimitTwoLevelsAutomatonBuilder of(Network network, String lib) { - return of(network, lib, Reporter.NO_OP); - } - - public static CurrentLimitTwoLevelsAutomatonBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); - if (modelConfig == null) { - Reporters.reportLibNotFound(reporter, CurrentLimitTwoLevelsAutomatonBuilder.class.getSimpleName(), lib); - return null; - } - return new CurrentLimitTwoLevelsAutomatonBuilder(network, LIBS.get(lib), reporter); - } - - public static Set getSupportedLibs() { - return LIBS.keySet(); - } - - protected CurrentLimitTwoLevelsAutomatonBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { - super(network, modelConfig, reporter, new BuilderEquipment<>(QUADRIPOLE_TYPE, "iMeasurement1"), - new BuilderEquipment<>(QUADRIPOLE_TYPE, "controlledQuadripole1")); - iMeasurement2 = new BuilderEquipment<>(QUADRIPOLE_TYPE, "iMeasurement2"); - } - - public CurrentLimitTwoLevelsAutomatonBuilder iMeasurement1(String staticId) { - iMeasurement.addEquipment(staticId, network::getBranch); - return self(); - } - - public CurrentLimitTwoLevelsAutomatonBuilder iMeasurement1Side(TwoSides side) { - this.iMeasurementSide = side; - return self(); - } - - public CurrentLimitTwoLevelsAutomatonBuilder iMeasurement2(String staticId) { - iMeasurement2.addEquipment(staticId, network::getBranch); - return self(); - } - - public CurrentLimitTwoLevelsAutomatonBuilder iMeasurement2Side(TwoSides side) { - this.iMeasurement2Side = side; - return self(); - } - - @Override - protected void checkData() { - super.checkData(); - isInstantiable &= iMeasurement2.checkEquipmentData(reporter); - if (iMeasurement2Side == null) { - Reporters.reportFieldNotSet(reporter, "iMeasurement2Side"); - isInstantiable = false; - } - } - - @Override - public CurrentLimitTwoLevelsAutomaton build() { - return isInstantiable() ? new CurrentLimitTwoLevelsAutomaton(dynamicModelId, parameterSetId, - iMeasurement.getEquipment(), iMeasurementSide, iMeasurement2.getEquipment(), iMeasurement2Side, - controlledEquipment.getEquipment(), getLib()) - : null; - } - - @Override - protected CurrentLimitTwoLevelsAutomatonBuilder self() { - return this; - } -} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterIAutomatonBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterIAutomatonBuilder.java deleted file mode 100644 index f5b932a6c..000000000 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterIAutomatonBuilder.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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 com.powsybl.dynawaltz.models.automatons.phaseshifters; - -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.dynawaltz.builders.ModelConfig; -import com.powsybl.dynawaltz.builders.ModelConfigs; -import com.powsybl.dynawaltz.builders.Reporters; -import com.powsybl.iidm.network.Network; - -import java.util.Map; -import java.util.Set; - -/** - * @author Laurent Issertial {@literal } - */ -public class PhaseShifterIAutomatonBuilder extends AbstractPhaseShifterModelBuilder { - - private static final String CATEGORY = "phaseShiftersI"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); - - public static PhaseShifterIAutomatonBuilder of(Network network) { - return of(network, Reporter.NO_OP); - } - - public static PhaseShifterIAutomatonBuilder of(Network network, Reporter reporter) { - return new PhaseShifterIAutomatonBuilder(network, LIBS.values().iterator().next(), reporter); - } - - public static PhaseShifterIAutomatonBuilder of(Network network, String lib) { - return of(network, lib, Reporter.NO_OP); - } - - public static PhaseShifterIAutomatonBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); - if (modelConfig == null) { - Reporters.reportLibNotFound(reporter, PhaseShifterIAutomatonBuilder.class.getSimpleName(), lib); - return null; - } - return new PhaseShifterIAutomatonBuilder(network, LIBS.get(lib), reporter); - } - - public static Set getSupportedLibs() { - return LIBS.keySet(); - } - - protected PhaseShifterIAutomatonBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { - super(network, modelConfig, reporter); - } - - @Override - public PhaseShifterIAutomaton build() { - return isInstantiable() ? new PhaseShifterIAutomaton(dynamicModelId, transformer.getEquipment(), parameterSetId, getLib()) : null; - } - - @Override - protected PhaseShifterIAutomatonBuilder self() { - return this; - } -} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterPAutomatonBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterPAutomatonBuilder.java deleted file mode 100644 index 9fb22c389..000000000 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/automatons/phaseshifters/PhaseShifterPAutomatonBuilder.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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 com.powsybl.dynawaltz.models.automatons.phaseshifters; - -import com.powsybl.commons.reporter.Reporter; -import com.powsybl.dynawaltz.builders.ModelConfig; -import com.powsybl.dynawaltz.builders.ModelConfigs; -import com.powsybl.dynawaltz.builders.Reporters; -import com.powsybl.iidm.network.Network; - -import java.util.Map; -import java.util.Set; - -/** - * @author Laurent Issertial {@literal } - */ -public class PhaseShifterPAutomatonBuilder extends AbstractPhaseShifterModelBuilder { - - private static final String CATEGORY = "phaseShiftersP"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); - - public static PhaseShifterPAutomatonBuilder of(Network network) { - return of(network, Reporter.NO_OP); - } - - public static PhaseShifterPAutomatonBuilder of(Network network, Reporter reporter) { - return new PhaseShifterPAutomatonBuilder(network, LIBS.values().iterator().next(), reporter); - } - - public static PhaseShifterPAutomatonBuilder of(Network network, String lib) { - return of(network, lib, Reporter.NO_OP); - } - - public static PhaseShifterPAutomatonBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); - if (modelConfig == null) { - Reporters.reportLibNotFound(reporter, PhaseShifterPAutomatonBuilder.class.getSimpleName(), lib); - return null; - } - return new PhaseShifterPAutomatonBuilder(network, LIBS.get(lib), reporter); - } - - public static Set getSupportedLibs() { - return LIBS.keySet(); - } - - protected PhaseShifterPAutomatonBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { - super(network, modelConfig, reporter); - } - - @Override - public PhaseShifterPAutomaton build() { - return isInstantiable() ? new PhaseShifterPAutomaton(dynamicModelId, transformer.getEquipment(), parameterSetId, getLib()) : null; - } - - @Override - protected PhaseShifterPAutomatonBuilder self() { - return this; - } -} diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/InfiniteBusBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/InfiniteBusBuilder.java index 610e13a68..f55f0eb60 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/InfiniteBusBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/InfiniteBusBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class InfiniteBusBuilder extends AbstractBusBuilder { private static final String CATEGORY = "infiniteBuses"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static InfiniteBusBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static InfiniteBusBuilder of(Network network, Reporter reporter) { - return new InfiniteBusBuilder(network, LIBS.values().iterator().next(), reporter); + return new InfiniteBusBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static InfiniteBusBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static InfiniteBusBuilder of(Network network, String lib) { } public static InfiniteBusBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, InfiniteBusBuilder.class.getSimpleName(), lib); return null; } - return new InfiniteBusBuilder(network, LIBS.get(lib), reporter); + return new InfiniteBusBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected InfiniteBusBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/StandardBusBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/StandardBusBuilder.java index 63afa77d1..953b5205b 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/StandardBusBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/buses/StandardBusBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class StandardBusBuilder extends AbstractBusBuilder { private static final String CATEGORY = "baseBuses"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static StandardBusBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static StandardBusBuilder of(Network network, Reporter reporter) { - return new StandardBusBuilder(network, LIBS.values().iterator().next(), reporter); + return new StandardBusBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static StandardBusBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static StandardBusBuilder of(Network network, String lib) { } public static StandardBusBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, StandardBusBuilder.class.getSimpleName(), lib); return null; } - return new StandardBusBuilder(network, LIBS.get(lib), reporter); + return new StandardBusBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected StandardBusBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventQuadripoleDisconnection.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventBranchDisconnection.java similarity index 63% rename from dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventQuadripoleDisconnection.java rename to dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventBranchDisconnection.java index 0186d170c..7dcda04f2 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventQuadripoleDisconnection.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventBranchDisconnection.java @@ -7,10 +7,11 @@ package com.powsybl.dynawaltz.models.events; import com.powsybl.dynawaltz.models.VarConnection; -import com.powsybl.dynawaltz.models.automatons.QuadripoleModel; +import com.powsybl.dynawaltz.models.automationsystems.BranchModel; import com.powsybl.dynawaltz.models.macroconnections.MacroConnectionsAdder; import com.powsybl.dynawaltz.parameters.ParametersSet; import com.powsybl.iidm.network.Branch; +import com.powsybl.iidm.network.TwoSides; import java.util.List; @@ -21,30 +22,33 @@ * @author Marcos de Miguel {@literal } * @author Laurent Issertial {@literal } */ -public class EventQuadripoleDisconnection extends AbstractEvent { +public class EventBranchDisconnection extends AbstractEvent { - private final boolean disconnectOrigin; - private final boolean disconnectExtremity; + private final TwoSides disconnectSide; - protected EventQuadripoleDisconnection(String eventId, Branch equipment, double startTime, boolean disconnectOrigin, boolean disconnectExtremity) { + protected EventBranchDisconnection(String eventId, Branch equipment, double startTime, TwoSides disconnectSide) { super(eventId, equipment, startTime, "EventQuadripoleDisconnection"); - this.disconnectOrigin = disconnectOrigin; - this.disconnectExtremity = disconnectExtremity; + this.disconnectSide = disconnectSide; } - private List getVarConnectionsWith(QuadripoleModel connected) { + private List getVarConnectionsWith(BranchModel connected) { return List.of(new VarConnection("event_state1_value", connected.getStateValueVarName())); } @Override public void createMacroConnections(MacroConnectionsAdder adder) { - adder.createMacroConnections(this, getEquipment(), QuadripoleModel.class, this::getVarConnectionsWith); + adder.createMacroConnections(this, getEquipment(), BranchModel.class, this::getVarConnectionsWith); } @Override protected void createEventSpecificParameters(ParametersSet paramSet) { paramSet.addParameter("event_tEvent", DOUBLE, Double.toString(getStartTime())); - paramSet.addParameter("event_disconnectOrigin", BOOL, Boolean.toString(disconnectOrigin)); - paramSet.addParameter("event_disconnectExtremity", BOOL, Boolean.toString(disconnectExtremity)); + paramSet.addParameter("event_disconnectOrigin", BOOL, Boolean.toString(disconnectSide == null || TwoSides.ONE == disconnectSide)); + paramSet.addParameter("event_disconnectExtremity", BOOL, Boolean.toString(disconnectSide == null || TwoSides.TWO == disconnectSide)); + } + + @Override + public String getName() { + return "EventBranchDisconnection"; } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventDisconnectionBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventDisconnectionBuilder.java index 5d274e9a6..df12f43ca 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventDisconnectionBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventDisconnectionBuilder.java @@ -21,19 +21,17 @@ public class EventDisconnectionBuilder extends AbstractEventModelBuilder CONNECTABLE_INJECTIONS = EnumSet.of(IdentifiableType.GENERATOR, IdentifiableType.LOAD, IdentifiableType.STATIC_VAR_COMPENSATOR, IdentifiableType.SHUNT_COMPENSATOR); - private static final EnumSet CONNECTABLE_QUADRIPOLES = EnumSet.of(IdentifiableType.LINE, IdentifiableType.TWO_WINDINGS_TRANSFORMER); + private static final EnumSet CONNECTABLE_BRANCHES = EnumSet.of(IdentifiableType.LINE, IdentifiableType.TWO_WINDINGS_TRANSFORMER); private enum DisconnectionType { INJECTION, - QUADRIPOLE, + BRANCH, HVDC, NONE } - private boolean disconnectSide = false; private DisconnectionType disconnectionType = DisconnectionType.NONE; - protected boolean disconnectOrigin = true; - protected boolean disconnectExtremity = true; + protected TwoSides disconnectSide = null; public static EventDisconnectionBuilder of(Network network) { return of(network, Reporter.NO_OP); @@ -48,26 +46,15 @@ public static EventDisconnectionBuilder of(Network network, Reporter reporter) { } public EventDisconnectionBuilder disconnectOnly(TwoSides side) { - disconnectSide = true; - switch (side) { - case ONE -> { - disconnectOrigin = true; - disconnectExtremity = false; - } - case TWO -> { - disconnectOrigin = false; - disconnectExtremity = true; - } - default -> throw new IllegalStateException(); - } + this.disconnectSide = side; return self(); } private void setDisconnectionType(IdentifiableType type) { if (CONNECTABLE_INJECTIONS.contains(type)) { disconnectionType = DisconnectionType.INJECTION; - } else if (CONNECTABLE_QUADRIPOLES.contains(type)) { - disconnectionType = DisconnectionType.QUADRIPOLE; + } else if (CONNECTABLE_BRANCHES.contains(type)) { + disconnectionType = DisconnectionType.BRANCH; } else if (IdentifiableType.HVDC_LINE == type) { disconnectionType = DisconnectionType.HVDC; } @@ -92,8 +79,8 @@ protected void checkData() { Reporters.reportStaticIdUnknown(reporter, "staticId", builderEquipment.getStaticId(), "Disconnectable equipment"); isInstantiable = false; } - if (DisconnectionType.INJECTION == disconnectionType && disconnectSide) { - Reporters.reportFieldSetWithWrongEquipment(reporter, "disconnectSide", builderEquipment.getEquipment().getType(), builderEquipment.getStaticId()); + if (DisconnectionType.INJECTION == disconnectionType && disconnectSide != null) { + Reporters.reportFieldSetWithWrongEquipment(reporter, "disconnectOnly", builderEquipment.getEquipment().getType(), builderEquipment.getStaticId()); isInstantiable = false; } } @@ -104,10 +91,10 @@ public AbstractEvent build() { if (isInstantiable()) { return switch (disconnectionType) { case INJECTION -> new EventInjectionDisconnection(eventId, (Injection) builderEquipment.getEquipment(), startTime, true); - case QUADRIPOLE -> - new EventQuadripoleDisconnection(eventId, (Branch) builderEquipment.getEquipment(), startTime, disconnectOrigin, disconnectExtremity); + case BRANCH -> + new EventBranchDisconnection(eventId, (Branch) builderEquipment.getEquipment(), startTime, disconnectSide); case HVDC -> - new EventHvdcDisconnection(eventId, (HvdcLine) builderEquipment.getEquipment(), startTime, disconnectOrigin, disconnectExtremity); + new EventHvdcDisconnection(eventId, (HvdcLine) builderEquipment.getEquipment(), startTime, disconnectSide); default -> null; }; } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventHvdcDisconnection.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventHvdcDisconnection.java index 5b4dfc6a0..8dbc02f12 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventHvdcDisconnection.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/events/EventHvdcDisconnection.java @@ -20,13 +20,11 @@ */ public class EventHvdcDisconnection extends AbstractDynamicLibEventDisconnection { - private final boolean disconnectOrigin; - private final boolean disconnectExtremity; + private final TwoSides disconnectSide; - protected EventHvdcDisconnection(String eventId, HvdcLine equipment, double startTime, boolean disconnectOrigin, boolean disconnectExtremity) { - super(eventId, equipment, startTime, disconnectOrigin || disconnectExtremity); - this.disconnectOrigin = disconnectOrigin; - this.disconnectExtremity = disconnectExtremity; + protected EventHvdcDisconnection(String eventId, HvdcLine equipment, double startTime, TwoSides disconnectSide) { + super(eventId, equipment, startTime, true); + this.disconnectSide = disconnectSide; } private List getVarConnectionsWithHvdcModel(HvdcModel connected) { @@ -40,12 +38,10 @@ private List getVarConnectionsWithHvdcModelSide(HvdcModel connect @Override public void createMacroConnections(MacroConnectionsAdder adder) { - if (disconnectOrigin && disconnectExtremity) { + if (disconnectSide == null) { adder.createMacroConnections(this, getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModel); - } else if (disconnectOrigin) { - adder.createMacroConnections(this, getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModelSide, TwoSides.ONE); - } else if (disconnectExtremity) { - adder.createMacroConnections(this, getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModelSide, TwoSides.TWO); + } else { + adder.createMacroConnections(this, getEquipment(), HvdcModel.class, this::getVarConnectionsWithHvdcModelSide, disconnectSide); } } } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GeneratorFictitiousBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GeneratorFictitiousBuilder.java index 540eb8859..94e03fe57 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GeneratorFictitiousBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GeneratorFictitiousBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class GeneratorFictitiousBuilder extends AbstractGeneratorBuilder { private static final String CATEGORY = "baseGenerators"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static GeneratorFictitiousBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static GeneratorFictitiousBuilder of(Network network, Reporter reporter) { - return new GeneratorFictitiousBuilder(network, LIBS.values().iterator().next(), reporter); + return new GeneratorFictitiousBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static GeneratorFictitiousBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static GeneratorFictitiousBuilder of(Network network, String lib) { } public static GeneratorFictitiousBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, GeneratorFictitiousBuilder.class.getSimpleName(), lib); return null; } - return new GeneratorFictitiousBuilder(network, LIBS.get(lib), reporter); + return new GeneratorFictitiousBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected GeneratorFictitiousBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GridFormingConverterBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GridFormingConverterBuilder.java index 958ea70b7..a36ee055e 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GridFormingConverterBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/GridFormingConverterBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class GridFormingConverterBuilder extends AbstractGeneratorBuilder { private static final String CATEGORY = "gridFormingConverters"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static GridFormingConverterBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static GridFormingConverterBuilder of(Network network, Reporter reporter) { - return new GridFormingConverterBuilder(network, LIBS.values().iterator().next(), reporter); + return new GridFormingConverterBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static GridFormingConverterBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static GridFormingConverterBuilder of(Network network, String lib) { } public static GridFormingConverterBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, GridFormingConverterBuilder.class.getSimpleName(), lib); return null; } - return new GridFormingConverterBuilder(network, LIBS.get(lib), reporter); + return new GridFormingConverterBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected GridFormingConverterBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/SynchronizedGeneratorBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/SynchronizedGeneratorBuilder.java index 2f98f6508..182dad610 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/SynchronizedGeneratorBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/SynchronizedGeneratorBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class SynchronizedGeneratorBuilder extends AbstractGeneratorBuilder { private static final String CATEGORY = "synchronizedGenerators"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static SynchronizedGeneratorBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static SynchronizedGeneratorBuilder of(Network network, Reporter reporter) { - return new SynchronizedGeneratorBuilder(network, LIBS.values().iterator().next(), reporter); + return new SynchronizedGeneratorBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static SynchronizedGeneratorBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static SynchronizedGeneratorBuilder of(Network network, String lib) { } public static SynchronizedGeneratorBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, SynchronizedGeneratorBuilder.class.getSimpleName(), lib); return null; } - return new SynchronizedGeneratorBuilder(network, LIBS.get(lib), reporter); + return new SynchronizedGeneratorBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected SynchronizedGeneratorBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/SynchronousGeneratorBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/SynchronousGeneratorBuilder.java index ad2955280..0bb9d122b 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/SynchronousGeneratorBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/SynchronousGeneratorBuilder.java @@ -10,11 +10,11 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -23,14 +23,14 @@ public class SynchronousGeneratorBuilder extends AbstractGeneratorBuilder { private static final String CATEGORY = "synchronousGenerators"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static SynchronousGeneratorBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static SynchronousGeneratorBuilder of(Network network, Reporter reporter) { - return new SynchronousGeneratorBuilder(network, LIBS.values().iterator().next(), reporter); + return new SynchronousGeneratorBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static SynchronousGeneratorBuilder of(Network network, String lib) { @@ -38,16 +38,16 @@ public static SynchronousGeneratorBuilder of(Network network, String lib) { } public static SynchronousGeneratorBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, SynchronousGeneratorBuilder.class.getSimpleName(), lib); return null; } - return new SynchronousGeneratorBuilder(network, LIBS.get(lib), reporter); + return new SynchronousGeneratorBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected SynchronousGeneratorBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/WeccBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/WeccBuilder.java index 77dd79329..58ef65203 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/WeccBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/generators/WeccBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class WeccBuilder extends AbstractGeneratorBuilder { private static final String CATEGORY = "wecc"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static WeccBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static WeccBuilder of(Network network, Reporter reporter) { - return new WeccBuilder(network, LIBS.values().iterator().next(), reporter); + return new WeccBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static WeccBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static WeccBuilder of(Network network, String lib) { } public static WeccBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, WeccBuilder.class.getSimpleName(), lib); return null; } - return new WeccBuilder(network, LIBS.get(lib), reporter); + return new WeccBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected WeccBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcPBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcPBuilder.java index 433d69a3e..756731814 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcPBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcPBuilder.java @@ -9,13 +9,13 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.HvdcLine; import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -24,14 +24,14 @@ public class HvdcPBuilder extends AbstractHvdcBuilder { private static final String CATEGORY = "hvdcP"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static HvdcPBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static HvdcPBuilder of(Network network, Reporter reporter) { - return new HvdcPBuilder(network, LIBS.values().iterator().next(), reporter); + return new HvdcPBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static HvdcPBuilder of(Network network, String lib) { @@ -39,16 +39,16 @@ public static HvdcPBuilder of(Network network, String lib) { } public static HvdcPBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, HvdcPBuilder.class.getSimpleName(), lib); return null; } - return new HvdcPBuilder(network, LIBS.get(lib), reporter); + return new HvdcPBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected HvdcPBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscBuilder.java index 3a24f5adb..ee8fdad6e 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/hvdc/HvdcVscBuilder.java @@ -9,6 +9,7 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.HvdcConverterStation; @@ -16,7 +17,6 @@ import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -25,14 +25,14 @@ public class HvdcVscBuilder extends AbstractHvdcBuilder { private static final String CATEGORY = "hvdcVsc"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static HvdcVscBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static HvdcVscBuilder of(Network network, Reporter reporter) { - return new HvdcVscBuilder(network, LIBS.values().iterator().next(), reporter); + return new HvdcVscBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static HvdcVscBuilder of(Network network, String lib) { @@ -40,16 +40,16 @@ public static HvdcVscBuilder of(Network network, String lib) { } public static HvdcVscBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, HvdcVscBuilder.class.getSimpleName(), lib); return null; } - return new HvdcVscBuilder(network, LIBS.get(lib), reporter); + return new HvdcVscBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected HvdcVscBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/LineBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/LineBuilder.java index 90730f2bd..652fa3248 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/LineBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/LineBuilder.java @@ -10,13 +10,13 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.AbstractEquipmentModelBuilder; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Line; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -25,14 +25,14 @@ public class LineBuilder extends AbstractEquipmentModelBuilder { private static final String CATEGORY = "baseLines"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static LineBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static LineBuilder of(Network network, Reporter reporter) { - return new LineBuilder(network, LIBS.values().iterator().next(), reporter); + return new LineBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static LineBuilder of(Network network, String lib) { @@ -40,16 +40,16 @@ public static LineBuilder of(Network network, String lib) { } public static LineBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, LineBuilder.class.getSimpleName(), lib); return null; } - return new LineBuilder(network, LIBS.get(lib), reporter); + return new LineBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected LineBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/LineModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/LineModel.java index 91e4d6d4c..38c2eb769 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/LineModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/lines/LineModel.java @@ -6,12 +6,12 @@ */ package com.powsybl.dynawaltz.models.lines; -import com.powsybl.dynawaltz.models.automatons.QuadripoleModel; +import com.powsybl.dynawaltz.models.automationsystems.BranchModel; /** * @author Florian Dupuy {@literal } */ -public interface LineModel extends QuadripoleModel { +public interface LineModel extends BranchModel { String getStateValueVarName(); } diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/BaseLoadBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/BaseLoadBuilder.java index 068a0fc1b..0556d6a66 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/BaseLoadBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/BaseLoadBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class BaseLoadBuilder extends AbstractLoadModelBuilder { private static final String CATEGORY = "baseLoads"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static BaseLoadBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static BaseLoadBuilder of(Network network, Reporter reporter) { - return new BaseLoadBuilder(network, LIBS.values().iterator().next(), reporter); + return new BaseLoadBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static BaseLoadBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static BaseLoadBuilder of(Network network, String lib) { } public static BaseLoadBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, BaseLoadBuilder.class.getSimpleName(), lib); return null; } - return new BaseLoadBuilder(network, LIBS.get(lib), reporter); + return new BaseLoadBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected BaseLoadBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadOneTransformerBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadOneTransformerBuilder.java index 260e7decb..5f301e8e3 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadOneTransformerBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadOneTransformerBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class LoadOneTransformerBuilder extends AbstractLoadModelBuilder { private static final String CATEGORY = "loadsOneTransformer"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static LoadOneTransformerBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static LoadOneTransformerBuilder of(Network network, Reporter reporter) { - return new LoadOneTransformerBuilder(network, LIBS.values().iterator().next(), reporter); + return new LoadOneTransformerBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static LoadOneTransformerBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static LoadOneTransformerBuilder of(Network network, String lib) { } public static LoadOneTransformerBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, LoadOneTransformerBuilder.class.getSimpleName(), lib); return null; } - return new LoadOneTransformerBuilder(network, LIBS.get(lib), reporter); + return new LoadOneTransformerBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected LoadOneTransformerBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadOneTransformerTapChangerBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadOneTransformerTapChangerBuilder.java index 18a831367..11145f24a 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadOneTransformerTapChangerBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadOneTransformerTapChangerBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class LoadOneTransformerTapChangerBuilder extends AbstractLoadModelBuilder { private static final String CATEGORY = "loadsOneTransformerTapChanger"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static LoadOneTransformerTapChangerBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static LoadOneTransformerTapChangerBuilder of(Network network, Reporter reporter) { - return new LoadOneTransformerTapChangerBuilder(network, LIBS.values().iterator().next(), reporter); + return new LoadOneTransformerTapChangerBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static LoadOneTransformerTapChangerBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static LoadOneTransformerTapChangerBuilder of(Network network, String lib } public static LoadOneTransformerTapChangerBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, LoadOneTransformerTapChangerBuilder.class.getSimpleName(), lib); return null; } - return new LoadOneTransformerTapChangerBuilder(network, LIBS.get(lib), reporter); + return new LoadOneTransformerTapChangerBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected LoadOneTransformerTapChangerBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadTwoTransformersBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadTwoTransformersBuilder.java index 0a2f7588f..d9a4faea1 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadTwoTransformersBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadTwoTransformersBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class LoadTwoTransformersBuilder extends AbstractLoadModelBuilder { private static final String CATEGORY = "loadsTwoTransformers"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static LoadTwoTransformersBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static LoadTwoTransformersBuilder of(Network network, Reporter reporter) { - return new LoadTwoTransformersBuilder(network, LIBS.values().iterator().next(), reporter); + return new LoadTwoTransformersBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static LoadTwoTransformersBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static LoadTwoTransformersBuilder of(Network network, String lib) { } public static LoadTwoTransformersBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, LoadTwoTransformersBuilder.class.getSimpleName(), lib); return null; } - return new LoadTwoTransformersBuilder(network, LIBS.get(lib), reporter); + return new LoadTwoTransformersBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected LoadTwoTransformersBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadTwoTransformersTapChangersBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadTwoTransformersTapChangersBuilder.java index bf2e11e48..76c2e2b89 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadTwoTransformersTapChangersBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/loads/LoadTwoTransformersTapChangersBuilder.java @@ -9,11 +9,11 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.Network; -import java.util.Map; import java.util.Set; /** @@ -22,14 +22,14 @@ public class LoadTwoTransformersTapChangersBuilder extends AbstractLoadModelBuilder { private static final String CATEGORY = "loadsTwoTransformersTapChanger"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static LoadTwoTransformersTapChangersBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static LoadTwoTransformersTapChangersBuilder of(Network network, Reporter reporter) { - return new LoadTwoTransformersTapChangersBuilder(network, LIBS.values().iterator().next(), reporter); + return new LoadTwoTransformersTapChangersBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static LoadTwoTransformersTapChangersBuilder of(Network network, String lib) { @@ -37,16 +37,16 @@ public static LoadTwoTransformersTapChangersBuilder of(Network network, String l } public static LoadTwoTransformersTapChangersBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, LoadTwoTransformersTapChangersBuilder.class.getSimpleName(), lib); return null; } - return new LoadTwoTransformersTapChangersBuilder(network, LIBS.get(lib), reporter); + return new LoadTwoTransformersTapChangersBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected LoadTwoTransformersTapChangersBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/macroconnections/MacroConnectionsAdder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/macroconnections/MacroConnectionsAdder.java index 8e03e1dbf..55c41e3f5 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/macroconnections/MacroConnectionsAdder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/macroconnections/MacroConnectionsAdder.java @@ -11,7 +11,7 @@ import com.powsybl.dynawaltz.models.BlackBoxModel; import com.powsybl.dynawaltz.models.Model; import com.powsybl.dynawaltz.models.VarConnection; -import com.powsybl.dynawaltz.models.automatons.TapChangerAutomaton; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystem; import com.powsybl.dynawaltz.models.buses.EquipmentConnectionPoint; import com.powsybl.dynawaltz.models.utils.BusUtils; import com.powsybl.iidm.network.*; @@ -189,8 +189,8 @@ public void createTerminalMacroConnections(BlackBoxModel originModel, HvdcLine h /** * Creates macro connection with TapChangerAutomaton from dynamic id */ - public boolean createTcaMacroConnectionsOrSkip(BlackBoxModel originModel, String tapChangerId, Function> varConnectionsSupplier) { - TapChangerAutomaton connectedModel = pureDynamicModelGetter.getPureDynamicModel(tapChangerId, TapChangerAutomaton.class, false); + public boolean createTcaMacroConnectionsOrSkip(BlackBoxModel originModel, String tapChangerId, Function> varConnectionsSupplier) { + TapChangerAutomationSystem connectedModel = pureDynamicModelGetter.getPureDynamicModel(tapChangerId, TapChangerAutomationSystem.class, false); if (connectedModel != null && connectedModel.isConnected(this)) { String macroConnectorId = MacroConnector.createMacroConnectorId(originModel.getName(), connectedModel.getName()); MacroConnect mc = new MacroConnect(macroConnectorId, originModel.getMacroConnectFromAttributes(), connectedModel.getMacroConnectToAttributes()); diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/svarcs/BaseStaticVarCompensatorBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/svarcs/BaseStaticVarCompensatorBuilder.java index 6fd76ab36..3cebd5589 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/svarcs/BaseStaticVarCompensatorBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/svarcs/BaseStaticVarCompensatorBuilder.java @@ -10,13 +10,13 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.AbstractEquipmentModelBuilder; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.StaticVarCompensator; -import java.util.Map; import java.util.Set; /** @@ -25,14 +25,14 @@ public class BaseStaticVarCompensatorBuilder extends AbstractEquipmentModelBuilder { private static final String CATEGORY = "staticVarCompensators"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static BaseStaticVarCompensatorBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static BaseStaticVarCompensatorBuilder of(Network network, Reporter reporter) { - return new BaseStaticVarCompensatorBuilder(network, LIBS.values().iterator().next(), reporter); + return new BaseStaticVarCompensatorBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static BaseStaticVarCompensatorBuilder of(Network network, String lib) { @@ -40,16 +40,16 @@ public static BaseStaticVarCompensatorBuilder of(Network network, String lib) { } public static BaseStaticVarCompensatorBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, BaseStaticVarCompensatorBuilder.class.getSimpleName(), lib); return null; } - return new BaseStaticVarCompensatorBuilder(network, LIBS.get(lib), reporter); + return new BaseStaticVarCompensatorBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected BaseStaticVarCompensatorBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerFixedRatioBuilder.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerFixedRatioBuilder.java index 5b9536504..09e7ba595 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerFixedRatioBuilder.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerFixedRatioBuilder.java @@ -10,13 +10,13 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.dynawaltz.builders.AbstractEquipmentModelBuilder; import com.powsybl.dynawaltz.builders.ModelConfig; +import com.powsybl.dynawaltz.builders.ModelConfigsHandler; import com.powsybl.dynawaltz.builders.ModelConfigs; import com.powsybl.dynawaltz.builders.Reporters; import com.powsybl.iidm.network.IdentifiableType; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.TwoWindingsTransformer; -import java.util.Map; import java.util.Set; /** @@ -25,14 +25,14 @@ public class TransformerFixedRatioBuilder extends AbstractEquipmentModelBuilder { private static final String CATEGORY = "transformers"; - private static final Map LIBS = ModelConfigs.getInstance().getModelConfigs(CATEGORY); + private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY); public static TransformerFixedRatioBuilder of(Network network) { return of(network, Reporter.NO_OP); } public static TransformerFixedRatioBuilder of(Network network, Reporter reporter) { - return new TransformerFixedRatioBuilder(network, LIBS.values().iterator().next(), reporter); + return new TransformerFixedRatioBuilder(network, MODEL_CONFIGS.getDefaultModelConfig(), reporter); } public static TransformerFixedRatioBuilder of(Network network, String lib) { @@ -40,16 +40,16 @@ public static TransformerFixedRatioBuilder of(Network network, String lib) { } public static TransformerFixedRatioBuilder of(Network network, String lib, Reporter reporter) { - ModelConfig modelConfig = LIBS.get(lib); + ModelConfig modelConfig = MODEL_CONFIGS.getModelConfig(lib); if (modelConfig == null) { Reporters.reportLibNotFound(reporter, TransformerFixedRatioBuilder.class.getSimpleName(), lib); return null; } - return new TransformerFixedRatioBuilder(network, LIBS.get(lib), reporter); + return new TransformerFixedRatioBuilder(network, modelConfig, reporter); } public static Set getSupportedLibs() { - return LIBS.keySet(); + return MODEL_CONFIGS.getSupportedLibs(); } protected TransformerFixedRatioBuilder(Network network, ModelConfig modelConfig, Reporter reporter) { diff --git a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerModel.java b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerModel.java index bc440ffc7..9c0c16480 100644 --- a/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerModel.java +++ b/dynawaltz/src/main/java/com/powsybl/dynawaltz/models/transformers/TransformerModel.java @@ -7,12 +7,12 @@ */ package com.powsybl.dynawaltz.models.transformers; -import com.powsybl.dynawaltz.models.automatons.QuadripoleModel; +import com.powsybl.dynawaltz.models.automationsystems.BranchModel; /** * @author Laurent Issertial {@literal } */ -public interface TransformerModel extends QuadripoleModel { +public interface TransformerModel extends BranchModel { String getStateValueVarName(); diff --git a/dynawaltz/src/main/resources/models.json b/dynawaltz/src/main/resources/models.json index 163d3cdb3..0f785ad16 100644 --- a/dynawaltz/src/main/resources/models.json +++ b/dynawaltz/src/main/resources/models.json @@ -1,363 +1,437 @@ { - "baseGenerators": [ - { - "lib": "GeneratorFictitious" - } - ], - "synchronousGenerators": [ - { - "lib": "GeneratorSynchronousFourWindings" - }, - { - "lib": "GeneratorSynchronousFourWindingsGoverPropVRPropInt", - "properties": [ - "Controllable" - ] - }, - { - "lib": "GeneratorSynchronousFourWindingsGovSteam1ExcIEEEST4B" - }, - { - "lib": "GeneratorSynchronousFourWindingsGovSteam1ExcIEEEST4BPssIEEE2B" - }, - { - "lib": "GeneratorSynchronousFourWindingsPmConstVRNordic" - }, - { - "lib": "GeneratorSynchronousFourWindingsPmConstVRNordicTfo", - "properties": [ - "Transformer" - ] - }, - { - "lib": "GeneratorSynchronousFourWindingsProportionalRegulations", - "properties": [ - "Controllable" - ] - }, - { - "lib": "GeneratorSynchronousFourWindingsTGov1Sexs" - }, - { - "lib": "GeneratorSynchronousFourWindingsTGov1SexsPss2A" - }, - { - "lib": "GeneratorSynchronousFourWindingsVRKundur" - }, - { - "lib": "GeneratorSynchronousFourWindingsVRKundurPssKundur" - }, - { - "lib": "GeneratorSynchronousProportionalRegulationsInternalParameters" - }, - { - "lib": "GeneratorSynchronousThreeWindings" - }, - { - "lib": "GeneratorSynchronousThreeWindingsGoverNordicVRNordic" - }, - { - "lib": "GeneratorSynchronousThreeWindingsGoverNordicVRNordicTfo", - "properties": [ - "Transformer" - ] - }, - { - "lib": "GeneratorSynchronousThreeWindingsGoverPropVRPropInt", - "properties": [ - "Controllable" - ] - }, - { - "lib": "GeneratorSynchronousThreeWindingsPmConstVRNordic" - }, - { - "lib": "GeneratorSynchronousThreeWindingsPmConstVRNordicTfo", - "properties": [ - "Transformer" - ] - }, - { - "lib": "GeneratorSynchronousThreeWindingsProportionalRegulations", - "properties": [ - "Controllable" - ] - } - ], - "synchronizedGenerators": [ - { - "lib": "GeneratorPQ" - }, - { - "lib": "GeneratorPV", - "properties": [ - "Controllable" - ] - }, - { - "lib": "GeneratorPVFixed" - }, - { - "lib": "GeneratorPVDiagramPQ" - } - ], - "hvdcP": [ - { - "lib": "HvdcPV" - }, - { - "lib": "HvdcPVEmulation" - }, - { - "lib": "HvdcPVEmulationSet" - }, - { - "lib": "HvdcPVDiagramPQ" - }, - { - "lib": "HvdcPVDiagramPQEmulation" - }, - { - "lib": "HvdcPVDiagramPQEmulationSet" - }, - { - "lib": "HvdcPTanPhi" - }, - { - "lib": "HvdcPTanPhiDiagramPQ" - }, - { - "lib": "HvdcPVDangling", - "properties": [ - "Dangling" - ] - }, - { - "lib": "HvdcPVDanglingDiagramPQ", - "properties": [ - "Dangling" - ] - }, - { - "lib": "HvdcPTanPhiDangling", - "properties": [ - "Dangling" - ] - }, - { - "lib": "HvdcPTanPhiDanglingDiagramPQ", - "properties": [ - "Dangling" - ] - } - ], - "hvdcVsc": [ - { - "lib": "HvdcVSC" - }, - { - "lib": "HvdcVSCEmulation" - }, - { - "lib": "HvdcVSCDanglingP", - "properties": [ - "Dangling" - ] - }, - { - "lib": "HvdcVSCDanglingUdc", - "properties": [ - "Dangling" - ] - } - ], - "baseBuses": [ - { - "lib": "Bus" - } - ], - "infiniteBuses": [ - { - "lib": "InfiniteBus" - }, - { - "lib": "InfiniteBusWithImpedance" - }, - { - "lib": "InfiniteBusWithVariations" - } - ], - "baseLoads": [ - { - "lib": "LoadAlphaBeta", - "properties": [ - "Controllable" - ] - }, - { - "lib": "LoadAlphaBetaRestorative" - }, - { - "lib": "LoadAlphaBetaRestorativeLimitsRecalc" - }, - { - "lib": "LoadAlphaBetaMotor" - }, - { - "lib": "LoadPQ" - } - ], - "loadsOneTransformer": [ - { - "lib": "LoadOneTransformer" - } - ], - "loadsOneTransformerTapChanger": [ - { - "lib": "LoadOneTransformerTapChanger" - } - ], - "loadsTwoTransformers": [ - { - "lib": "LoadTwoTransformers" - } - ], - "loadsTwoTransformersTapChanger": [ - { - "lib": "LoadTwoTransformersTapChangers" - } - ], - "baseLines": [ - { - "lib": "Line" - } - ], - "staticVarCompensators": [ - { - "lib": "StaticVarCompensator" - }, - { - "lib": "StaticVarCompensatorPV" - }, - { - "lib": "StaticVarCompensatorPVModeHandling" - }, - { - "lib": "StaticVarCompensatorPVRemote" - }, - { - "lib": "StaticVarCompensatorPVRemoteModeHandling" - }, - { - "lib": "StaticVarCompensatorPVProp" - }, - { - "lib": "StaticVarCompensatorPVPropModeHandling" - }, - { - "lib": "StaticVarCompensatorPVPropRemote" - }, - { - "lib": "StaticVarCompensatorPVPropRemoteModeHandling" - } - ], - "transformers": [ - { - "lib": "TransformerFixedRatio" - } - ], - "wecc": [ - { - "lib": "WTG4AWeccCurrentSource", - "internalModelPrefix": "WTG4A", - "properties": [ - "Synchronized" - ] - }, - { - "lib": "WTG4BWeccCurrentSource", - "internalModelPrefix": "WTG4B", - "properties": [ - "Synchronized" - ] - }, - { - "lib": "WT4AWeccCurrentSource", - "internalModelPrefix": "WT4A" - }, - { - "lib": "WT4BWeccCurrentSource", - "internalModelPrefix": "WT4B" - }, - { - "lib": "PhotovoltaicsWeccCurrentSource", - "internalModelPrefix": "photovoltaics", - "properties": [ - "Synchronized" - ] - }, - { - "lib": "PhotovoltaicsWeccVoltageSource", - "internalModelPrefix": "photovoltaics", - "properties": [ - "Synchronized" - ] - } - ], - "gridFormingConverters": [ - { - "lib": "GridFormingConverterDroopControl", - "properties": [ - "Synchronized" - ] - }, - { - "lib": "GridFormingConverterMatchingControl", - "properties": [ - "Synchronized" - ] - }, - { - "lib": "GridFormingConverterDispatchableVirtualOscillatorControl", - "properties": [ - "Synchronized" - ] - } - ], - "clas": [ - { - "lib": "CurrentLimitAutomaton" - } - ], - "clasTwoLevels": [ - { - "lib": "CurrentLimitAutomatonTwoLevels" - } - ], - "phaseShiftersI": [ - { - "lib": "PhaseShifterI" - } - ], - "phaseShiftersP": [ - { - "lib": "PhaseShifterP" - } - ], - "tapChangers": [ - { - "lib": "TapChangerAutomaton" - } - ], - "tcbs": [ - { - "lib": "TapChangerBlockingAutomaton" - } - ], - "underVoltages": [ - { - "lib": "UnderVoltageAutomaton", - "alias": "UnderVoltage" - } - ] + "baseGenerators": { + "defaultLib": "GeneratorFictitious", + "libs": [ + { + "lib": "GeneratorFictitious" + } + ] + }, + "synchronousGenerators": { + "defaultLib": "GeneratorSynchronousFourWindings", + "libs": [ + { + "lib": "GeneratorSynchronousFourWindings" + }, + { + "lib": "GeneratorSynchronousFourWindingsGoverPropVRPropInt", + "properties": [ + "Controllable" + ] + }, + { + "lib": "GeneratorSynchronousFourWindingsGovSteam1ExcIEEEST4B" + }, + { + "lib": "GeneratorSynchronousFourWindingsGovSteam1ExcIEEEST4BPssIEEE2B" + }, + { + "lib": "GeneratorSynchronousFourWindingsPmConstVRNordic" + }, + { + "lib": "GeneratorSynchronousFourWindingsPmConstVRNordicTfo", + "properties": [ + "Transformer" + ] + }, + { + "lib": "GeneratorSynchronousFourWindingsProportionalRegulations", + "properties": [ + "Controllable" + ] + }, + { + "lib": "GeneratorSynchronousFourWindingsTGov1Sexs" + }, + { + "lib": "GeneratorSynchronousFourWindingsTGov1SexsPss2A" + }, + { + "lib": "GeneratorSynchronousFourWindingsVRKundur" + }, + { + "lib": "GeneratorSynchronousFourWindingsVRKundurPssKundur" + }, + { + "lib": "GeneratorSynchronousProportionalRegulationsInternalParameters" + }, + { + "lib": "GeneratorSynchronousThreeWindings" + }, + { + "lib": "GeneratorSynchronousThreeWindingsGoverNordicVRNordic" + }, + { + "lib": "GeneratorSynchronousThreeWindingsGoverNordicVRNordicTfo", + "properties": [ + "Transformer" + ] + }, + { + "lib": "GeneratorSynchronousThreeWindingsGoverPropVRPropInt", + "properties": [ + "Controllable" + ] + }, + { + "lib": "GeneratorSynchronousThreeWindingsPmConstVRNordic" + }, + { + "lib": "GeneratorSynchronousThreeWindingsPmConstVRNordicTfo", + "properties": [ + "Transformer" + ] + }, + { + "lib": "GeneratorSynchronousThreeWindingsProportionalRegulations", + "properties": [ + "Controllable" + ] + } + ] + }, + "synchronizedGenerators": { + "defaultLib": "GeneratorPQ", + "libs": [ + { + "lib": "GeneratorPQ" + }, + { + "lib": "GeneratorPV", + "properties": [ + "Controllable" + ] + }, + { + "lib": "GeneratorPVFixed" + }, + { + "lib": "GeneratorPVDiagramPQ" + } + ] + }, + "hvdcP": { + "defaultLib": "HvdcPV", + "libs": [ + { + "lib": "HvdcPV" + }, + { + "lib": "HvdcPVEmulation" + }, + { + "lib": "HvdcPVEmulationSet" + }, + { + "lib": "HvdcPVDiagramPQ" + }, + { + "lib": "HvdcPVDiagramPQEmulation" + }, + { + "lib": "HvdcPVDiagramPQEmulationSet" + }, + { + "lib": "HvdcPTanPhi" + }, + { + "lib": "HvdcPTanPhiDiagramPQ" + }, + { + "lib": "HvdcPVDangling", + "properties": [ + "Dangling" + ] + }, + { + "lib": "HvdcPVDanglingDiagramPQ", + "properties": [ + "Dangling" + ] + }, + { + "lib": "HvdcPTanPhiDangling", + "properties": [ + "Dangling" + ] + }, + { + "lib": "HvdcPTanPhiDanglingDiagramPQ", + "properties": [ + "Dangling" + ] + } + ] + }, + "hvdcVsc": { + "defaultLib": "HvdcVSC", + "libs": [ + { + "lib": "HvdcVSC" + }, + { + "lib": "HvdcVSCEmulation" + }, + { + "lib": "HvdcVSCDanglingP", + "properties": [ + "Dangling" + ] + }, + { + "lib": "HvdcVSCDanglingUdc", + "properties": [ + "Dangling" + ] + } + ] + }, + "baseBuses": { + "defaultLib": "Bus", + "libs": [ + { + "lib": "Bus" + } + ] + }, + "infiniteBuses": { + "defaultLib": "InfiniteBus", + "libs": [ + { + "lib": "InfiniteBus" + }, + { + "lib": "InfiniteBusWithImpedance" + }, + { + "lib": "InfiniteBusWithVariations" + } + ] + }, + "baseLoads": { + "defaultLib": "LoadAlphaBeta", + "libs": [ + { + "lib": "LoadAlphaBeta", + "properties": [ + "Controllable" + ] + }, + { + "lib": "LoadAlphaBetaRestorative" + }, + { + "lib": "LoadAlphaBetaRestorativeLimitsRecalc" + }, + { + "lib": "LoadAlphaBetaMotor" + }, + { + "lib": "LoadPQ" + } + ] + }, + "loadsOneTransformer": { + "defaultLib": "LoadOneTransformer", + "libs": [ + { + "lib": "LoadOneTransformer" + } + ] + }, + "loadsOneTransformerTapChanger": { + "defaultLib": "LoadOneTransformerTapChanger", + "libs": [ + { + "lib": "LoadOneTransformerTapChanger" + } + ] + }, + "loadsTwoTransformers": { + "defaultLib": "LoadTwoTransformers", + "libs": [ + { + "lib": "LoadTwoTransformers" + } + ] + }, + "loadsTwoTransformersTapChanger": { + "defaultLib": "LoadTwoTransformersTapChangers", + "libs": [ + { + "lib": "LoadTwoTransformersTapChangers" + } + ] + }, + "baseLines": { + "defaultLib": "Line", + "libs": [ + { + "lib": "Line" + } + ] + }, + "staticVarCompensators": { + "defaultLib": "StaticVarCompensator", + "libs": [ + { + "lib": "StaticVarCompensator" + }, + { + "lib": "StaticVarCompensatorPV" + }, + { + "lib": "StaticVarCompensatorPVModeHandling" + }, + { + "lib": "StaticVarCompensatorPVRemote" + }, + { + "lib": "StaticVarCompensatorPVRemoteModeHandling" + }, + { + "lib": "StaticVarCompensatorPVProp" + }, + { + "lib": "StaticVarCompensatorPVPropModeHandling" + }, + { + "lib": "StaticVarCompensatorPVPropRemote" + }, + { + "lib": "StaticVarCompensatorPVPropRemoteModeHandling" + } + ] + }, + "transformers": { + "defaultLib": "TransformerFixedRatio", + "libs": [ + { + "lib": "TransformerFixedRatio" + } + ] + }, + "wecc": { + "defaultLib": "WTG4AWeccCurrentSource", + "libs": [ + { + "lib": "WTG4AWeccCurrentSource", + "internalModelPrefix": "WTG4A", + "properties": [ + "Synchronized" + ] + }, + { + "lib": "WTG4BWeccCurrentSource", + "internalModelPrefix": "WTG4B", + "properties": [ + "Synchronized" + ] + }, + { + "lib": "WT4AWeccCurrentSource", + "internalModelPrefix": "WT4A" + }, + { + "lib": "WT4BWeccCurrentSource", + "internalModelPrefix": "WT4B" + }, + { + "lib": "PhotovoltaicsWeccCurrentSource", + "internalModelPrefix": "photovoltaics", + "properties": [ + "Synchronized" + ] + }, + { + "lib": "PhotovoltaicsWeccVoltageSource", + "internalModelPrefix": "photovoltaics", + "properties": [ + "Synchronized" + ] + } + ] + }, + "gridFormingConverters": { + "defaultLib": "GridFormingConverterDroopControl", + "libs": [ + { + "lib": "GridFormingConverterDroopControl", + "properties": [ + "Synchronized" + ] + }, + { + "lib": "GridFormingConverterMatchingControl", + "properties": [ + "Synchronized" + ] + }, + { + "lib": "GridFormingConverterDispatchableVirtualOscillatorControl", + "properties": [ + "Synchronized" + ] + } + ] + }, + "overloadManagements": { + "defaultLib": "OverloadManagementSystem", + "libs": [ + { + "lib": "CurrentLimitAutomaton", + "alias": "OverloadManagementSystem" + } + ] + }, + "twoLevelsOverloadManagements": { + "defaultLib": "TwoLevelsOverloadManagementSystem", + "libs": [ + { + "lib": "CurrentLimitAutomatonTwoLevels", + "alias": "TwoLevelsOverloadManagementSystem" + } + ] + }, + "phaseShiftersI": { + "defaultLib": "PhaseShifterI", + "libs": [ + { + "lib": "PhaseShifterI" + } + ] + }, + "phaseShiftersP": { + "defaultLib": "PhaseShifterP", + "libs": [ + { + "lib": "PhaseShifterP" + } + ] + }, + "tapChangers": { + "defaultLib": "TapChangerAutomaton", + "libs": [ + { + "lib": "TapChangerAutomaton" + } + ] + }, + "tcbs": { + "defaultLib": "TapChangerBlockingAutomaton", + "libs": [ + { + "lib": "TapChangerBlockingAutomaton" + } + ] + }, + "underVoltages": { + "defaultLib": "UnderVoltage", + "libs": [ + { + "lib": "UnderVoltageAutomaton", + "alias": "UnderVoltage" + } + ] + } } \ No newline at end of file diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java new file mode 100644 index 000000000..0699124df --- /dev/null +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/DefaultLibBuilderTest.java @@ -0,0 +1,78 @@ +/** + * 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.dynawaltz.builders; + +import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.UnderVoltageAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicOverloadManagementSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicTwoLevelsOverloadManagementSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.phaseshifters.PhaseShifterIAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.phaseshifters.PhaseShifterPAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.buses.InfiniteBusBuilder; +import com.powsybl.dynawaltz.models.buses.StandardBusBuilder; +import com.powsybl.dynawaltz.models.generators.*; +import com.powsybl.dynawaltz.models.hvdc.HvdcPBuilder; +import com.powsybl.dynawaltz.models.hvdc.HvdcVscBuilder; +import com.powsybl.dynawaltz.models.lines.LineBuilder; +import com.powsybl.dynawaltz.models.loads.*; +import com.powsybl.dynawaltz.models.svarcs.BaseStaticVarCompensatorBuilder; +import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.test.SvcTestCaseFactory; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * @author Laurent Issertial {@literal } + */ +class DefaultLibBuilderTest { + + private static final Network NETWORK = SvcTestCaseFactory.create(); + + @Test + void testDefaultLibAutomatons() { + assertNotNull(UnderVoltageAutomationSystemBuilder.of(NETWORK)); + assertNotNull(TapChangerBlockingAutomationSystemBuilder.of(NETWORK)); + assertNotNull(TapChangerAutomationSystemBuilder.of(NETWORK)); + assertNotNull(DynamicOverloadManagementSystemBuilder.of(NETWORK)); + assertNotNull(DynamicTwoLevelsOverloadManagementSystemBuilder.of(NETWORK)); + assertNotNull(PhaseShifterIAutomationSystemBuilder.of(NETWORK)); + assertNotNull(PhaseShifterPAutomationSystemBuilder.of(NETWORK)); + } + + @Test + void testDefaultLibEquipments() { + // Load + assertNotNull(BaseLoadBuilder.of(NETWORK)); + assertNotNull(LoadOneTransformerBuilder.of(NETWORK)); + assertNotNull(LoadOneTransformerTapChangerBuilder.of(NETWORK)); + assertNotNull(LoadTwoTransformersBuilder.of(NETWORK)); + assertNotNull(LoadTwoTransformersTapChangersBuilder.of(NETWORK)); + // Bus + assertNotNull(StandardBusBuilder.of(NETWORK)); + assertNotNull(InfiniteBusBuilder.of(NETWORK)); + // Transformer + assertNotNull(TransformerFixedRatioBuilder.of(NETWORK)); + // Line + assertNotNull(LineBuilder.of(NETWORK)); + // Generator + assertNotNull(GeneratorFictitiousBuilder.of(NETWORK)); + assertNotNull(SynchronizedGeneratorBuilder.of(NETWORK)); + assertNotNull(SynchronousGeneratorBuilder.of(NETWORK)); + assertNotNull(WeccBuilder.of(NETWORK)); + assertNotNull(GridFormingConverterBuilder.of(NETWORK)); + // HVDC + assertNotNull(HvdcPBuilder.of(NETWORK)); + assertNotNull(HvdcVscBuilder.of(NETWORK)); + // Static var comp + assertNotNull(BaseStaticVarCompensatorBuilder.of(NETWORK)); + } + +} diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderTest.java index 7efaca550..a5a1bb725 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/builders/ModelConfigLoaderTest.java @@ -10,14 +10,17 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * @author Laurent Issertial {@literal } */ @@ -27,42 +30,76 @@ class ModelConfigLoaderTest { void loadConfigTest() throws IOException { String json = """ { - "synchronousGenerators": [ - { - "lib": "PhotovoltaicsWeccCurrentSource", - "alias": "WeccCs", - "internalModelPrefix": "WTG4A", - "properties": [ - "Synchronized" - ] - }, - { - "lib": "WT4BWeccCurrentSource", - "properties": [ - "Synchronized", - "Controllable" - ] - }, - { - "lib": "WT4AWeccCurrentSource" + "synchronousGenerators": { + "defaultLib": "WT4BWeccCurrentSource", + "libs": [ + { + "lib": "PhotovoltaicsWeccCurrentSource", + "alias": "WeccCs", + "internalModelPrefix": "WTG4A", + "properties": [ + "Synchronized" + ] + }, + { + "lib": "WT4BWeccCurrentSource", + "properties": [ + "Synchronized", + "Controllable" + ] + }, + { + "lib": "WT4AWeccCurrentSource" + } + ] } - ] }"""; ObjectMapper objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addDeserializer(Map.class, new ModelConfigsJsonDeserializer()); objectMapper.registerModule(module); - Map> configs = objectMapper.readValue(json, new TypeReference<>() { + Map configs = objectMapper.readValue(json, new TypeReference<>() { }); - Assertions.assertThat(configs.keySet()).containsExactly("synchronousGenerators"); - Assertions.assertThat(configs.get("synchronousGenerators").keySet()).containsExactly( + assertThat(configs.keySet()).containsExactlyInAnyOrder("synchronousGenerators"); + ModelConfigs synchroGens = configs.get("synchronousGenerators"); + assertThat(synchroGens.getSupportedLibs()).containsExactlyInAnyOrder( "WeccCs", "WT4BWeccCurrentSource", "WT4AWeccCurrentSource"); - Assertions.assertThat(configs.get("synchronousGenerators").values()).containsExactly( + ModelConfig defaultModel = new ModelConfig("WT4BWeccCurrentSource", null, null, List.of("SYNCHRONIZED", "CONTROLLABLE")); + assertThat(listModelConfigs(synchroGens)).containsExactlyInAnyOrder( new ModelConfig("PhotovoltaicsWeccCurrentSource", "WeccCs", "WTG4A", List.of("SYNCHRONIZED")), - new ModelConfig("WT4BWeccCurrentSource", null, null, List.of("SYNCHRONIZED", "CONTROLLABLE")), + defaultModel, new ModelConfig("WT4AWeccCurrentSource", null, null, Collections.emptyList())); + assertEquals(defaultModel, synchroGens.getDefaultModelConfig()); + } + + @Test + void mergeModelConfigs() { + ModelConfig defaultModel = new ModelConfig("AA", null, null, Collections.emptyList()); + ModelConfigs modelConfigs1 = new ModelConfigs(new HashMap<>(Map.of(defaultModel.name(), defaultModel)), defaultModel.name()); + + ModelConfig mc1 = new ModelConfig("BB", null, null, Collections.emptyList()); + ModelConfig mc2 = new ModelConfig("CC", null, null, Collections.emptyList()); + ModelConfigs modelConfigs2 = new ModelConfigs(new HashMap<>(Map.of(mc1.name(), mc1, mc2.name(), mc2)), mc1.name()); + + modelConfigs1.addModelConfigs(modelConfigs2); + assertThat(listModelConfigs(modelConfigs1)).containsExactlyInAnyOrder( + defaultModel, + new ModelConfig("BB", null, null, Collections.emptyList()), + mc2); + assertEquals(defaultModel, modelConfigs1.getDefaultModelConfig()); + + ModelConfigs modelConfigs3 = new ModelConfigs(new HashMap<>(Map.of(mc2.name(), mc2)), null); + ModelConfigs modelConfigs4 = new ModelConfigs(new HashMap<>(Map.of(defaultModel.name(), defaultModel)), defaultModel.name()); + modelConfigs3.addModelConfigs(modelConfigs4); + assertEquals(defaultModel, modelConfigs3.getDefaultModelConfig()); + } + + private List listModelConfigs(ModelConfigs modelConfigs) { + return modelConfigs.getSupportedLibs().stream() + .map(modelConfigs::getModelConfig) + .toList(); } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/BuilderEquipmentSetterTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/BuilderEquipmentSetterTest.java new file mode 100644 index 000000000..7c0045607 --- /dev/null +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/BuilderEquipmentSetterTest.java @@ -0,0 +1,59 @@ +/** + * 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.dynawaltz.models; + +import com.powsybl.commons.reporter.ReporterModel; +import com.powsybl.commons.test.TestUtil; +import com.powsybl.dynawaltz.models.lines.LineBuilder; +import com.powsybl.iidm.network.Line; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.test.PhaseShifterTestCaseFactory; +import com.powsybl.iidm.network.test.SvcTestCaseFactory; +import org.junit.jupiter.api.Test; + +import java.io.StringWriter; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * @author Laurent Issertial {@literal } + */ +class BuilderEquipmentSetterTest { + + @Test + void addEquipmentFromAnotherNetwork() { + + Network network = SvcTestCaseFactory.create(); + Line ln1 = network.getLine("L1"); + Network network2 = PhaseShifterTestCaseFactory.create(); + Line ln2 = network2.getLine("L1"); + ReporterModel reporter = new ReporterModel("builderTests", "Builder tests"); + + BlackBoxModel bbm1 = LineBuilder.of(network) + .dynamicModelId("BBM_LINE_NETWORK_1") + .equipment(ln1) + .parameterSetId("sl") + .build(); + BlackBoxModel bbm2 = LineBuilder.of(network, reporter) + .dynamicModelId("BBM_LINE_NETWORK_2") + .equipment(ln2) + .parameterSetId("sl") + .build(); + + assertNotNull(bbm1); + assertNull(bbm2); + StringWriter sw = new StringWriter(); + reporter.export(sw); + assertEquals(""" + + Builder tests + 'equipment' field value LINE L1 does not belong to the builder network + Model BBM_LINE_NETWORK_2 cannot be instantiated + """, + TestUtil.normalizeLineSeparator(sw.toString())); + } +} diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/lines/StandardLineTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/lines/StandardLineTest.java index 6e274156e..22c7f19da 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/lines/StandardLineTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/models/lines/StandardLineTest.java @@ -12,7 +12,7 @@ import com.powsybl.dynawaltz.DynaWaltzContext; import com.powsybl.dynawaltz.DynaWaltzParameters; import com.powsybl.dynawaltz.models.BlackBoxModel; -import com.powsybl.dynawaltz.models.automatons.currentlimits.CurrentLimitAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicOverloadManagementSystemBuilder; import com.powsybl.iidm.network.*; import org.junit.jupiter.api.Test; @@ -29,7 +29,7 @@ class StandardLineTest { @Test - void connectionToCurrentLimitAutomatonException() { + void connectionToDynamicOverloadManagementSystemException() { Network network = Network.create("test", "test"); Substation s = network.newSubstation().setId("s").add(); VoltageLevel vl1 = s.newVoltageLevel().setId("vl1").setNominalV(400).setTopologyKind(TopologyKind.BUS_BREAKER).add(); @@ -41,10 +41,10 @@ void connectionToCurrentLimitAutomatonException() { List dynamicModels = new ArrayList<>(); dynamicModels.add(new StandardLine("BBM_l", l, "SL", "Line")); - dynamicModels.add(CurrentLimitAutomatonBuilder.of(network, "CurrentLimitAutomaton") + dynamicModels.add(DynamicOverloadManagementSystemBuilder.of(network, "OverloadManagementSystem") .dynamicModelId("BBM_CLA") .parameterSetId("CLA") - .controlledQuadripole(l.getId()) + .controlledBranch(l.getId()) .iMeasurement(l.getId()) .iMeasurementSide(TwoSides.ONE) .build()); diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectQuadripoleEventXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectBranchEventXmlTest.java similarity index 82% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectQuadripoleEventXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectBranchEventXmlTest.java index aa27b8c5e..f2a60880a 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectQuadripoleEventXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DisconnectBranchEventXmlTest.java @@ -18,7 +18,7 @@ /** * @author Laurent Issertial {@literal } */ -class DisconnectQuadripoleEventXmlTest extends AbstractDynamicModelXmlTest { +class DisconnectBranchEventXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { @@ -42,7 +42,7 @@ protected void addDynamicModels() { void writeDisconnectModel() throws SAXException, IOException { DydXml.write(tmpDir, context); ParametersXml.write(tmpDir, context); - validate("dyd.xsd", "disconnect_quadripole_dyd.xml", tmpDir.resolve(DynaWaltzConstants.DYD_FILENAME)); - validate("parameters.xsd", "disconnect_quadripole_par.xml", tmpDir.resolve(context.getSimulationParFile())); + validate("dyd.xsd", "disconnect_branch_dyd.xml", tmpDir.resolve(DynaWaltzConstants.DYD_FILENAME)); + validate("parameters.xsd", "disconnect_branch_par.xml", tmpDir.resolve(context.getSimulationParFile())); } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynaWaltzTestUtil.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynaWaltzTestUtil.java index d71c21919..52f7048c4 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynaWaltzTestUtil.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynaWaltzTestUtil.java @@ -10,7 +10,7 @@ import com.powsybl.dynamicsimulation.Curve; import com.powsybl.dynawaltz.DynaWaltzCurve; import com.powsybl.dynawaltz.models.BlackBoxModel; -import com.powsybl.dynawaltz.models.automatons.currentlimits.CurrentLimitAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicOverloadManagementSystemBuilder; import com.powsybl.dynawaltz.models.events.EventDisconnectionBuilder; import com.powsybl.dynawaltz.models.generators.GeneratorFictitiousBuilder; import com.powsybl.dynawaltz.models.generators.SynchronizedGeneratorBuilder; @@ -145,10 +145,10 @@ void setup() { // Automatons network.getLineStream().filter(line -> !line.getId().equalsIgnoreCase(standardLine.getStaticId())) - .forEach(l -> dynamicModels.add(CurrentLimitAutomatonBuilder.of(network, "CurrentLimitAutomaton") + .forEach(l -> dynamicModels.add(DynamicOverloadManagementSystemBuilder.of(network, "OverloadManagementSystem") .dynamicModelId("BBM_" + l.getId()) .parameterSetId("CLA") - .controlledQuadripole(l.getId()) + .controlledBranch(l.getId()) .iMeasurement(l.getId()) .iMeasurementSide(TwoSides.ONE) .build())); diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitAutomatonBuilderLimitModelXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynamicOverloadManagementSystemModelXmlTest.java similarity index 75% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitAutomatonBuilderLimitModelXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynamicOverloadManagementSystemModelXmlTest.java index 271c120e4..b4628ab59 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitAutomatonBuilderLimitModelXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynamicOverloadManagementSystemModelXmlTest.java @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.xml; import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; -import com.powsybl.dynawaltz.models.automatons.currentlimits.CurrentLimitAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicOverloadManagementSystemBuilder; import com.powsybl.iidm.network.TwoSides; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.Test; @@ -20,7 +20,7 @@ /** * @author Laurent Issertial {@literal } */ -class CurrentLimitAutomatonBuilderLimitModelXmlTest extends AbstractDynamicModelXmlTest { +class DynamicOverloadManagementSystemModelXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { @@ -29,17 +29,17 @@ protected void setupNetwork() { @Override protected void addDynamicModels() { - dynamicModels.add(CurrentLimitAutomatonBuilder.of(network, "CurrentLimitAutomaton") + dynamicModels.add(DynamicOverloadManagementSystemBuilder.of(network, "OverloadManagementSystem") .dynamicModelId("BBM_CLA_LINE") .parameterSetId("cla") - .controlledQuadripole("NHV1_NHV2_1") + .controlledBranch("NHV1_NHV2_1") .iMeasurement("NHV1_NHV2_1") .iMeasurementSide(TwoSides.ONE) .build()); - dynamicModels.add(CurrentLimitAutomatonBuilder.of(network, "CurrentLimitAutomaton") + dynamicModels.add(DynamicOverloadManagementSystemBuilder.of(network, "OverloadManagementSystem") .dynamicModelId("BBM_CLA_TRANSFORMER") .parameterSetId("cla") - .controlledQuadripole("NGEN_NHV1") + .controlledBranch("NGEN_NHV1") .iMeasurement("NGEN_NHV1") .iMeasurementSide(TwoSides.TWO) .build()); @@ -48,10 +48,10 @@ protected void addDynamicModels() { .staticId("NHV2_NLOAD") .parameterSetId("tf") .build()); - dynamicModels.add(CurrentLimitAutomatonBuilder.of(network, "CurrentLimitAutomaton") + dynamicModels.add(DynamicOverloadManagementSystemBuilder.of(network, "OverloadManagementSystem") .dynamicModelId("BBM_CLA_TRANSFORMER2") .parameterSetId("cla") - .controlledQuadripole("NHV1_NHV2_1") + .controlledBranch("NHV1_NHV2_1") .iMeasurement("NHV2_NLOAD") .iMeasurementSide(TwoSides.TWO) .build()); diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitAutomatonBuilderLimitTwoLevelsModelXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynamicTwoLevelsOverloadManagementSystemModelXmlTest.java similarity index 78% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitAutomatonBuilderLimitTwoLevelsModelXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynamicTwoLevelsOverloadManagementSystemModelXmlTest.java index 995dde9f5..dc1e4a792 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/CurrentLimitAutomatonBuilderLimitTwoLevelsModelXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/DynamicTwoLevelsOverloadManagementSystemModelXmlTest.java @@ -7,7 +7,7 @@ */ package com.powsybl.dynawaltz.xml; -import com.powsybl.dynawaltz.models.automatons.currentlimits.CurrentLimitTwoLevelsAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.overloadmanagments.DynamicTwoLevelsOverloadManagementSystemBuilder; import com.powsybl.iidm.network.TwoSides; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.Test; @@ -19,7 +19,7 @@ /** * @author Laurent Issertial {@literal } */ -class CurrentLimitAutomatonBuilderLimitTwoLevelsModelXmlTest extends AbstractDynamicModelXmlTest { +class DynamicTwoLevelsOverloadManagementSystemModelXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { @@ -28,10 +28,10 @@ protected void setupNetwork() { @Override protected void addDynamicModels() { - dynamicModels.add(CurrentLimitTwoLevelsAutomatonBuilder.of(network, "CurrentLimitAutomatonTwoLevels") + dynamicModels.add(DynamicTwoLevelsOverloadManagementSystemBuilder.of(network, "TwoLevelsOverloadManagementSystem") .dynamicModelId("BBM_CLA_TWO_LEVELS") .parameterSetId("cla") - .controlledQuadripole("NGEN_NHV1") + .controlledBranch("NGEN_NHV1") .iMeasurement1("NHV1_NHV2_1") .iMeasurement1Side(TwoSides.TWO) .iMeasurement2("NHV1_NHV2_2") diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerAutomatonXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerAutomationSystemXmlTest.java similarity index 84% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerAutomatonXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerAutomationSystemXmlTest.java index fab348ffb..690fef153 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerAutomatonXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerAutomationSystemXmlTest.java @@ -7,7 +7,7 @@ */ package com.powsybl.dynawaltz.xml; -import com.powsybl.dynawaltz.models.automatons.TapChangerAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystemBuilder; import com.powsybl.dynawaltz.models.loads.BaseLoadBuilder; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.Test; @@ -19,7 +19,7 @@ /** * @author Laurent Issertial {@literal } */ -class EmptyTapChangerAutomatonXmlTest extends AbstractDynamicModelXmlTest { +class EmptyTapChangerAutomationSystemXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { @@ -33,7 +33,7 @@ protected void addDynamicModels() { .staticId("LOAD") .parameterSetId("LAB") .build()); - dynamicModels.add(TapChangerAutomatonBuilder.of(network) + dynamicModels.add(TapChangerAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TC") .parameterSetId("tc") .staticId("LOAD") @@ -48,7 +48,7 @@ void writeModel() throws SAXException, IOException, XMLStreamException { checkReporter(""" + Test DYD + Dynawaltz models processing - TapChangerAutomaton BBM_TC equipment is not a LoadWithTransformers, the automaton will be skipped + TapChangerAutomaton BBM_TC equipment is not a LoadWithTransformers, the automation system will be skipped """); } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomatonXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomationSystemXmlTest.java similarity index 80% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomatonXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomationSystemXmlTest.java index 4934e8b5e..ed50db613 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomatonXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/EmptyTapChangerBlockingAutomationSystemXmlTest.java @@ -7,8 +7,8 @@ */ package com.powsybl.dynawaltz.xml; -import com.powsybl.dynawaltz.models.automatons.TapChangerAutomatonBuilder; -import com.powsybl.dynawaltz.models.automatons.TapChangerBlockingAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder; import com.powsybl.dynawaltz.models.loads.LoadOneTransformerBuilder; import com.powsybl.iidm.network.Bus; import com.powsybl.iidm.network.VoltageLevel; @@ -22,7 +22,7 @@ /** * @author Laurent Issertial {@literal } */ -class EmptyTapChangerBlockingAutomatonXmlTest extends AbstractDynamicModelXmlTest { +class EmptyTapChangerBlockingAutomationSystemXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { @@ -39,13 +39,13 @@ protected void addDynamicModels() { .staticId("LOAD") .parameterSetId("lot") .build()); - dynamicModels.add(TapChangerBlockingAutomatonBuilder.of(network) + dynamicModels.add(TapChangerBlockingAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TapChangerBlocking") .parameterSetId("TapChangerPar") .transformers("GEN", "LOAD", "BBM_TC") .uMeasurements("NHV1") .build()); - dynamicModels.add(TapChangerAutomatonBuilder.of(network) + dynamicModels.add(TapChangerAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TC") .parameterSetId("tc") .staticId("LOAD2") @@ -60,8 +60,8 @@ void writeModel() throws SAXException, IOException, XMLStreamException { checkReporter(""" + Test DYD + Dynawaltz models processing - TapChangerAutomaton BBM_TC equipment is not a LoadWithTransformers, the automaton will be skipped - None of TapChangerBlockingAutomaton BBM_TapChangerBlocking equipments are TapChangerModel, the automaton will be skipped + TapChangerAutomaton BBM_TC equipment is not a LoadWithTransformers, the automation system will be skipped + None of TapChangerBlockingAutomaton BBM_TapChangerBlocking equipments are TapChangerModel, the automation system will be skipped """); } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/PhaseShiftersXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/PhaseShiftersXmlTest.java index ad7668f06..30e8b79d8 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/PhaseShiftersXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/PhaseShiftersXmlTest.java @@ -9,8 +9,8 @@ import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; import com.powsybl.dynawaltz.models.BlackBoxModel; -import com.powsybl.dynawaltz.models.automatons.phaseshifters.PhaseShifterIAutomatonBuilder; -import com.powsybl.dynawaltz.models.automatons.phaseshifters.PhaseShifterPAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.phaseshifters.PhaseShifterIAutomationSystemBuilder; +import com.powsybl.dynawaltz.models.automationsystems.phaseshifters.PhaseShifterPAutomationSystemBuilder; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.BeforeEach; @@ -66,13 +66,13 @@ void writeLoadModel(String dydName, Function phaseShifte private static Stream providePhaseShifter() { return Stream.of( Arguments.of("phase_shifter_i_dyd", (Function) n -> - PhaseShifterIAutomatonBuilder.of(n) + PhaseShifterIAutomationSystemBuilder.of(n) .dynamicModelId(DYN_NAME) .parameterSetId("ps") .transformer("NGEN_NHV1") .build(), true), Arguments.of("phase_shifter_p_dyd", (Function) n -> - PhaseShifterPAutomatonBuilder.of(n) + PhaseShifterPAutomationSystemBuilder.of(n) .dynamicModelId(DYN_NAME) .parameterSetId("ps") .transformer("NGEN_NHV1") diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomatonExceptionsXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemExceptionsXmlTest.java similarity index 94% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomatonExceptionsXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemExceptionsXmlTest.java index 63b414e83..e8d03f691 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomatonExceptionsXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemExceptionsXmlTest.java @@ -10,7 +10,7 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.dynawaltz.models.BlackBoxModel; import com.powsybl.dynawaltz.models.TransformerSide; -import com.powsybl.dynawaltz.models.automatons.TapChangerAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystemBuilder; import com.powsybl.dynawaltz.models.loads.*; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; @@ -30,7 +30,7 @@ * @author Laurent Issertial {@literal } */ @ExtendWith(CustomParameterResolver.class) -class TapChangerAutomatonExceptionsXmlTest extends AbstractParametrizedDynamicModelXmlTest { +class TapChangerAutomationSystemExceptionsXmlTest extends AbstractParametrizedDynamicModelXmlTest { private static final String LOAD_NAME = "LOAD"; private static final String DYN_LOAD_NAME = "BBM_" + LOAD_NAME; @@ -47,7 +47,7 @@ protected void setupNetwork() { protected void addDynamicModels(TransformerSide side, Function< Network, BlackBoxModel> loadConstructor) { dynamicModels.add(loadConstructor.apply(network)); - dynamicModels.add(TapChangerAutomatonBuilder.of(network) + dynamicModels.add(TapChangerAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TC") .parameterSetId("tc") .staticId(LOAD_NAME) diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomatonXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemXmlTest.java similarity index 88% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomatonXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemXmlTest.java index 889cbec35..47fe9ca54 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomatonXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerAutomationSystemXmlTest.java @@ -8,7 +8,7 @@ package com.powsybl.dynawaltz.xml; import com.powsybl.dynawaltz.models.TransformerSide; -import com.powsybl.dynawaltz.models.automatons.TapChangerAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystemBuilder; import com.powsybl.dynawaltz.models.loads.*; import com.powsybl.iidm.network.Bus; import com.powsybl.iidm.network.VoltageLevel; @@ -22,7 +22,7 @@ /** * @author Laurent Issertial {@literal } */ -class TapChangerAutomatonXmlTest extends AbstractDynamicModelXmlTest { +class TapChangerAutomationSystemXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { @@ -50,18 +50,18 @@ protected void addDynamicModels() { .staticId("LOAD3") .parameterSetId("LTT") .build()); - dynamicModels.add(TapChangerAutomatonBuilder.of(network) + dynamicModels.add(TapChangerAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TC") .parameterSetId("tc") .staticId("LOAD") .build()); - dynamicModels.add(TapChangerAutomatonBuilder.of(network) + dynamicModels.add(TapChangerAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TC2") .parameterSetId("tc") .staticId("LOAD2") .side(TransformerSide.LOW_VOLTAGE) .build()); - dynamicModels.add(TapChangerAutomatonBuilder.of(network) + dynamicModels.add(TapChangerAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TC3") .parameterSetId("tc") .staticId("LOAD3") diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomatonXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomationSystemXmlTest.java similarity index 86% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomatonXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomationSystemXmlTest.java index 3637f68ef..a793eb8d0 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomatonXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingAutomationSystemXmlTest.java @@ -11,7 +11,7 @@ import com.powsybl.dynawaltz.models.loads.LoadOneTransformerTapChangerBuilder; import com.powsybl.dynawaltz.models.loads.LoadTwoTransformersTapChangersBuilder; import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder; -import com.powsybl.dynawaltz.models.automatons.TapChangerBlockingAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder; import com.powsybl.iidm.network.Bus; import com.powsybl.iidm.network.VoltageLevel; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; @@ -27,7 +27,7 @@ /** * @author Laurent Issertial {@literal } */ -class TapChangerBlockingAutomatonXmlTest extends AbstractDynamicModelXmlTest { +class TapChangerBlockingAutomationSystemXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { @@ -54,7 +54,7 @@ protected void addDynamicModels() { .staticId("LOAD2") .parameterSetId("ltt") .build()); - dynamicModels.add(TapChangerBlockingAutomatonBuilder.of(network) + dynamicModels.add(TapChangerBlockingAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TapChangerBlocking") .parameterSetId("TapChangerPar") .transformers("NGEN_NHV1", "NHV2_NLOAD", "LOAD", "LOAD2") @@ -71,12 +71,12 @@ void writeModel() throws SAXException, IOException, XMLStreamException { @Test void testMonitoredEquipmentsLimit() { - TapChangerBlockingAutomatonBuilder builder = TapChangerBlockingAutomatonBuilder.of(network) + TapChangerBlockingAutomationSystemBuilder builder = TapChangerBlockingAutomationSystemBuilder.of(network) .dynamicModelId("TapChanger1") .parameterSetId("TapChangerPar") .transformers("NGEN_NHV1") .uMeasurements("NHV1", "NHV1", "NHV1", "NHV1", "NHV1", "NHV1"); Exception e = assertThrows(PowsyblException.class, builder::build); - assertEquals("Tap changer blocking automaton can only handle 5 measurement points at the same time", e.getMessage()); + assertEquals("Tap changer blocking automation system can only handle 5 measurement points at the same time", e.getMessage()); } } diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingToTapChangerAutomatonXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingToTapChangerAutomationSystemXmlTest.java similarity index 81% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingToTapChangerAutomatonXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingToTapChangerAutomationSystemXmlTest.java index 6a0863fa7..0c3efbe3e 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingToTapChangerAutomatonXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/TapChangerBlockingToTapChangerAutomationSystemXmlTest.java @@ -7,7 +7,7 @@ */ package com.powsybl.dynawaltz.xml; -import com.powsybl.dynawaltz.models.automatons.TapChangerBlockingAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -17,12 +17,12 @@ /** * @author Laurent Issertial {@literal } */ -class TapChangerBlockingToTapChangerAutomatonXmlTest extends TapChangerAutomatonXmlTest { +class TapChangerBlockingToTapChangerAutomationSystemXmlTest extends TapChangerAutomationSystemXmlTest { @Override protected void addDynamicModels() { super.addDynamicModels(); - dynamicModels.add(TapChangerBlockingAutomatonBuilder.of(network) + dynamicModels.add(TapChangerBlockingAutomationSystemBuilder.of(network) .dynamicModelId("BBM_TapChangerBlocking") .parameterSetId("TapChangerPar") .transformers("BBM_TC", "BBM_TC2", "BBM_TC3") diff --git a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/UnderVoltageAutomatonXmlTest.java b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/UnderVoltageAutomationSystemXmlTest.java similarity index 83% rename from dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/UnderVoltageAutomatonXmlTest.java rename to dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/UnderVoltageAutomationSystemXmlTest.java index 6a0439100..66a23717c 100644 --- a/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/UnderVoltageAutomatonXmlTest.java +++ b/dynawaltz/src/test/java/com/powsybl/dynawaltz/xml/UnderVoltageAutomationSystemXmlTest.java @@ -7,7 +7,7 @@ */ package com.powsybl.dynawaltz.xml; -import com.powsybl.dynawaltz.models.automatons.UnderVoltageAutomatonBuilder; +import com.powsybl.dynawaltz.models.automationsystems.UnderVoltageAutomationSystemBuilder; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; @@ -18,7 +18,7 @@ /** * @author Laurent Issertial {@literal } */ -class UnderVoltageAutomatonXmlTest extends AbstractDynamicModelXmlTest { +class UnderVoltageAutomationSystemXmlTest extends AbstractDynamicModelXmlTest { @Override protected void setupNetwork() { @@ -27,7 +27,7 @@ protected void setupNetwork() { @Override protected void addDynamicModels() { - dynamicModels.add(UnderVoltageAutomatonBuilder.of(network) + dynamicModels.add(UnderVoltageAutomationSystemBuilder.of(network) .dynamicModelId("BBM_under_voltage") .parameterSetId("uv") .generator("GEN") diff --git a/dynawaltz/src/test/resources/disconnect_quadripole_dyd.xml b/dynawaltz/src/test/resources/disconnect_branch_dyd.xml similarity index 58% rename from dynawaltz/src/test/resources/disconnect_quadripole_dyd.xml rename to dynawaltz/src/test/resources/disconnect_branch_dyd.xml index 485834e3c..4e74c173d 100644 --- a/dynawaltz/src/test/resources/disconnect_quadripole_dyd.xml +++ b/dynawaltz/src/test/resources/disconnect_branch_dyd.xml @@ -2,12 +2,12 @@ - + - + - - + + diff --git a/dynawaltz/src/test/resources/disconnect_quadripole_par.xml b/dynawaltz/src/test/resources/disconnect_branch_par.xml similarity index 100% rename from dynawaltz/src/test/resources/disconnect_quadripole_par.xml rename to dynawaltz/src/test/resources/disconnect_branch_par.xml diff --git a/dynawaltz/src/test/resources/events.xml b/dynawaltz/src/test/resources/events.xml index d8b10d589..819227bc2 100644 --- a/dynawaltz/src/test/resources/events.xml +++ b/dynawaltz/src/test/resources/events.xml @@ -19,7 +19,7 @@ - + @@ -33,7 +33,7 @@ - - + + diff --git a/pom.xml b/pom.xml index 9e99d3a64..3ec778c88 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.powsybl powsybl-parent - 15 + 18