Skip to content

Commit

Permalink
introduce contingency parameters extension
Browse files Browse the repository at this point in the history
Signed-off-by: vmouradian <valentin.mouradian@artelys.com>
  • Loading branch information
vmouradian committed Dec 3, 2024
1 parent c1e8dd0 commit dec6e7c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/)
* 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.openloadflow.sa;

import com.powsybl.commons.extensions.AbstractExtension;
import com.powsybl.contingency.Contingency;
import com.powsybl.loadflow.LoadFlowParameters;

/**
* @author Valentin Mouradian {@literal <valentin.mouradian at artelys.com>}
*/
public class ContingencyParameters extends AbstractExtension<Contingency> {

private boolean distributedSlack;

private boolean areaInterchangeControl;

private LoadFlowParameters.BalanceType balanceType;

public ContingencyParameters(boolean distributedSlack, boolean areaInterchangeControl, LoadFlowParameters.BalanceType balanceType) {
this.distributedSlack = distributedSlack;
this.areaInterchangeControl = areaInterchangeControl;
this.balanceType = balanceType;
}

@Override
public String getName() {
return "ContingencyParameters";
}

public boolean isDistributedSlack() {
return distributedSlack;
}

public boolean isAreaInterchangeControl() {
return areaInterchangeControl;
}

public LoadFlowParameters.BalanceType getBalanceType() {
return balanceType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import static com.powsybl.openloadflow.util.LoadFlowAssert.*;
import static java.util.Collections.emptySet;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>}
Expand Down Expand Up @@ -3997,4 +3996,17 @@ void testNoCc0Sc0() {
assertEquals(LoadFlowResult.ComponentResult.Status.CONVERGED, saResultAll.getPreContingencyResult().getStatus());
assertEquals(6, saResultAll.getPreContingencyResult().getNetworkResult().getBusResults().size()); // 6 buses in total
}

@Test
void testContingencyParametersExtension() {
Contingency contingency = new Contingency("L2", new BranchContingency("L2"));
contingency.addExtension(ContingencyParameters.class, new ContingencyParameters(false, true, LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD));

ContingencyParameters contingencyParameters = contingency.getExtension(ContingencyParameters.class);

assertEquals(contingencyParameters, contingency.getExtensionByName("ContingencyParameters"));
assertFalse(contingencyParameters.isDistributedSlack());
assertTrue(contingencyParameters.isAreaInterchangeControl());
assertEquals(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD, contingencyParameters.getBalanceType());
}
}

0 comments on commit dec6e7c

Please sign in to comment.