Skip to content

Commit

Permalink
Merge branch 'main' into features/InterTemporalSensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
bqth29 authored Jan 6, 2025
2 parents ec84aac + c1301c6 commit e6b0dbb
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ String getBaseCaseCnecId() {
return null;
}

boolean nullSafeIsMnec() {
/*
* In case of absence of element MNEC in XML input (as it is optional), no default value is set.
* An absence of MNEC element is equivalent to the critical branch to be considered as non MNEC
*/
return Optional.ofNullable(criticalBranch.isMNEC()).orElse(false);
}

String getOutageCnecId() {
if (!isBaseCase) {
return criticalBranch.getId().concat(" - ").concat("outage");
Expand Down Expand Up @@ -145,7 +153,7 @@ private void interpretWithNetwork(UcteNetworkAnalyzer ucteNetworkAnalyzer) {
}
}

if (!criticalBranch.isCNEC() && !criticalBranch.isMNEC()) {
if (!criticalBranch.isCNEC() && !nullSafeIsMnec()) {
this.importStatus = ImportStatus.NOT_FOR_RAO;
this.importStatusDetail = String.format("critical branch %s was removed as it is neither a CNEC, nor a MNEC", criticalBranch.getId());
return;
Expand Down Expand Up @@ -192,7 +200,7 @@ private FlowCnecAdder createCnecAdder(Crac crac, String instantId) {
.withInstant(instantId)
.withReliabilityMargin(criticalBranch.getFrmMw())
.withOperator(criticalBranch.getTsoOrigin())
.withMonitored(criticalBranch.isMNEC())
.withMonitored(nullSafeIsMnec())
.withOptimized(criticalBranch.isCNEC())
.withIMax(ucteFlowElementHelper.getCurrentLimit(TwoSides.ONE), TwoSides.ONE)
.withIMax(ucteFlowElementHelper.getCurrentLimit(TwoSides.TWO), TwoSides.TWO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ void importMnecs() throws IOException {
assertCriticalBranchNotImported("BE_CBCO_000004", ImportStatus.NOT_FOR_RAO);
}

@Test
void importWithoutMnecs() throws IOException {
Network network = Network.read("TestCase12Nodes_with_Xnodes.uct", getClass().getResourceAsStream("/network/TestCase12Nodes_with_Xnodes.uct"));
OffsetDateTime timestamp = OffsetDateTime.parse("2019-01-08T00:30Z");
creationContext = (FbConstraintCreationContext) Crac.readWithContext("no_MNEC_test.xml", getClass().getResourceAsStream("/merged_cb/no_MNEC_test.xml"), network, timestamp, parameters);
Crac crac = creationContext.getCrac();

assertEquals(1, crac.getFlowCnecs().size());
assertTrue(crac.getFlowCnec("BE_CBCO_000001 - preventive").isOptimized());
assertFalse(crac.getFlowCnec("BE_CBCO_000001 - preventive").isMonitored());

assertCriticalBranchNotImported("BE_CBCO_000002", ImportStatus.NOT_FOR_RAO);
}

private void assertHasThresholds(FlowCnec cnec, Set<TwoSides> monitoredSides, Unit unit, Double min, Double max) {
assertEquals(monitoredSides.size(), cnec.getThresholds().size());
monitoredSides.forEach(side -> assertTrue(cnec.getThresholds().stream().anyMatch(branchThreshold -> branchThreshold.getSide().equals(side))));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version='1.0' encoding='UTF-8'?>
<FlowBasedConstraintDocument DtdRelease="4" DtdVersion="0" xmlns="flowbased" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="flowbasedconstraintdocument-23.xsd">
<DocumentIdentification v="17XTSO-CS------W-20190108-F301v1"/>
<DocumentVersion v="1"/>
<DocumentType v="B06"/>
<ProcessType v="A01"/>
<SenderIdentification codingScheme="A01" v="17XTSO-CS------W"/>
<SenderRole v="A36"/>
<ReceiverIdentification codingScheme="A01" v="22XCORESO------S"/>
<ReceiverRole v="A44"/>
<CreationDateTime v="2019-08-15T14:07:28Z"/>
<ConstraintTimeInterval v="2019-01-07T23:00Z/2019-01-08T23:00Z"/>
<Domain codingScheme="A01" v="10Y1001C--00059P"/>
<criticalBranches>
<criticalBranch id="BE_CBCO_000001">
<timeInterval v="2019-01-07T23:00Z/2019-01-08T23:00Z"/>
<branch eic="1234567890123450" from="BBE1AA1 " name="[BE-BE] BBE1 - BBE2 [DIR]" order="1" to="BBE2AA1 "/>
<imaxFactor>1</imaxFactor>
<imaxType>SEASONAL</imaxType>
<permanentImaxFactor>1</permanentImaxFactor>
<temporaryImaxFactor>1</temporaryImaxFactor>
<frmMw>138</frmMw>
<minRAMfactor>70</minRAMfactor>
<CNEC>true</CNEC>
<direction>DIRECT</direction>
<tsoOrigin>BE</tsoOrigin>
</criticalBranch>
<criticalBranch id="BE_CBCO_000002">
<timeInterval v="2019-01-07T23:00Z/2019-01-08T23:00Z"/>
<branch eic="1234567890123450" from="BBE1AA1 " name="[BE-BE] BBE1 - BBE2 [DIR]" order="1" to="BBE2AA1 "/>
<imaxFactor>1</imaxFactor>
<imaxType>SEASONAL</imaxType>
<permanentImaxFactor>1</permanentImaxFactor>
<temporaryImaxFactor>1</temporaryImaxFactor>
<frmMw>138</frmMw>
<minRAMfactor>70</minRAMfactor>
<CNEC>false</CNEC>
<direction>DIRECT</direction>
<tsoOrigin>BE</tsoOrigin>
</criticalBranch>
</criticalBranches>
</FlowBasedConstraintDocument>

0 comments on commit e6b0dbb

Please sign in to comment.