Skip to content

Commit

Permalink
Add Vsc creation (#325)
Browse files Browse the repository at this point in the history
Signed-off-by: Seddik Yengui <[email protected]>
  • Loading branch information
YenguiSeddik authored Sep 21, 2023
1 parent 5eff596 commit f1e53ce
Show file tree
Hide file tree
Showing 13 changed files with 1,117 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public enum ModificationType {
DELETE_VOLTAGE_LEVEL_ON_LINE(PreloadingStrategy.NONE),
DELETE_ATTACHING_LINE(PreloadingStrategy.NONE),
GENERATION_DISPATCH(PreloadingStrategy.COLLECTION),
VOLTAGE_INIT_MODIFICATION(PreloadingStrategy.COLLECTION);
VOLTAGE_INIT_MODIFICATION(PreloadingStrategy.COLLECTION),
VSC_CREATION(PreloadingStrategy.NONE),
CONVERTER_STATION_CREATION(PreloadingStrategy.NONE);

private final PreloadingStrategy strategy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ public enum Type {
FILTERS_NOT_FOUND(HttpStatus.NOT_FOUND),
GENERATION_DISPATCH_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
PRELOADING_STRATEGY_NOT_ALLOWED(HttpStatus.INTERNAL_SERVER_ERROR),
VOLTAGE_INIT_MODIFICATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR);
VOLTAGE_INIT_MODIFICATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
CREATE_VSC_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
HVDC_LINE_ALREADY_EXISTS(HttpStatus.BAD_REQUEST),
VSC_CONVERTER_STATION_NOT_FOUND(HttpStatus.NOT_FOUND),
CREATE_CONVERTER_STATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR);

public final HttpStatus status;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* 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;

import com.fasterxml.jackson.annotation.JsonTypeName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.annotation.ModificationErrorTypeName;
import org.gridsuite.modification.server.entities.equipment.creation.ConverterStationCreationEntity;

import java.util.List;

/**
* @author Seddik Yengui <seddik.yengui at rte-france.com>
*/

@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
@ToString(callSuper = true)
@Schema(description = "Converter station creation")
@JsonTypeName("CONVERTER_STATION_CREATION")
@ModificationErrorTypeName("CREATE_CONVERTER_STATION_ERROR")
public class ConverterStationCreationInfos extends InjectionCreationInfos implements ReactiveLimitsHolderInfos {
@Schema(description = "Loss Factor")
private Float lossFactor;

@Schema(description = "Reactive power")
private Double reactivePower;

@Schema(description = "Voltage regulation")
private Boolean voltageRegulationOn;

@Schema(description = "Voltage")
private Double voltage;

@Schema(description = "Reactive capability curve")
private Boolean reactiveCapabilityCurve;

@Schema(description = "Minimum reactive power")
private Double minimumReactivePower;

@Schema(description = "Maximum reactive power")
private Double maximumReactivePower;

@Schema(description = "Reactive capability curve points")
private List<ReactiveCapabilityCurveCreationInfos> reactiveCapabilityCurvePoints;

@Override
public ConverterStationCreationEntity toEntity() {
return new ConverterStationCreationEntity(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
@JsonSubTypes.Type(value = DeleteVoltageLevelOnLineInfos.class),
@JsonSubTypes.Type(value = DeleteAttachingLineInfos.class),
@JsonSubTypes.Type(value = GenerationDispatchInfos.class),
@JsonSubTypes.Type(value = VoltageInitModificationInfos.class)
@JsonSubTypes.Type(value = VoltageInitModificationInfos.class),
@JsonSubTypes.Type(value = VscCreationInfos.class),
@JsonSubTypes.Type(value = ConverterStationCreationInfos.class)
})
@SuperBuilder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* 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;

import com.fasterxml.jackson.annotation.JsonTypeName;
import com.powsybl.commons.reporter.Reporter;
import com.powsybl.commons.reporter.ReporterModel;
import com.powsybl.iidm.network.HvdcLine;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.annotation.ModificationErrorTypeName;
import org.gridsuite.modification.server.entities.equipment.creation.VscCreationEntity;
import org.gridsuite.modification.server.modifications.AbstractModification;
import org.gridsuite.modification.server.modifications.VscCreation;

/**
* @author Seddik Yengui <seddik.yengui at rte-france.com>
*/

@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
@ToString(callSuper = true)
@Schema(description = "VSC creation")
@JsonTypeName("VSC_CREATION")
@ModificationErrorTypeName("CREATE_VSC_ERROR")
public class VscCreationInfos extends EquipmentCreationInfos {
@Schema(description = "DC nominal voltage")
private Double dcNominalVoltage;

@Schema(description = "DC resistance")
private Double dcResistance;

@Schema(description = "Maximum active power ")
private Double maximumActivePower;

@Schema(description = "Operator active power limit (Side1->Side2)")
private Float operatorActivePowerLimitFromSide1ToSide2;

@Schema(description = "Operator active power limit (Side2->Side1)")
private Float operatorActivePowerLimitFromSide2ToSide1;

@Schema(description = "Converters mode")
private HvdcLine.ConvertersMode convertersMode;

@Schema(description = "Active power")
private Double activePower;

@Schema(description = "Angle droop active power control ")
private Boolean angleDroopActivePowerControl;

@Schema(description = "p0")
private Float p0;

@Schema(description = "droop")
private Float droop;

@Schema(description = "Converter station 1")
private ConverterStationCreationInfos converterStation1;

@Schema(description = "Converter station 2")
private ConverterStationCreationInfos converterStation2;

@Override
public VscCreationEntity toEntity() {
return new VscCreationEntity(this);
}

@Override
public AbstractModification toModification() {
return new VscCreation(this);
}

@Override
public Reporter createSubReporter(ReporterModel reporter) {
return reporter.createSubReporter(getType().name(), "Vsc creation ${vscId}", "vscId", this.getEquipmentId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/**
* 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.entities.equipment.creation;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.gridsuite.modification.server.dto.ConverterStationCreationInfos;
import org.gridsuite.modification.server.dto.ReactiveCapabilityCurveCreationInfos;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

/**
* @author Seddik Yengui <seddik.yengui at rte-france.com>
*/

@AllArgsConstructor
@NoArgsConstructor
@Getter
@Entity
@Table(name = "converterStationCreation")
public class ConverterStationCreationEntity extends InjectionCreationEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private UUID id;

@Column
private Float lossFactor;

@Column
private Double minimumReactivePower;

@Column
private Double maximumReactivePower;

@Column
private Double reactivePower;

@Column
private Boolean voltageRegulationOn;

@Column
private Double voltage;

@ElementCollection
@CollectionTable(name = "converter_station_creation_rcc_points")
private List<ReactiveCapabilityCurveCreationEmbeddable> reactiveCapabilityCurvePoints;

@Column
private Boolean reactiveCapabilityCurve;

public ConverterStationCreationEntity(ConverterStationCreationInfos converterStationCreationInfos) {
super(converterStationCreationInfos);
assignAttributes(converterStationCreationInfos);
}

private void assignAttributes(ConverterStationCreationInfos converterStationCreationInfos) {
this.lossFactor = converterStationCreationInfos.getLossFactor();
this.minimumReactivePower = converterStationCreationInfos.getMinimumReactivePower();
this.maximumReactivePower = converterStationCreationInfos.getMaximumReactivePower();
this.reactivePower = converterStationCreationInfos.getReactivePower();
this.voltageRegulationOn = converterStationCreationInfos.getVoltageRegulationOn();
this.voltage = converterStationCreationInfos.getVoltage();
this.reactiveCapabilityCurvePoints = toEmbeddablePoints(converterStationCreationInfos.getReactiveCapabilityCurvePoints());
this.reactiveCapabilityCurve = converterStationCreationInfos.getReactiveCapabilityCurve();
}

public ConverterStationCreationInfos toConverterStationInfos() {
return ConverterStationCreationInfos.builder()
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
.lossFactor(getLossFactor())
.minimumReactivePower(getMinimumReactivePower())
.maximumReactivePower(getMaximumReactivePower())
.reactivePower(getReactivePower())
.voltageRegulationOn(getVoltageRegulationOn())
.voltage(getVoltage())
.reactiveCapabilityCurvePoints(toReactiveCapabilityCurveInfos(getReactiveCapabilityCurvePoints()))
.voltageLevelId(getVoltageLevelId())
.busOrBusbarSectionId(getBusOrBusbarSectionId())
.connectionName(getConnectionName())
.connectionPosition(getConnectionPosition())
.connectionDirection(getConnectionDirection())
.reactiveCapabilityCurve(getReactiveCapabilityCurve())
.build();
}

private static List<ReactiveCapabilityCurveCreationEmbeddable> toEmbeddablePoints(
List<ReactiveCapabilityCurveCreationInfos> points) {
return points == null ? null : points.stream()
.map(point -> new ReactiveCapabilityCurveCreationEmbeddable(point.getQminP(),
point.getQmaxP(),
point.getP()))
.collect(Collectors.toList());
}

private static List<ReactiveCapabilityCurveCreationInfos> toReactiveCapabilityCurveInfos(List<ReactiveCapabilityCurveCreationEmbeddable> pointsEmbeddable) {
if (pointsEmbeddable == null) {
return null;
}

return pointsEmbeddable.stream()
.map(pointEmbeddable -> ReactiveCapabilityCurveCreationInfos.builder()
.p(pointEmbeddable.getP())
.qmaxP(pointEmbeddable.getQmaxP())
.qminP(pointEmbeddable.getQminP())
.build())
.collect(Collectors.toList());
}
}
Loading

0 comments on commit f1e53ce

Please sign in to comment.