Skip to content

Commit

Permalink
Import Matpower branch limits (#1931)
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
  • Loading branch information
geofjamg authored Jan 12, 2022
1 parent 76d5a4b commit 27b6156
Show file tree
Hide file tree
Showing 12 changed files with 458 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ private static void createBranches(MatpowerModel model, ContainersMapping contai
String connectedBus1 = isInService ? bus1Id : null;
String connectedBus2 = isInService ? bus2Id : null;

Branch<?> branch;
if (isTransformer(model, mBranch)) {
TwoWindingsTransformer newTwt = voltageLevel2.getSubstation().map(Substation::newTwoWindingsTransformer).orElseGet(network::newTwoWindingsTransformer)
.setId(getId(TRANSFORMER_PREFIX, mBranch.getFrom(), mBranch.getTo()))
Expand Down Expand Up @@ -292,9 +293,10 @@ private static void createBranches(MatpowerModel model, ContainersMapping contai
.endStep()
.add();
}
branch = newTwt;
LOGGER.trace("Created TwoWindingsTransformer {} {} {}", newTwt.getId(), bus1Id, bus2Id);
} else {
Line newLine = network.newLine()
branch = network.newLine()
.setId(getId(LINE_PREFIX, mBranch.getFrom(), mBranch.getTo()))
.setEnsureIdUnicity(true)
.setBus1(connectedBus1)
Expand All @@ -310,7 +312,30 @@ private static void createBranches(MatpowerModel model, ContainersMapping contai
.setG2(0)
.setB2(mBranch.getB() / zb / 2)
.add();
LOGGER.trace("Created line {} {} {}", newLine.getId(), bus1Id, bus2Id);
LOGGER.trace("Created line {} {} {}", branch.getId(), bus1Id, bus2Id);
}
if (mBranch.getRateA() != 0) {
// we create the apparent power limit arbitrary on side one
// there is probably something to fix on IIDM API to not have sided apparent
// power limits. Apparent power does not depend on voltage so it does not make
// sens to associate the limit to a branch side.
ApparentPowerLimitsAdder limitsAdder = branch.newApparentPowerLimits1()
.setPermanentLimit(mBranch.getRateA()); // long term rating
if (mBranch.getRateB() != 0) {
limitsAdder.beginTemporaryLimit()
.setName("RateB")
.setValue(mBranch.getRateB())
.setAcceptableDuration(60 * 20) // 20' for short term rating
.endTemporaryLimit();
}
if (mBranch.getRateC() != 0) {
limitsAdder.beginTemporaryLimit()
.setName("RateC")
.setValue(mBranch.getRateC())
.setAcceptableDuration(60) // 1' for emergency rating
.endTemporaryLimit();
}
limitsAdder.add();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public void testCase9() throws IOException {
testCase(MatpowerModelFactory.create9());
}

@Test
public void testCase9limits() throws IOException {
testCase(MatpowerModelFactory.create9limits());
}

@Test
public void testCase14() throws IOException {
testCase(MatpowerModelFactory.create14());
Expand Down Expand Up @@ -120,7 +125,7 @@ private void testNetwork(Network network, String id) throws IOException {
ZonedDateTime caseDateTime = DEFAULTDATEFORTESTS.atStartOfDay(ZoneOffset.UTC.normalized());
network.setCaseDate(new DateTime(caseDateTime.toInstant().toEpochMilli(), DateTimeZone.UTC));

String fileName = id + "mat.xiidm";
String fileName = id + ".xiidm";
Path file = tmpDir.resolve(fileName);
NetworkXml.write(network, file);
try (InputStream is = Files.newInputStream(file)) {
Expand Down
95 changes: 95 additions & 0 deletions matpower/matpower-converter/src/test/resources/ieee9_limits.xiidm
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_6" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_3" id="ieee9_limits" caseDate="2020-01-01T00:00:00.000Z" forecastDistance="0" sourceFormat="MATPOWER">
<iidm:substation id="SUB-1">
<iidm:voltageLevel id="VL-1" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-1" v="1.04" angle="0.0"/>
</iidm:busBreakerTopology>
<iidm:generator id="GEN-1" energySource="OTHER" minP="0.0" maxP="98.5" voltageRegulatorOn="true" targetP="71.64102" targetV="1.04" targetQ="27.04592" bus="BUS-1" connectableBus="BUS-1">
<iidm:minMaxReactiveLimits minQ="-99990.0" maxQ="999900.0"/>
</iidm:generator>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-2">
<iidm:voltageLevel id="VL-2" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-2" v="1.025" angle="9.28"/>
</iidm:busBreakerTopology>
<iidm:generator id="GEN-2" energySource="OTHER" minP="0.0" maxP="263.0" voltageRegulatorOn="true" targetP="163.0" targetV="1.025" targetQ="6.65366" bus="BUS-2" connectableBus="BUS-2">
<iidm:minMaxReactiveLimits minQ="-99990.0" maxQ="999900.0"/>
</iidm:generator>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-3">
<iidm:voltageLevel id="VL-3" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-3" v="1.025" angle="4.6647"/>
</iidm:busBreakerTopology>
<iidm:generator id="GEN-3" energySource="OTHER" minP="0.0" maxP="185.0" voltageRegulatorOn="true" targetP="85.0" targetV="1.025" targetQ="-10.8597" bus="BUS-3" connectableBus="BUS-3">
<iidm:minMaxReactiveLimits minQ="-99990.0" maxQ="999900.0"/>
</iidm:generator>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-4">
<iidm:voltageLevel id="VL-4" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-4" v="1.025" angle="-2.216"/>
</iidm:busBreakerTopology>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-5">
<iidm:voltageLevel id="VL-5" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-5" v="0.995" angle="-3.988"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-5" loadType="UNDEFINED" p0="125.0" q0="50.0" bus="BUS-5" connectableBus="BUS-5"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-6">
<iidm:voltageLevel id="VL-6" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-6" v="1.012" angle="-3.687"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-6" loadType="UNDEFINED" p0="90.0" q0="30.0" bus="BUS-6" connectableBus="BUS-6"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-7">
<iidm:voltageLevel id="VL-7" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-7" v="1.025" angle="3.7197"/>
</iidm:busBreakerTopology>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-8">
<iidm:voltageLevel id="VL-8" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-8" v="1.015" angle="0.7275"/>
</iidm:busBreakerTopology>
<iidm:load id="LOAD-8" loadType="UNDEFINED" p0="100.0" q0="35.0" bus="BUS-8" connectableBus="BUS-8"/>
</iidm:voltageLevel>
</iidm:substation>
<iidm:substation id="SUB-9">
<iidm:voltageLevel id="VL-9" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="BUS-9" v="1.032" angle="1.9667"/>
</iidm:busBreakerTopology>
</iidm:voltageLevel>
</iidm:substation>
<iidm:line id="LINE-4-1" r="0.0" x="5.76E-4" g1="0.0" b1="0.0" g2="0.0" b2="0.0" bus1="BUS-4" connectableBus1="BUS-4" voltageLevelId1="VL-4" bus2="BUS-1" connectableBus2="BUS-1" voltageLevelId2="VL-1"/>
<iidm:line id="LINE-7-2" r="0.0" x="6.25E-4" g1="0.0" b1="0.0" g2="0.0" b2="0.0" bus1="BUS-7" connectableBus1="BUS-7" voltageLevelId1="VL-7" bus2="BUS-2" connectableBus2="BUS-2" voltageLevelId2="VL-2"/>
<iidm:line id="LINE-9-3" r="0.0" x="5.86E-4" g1="0.0" b1="0.0" g2="0.0" b2="0.0" bus1="BUS-9" connectableBus1="BUS-9" voltageLevelId1="VL-9" bus2="BUS-3" connectableBus2="BUS-3" voltageLevelId2="VL-3"/>
<iidm:line id="LINE-7-8" r="8.5E-5" x="7.199999999999999E-4" g1="0.0" b1="7.449999999999999" g2="0.0" b2="7.449999999999999" bus1="BUS-7" connectableBus1="BUS-7" voltageLevelId1="VL-7" bus2="BUS-8" connectableBus2="BUS-8" voltageLevelId2="VL-8"/>
<iidm:line id="LINE-9-8" r="1.19E-4" x="0.001008" g1="0.0" b1="10.45" g2="0.0" b2="10.45" bus1="BUS-9" connectableBus1="BUS-9" voltageLevelId1="VL-9" bus2="BUS-8" connectableBus2="BUS-8" voltageLevelId2="VL-8"/>
<iidm:line id="LINE-7-5" r="3.2E-4" x="0.00161" g1="0.0" b1="15.299999999999999" g2="0.0" b2="15.299999999999999" bus1="BUS-7" connectableBus1="BUS-7" voltageLevelId1="VL-7" bus2="BUS-5" connectableBus2="BUS-5" voltageLevelId2="VL-5"/>
<iidm:line id="LINE-9-6" r="3.9E-4" x="0.0017000000000000001" g1="0.0" b1="17.9" g2="0.0" b2="17.9" bus1="BUS-9" connectableBus1="BUS-9" voltageLevelId1="VL-9" bus2="BUS-6" connectableBus2="BUS-6" voltageLevelId2="VL-6"/>
<iidm:line id="LINE-5-4" r="1.0E-4" x="8.500000000000001E-4" g1="0.0" b1="8.799999999999999" g2="0.0" b2="8.799999999999999" bus1="BUS-5" connectableBus1="BUS-5" voltageLevelId1="VL-5" bus2="BUS-4" connectableBus2="BUS-4" voltageLevelId2="VL-4"/>
<iidm:line id="LINE-6-4" r="1.7E-4" x="9.2E-4" g1="0.0" b1="7.9" g2="0.0" b2="7.9" bus1="BUS-6" connectableBus1="BUS-6" voltageLevelId1="VL-6" bus2="BUS-4" connectableBus2="BUS-4" voltageLevelId2="VL-4">
<iidm:apparentPowerLimits1 permanentLimit="50.0">
<iidm:temporaryLimit name="RateB" acceptableDuration="1200" value="60.0"/>
<iidm:temporaryLimit name="RateC" acceptableDuration="60" value="70.0"/>
</iidm:apparentPowerLimits1>
</iidm:line>
<iidm:extension id="VL-1">
<slt:slackTerminal id="GEN-1"/>
</iidm:extension>
</iidm:network>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public static MatpowerModel create9() {
return readModelJsonFromResources("ieee9.json");
}

public static MatpowerModel create9limits() {
return readModelJsonFromResources("ieee9_limits.json");
}

public static MatpowerModel create14() {
return readModelJsonFromResources("ieee14.json");
}
Expand Down
Loading

0 comments on commit 27b6156

Please sign in to comment.