Skip to content

Commit f725637

Browse files
Move code from study-server
1 parent 3f5009b commit f725637

File tree

4 files changed

+193
-0
lines changed

4 files changed

+193
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2023, 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 org.gridsuite.shortcircuit.server.dto;
8+
9+
import com.powsybl.shortcircuit.ShortCircuitParameters;
10+
import com.powsybl.shortcircuit.VoltageRange;
11+
import lombok.*;
12+
13+
import java.util.List;
14+
15+
/**
16+
* @author AJELLAL Ali <[email protected]>
17+
* @since 1.7.0
18+
*/
19+
@Builder
20+
public record ShortCircuitParametersInfos(
21+
ShortCircuitPredefinedConfiguration predefinedParameters,
22+
ShortCircuitParameters parameters,
23+
List<VoltageRange> cei909VoltageRanges
24+
) {
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2023, 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 org.gridsuite.shortcircuit.server.dto;
8+
9+
/**
10+
* @author AJELLAL Ali <[email protected]>
11+
* @since 1.7.0
12+
*/
13+
public enum ShortCircuitPredefinedConfiguration {
14+
ICC_MAX_WITH_NOMINAL_VOLTAGE_MAP,
15+
ICC_MAX_WITH_CEI909
16+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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 org.gridsuite.shortcircuit.server.entities;
8+
9+
import com.powsybl.shortcircuit.InitialVoltageProfileMode;
10+
import com.powsybl.shortcircuit.StudyType;
11+
import jakarta.persistence.*;
12+
import lombok.*;
13+
import org.gridsuite.shortcircuit.server.dto.ShortCircuitPredefinedConfiguration;
14+
15+
import java.util.UUID;
16+
17+
/**
18+
* @author Abdelsalem Hedhili <abdelsalem.hedhili at rte-france.com>
19+
* @since 1.7.0
20+
*/
21+
@Builder
22+
@NoArgsConstructor
23+
@AllArgsConstructor
24+
@Getter
25+
@Setter
26+
@Entity
27+
@Table(name = "shortCircuitParameters")
28+
public class ShortCircuitParametersEntity {
29+
30+
public ShortCircuitParametersEntity(boolean withLimitViolations, boolean withVoltageResult, boolean withFortescueResult, boolean withFeederResult, StudyType studyType, double minVoltageDropProportionalThreshold, boolean withLoads, boolean withShuntCompensators, boolean withVscConverterStations, boolean withNeutralPosition, InitialVoltageProfileMode initialVoltageProfileMode, ShortCircuitPredefinedConfiguration predefinedParameters) {
31+
this(null, withLimitViolations, withVoltageResult, withFortescueResult, withFeederResult, studyType, minVoltageDropProportionalThreshold, predefinedParameters, withLoads, withShuntCompensators, withVscConverterStations, withNeutralPosition, initialVoltageProfileMode);
32+
}
33+
34+
@Id
35+
@GeneratedValue(strategy = GenerationType.AUTO)
36+
@Column(name = "id")
37+
private UUID id;
38+
39+
@Column(name = "withLimitViolations", columnDefinition = "boolean default true")
40+
private boolean withLimitViolations;
41+
42+
@Column(name = "withVoltageResult", columnDefinition = "boolean default true")
43+
private boolean withVoltageResult;
44+
45+
@Column(name = "withFortescueResult", columnDefinition = "boolean default true")
46+
private boolean withFortescueResult;
47+
48+
@Column(name = "withFeederResult", columnDefinition = "boolean default true")
49+
private boolean withFeederResult;
50+
51+
@Column(name = "studyType")
52+
@Enumerated(EnumType.STRING)
53+
private StudyType studyType;
54+
55+
@Column(name = "minVoltageDropProportionalThreshold")
56+
private double minVoltageDropProportionalThreshold;
57+
58+
@Column(name = "predefinedParameters")
59+
@Enumerated(EnumType.STRING)
60+
private ShortCircuitPredefinedConfiguration predefinedParameters;
61+
62+
@Column(name = "withLoads", columnDefinition = "boolean default false")
63+
private boolean withLoads;
64+
65+
@Column(name = "withShuntCompensators", columnDefinition = "boolean default false")
66+
private boolean withShuntCompensators;
67+
68+
@Column(name = "withVscConverterStations", columnDefinition = "boolean default true")
69+
private boolean withVscConverterStations;
70+
71+
@Column(name = "withNeutralPosition", columnDefinition = "boolean default true")
72+
private boolean withNeutralPosition;
73+
74+
@Column(name = "initialVoltageProfileMode")
75+
@Enumerated(EnumType.STRING)
76+
private InitialVoltageProfileMode initialVoltageProfileMode;
77+
}

src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitService.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import com.fasterxml.jackson.databind.ObjectMapper;
1010
import com.powsybl.security.LimitViolationType;
11+
import com.powsybl.shortcircuit.InitialVoltageProfileMode;
12+
import com.powsybl.shortcircuit.ShortCircuitParameters;
13+
import com.powsybl.shortcircuit.StudyType;
14+
import com.powsybl.shortcircuit.VoltageRange;
1115
import com.powsybl.ws.commons.LogUtils;
1216
import com.univocity.parsers.csv.CsvWriter;
1317
import com.univocity.parsers.csv.CsvWriterSettings;
@@ -42,6 +46,13 @@ public class ShortCircuitService {
4246

4347
private static final Logger LOGGER = LoggerFactory.getLogger(ShortCircuitService.class);
4448

49+
//TODO tmp migration
50+
private static final List<VoltageRange> CEI909_VOLTAGE_PROFILE = List.of(
51+
new VoltageRange(10.0, 199.99, 1.1),
52+
new VoltageRange(200.0, 299.99, 1.09),
53+
new VoltageRange(300.0, 500.0, 1.05)
54+
);
55+
4556
@Autowired
4657
NotificationService notificationService;
4758

@@ -113,6 +124,70 @@ private static FeederResult fromEntity(FeederResultEntity feederResultEntity) {
113124
return new FeederResult(feederResultEntity.getConnectableId(), feederResultEntity.getCurrent(), feederResultEntity.getPositiveMagnitude());
114125
}
115126

127+
//TODO tmp migration
128+
public static ShortCircuitParametersEntity toEntity(ShortCircuitParameters parameters, ShortCircuitPredefinedConfiguration shortCircuitPredefinedConfiguration) {
129+
Objects.requireNonNull(parameters);
130+
return new ShortCircuitParametersEntity(parameters.isWithLimitViolations(),
131+
parameters.isWithVoltageResult(),
132+
parameters.isWithFortescueResult(),
133+
parameters.isWithFeederResult(),
134+
parameters.getStudyType(),
135+
parameters.getMinVoltageDropProportionalThreshold(),
136+
parameters.isWithLoads(),
137+
parameters.isWithShuntCompensators(),
138+
parameters.isWithVSCConverterStations(),
139+
parameters.isWithNeutralPosition(),
140+
parameters.getInitialVoltageProfileMode(),
141+
shortCircuitPredefinedConfiguration);
142+
}
143+
144+
//TODO tmp migration
145+
public static ShortCircuitParameters fromEntity(ShortCircuitParametersEntity entity) {
146+
Objects.requireNonNull(entity);
147+
List<VoltageRange> voltageRanges = InitialVoltageProfileMode.CONFIGURED.equals(entity.getInitialVoltageProfileMode()) ? CEI909_VOLTAGE_PROFILE : null;
148+
return new ShortCircuitParameters()
149+
.setStudyType(entity.getStudyType())
150+
.setMinVoltageDropProportionalThreshold(entity.getMinVoltageDropProportionalThreshold())
151+
.setWithFeederResult(entity.isWithFeederResult())
152+
.setWithLimitViolations(entity.isWithLimitViolations())
153+
.setWithVoltageResult(entity.isWithVoltageResult())
154+
.setWithFortescueResult(entity.isWithFortescueResult())
155+
.setWithLoads(entity.isWithLoads())
156+
.setWithShuntCompensators(entity.isWithShuntCompensators())
157+
.setWithVSCConverterStations(entity.isWithVscConverterStations())
158+
.setWithNeutralPosition(entity.isWithNeutralPosition())
159+
.setInitialVoltageProfileMode(entity.getInitialVoltageProfileMode())
160+
.setVoltageRanges(voltageRanges);
161+
}
162+
163+
//TODO tmp migration
164+
public static ShortCircuitParameters getDefaultShortCircuitParameters() {
165+
return new ShortCircuitParameters()
166+
.setStudyType(StudyType.TRANSIENT)
167+
.setMinVoltageDropProportionalThreshold(20)
168+
.setWithFeederResult(true)
169+
.setWithLimitViolations(true)
170+
.setWithVoltageResult(false)
171+
.setWithFortescueResult(false)
172+
.setWithLoads(false)
173+
.setWithShuntCompensators(false)
174+
.setWithVSCConverterStations(true)
175+
.setWithNeutralPosition(true)
176+
// the voltageRanges is not taken into account when initialVoltageProfileMode=NOMINAL
177+
.setInitialVoltageProfileMode(InitialVoltageProfileMode.NOMINAL)
178+
.setVoltageRanges(null);
179+
}
180+
181+
//TODO tmp migration
182+
public static ShortCircuitParametersInfos toShortCircuitParametersInfo(ShortCircuitParametersEntity entity) {
183+
Objects.requireNonNull(entity);
184+
return ShortCircuitParametersInfos.builder()
185+
.predefinedParameters(entity.getPredefinedParameters())
186+
.parameters(fromEntity(entity))
187+
.cei909VoltageRanges(CEI909_VOLTAGE_PROFILE)
188+
.build();
189+
}
190+
116191
private static ShortCircuitAnalysisResultEntity sortByElementId(ShortCircuitAnalysisResultEntity result) {
117192
result.setFaultResults(result.getFaultResults().stream()
118193
.sorted(Comparator.comparing(fr -> fr.getFault().getElementId()))

0 commit comments

Comments
 (0)