|
8 | 8 |
|
9 | 9 | import com.fasterxml.jackson.databind.ObjectMapper;
|
10 | 10 | 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; |
11 | 15 | import com.powsybl.ws.commons.LogUtils;
|
12 | 16 | import com.univocity.parsers.csv.CsvWriter;
|
13 | 17 | import com.univocity.parsers.csv.CsvWriterSettings;
|
@@ -42,6 +46,13 @@ public class ShortCircuitService {
|
42 | 46 |
|
43 | 47 | private static final Logger LOGGER = LoggerFactory.getLogger(ShortCircuitService.class);
|
44 | 48 |
|
| 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 | + |
45 | 56 | @Autowired
|
46 | 57 | NotificationService notificationService;
|
47 | 58 |
|
@@ -113,6 +124,70 @@ private static FeederResult fromEntity(FeederResultEntity feederResultEntity) {
|
113 | 124 | return new FeederResult(feederResultEntity.getConnectableId(), feederResultEntity.getCurrent(), feederResultEntity.getPositiveMagnitude());
|
114 | 125 | }
|
115 | 126 |
|
| 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 | + |
116 | 191 | private static ShortCircuitAnalysisResultEntity sortByElementId(ShortCircuitAnalysisResultEntity result) {
|
117 | 192 | result.setFaultResults(result.getFaultResults().stream()
|
118 | 193 | .sorted(Comparator.comparing(fr -> fr.getFault().getElementId()))
|
|
0 commit comments