Skip to content

Commit ee2bfbd

Browse files
WalAmenimurgeyseb
authored andcommitted
Correction of balances adjustment (#118)
Signed-off-by: Ameni Walha <ameni.walha@rte-france.com>
1 parent 8f10de8 commit ee2bfbd

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

balances-adjustment/src/main/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImpl.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public CompletableFuture<BalanceComputationResult> run(String workingStateId, Ba
121121
// Change the workingStateId with final scaling
122122
network.getVariantManager().setWorkingVariant(workingStateId);
123123
scaleBalancedNetwork(previousScalingMap);
124+
runLoadFlow(loadFlow, workingStateId);
124125
result = new BalanceComputationResult(BalanceComputationResult.Status.SUCCESS, iterationCounter, previousScalingMap);
125126

126127
} else {
@@ -142,10 +143,6 @@ public CompletableFuture<BalanceComputationResult> run(String workingStateId, Ba
142143
LOGGER.info(" Network areas : {} are balanced after {} iterations", networkAreasName, result.getIterationCount());
143144

144145
} else {
145-
// return the network at initial working state id
146-
network.getVariantManager().removeVariant(workingVariantCopyId);
147-
network.getVariantManager().cloneVariant(workingStateId, workingVariantCopyId);
148-
network.getVariantManager().setWorkingVariant(workingVariantCopyId);
149146
LOGGER.error(" Network areas are unbalanced after {} iterations", iterationCounter);
150147
}
151148

balances-adjustment/src/test/java/com/powsybl/balances_adjustment/balance_computation/BalanceComputationImplDcTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class BalanceComputationImplDcTest {
4040
private BalanceComputationParameters parameters;
4141
private BalanceComputationFactory balanceComputationFactory;
4242
private LoadFlowFactory loadFlowFactory;
43+
private String newStateId = "NewStateId";
4344

4445
@Before
4546
public void setUp() {
@@ -96,6 +97,34 @@ public void testBalancedNetworkAfter1Scaling() {
9697

9798
}
9899

100+
@Test
101+
public void testBalancesAdjustmentWithDifferentStateId() {
102+
networkAreaNetPositionTargetMap = new HashMap<>();
103+
networkAreaNetPositionTargetMap.put(countryAreaFR, 1100.);
104+
105+
testNetwork1.getVariantManager().cloneVariant(testNetwork1.getVariantManager().getWorkingVariantId(), newStateId);
106+
107+
Map<NetworkArea, Scalable> networkAreasScalableMap1 = new HashMap<>();
108+
Scalable scalable1 = Scalable.onGenerator("FFR1AA1 _generator");
109+
Scalable scalable2 = Scalable.onGenerator("FFR2AA1 _generator");
110+
Scalable scalable3 = Scalable.onGenerator("FFR3AA1 _generator");
111+
112+
networkAreasScalableMap1.put(countryAreaFR, Scalable.proportional(28.f, scalable1, 28f, scalable2, 44.f, scalable3));
113+
114+
BalanceComputation balanceComputation = balanceComputationFactory.create(testNetwork1, networkAreaNetPositionTargetMap, networkAreasScalableMap1, loadFlowFactory, computationManager, 1);
115+
116+
BalanceComputationResult result = balanceComputation.run(newStateId, parameters).join();
117+
118+
assertEquals(BalanceComputationResult.Status.SUCCESS, result.getStatus());
119+
assertEquals(2, result.getIterationCount());
120+
// Check net position does not change with the initial state id after balances
121+
assertEquals(1000., countryAreaFR.getNetPosition(testNetwork1), 1.);
122+
// Check target net position after balances with the new state id
123+
testNetwork1.getVariantManager().setWorkingVariant(newStateId);
124+
assertEquals(1100., countryAreaFR.getNetPosition(testNetwork1), 1.);
125+
126+
}
127+
99128
@Test
100129
public void testUnBalancedNetwork() {
101130

0 commit comments

Comments
 (0)