Skip to content

Commit

Permalink
Correction of balances adjustment (#118)
Browse files Browse the repository at this point in the history
Signed-off-by: Ameni Walha <ameni.walha@rte-france.com>
  • Loading branch information
WalAmeni authored and murgeyseb committed Jul 19, 2019
1 parent b933032 commit 015fe34
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public CompletableFuture<BalanceComputationResult> run(String workingStateId, Ba
// Change the workingStateId with final scaling
network.getVariantManager().setWorkingVariant(workingStateId);
scaleBalancedNetwork(previousScalingMap);
runLoadFlow(loadFlow, workingStateId);
result = new BalanceComputationResult(BalanceComputationResult.Status.SUCCESS, iterationCounter, previousScalingMap);

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

} else {
// return the network at initial working state id
network.getVariantManager().removeVariant(workingVariantCopyId);
network.getVariantManager().cloneVariant(workingStateId, workingVariantCopyId);
network.getVariantManager().setWorkingVariant(workingVariantCopyId);
LOGGER.error(" Network areas are unbalanced after {} iterations", iterationCounter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class BalanceComputationImplDcTest {
private BalanceComputationParameters parameters;
private BalanceComputationFactory balanceComputationFactory;
private LoadFlowFactory loadFlowFactory;
private String newStateId = "NewStateId";

@Before
public void setUp() {
Expand Down Expand Up @@ -96,6 +97,34 @@ public void testBalancedNetworkAfter1Scaling() {

}

@Test
public void testBalancesAdjustmentWithDifferentStateId() {
networkAreaNetPositionTargetMap = new HashMap<>();
networkAreaNetPositionTargetMap.put(countryAreaFR, 1100.);

testNetwork1.getVariantManager().cloneVariant(testNetwork1.getVariantManager().getWorkingVariantId(), newStateId);

Map<NetworkArea, Scalable> networkAreasScalableMap1 = new HashMap<>();
Scalable scalable1 = Scalable.onGenerator("FFR1AA1 _generator");
Scalable scalable2 = Scalable.onGenerator("FFR2AA1 _generator");
Scalable scalable3 = Scalable.onGenerator("FFR3AA1 _generator");

networkAreasScalableMap1.put(countryAreaFR, Scalable.proportional(28.f, scalable1, 28f, scalable2, 44.f, scalable3));

BalanceComputation balanceComputation = balanceComputationFactory.create(testNetwork1, networkAreaNetPositionTargetMap, networkAreasScalableMap1, loadFlowFactory, computationManager, 1);

BalanceComputationResult result = balanceComputation.run(newStateId, parameters).join();

assertEquals(BalanceComputationResult.Status.SUCCESS, result.getStatus());
assertEquals(2, result.getIterationCount());
// Check net position does not change with the initial state id after balances
assertEquals(1000., countryAreaFR.getNetPosition(testNetwork1), 1.);
// Check target net position after balances with the new state id
testNetwork1.getVariantManager().setWorkingVariant(newStateId);
assertEquals(1100., countryAreaFR.getNetPosition(testNetwork1), 1.);

}

@Test
public void testUnBalancedNetwork() {

Expand Down

0 comments on commit 015fe34

Please sign in to comment.