-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/add-control-on-active-limits-fie…
…lds' into add-control-on-active-limits-fields
- Loading branch information
Showing
11 changed files
with
461 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/org/gridsuite/modification/server/dto/formula/equipmentfield/LoadField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* 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/. | ||
*/ | ||
|
||
package org.gridsuite.modification.server.dto.formula.equipmentfield; | ||
|
||
import com.powsybl.iidm.network.Load; | ||
|
||
/** | ||
* @author Seddik Yengui <Seddik.yengui at rte-france.com> | ||
*/ | ||
|
||
public enum LoadField { | ||
ACTIVE_POWER, | ||
REACTIVE_POWER; | ||
|
||
public static Double getReferenceValue(Load load, String loadField) { | ||
LoadField field = LoadField.valueOf(loadField); | ||
return switch (field) { | ||
case ACTIVE_POWER -> load.getP0(); | ||
case REACTIVE_POWER -> load.getQ0(); | ||
}; | ||
} | ||
|
||
public static void setNewValue(Load load, String loadField, Double newValue) { | ||
LoadField field = LoadField.valueOf(loadField); | ||
switch (field) { | ||
case ACTIVE_POWER -> load.setP0(newValue); | ||
case REACTIVE_POWER -> load.setQ0(newValue); | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
.../java/org/gridsuite/modification/server/dto/formula/equipmentfield/VoltageLevelField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* 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/. | ||
*/ | ||
|
||
package org.gridsuite.modification.server.dto.formula.equipmentfield; | ||
|
||
import com.powsybl.iidm.network.VoltageLevel; | ||
import com.powsybl.iidm.network.extensions.IdentifiableShortCircuit; | ||
import com.powsybl.iidm.network.extensions.IdentifiableShortCircuitAdder; | ||
|
||
/** | ||
* @author Seddik Yengui <Seddik.yengui at rte-france.com> | ||
*/ | ||
|
||
public enum VoltageLevelField { | ||
NOMINAL_VOLTAGE, | ||
LOW_VOLTAGE_LIMIT, | ||
HIGH_VOLTAGE_LIMIT, | ||
LOW_SHORT_CIRCUIT_CURRENT_LIMIT, | ||
HIGH_SHORT_CIRCUIT_CURRENT_LIMIT; | ||
|
||
public static Double getReferenceValue(VoltageLevel voltageLevel, String voltageLevelField) { | ||
IdentifiableShortCircuit<VoltageLevel> identifiableShortCircuit = voltageLevel.getExtension(IdentifiableShortCircuit.class); | ||
VoltageLevelField field = VoltageLevelField.valueOf(voltageLevelField); | ||
return switch (field) { | ||
case NOMINAL_VOLTAGE -> voltageLevel.getNominalV(); | ||
case LOW_VOLTAGE_LIMIT -> voltageLevel.getLowVoltageLimit(); | ||
case HIGH_VOLTAGE_LIMIT -> voltageLevel.getHighVoltageLimit(); | ||
case LOW_SHORT_CIRCUIT_CURRENT_LIMIT -> identifiableShortCircuit == null ? null : identifiableShortCircuit.getIpMin(); | ||
case HIGH_SHORT_CIRCUIT_CURRENT_LIMIT -> identifiableShortCircuit == null ? null : identifiableShortCircuit.getIpMax(); | ||
}; | ||
} | ||
|
||
public static void setNewValue(VoltageLevel voltageLevel, String voltageLevelField, Double newValue) { | ||
IdentifiableShortCircuit<VoltageLevel> identifiableShortCircuit = voltageLevel.getExtension(IdentifiableShortCircuit.class); | ||
VoltageLevelField field = VoltageLevelField.valueOf(voltageLevelField); | ||
switch (field) { | ||
case NOMINAL_VOLTAGE -> voltageLevel.setNominalV(newValue); | ||
case LOW_VOLTAGE_LIMIT -> voltageLevel.setLowVoltageLimit(newValue); | ||
case HIGH_VOLTAGE_LIMIT -> voltageLevel.setHighVoltageLimit(newValue); | ||
case LOW_SHORT_CIRCUIT_CURRENT_LIMIT -> { | ||
IdentifiableShortCircuitAdder<VoltageLevel> adder = voltageLevel.newExtension(IdentifiableShortCircuitAdder.class).withIpMin(newValue); | ||
if (identifiableShortCircuit != null) { | ||
adder.withIpMax(identifiableShortCircuit.getIpMax()); | ||
} | ||
adder.add(); | ||
} | ||
case HIGH_SHORT_CIRCUIT_CURRENT_LIMIT -> { | ||
IdentifiableShortCircuitAdder<VoltageLevel> adder = voltageLevel.newExtension(IdentifiableShortCircuitAdder.class).withIpMax(newValue); | ||
if (identifiableShortCircuit != null) { | ||
adder.withIpMin(identifiableShortCircuit.getIpMin()); | ||
} | ||
adder.add(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...t/java/org/gridsuite/modification/server/modifications/LoadByFormulaModificationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* 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/. | ||
*/ | ||
|
||
package org.gridsuite.modification.server.modifications; | ||
|
||
import com.powsybl.iidm.network.IdentifiableType; | ||
import org.gridsuite.modification.server.dto.FilterEquipments; | ||
import org.gridsuite.modification.server.dto.IdentifiableAttributes; | ||
import org.gridsuite.modification.server.dto.formula.FormulaInfos; | ||
import org.gridsuite.modification.server.dto.formula.Operator; | ||
import org.gridsuite.modification.server.dto.formula.ReferenceFieldOrValue; | ||
import org.gridsuite.modification.server.dto.formula.equipmentfield.LoadField; | ||
|
||
import java.util.List; | ||
|
||
import static org.gridsuite.modification.server.utils.NetworkUtil.createLoad; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Seddik Yengui <Seddik.yengui at rte-france.com> | ||
*/ | ||
|
||
public class LoadByFormulaModificationTest extends AbstractByFormulaModificationTest { | ||
private static final String LOAD_ID_1 = "load1"; | ||
private static final String LOAD_ID_2 = "load2"; | ||
private static final String LOAD_ID_3 = "load3"; | ||
private static final String LOAD_ID_4 = "load4"; | ||
|
||
@Override | ||
protected void createEquipments() { | ||
createLoad(getNetwork().getVoltageLevel("v1"), LOAD_ID_1, "load1", 100, 100, 120, null, 5, null); | ||
createLoad(getNetwork().getVoltageLevel("v2"), LOAD_ID_2, "load2", 200, 80, 90, null, 5, null); | ||
createLoad(getNetwork().getVoltageLevel("v3"), LOAD_ID_3, "load3", 300, 100, 70, null, 5, null); | ||
createLoad(getNetwork().getVoltageLevel("v4"), LOAD_ID_4, "load4", 400, 50, 150, null, 5, null); | ||
} | ||
|
||
@Override | ||
protected List<FilterEquipments> getTestFilters() { | ||
IdentifiableAttributes load1 = getIdentifiableAttributes(LOAD_ID_1, 1.0); | ||
IdentifiableAttributes load2 = getIdentifiableAttributes(LOAD_ID_2, 2.0); | ||
IdentifiableAttributes load3 = getIdentifiableAttributes(LOAD_ID_3, 2.0); | ||
IdentifiableAttributes load4 = getIdentifiableAttributes(LOAD_ID_4, 5.0); | ||
|
||
FilterEquipments filter1 = getFilterEquipments(FILTER_ID_1, "filter1", List.of(load1, load2), List.of()); | ||
FilterEquipments filter2 = getFilterEquipments(FILTER_ID_2, "filter2", List.of(load3, load4), List.of()); | ||
|
||
return List.of(filter1, filter2); | ||
} | ||
|
||
@Override | ||
protected List<FormulaInfos> getFormulaInfos() { | ||
FormulaInfos formulaInfos1 = getFormulaInfo(LoadField.ACTIVE_POWER.name(), | ||
List.of(filter1), | ||
Operator.ADDITION, | ||
ReferenceFieldOrValue.builder().equipmentField(LoadField.ACTIVE_POWER.name()).build(), | ||
ReferenceFieldOrValue.builder().value(25.).build() | ||
); | ||
|
||
FormulaInfos formulaInfos2 = getFormulaInfo(LoadField.REACTIVE_POWER.name(), | ||
List.of(filter2), | ||
Operator.MULTIPLICATION, | ||
ReferenceFieldOrValue.builder().equipmentField(LoadField.REACTIVE_POWER.name()).build(), | ||
ReferenceFieldOrValue.builder().value(2.5).build() | ||
); | ||
return List.of(formulaInfos1, formulaInfos2); | ||
} | ||
|
||
@Override | ||
protected List<FormulaInfos> getUpdatedFormulaInfos() { | ||
FormulaInfos formulaInfos1 = getFormulaInfo(LoadField.ACTIVE_POWER.name(), | ||
List.of(filter1), | ||
Operator.PERCENTAGE, | ||
ReferenceFieldOrValue.builder().value(200.).build(), | ||
ReferenceFieldOrValue.builder().equipmentField(LoadField.ACTIVE_POWER.name()).build() | ||
); | ||
|
||
return List.of(formulaInfos1); | ||
} | ||
|
||
@Override | ||
protected IdentifiableType getIdentifiableType() { | ||
return IdentifiableType.LOAD; | ||
} | ||
|
||
@Override | ||
protected void assertAfterNetworkModificationCreation() { | ||
assertEquals(125, getNetwork().getLoad(LOAD_ID_1).getP0(), 0); | ||
assertEquals(105, getNetwork().getLoad(LOAD_ID_2).getP0(), 0); | ||
assertEquals(175, getNetwork().getLoad(LOAD_ID_3).getQ0(), 0); | ||
assertEquals(375, getNetwork().getLoad(LOAD_ID_4).getQ0(), 0); | ||
} | ||
|
||
@Override | ||
protected void assertAfterNetworkModificationDeletion() { | ||
assertEquals(100, getNetwork().getLoad(LOAD_ID_1).getP0(), 0); | ||
assertEquals(80, getNetwork().getLoad(LOAD_ID_2).getP0(), 0); | ||
assertEquals(70, getNetwork().getLoad(LOAD_ID_3).getQ0(), 0); | ||
assertEquals(150, getNetwork().getLoad(LOAD_ID_4).getQ0(), 0); | ||
} | ||
} |
Oops, something went wrong.