Skip to content

Commit

Permalink
Refactorization of Reactive Capability Curves. (#291)
Browse files Browse the repository at this point in the history
Signed-off-by: BOUTIER Charly <charly.boutier@rte-france.com>
  • Loading branch information
EstherDarkish authored Oct 5, 2022
1 parent 3dc9f79 commit c77963e
Show file tree
Hide file tree
Showing 14 changed files with 689 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@AllArgsConstructor
@Builder
@Schema(description = "Battery attributes")
public class BatteryAttributes extends AbstractAttributes implements InjectionAttributes {
public class BatteryAttributes extends AbstractAttributes implements InjectionAttributes, ReactiveLimitHolder {

@Schema(description = "Voltage level ID")
private String voltageLevelId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@AllArgsConstructor
@Builder
@Schema(description = "Generator attributes")
public class GeneratorAttributes extends AbstractAttributes implements InjectionAttributes {
public class GeneratorAttributes extends AbstractAttributes implements InjectionAttributes, ReactiveLimitHolder {

@Schema(description = "Voltage level ID")
private String voltageLevelId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package com.powsybl.network.store.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -20,16 +19,15 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(description = "Point attributes")
public class ReactiveCapabilityCurvePointAttributes {

@Schema(description = "Active power value")
double p;
private double p;

@Schema(description = "Reactive power minimum value")
double minQ;
private double minQ;

@Schema(description = "Reactive power maximum value")
double maxQ;
private double maxQ;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2022, 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 com.powsybl.network.store.model;

/**
* @author Charly Boutier <charly.boutier at rte-france.com>
*/
public interface ReactiveLimitHolder {

ReactiveLimitsAttributes getReactiveLimits();

void setReactiveLimits(ReactiveLimitsAttributes limits);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@Schema(description = "Temporary limit attributes")
public class TemporaryLimitAttributes {

// TODO side and type should be in LimitAttributes
@JsonIgnore
@Schema(description = "Temporary limit side", required = true)
private Integer side;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@AllArgsConstructor
@Builder
@Schema(description = "VSC converter station attributes")
public class VscConverterStationAttributes extends AbstractAttributes implements InjectionAttributes {
public class VscConverterStationAttributes extends AbstractAttributes implements InjectionAttributes, ReactiveLimitHolder {

@Schema(description = "Voltage level ID")
private String voltageLevelId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public class Mappings {
private static final String PERMANENT_ACTIVE_POWER_LIMIT_1 = "permanentActivePowerLimit1";
private static final String PERMANENT_ACTIVE_POWER_LIMIT_2 = "permanentActivePowerLimit2";
private static final String VOLTAGE_REGULATOR_ON = "voltageRegulatorOn";
private static final String MIN_MAX_REACIVE_LIMITS = "minMaxReactiveLimits";
private static final String REACTIVE_CAPABILITY_CURVE = "reactiveCapabilityCurve";
private static final String REGULATION_TERMINAL = "regulatingTerminal";
private static final String MINQ = "minQ";
private static final String MAXQ = "maxQ";

public TableMapping getTableMapping(String table) {
Objects.requireNonNull(table);
Expand Down Expand Up @@ -270,19 +270,21 @@ private void createGeneratorMappings() {
generatorMappings.addColumnMapping("targetQ", new ColumnMapping<>(Double.class, GeneratorAttributes::getTargetQ, GeneratorAttributes::setTargetQ));
generatorMappings.addColumnMapping("targetV", new ColumnMapping<>(Double.class, GeneratorAttributes::getTargetV, GeneratorAttributes::setTargetV));
generatorMappings.addColumnMapping(RATED_S, new ColumnMapping<>(Double.class, GeneratorAttributes::getRatedS, GeneratorAttributes::setRatedS));
generatorMappings.addColumnMapping(MIN_MAX_REACIVE_LIMITS, new ColumnMapping<>(ReactiveLimitsAttributes.class, (GeneratorAttributes attributes) ->
attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? attributes.getReactiveLimits() : null,
(GeneratorAttributes attributes, ReactiveLimitsAttributes limits) -> {
if (limits instanceof MinMaxReactiveLimitsAttributes) {
attributes.setReactiveLimits(limits);
generatorMappings.addColumnMapping(MINQ, new ColumnMapping<>(Double.class,
(GeneratorAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMinQ() : null,
(GeneratorAttributes attributes, Double value) -> {
if (attributes.getReactiveLimits() == null) {
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
}
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMinQ(value);
}));
generatorMappings.addColumnMapping(REACTIVE_CAPABILITY_CURVE, new ColumnMapping<>(ReactiveLimitsAttributes.class, (GeneratorAttributes attributes) ->
attributes.getReactiveLimits() instanceof ReactiveCapabilityCurveAttributes ? attributes.getReactiveLimits() : null,
(GeneratorAttributes attributes, ReactiveLimitsAttributes limits) -> {
if (limits instanceof ReactiveCapabilityCurveAttributes) {
attributes.setReactiveLimits(limits);
generatorMappings.addColumnMapping(MAXQ, new ColumnMapping<>(Double.class,
(GeneratorAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMaxQ() : null,
(GeneratorAttributes attributes, Double value) -> {
if (attributes.getReactiveLimits() == null) {
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
}
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMaxQ(value);
}));
generatorMappings.addColumnMapping("activePowerControl", new ColumnMapping<>(ActivePowerControlAttributes.class, GeneratorAttributes::getActivePowerControl, GeneratorAttributes::setActivePowerControl));
generatorMappings.addColumnMapping(REGULATION_TERMINAL, new ColumnMapping<>(TerminalRefAttributes.class, GeneratorAttributes::getRegulatingTerminal, GeneratorAttributes::setRegulatingTerminal));
Expand Down Expand Up @@ -402,19 +404,21 @@ private void createBatteryMappings() {
batteryMappings.addColumnMapping("p", new ColumnMapping<>(Double.class, BatteryAttributes::getP, BatteryAttributes::setP));
batteryMappings.addColumnMapping("q", new ColumnMapping<>(Double.class, BatteryAttributes::getQ, BatteryAttributes::setQ));
batteryMappings.addColumnMapping(FICTITIOUS, new ColumnMapping<>(Boolean.class, BatteryAttributes::isFictitious, BatteryAttributes::setFictitious));
batteryMappings.addColumnMapping(MIN_MAX_REACIVE_LIMITS, new ColumnMapping<>(ReactiveLimitsAttributes.class, (BatteryAttributes attributes) ->
attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? attributes.getReactiveLimits() : null,
(BatteryAttributes attributes, ReactiveLimitsAttributes limits) -> {
if (limits instanceof MinMaxReactiveLimitsAttributes) {
attributes.setReactiveLimits(limits);
batteryMappings.addColumnMapping(MINQ, new ColumnMapping<>(Double.class,
(BatteryAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMinQ() : null,
(BatteryAttributes attributes, Double value) -> {
if (attributes.getReactiveLimits() == null) {
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
}
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMinQ(value);
}));
batteryMappings.addColumnMapping(REACTIVE_CAPABILITY_CURVE, new ColumnMapping<>(ReactiveLimitsAttributes.class, (BatteryAttributes attributes) ->
attributes.getReactiveLimits() instanceof ReactiveCapabilityCurveAttributes ? attributes.getReactiveLimits() : null,
(BatteryAttributes attributes, ReactiveLimitsAttributes limits) -> {
if (limits instanceof ReactiveCapabilityCurveAttributes) {
attributes.setReactiveLimits(limits);
batteryMappings.addColumnMapping(MAXQ, new ColumnMapping<>(Double.class,
(BatteryAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMaxQ() : null,
(BatteryAttributes attributes, Double value) -> {
if (attributes.getReactiveLimits() == null) {
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
}
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMaxQ(value);
}));
batteryMappings.addColumnMapping("activePowerControl", new ColumnMapping<>(ActivePowerControlAttributes.class, BatteryAttributes::getActivePowerControl, BatteryAttributes::setActivePowerControl));
batteryMappings.addColumnMapping("node", new ColumnMapping<>(Integer.class, BatteryAttributes::getNode, BatteryAttributes::setNode));
Expand Down Expand Up @@ -559,19 +563,21 @@ private void createVscConverterStationMappings() {
vscConverterStationMappings.addColumnMapping("reactivePowerSetPoint", new ColumnMapping<>(Double.class, VscConverterStationAttributes::getReactivePowerSetPoint, VscConverterStationAttributes::setReactivePowerSetPoint));
vscConverterStationMappings.addColumnMapping("voltageSetPoint", new ColumnMapping<>(Double.class, VscConverterStationAttributes::getVoltageSetPoint, VscConverterStationAttributes::setVoltageSetPoint));
vscConverterStationMappings.addColumnMapping(FICTITIOUS, new ColumnMapping<>(Boolean.class, VscConverterStationAttributes::isFictitious, VscConverterStationAttributes::setFictitious));
vscConverterStationMappings.addColumnMapping(MIN_MAX_REACIVE_LIMITS, new ColumnMapping<>(ReactiveLimitsAttributes.class, (VscConverterStationAttributes attributes) ->
attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? attributes.getReactiveLimits() : null,
(VscConverterStationAttributes attributes, ReactiveLimitsAttributes limits) -> {
if (limits instanceof MinMaxReactiveLimitsAttributes) {
attributes.setReactiveLimits(limits);
vscConverterStationMappings.addColumnMapping(MINQ, new ColumnMapping<>(Double.class,
(VscConverterStationAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMinQ() : null,
(VscConverterStationAttributes attributes, Double value) -> {
if (attributes.getReactiveLimits() == null) {
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
}
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMinQ(value);
}));
vscConverterStationMappings.addColumnMapping(REACTIVE_CAPABILITY_CURVE, new ColumnMapping<>(ReactiveLimitsAttributes.class, (VscConverterStationAttributes attributes) ->
attributes.getReactiveLimits() instanceof ReactiveCapabilityCurveAttributes ? attributes.getReactiveLimits() : null,
(VscConverterStationAttributes attributes, ReactiveLimitsAttributes limits) -> {
if (limits instanceof ReactiveCapabilityCurveAttributes) {
attributes.setReactiveLimits(limits);
vscConverterStationMappings.addColumnMapping(MAXQ, new ColumnMapping<>(Double.class,
(VscConverterStationAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMaxQ() : null,
(VscConverterStationAttributes attributes, Double value) -> {
if (attributes.getReactiveLimits() == null) {
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
}
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMaxQ(value);
}));
vscConverterStationMappings.addColumnMapping("node", new ColumnMapping<>(Integer.class, VscConverterStationAttributes::getNode, VscConverterStationAttributes::setNode));
vscConverterStationMappings.addColumnMapping(PROPERTIES, new ColumnMapping<>(Map.class, VscConverterStationAttributes::getProperties, VscConverterStationAttributes::setProperties));
Expand Down
Loading

0 comments on commit c77963e

Please sign in to comment.