diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/TransformerConversionTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/TransformerConversionTest.java index 18160be481b..4a8eefb15ff 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/TransformerConversionTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/TransformerConversionTest.java @@ -46,165 +46,134 @@ class TransformerConversionTest { private static final String DIR = "/issues/transformers/"; @Test - void microGridBaseCaseBExfmr2ShuntDefault() { - Conversion.Config config = new Conversion.Config(); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); + void t2wDefaultConfigTest() { + // Load network model with default config + Network n = networkModel(twoWindingTransformers()); + + // TRA is a transformer with a RatioTapChanger, PST is a phase shifter with PhaseTapChanger + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); + assertTrue(t2xCompareFlow(n, "PST", 927.034612, -339.274880, -911.542354, 422.345850)); } @Test - void microGridBaseCaseBExfmr2ShuntEnd1() { + void t2wShuntEnd1Test() { + // All shunt admittances to ground (g, b) at end1 (before transmission impedance) Conversion.Config config = new Conversion.Config(); config.setXfmr2Shunt(Xfmr2ShuntInterpretationAlternative.END1); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); } @Test - void microGridBaseCaseBExfmr2ShuntEnd2() { + void t2wShuntEnd2Test() { + // All shunt admittances to ground (g, b) at end2 (after transmission impedance) Conversion.Config config = new Conversion.Config(); config.setXfmr2Shunt(Xfmr2ShuntInterpretationAlternative.END2); - // Same result as End1, IIDM model and LoadFlowParameters does not allow this configuration - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + // Same result as end1, IIDM model and LoadFlowParameters does not allow this configuration + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); } @Test - void microGridBaseCaseBExfmr2ShuntEnd1End2() { + void t2wShuntEnd1End2Test() { + // Shunt admittances to ground (g, b) at the end where they are defined in Cgmes model Conversion.Config config = new Conversion.Config(); config.setXfmr2Shunt(Xfmr2ShuntInterpretationAlternative.END1_END2); - // Same result as End1, IIDM model and LoadFlowParameters does not allow this configuration - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + // Same result as end1, IIDM model and LoadFlowParameters does not allow this configuration + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); } @Test - void microGridBaseCaseBExfmr2ShuntSplit() { + void t2wShuntSplitTest() { + // Split shunt admittances to ground (g, b) between end1 and end2. Conversion.Config config = new Conversion.Config(); config.setXfmr2Shunt(Xfmr2ShuntInterpretationAlternative.SPLIT); config.setXfmr3Shunt(Xfmr3ShuntInterpretationAlternative.SPLIT); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.970891, -15.839366, 94.275697, 20.952066); - assertTrue(ok); - } + Network n = networkModel(twoWindingTransformers(), config); - @Test - void microGridBaseCaseBExfmr2RatioPhaseDefault() { - Conversion.Config config = new Conversion.Config(); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 927.034612, -339.274880, -911.542354, 422.345850); - assertTrue(ok); + assertTrue(t2xCompareFlow(n, "TRA", -93.970891, -15.839366, 94.275697, 20.952066)); } @Test - void microGridBaseCaseBExfmr2RatioPhaseEnd1() { + void t2wRatioPhaseEnd1Test() { + // All tapChangers (ratioTapChanger and phaseTapChanger) are considered at end1 (before transmission impedance) Conversion.Config config = new Conversion.Config(); config.setXfmr2RatioPhase(Xfmr2RatioPhaseInterpretationAlternative.END1); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -91.807775, 98.389959, 92.184500, -89.747219); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 927.034612, -339.274880, -911.542354, 422.345850); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + assertTrue(t2xCompareFlow(n, "TRA", -91.807775, 98.389959, 92.184500, -89.747219)); + assertTrue(t2xCompareFlow(n, "PST", 927.034612, -339.274880, -911.542354, 422.345850)); } @Test - void microGridBaseCaseBExfmr2RatioPhaseEnd2() { + void t2wRatioPhaseEnd2Test() { + // All tapChangers (ratioTapChanger and phaseTapChanger) are considered at end2 (after transmission impedance) Conversion.Config config = new Conversion.Config(); config.setXfmr2RatioPhase(Xfmr2RatioPhaseInterpretationAlternative.END2); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 58.877292, -201.626411, -58.176878, 205.382102); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); + assertTrue(t2xCompareFlow(n, "PST", 58.877292, -201.626411, -58.176878, 205.382102)); } @Test - void microGridBaseCaseBExfmr2RatioPhaseEnd1End2() { + void t2wRatioPhaseEnd1End2Test() { + // TapChangers (ratioTapChanger and phaseTapChanger) are considered at the end where they are defined in CGMES Conversion.Config config = new Conversion.Config(); config.setXfmr2RatioPhase(Xfmr2RatioPhaseInterpretationAlternative.END1_END2); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 927.034612, -339.274880, -911.542354, 422.345850); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); + assertTrue(t2xCompareFlow(n, "PST", 927.034612, -339.274880, -911.542354, 422.345850)); } @Test - void microGridBaseCaseBExfmr2RatioPhaseX() { + void t2wRatioPhaseXTest() { + // If x1 == 0 all tapChangers (ratioTapChanger and phaseTapChanger) are considered at the end1 + // otherwise they are considered at end2 Conversion.Config config = new Conversion.Config(); config.setXfmr2RatioPhase(Xfmr2RatioPhaseInterpretationAlternative.X); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 58.877292, -201.626411, -58.176878, 205.382102); - assertTrue(ok); - } + Network n = networkModel(twoWindingTransformers(), config); - @Test - void microGridBaseCaseBExfmr2Ratio0Default() { - Conversion.Config config = new Conversion.Config(); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 927.034612, -339.274880, -911.542354, 422.345850); - assertTrue(ok); + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); + assertTrue(t2xCompareFlow(n, "PST", 58.877292, -201.626411, -58.176878, 205.382102)); } @Test - void microGridBaseCaseBExfmr2Ratio0End1() { + void t2wRatio0End1Test() { + // Structural ratio always at end1 (before transmission impedance) Conversion.Config config = new Conversion.Config(); config.setXfmr2StructuralRatio(Xfmr2StructuralRatioInterpretationAlternative.END1); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -0.849849, -0.138409, 0.852591, 0.184615); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 70.106993, -25.657663, -68.935391, 31.939905); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + assertTrue(t2xCompareFlow(n, "TRA", -0.849849, -0.138409, 0.852591, 0.184615)); + assertTrue(t2xCompareFlow(n, "PST", 70.106993, -25.657663, -68.935391, 31.939905)); } @Test - void microGridBaseCaseBExfmr2Ratio0End2() { + void t2wRatio0End2Test() { + // Structural ratio always at end2 (after transmission impedance) Conversion.Config config = new Conversion.Config(); config.setXfmr2StructuralRatio(Xfmr2StructuralRatioInterpretationAlternative.END2); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 927.034612, -339.274880, -911.542354, 422.345850); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); + assertTrue(t2xCompareFlow(n, "PST", 927.034612, -339.274880, -911.542354, 422.345850)); } @Test - void microGridBaseCaseBExfmr2Ratio0X() { + void t2wRatio0XTest() { + // If x1 == 0 structural ratio at end1, otherwise at end2 Conversion.Config config = new Conversion.Config(); config.setXfmr2StructuralRatio(Xfmr2StructuralRatioInterpretationAlternative.X); - Network n = networkModel(CgmesConformity1Catalog.microGridBaseCaseBE(), config); - // RatioTapChanger - boolean ok = t2xCompareFlow(n, "e482b89a-fa84-4ea9-8e70-a83d44790957", -93.855301, -15.285520, 94.158074, 20.388478); - assertTrue(ok); - // PhaseTapChanger - ok = t2xCompareFlow(n, "a708c3bc-465d-4fe7-b6ef-6fa6408a62b0", 927.034612, -339.274880, -911.542354, 422.345850); - assertTrue(ok); + Network n = networkModel(twoWindingTransformers(), config); + + assertTrue(t2xCompareFlow(n, "TRA", -93.855301, -15.285520, 94.158074, 20.388478)); + assertTrue(t2xCompareFlow(n, "PST", 927.034612, -339.274880, -911.542354, 422.345850)); } /** @@ -339,7 +308,7 @@ void microGridBaseCaseBExfmr3Ratio0End3() { @Test void phaseAngleClockTest() { // A 2w- and a 3w-transformer with non-null phase angle clock value on respectively 2nd and 3rd winding - Network n = networkModelWithPhaseAngleClock(phaseAngleClock("PhaseAngleClock_EQ.xml")); + Network n = networkModel(phaseAngleClock("PhaseAngleClock_EQ.xml"), new PhaseAngleClock()); // Phase angle clock values have been correctly read assertEquals(5, n.getTwoWindingsTransformer("T2W").getExtension(TwoWindingsTransformerPhaseAngleClock.class).getPhaseAngleClock()); @@ -354,7 +323,7 @@ void phaseAngleClockTest() { @Test void phaseAngleClockAllZeroTest() { // The same 2w- and a 3w-transformer as in phaseAngleClockTest() but with all phase angle clock equal to 0 - Network n = networkModelWithPhaseAngleClock(phaseAngleClock("PhaseAngleClock_EQ_AllZero.xml")); + Network n = networkModel(phaseAngleClock("PhaseAngleClock_EQ_AllZero.xml"), new PhaseAngleClock()); // No phase angle clock extension has been created since all values are equal to 0 assertNull(n.getTwoWindingsTransformer("T2W").getExtension(TwoWindingsTransformerPhaseAngleClock.class)); @@ -368,7 +337,7 @@ void phaseAngleClockAllZeroTest() { @Test void phaseAngleClockAllNonZeroTest() { // The same 2w- and a 3w-transformer as in phaseAngleClockTest() but with non-null phase angle clock value on all windings - Network n = networkModelWithPhaseAngleClock(phaseAngleClock("PhaseAngleClock_EQ_AllNonZero.xml")); + Network n = networkModel(phaseAngleClock("PhaseAngleClock_EQ_AllNonZero.xml"), new PhaseAngleClock()); // Non-null phase angle clock values on 1st winding are discarded, the other ones are correctly read assertEquals(5, n.getTwoWindingsTransformer("T2W").getExtension(TwoWindingsTransformerPhaseAngleClock.class).getPhaseAngleClock()); @@ -436,20 +405,24 @@ private boolean t3xCompareFlow(Network n, String id, double p1, double q1, doubl return ok; } - private Network networkModelWithPhaseAngleClock(GridModelReference gridModelReference) { + private Network networkModel(GridModelReference gridModelReference) { + return networkModel(gridModelReference, new Conversion.Config(), Collections.emptyList()); + } + + private Network networkModel(GridModelReference gridModelReference, CgmesImportPostProcessor postProcessor) { List postProcessors = new ArrayList<>(); - postProcessors.add(new PhaseAngleClock()); + postProcessors.add(postProcessor); return networkModel(gridModelReference, new Conversion.Config(), postProcessors); } - private Network networkModel(GridModelReference testGridModel, Conversion.Config config) { - return networkModel(testGridModel, config, Collections.emptyList()); + private Network networkModel(GridModelReference gridModelReference, Conversion.Config config) { + return networkModel(gridModelReference, config, Collections.emptyList()); } - private Network networkModel(GridModelReference testGridModel, Conversion.Config config, List postProcessors) { + private Network networkModel(GridModelReference gridModelReference, Conversion.Config config, List postProcessors) { config.setConvertSvInjections(true); - Network n = ConversionUtil.networkModel(testGridModel, config, postProcessors); + Network n = ConversionUtil.networkModel(gridModelReference, config, postProcessors); double threshold = 0.01; ValidationConfig vconfig = loadFlowValidationConfig(threshold); @@ -459,6 +432,17 @@ private Network networkModel(GridModelReference testGridModel, Conversion.Config return n; } + private GridModelReferenceResources twoWindingTransformers() { + return new GridModelReferenceResources( + "TwoWindingsTransformers", + null, + new ResourceSet(DIR, + "TwoWindingsTransformers_EQ.xml", + "TwoWindingsTransformers_SSH.xml", + "TwoWindingsTransformers_SV.xml", + "TwoWindingsTransformers_TP.xml")); + } + private GridModelReferenceResources phaseAngleClock(String phaseAngleClockEQ) { return new GridModelReferenceResources( "PhaseAngleClock", diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_EQ.xml b/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_EQ.xml new file mode 100644 index 00000000000..098299fa15f --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_EQ.xml @@ -0,0 +1,249 @@ + + + 2021-03-01T23:00:00Z + 2021-03-02T10:22:58Z + Two windings transformer + 001 + http://entsoe.eu/CIM/EquipmentCore/3/1 + http://entsoe.eu/CIM/EquipmentOperation/3/1 + powsybl.org + + + Geographical region + + + Subgeographical region + + + + Substation + + + + Voltage level 400 kV + + + + + Voltage level 110 kV + + + + + Voltage level 10.5 kV + + + + + Phase shifter + + + + Phase shifter end 1 + 2.707692 + 14.518904 + 0 + 0 + 2.72 + 14.516604 + 0 + 0 + 0 + 0 + 650 + 400 + 1 + 0 + false + + + + + + + Terminal PST_E1 + 1 + + + + + Node 1 + + + + Phase shifter end 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 650 + 110 + 2 + 0 + false + + + + + + + Terminal PST_E2 + 2 + + + + + Node 2 + + + + Phase tap changer + 400 + 1 + 25 + 13 + 10 + 1.25 + 14.518904 + 14.518904 + 90.000000 + + true + + + + Phase tap changer control + + + + + Power transformer + + + + Power transformer end 1 + 0.104711 + 5.843419 + -0.0000830339 + 0.0000173295 + 0.104711 + 5.843419 + 0 + 0 + 0 + 0 + 250 + 110.343750 + 1 + 0 + false + + + + + + + Terminal TRA_E1 + 1 + + + + + Power transformer end 2 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 250 + 10.5 + 2 + 0 + false + + + + + + + Terminal TRA_E2 + 2 + + + + + Node 3 + + + + Ratio tap changer + 10.5 + 1 + 33 + 17 + 14 + 0.8 + true + + + + + + Ratio tap changer control + + + + + Busbar section 1 + + + + Terminal BBS_1 + 1 + + + + + Busbar section 2 + + + + Terminal BBS_2 + 1 + + + + + Busbar section 3 + + + + Terminal BBS_3 + 1 + + + + + 400 kV + 400 + + + 110 kV + 110 + + + 10.5 kV + 10.5 + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_SSH.xml b/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_SSH.xml new file mode 100644 index 00000000000..4d890ef3939 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_SSH.xml @@ -0,0 +1,55 @@ + + + 2021-03-01T23:00:00Z + 2021-03-02T10:22:58Z + Two windings transformer + 001 + http://entsoe.eu/CIM/SteadyStateHypothesis/1/1 + powsybl.org + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + 14 + true + + + true + 10 + + + true + 35 + + true + -65 + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_SV.xml b/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_SV.xml new file mode 100644 index 00000000000..e14419012d0 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_SV.xml @@ -0,0 +1,25 @@ + + + 2021-03-01T23:00:00Z + 2021-03-02T10:22:58Z + Two windings transformer + 001 + http://entsoe.eu/CIM/StateVariables/4/1 + powsybl.org + + + -6.780710 + 412.989001 + + + + -9.391330 + 115.5 + + + + -7.057180 + 10.820805 + + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_TP.xml b/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_TP.xml new file mode 100644 index 00000000000..3fcf5f14db0 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/transformers/TwoWindingsTransformers_TP.xml @@ -0,0 +1,46 @@ + + + 2021-03-01T23:00:00Z + 2021-03-02T10:22:58Z + Two windings transformer + 001 + http://entsoe.eu/CIM/Topology/4/1 + powsybl.org + + + Topological node 1 + + + + + Topological node 2 + + + + + Topological node 3 + + + + + + + + + + + + + + + + + + + + + + + + +