Skip to content

Commit

Permalink
add creation hvdc lcc (#566)
Browse files Browse the repository at this point in the history
Signed-off-by: Rehili Ghazwa <[email protected]>
  • Loading branch information
ghazwarhili authored Dec 11, 2024
1 parent 9d5483f commit e18e64f
Show file tree
Hide file tree
Showing 7 changed files with 497 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ private EntityRegistry() {
register(StaticVarCompensatorCreationInfos.class, StaticCompensatorCreationEntity.class);
register(VscCreationInfos.class, VscCreationEntity.class);
register(ConverterStationCreationInfos.class, ConverterStationCreationEntity.class);
register(LccCreationInfos.class, LccCreationEntity.class);
register(LccConverterStationCreationInfos.class, LccConverterStationCreationEntity.class);
register(TabularCreationInfos.class, TabularCreationEntity.class);

// // modification
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* 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.server.entities.equipment.creation;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.gridsuite.modification.dto.LccConverterStationCreationInfos;

import java.util.List;
import java.util.UUID;

import static org.gridsuite.modification.server.entities.equipment.creation.ShuntCompensatorCreationEmbeddable.fromEmbeddableShuntCompensatorCreation;
import static org.gridsuite.modification.server.entities.equipment.creation.ShuntCompensatorCreationEmbeddable.toEmbeddableShuntCompensatorCreation;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/

@AllArgsConstructor
@NoArgsConstructor
@Getter
@Entity
@Table(name = "lccConverterStationCreation")
@PrimaryKeyJoinColumn(foreignKey = @ForeignKey(name = "lcc_converter_station_creation_id_fk_constraint"))
public class LccConverterStationCreationEntity extends InjectionCreationEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private UUID id;

@Column
private Float lossFactor;

@Column
private Float powerFactor;

@ElementCollection
@CollectionTable(name = "shunt_compensator_on_side",
foreignKey = @ForeignKey(name = "lcc_converter_station_creation_shunt_compensators_on_side_fk"))
private List<ShuntCompensatorCreationEmbeddable> shuntCompensatorsOnSide;

public LccConverterStationCreationEntity(LccConverterStationCreationInfos converterStationCreationInfos) {
super(converterStationCreationInfos);
assignAttributes(converterStationCreationInfos);
}

private void assignAttributes(LccConverterStationCreationInfos converterStationCreationInfos) {
this.lossFactor = converterStationCreationInfos.getLossFactor();
this.powerFactor = converterStationCreationInfos.getPowerFactor();
this.shuntCompensatorsOnSide = toEmbeddableShuntCompensatorCreation(converterStationCreationInfos.getShuntCompensatorsOnSide());
}

public LccConverterStationCreationInfos toLccConverterStationInfos() {
return LccConverterStationCreationInfos.builder()
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// Injection
.voltageLevelId(getVoltageLevelId())
.busOrBusbarSectionId(getBusOrBusbarSectionId())
.connectionName(getConnectionName())
.connectionPosition(getConnectionPosition())
.connectionDirection(getConnectionDirection())
.terminalConnected(isTerminalConnected())
// ConverterStation
.lossFactor(getLossFactor())
.powerFactor(getPowerFactor())
.shuntCompensatorsOnSide(fromEmbeddableShuntCompensatorCreation(getShuntCompensatorsOnSide()))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* 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.server.entities.equipment.creation;

import com.powsybl.iidm.network.HvdcLine;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.gridsuite.modification.dto.LccConverterStationCreationInfos;
import org.gridsuite.modification.dto.LccCreationInfos;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.modification.server.entities.equipment.modification.FreePropertyEntity;
import org.springframework.util.CollectionUtils;

/**
* @author Rehili Ghazwa <ghazwa.rehili at rte-france.com>
*/

@NoArgsConstructor
@Getter
@Entity
@Table(name = "lccCreation")
@PrimaryKeyJoinColumn(foreignKey = @ForeignKey(name = "lcc_creation_id_fk_constraint"))
public class LccCreationEntity extends EquipmentCreationEntity {
@Column
private Double nominalV;

@Column
private Double r;

@Column
private Double maxP;

@Column
@Enumerated(EnumType.STRING)
private HvdcLine.ConvertersMode convertersMode;

@Column
private Double activePowerSetpoint;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(
name = "lcc_converter_station_1_id",
referencedColumnName = "id",
foreignKey = @ForeignKey(
name = "lcc_converter_station_1_id_fk"
))
private LccConverterStationCreationEntity converterStation1;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(
name = "lcc_converter_station_2_id",
referencedColumnName = "id",
foreignKey = @ForeignKey(
name = "lcc_converter_station_2_id_fk"
))
private LccConverterStationCreationEntity converterStation2;

public LccCreationEntity(@NonNull LccCreationInfos lccCreationInfos) {
super(lccCreationInfos);
assignAttributes(lccCreationInfos);
}

@Override
public void update(@NonNull ModificationInfos modificationInfos) {
super.update(modificationInfos);
assignAttributes((LccCreationInfos) modificationInfos);
}

private void assignAttributes(LccCreationInfos lccCreationInfos) {
this.nominalV = lccCreationInfos.getNominalV();
this.r = lccCreationInfos.getR();
this.maxP = lccCreationInfos.getMaxP();
this.activePowerSetpoint = lccCreationInfos.getActivePowerSetpoint();
this.convertersMode = lccCreationInfos.getConvertersMode();
this.converterStation1 = new LccConverterStationCreationEntity(lccCreationInfos.getConverterStation1());
this.converterStation2 = new LccConverterStationCreationEntity(lccCreationInfos.getConverterStation2());
}

@Override
public LccCreationInfos toModificationInfos() {
return toLccCreationInfosBuilder().build();
}

private LccCreationInfos.LccCreationInfosBuilder<?, ?> toLccCreationInfosBuilder() {
LccConverterStationCreationInfos converterStationCreationInfos1 = getConverterStation1() == null ? null : getConverterStation1().toLccConverterStationInfos();
LccConverterStationCreationInfos converterStationCreationInfos2 = getConverterStation2() == null ? null : getConverterStation2().toLccConverterStationInfos();
return LccCreationInfos.builder()
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
.nominalV(getNominalV())
.r(getR())
.maxP(getMaxP())
.activePowerSetpoint(getActivePowerSetpoint())
.convertersMode(getConvertersMode())
.converterStation1(converterStationCreationInfos1)
.converterStation2(converterStationCreationInfos2)
// properties
.properties(CollectionUtils.isEmpty(getProperties()) ? null :
getProperties().stream()
.map(FreePropertyEntity::toInfos)
.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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.server.entities.equipment.creation;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.gridsuite.modification.dto.LccConverterStationCreationInfos;

import java.util.List;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Embeddable
public class ShuntCompensatorCreationEmbeddable {
@Column(name = "shuntCompensatorId")
private String id;

@Column(name = "shuntCompensatorName")
private String name;

@Column
private Double maxQAtNominalV;

@Column
private Boolean connectedToHvdc;

public static List<ShuntCompensatorCreationEmbeddable> toEmbeddableShuntCompensatorCreation(List<LccConverterStationCreationInfos.ShuntCompensatorInfos> compensatorCreationInfos) {
return compensatorCreationInfos == null ? null :
compensatorCreationInfos.stream()
.map(compensatorCreationInfo -> new ShuntCompensatorCreationEmbeddable(compensatorCreationInfo.getId(),
compensatorCreationInfo.getName(),
compensatorCreationInfo.getMaxQAtNominalV(),
compensatorCreationInfo.getConnectedToHvdc()))
.toList();
}

public static List<LccConverterStationCreationInfos.ShuntCompensatorInfos> fromEmbeddableShuntCompensatorCreation(List<ShuntCompensatorCreationEmbeddable> compensatorCreationEmbeddables) {
return compensatorCreationEmbeddables == null ? null :
compensatorCreationEmbeddables.stream()
.map(compensatorCreationEmbeddable -> new LccConverterStationCreationInfos.ShuntCompensatorInfos(compensatorCreationEmbeddable.getId(),
compensatorCreationEmbeddable.getName(),
compensatorCreationEmbeddable.getMaxQAtNominalV(),
compensatorCreationEmbeddable.getConnectedToHvdc()))
.toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?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="rehiligha (generated)" id="1733488784779-31">
<createTable tableName="lcc_converter_station_creation">
<column name="equipment_id" type="VARCHAR(255)"/>
<column name="equipment_name" type="VARCHAR(255)"/>
<column name="bus_or_busbar_section_id" type="VARCHAR(255)"/>
<column name="connection_direction" type="SMALLINT"/>
<column name="connection_name" type="VARCHAR(255)"/>
<column name="connection_position" type="INT"/>
<column defaultValueBoolean="true" name="connected" type="BOOLEAN"/>
<column name="voltage_level_id" type="VARCHAR(255)"/>
<column name="loss_factor" type="FLOAT4"/>
<column name="power_factor" type="FLOAT4"/>
<column name="id" type="UUID">
<constraints nullable="false" primaryKey="true" primaryKeyName="lcc_converter_station_creationPK"/>
</column>
</createTable>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-32">
<createTable tableName="lcc_creation">
<column name="equipment_id" type="VARCHAR(255)"/>
<column name="equipment_name" type="VARCHAR(255)"/>
<column name="active_power_setpoint" type="FLOAT(53)"/>
<column name="converters_mode" type="VARCHAR(255)"/>
<column name="maxp" type="FLOAT(53)"/>
<column name="nominalv" type="FLOAT(53)"/>
<column name="r" type="FLOAT(53)"/>
<column name="id" type="UUID">
<constraints nullable="false" primaryKey="true" primaryKeyName="lcc_creationPK"/>
</column>
<column name="lcc_converter_station_1_id" type="UUID"/>
<column name="lcc_converter_station_2_id" type="UUID"/>
</createTable>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-33">
<createTable tableName="shunt_compensator_on_side">
<column name="lcc_converter_station_creation_entity_id" type="UUID">
<constraints nullable="false"/>
</column>
<column name="connected_to_hvdc" type="BOOLEAN"/>
<column name="shunt_compensator_id" type="VARCHAR(255)"/>
<column name="maxqat_nominalv" type="FLOAT(53)"/>
<column name="shunt_compensator_name" type="VARCHAR(255)"/>
</createTable>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-35">
<addUniqueConstraint columnNames="lcc_converter_station_1_id" constraintName="uc_lcc_converter_station_1_id_col" tableName="lcc_creation"/>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-36">
<addUniqueConstraint columnNames="lcc_converter_station_2_id" constraintName="uc_lcc_converter_station_2_id_col" tableName="lcc_creation"/>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-56">
<addForeignKeyConstraint baseColumnNames="lcc_converter_station_1_id" baseTableName="lcc_creation" constraintName="lcc_converter_station_1_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="lcc_converter_station_creation" validate="true"/>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-57">
<addForeignKeyConstraint baseColumnNames="lcc_converter_station_2_id" baseTableName="lcc_creation" constraintName="lcc_converter_station_2_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="lcc_converter_station_creation" validate="true"/>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-58">
<addForeignKeyConstraint baseColumnNames="id" baseTableName="lcc_converter_station_creation" constraintName="lcc_converter_station_creation_id_fk_constraint" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="modification" validate="true"/>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-59">
<addForeignKeyConstraint baseColumnNames="lcc_converter_station_creation_entity_id" baseTableName="shunt_compensator_on_side" constraintName="lcc_converter_station_creation_shunt_compensators_on_side_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="lcc_converter_station_creation" validate="true"/>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733488784779-60">
<addForeignKeyConstraint baseColumnNames="id" baseTableName="lcc_creation" constraintName="lcc_creation_id_fk_constraint" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="modification" validate="true"/>
</changeSet>
</databaseChangeLog>
5 changes: 4 additions & 1 deletion src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,7 @@ databaseChangeLog:
file: changesets/changelog_20240912T130742Z.xml
- include:
relativeToChangelogFile: true
file: changesets/changelog_20241015T130742Z.xml
file: changesets/changelog_20241015T130742Z.xml
- include:
relativeToChangelogFile: true
file: changesets/changelog_20241206T123930Z.xml
Loading

0 comments on commit e18e64f

Please sign in to comment.