Skip to content

Commit

Permalink
cspr creation modification network
Browse files Browse the repository at this point in the history
  • Loading branch information
ghazwarhili committed Aug 26, 2024
1 parent ea496ab commit de654e8
Show file tree
Hide file tree
Showing 13 changed files with 827 additions and 217 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public class StaticVarCompensatorCreationInfos extends InjectionCreationInfos {
@Schema(description = "Minimum susceptance available")
private Double minSusceptance;

@Schema(description = "Maximal qAtNominalV available")
private Double maxQAtNominalV;

@Schema(description = "Minimum qAtNominalV available")
private Double minQAtNominalV;

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

Expand All @@ -55,11 +61,35 @@ public class StaticVarCompensatorCreationInfos extends InjectionCreationInfos {
@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")
private StandByAutomatonCreationInfos standbyAutomatonCreationInfos;
@Schema(description = "add standby automate")
private boolean standByAutomateOn;

@Schema(description = "Minimum reactive power ")
private boolean standby;

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

@Schema(description = "Fix part of the reactive power")
private Double q0;

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

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

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

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

@Override
public StaticCompensatorCreationEntity toEntity() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.gridsuite.modification.server.dto.ModificationInfos;
import org.gridsuite.modification.server.dto.StandByAutomatonCreationInfos;
import org.gridsuite.modification.server.dto.StaticVarCompensatorCreationInfos;
import org.gridsuite.modification.server.dto.VoltageRegulationType;
import org.gridsuite.modification.server.entities.equipment.modification.FreePropertyEntity;
Expand All @@ -32,34 +31,58 @@ public class StaticCompensatorCreationEntity extends InjectionCreationEntity {
@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;

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

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

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

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

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

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(
name = "standBy_automaton_creation",
referencedColumnName = "id",
foreignKey = @ForeignKey(
name = "standBy_automaton_creation_id_fk"
))
private StandByAutomatonCreationEntity standByAutomatonCreation;
@Column
private boolean standByAutomateOn;

@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);
Expand All @@ -76,13 +99,23 @@ public void update(ModificationInfos modificationInfos) {
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.regulatingTerminalId = creationInfos.getRegulatingTerminalId();
this.voltageRegulationType = creationInfos.getVoltageRegulationType();
this.regulatingTerminalId = creationInfos.getRegulatingTerminalId();
this.regulatingTerminalType = creationInfos.getRegulatingTerminalType();
this.regulatingTerminalVlId = creationInfos.getRegulatingTerminalVlId();
this.standByAutomatonCreation = toEmbeddableStandByAutomaton(creationInfos.getStandbyAutomatonCreationInfos());
this.standByAutomateOn = creationInfos.isStandByAutomateOn();
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
Expand All @@ -107,45 +140,28 @@ public StaticVarCompensatorCreationInfos toModificationInfos() {
.terminalConnected(isTerminalConnected())
.maxSusceptance(getMaxSusceptance())
.minSusceptance(getMinSusceptance())
.minQAtNominalV(getMinQAtNominalV())
.maxQAtNominalV(getMaxQAtNominalV())
.regulationMode(getRegulationMode())
.reactivePowerSetpoint(getReactivePowerSetpoint())
.voltageSetpoint(getVoltageSetpoint())
.voltageRegulationType(getVoltageRegulationType())
.regulatingTerminalId(getRegulatingTerminalId())
.regulatingTerminalType(getRegulatingTerminalType())
.regulatingTerminalVlId(getRegulatingTerminalVlId())
.standbyAutomatonCreationInfos(toStandByAutomatonInfos(getStandByAutomatonCreation()))
// StandBy automate
.standByAutomateOn(isStandByAutomateOn())
.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());
}

private static StandByAutomatonCreationEntity toEmbeddableStandByAutomaton(
StandByAutomatonCreationInfos standByAutomaton) {
return standByAutomaton == null ? null :
StandByAutomatonCreationEntity.builder()
.standby(standByAutomaton.isStandby())
.b0(standByAutomaton.getB0())
.lowVoltageSetpoint(standByAutomaton.getLowVoltageSetpoint())
.highVoltageSetpoint(standByAutomaton.getHighVoltageSetpoint())
.lowVoltageThreshold(standByAutomaton.getLowVoltageThreshold())
.highVoltageThreshold(standByAutomaton.getHighVoltageThreshold())
.build();
}

private static StandByAutomatonCreationInfos toStandByAutomatonInfos(StandByAutomatonCreationEntity standByAutomatonEmbeddable) {
if (standByAutomatonEmbeddable == null) {
return null;
}

return StandByAutomatonCreationInfos.builder()
.b0(standByAutomatonEmbeddable.getB0())
.standby(standByAutomatonEmbeddable.isStandby())
.highVoltageSetpoint(standByAutomatonEmbeddable.getHighVoltageSetpoint())
.lowVoltageSetpoint(standByAutomatonEmbeddable.getLowVoltageSetpoint())
.highVoltageThreshold(standByAutomatonEmbeddable.getHighVoltageThreshold())
.lowVoltageSetpoint(standByAutomatonEmbeddable.getLowVoltageThreshold())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ HvdcLine getHvdcLine(Network network, String hvdcLineId) {
return hvdcLine;
}

StaticVarCompensator staticVarCompensator(Network network, String staticVarCompensatorId) {
StaticVarCompensator staticVarCompensator = network.getStaticVarCompensator(staticVarCompensatorId);
if (staticVarCompensator == null) {
throw new NetworkModificationException(GENERATOR_NOT_FOUND, "Static var compensator " + staticVarCompensatorId + " does not exist in network");
}
return staticVarCompensator;
}

public void controlConnectivity(Network network, String voltageLevelId, String busOrBusbarSectionId, Integer connectionPosition) {
VoltageLevel voltageLevel = getVoltageLevel(network, voltageLevelId);
if (voltageLevel.getTopologyKind() == TopologyKind.NODE_BREAKER) {
Expand Down Expand Up @@ -1147,6 +1155,55 @@ public void checkReactiveLimitsCreation(ReactiveLimitsHolderInfos modificationIn
}
}

public void checkReactivePowerLimitsAndSetPointsCreation(Double maxSusceptance, Double minSusceptance,
Double maxQAtNominalV, Double minQAtNominalV,
Double voltageSetpoint, Double reactivePowerSetpoint,
StaticVarCompensator.RegulationMode regulationMode,
NetworkModificationException.Type errorType,
String equipmentId,
String equipmentName) {
// check min max reactive limits
if (Objects.isNull(minSusceptance) && Objects.isNull(minQAtNominalV)) {
throw makeEquipmentException(errorType, equipmentId, equipmentName, "minimum susceptance is not set");
} else if (Objects.isNull(maxSusceptance) && Objects.isNull(maxQAtNominalV)) {
throw makeEquipmentException(errorType, equipmentId, equipmentName, "maximum susceptance is not set");
} else if (Objects.nonNull(maxSusceptance) && Objects.nonNull(minSusceptance) && maxSusceptance < minSusceptance ||
Objects.nonNull(maxQAtNominalV) && Objects.nonNull(minQAtNominalV) && maxQAtNominalV < minQAtNominalV) {
throw makeEquipmentException(errorType, equipmentId, equipmentName, "maximum susceptance is expected to be greater than or equal to minimum susceptance");
}

// check set points
switch (regulationMode) {
case VOLTAGE -> {
if (voltageSetpoint == null) {
throw makeEquipmentException(errorType, equipmentId, equipmentName, "Voltage setpoint is not set");
}
}
case REACTIVE_POWER -> {
if (reactivePowerSetpoint == null) {
throw makeEquipmentException(errorType, equipmentId, equipmentName, "Reactive power setpoint is not set");
}
}
}
}

public void checkStandByAutomateCreation(Boolean standBy, Double b0, Double q0,
Double minSusceptance, Double maxSusceptance,
Double minQAtNominalV, Double maxQAtNominalV,
StaticVarCompensator.RegulationMode regulationMode,
NetworkModificationException.Type errorType,
String equipmentId,
String equipmentName) {
if (Boolean.TRUE.equals(standBy) && regulationMode != StaticVarCompensator.RegulationMode.VOLTAGE) {
throw makeEquipmentException(errorType, equipmentId, equipmentName, "Regulation mode is expected to be voltage");
}
if (Objects.nonNull(b0) && Objects.nonNull(minSusceptance) && Objects.nonNull(maxSusceptance) && (b0 < minSusceptance || b0 > maxSusceptance)
|| Objects.nonNull(q0) && Objects.nonNull(minQAtNominalV) && Objects.nonNull(maxQAtNominalV) && (q0 < minQAtNominalV || q0 > maxQAtNominalV)) {
throw makeEquipmentException(errorType, equipmentId, equipmentName,
"b0 is expected to be within the range of minimun susceptance and maximum susceptance");
}
}

public static void addToReports(List<ReportNode> reports, Double newValue, String fieldName) {
if (newValue != null) {
reports.add(ModificationUtils.getInstance().buildCreationReport(newValue, fieldName));
Expand Down
Loading

0 comments on commit de654e8

Please sign in to comment.