diff --git a/src/main/java/com/powsybl/openloadflow/sa/ContingencyParameters.java b/src/main/java/com/powsybl/openloadflow/sa/ContingencyParameters.java new file mode 100644 index 0000000000..df5e685d2b --- /dev/null +++ b/src/main/java/com/powsybl/openloadflow/sa/ContingencyParameters.java @@ -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 } + */ +public class ContingencyParameters extends AbstractExtension { + + 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; + } +} diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java index 1ee1b502df..4edcff428d 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java @@ -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()); + } }