Skip to content

Commit

Permalink
control area net interchange tolerance is optional, no default value …
Browse files Browse the repository at this point in the history
…is used

Signed-off-by: Luma <[email protected]>
  • Loading branch information
zamarrenolm committed Dec 16, 2024
1 parent 4f9d471 commit d264397
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ public void convert() {
.setName(p.getLocal("name"))
.setInterchangeTarget(p.asDouble("netInterchange", Double.NaN))
.add();
String pTolerance = "0";
if (p.containsKey(CgmesNames.P_TOLERANCE)) {
pTolerance = p.get(CgmesNames.P_TOLERANCE);
String pTolerance = p.get(CgmesNames.P_TOLERANCE);
area.setProperty(CgmesNames.P_TOLERANCE, pTolerance);
}
area.setProperty(CgmesNames.P_TOLERANCE, pTolerance);
if (p.containsKey(CgmesNames.ENERGY_IDENT_CODE_EIC)) {
area.addAlias(p.get(CgmesNames.ENERGY_IDENT_CODE_EIC), CgmesNames.ENERGY_IDENT_CODE_EIC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,9 @@ private static void writeControlArea(Area controlArea, String cimNamespace, XMLS
double pTolerance;
if (controlArea.hasProperty("pTolerance")) {
pTolerance = Double.parseDouble(controlArea.getProperty("pTolerance"));
} else {
pTolerance = Math.abs(0.01 * netInterchange);
writer.writeStartElement(cimNamespace, "ControlArea.pTolerance");
writer.writeCharacters(CgmesExportUtil.format(pTolerance));
}
writer.writeStartElement(cimNamespace, "ControlArea.pTolerance");
writer.writeCharacters(CgmesExportUtil.format(pTolerance));
writer.writeEndElement();
writer.writeEndElement();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,30 @@ void networkWithoutControlAreaInterchange() throws IOException {
new CgmesExport().createDefaultControlAreaInterchange(network);

// Check that exported files now have a control area definition
// No default value for tolerance
Path tmpDirWithCA = tmpDir.resolve("network-with-ca");
Files.createDirectories(tmpDirWithCA);
network.write("CGMES", null, tmpDirWithCA.resolve(baseName));
Network networkWithCA = Network.read(new GenericReadOnlyDataSource(tmpDirWithCA, baseName));
assertEquals(1, networkWithCA.getAreaCount());
assertEquals(1, networkWithCA.getAreas().iterator().next().getAreaBoundaryStream().count());
Area areaExported = networkWithCA.getAreas().iterator().next();
assertEquals(1, areaExported.getAreaBoundaryStream().count());
assertEquals(-50, areaExported.getInterchangeTarget().orElse(Double.NaN));
// No default value for tolerance
assertNull(areaExported.getProperty(CgmesNames.P_TOLERANCE));

// Check that tolerance is exported only if explicitly defined
Area area = network.getAreas().iterator().next();
area.setProperty(CgmesNames.P_TOLERANCE, "1.01");
Path tmpDirWithCaTolerance = tmpDir.resolve("network-with-ca-tolerance");
Files.createDirectories(tmpDirWithCaTolerance);
network.write("CGMES", null, tmpDirWithCaTolerance.resolve(baseName));
Network networkWithCaTolerance = Network.read(new GenericReadOnlyDataSource(tmpDirWithCaTolerance, baseName));
assertEquals(1, networkWithCaTolerance.getAreaCount());
areaExported = networkWithCaTolerance.getAreas().iterator().next();
assertEquals(1, areaExported.getAreaBoundaryStream().count());
assertEquals(-50, areaExported.getInterchangeTarget().orElse(Double.NaN));
assertEquals("1.01", areaExported.getProperty(CgmesNames.P_TOLERANCE));
}
}

Expand Down

0 comments on commit d264397

Please sign in to comment.