Skip to content

Commit

Permalink
Add connectivity option for line and 2wt creation modifications (#376)
Browse files Browse the repository at this point in the history
Signed-off-by: David BRAQUART <[email protected]>
  • Loading branch information
dbraquart authored Nov 23, 2023
1 parent 841b4b3 commit 7e376df
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ public class BranchCreationInfos extends EquipmentCreationInfos {

@Schema(description = "Connection position 2")
private Integer connectionPosition2;

@Schema(description = "Connected 1")
private boolean connected1;

@Schema(description = "Connected 2")
private boolean connected2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public class BranchCreationEntity extends EquipmentCreationEntity {
@Column(name = "connectionPosition2")
private Integer connectionPosition2;

@Column(name = "connected1", columnDefinition = "boolean default true")
private boolean connected1;

@Column(name = "connected2", columnDefinition = "boolean default true")
private boolean connected2;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(name = "current_limits_id1",
referencedColumnName = "id",
Expand Down Expand Up @@ -109,5 +115,7 @@ private void assignAttributes(BranchCreationInfos branchCreationInfos) {
connectionName2 = branchCreationInfos.getConnectionName2();
connectionPosition1 = branchCreationInfos.getConnectionPosition1();
connectionPosition2 = branchCreationInfos.getConnectionPosition2();
connected1 = branchCreationInfos.isConnected1();
connected2 = branchCreationInfos.isConnected2();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,26 @@ public LineCreationInfos toModificationInfos() {
.stashed(getStashed())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// branch
.seriesResistance(getSeriesResistance())
.seriesReactance(getSeriesReactance())
.shuntConductance1(getShuntConductance1())
.shuntSusceptance1(getShuntSusceptance1())
.shuntConductance2(getShuntConductance2())
.shuntSusceptance2(getShuntSusceptance2())
.voltageLevelId1(getVoltageLevelId1())
.busOrBusbarSectionId1(getBusOrBusbarSectionId1())
.voltageLevelId2(getVoltageLevelId2())
.busOrBusbarSectionId1(getBusOrBusbarSectionId1())
.busOrBusbarSectionId2(getBusOrBusbarSectionId2())
.connectionName1(getConnectionName1())
.connectionDirection1(getConnectionDirection1())
.connectionName2(getConnectionName2())
.connectionDirection1(getConnectionDirection1())
.connectionDirection2(getConnectionDirection2())
.connectionPosition1(getConnectionPosition1())
.connectionPosition2(getConnectionPosition2());
.connectionPosition2(getConnectionPosition2())
.connected1(isConnected1())
.connected2(isConnected2())
// line
.shuntConductance1(getShuntConductance1())
.shuntSusceptance1(getShuntSusceptance1())
.shuntConductance2(getShuntConductance2())
.shuntSusceptance2(getShuntSusceptance2());

if (getCurrentLimits1() != null) {
builder.currentLimits1(getCurrentLimits1().toCurrentLimitsInfos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,27 @@ public TwoWindingsTransformerCreationInfos toModificationInfos() {
.stashed(getStashed())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// branch
.seriesResistance(getSeriesResistance())
.seriesReactance(getSeriesReactance())
.magnetizingConductance(getMagnetizingConductance())
.magnetizingSusceptance(getMagnetizingSusceptance())
.ratedVoltage1(getRatedVoltage1())
.ratedVoltage2(getRatedVoltage2())
.ratedS(getRatedS())
.voltageLevelId1(getVoltageLevelId1())
.busOrBusbarSectionId1(getBusOrBusbarSectionId1())
.voltageLevelId2(getVoltageLevelId2())
.busOrBusbarSectionId1(getBusOrBusbarSectionId1())
.busOrBusbarSectionId2(getBusOrBusbarSectionId2())
.connectionName1(getConnectionName1())
.connectionDirection1(getConnectionDirection1())
.connectionName2(getConnectionName2())
.connectionDirection1(getConnectionDirection1())
.connectionDirection2(getConnectionDirection2())
.connectionPosition1(getConnectionPosition1())
.connectionPosition2(getConnectionPosition2());
.connectionPosition2(getConnectionPosition2())
.connected1(isConnected1())
.connected2(isConnected2())
// 2WT
.magnetizingConductance(getMagnetizingConductance())
.magnetizingSusceptance(getMagnetizingSusceptance())
.ratedVoltage1(getRatedVoltage1())
.ratedVoltage2(getRatedVoltage2())
.ratedS(getRatedS());

if (getCurrentLimits1() != null) {
builder.currentLimits1(getCurrentLimits1().toCurrentLimitsInfos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void apply(Network network, Reporter subReporter) {
ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos1, line.newCurrentLimits1());
ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos2, line.newCurrentLimits2());
}

ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getLine(modificationInfos.getEquipmentId()), subReporter);
}

private void addLine(Network network, VoltageLevel voltageLevel1, VoltageLevel voltageLevel2, LineCreationInfos lineCreationInfos, boolean withSwitch1, boolean withSwitch2, Reporter subReporter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,28 @@ public void disconnectInjection(InjectionCreationInfos modificationInfos, Inject
}
}

public void disconnectBranch(BranchCreationInfos modificationInfos, Branch<?> branch, Reporter subReporter) {
// A newly created branch is connected by default on both sides, unless we choose not to do
if (!modificationInfos.isConnected1()) {
branch.getTerminal1().disconnect();
subReporter.report(Report.builder()
.withKey("terminal1Disconnected")
.withDefaultMessage("Equipment with id=${id} disconnected on side 1")
.withValue("id", modificationInfos.getEquipmentId())
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}
if (!modificationInfos.isConnected2()) {
branch.getTerminal2().disconnect();
subReporter.report(Report.builder()
.withKey("terminal2Disconnected")
.withDefaultMessage("Equipment with id=${id} disconnected on side 2")
.withValue("id", modificationInfos.getEquipmentId())
.withSeverity(TypedValue.INFO_SEVERITY)
.build());
}
}

public Identifiable<?> getEquipmentByIdentifiableType(Network network, String type, String equipmentId) {
if (type == null || equipmentId == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void apply(Network network, Reporter subReporter) {
ModificationUtils.getInstance().setCurrentLimits(currentLimitsInfos2, twoWindingsTransformer.newCurrentLimits2());
}

ModificationUtils.getInstance().disconnectBranch(modificationInfos, network.getTwoWindingsTransformer(modificationInfos.getEquipmentId()), subReporter);
}

private TwoWindingsTransformer create2WTInNodeBreaker(Network network, VoltageLevel voltageLevel1, VoltageLevel voltageLevel2, Reporter subReporter) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="braquartdav (generated)" id="1700243549225-29">
<addColumn tableName="line_creation">
<column defaultValueBoolean="true" name="connected1" type="boolean"/>
</addColumn>
</changeSet>
<changeSet author="braquartdav (generated)" id="1700243549225-30">
<addColumn tableName="two_windings_transformer_creation">
<column defaultValueBoolean="true" name="connected1" type="boolean"/>
</addColumn>
</changeSet>
<changeSet author="braquartdav (generated)" id="1700243549225-31">
<addColumn tableName="line_creation">
<column defaultValueBoolean="true" name="connected2" type="boolean"/>
</addColumn>
</changeSet>
<changeSet author="braquartdav (generated)" id="1700243549225-32">
<addColumn tableName="two_windings_transformer_creation">
<column defaultValueBoolean="true" name="connected2" type="boolean"/>
</addColumn>
</changeSet>
</databaseChangeLog>
3 changes: 3 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,7 @@ databaseChangeLog:
relativeToChangelogFile: true
- include:
file: changesets/changelog_20231611T132720Z.xml
relativeToChangelogFile: true
- include:
file: changesets/changelog_20231117T175127Z.xml
relativeToChangelogFile: true
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public void testCreateLineWithBothCurrentLimits() throws Exception {
.connectionDirection2(ConnectablePosition.Direction.TOP)
.connectionPosition1(0)
.connectionPosition2(0)
.connected1(true)
.connected2(false)
.build();

String lineCreationJson = mapper.writeValueAsString(lineCreation);
Expand All @@ -223,7 +225,7 @@ public void testCreateLineWithBothCurrentLimits() throws Exception {
testNetworkModificationsCount(getGroupId(), 1);

assertEquals(
"LineCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=LINE_CREATION, date=null, stashed=false, messageType=null, messageValues=null), equipmentId=idLineEdited), equipmentName=nameLineEdited), seriesResistance=110.0, seriesReactance=110.0, voltageLevelId1=v2, voltageLevelId2=v1, busOrBusbarSectionId1=1A, busOrBusbarSectionId2=1.1, currentLimits1=CurrentLimitsInfos(permanentLimit=200.0, temporaryLimits=[CurrentTemporaryLimitCreationInfos(name=IT10, value=200.0, acceptableDuration=600)]), currentLimits2=CurrentLimitsInfos(permanentLimit=100.0, temporaryLimits=[CurrentTemporaryLimitCreationInfos(name=IT20, value=600.0, acceptableDuration=1200)]), connectionName1=cn1LineEdited, connectionDirection1=BOTTOM, connectionName2=cn2LineEdited, connectionDirection2=TOP, connectionPosition1=0, connectionPosition2=0), shuntConductance1=15.0, shuntSusceptance1=15.0, shuntConductance2=25.0, shuntSusceptance2=25.0)",
"LineCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=LINE_CREATION, date=null, stashed=false, messageType=null, messageValues=null), equipmentId=idLineEdited), equipmentName=nameLineEdited), seriesResistance=110.0, seriesReactance=110.0, voltageLevelId1=v2, voltageLevelId2=v1, busOrBusbarSectionId1=1A, busOrBusbarSectionId2=1.1, currentLimits1=CurrentLimitsInfos(permanentLimit=200.0, temporaryLimits=[CurrentTemporaryLimitCreationInfos(name=IT10, value=200.0, acceptableDuration=600)]), currentLimits2=CurrentLimitsInfos(permanentLimit=100.0, temporaryLimits=[CurrentTemporaryLimitCreationInfos(name=IT20, value=600.0, acceptableDuration=1200)]), connectionName1=cn1LineEdited, connectionDirection1=BOTTOM, connectionName2=cn2LineEdited, connectionDirection2=TOP, connectionPosition1=0, connectionPosition2=0, connected1=true, connected2=false), shuntConductance1=15.0, shuntSusceptance1=15.0, shuntConductance2=25.0, shuntSusceptance2=25.0)",
lineCreation.toString()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ protected ModificationInfos buildModification() {
.ratedS(1.)
.voltageLevelId1("v1")
.busOrBusbarSectionId1("bus1")
.connected1(true)
.voltageLevelId2("v12")
.busOrBusbarSectionId2("bus12")
.connected2(true)
.currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build())
.currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build())
.connectionName1("cn201")
Expand Down Expand Up @@ -315,8 +317,10 @@ public void testCreateTwoWindingsTransformerWithRatioTapChangerInBusBreaker() th
.equipmentName("2wtName")
.voltageLevelId1("v1")
.busOrBusbarSectionId1("bus1")
.connected1(true)
.voltageLevelId2("v12")
.busOrBusbarSectionId2("bus12")
.connected2(true)
.magnetizingConductance(100.0)
.magnetizingSusceptance(200.0)
.ratedVoltage1(1000)
Expand All @@ -333,8 +337,10 @@ public void testCreateTwoWindingsTransformerWithRatioTapChangerInBusBreaker() th
.equipmentName("2wtName")
.voltageLevelId1("v1")
.busOrBusbarSectionId1("bus1")
.connected1(true)
.voltageLevelId2("v12")
.busOrBusbarSectionId2("bus12")
.connected2(true)
.magnetizingConductance(100.0)
.magnetizingSusceptance(200.0)
.ratedVoltage1(1000)
Expand Down Expand Up @@ -379,8 +385,10 @@ public void testCreateTwoWindingsTransformerWithPhaseTapChangerInBusBreaker() th
.seriesResistance(400)
.connectionName1("cnid2wt1")
.connectionDirection1(ConnectablePosition.Direction.TOP)
.connected1(true)
.connectionName2("cnid2wt2")
.connectionDirection2(ConnectablePosition.Direction.TOP)
.connected2(true)
.phaseTapChanger(phaseTapChangerCreationInfos)
.build();
testCreateTwoWindingsTransformerInBusBreaker(twoWindingsTransformerCreationInfos, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ protected ModificationInfos buildModification() {
.equipmentName("2wtName")
.voltageLevelId1("v1")
.busOrBusbarSectionId1("1.1")
.connected1(true)
.voltageLevelId2("v3")
.busOrBusbarSectionId2("bus3")
.connected2(true)
.magnetizingConductance(100.0)
.magnetizingSusceptance(200.0)
.ratedVoltage1(1000)
Expand Down
Loading

0 comments on commit 7e376df

Please sign in to comment.