Skip to content

Commit bfe058b

Browse files
EstherDarkishjonenst
authored andcommitted
Refactorization of Reactive Capability Curves. (#291)
Signed-off-by: BOUTIER Charly <[email protected]>
1 parent 3dc9f79 commit bfe058b

File tree

14 files changed

+689
-91
lines changed

14 files changed

+689
-91
lines changed

network-store-model/src/main/java/com/powsybl/network/store/model/BatteryAttributes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@AllArgsConstructor
2222
@Builder
2323
@Schema(description = "Battery attributes")
24-
public class BatteryAttributes extends AbstractAttributes implements InjectionAttributes {
24+
public class BatteryAttributes extends AbstractAttributes implements InjectionAttributes, ReactiveLimitHolder {
2525

2626
@Schema(description = "Voltage level ID")
2727
private String voltageLevelId;

network-store-model/src/main/java/com/powsybl/network/store/model/GeneratorAttributes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@AllArgsConstructor
2323
@Builder
2424
@Schema(description = "Generator attributes")
25-
public class GeneratorAttributes extends AbstractAttributes implements InjectionAttributes {
25+
public class GeneratorAttributes extends AbstractAttributes implements InjectionAttributes, ReactiveLimitHolder {
2626

2727
@Schema(description = "Voltage level ID")
2828
private String voltageLevelId;

network-store-model/src/main/java/com/powsybl/network/store/model/ReactiveCapabilityCurvePointAttributes.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
package com.powsybl.network.store.model;
88

9-
import com.fasterxml.jackson.annotation.JsonInclude;
109
import io.swagger.v3.oas.annotations.media.Schema;
1110
import lombok.AllArgsConstructor;
1211
import lombok.Builder;
@@ -20,16 +19,15 @@
2019
@NoArgsConstructor
2120
@AllArgsConstructor
2221
@Builder
23-
@JsonInclude(JsonInclude.Include.NON_NULL)
2422
@Schema(description = "Point attributes")
2523
public class ReactiveCapabilityCurvePointAttributes {
2624

2725
@Schema(description = "Active power value")
28-
double p;
26+
private double p;
2927

3028
@Schema(description = "Reactive power minimum value")
31-
double minQ;
29+
private double minQ;
3230

3331
@Schema(description = "Reactive power maximum value")
34-
double maxQ;
32+
private double maxQ;
3533
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package com.powsybl.network.store.model;
8+
9+
/**
10+
* @author Charly Boutier <charly.boutier at rte-france.com>
11+
*/
12+
public interface ReactiveLimitHolder {
13+
14+
ReactiveLimitsAttributes getReactiveLimits();
15+
16+
void setReactiveLimits(ReactiveLimitsAttributes limits);
17+
}

network-store-model/src/main/java/com/powsybl/network/store/model/TemporaryLimitAttributes.java

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
@Schema(description = "Temporary limit attributes")
2727
public class TemporaryLimitAttributes {
2828

29-
// TODO side and type should be in LimitAttributes
3029
@JsonIgnore
3130
@Schema(description = "Temporary limit side", required = true)
3231
private Integer side;

network-store-model/src/main/java/com/powsybl/network/store/model/VscConverterStationAttributes.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@AllArgsConstructor
2222
@Builder
2323
@Schema(description = "VSC converter station attributes")
24-
public class VscConverterStationAttributes extends AbstractAttributes implements InjectionAttributes {
24+
public class VscConverterStationAttributes extends AbstractAttributes implements InjectionAttributes, ReactiveLimitHolder {
2525

2626
@Schema(description = "Voltage level ID")
2727
private String voltageLevelId;

network-store-server/src/main/java/com/powsybl/network/store/server/Mappings.java

+38-32
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public class Mappings {
132132
private static final String PERMANENT_ACTIVE_POWER_LIMIT_1 = "permanentActivePowerLimit1";
133133
private static final String PERMANENT_ACTIVE_POWER_LIMIT_2 = "permanentActivePowerLimit2";
134134
private static final String VOLTAGE_REGULATOR_ON = "voltageRegulatorOn";
135-
private static final String MIN_MAX_REACIVE_LIMITS = "minMaxReactiveLimits";
136-
private static final String REACTIVE_CAPABILITY_CURVE = "reactiveCapabilityCurve";
137135
private static final String REGULATION_TERMINAL = "regulatingTerminal";
136+
private static final String MINQ = "minQ";
137+
private static final String MAXQ = "maxQ";
138138

139139
public TableMapping getTableMapping(String table) {
140140
Objects.requireNonNull(table);
@@ -270,19 +270,21 @@ private void createGeneratorMappings() {
270270
generatorMappings.addColumnMapping("targetQ", new ColumnMapping<>(Double.class, GeneratorAttributes::getTargetQ, GeneratorAttributes::setTargetQ));
271271
generatorMappings.addColumnMapping("targetV", new ColumnMapping<>(Double.class, GeneratorAttributes::getTargetV, GeneratorAttributes::setTargetV));
272272
generatorMappings.addColumnMapping(RATED_S, new ColumnMapping<>(Double.class, GeneratorAttributes::getRatedS, GeneratorAttributes::setRatedS));
273-
generatorMappings.addColumnMapping(MIN_MAX_REACIVE_LIMITS, new ColumnMapping<>(ReactiveLimitsAttributes.class, (GeneratorAttributes attributes) ->
274-
attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? attributes.getReactiveLimits() : null,
275-
(GeneratorAttributes attributes, ReactiveLimitsAttributes limits) -> {
276-
if (limits instanceof MinMaxReactiveLimitsAttributes) {
277-
attributes.setReactiveLimits(limits);
273+
generatorMappings.addColumnMapping(MINQ, new ColumnMapping<>(Double.class,
274+
(GeneratorAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMinQ() : null,
275+
(GeneratorAttributes attributes, Double value) -> {
276+
if (attributes.getReactiveLimits() == null) {
277+
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
278278
}
279+
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMinQ(value);
279280
}));
280-
generatorMappings.addColumnMapping(REACTIVE_CAPABILITY_CURVE, new ColumnMapping<>(ReactiveLimitsAttributes.class, (GeneratorAttributes attributes) ->
281-
attributes.getReactiveLimits() instanceof ReactiveCapabilityCurveAttributes ? attributes.getReactiveLimits() : null,
282-
(GeneratorAttributes attributes, ReactiveLimitsAttributes limits) -> {
283-
if (limits instanceof ReactiveCapabilityCurveAttributes) {
284-
attributes.setReactiveLimits(limits);
281+
generatorMappings.addColumnMapping(MAXQ, new ColumnMapping<>(Double.class,
282+
(GeneratorAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMaxQ() : null,
283+
(GeneratorAttributes attributes, Double value) -> {
284+
if (attributes.getReactiveLimits() == null) {
285+
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
285286
}
287+
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMaxQ(value);
286288
}));
287289
generatorMappings.addColumnMapping("activePowerControl", new ColumnMapping<>(ActivePowerControlAttributes.class, GeneratorAttributes::getActivePowerControl, GeneratorAttributes::setActivePowerControl));
288290
generatorMappings.addColumnMapping(REGULATION_TERMINAL, new ColumnMapping<>(TerminalRefAttributes.class, GeneratorAttributes::getRegulatingTerminal, GeneratorAttributes::setRegulatingTerminal));
@@ -402,19 +404,21 @@ private void createBatteryMappings() {
402404
batteryMappings.addColumnMapping("p", new ColumnMapping<>(Double.class, BatteryAttributes::getP, BatteryAttributes::setP));
403405
batteryMappings.addColumnMapping("q", new ColumnMapping<>(Double.class, BatteryAttributes::getQ, BatteryAttributes::setQ));
404406
batteryMappings.addColumnMapping(FICTITIOUS, new ColumnMapping<>(Boolean.class, BatteryAttributes::isFictitious, BatteryAttributes::setFictitious));
405-
batteryMappings.addColumnMapping(MIN_MAX_REACIVE_LIMITS, new ColumnMapping<>(ReactiveLimitsAttributes.class, (BatteryAttributes attributes) ->
406-
attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? attributes.getReactiveLimits() : null,
407-
(BatteryAttributes attributes, ReactiveLimitsAttributes limits) -> {
408-
if (limits instanceof MinMaxReactiveLimitsAttributes) {
409-
attributes.setReactiveLimits(limits);
407+
batteryMappings.addColumnMapping(MINQ, new ColumnMapping<>(Double.class,
408+
(BatteryAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMinQ() : null,
409+
(BatteryAttributes attributes, Double value) -> {
410+
if (attributes.getReactiveLimits() == null) {
411+
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
410412
}
413+
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMinQ(value);
411414
}));
412-
batteryMappings.addColumnMapping(REACTIVE_CAPABILITY_CURVE, new ColumnMapping<>(ReactiveLimitsAttributes.class, (BatteryAttributes attributes) ->
413-
attributes.getReactiveLimits() instanceof ReactiveCapabilityCurveAttributes ? attributes.getReactiveLimits() : null,
414-
(BatteryAttributes attributes, ReactiveLimitsAttributes limits) -> {
415-
if (limits instanceof ReactiveCapabilityCurveAttributes) {
416-
attributes.setReactiveLimits(limits);
415+
batteryMappings.addColumnMapping(MAXQ, new ColumnMapping<>(Double.class,
416+
(BatteryAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMaxQ() : null,
417+
(BatteryAttributes attributes, Double value) -> {
418+
if (attributes.getReactiveLimits() == null) {
419+
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
417420
}
421+
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMaxQ(value);
418422
}));
419423
batteryMappings.addColumnMapping("activePowerControl", new ColumnMapping<>(ActivePowerControlAttributes.class, BatteryAttributes::getActivePowerControl, BatteryAttributes::setActivePowerControl));
420424
batteryMappings.addColumnMapping("node", new ColumnMapping<>(Integer.class, BatteryAttributes::getNode, BatteryAttributes::setNode));
@@ -559,19 +563,21 @@ private void createVscConverterStationMappings() {
559563
vscConverterStationMappings.addColumnMapping("reactivePowerSetPoint", new ColumnMapping<>(Double.class, VscConverterStationAttributes::getReactivePowerSetPoint, VscConverterStationAttributes::setReactivePowerSetPoint));
560564
vscConverterStationMappings.addColumnMapping("voltageSetPoint", new ColumnMapping<>(Double.class, VscConverterStationAttributes::getVoltageSetPoint, VscConverterStationAttributes::setVoltageSetPoint));
561565
vscConverterStationMappings.addColumnMapping(FICTITIOUS, new ColumnMapping<>(Boolean.class, VscConverterStationAttributes::isFictitious, VscConverterStationAttributes::setFictitious));
562-
vscConverterStationMappings.addColumnMapping(MIN_MAX_REACIVE_LIMITS, new ColumnMapping<>(ReactiveLimitsAttributes.class, (VscConverterStationAttributes attributes) ->
563-
attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? attributes.getReactiveLimits() : null,
564-
(VscConverterStationAttributes attributes, ReactiveLimitsAttributes limits) -> {
565-
if (limits instanceof MinMaxReactiveLimitsAttributes) {
566-
attributes.setReactiveLimits(limits);
566+
vscConverterStationMappings.addColumnMapping(MINQ, new ColumnMapping<>(Double.class,
567+
(VscConverterStationAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMinQ() : null,
568+
(VscConverterStationAttributes attributes, Double value) -> {
569+
if (attributes.getReactiveLimits() == null) {
570+
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
567571
}
572+
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMinQ(value);
568573
}));
569-
vscConverterStationMappings.addColumnMapping(REACTIVE_CAPABILITY_CURVE, new ColumnMapping<>(ReactiveLimitsAttributes.class, (VscConverterStationAttributes attributes) ->
570-
attributes.getReactiveLimits() instanceof ReactiveCapabilityCurveAttributes ? attributes.getReactiveLimits() : null,
571-
(VscConverterStationAttributes attributes, ReactiveLimitsAttributes limits) -> {
572-
if (limits instanceof ReactiveCapabilityCurveAttributes) {
573-
attributes.setReactiveLimits(limits);
574+
vscConverterStationMappings.addColumnMapping(MAXQ, new ColumnMapping<>(Double.class,
575+
(VscConverterStationAttributes attributes) -> attributes.getReactiveLimits() instanceof MinMaxReactiveLimitsAttributes ? ((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).getMaxQ() : null,
576+
(VscConverterStationAttributes attributes, Double value) -> {
577+
if (attributes.getReactiveLimits() == null) {
578+
attributes.setReactiveLimits(new MinMaxReactiveLimitsAttributes());
574579
}
580+
((MinMaxReactiveLimitsAttributes) attributes.getReactiveLimits()).setMaxQ(value);
575581
}));
576582
vscConverterStationMappings.addColumnMapping("node", new ColumnMapping<>(Integer.class, VscConverterStationAttributes::getNode, VscConverterStationAttributes::setNode));
577583
vscConverterStationMappings.addColumnMapping(PROPERTIES, new ColumnMapping<>(Map.class, VscConverterStationAttributes::getProperties, VscConverterStationAttributes::setProperties));

0 commit comments

Comments
 (0)