Skip to content

Commit

Permalink
add creation cspr modification network (#519)
Browse files Browse the repository at this point in the history
Signed-off-by: REHILI Ghazwa <[email protected]>
  • Loading branch information
ghazwarhili authored Oct 11, 2024
1 parent f8157eb commit b1f1295
Show file tree
Hide file tree
Showing 17 changed files with 1,142 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum ModificationType {
SUBSTATION_MODIFICATION(PreloadingStrategy.NONE),
SHUNT_COMPENSATOR_CREATION(PreloadingStrategy.NONE),
SHUNT_COMPENSATOR_MODIFICATION(PreloadingStrategy.NONE),
STATIC_VAR_COMPENSATOR_CREATION(PreloadingStrategy.NONE),
VOLTAGE_LEVEL_CREATION(PreloadingStrategy.NONE),
VOLTAGE_LEVEL_MODIFICATION(PreloadingStrategy.NONE),
LINE_SPLIT_WITH_VOLTAGE_LEVEL(PreloadingStrategy.NONE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public enum Type {
CREATE_GENERATOR_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
CREATE_SHUNT_COMPENSATOR_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
MODIFY_SHUNT_COMPENSATOR_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
CREATE_STATIC_VAR_COMPENSATOR_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
DELETE_EQUIPMENT_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
BY_FILTER_DELETION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
EQUIPMENT_NOT_FOUND(HttpStatus.NOT_FOUND),
Expand All @@ -70,6 +71,8 @@ public enum Type {
GENERATOR_ALREADY_EXISTS(HttpStatus.BAD_REQUEST),
SHUNT_COMPENSATOR_ALREADY_EXISTS(HttpStatus.BAD_REQUEST),
SHUNT_COMPENSATOR_NOT_FOUND(HttpStatus.NOT_FOUND),
STATIC_VAR_COMPENSATOR_ALREADY_EXISTS(HttpStatus.BAD_REQUEST),
STATIC_VAR_COMPENSATOR_NOT_FOUND(HttpStatus.NOT_FOUND),
LINE_ALREADY_EXISTS(HttpStatus.BAD_REQUEST),
TWO_WINDINGS_TRANSFORMER_ALREADY_EXISTS(HttpStatus.BAD_REQUEST),
TWO_WINDINGS_TRANSFORMER_CREATION_ERROR(HttpStatus.BAD_REQUEST),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
@JsonSubTypes.Type(value = VoltageLevelModificationInfos.class),
@JsonSubTypes.Type(value = ShuntCompensatorCreationInfos.class),
@JsonSubTypes.Type(value = ShuntCompensatorModificationInfos.class),
@JsonSubTypes.Type(value = StaticVarCompensatorCreationInfos.class),
@JsonSubTypes.Type(value = TwoWindingsTransformerCreationInfos.class),
@JsonSubTypes.Type(value = TwoWindingsTransformerModificationInfos.class),
@JsonSubTypes.Type(value = EquipmentDeletionInfos.class),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* 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.dto;

import com.fasterxml.jackson.annotation.JsonTypeName;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.iidm.network.StaticVarCompensator;
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.ModificationType;
import org.gridsuite.modification.server.dto.annotation.ModificationErrorTypeName;
import org.gridsuite.modification.server.entities.equipment.creation.StaticCompensatorCreationEntity;
import org.gridsuite.modification.server.modifications.AbstractModification;
import org.gridsuite.modification.server.modifications.StaticVarCompensatorCreation;

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

@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
@ToString(callSuper = true)
@Schema(description = "Static var compensator creation")
@JsonTypeName("STATIC_VAR_COMPENSATOR_CREATION")
@ModificationErrorTypeName("CREATE_STATIC_VAR_COMPENSATOR_ERROR")
public class StaticVarCompensatorCreationInfos extends InjectionCreationInfos {
@Schema(description = "Susceptance max")
private Double maxSusceptance;

@Schema(description = "Susceptance min")
private Double minSusceptance;

@Schema(description = "Q max at nominal voltage")
private Double maxQAtNominalV;

@Schema(description = "Q min at nominal voltage")
private Double minQAtNominalV;

@Schema(description = "regulation mode")
private StaticVarCompensator.RegulationMode regulationMode;

@Schema(description = "Voltage set point")
private Double voltageSetpoint;

@Schema(description = "Reactive power set point")
private Double reactivePowerSetpoint;

@Schema(description = "Voltage Regulation type")
private VoltageRegulationType voltageRegulationType;

@Schema(description = "Regulating terminal equipment id")
private String regulatingTerminalId;

@Schema(description = "Regulating terminal equipment type")
private String regulatingTerminalType;

@Schema(description = "Regulating terminal voltage level id")
private String regulatingTerminalVlId;

@Schema(description = "standby automaton on")
private boolean standbyAutomatonOn;

@Schema(description = "Standby")
private boolean standby;

@Schema(description = "Fixed part of susceptance")
private Double b0;

@Schema(description = "Fixed part of Q at nominal voltage")
private Double q0;

@Schema(description = "Low voltage set point ")
private Double lowVoltageSetpoint;

@Schema(description = "High voltage set point")
private Double highVoltageSetpoint;

@Schema(description = "Low voltage threshold")
private Double lowVoltageThreshold;

@Schema(description = "High voltage threshold")
private Double highVoltageThreshold;

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

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

@Override
public ReportNode createSubReportNode(ReportNode reportNode) {
return reportNode.newReportNode().withMessageTemplate(ModificationType.STATIC_VAR_COMPENSATOR_CREATION.name(),
"Static var compensator creation ${id}").withUntypedValue("id", this.getEquipmentId()).add();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/**
* 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.StaticVarCompensator;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.gridsuite.modification.server.dto.ModificationInfos;
import org.gridsuite.modification.server.dto.StaticVarCompensatorCreationInfos;
import org.gridsuite.modification.server.dto.VoltageRegulationType;
import org.gridsuite.modification.server.entities.equipment.modification.FreePropertyEntity;
import org.springframework.util.CollectionUtils;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
@NoArgsConstructor
@Getter
@Entity
@Table(name = "staticVarCompensatorCreation")
@PrimaryKeyJoinColumn(foreignKey = @ForeignKey(name = "staticVarCompensatorCreation_id_fk_constraint"))
public class StaticCompensatorCreationEntity extends InjectionCreationEntity {
@Column
private Double maxSusceptance;

@Column
private Double minSusceptance;

@Column
private Double maxQAtNominalV;

@Column
private Double minQAtNominalV;

@Enumerated(EnumType.STRING)
@Column(name = "regulationMode")
private StaticVarCompensator.RegulationMode regulationMode;

@Column
private Double voltageSetpoint;

@Column
private Double reactivePowerSetpoint;

@Enumerated(EnumType.STRING)
@Column(name = "voltageRegulationType")
private VoltageRegulationType voltageRegulationType;

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

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

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

@Column
private boolean standbyAutomatonOn;

@Column
private boolean standby;

@Column
private Double b0;

@Column
private Double q0;

@Column
private Double lowVoltageSetpoint;

@Column
private Double highVoltageSetpoint;

@Column
private Double lowVoltageThreshold;

@Column
private Double highVoltageThreshold;

public StaticCompensatorCreationEntity(StaticVarCompensatorCreationInfos creationInfos) {
super(creationInfos);
assignAttributes(creationInfos);
}

@Override
public void update(ModificationInfos modificationInfos) {
super.update(modificationInfos);
StaticVarCompensatorCreationInfos staticVarCompensatorCreationInfos = (StaticVarCompensatorCreationInfos) modificationInfos;
assignAttributes(staticVarCompensatorCreationInfos);
}

private void assignAttributes(StaticVarCompensatorCreationInfos creationInfos) {
this.maxSusceptance = creationInfos.getMaxSusceptance();
this.minSusceptance = creationInfos.getMinSusceptance();
this.maxQAtNominalV = creationInfos.getMaxQAtNominalV();
this.minQAtNominalV = creationInfos.getMinQAtNominalV();
this.regulationMode = creationInfos.getRegulationMode();
this.voltageSetpoint = creationInfos.getVoltageSetpoint();
this.reactivePowerSetpoint = creationInfos.getReactivePowerSetpoint();
this.voltageRegulationType = creationInfos.getVoltageRegulationType();
this.regulatingTerminalId = creationInfos.getRegulatingTerminalId();
this.regulatingTerminalType = creationInfos.getRegulatingTerminalType();
this.regulatingTerminalVlId = creationInfos.getRegulatingTerminalVlId();
this.standbyAutomatonOn = creationInfos.isStandbyAutomatonOn();
this.standby = creationInfos.isStandby();
this.b0 = creationInfos.getB0();
this.q0 = creationInfos.getQ0();
this.highVoltageSetpoint = creationInfos.getHighVoltageSetpoint();
this.lowVoltageSetpoint = creationInfos.getLowVoltageSetpoint();
this.lowVoltageThreshold = creationInfos.getLowVoltageThreshold();
this.highVoltageThreshold = creationInfos.getHighVoltageThreshold();
}

@Override
public StaticVarCompensatorCreationInfos toModificationInfos() {
return toStaticVarCompensatorCreationInfosBuilder().build();
}

private StaticVarCompensatorCreationInfos.StaticVarCompensatorCreationInfosBuilder<?, ?> toStaticVarCompensatorCreationInfosBuilder() {
return StaticVarCompensatorCreationInfos
.builder()
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// Injection
.voltageLevelId(getVoltageLevelId())
.busOrBusbarSectionId(getBusOrBusbarSectionId())
.connectionName(getConnectionName())
.connectionDirection(getConnectionDirection())
.connectionPosition(getConnectionPosition())
.terminalConnected(isTerminalConnected())
.maxSusceptance(getMaxSusceptance())
.minSusceptance(getMinSusceptance())
.minQAtNominalV(getMinQAtNominalV())
.maxQAtNominalV(getMaxQAtNominalV())
.regulationMode(getRegulationMode())
.reactivePowerSetpoint(getReactivePowerSetpoint())
.voltageSetpoint(getVoltageSetpoint())
.voltageRegulationType(getVoltageRegulationType())
.regulatingTerminalId(getRegulatingTerminalId())
.regulatingTerminalType(getRegulatingTerminalType())
.regulatingTerminalVlId(getRegulatingTerminalVlId())
// Standby automaton
.standbyAutomatonOn(isStandbyAutomatonOn())
.standby(isStandby())
.b0(getB0())
.q0(getQ0())
.lowVoltageSetpoint(getLowVoltageSetpoint())
.highVoltageSetpoint(getHighVoltageSetpoint())
.lowVoltageThreshold(getLowVoltageThreshold())
.highVoltageThreshold(getHighVoltageThreshold())
// properties
.properties(CollectionUtils.isEmpty(getProperties()) ? null :
getProperties().stream()
.map(FreePropertyEntity::toInfos)
.toList());
}
}
Loading

0 comments on commit b1f1295

Please sign in to comment.