|
30 | 30 | import com.powsybl.openrao.data.crac.api.usagerule.OnContingencyState; |
31 | 31 | import com.powsybl.openrao.data.crac.api.usagerule.OnFlowConstraintInCountry; |
32 | 32 | import com.powsybl.openrao.data.crac.api.usagerule.OnInstant; |
| 33 | +import com.powsybl.openrao.data.crac.api.usagerule.UsageRule; |
33 | 34 | import com.powsybl.openrao.data.crac.io.cim.parameters.CimCracCreationParameters; |
34 | 35 | import com.powsybl.openrao.data.crac.io.cim.parameters.RangeActionSpeed; |
35 | 36 | import com.powsybl.openrao.data.crac.io.cim.parameters.VoltageCnecsCreationParameters; |
@@ -1237,4 +1238,83 @@ void testImportHvdcAutomatonWithPartiallyConnectedHvdc2AndInvalidContingencies() |
1237 | 1238 | assert cracCreationContext.getCreationReport().getReport().contains("[ALTERED] RemedialAction_Series \"HVDC-direction12\" was modified: HVDC line BBE2AA12 FFR3AA12 1 has terminals 1 and 2 disconnected; Contingencies Co-2 were not imported. "); |
1238 | 1239 | assert cracCreationContext.getCreationReport().getReport().contains("[ALTERED] RemedialAction_Series \"HVDC-direction11\" was modified: HVDC line BBE2AA12 FFR3AA12 1 has terminals 1 and 2 disconnected; Contingencies Co-2 were not imported. "); |
1239 | 1240 | } |
| 1241 | + |
| 1242 | + @Test |
| 1243 | + void importCimCracWithPreventiveHvdcRa() throws IOException { |
| 1244 | + Network network = loadNetworkWithHvdc(); |
| 1245 | + setUpWithSpeed("/cracs/CIM_with_preventive_HVDC.xml", network, OffsetDateTime.parse("2021-04-01T23:00Z"), Set.of(new RangeActionSpeed("BBE2AA11 FFR3AA11 1", 1), new RangeActionSpeed("BBE2AA12 FFR3AA12 1", 2))); |
| 1246 | + Crac crac = cracCreationContext.getCrac(); |
| 1247 | + |
| 1248 | + assertEquals(2, crac.getHvdcRangeActions().size()); |
| 1249 | + |
| 1250 | + HvdcRangeAction hvdcRangeAction1 = crac.getHvdcRangeAction("HVDC-direction11 + HVDC-direction12 - BBE2AA11 FFR3AA11 1"); |
| 1251 | + assertEquals(1, hvdcRangeAction1.getRanges().size()); |
| 1252 | + assertEquals(-4000, hvdcRangeAction1.getRanges().iterator().next().getMin()); |
| 1253 | + assertEquals(5000, hvdcRangeAction1.getRanges().iterator().next().getMax()); |
| 1254 | + assertEquals(Optional.of("BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1"), hvdcRangeAction1.getGroupId()); |
| 1255 | + assertEquals(1, hvdcRangeAction1.getUsageRules().size()); |
| 1256 | + assertEquals("preventive", hvdcRangeAction1.getUsageRules().iterator().next().getInstant().getId()); |
| 1257 | + |
| 1258 | + HvdcRangeAction hvdcRangeAction2 = crac.getHvdcRangeAction("HVDC-direction11 + HVDC-direction12 - BBE2AA12 FFR3AA12 1"); |
| 1259 | + assertEquals(1, hvdcRangeAction2.getRanges().size()); |
| 1260 | + assertEquals(-3000, hvdcRangeAction2.getRanges().iterator().next().getMin()); |
| 1261 | + assertEquals(3500, hvdcRangeAction2.getRanges().iterator().next().getMax()); |
| 1262 | + assertEquals(Optional.of("BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1"), hvdcRangeAction2.getGroupId()); |
| 1263 | + assertEquals(1, hvdcRangeAction2.getUsageRules().size()); |
| 1264 | + assertEquals("preventive", hvdcRangeAction2.getUsageRules().iterator().next().getInstant().getId()); |
| 1265 | + } |
| 1266 | + |
| 1267 | + @Test |
| 1268 | + void importCimCracWithCurativeHvdcRa() throws IOException { |
| 1269 | + Network network = loadNetworkWithHvdc(); |
| 1270 | + setUpWithSpeed("/cracs/CIM_with_curative_HVDC.xml", network, OffsetDateTime.parse("2021-04-01T23:00Z"), Set.of(new RangeActionSpeed("BBE2AA11 FFR3AA11 1", 1), new RangeActionSpeed("BBE2AA12 FFR3AA12 1", 2))); |
| 1271 | + Crac crac = cracCreationContext.getCrac(); |
| 1272 | + |
| 1273 | + assertEquals(2, crac.getHvdcRangeActions().size()); |
| 1274 | + |
| 1275 | + HvdcRangeAction hvdcRangeAction1 = crac.getHvdcRangeAction("HVDC-direction11 + HVDC-direction12 - BBE2AA11 FFR3AA11 1"); |
| 1276 | + assertEquals(1, hvdcRangeAction1.getRanges().size()); |
| 1277 | + assertEquals(-4000, hvdcRangeAction1.getRanges().iterator().next().getMin()); |
| 1278 | + assertEquals(5000, hvdcRangeAction1.getRanges().iterator().next().getMax()); |
| 1279 | + assertEquals(Optional.of("BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1"), hvdcRangeAction1.getGroupId()); |
| 1280 | + assertEquals(1, hvdcRangeAction1.getUsageRules().size()); |
| 1281 | + assertEquals("curative", hvdcRangeAction1.getUsageRules().iterator().next().getInstant().getId()); |
| 1282 | + |
| 1283 | + HvdcRangeAction hvdcRangeAction2 = crac.getHvdcRangeAction("HVDC-direction11 + HVDC-direction12 - BBE2AA12 FFR3AA12 1"); |
| 1284 | + assertEquals(1, hvdcRangeAction2.getRanges().size()); |
| 1285 | + assertEquals(-3000, hvdcRangeAction2.getRanges().iterator().next().getMin()); |
| 1286 | + assertEquals(3500, hvdcRangeAction2.getRanges().iterator().next().getMax()); |
| 1287 | + assertEquals(Optional.of("BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1"), hvdcRangeAction2.getGroupId()); |
| 1288 | + assertEquals(1, hvdcRangeAction2.getUsageRules().size()); |
| 1289 | + assertEquals("curative", hvdcRangeAction2.getUsageRules().iterator().next().getInstant().getId()); |
| 1290 | + } |
| 1291 | + |
| 1292 | + @Test |
| 1293 | + void importCimCracWithPreventiveAndCurativeHvdcRa() throws IOException { |
| 1294 | + Network network = loadNetworkWithHvdc(); |
| 1295 | + setUpWithSpeed("/cracs/CIM_with_preventive_and_curative_HVDC.xml", network, OffsetDateTime.parse("2021-04-01T23:00Z"), Set.of(new RangeActionSpeed("BBE2AA11 FFR3AA11 1", 1), new RangeActionSpeed("BBE2AA12 FFR3AA12 1", 2))); |
| 1296 | + Crac crac = cracCreationContext.getCrac(); |
| 1297 | + |
| 1298 | + assertEquals(2, crac.getHvdcRangeActions().size()); |
| 1299 | + |
| 1300 | + HvdcRangeAction hvdcRangeAction1 = crac.getHvdcRangeAction("HVDC-direction11 + HVDC-direction12 - BBE2AA11 FFR3AA11 1"); |
| 1301 | + assertEquals(1, hvdcRangeAction1.getRanges().size()); |
| 1302 | + assertEquals(-4000, hvdcRangeAction1.getRanges().iterator().next().getMin()); |
| 1303 | + assertEquals(5000, hvdcRangeAction1.getRanges().iterator().next().getMax()); |
| 1304 | + assertEquals(Optional.of("BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1"), hvdcRangeAction1.getGroupId()); |
| 1305 | + List<UsageRule> usageRules1 = hvdcRangeAction1.getUsageRules().stream().sorted(Comparator.comparing(ur -> ur.getInstant().getId())).toList(); |
| 1306 | + assertEquals(2, usageRules1.size()); |
| 1307 | + assertEquals("curative", usageRules1.getFirst().getInstant().getId()); |
| 1308 | + assertEquals("preventive", usageRules1.getLast().getInstant().getId()); |
| 1309 | + |
| 1310 | + HvdcRangeAction hvdcRangeAction2 = crac.getHvdcRangeAction("HVDC-direction11 + HVDC-direction12 - BBE2AA12 FFR3AA12 1"); |
| 1311 | + assertEquals(1, hvdcRangeAction2.getRanges().size()); |
| 1312 | + assertEquals(-3000, hvdcRangeAction2.getRanges().iterator().next().getMin()); |
| 1313 | + assertEquals(3500, hvdcRangeAction2.getRanges().iterator().next().getMax()); |
| 1314 | + assertEquals(Optional.of("BBE2AA11 FFR3AA11 1 + BBE2AA12 FFR3AA12 1"), hvdcRangeAction2.getGroupId()); |
| 1315 | + List<UsageRule> usageRules2 = hvdcRangeAction2.getUsageRules().stream().sorted(Comparator.comparing(ur -> ur.getInstant().getId())).toList(); |
| 1316 | + assertEquals(2, usageRules2.size()); |
| 1317 | + assertEquals("curative", usageRules2.getFirst().getInstant().getId()); |
| 1318 | + assertEquals("preventive", usageRules2.getLast().getInstant().getId()); |
| 1319 | + } |
1240 | 1320 | } |
0 commit comments