Skip to content

Commit

Permalink
Fix CIM Angle CNEC creation (#1010)
Browse files Browse the repository at this point in the history
* Fix CIM Angle CNEC creation

Signed-off-by: Peter Mitri <[email protected]
  • Loading branch information
pet-mit authored May 24, 2024
1 parent 1a2ac67 commit bcdb8af
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public AngleCnec createAndAddAdditionalConstraintSeries() {
.withMonitored()
.withOptimized(false)
.withReliabilityMargin(0.)
.newThreshold().withUnit(Unit.DEGREE).withMax(additionalConstraintSerie.getQuantityQuantity().doubleValue())
.withMin(-additionalConstraintSerie.getQuantityQuantity().doubleValue()).add()
.newThreshold().withUnit(Unit.DEGREE).withMax(additionalConstraintSerie.getQuantityQuantity().doubleValue()).add()
.withInstant(crac.getInstant(InstantKind.CURATIVE).getId())
.withContingency(contingencyId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private void assertCnecImported(String monitoredSeriesId, Set<String> expectedCn
assertEquals(expectedCnecIds, importedCnecIds);
}

private void assertAngleCnecImportedWithContingency(String id, String contingencyId, Set<String> networkElementIds) {
private void assertAngleCnecImportedWithContingency(String id, String contingencyId, Set<String> networkElementIds, double max) {
AngleCnecCreationContext angleCnecCreationContext = cracCreationContext.getAngleCnecCreationContext(id);
assertNotNull(angleCnecCreationContext);
assertTrue(angleCnecCreationContext.isImported());
Expand All @@ -216,6 +216,9 @@ private void assertAngleCnecImportedWithContingency(String id, String contingenc
importedAngleCnecNetworkElements.add(importedCrac.getAngleCnec(id).getExportingNetworkElement().toString());
assertEquals(networkElementIds, importedAngleCnecNetworkElements);
assertEquals(contingencyId, angleCnecCreationContext.getContingencyId());
assertEquals(1, importedCrac.getAngleCnec(id).getThresholds().size());
assertEquals(max, importedCrac.getAngleCnec(id).getThresholds().iterator().next().max().orElseThrow());
assertTrue(importedCrac.getAngleCnec(id).getThresholds().iterator().next().min().isEmpty());
}

private void assertAngleCnecNotImported(String id, ImportStatus importStatus) {
Expand Down Expand Up @@ -795,15 +798,15 @@ void testImportAngleCnecs() {
setUp("/cracs/CIM_21_7_1.xml", baseNetwork, OffsetDateTime.parse("2021-04-01T23:00Z"), new CracCreationParameters());
// -- Imported
// Angle cnec and associated RA imported :
assertAngleCnecImportedWithContingency("AngleCnec1", "Co-1", Set.of("_8d8a82ba-b5b0-4e94-861a-192af055f2b8", "_b7998ae6-0cc6-4dfe-8fec-0b549b07b6c3"));
assertAngleCnecImportedWithContingency("AngleCnec1", "Co-1", Set.of("_8d8a82ba-b5b0-4e94-861a-192af055f2b8", "_b7998ae6-0cc6-4dfe-8fec-0b549b07b6c3"), 30.);
assertNetworkActionImported("RA1", Set.of("_1dc9afba-23b5-41a0-8540-b479ed8baf4b", "_2844585c-0d35-488d-a449-685bcd57afbf"), false);
assertHasOnAngleUsageRule("RA1", "AngleCnec1");
assertEquals(1, importedCrac.getRemedialAction("RA1").getUsageRules().size());
// -- Partially imported
// Angle cnec without an associated RA :
assertAngleCnecImportedWithContingency("AngleCnec3", "Co-1", Set.of("_8d8a82ba-b5b0-4e94-861a-192af055f2b8", "_b7998ae6-0cc6-4dfe-8fec-0b549b07b6c3"));
assertAngleCnecImportedWithContingency("AngleCnec3", "Co-1", Set.of("_8d8a82ba-b5b0-4e94-861a-192af055f2b8", "_b7998ae6-0cc6-4dfe-8fec-0b549b07b6c3"), 40.);
// Angle cnec with ill defined RA :
assertAngleCnecImportedWithContingency("AngleCnec11", "Co-1", Set.of("_8d8a82ba-b5b0-4e94-861a-192af055f2b8", "_b7998ae6-0cc6-4dfe-8fec-0b549b07b6c3"));
assertAngleCnecImportedWithContingency("AngleCnec11", "Co-1", Set.of("_8d8a82ba-b5b0-4e94-861a-192af055f2b8", "_b7998ae6-0cc6-4dfe-8fec-0b549b07b6c3"), 60.);
assertRemedialActionNotImported("RA11", ELEMENT_NOT_FOUND_IN_NETWORK);

// -- Not imported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
<businessType>B87</businessType>
<name>AngleCnec3-name</name>
<measurement_Unit.name>DD</measurement_Unit.name>
<quantity.quantity>30</quantity.quantity>
<quantity.quantity>40</quantity.quantity>
<RegisteredResource>
<mRID codingScheme="A02">_8d8a82ba-b5b0-4e94-861a-192af055f2b8</mRID>
<name>rr1</name>
Expand Down Expand Up @@ -662,7 +662,7 @@
<businessType>B87</businessType>
<name>AngleCnec11-name</name>
<measurement_Unit.name>DD</measurement_Unit.name>
<quantity.quantity>30</quantity.quantity>
<quantity.quantity>60</quantity.quantity>
<RegisteredResource>
<mRID codingScheme="A02">_8d8a82ba-b5b0-4e94-861a-192af055f2b8</mRID>
<name>rr1</name>
Expand Down
5 changes: 4 additions & 1 deletion docs/input-data/crac/cim.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ Finally, a CNEC can be named in the following way : _[network element name] - [s
</RemedialAction_Series>
</Series>
```
AngleCnecs are easily distinguishable thanks to the AdditionalConstraint_Series tag. They define an AngleCnec in curative with an importing element, an exporting element (cf. the two registered resources) and with a threshold with a max bound defined by quantity.
AngleCnecs are easily distinguishable thanks to the AdditionalConstraint_Series tag.
They define an AngleCnec in curative with an importing element, an exporting element (cf. the two registered resources)
and with a threshold with a max bound defined by quantity. In order to be secure, they must respect:
exporting element angle - importing element angle <= max bound
In the CIM CRAC, AngleCnecs are actually defined with their corresponding remedial actions in B56 Series (ie Remedial Action series). The Contingency_Series (unique) refers to the contingency after which the AngleCnec is monitored.

### VoltageCnecs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Feature: US 21.7 : import angle cnecs
When I import crac at "2021-04-02 05:00"
Then it should have the following angle CNECs:
| AngleCnecId | Name | ImportingElementId | ExportingElementId | Instant | Contingency | Optimized | Monitored | UpperBound | LowerBound |
| AngleCnec1 | AngleCnec1-name | _d77b61ef-61aa-4b22-95f6-b56ca080788d | _8d8a82ba-b5b0-4e94-861a-192af055f2b8 | CURATIVE | Co-1 | no | yes | 30 | -30 |
| AngleCnec2 | AngleCnec2-name | _8d8a82ba-b5b0-4e94-861a-192af055f2b8 | _b7998ae6-0cc6-4dfe-8fec-0b549b07b6c3 | CURATIVE | Co-2 | no | yes | -47 | 47 |
| AngleCnec1 | AngleCnec1-name | _d77b61ef-61aa-4b22-95f6-b56ca080788d | _8d8a82ba-b5b0-4e94-861a-192af055f2b8 | CURATIVE | Co-1 | no | yes | 30 | |
| AngleCnec2 | AngleCnec2-name | _8d8a82ba-b5b0-4e94-861a-192af055f2b8 | _b7998ae6-0cc6-4dfe-8fec-0b549b07b6c3 | CURATIVE | Co-2 | no | yes | -47 | |
And it should have 1 network actions
And it should have the following network actions:
| NetworkActionId | NetworkActionName | ElementaryActions | ElementaryActionType | NetworkElementId | Action/Setpoint |
Expand Down

0 comments on commit bcdb8af

Please sign in to comment.