-
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.
Allows providing a custom GLSK provider to compute nodal injections f…
…or allocated flows (#85) * Allows providing a custom GLSK provider to compute nodal injections for allocated flows Signed-off-by: Sébastien Murgey <sebastien.murgey@rte-france.com>
- Loading branch information
Showing
10 changed files
with
162 additions
and
39 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
20 changes: 20 additions & 0 deletions
20
flow-decomposition/src/main/java/com/powsybl/flow_decomposition/GlskProvider.java
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 @@ | ||
/* | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.flow_decomposition; | ||
|
||
import com.powsybl.iidm.network.Country; | ||
import com.powsybl.iidm.network.Network; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author Sebastien Murgey {@literal <sebastien.murgey at rte-france.com>} | ||
*/ | ||
public interface GlskProvider { | ||
Map<Country, Map<String, Double>> getGlsk(Network network); | ||
} |
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
77 changes: 77 additions & 0 deletions
77
flow-decomposition/src/test/java/com/powsybl/flow_decomposition/CustomGlskProviderTests.java
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,77 @@ | ||
/* | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.flow_decomposition; | ||
|
||
import com.powsybl.flow_decomposition.glsk_provider.AutoGlskProvider; | ||
import com.powsybl.flow_decomposition.xnec_provider.XnecProviderByIds; | ||
import com.powsybl.iidm.network.Country; | ||
import com.powsybl.iidm.network.Network; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Sebastien Murgey {@literal <sebastien.murgey at rte-france.com>} | ||
*/ | ||
class CustomGlskProviderTests { | ||
private static final String NETWORK_FILE_FOR_CUSTOM_GLSK_TEST = "customGlskProviderTestNetwork.uct"; | ||
private static final String NETWORK_ELEMENT_DECOMPOSED = "FGEN2 11 FINTER11 1"; | ||
private static final double EPSILON = 1e-3; | ||
|
||
@Test | ||
void checkThatDefaultGlskProviderIsAutoCountryGlsk() { | ||
FlowDecompositionComputer computer = new FlowDecompositionComputer(); | ||
XnecProvider xnecProvider = XnecProviderByIds.builder() | ||
.addNetworkElementsOnBasecase(Set.of(NETWORK_ELEMENT_DECOMPOSED)) | ||
.build(); | ||
Network network = TestUtils.importNetwork(NETWORK_FILE_FOR_CUSTOM_GLSK_TEST); | ||
FlowDecompositionResults results = computer.run(xnecProvider, network); | ||
assertEquals(0., results.getDecomposedFlowMap().get(NETWORK_ELEMENT_DECOMPOSED).getAllocatedFlow(), EPSILON); | ||
} | ||
|
||
@Test | ||
void checkThatDefaultGlskProviderCanBeProvided() { | ||
FlowDecompositionComputer computer = new FlowDecompositionComputer(); | ||
XnecProvider xnecProvider = XnecProviderByIds.builder() | ||
.addNetworkElementsOnBasecase(Set.of(NETWORK_ELEMENT_DECOMPOSED)) | ||
.build(); | ||
GlskProvider glskProvider = new AutoGlskProvider(); | ||
Network network = TestUtils.importNetwork(NETWORK_FILE_FOR_CUSTOM_GLSK_TEST); | ||
FlowDecompositionResults results = computer.run(xnecProvider, glskProvider, network); | ||
assertEquals(0., results.getDecomposedFlowMap().get(NETWORK_ELEMENT_DECOMPOSED).getAllocatedFlow(), EPSILON); | ||
} | ||
|
||
@Test | ||
void checkThatOtherGlskProviderGivesOtherCorrectResults() { | ||
FlowDecompositionComputer computer = new FlowDecompositionComputer(); | ||
XnecProvider xnecProvider = XnecProviderByIds.builder() | ||
.addNetworkElementsOnBasecase(Set.of(NETWORK_ELEMENT_DECOMPOSED)) | ||
.build(); | ||
GlskProvider glskProvider = network -> Map.of(Country.FR, Map.of("FGEN2 11_generator", 1.0), | ||
Country.BE, Map.of("BGEN 11_generator", 1.0)); | ||
Network network = TestUtils.importNetwork(NETWORK_FILE_FOR_CUSTOM_GLSK_TEST); | ||
FlowDecompositionResults results = computer.run(xnecProvider, glskProvider, network); | ||
assertEquals(-100., results.getDecomposedFlowMap().get(NETWORK_ELEMENT_DECOMPOSED).getAllocatedFlow(), EPSILON); | ||
} | ||
|
||
@Test | ||
void checkThatLskInGlskProviderGivesOtherCorrectResults() { | ||
FlowDecompositionComputer computer = new FlowDecompositionComputer(); | ||
XnecProvider xnecProvider = XnecProviderByIds.builder() | ||
.addNetworkElementsOnBasecase(Set.of(NETWORK_ELEMENT_DECOMPOSED)) | ||
.build(); | ||
GlskProvider glskProvider = network -> Map.of(Country.FR, Map.of("FGEN2 11_load", 1.0), | ||
Country.BE, Map.of("BGEN 11_generator", 1.0)); | ||
Network network = TestUtils.importNetwork(NETWORK_FILE_FOR_CUSTOM_GLSK_TEST); | ||
FlowDecompositionResults results = computer.run(xnecProvider, glskProvider, network); | ||
assertEquals(-100., results.getDecomposedFlowMap().get(NETWORK_ELEMENT_DECOMPOSED).getAllocatedFlow(), EPSILON); | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
...ition/src/test/resources/com/powsybl/flow_decomposition/customGlskProviderTestNetwork.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,19 @@ | ||
##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 FGEN1 0 2 400.00 0.00000 0.00000 -200.00 0.00000 1000.00 -1000.0 1000.00 -1000.0 | ||
FINTER11 FINTER11 0 0 400.00 0.00000 0.00000 | ||
FGEN2 11 FGEN2 0 2 400.00 100.000 0.00000 0.00000 0.00000 1000.00 -1000.0 1000.00 -1000.0 | ||
##ZBE | ||
BGEN 11 BGEN1 0 3 400.00 200.000 0.00000 -100.00 0.00000 1000.00 -1000.0 1000.00 -1000.0 | ||
##L | ||
FGEN1 11 BGEN 11 1 0 1.0000 0.0500 0.000000 480 LINE | ||
FGEN2 11 FINTER11 1 0 1.0000 0.0500 0.000000 480 LINE | ||
FINTER11 BGEN 11 1 0 1.0000 0.0500 0.000000 480 LINE |