Skip to content

Commit 067edfd

Browse files
committed
Add magnetizing reactance support to TwoWindingsTransformerFortescue
Signed-off-by: Coline Piloquet <coline.piloquet@rte-france.com>
1 parent dc04679 commit 067edfd

File tree

11 files changed

+178
-9
lines changed

11 files changed

+178
-9
lines changed

iidm/iidm-extensions/src/main/java/com/powsybl/iidm/network/extensions/TwoWindingsTransformerFortescue.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ default String getName() {
4444

4545
void setFreeFluxes(boolean freeFluxes);
4646

47+
/**
48+
* The magnetizing reactance of the two-winding transformer, if not considered as infinite.
49+
*/
50+
double getXm();
51+
52+
void setXm(double xm);
53+
4754
/**
4855
* Get the winding connection type of transformer side 1, see {@link WindingConnectionType}).
4956
*/

iidm/iidm-extensions/src/main/java/com/powsybl/iidm/network/extensions/TwoWindingsTransformerFortescueAdder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public interface TwoWindingsTransformerFortescueAdder extends ExtensionAdder<Two
2222

2323
TwoWindingsTransformerFortescueAdder withFreeFluxes(boolean freeFluxes);
2424

25+
TwoWindingsTransformerFortescueAdder withXm(double xm);
26+
2527
TwoWindingsTransformerFortescueAdder withConnectionType1(WindingConnectionType connectionType1);
2628

2729
TwoWindingsTransformerFortescueAdder withConnectionType2(WindingConnectionType connectionType2);

iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/extensions/TwoWindingsTransformerFortescueAdderImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class TwoWindingsTransformerFortescueAdderImpl extends AbstractExtensionA
2626
private double rz = Double.NaN;
2727
private double xz = Double.NaN;
2828
private boolean freeFluxes = DEFAULT_FREE_FLUXES;
29+
private double xm = Double.NaN;
2930
private WindingConnectionType connectionType1 = DEFAULT_LEG1_CONNECTION_TYPE;
3031
private WindingConnectionType connectionType2 = DEFAULT_LEG2_CONNECTION_TYPE;
3132
private double groundingR1 = DEFAULT_GROUNDING_R;
@@ -44,7 +45,7 @@ public Class<? super TwoWindingsTransformerFortescue> getExtensionClass() {
4445

4546
@Override
4647
protected TwoWindingsTransformerFortescueImpl createExtension(TwoWindingsTransformer twt) {
47-
return new TwoWindingsTransformerFortescueImpl(twt, rz, xz, freeFluxes, connectionType1, connectionType2, groundingR1, groundingX1, groundingR2, groundingX2);
48+
return new TwoWindingsTransformerFortescueImpl(twt, rz, xz, freeFluxes, xm, connectionType1, connectionType2, groundingR1, groundingX1, groundingR2, groundingX2);
4849
}
4950

5051
@Override
@@ -65,6 +66,12 @@ public TwoWindingsTransformerFortescueAdderImpl withFreeFluxes(boolean freeFluxe
6566
return this;
6667
}
6768

69+
@Override
70+
public TwoWindingsTransformerFortescueAdderImpl withXm(double xm) {
71+
this.xm = xm;
72+
return this;
73+
}
74+
6875
@Override
6976
public TwoWindingsTransformerFortescueAdderImpl withConnectionType1(WindingConnectionType connectionType1) {
7077
this.connectionType1 = Objects.requireNonNull(connectionType1);

iidm/iidm-impl/src/main/java/com/powsybl/iidm/network/impl/extensions/TwoWindingsTransformerFortescueImpl.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,22 @@ public class TwoWindingsTransformerFortescueImpl extends AbstractExtension<TwoWi
2323
private double rz;
2424
private double xz;
2525
private boolean freeFluxes;
26+
private double xm;
2627
private WindingConnectionType connectionType1;
2728
private WindingConnectionType connectionType2;
2829
private double groundingR1;
2930
private double groundingX1;
3031
private double groundingR2;
3132
private double groundingX2;
3233

33-
public TwoWindingsTransformerFortescueImpl(TwoWindingsTransformer twt, double rz, double xz, boolean freeFluxes,
34+
public TwoWindingsTransformerFortescueImpl(TwoWindingsTransformer twt, double rz, double xz, boolean freeFluxes, double xm,
3435
WindingConnectionType connectionType1, WindingConnectionType connectionType2,
3536
double groundingR1, double groundingX1, double groundingR2, double groundingX2) {
3637
super(twt);
3738
this.rz = rz;
3839
this.xz = xz;
3940
this.freeFluxes = freeFluxes;
41+
this.xm = xm;
4042
this.connectionType1 = Objects.requireNonNull(connectionType1);
4143
this.connectionType2 = Objects.requireNonNull(connectionType2);
4244
this.groundingR1 = groundingR1;
@@ -70,6 +72,16 @@ public boolean isFreeFluxes() {
7072
return freeFluxes;
7173
}
7274

75+
@Override
76+
public double getXm() {
77+
return xm;
78+
}
79+
80+
@Override
81+
public void setXm(double xm) {
82+
this.xm = xm;
83+
}
84+
7385
@Override
7486
public void setFreeFluxes(boolean freeFluxes) {
7587
this.freeFluxes = freeFluxes;

iidm/iidm-serde/src/main/java/com/powsybl/iidm/serde/extensions/TwoWindingsTransformerFortescueSerDe.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,53 @@
88
package com.powsybl.iidm.serde.extensions;
99

1010
import com.google.auto.service.AutoService;
11-
import com.powsybl.commons.extensions.AbstractExtensionSerDe;
1211
import com.powsybl.commons.extensions.ExtensionSerDe;
1312
import com.powsybl.commons.io.DeserializerContext;
1413
import com.powsybl.commons.io.SerializerContext;
1514
import com.powsybl.iidm.network.TwoWindingsTransformer;
1615
import com.powsybl.iidm.network.extensions.TwoWindingsTransformerFortescue;
1716
import com.powsybl.iidm.network.extensions.TwoWindingsTransformerFortescueAdder;
1817
import com.powsybl.iidm.network.extensions.WindingConnectionType;
18+
import com.powsybl.iidm.serde.IidmVersion;
1919

2020
/**
2121
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>}
2222
*/
2323
@AutoService(ExtensionSerDe.class)
24-
public class TwoWindingsTransformerFortescueSerDe extends AbstractExtensionSerDe<TwoWindingsTransformer, TwoWindingsTransformerFortescue> {
24+
public class TwoWindingsTransformerFortescueSerDe extends AbstractVersionableNetworkExtensionSerDe<TwoWindingsTransformer, TwoWindingsTransformerFortescue, TwoWindingsTransformerFortescueSerDe.Version> {
25+
26+
public enum Version implements SerDeVersion<Version> {
27+
V_1_0("/xsd/twoWindingsTransformerFortescue_V1_0.xsd", "http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_0",
28+
new VersionNumbers(1, 0), IidmVersion.V_1_0, IidmVersion.V_1_15),
29+
V_1_1("/xsd/twoWindingsTransformerFortescue_V1_1.xsd", "http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_1",
30+
new VersionNumbers(1, 1), IidmVersion.V_1_0, null);
31+
32+
private final VersionInfo versionInfo;
33+
34+
Version(String xsdResourcePath, String namespaceUri, VersionNumbers versionNumbers, IidmVersion minIidmVersionIncluded, IidmVersion maxIidmVersionExcluded) {
35+
this.versionInfo = new VersionInfo(xsdResourcePath, namespaceUri, "t2f", versionNumbers,
36+
minIidmVersionIncluded, maxIidmVersionExcluded, TwoWindingsTransformerFortescue.NAME);
37+
}
38+
39+
@Override
40+
public VersionInfo getVersionInfo() {
41+
return versionInfo;
42+
}
43+
}
2544

2645
public TwoWindingsTransformerFortescueSerDe() {
27-
super("twoWindingsTransformerFortescue", "network", TwoWindingsTransformerFortescue.class,
28-
"twoWindingsTransformerFortescue_V1_0.xsd", "http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_0",
29-
"t2f");
46+
super(TwoWindingsTransformerFortescue.NAME, TwoWindingsTransformerFortescue.class, Version.values());
3047
}
3148

3249
@Override
3350
public void write(TwoWindingsTransformerFortescue twtFortescue, SerializerContext context) {
3451
context.getWriter().writeDoubleAttribute("rz", twtFortescue.getRz(), Double.NaN);
3552
context.getWriter().writeDoubleAttribute("xz", twtFortescue.getXz(), Double.NaN);
3653
context.getWriter().writeBooleanAttribute("freeFluxes", twtFortescue.isFreeFluxes());
54+
Version extVersion = getExtensionVersionToExport(context);
55+
if (extVersion.isGreaterThan(Version.V_1_0)) {
56+
context.getWriter().writeDoubleAttribute("xm", twtFortescue.getXm(), Double.NaN);
57+
}
3758
context.getWriter().writeEnumAttribute("connectionType1", twtFortescue.getConnectionType1());
3859
context.getWriter().writeEnumAttribute("connectionType2", twtFortescue.getConnectionType2());
3960
context.getWriter().writeDoubleAttribute("groundingR1", twtFortescue.getGroundingR1(), 0);
@@ -47,6 +68,11 @@ public TwoWindingsTransformerFortescue read(TwoWindingsTransformer twt, Deserial
4768
double rz = context.getReader().readDoubleAttribute("rz");
4869
double xz = context.getReader().readDoubleAttribute("xz");
4970
boolean freeFluxes = context.getReader().readBooleanAttribute("freeFluxes");
71+
double xm = Double.NaN;
72+
Version extVersion = getExtensionVersionImported(context);
73+
if (extVersion.isGreaterThan(Version.V_1_0)) {
74+
xm = context.getReader().readDoubleAttribute("xm");
75+
}
5076
WindingConnectionType connectionType1 = context.getReader().readEnumAttribute("connectionType1", WindingConnectionType.class);
5177
WindingConnectionType connectionType2 = context.getReader().readEnumAttribute("connectionType2", WindingConnectionType.class);
5278
double groundingR1 = context.getReader().readDoubleAttribute("groundingR1", 0);
@@ -58,6 +84,7 @@ public TwoWindingsTransformerFortescue read(TwoWindingsTransformer twt, Deserial
5884
.withRz(rz)
5985
.withXz(xz)
6086
.withFreeFluxes(freeFluxes)
87+
.withXm(xm)
6188
.withConnectionType1(connectionType1)
6289
.withConnectionType2(connectionType2)
6390
.withGroundingR1(groundingR1)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (c) 2026, RTE (http://www.rte-france.com)
5+
This Source Code Form is subject to the terms of the Mozilla Public
6+
License, v. 2.0. If a copy of the MPL was not distributed with this
7+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
8+
SPDX-License-Identifier: MPL-2.0
9+
10+
-->
11+
<xs:schema version="1.0"
12+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
13+
xmlns:t2f="http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_1"
14+
targetNamespace="http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_1"
15+
elementFormDefault="qualified">
16+
<xs:simpleType name="WindingConnectionType">
17+
<xs:restriction base="xs:string">
18+
<xs:enumeration value="Y"/>
19+
<xs:enumeration value="Y_GROUNDED"/>
20+
<xs:enumeration value="DELTA"/>
21+
</xs:restriction>
22+
</xs:simpleType>
23+
<xs:element name="twoWindingsTransformerFortescue">
24+
<xs:complexType>
25+
<xs:attribute name="rz" type="xs:double"/>
26+
<xs:attribute name="xz" type="xs:double"/>
27+
<xs:attribute name="freeFluxes" use="required" type="xs:boolean"/>
28+
<xs:attribute name="xm" type="xs:double"/>
29+
<xs:attribute name="connectionType1" use="required" type="t2f:WindingConnectionType"/>
30+
<xs:attribute name="connectionType2" use="required" type="t2f:WindingConnectionType"/>
31+
<xs:attribute name="groundingR1" type="xs:double"/>
32+
<xs:attribute name="groundingX1" type="xs:double"/>
33+
<xs:attribute name="groundingR2" type="xs:double"/>
34+
<xs:attribute name="groundingX2" type="xs:double"/>
35+
</xs:complexType>
36+
</xs:element>
37+
</xs:schema>

iidm/iidm-serde/src/test/java/com/powsybl/iidm/serde/extensions/TwoWindingsTransformerFortescueXmlSerDeTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,34 @@ void testXmlSerializer() throws IOException {
6161
assertEquals(fortescue.getGroundingR2(), fortescue2.getGroundingR2(), 0);
6262
assertEquals(fortescue.getGroundingX2(), fortescue2.getGroundingX2(), 0);
6363
}
64+
65+
@Test
66+
void testXmlSerializerWithMagnetizingReactance() throws IOException {
67+
Network network = EurostagTutorialExample1Factory.create();
68+
network.setCaseDate(ZonedDateTime.parse("2016-12-07T11:18:52.881+01:00"));
69+
var twt = network.getTwoWindingsTransformer("NGEN_NHV1");
70+
assertNotNull(twt);
71+
TwoWindingsTransformerFortescue fortescue = twt.newExtension(TwoWindingsTransformerFortescueAdder.class)
72+
.withRz(0.1d)
73+
.withXz(2d)
74+
.withFreeFluxes(false)
75+
.withXm(0.5d)
76+
.withConnectionType1(WindingConnectionType.Y_GROUNDED)
77+
.withConnectionType2(WindingConnectionType.DELTA)
78+
.withGroundingR1(0.02d)
79+
.withGroundingX1(0.3d)
80+
.withGroundingR2(0.04d)
81+
.withGroundingX2(0.95d)
82+
.add();
83+
84+
Network network2 = allFormatsRoundTripTest(network, "/fortescue/twoWindingsTransformerFortescueWithMagnetizingReactanceRef.xml");
85+
86+
TwoWindingsTransformer twt2 = network2.getTwoWindingsTransformer("NGEN_NHV1");
87+
assertNotNull(twt2);
88+
TwoWindingsTransformerFortescue fortescue2 = twt2.getExtension(TwoWindingsTransformerFortescue.class);
89+
assertNotNull(fortescue2);
90+
91+
assertEquals(fortescue.isFreeFluxes(), fortescue2.isFreeFluxes());
92+
assertEquals(fortescue.getXm(), fortescue2.getXm());
93+
}
6494
}

iidm/iidm-serde/src/test/resources/V1_15/europeanLvTestFeederRef.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" xmlns:lf="http://www.powsybl.org/schema/iidm/ext/line_fortescue/1_0" xmlns:las="http://www.powsybl.org/schema/iidm/ext/load_asymmetrical/1_0" xmlns:gf="http://www.powsybl.org/schema/iidm/ext/generator_fortescue/1_0" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" xmlns:t2f="http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_0" id="EuropeanLvTestFeeder" caseDate="2023-04-11T23:59:00.000+01:00" forecastDistance="0" sourceFormat="csv" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
2+
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" xmlns:lf="http://www.powsybl.org/schema/iidm/ext/line_fortescue/1_0" xmlns:las="http://www.powsybl.org/schema/iidm/ext/load_asymmetrical/1_0" xmlns:gf="http://www.powsybl.org/schema/iidm/ext/generator_fortescue/1_0" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" xmlns:t2f="http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_1" id="EuropeanLvTestFeeder" caseDate="2023-04-11T23:59:00.000+01:00" forecastDistance="0" sourceFormat="csv" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
33
<iidm:substation id="Substation-1">
44
<iidm:voltageLevel id="SourceVoltageLevel" nominalV="11.0" topologyKind="BUS_BREAKER">
55
<iidm:busBreakerTopology>

iidm/iidm-serde/src/test/resources/fortescue/twoWindingsTransformerFortescueRef.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" xmlns:t2f="http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_0" id="sim1" caseDate="2016-12-07T11:18:52.881+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
2+
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" xmlns:t2f="http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_1" id="sim1" caseDate="2016-12-07T11:18:52.881+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
33
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
44
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
55
<iidm:busBreakerTopology>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_15" xmlns:t2f="http://www.powsybl.org/schema/iidm/ext/two_windings_transformer_fortescue/1_1" id="sim1" caseDate="2016-12-07T11:18:52.881+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
3+
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
4+
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
5+
<iidm:busBreakerTopology>
6+
<iidm:bus id="NGEN"/>
7+
</iidm:busBreakerTopology>
8+
<iidm:generator id="GEN" energySource="OTHER" minP="-9999.99" maxP="9999.99" voltageRegulatorOn="true" targetP="607.0" targetV="24.5" targetQ="301.0" bus="NGEN" connectableBus="NGEN">
9+
<iidm:minMaxReactiveLimits minQ="-9999.99" maxQ="9999.99"/>
10+
</iidm:generator>
11+
</iidm:voltageLevel>
12+
<iidm:voltageLevel id="VLHV1" nominalV="380.0" topologyKind="BUS_BREAKER">
13+
<iidm:busBreakerTopology>
14+
<iidm:bus id="NHV1"/>
15+
</iidm:busBreakerTopology>
16+
</iidm:voltageLevel>
17+
<iidm:twoWindingsTransformer id="NGEN_NHV1" r="0.26658461538461536" x="11.104492831516762" g="0.0" b="0.0" ratedU1="24.0" ratedU2="400.0" bus1="NGEN" connectableBus1="NGEN" voltageLevelId1="VLGEN" bus2="NHV1" connectableBus2="NHV1" voltageLevelId2="VLHV1"/>
18+
</iidm:substation>
19+
<iidm:substation id="P2" country="FR" tso="RTE" geographicalTags="B">
20+
<iidm:voltageLevel id="VLHV2" nominalV="380.0" topologyKind="BUS_BREAKER">
21+
<iidm:busBreakerTopology>
22+
<iidm:bus id="NHV2"/>
23+
</iidm:busBreakerTopology>
24+
</iidm:voltageLevel>
25+
<iidm:voltageLevel id="VLLOAD" nominalV="150.0" topologyKind="BUS_BREAKER">
26+
<iidm:busBreakerTopology>
27+
<iidm:bus id="NLOAD"/>
28+
</iidm:busBreakerTopology>
29+
<iidm:load id="LOAD" loadType="UNDEFINED" p0="600.0" q0="200.0" bus="NLOAD" connectableBus="NLOAD"/>
30+
</iidm:voltageLevel>
31+
<iidm:twoWindingsTransformer id="NHV2_NLOAD" r="0.04724999999999999" x="4.049724365620455" g="0.0" b="0.0" ratedU1="400.0" ratedU2="158.0" bus1="NHV2" connectableBus1="NHV2" voltageLevelId1="VLHV2" bus2="NLOAD" connectableBus2="NLOAD" voltageLevelId2="VLLOAD">
32+
<iidm:ratioTapChanger lowTapPosition="0" tapPosition="1" targetDeadband="0.0" loadTapChangingCapabilities="true" regulating="true" regulationMode="VOLTAGE" regulationValue="158.0">
33+
<iidm:terminalRef id="NHV2_NLOAD" side="TWO"/>
34+
<iidm:step r="0.0" x="0.0" g="0.0" b="0.0" rho="0.8505666905244191"/>
35+
<iidm:step r="0.0" x="0.0" g="0.0" b="0.0" rho="1.0006666666666666"/>
36+
<iidm:step r="0.0" x="0.0" g="0.0" b="0.0" rho="1.150766642808914"/>
37+
</iidm:ratioTapChanger>
38+
</iidm:twoWindingsTransformer>
39+
</iidm:substation>
40+
<iidm:line id="NHV1_NHV2_1" r="3.0" x="33.0" g1="0.0" b1="1.93E-4" g2="0.0" b2="1.93E-4" bus1="NHV1" connectableBus1="NHV1" voltageLevelId1="VLHV1" bus2="NHV2" connectableBus2="NHV2" voltageLevelId2="VLHV2"/>
41+
<iidm:line id="NHV1_NHV2_2" r="3.0" x="33.0" g1="0.0" b1="1.93E-4" g2="0.0" b2="1.93E-4" bus1="NHV1" connectableBus1="NHV1" voltageLevelId1="VLHV1" bus2="NHV2" connectableBus2="NHV2" voltageLevelId2="VLHV2"/>
42+
<iidm:extension id="NGEN_NHV1">
43+
<t2f:twoWindingsTransformerFortescue rz="0.1" xz="2.0" freeFluxes="false" xm="0.5" connectionType1="Y_GROUNDED" connectionType2="DELTA" groundingR1="0.02" groundingX1="0.3" groundingR2="0.04" groundingX2="0.95"/>
44+
</iidm:extension>
45+
</iidm:network>

0 commit comments

Comments
 (0)