Skip to content

Commit

Permalink
CGMES ground conversion (#2848)
Browse files Browse the repository at this point in the history
Signed-off-by: Luma <zamarrenolm@aia.es>
Co-authored-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
  • Loading branch information
zamarrenolm and So-Fras authored Jan 17, 2024
1 parent 3a1881c commit e72bdde
Show file tree
Hide file tree
Showing 10 changed files with 563 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public Network convert(Reporter reporter) {
convert(cgmes.busBarSections(), bbs -> new BusbarSectionConversion(bbs, context));
}

convert(cgmes.grounds(), g -> new GroundConversion(g, context));
convert(cgmes.energyConsumers(), ec -> new EnergyConsumerConversion(ec, context));
convert(cgmes.energySources(), es -> new EnergySourceConversion(es, context));
convf = eqi -> new EquivalentInjectionConversion(eqi, context);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
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.elements;

import com.powsybl.cgmes.conversion.Context;
import com.powsybl.iidm.network.*;
import com.powsybl.triplestore.api.PropertyBag;

/**
* @author Luma Zamarreño {@literal <zamarrenolm at aia.es>}
*/
public class GroundConversion extends AbstractConductingEquipmentConversion {

public GroundConversion(PropertyBag ec, Context context) {
super("Ground", ec, context);
}

@Override
public void convert() {
GroundAdder adder = voltageLevel().newGround();
identify(adder);
connect(adder);
Ground g = adder.add();
addAliasesAndProperties(g);
convertedTerminals(g.getTerminal());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (c) 2023, 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.iidm.network.Ground;
import com.powsybl.iidm.network.Network;
import org.junit.jupiter.api.Test;

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

/**
* @author Sophie Frasnedo {@literal <sophie.frasnedo at rte-france.com>}
*/

class GroundConversionTest {

@Test
void groundConversionTest() {
Network network = Network.read("groundTest.xml", getClass().getResourceAsStream("/groundTest.xml"));

assertEquals(2, network.getGroundCount());

assertNotNull(network.getGround("OU"));

Ground groundCV = network.getGround("CV");
assertNotNull(groundCV);
assertEquals("CW", groundCV.getNameOrId());
assertNotNull(groundCV.getTerminal());
assertFalse(groundCV.getTerminal().isConnected());
assertEquals("S", groundCV.getTerminal().getVoltageLevel().getId());
}
}
466 changes: 466 additions & 0 deletions cgmes/cgmes-conversion/src/test/resources/groundTest.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ default PropertyBags graph() {
return new PropertyBags();
}

default PropertyBags grounds() {
return new PropertyBags();
}

CgmesDcTerminal dcTerminal(String dcTerminalId);

void clear(CgmesSubset subset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ public PropertyBags graph() {
return namedQuery("graph");
}

@Override
public PropertyBags grounds() {
return namedQuery("grounds");
}

@Override
public PropertyBags modelProfiles() {
return namedQuery(MODEL_PROFILES);
Expand Down
11 changes: 11 additions & 0 deletions cgmes/cgmes-model/src/main/resources/CIM16.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,17 @@ WHERE {
}}
}

# query: grounds
SELECT *
WHERE {
{ GRAPH ?graph {
?Ground
a cim:Ground ;
cim:IdentifiedObject.name ?name .
?Terminal cim:Terminal.ConductingEquipment ?Ground .
}}
}

# query: update
DELETE { GRAPH <{0}>
{ ?subject ?predicate ?value }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public GroundImpl add() {
NetworkImpl network = getNetwork();
String id = checkAndGetUniqueId();
TerminalExt terminal = checkAndGetTerminal();
GroundImpl ground = new GroundImpl(getNetworkRef(), id, id);
GroundImpl ground = new GroundImpl(getNetworkRef(), id, getName());
ground.addTerminal(terminal);
voltageLevel.attach(terminal, false);
network.getIndex().checkAndAdd(ground);
Expand Down
4 changes: 2 additions & 2 deletions iidm/iidm-serde/src/test/resources/V1_12/ground.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<iidm:switch id="D_1_6" kind="DISCONNECTOR" retained="false" open="false" node1="1" node2="6"/>
</iidm:nodeBreakerTopology>
<iidm:load id="L" loadType="UNDEFINED" p0="1.0" q0="1.0" node="2"/>
<iidm:ground id="GroundNB" name="GroundNB" node="6"/>
<iidm:ground id="GroundNB" name="GroundNB1" node="6"/>
</iidm:voltageLevel>
<iidm:voltageLevel id="VL2" nominalV="220.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand All @@ -25,7 +25,7 @@
<iidm:generator id="CB" energySource="HYDRO" minP="0.0" maxP="70.0" voltageRegulatorOn="false" targetP="0.0" targetV="0.0" targetQ="0.0" bus="BUS1" connectableBus="BUS1">
<iidm:minMaxReactiveLimits minQ="-1.7976931348623157E308" maxQ="1.7976931348623157E308"/>
</iidm:generator>
<iidm:ground id="GroundBB" name="GroundBB" bus="BUS2" connectableBus="BUS2"/>
<iidm:ground id="GroundBB" name="GroundBB1" bus="BUS2" connectableBus="BUS2"/>
</iidm:voltageLevel>
<iidm:twoWindingsTransformer id="TWT" r="2.0" x="14.745" g="0.0" b="3.2E-5" ratedU1="225.0" ratedU2="225.0" voltageLevelId1="VL1" node1="3" voltageLevelId2="VL2" bus2="BUS1" connectableBus2="BUS1"/>
</iidm:substation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,18 @@ public static Network createWithGrounds(NetworkFactory networkFactory) {
.setNode1(1)
.setNode2(6)
.add();

vl1.newGround()
.setId("GroundNB")
.setName("GroundNB1")
.setNode(6)
.setEnsureIdUnicity(true)
.add();

// Create ground in bus-breaker view
vl2.newGround()
.setId("GroundBB")
.setName("GroundBB1")
.setBus("BUS2")
.setEnsureIdUnicity(true)
.add();
Expand Down

0 comments on commit e72bdde

Please sign in to comment.