-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stores and apply several limit sets in the branch creation #9
base: main
Are you sure you want to change the base?
Changes from 12 commits
a6634b6
28ad43f
1f00dc0
58a77ef
0c57651
eccbc5e
d05d9be
e0942a2
4ede9ef
5eae6c8
ad86424
13d096f
c20b3a8
a52072a
1c71d77
e5e03d9
2e16fd5
6e93a4a
ba0de6a
d080a43
a07090d
cbc5f73
31cfb43
dc771ee
44c9e25
2e595de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Sylvain Bouzols <sylvain.bouzols at rte-france.com> | ||
*/ | ||
|
@@ -43,11 +45,17 @@ public class BranchCreationInfos extends EquipmentCreationInfos { | |
@Schema(description = "Bus or Busbar section id Side 2") | ||
private String busOrBusbarSectionId2; | ||
|
||
@Schema(description = "Current limits Side 1") | ||
private CurrentLimitsInfos currentLimits1; | ||
@Schema(description = "Operational limit groups on side 1") | ||
private List<OperationalLimitsGroupInfos> operationalLimitsGroups1; | ||
|
||
@Schema(description = "Operational limit groups on side 2") | ||
private List<OperationalLimitsGroupInfos> operationalLimitsGroups2; | ||
|
||
@Schema(description = "Selected operational limits group id on Side 1") | ||
private String selectedOperationalLimitsGroupId1; | ||
|
||
@Schema(description = "Current limits Side 2") | ||
private CurrentLimitsInfos currentLimits2; | ||
@Schema(description = "Selected operational limits group id on Side 2") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Selected operational limits group on Side 2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK why not. |
||
private String selectedOperationalLimitsGroupId2; | ||
|
||
@Schema(description = "Connection Name 1") | ||
private String connectionName1; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright (c) 2024, 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.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@SuperBuilder | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
@ToString | ||
@Schema(description = "Operational limits group") | ||
public class OperationalLimitsGroupInfos { | ||
@Schema(description = "Operational limit group id") | ||
private String id; | ||
|
||
@Schema(description = "Current limits") | ||
private CurrentLimitsInfos currentLimits; | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,12 +11,17 @@ | |||||
import com.powsybl.iidm.modification.topology.CreateBranchFeederBays; | ||||||
import com.powsybl.iidm.modification.topology.CreateBranchFeederBaysBuilder; | ||||||
import com.powsybl.iidm.network.*; | ||||||
import org.apache.commons.collections4.CollectionUtils; | ||||||
import org.gridsuite.modification.NetworkModificationException; | ||||||
import org.gridsuite.modification.dto.CurrentLimitsInfos; | ||||||
import org.gridsuite.modification.dto.LineCreationInfos; | ||||||
import org.gridsuite.modification.dto.OperationalLimitsGroupInfos; | ||||||
import org.gridsuite.modification.utils.ModificationUtils; | ||||||
import org.gridsuite.modification.utils.PropertiesUtils; | ||||||
|
||||||
import java.util.List; | ||||||
|
||||||
import static com.powsybl.iidm.network.TwoSides.ONE; | ||||||
import static com.powsybl.iidm.network.TwoSides.TWO; | ||||||
basseche marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
import static org.gridsuite.modification.NetworkModificationException.Type.*; | ||||||
|
||||||
/** | ||||||
|
@@ -67,16 +72,25 @@ public void apply(Network network, ReportNode subReportNode) { | |||||
} | ||||||
|
||||||
// Set permanent and temporary current limits | ||||||
CurrentLimitsInfos currentLimitsInfos1 = modificationInfos.getCurrentLimits1(); | ||||||
CurrentLimitsInfos currentLimitsInfos2 = modificationInfos.getCurrentLimits2(); | ||||||
if (currentLimitsInfos1 != null || currentLimitsInfos2 != null) { | ||||||
List<OperationalLimitsGroupInfos> opLimitsGroupSide1 = modificationInfos.getOperationalLimitsGroups1(); | ||||||
List<OperationalLimitsGroupInfos> opLimitsGroupSide2 = modificationInfos.getOperationalLimitsGroups2(); | ||||||
if (!CollectionUtils.isEmpty(opLimitsGroupSide1)) { | ||||||
var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK done. |
||||||
ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide1, line, ONE); | ||||||
} | ||||||
if (!CollectionUtils.isEmpty(opLimitsGroupSide2)) { | ||||||
var line = ModificationUtils.getInstance().getLine(network, modificationInfos.getEquipmentId()); | ||||||
ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos1, line.newCurrentLimits1()); | ||||||
ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos2, line.newCurrentLimits2()); | ||||||
ModificationUtils.getInstance().setCurrentLimitsOnASide(opLimitsGroupSide2, line, TWO); | ||||||
} | ||||||
ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReportNode); | ||||||
// properties | ||||||
Line line = network.getLine(modificationInfos.getEquipmentId()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can place this line before (for example, line 74) to avoid calling getLine three times and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I thought about this but didn't dare because it looks like whoever wrote this like this did it on purpose. And I didn't want to take the risk. But ok you look motivated I did it ! |
||||||
if (modificationInfos.getSelectedOperationalLimitsGroupId1() != null) { | ||||||
line.setSelectedOperationalLimitsGroup1(modificationInfos.getSelectedOperationalLimitsGroupId1()); | ||||||
} | ||||||
if (modificationInfos.getSelectedOperationalLimitsGroupId2() != null) { | ||||||
line.setSelectedOperationalLimitsGroup2(modificationInfos.getSelectedOperationalLimitsGroupId2()); | ||||||
} | ||||||
PropertiesUtils.applyProperties(line, subReportNode, modificationInfos.getProperties(), "LineProperties"); | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
|
||
import javax.annotation.Nullable; | ||
|
||
import static com.powsybl.iidm.network.TwoSides.ONE; | ||
import static org.gridsuite.modification.NetworkModificationException.Type.*; | ||
|
||
/** | ||
|
@@ -440,15 +441,15 @@ public LineAdder createLineAdder(Network network, VoltageLevel voltageLevel1, Vo | |
.setB2(lineCreationInfos.getB2() != null ? lineCreationInfos.getB2() : 0.0); | ||
|
||
// lineAdder completion by topology | ||
setBranchAdderNodeOrBus(lineAdder, voltageLevel1, lineCreationInfos, TwoSides.ONE, withSwitch1); | ||
setBranchAdderNodeOrBus(lineAdder, voltageLevel1, lineCreationInfos, ONE, withSwitch1); | ||
setBranchAdderNodeOrBus(lineAdder, voltageLevel2, lineCreationInfos, TwoSides.TWO, withSwitch2); | ||
|
||
return lineAdder; | ||
} | ||
|
||
public void setBranchAdderNodeOrBus(BranchAdder<?, ?> branchAdder, VoltageLevel voltageLevel, BranchCreationInfos branchCreationInfos, | ||
TwoSides side, boolean withSwitch) { | ||
String busOrBusbarSectionId = (side == TwoSides.ONE) ? branchCreationInfos.getBusOrBusbarSectionId1() : branchCreationInfos.getBusOrBusbarSectionId2(); | ||
String busOrBusbarSectionId = (side == ONE) ? branchCreationInfos.getBusOrBusbarSectionId1() : branchCreationInfos.getBusOrBusbarSectionId2(); | ||
if (voltageLevel.getTopologyKind() == TopologyKind.BUS_BREAKER) { | ||
setBranchAdderBusBreaker(branchAdder, voltageLevel, side, busOrBusbarSectionId); | ||
} else { | ||
|
@@ -462,7 +463,7 @@ private void setBranchAdderBusBreaker(BranchAdder<?, ?> branchAdder, VoltageLeve | |
Bus bus = getBusBreakerBus(voltageLevel, busId); | ||
|
||
// complete the lineAdder | ||
if (side == TwoSides.ONE) { | ||
if (side == ONE) { | ||
branchAdder.setBus1(bus.getId()).setConnectableBus1(bus.getId()); | ||
} else { | ||
branchAdder.setBus2(bus.getId()).setConnectableBus2(bus.getId()); | ||
|
@@ -481,7 +482,7 @@ private void setBranchAdderNodeBreaker(BranchAdder<?, ?> branchAdder, VoltageLev | |
sideSuffix); | ||
|
||
// complete the lineAdder | ||
if (side == TwoSides.ONE) { | ||
if (side == ONE) { | ||
branchAdder.setNode1(nodeNum); | ||
} else { | ||
branchAdder.setNode2(nodeNum); | ||
|
@@ -1010,24 +1011,34 @@ public Identifiable<?> getEquipmentByIdentifiableType(Network network, Identifia | |
}; | ||
} | ||
|
||
public void setCurrentLimits(CurrentLimitsInfos currentLimitsInfos, CurrentLimitsAdder limitsAdder) { | ||
if (currentLimitsInfos != null) { | ||
boolean hasPermanent = currentLimitsInfos.getPermanentLimit() != null; | ||
boolean hasTemporary = currentLimitsInfos.getTemporaryLimits() != null && !currentLimitsInfos.getTemporaryLimits().isEmpty(); | ||
if (hasPermanent) { | ||
limitsAdder.setPermanentLimit(currentLimitsInfos.getPermanentLimit()); | ||
} | ||
if (hasTemporary) { | ||
for (CurrentTemporaryLimitCreationInfos limit : currentLimitsInfos.getTemporaryLimits()) { | ||
limitsAdder | ||
.beginTemporaryLimit() | ||
.setName(limit.getName()) | ||
.setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) | ||
.setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) | ||
.endTemporaryLimit(); | ||
/** | ||
* @param opLimitGroups added current limits | ||
* @param branch branch to which limits are going to be added | ||
* @param side which side of the branch receives the limits | ||
*/ | ||
public void setCurrentLimitsOnASide(List<OperationalLimitsGroupInfos> opLimitGroups, Branch<?> branch, TwoSides side) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setCurrentLimitsOnSide (don't like the LimitsOnASide) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why ? I think this is more precise with "A" given that "side" also means "secondary" or "in the same time" in english. |
||
for (OperationalLimitsGroupInfos opLimitsGroup : opLimitGroups) { | ||
boolean hasPermanent = opLimitsGroup.getCurrentLimits().getPermanentLimit() != null; | ||
boolean hasTemporary = !CollectionUtils.isEmpty(opLimitsGroup.getCurrentLimits().getTemporaryLimits()); | ||
boolean hasLimits = hasPermanent || hasTemporary; | ||
if (hasLimits) { | ||
basseche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
OperationalLimitsGroup opGroup = side == ONE | ||
? branch.newOperationalLimitsGroup1(opLimitsGroup.getId()) | ||
: branch.newOperationalLimitsGroup2(opLimitsGroup.getId()); | ||
CurrentLimitsAdder limitsAdder = opGroup.newCurrentLimits(); | ||
if (hasPermanent) { | ||
limitsAdder.setPermanentLimit(opLimitsGroup.getCurrentLimits().getPermanentLimit()); | ||
} | ||
if (hasTemporary) { | ||
for (CurrentTemporaryLimitCreationInfos limit : opLimitsGroup.getCurrentLimits().getTemporaryLimits()) { | ||
limitsAdder | ||
.beginTemporaryLimit() | ||
.setName(limit.getName()) | ||
.setValue(limit.getValue() == null ? Double.MAX_VALUE : limit.getValue()) | ||
.setAcceptableDuration(limit.getAcceptableDuration() == null ? Integer.MAX_VALUE : limit.getAcceptableDuration()) | ||
.endTemporaryLimit(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can suggest here to use the functional approach (with forEach)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK done. And it reduces cognitive complexity. Nice. |
||
} | ||
} | ||
if (hasPermanent || hasTemporary) { | ||
limitsAdder.add(); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private String selectedOperationalLimitsGroup1;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK done.