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 613d726 commit 09be168
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
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 @@ -3911,4 +3911,17 @@ void testNoMoreVoltageControlledBusTwoBusNetwork() {
assertReactivePowerEquals(0.0, network.getGenerator("G2").getTerminal());
assertVoltageEquals(400.01, network.getBusBreakerView().getBus("B2"));
}

@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 09be168

Please sign in to comment.