Skip to content

Commit

Permalink
Import Matpower voltage limits (#2025)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
  • Loading branch information
geofjamg authored Mar 21, 2022
1 parent 4bd3cb5 commit f1a63e2
Show file tree
Hide file tree
Showing 9 changed files with 570 additions and 551 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ private static void createBuses(MatpowerModel model, ContainersMapping container
context.getSlackBuses().add(bus);
}

// create voltage limits
createVoltageLimits(mBus, voltageLevel);

// create load
createLoad(mBus, voltageLevel);

Expand All @@ -130,6 +133,22 @@ private static void createBuses(MatpowerModel model, ContainersMapping container
}
}

private static void createVoltageLimits(MBus mBus, VoltageLevel voltageLevel) {
// as in IIDM, we only have one min and one max voltage level by voltage level we keep only the most severe ones
if (mBus.getMinimumVoltageMagnitude() != 0) {
double lowVoltageLimit = mBus.getMinimumVoltageMagnitude() * voltageLevel.getNominalV();
if (Double.isNaN(voltageLevel.getLowVoltageLimit()) || lowVoltageLimit > voltageLevel.getLowVoltageLimit()) {
voltageLevel.setLowVoltageLimit(lowVoltageLimit);
}
}
if (mBus.getMaximumVoltageMagnitude() != 0) {
double highVoltageLimit = mBus.getMaximumVoltageMagnitude() * voltageLevel.getNominalV();
if (Double.isNaN(voltageLevel.getHighVoltageLimit()) || highVoltageLimit < voltageLevel.getHighVoltageLimit()) {
voltageLevel.setHighVoltageLimit(highVoltageLimit);
}
}
}

private static void createGenerators(MatpowerModel model, MBus mBus, VoltageLevel voltageLevel) {
for (MGen mGen : model.getGeneratorsByBusNum(mBus.getNumber())) {
String busId = getId(BUS_PREFIX, mGen.getNumber());
Expand Down
236 changes: 118 additions & 118 deletions matpower/matpower-converter/src/test/resources/ieee118.xiidm

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_7" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_4" id="ieee14-phase-shifter" caseDate="2020-01-01T00:00:00.000Z" forecastDistance="0" sourceFormat="MATPOWER" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="SUB-8">
<iidm:voltageLevel id="VL-1" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-1" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-1" v="1.06" angle="0.0"/>
</iidm:busBreakerTopology>
Expand All @@ -11,7 +11,7 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-9">
<iidm:voltageLevel id="VL-2" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-2" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-2" v="1.0449999999999997" angle="-5.000328510465844"/>
</iidm:busBreakerTopology>
Expand All @@ -22,7 +22,7 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-10">
<iidm:voltageLevel id="VL-3" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-3" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-3" v="1.01" angle="-12.78892335601888"/>
</iidm:busBreakerTopology>
Expand All @@ -33,18 +33,18 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-4">
<iidm:voltageLevel id="VL-4" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-4" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-4" v="1.0173494845822744" angle="-10.412306262257337"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-4" loadType="UNDEFINED" p0="47.8" q0="-3.9" bus="BUS-4" connectableBus="BUS-4"/>
</iidm:voltageLevel>
<iidm:voltageLevel id="VL-7" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-7" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-7" v="1.061731342223832" angle="-10.185085117783457"/>
</iidm:busBreakerTopology>
</iidm:voltageLevel>
<iidm:voltageLevel id="VL-9" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-9" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-9" v="1.0582629220284285" angle="-12.65099581261227"/>
</iidm:busBreakerTopology>
Expand All @@ -61,13 +61,13 @@
<iidm:twoWindingsTransformer id="TWT-4-9" r="0.0" x="0.0055618" g="0.0" b="0.0" ratedU1="0.969" ratedU2="1.0" bus1="BUS-4" connectableBus1="BUS-4" voltageLevelId1="VL-4" bus2="BUS-9" connectableBus2="BUS-9" voltageLevelId2="VL-9"/>
</iidm:substation>
<iidm:substation id="SUB-11">
<iidm:voltageLevel id="VL-5" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-5" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-5" v="1.0200789534978287" angle="-8.724093100611777"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-5" loadType="UNDEFINED" p0="7.6" q0="1.6" bus="BUS-5" connectableBus="BUS-5"/>
</iidm:voltageLevel>
<iidm:voltageLevel id="VL-6" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-6" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-6" v="1.07" angle="-13.22467775771849"/>
</iidm:busBreakerTopology>
Expand All @@ -79,7 +79,7 @@
<iidm:twoWindingsTransformer id="TWT-5-6" r="0.0" x="0.0025202000000000002" g="0.0" b="0.0" ratedU1="0.932" ratedU2="1.0" bus1="BUS-5" connectableBus1="BUS-5" voltageLevelId1="VL-5" bus2="BUS-6" connectableBus2="BUS-6" voltageLevelId2="VL-6"/>
</iidm:substation>
<iidm:substation id="SUB-6">
<iidm:voltageLevel id="VL-8" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-8" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-8" v="1.09" angle="-10.185085117783467"/>
</iidm:busBreakerTopology>
Expand All @@ -89,39 +89,39 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-7">
<iidm:voltageLevel id="VL-10" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-10" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-10" v="1.0531461836881817" angle="-13.035710471997398"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-10" loadType="UNDEFINED" p0="9.0" q0="5.8" bus="BUS-10" connectableBus="BUS-10"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-5">
<iidm:voltageLevel id="VL-11" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-11" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-11" v="1.0582558695370825" angle="-13.25292235374066"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-11" loadType="UNDEFINED" p0="3.5" q0="1.8" bus="BUS-11" connectableBus="BUS-11"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-3">
<iidm:voltageLevel id="VL-12" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-12" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-12" v="1.0551462766263606" angle="-13.988186540628082"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-12" loadType="UNDEFINED" p0="6.1" q0="1.6" bus="BUS-12" connectableBus="BUS-12"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-2">
<iidm:voltageLevel id="VL-13" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-13" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-13" v="1.0509495051495474" angle="-13.97721516091526"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-13" loadType="UNDEFINED" p0="13.5" q0="5.8" bus="BUS-13" connectableBus="BUS-13"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-1">
<iidm:voltageLevel id="VL-14" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-14" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-14" v="1.037140277380203" angle="-14.223902738389041"/>
</iidm:busBreakerTopology>
Expand Down
28 changes: 14 additions & 14 deletions matpower/matpower-converter/src/test/resources/ieee14.xiidm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_7" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_4" id="ieee14" caseDate="2020-01-01T00:00:00.000Z" forecastDistance="0" sourceFormat="MATPOWER" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="SUB-8">
<iidm:voltageLevel id="VL-1" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-1" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-1" v="1.06" angle="0.0"/>
</iidm:busBreakerTopology>
Expand All @@ -11,7 +11,7 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-9">
<iidm:voltageLevel id="VL-2" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-2" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-2" v="1.045" angle="-4.98"/>
</iidm:busBreakerTopology>
Expand All @@ -22,7 +22,7 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-10">
<iidm:voltageLevel id="VL-3" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-3" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-3" v="1.01" angle="-12.72"/>
</iidm:busBreakerTopology>
Expand All @@ -33,18 +33,18 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-4">
<iidm:voltageLevel id="VL-4" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-4" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-4" v="1.019" angle="-10.33"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-4" loadType="UNDEFINED" p0="47.8" q0="-3.9" bus="BUS-4" connectableBus="BUS-4"/>
</iidm:voltageLevel>
<iidm:voltageLevel id="VL-7" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-7" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-7" v="1.062" angle="-13.37"/>
</iidm:busBreakerTopology>
</iidm:voltageLevel>
<iidm:voltageLevel id="VL-9" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-9" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-9" v="1.056" angle="-14.94"/>
</iidm:busBreakerTopology>
Expand All @@ -57,13 +57,13 @@
<iidm:twoWindingsTransformer id="TWT-4-9" r="0.0" x="0.0055618" g="0.0" b="0.0" ratedU1="0.969" ratedU2="1.0" bus1="BUS-4" connectableBus1="BUS-4" voltageLevelId1="VL-4" bus2="BUS-9" connectableBus2="BUS-9" voltageLevelId2="VL-9"/>
</iidm:substation>
<iidm:substation id="SUB-11">
<iidm:voltageLevel id="VL-5" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-5" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-5" v="1.02" angle="-8.78"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-5" loadType="UNDEFINED" p0="7.6" q0="1.6" bus="BUS-5" connectableBus="BUS-5"/>
</iidm:voltageLevel>
<iidm:voltageLevel id="VL-6" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-6" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-6" v="1.07" angle="-14.22"/>
</iidm:busBreakerTopology>
Expand All @@ -75,7 +75,7 @@
<iidm:twoWindingsTransformer id="TWT-5-6" r="0.0" x="0.0025202000000000002" g="0.0" b="0.0" ratedU1="0.932" ratedU2="1.0" bus1="BUS-5" connectableBus1="BUS-5" voltageLevelId1="VL-5" bus2="BUS-6" connectableBus2="BUS-6" voltageLevelId2="VL-6"/>
</iidm:substation>
<iidm:substation id="SUB-6">
<iidm:voltageLevel id="VL-8" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-8" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-8" v="1.09" angle="-13.36"/>
</iidm:busBreakerTopology>
Expand All @@ -85,39 +85,39 @@
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-7">
<iidm:voltageLevel id="VL-10" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-10" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-10" v="1.051" angle="-15.1"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-10" loadType="UNDEFINED" p0="9.0" q0="5.8" bus="BUS-10" connectableBus="BUS-10"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-5">
<iidm:voltageLevel id="VL-11" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-11" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-11" v="1.057" angle="-14.79"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-11" loadType="UNDEFINED" p0="3.5" q0="1.8" bus="BUS-11" connectableBus="BUS-11"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-3">
<iidm:voltageLevel id="VL-12" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-12" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-12" v="1.055" angle="-15.07"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-12" loadType="UNDEFINED" p0="6.1" q0="1.6" bus="BUS-12" connectableBus="BUS-12"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-2">
<iidm:voltageLevel id="VL-13" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-13" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-13" v="1.05" angle="-15.16"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-13" loadType="UNDEFINED" p0="13.5" q0="5.8" bus="BUS-13" connectableBus="BUS-13"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-1">
<iidm:voltageLevel id="VL-14" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:voltageLevel id="VL-14" nominalV="1.0" lowVoltageLimit="0.94" highVoltageLimit="1.06" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-14" v="1.036" angle="-16.04"/>
</iidm:busBreakerTopology>
Expand Down
Loading

0 comments on commit f1a63e2

Please sign in to comment.