Skip to content

feat: add subtract load flow balancing option #645

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
13 changes: 7 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<db-util.version>1.0.5</db-util.version>
<mockwebserver3.version>5.0.0-alpha.14</mockwebserver3.version>
<!-- TODO network-modification.version remove when migration powsybl -->
<network-modification.version>0.19.0</network-modification.version>
<network-modification.version>0.20.0-SNAPSHOT</network-modification.version>
<liquibase-hibernate-package>org.gridsuite.modification.server</liquibase-hibernate-package>
<sonar.coverage.exclusions>**/migration/**/*</sonar.coverage.exclusions>
<sonar.organization>gridsuite</sonar.organization>
Expand Down Expand Up @@ -96,6 +96,12 @@
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-balances-adjustment</artifactId>
<version>2.14.0-SNAPSHOT</version>
</dependency>

<!-- imports -->
<dependency>
<groupId>org.gridsuite</groupId>
Expand Down Expand Up @@ -200,11 +206,6 @@
<artifactId>powsybl-open-loadflow</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-config-classic</artifactId>
<scope>runtime</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public class BalancesAdjustmentEntity extends ModificationEntity {
@Enumerated(EnumType.STRING)
private LoadFlowParameters.BalanceType balanceType = DEFAULT_BALANCE_TYPE;

@Column(name = "with_load_flow")
private boolean withLoadFlow = DEFAULT_WITH_LOAD_FLOW;

@Column(name = "subtract_load_flow_balancing")
private boolean subtractLoadFlowBalancing = DEFAULT_SUBTRACT_LOAD_FLOW_BALANCING;

@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(name = "balances_adjustment_id", foreignKey = @ForeignKey(name = "area_balances_adjustment_id_fk"))
private List<BalancesAdjustmentAreaEntity> areas;
Expand All @@ -56,16 +62,18 @@ public BalancesAdjustmentEntity(@NonNull BalancesAdjustmentModificationInfos bal
@Override
public BalancesAdjustmentModificationInfos toModificationInfos() {
return BalancesAdjustmentModificationInfos.builder()
.date(getDate())
.uuid(getId())
.stashed(getStashed())
.activated(getActivated())
.areas(areas.stream().map(BalancesAdjustmentAreaEntity::getAreaInfos).toList())
.thresholdNetPosition(thresholdNetPosition)
.maxNumberIterations(maxNumberIterations)
.countriesToBalance(CountriesUtils.toList(countriesToBalance))
.balanceType(balanceType)
.build();
.date(getDate())
.uuid(getId())
.stashed(getStashed())
.activated(getActivated())
.areas(areas.stream().map(BalancesAdjustmentAreaEntity::getAreaInfos).toList())
.thresholdNetPosition(thresholdNetPosition)
.maxNumberIterations(maxNumberIterations)
.countriesToBalance(CountriesUtils.toList(countriesToBalance))
.balanceType(balanceType)
.withLoadFlow(withLoadFlow)
.subtractLoadFlowBalancing(subtractLoadFlowBalancing)
.build();
}

@Override
Expand All @@ -79,6 +87,8 @@ private void assignAttributes(BalancesAdjustmentModificationInfos balancesAdjust
thresholdNetPosition = balancesAdjustmentModificationInfos.getThresholdNetPosition();
countriesToBalance = CountriesUtils.stringify(balancesAdjustmentModificationInfos.getCountriesToBalance());
balanceType = balancesAdjustmentModificationInfos.getBalanceType();
withLoadFlow = balancesAdjustmentModificationInfos.isWithLoadFlow();
subtractLoadFlowBalancing = balancesAdjustmentModificationInfos.isSubtractLoadFlowBalancing();
List<BalancesAdjustmentAreaEntity> areaEntities = balancesAdjustmentModificationInfos
.getAreas()
.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?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="berrahmaach (generated)" id="1748876161766-25">
<addColumn tableName="balances_adjustment">
<column name="with_load_flow" type="boolean" defaultValueBoolean="true" valueBoolean="true">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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="mancinijor (generated)" id="1749721253189-28">
<addColumn tableName="balances_adjustment">
<column name="subtract_load_flow_balancing" type="boolean" defaultValue="false"/>
</addColumn>
</changeSet>
</databaseChangeLog>
6 changes: 6 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,9 @@ databaseChangeLog:
- include:
file: changesets/changelog_20250520T103410Z.xml
relativeToChangelogFile: true
- include:
file: changesets/changelog_20250602T145520Z.xml
relativeToChangelogFile: true
- include:
file: changesets/changelog_20250612T094023Z.xml
relativeToChangelogFile: true
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ protected ModificationInfos buildModification() {
.shiftEquipmentType(ShiftEquipmentType.LOAD)
.build()
))
.withLoadFlow(true)
.build();
}

Expand Down
Loading