Skip to content

Commit

Permalink
CGMES: Fix equivalent injection missing regulation target (#3087)
Browse files Browse the repository at this point in the history
* fix equivalent injection missing regulation target

Signed-off-by: Luma <[email protected]>
(cherry picked from commit e0c78c2)
  • Loading branch information
zamarrenolm authored and olperr1 committed Jul 1, 2024
1 parent d8c994d commit a255882
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,9 @@ private Regulation getRegulation() {
regulation.targetV = Double.NaN;
if (regulation.status) {
regulation.targetV = p.asDouble(REGULATION_TARGET);
if (regulation.targetV == 0) {
fixed(REGULATION_TARGET, "Target voltage value can not be zero", regulation.targetV,
voltageLevel().getNominalV());
regulation.targetV = voltageLevel().getNominalV();
if (Double.isNaN(regulation.targetV) || regulation.targetV == 0) {
missing("Valid target voltage value (voltage regulation is considered as off)");
regulation.status = false;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/

package com.powsybl.cgmes.conversion.test;

import com.powsybl.commons.datasource.ResourceDataSource;
import com.powsybl.commons.datasource.ResourceSet;
import com.powsybl.commons.test.AbstractSerDeTest;
import com.powsybl.iidm.network.DanglingLine;
import com.powsybl.iidm.network.Network;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* @author Luma Zamarreño {@literal <zamarrenolm at aia.es>}
*/

class EquivalentInjectionImportTest extends AbstractSerDeTest {

@Test
void equivalentInjectionWithRegulationTargetTest() {
String basename = "ei_regulation";
Network network = Network.read(new ResourceDataSource(basename,
new ResourceSet("/issues",
"ei_regulation_EQ.xml",
"ei_regulation_with_target_SSH.xml",
"ei_regulation_EQ_BD.xml")));
DanglingLine dl = network.getDanglingLine("ACLS1");
assertEquals(401, dl.getGeneration().getTargetV());
assertTrue(dl.getGeneration().isVoltageRegulationOn());
}

@Test
void equivalentInjectionMissingRegulationTargetTest() {
String basename = "ei_regulation";
Network network = Network.read(new ResourceDataSource(basename,
new ResourceSet("/issues",
"ei_regulation_EQ.xml",
"ei_regulation_missing_target_SSH.xml",
"ei_regulation_EQ_BD.xml")));
DanglingLine dl = network.getDanglingLine("ACLS1");
// No generation data has been created for the dangling line
assertNull(dl.getGeneration());
}

@Test
void equivalentInjectionWithRegulationTargetZeroTest() {
String basename = "ei_regulation";
Network network = Network.read(new ResourceDataSource(basename,
new ResourceSet("/issues",
"ei_regulation_EQ.xml",
"ei_regulation_with_target_zero_SSH.xml",
"ei_regulation_EQ_BD.xml")));
DanglingLine dl = network.getDanglingLine("ACLS1");
// Zero is an invalid value, no generation data has been created for the dangling line
assertNull(dl.getGeneration());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<rdf:RDF xmlns:cim="http://iec.ch/TC57/CIM100#" xmlns:md="http://iec.ch/TC57/61970-552/ModelDescription/1#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:eu="http://iec.ch/TC57/CIM100-European#">
<md:FullModel rdf:about="urn:uuid:d400c631-75a0-4c30-8aed-832b0d282e73">
<md:Model.created>2024-06-28T11:00:00Z</md:Model.created>
<md:Model.scenarioTime>2024-06-28T11:00:00Z</md:Model.scenarioTime>
<md:Model.version>1</md:Model.version>
<md:Model.description>Equivalent injection missing regulation target</md:Model.description>
<md:Model.modelingAuthoritySet>https://www.powsybl.org/</md:Model.modelingAuthoritySet>
<md:Model.profile>http://iec.ch/TC57/ns/CIM/CoreEquipment-EU/3.0</md:Model.profile>
</md:FullModel>

<cim:GeographicalRegion rdf:ID="_GeographicalRegionTest">
<cim:IdentifiedObject.mRID>GeographicalRegionTest</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>GeographicalRegionTest</cim:IdentifiedObject.name>
</cim:GeographicalRegion>
<cim:SubGeographicalRegion rdf:ID="_SubGeographicalRegionTest">
<cim:IdentifiedObject.mRID>SubGeographicalRegionTest</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>SubGeographicalRegionTest</cim:IdentifiedObject.name>
<cim:SubGeographicalRegion.Region rdf:resource="#_GeographicalRegionTest" />
</cim:SubGeographicalRegion>
<cim:Substation rdf:ID="_Substation1">
<cim:IdentifiedObject.mRID>Substation1</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>Substation1</cim:IdentifiedObject.name>
<cim:Substation.Region rdf:resource="#_SubGeographicalRegionTest" />
</cim:Substation>
<cim:VoltageLevel rdf:ID="_VoltageLevel1">
<cim:IdentifiedObject.mRID>VoltageLevel1</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>VoltageLevel1</cim:IdentifiedObject.name>
<cim:VoltageLevel.highVoltageLimit>420</cim:VoltageLevel.highVoltageLimit>
<cim:VoltageLevel.lowVoltageLimit>380</cim:VoltageLevel.lowVoltageLimit>
<cim:VoltageLevel.Substation rdf:resource="#_Substation1"/>
<cim:VoltageLevel.BaseVoltage rdf:resource="#_BaseVoltage400"/>
</cim:VoltageLevel>
<cim:ConnectivityNode rdf:ID="_ConnectivityNode1">
<cim:IdentifiedObject.mRID>ConnectivityNode1</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>Connectivity Node 1</cim:IdentifiedObject.name>
<cim:ConnectivityNode.ConnectivityNodeContainer rdf:resource="#_VoltageLevel1" />
</cim:ConnectivityNode>

<cim:ACLineSegment rdf:ID="_ACLS1">
<cim:IdentifiedObject.mRID>ACLS1</cim:IdentifiedObject.mRID>
<cim:ConductingEquipment.BaseVoltage rdf:resource="#_BaseVoltage400"/>
<cim:IdentifiedObject.name>ACLS1</cim:IdentifiedObject.name>
<cim:ACLineSegment.x>0.12</cim:ACLineSegment.x>
<cim:ACLineSegment.bch>0</cim:ACLineSegment.bch>
<cim:Conductor.length>0.3</cim:Conductor.length>
<cim:ACLineSegment.r>0.34</cim:ACLineSegment.r>
</cim:ACLineSegment>
<cim:Terminal rdf:ID="_ACLS1_T1">
<cim:IdentifiedObject.mRID>ACLS1_T1</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>ACLS1 Terminal 1</cim:IdentifiedObject.name>
<cim:ACDCTerminal.sequenceNumber>1</cim:ACDCTerminal.sequenceNumber>
<cim:Terminal.phases rdf:resource="http://iec.ch/TC57/CIM100#PhaseCode.ABC" />
<cim:Terminal.ConductingEquipment rdf:resource="#_ACLS1" />
<cim:Terminal.ConnectivityNode rdf:resource="#_ConnectivityNode1" />
</cim:Terminal>
<cim:Terminal rdf:ID="_ACLS1_T2">
<cim:IdentifiedObject.mRID>ACLS1_T2</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>ACLS1 Terminal 2</cim:IdentifiedObject.name>
<cim:ACDCTerminal.sequenceNumber>2</cim:ACDCTerminal.sequenceNumber>
<cim:Terminal.phases rdf:resource="http://iec.ch/TC57/CIM100#PhaseCode.ABC" />
<cim:Terminal.ConductingEquipment rdf:resource="#_ACLS1" />
<cim:Terminal.ConnectivityNode rdf:resource="#_ConnectivityNodeAtBoundary1" />
</cim:Terminal>

<cim:EquivalentInjection rdf:ID="_EI1">
<cim:IdentifiedObject.mRID>EI1</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>EI1</cim:IdentifiedObject.name>
<cim:ConductingEquipment.BaseVoltage rdf:resource="#_BaseVoltage400" />
<cim:Equipment.EquipmentContainer rdf:resource="#_LineContainerAtBoundary1" />
<cim:EquivalentInjection.r>0</cim:EquivalentInjection.r>
<cim:EquivalentInjection.x>0</cim:EquivalentInjection.x>
<cim:EquivalentInjection.regulationCapability>true</cim:EquivalentInjection.regulationCapability>
</cim:EquivalentInjection>
<cim:Terminal rdf:ID="_E1_T">
<cim:IdentifiedObject.mRID>EI1_T</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>EI1 Terminal</cim:IdentifiedObject.name>
<cim:ACDCTerminal.sequenceNumber>1</cim:ACDCTerminal.sequenceNumber>
<cim:Terminal.phases rdf:resource="http://iec.ch/TC57/CIM100#PhaseCode.ABC" />
<cim:Terminal.ConductingEquipment rdf:resource="#_EI1" />
<cim:Terminal.ConnectivityNode rdf:resource="#_ConnectivityNodeAtBoundary1" />
</cim:Terminal>

</rdf:RDF>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:cim="http://iec.ch/TC57/CIM100#" xmlns:eu="http://iec.ch/TC57/CIM100-European#" xmlns:md="http://iec.ch/TC57/61970-552/ModelDescription/1#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<md:FullModel rdf:about="urn:uuid:536f9bf1-3f8f-a546-87e3-7af2272f29b7">
<md:Model.created>2024-06-28T11:00:00Z</md:Model.created>
<md:Model.scenarioTime>2024-06-28T11:00:00Z</md:Model.scenarioTime>
<md:Model.version>1</md:Model.version>
<md:Model.description>Equivalent injection missing regulation target</md:Model.description>
<md:Model.profile>http://iec.ch/TC57/ns/CIM/EquipmentBoundary-EU/3.0</md:Model.profile>
<md:Model.modelingAuthoritySet>http://powsybl.org</md:Model.modelingAuthoritySet>
</md:FullModel>
<cim:BaseVoltage rdf:ID="_BaseVoltage400">
<cim:IdentifiedObject.mRID>BaseVoltage400</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.description>Base Voltage Level 400kV</cim:IdentifiedObject.description>
<cim:IdentifiedObject.name>400.0 kV</cim:IdentifiedObject.name>
<cim:BaseVoltage.nominalVoltage>400.0</cim:BaseVoltage.nominalVoltage>
</cim:BaseVoltage>
<cim:Line rdf:ID="_LineContainerAtBoundary1">
<cim:IdentifiedObject.name>LineContainerAtBoundary1</cim:IdentifiedObject.name>
<cim:IdentifiedObject.mRID>LineContainerAtBoundary1</cim:IdentifiedObject.mRID>
</cim:Line>
<cim:ConnectivityNode rdf:ID="_ConnectivityNodeAtBoundary1">
<cim:IdentifiedObject.mRID>ConnectivityNodeAtBoundary1</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>ConnectivityNodeAtBoundary1</cim:IdentifiedObject.name>
<cim:ConnectivityNode.ConnectivityNodeContainer rdf:resource="#_LineContainerAtBoundary1" />
</cim:ConnectivityNode>
<eu:BoundaryPoint rdf:ID="_BoundaryPoint1">
<cim:IdentifiedObject.mRID>BoundaryPoint1</cim:IdentifiedObject.mRID>
<cim:IdentifiedObject.name>BoundaryPoint1</cim:IdentifiedObject.name>
<eu:BoundaryPoint.ConnectivityNode rdf:resource="#_ConnectivityNodeAtBoundary1" />
</eu:BoundaryPoint>
</rdf:RDF>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<rdf:RDF xmlns:cim="http://iec.ch/TC57/CIM100#" xmlns:md="http://iec.ch/TC57/61970-552/ModelDescription/1#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:eu="http://iec.ch/TC57/CIM100-European#">
<md:FullModel rdf:about="urn:uuid:d400c631-75a0-4c30-8aed-832b0d282e73">
<md:Model.created>2024-06-28T11:00:00Z</md:Model.created>
<md:Model.scenarioTime>2024-06-28T11:00:00Z</md:Model.scenarioTime>
<md:Model.version>1</md:Model.version>
<md:Model.description>Equivalent injection missing regulation target</md:Model.description>
<md:Model.modelingAuthoritySet>https://www.powsybl.org/</md:Model.modelingAuthoritySet>
<md:Model.profile>http://iec.ch/TC57/ns/CIM/SteadyStateHypothesis-EU/3.0</md:Model.profile>
</md:FullModel>

<cim:EquivalentInjection rdf:about="#_EI1">
<cim:Equipment.inService>true</cim:Equipment.inService>
<cim:EquivalentInjection.p>-100</cim:EquivalentInjection.p>
<cim:EquivalentInjection.q>10</cim:EquivalentInjection.q>
<cim:EquivalentInjection.regulationStatus>true</cim:EquivalentInjection.regulationStatus>
<!-- regulation status is true, but no regulation target is provided -->
</cim:EquivalentInjection>
</rdf:RDF>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<rdf:RDF xmlns:cim="http://iec.ch/TC57/CIM100#" xmlns:md="http://iec.ch/TC57/61970-552/ModelDescription/1#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:eu="http://iec.ch/TC57/CIM100-European#">
<md:FullModel rdf:about="urn:uuid:d400c631-75a0-4c30-8aed-832b0d282e73">
<md:Model.created>2024-06-28T11:00:00Z</md:Model.created>
<md:Model.scenarioTime>2024-06-28T11:00:00Z</md:Model.scenarioTime>
<md:Model.version>1</md:Model.version>
<md:Model.description>Equivalent injection missing regulation target</md:Model.description>
<md:Model.modelingAuthoritySet>https://www.powsybl.org/</md:Model.modelingAuthoritySet>
<md:Model.profile>http://iec.ch/TC57/ns/CIM/SteadyStateHypothesis-EU/3.0</md:Model.profile>
</md:FullModel>

<cim:EquivalentInjection rdf:about="#_EI1">
<cim:Equipment.inService>true</cim:Equipment.inService>
<cim:EquivalentInjection.p>-100</cim:EquivalentInjection.p>
<cim:EquivalentInjection.q>10</cim:EquivalentInjection.q>
<cim:EquivalentInjection.regulationStatus>true</cim:EquivalentInjection.regulationStatus>
<!-- regulation status is true, and a regulation target is provided -->
<cim:EquivalentInjection.regulationTarget>401</cim:EquivalentInjection.regulationTarget>
</cim:EquivalentInjection>
</rdf:RDF>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<rdf:RDF xmlns:cim="http://iec.ch/TC57/CIM100#" xmlns:md="http://iec.ch/TC57/61970-552/ModelDescription/1#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:eu="http://iec.ch/TC57/CIM100-European#">
<md:FullModel rdf:about="urn:uuid:d400c631-75a0-4c30-8aed-832b0d282e73">
<md:Model.created>2024-06-28T11:00:00Z</md:Model.created>
<md:Model.scenarioTime>2024-06-28T11:00:00Z</md:Model.scenarioTime>
<md:Model.version>1</md:Model.version>
<md:Model.description>Equivalent injection missing regulation target</md:Model.description>
<md:Model.modelingAuthoritySet>https://www.powsybl.org/</md:Model.modelingAuthoritySet>
<md:Model.profile>http://iec.ch/TC57/ns/CIM/SteadyStateHypothesis-EU/3.0</md:Model.profile>
</md:FullModel>

<cim:EquivalentInjection rdf:about="#_EI1">
<cim:Equipment.inService>true</cim:Equipment.inService>
<cim:EquivalentInjection.p>-100</cim:EquivalentInjection.p>
<cim:EquivalentInjection.q>10</cim:EquivalentInjection.q>
<cim:EquivalentInjection.regulationStatus>true</cim:EquivalentInjection.regulationStatus>
<!-- regulation status is true, and a regulation target is provided, but has an invalid value -->
<cim:EquivalentInjection.regulationTarget>0</cim:EquivalentInjection.regulationTarget>
</cim:EquivalentInjection>
</rdf:RDF>

0 comments on commit a255882

Please sign in to comment.