-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flow decomposition] Fix net position computation with dangling lines (…
…#134) * Fix net positions in flow decomposition for dangling lines --------- Signed-off-by: Hugo SCHINDLER <[email protected]>
- Loading branch information
Showing
4 changed files
with
122 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import com.powsybl.iidm.network.Country; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.loadflow.LoadFlow; | ||
import com.powsybl.loadflow.LoadFlowParameters; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
|
@@ -18,43 +19,107 @@ | |
/** | ||
* @author Sebastien Murgey {@literal <sebastien.murgey at rte-france.com>} | ||
* @author Peter Mitri {@literal <peter.mitri at rte-france.com>} | ||
* @author Hugo Schindler{@literal <[email protected]>} | ||
*/ | ||
class NetPositionTest { | ||
private static final double DOUBLE_TOLERANCE = 1e-3; | ||
|
||
@Test | ||
void testLines() { | ||
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("testCase.xiidm")); | ||
private static void assertNetPosition(Network network, double netPositionBe, double netPositionNl, double netPositionDe) { | ||
Map<Country, Double> netPositions = NetPositionComputer.computeNetPositions(network); | ||
assertEquals(1000.0, netPositions.get(Country.FR), DOUBLE_TOLERANCE); | ||
assertEquals(1500.0, netPositions.get(Country.BE), DOUBLE_TOLERANCE); | ||
assertEquals(0.0, netPositions.get(Country.NL), DOUBLE_TOLERANCE); | ||
assertEquals(-2500.0, netPositions.get(Country.DE), DOUBLE_TOLERANCE); | ||
assertEquals(netPositionBe, netPositions.get(Country.BE), DOUBLE_TOLERANCE); | ||
assertEquals(netPositionNl, netPositions.get(Country.NL), DOUBLE_TOLERANCE); | ||
assertEquals(netPositionDe, netPositions.get(Country.DE), DOUBLE_TOLERANCE); | ||
double sumAllNetPositions = netPositions.values().stream().mapToDouble(Double::doubleValue).sum(); | ||
assertEquals(0.0, sumAllNetPositions, DOUBLE_TOLERANCE); | ||
} | ||
|
||
private static void assertNetPositionForHvdc(Network network, double countryNetPosition) { | ||
Map<Country, Double> netPositions = NetPositionComputer.computeNetPositions(network); | ||
assertEquals(countryNetPosition, netPositions.get(Country.FR), DOUBLE_TOLERANCE); | ||
assertEquals(-countryNetPosition, netPositions.get(Country.DE), DOUBLE_TOLERANCE); | ||
double sumAllNetPositions = netPositions.values().stream().mapToDouble(Double::doubleValue).sum(); | ||
assertEquals(0.0, sumAllNetPositions, DOUBLE_TOLERANCE); | ||
} | ||
|
||
@Test | ||
void testLines() { | ||
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("testCase.xiidm")); | ||
LoadFlow.run(network, new LoadFlowParameters().setDc(true)); | ||
assertNetPosition(network, 1500.0, 0.0, -2500.0); | ||
} | ||
|
||
@Test | ||
void testLinesDisconnected() { | ||
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("testCase.xiidm")); | ||
network.getBranch("NNL2AA1 BBE3AA1 1").getTerminal1().disconnect(); | ||
network.getBranch("NNL2AA1 BBE3AA1 1").getTerminal2().disconnect(); | ||
LoadFlow.run(network, new LoadFlowParameters().setDc(true)); | ||
assertNetPosition(network, 1500.0, 0.0, -2500.0); | ||
} | ||
|
||
@Test | ||
void testLinesNaN() { | ||
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("testCase.xiidm")); | ||
LoadFlow.run(network, new LoadFlowParameters().setDc(true)); | ||
network.getBranch("NNL2AA1 BBE3AA1 1").getTerminal1().setP(Double.NaN); | ||
network.getBranch("NNL2AA1 BBE3AA1 1").getTerminal2().setP(Double.NaN); | ||
assertNetPosition(network, 324.666, 1175.334, -2500.0); | ||
} | ||
|
||
@Test | ||
void testDanglingLinesBalanced() { | ||
Network network = Network.read("TestCaseDangling.xiidm", getClass().getResourceAsStream("TestCaseDangling.xiidm")); | ||
LoadFlow.run(network, new LoadFlowParameters().setDc(true)); | ||
assertNetPosition(network, 2300.0, -500.0, -2800.0); | ||
} | ||
|
||
@Test | ||
void testDanglingLines() { | ||
void testDanglingLinesDisconnected() { | ||
Network network = Network.read("TestCaseDangling.xiidm", getClass().getResourceAsStream("TestCaseDangling.xiidm")); | ||
LoadFlow.run(network); | ||
network.getDanglingLine("BBE2AA1 X_BEFR1 1").getTerminal().disconnect(); | ||
LoadFlow.run(network, new LoadFlowParameters().setDc(true)); | ||
assertNetPosition(network, 2300.0, -500.0, -2800.0); | ||
} | ||
|
||
@Test | ||
void testDanglingLinesNaN() { | ||
Network network = Network.read("TestCaseDangling.xiidm", getClass().getResourceAsStream("TestCaseDangling.xiidm")); | ||
LoadFlow.run(network, new LoadFlowParameters().setDc(true)); | ||
network.getDanglingLine("BBE2AA1 X_BEFR1 1").getTerminal().setP(Double.NaN); | ||
assertNetPosition(network, 2300.0, -500.0, -2800.0); | ||
} | ||
|
||
@Test | ||
void testDanglingLinesUnbalanced() { | ||
Network network = Network.read("NETWORK_SINGLE_LOAD_TWO_GENERATORS_WITH_UNBOUNDED_XNODE.uct", getClass().getResourceAsStream("NETWORK_SINGLE_LOAD_TWO_GENERATORS_WITH_UNBOUNDED_XNODE.uct")); | ||
LoadFlow.run(network, new LoadFlowParameters().setDc(true)); | ||
Map<Country, Double> netPositions = NetPositionComputer.computeNetPositions(network); | ||
assertEquals(1000.0, netPositions.get(Country.FR), DOUBLE_TOLERANCE); | ||
assertEquals(2300.0, netPositions.get(Country.BE), DOUBLE_TOLERANCE); | ||
assertEquals(-500.0, netPositions.get(Country.NL), DOUBLE_TOLERANCE); | ||
assertEquals(-2800.0, netPositions.get(Country.DE), DOUBLE_TOLERANCE); | ||
assertEquals(100, netPositions.get(Country.FR), DOUBLE_TOLERANCE); | ||
assertEquals(0, netPositions.get(Country.BE), DOUBLE_TOLERANCE); | ||
double sumAllNetPositions = netPositions.values().stream().mapToDouble(Double::doubleValue).sum(); | ||
assertEquals(0.0, sumAllNetPositions, DOUBLE_TOLERANCE); | ||
assertEquals(100, sumAllNetPositions, DOUBLE_TOLERANCE); | ||
} | ||
|
||
@Test | ||
void testHvdcLines() { | ||
Network network = Network.read("TestCaseHvdc.xiidm", getClass().getResourceAsStream("TestCaseHvdc.xiidm")); | ||
Map<Country, Double> netPositions = NetPositionComputer.computeNetPositions(network); | ||
assertEquals(272.0, netPositions.get(Country.FR), DOUBLE_TOLERANCE); | ||
assertEquals(-272.0, netPositions.get(Country.DE), DOUBLE_TOLERANCE); | ||
double sumAllNetPositions = netPositions.values().stream().mapToDouble(Double::doubleValue).sum(); | ||
assertEquals(0.0, sumAllNetPositions, DOUBLE_TOLERANCE); | ||
assertNetPositionForHvdc(network, 272.0); | ||
} | ||
|
||
@Test | ||
void testHvdcLinesDisconnected() { | ||
Network network = Network.read("TestCaseHvdc.xiidm", getClass().getResourceAsStream("TestCaseHvdc.xiidm")); | ||
network.getHvdcLine("hvdc_line_FR_1_DE").getConverterStation1().getTerminal().disconnect(); | ||
network.getHvdcLine("hvdc_line_FR_1_DE").getConverterStation2().getTerminal().disconnect(); | ||
assertNetPositionForHvdc(network, 200.0); | ||
} | ||
|
||
@Test | ||
void testHvdcLinesNaN() { | ||
Network network = Network.read("TestCaseHvdc.xiidm", getClass().getResourceAsStream("TestCaseHvdc.xiidm")); | ||
network.getHvdcLine("hvdc_line_FR_1_DE").getConverterStation1().getTerminal().setP(Double.NaN); | ||
network.getHvdcLine("hvdc_line_FR_1_DE").getConverterStation2().getTerminal().setP(Double.NaN); | ||
assertNetPositionForHvdc(network, 200.0); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...om/powsybl/flow_decomposition/NETWORK_SINGLE_LOAD_TWO_GENERATORS_WITH_UNBOUNDED_XNODE.uct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
##C 2007.05.01 | ||
This is a test network with only two branches. | ||
Each branch is linking a generator with a central load. | ||
Used to validate: | ||
- Basic network importer | ||
- XNEC automatic selection | ||
- GLSK automatic generation | ||
- Zone automatic extraction | ||
##N | ||
##ZFR | ||
FGEN1 11 GEN 0 3 400.00 0.00000 0.00000 -100.00 0.00000 1000.00 -1000.0 1000.00 -1000.0 | ||
##ZBE | ||
BGEN2 11 GEN 0 2 400.00 0.00000 0.00000 -100.00 0.00000 1000.00 -1000.0 1000.00 -1000.0 | ||
BLOAD 11 LOAD 0 0 100.000 0.00000 0.00000 0.00000 | ||
##ZXX | ||
X 11 XNODE 0 0 100.000 0.00000 0.00000 0.00000 1000.00 -1000.0 1000.00 -1000.0 | ||
##L | ||
FGEN1 11 BLOAD 11 1 0 1.0000 0.0500 0.000000 480 LINE | ||
BLOAD 11 BGEN2 11 1 0 1.0000 0.0500 0.000000 480 LINE | ||
BLOAD 11 X 11 1 0 1.0000 0.0500 0.000000 480 LINE |