Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGMES: remove extension for Control Areas, use IIDM Area #3149

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,8 @@ public Network convert(ReportNode reportNode) {
voltageAngles(nodes, context);

if (config.importControlAreas()) {
network.newExtension(CgmesControlAreasAdder.class).add();
CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class);
cgmes.controlAreas().forEach(ca -> createControlArea(cgmesControlAreas, ca));
cgmes.tieFlows().forEach(tf -> addTieFlow(context, cgmesControlAreas, tf));
cgmesControlAreas.cleanIfEmpty();
cgmes.controlAreas().forEach(ca -> createControlArea(context, ca));
cgmes.tieFlows().forEach(tf -> addTieFlow(context, tf));
}

// set all regulating controls
Expand Down Expand Up @@ -351,31 +348,37 @@ private static void completeVoltagesAndAngles(Network network) {
network.getTieLines().forEach(tieLine -> AbstractConductingEquipmentConversion.calculateVoltageAndAngleInBoundaryBus(tieLine.getDanglingLine1(), tieLine.getDanglingLine2()));
}

private static void createControlArea(CgmesControlAreas cgmesControlAreas, PropertyBag ca) {
private static void createControlArea(Context context, PropertyBag ca) {
String controlAreaId = ca.getId("ControlArea");
cgmesControlAreas.newCgmesControlArea()
String type = ca.getLocal("controlAreaType");
Area area = context.network().newArea()
.setAreaType(type) // Copy the type defined by CGMES
.setId(controlAreaId)
.setName(ca.getLocal("name"))
.setEnergyIdentificationCodeEic(ca.getLocal("energyIdentCodeEic"))
.setNetInterchange(ca.asDouble("netInterchange", Double.NaN))
.setPTolerance(ca.asDouble("pTolerance", Double.NaN))
.setInterchangeTarget(ca.asDouble("netInterchange", Double.NaN))
.add();
if (ca.containsKey("pTolerance")) {
area.setProperty("tolerance", ca.get("pTolerance"));
}
if (ca.containsKey("energyIdentCodeEic")) {
area.addAlias(ca.get("energyIdentCodeEic"), "energyIdentificationCodeEic");
}
}

private static void addTieFlow(Context context, CgmesControlAreas cgmesControlAreas, PropertyBag tf) {
private static void addTieFlow(Context context, PropertyBag tf) {
String controlAreaId = tf.getId("ControlArea");
CgmesControlArea cgmesControlArea = cgmesControlAreas.getCgmesControlArea(controlAreaId);
if (cgmesControlArea == null) {
Area area = context.network().getArea(controlAreaId);
if (area == null) {
context.ignored("Tie Flow", String.format("Tie Flow %s refers to a non-existing control area", tf.getId("TieFlow")));
return;
}
String terminalId = tf.getId("terminal");
Boundary boundary = context.terminalMapping().findBoundary(terminalId, context.cgmes());
if (boundary != null) {
cgmesControlArea.add(boundary);
area.newAreaBoundary().setBoundary(boundary).add();
return;
}
RegulatingTerminalMapper.mapForTieFlow(terminalId, context).ifPresent(cgmesControlArea::add);
RegulatingTerminalMapper.mapForTieFlow(terminalId, context).ifPresent(t -> area.newAreaBoundary().setTerminal(t).add());
}

private void convert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ private void addIidmMappingsEquivalentInjection(Network network) {
}

private void addIidmMappingsControlArea(Network network) {
// FIXME(Luma) remove this use of CgmesControlAreas
CgmesControlAreas cgmesControlAreas = network.getExtension(CgmesControlAreas.class);
if (cgmesControlAreas == null) {
network.newExtension(CgmesControlAreasAdder.class).add();
Expand Down
Loading