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

New "Ground" injection #2837

Merged
merged 31 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fc40d6d
Add 1.12 xsd, IidmVersion and set current version to 1.12
flo-dup Dec 4, 2023
0009bab
Create 1.12 test references for versioned unit tests
flo-dup Dec 4, 2023
946210a
Create 1.12 json unit test references
flo-dup Dec 4, 2023
145f693
Create iidm equipment unit test reference
flo-dup Dec 4, 2023
55fe19f
Update non-versioned unit tests
flo-dup Dec 4, 2023
dffd0db
Update AbstractVersionableNetworkExtensionSerDe classes
flo-dup Dec 4, 2023
0b7b83b
Merge branch 'main' into evolution_xiidm/1.12
annetill Dec 15, 2023
72f0785
create Ground Identifiable
rolnico Dec 18, 2023
80f7674
checkstyle
rolnico Dec 18, 2023
16d875d
typo in test
rolnico Dec 18, 2023
b172ef0
improved coverage
rolnico Dec 18, 2023
2a18545
test coverage
rolnico Dec 19, 2023
d12ae22
checkstyle
rolnico Dec 19, 2023
7258c98
new implementation + SerDe
rolnico Dec 20, 2023
e73fa5e
merged switch
rolnico Dec 20, 2023
6862d28
add TCK test
rolnico Dec 21, 2023
76735b9
replace equipment with identifiable in javadoc
rolnico Jan 11, 2024
0aba02d
network creation moved to iidm-test to avoid duplication
rolnico Jan 11, 2024
13a9370
delete old and now unused network creation method
rolnico Jan 11, 2024
b53fb3e
delete comment
rolnico Jan 11, 2024
5b6a4e2
Merge branch 'main' into nro/ground_disconnector
rolnico Jan 11, 2024
4ce93a9
factorisation of a variable and a few methods in AbstractInjectionAdder
rolnico Jan 11, 2024
239d589
allow setFictitious if false only
rolnico Jan 11, 2024
8ff3086
delete ground from list in isValid
rolnico Jan 11, 2024
62db5dd
Merge branch 'main' into nro/ground_disconnector
rolnico Jan 11, 2024
5fcdc3e
add ground from list in isValid with right exit
rolnico Jan 11, 2024
f329af7
Merge branch 'main' into nro/ground_disconnector
flo-dup Jan 15, 2024
997b7a2
delete getVariantManagerHolder method
rolnico Jan 15, 2024
1bcfb12
add visitGround method in visitor + added Ground in some remaining sw…
rolnico Jan 15, 2024
b6a4d2e
Merge branch 'main' into nro/ground_disconnector
flo-dup Jan 15, 2024
7f9ad94
Merge branch 'main' into nro/ground_disconnector
flo-dup Jan 15, 2024
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
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:cca="http://www.powsybl.org/schema/iidm/ext/cgmes_control_areas/1_0" id="sim1" caseDate="2021-02-02T09:27:39.856+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:cca="http://www.powsybl.org/schema/iidm/ext/cgmes_control_areas/1_0" id="sim1" caseDate="2021-02-02T09:27:39.856+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:clbn="http://www.powsybl.org/schema/iidm/ext/cgmes_line_boundary_node/1_0" id="sim1" caseDate="2013-01-15T18:45:00.000+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:clbn="http://www.powsybl.org/schema/iidm/ext/cgmes_line_boundary_node/1_0" id="sim1" caseDate="2013-01-15T18:45:00.000+01:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:csshm="http://www.powsybl.org/schema/iidm/ext/cgmes_ssh_metadata/1_0" id="sim1" caseDate="2020-09-07T15:44:10.209+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:csshm="http://www.powsybl.org/schema/iidm/ext/cgmes_ssh_metadata/1_0" id="sim1" caseDate="2020-09-07T15:44:10.209+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:csm="http://www.powsybl.org/schema/iidm/ext/cgmes_sv_metadata/1_0" id="sim1" caseDate="2020-09-07T15:44:10.209+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:csm="http://www.powsybl.org/schema/iidm/ext/cgmes_sv_metadata/1_0" id="sim1" caseDate="2020-09-07T15:44:10.209+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:cc="http://www.powsybl.org/schema/iidm/ext/cim_characteristics/1_0" id="sim1" caseDate="2020-09-08T14:28:13.738+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:cc="http://www.powsybl.org/schema/iidm/ext/cim_characteristics/1_0" id="sim1" caseDate="2020-09-08T14:28:13.738+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
2 changes: 1 addition & 1 deletion entsoe-util/src/test/resources/entsoeAreaRef.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:ea="http://www.itesla_project.eu/schema/iidm/ext/entsoe_area/1_0" id="test" caseDate="2016-06-27T12:27:58.535+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:ea="http://www.itesla_project.eu/schema/iidm/ext/entsoe_area/1_0" id="test" caseDate="2016-06-27T12:27:58.535+02:00" forecastDistance="0" sourceFormat="test" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S" country="FR"></iidm:substation>
<iidm:extension id="S">
<ea:entsoeArea>BE</ea:entsoeArea>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee118cdf" caseDate="1993-08-25T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee118cdf" caseDate="1993-08-25T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="138.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee14cdf-solved" caseDate="1993-08-19T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee14cdf-solved" caseDate="1993-08-19T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee14cdf" caseDate="1993-08-19T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee14cdf" caseDate="1993-08-19T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="135.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee300cdf" caseDate="1991-05-13T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee300cdf" caseDate="1991-05-13T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="115.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee30cdf" caseDate="1993-08-20T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee30cdf" caseDate="1993-08-20T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="132.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee33" caseDate="2022-09-23T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee33" caseDate="2022-09-23T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="12.66" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee57cdf" caseDate="1993-08-25T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee57cdf" caseDate="1993-08-25T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="1.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee69" caseDate="2022-09-23T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee69" caseDate="2022-09-23T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="12.66" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee9cdf" caseDate="2009-04-26T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee9cdf" caseDate="2009-04-26T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="100.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_11" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee9zeroimpedancecdf" caseDate="2009-04-26T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_12" xmlns:slt="http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_5" id="ieee9zeroimpedancecdf" caseDate="2009-04-26T00:00:00.000Z" forecastDistance="0" sourceFormat="IEEE-CDF" minimumValidationLevel="STEADY_STATE_HYPOTHESIS">
<iidm:substation id="S1">
<iidm:voltageLevel id="VL1" nominalV="100.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down
19 changes: 19 additions & 0 deletions iidm/iidm-api/src/main/java/com/powsybl/iidm/network/Ground.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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.iidm.network;

/**
* @author Nicolas Rol {@literal <nicolas.rol at rte-france.com>}
*/
public interface Ground extends Injection<Ground> {

@Override
default IdentifiableType getType() {
return IdentifiableType.GROUND;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.iidm.network;

/**
* @author Nicolas Rol {@literal <nicolas.rol at rte-france.com>}
*/
public interface GroundAdder extends InjectionAdder<Ground, GroundAdder> {
@Override
Ground add();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ public enum IdentifiableType {
SHUNT_COMPENSATOR,
DANGLING_LINE,
STATIC_VAR_COMPENSATOR,
HVDC_CONVERTER_STATION
HVDC_CONVERTER_STATION,
GROUND
}
Original file line number Diff line number Diff line change
Expand Up @@ -1139,9 +1139,30 @@ default HvdcLine getHvdcLine(HvdcConverterStation converterStation) {
*/
HvdcLineAdder newHvdcLine();

/**
* Get all grounds.
*/
Iterable<Ground> getGrounds();

/**
* Get all grounds.
*/
Stream<Ground> getGroundStream();

/**
* Get the ground count.
*/
int getGroundCount();

/**
* Get a load.
flo-dup marked this conversation as resolved.
Show resolved Hide resolved
*
* @param id the id or an alias of the ground
*/
Ground getGround(String id);

/**
* Get an equipment by its ID or alias
* * Get an equipment by its ID or alias
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* * Get an equipment by its ID or alias
* Get an identifiable by its ID or alias

(equipment is uncountable + * was duplicated)

NB: there is a similar typo on the following line. I suggest to replace equipment by identifiable there too.

*
* @param id the id or an alias of the equipment
*/
Expand Down Expand Up @@ -1394,6 +1415,8 @@ default Stream<Identifiable<?>> getIdentifiableStream(IdentifiableType identifia
return getHvdcConverterStationStream().map(Function.identity());
case STATIC_VAR_COMPENSATOR:
return getStaticVarCompensatorStream().map(Function.identity());
case GROUND:
return getGroundStream().map(Function.identity());
default:
throw new PowsyblException("can get a stream of " + identifiableType + " from a network.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
import java.io.PrintStream;
import java.io.Writer;
import java.nio.file.Path;
import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
Expand Down Expand Up @@ -827,7 +830,7 @@ default Stream<Bus> getBusStreamFromBusViewBusId(String mergedBusId) {
Switch getSwitch(String switchId);

/**
* Get a builer to create a new switch.
* Get a builder to create a new switch.
*
* @throws com.powsybl.commons.PowsyblException if the topology kind is NODE_BREAKER
*/
Expand Down Expand Up @@ -1249,6 +1252,26 @@ default Stream<DanglingLine> getDanglingLineStream() {
*/
int getThreeWindingsTransformerCount();

/**
* Get a builder to create a new ground.
*/
GroundAdder newGround();

/**
* Get grounds.
*/
Iterable<Ground> getGrounds();

/**
* Get grounds.
*/
Stream<Ground> getGroundStream();

/**
* Get ground count.
*/
int getGroundCount();

/**
* Remove this voltage level from the network.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,26 @@ public Stream<ThreeWindingsTransformer> getThreeWindingsTransformerStream() {
return getConnectableStream(ThreeWindingsTransformer.class);
}

@Override
public GroundAdder newGround() {
return new GroundAdderImpl(this);
}

@Override
public Iterable<Ground> getGrounds() {
return getConnectables(Ground.class);
}

@Override
public Stream<Ground> getGroundStream() {
return getConnectableStream(Ground.class);
}

@Override
public int getGroundCount() {
return getConnectableCount(Ground.class);
}

@Override
protected String getTypeDescription() {
return "Voltage level";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.iidm.network.impl;

import com.powsybl.iidm.network.GroundAdder;
import com.powsybl.iidm.network.impl.util.Ref;

/**
* @author Nicolas Rol {@literal <nicolas.rol at rte-france.com>}
*/
class GroundAdderImpl extends AbstractInjectionAdder<GroundAdderImpl> implements GroundAdder {

private final VoltageLevelExt voltageLevel;
flo-dup marked this conversation as resolved.
Show resolved Hide resolved

GroundAdderImpl(VoltageLevelExt voltageLevel) {
this.voltageLevel = voltageLevel;
}

@Override
protected NetworkImpl getNetwork() {
return voltageLevel.getNetwork();
}

@Override
protected String getTypeDescription() {
return "Ground";
}

@Override
protected Ref<? extends VariantManagerHolder> getVariantManagerHolder() {
return getNetworkRef();
}

private Ref<NetworkImpl> getNetworkRef() {
return voltageLevel.getNetworkRef();
}

@Override
public GroundImpl add() {
NetworkImpl network = getNetwork();
String id = checkAndGetUniqueId();
TerminalExt terminal = checkAndGetTerminal();
GroundImpl ground = new GroundImpl(getNetworkRef(), id, id);
ground.addTerminal(terminal);
voltageLevel.attach(terminal, false);
network.getIndex().checkAndAdd(ground);
network.getListeners().notifyCreation(ground);
return ground;
}
}
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.iidm.network.impl;

import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.Ground;
import com.powsybl.iidm.network.impl.util.Ref;

/**
* @author Nicolas Rol {@literal <nicolas.rol at rte-france.com>}
*/
class GroundImpl extends AbstractConnectable<Ground> implements Ground {

GroundImpl(Ref<NetworkImpl> networkRef,
String id, String name) {
super(networkRef, id, name, false);
}

@Override
public TerminalExt getTerminal() {
return terminals.get(0);
}

@Override
public void setFictitious(boolean fictitious) {
throw new PowsyblException("The ground cannot be fictitious.");
flo-dup marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
protected String getTypeDescription() {
return "Ground";
}
}
Loading