Skip to content

Commit

Permalink
Replace ucte-x-node-code with pairing_key
Browse files Browse the repository at this point in the history
Signed-off-by: Coline PILOQUET <coline.piloquet@rte-france.com>
  • Loading branch information
colinepiloquet authored and EtienneLt committed Feb 13, 2024
1 parent abcae66 commit f12324e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/user_guide/sensitivity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ use the dangling line ID as the injection in the zone definition.
>>> n = pp.network.load('simple-eu-xnode.uct')
>>> n.get_dangling_lines()
name r x g b p0 q0 p q i voltage_level_id bus_id connected ucte-x-node-code isCoupler status_XNode geographicalName
name r x g b p0 q0 p q i voltage_level_id bus_id connected pairing_key isCoupler status_XNode geographicalName
id
NNL2AA1 XXXXXX11 1 0.0 10.0 0.0 0.0 0.0 0.0 NaN NaN NaN NNL2AA1 NNL2AA1_0 True XXXXXX11 false EQUIVALENT >>> zone_x = pp.sensitivity.create_empty_zone("X")
We can see that the dangling line 'NNL2AA1 XXXXXX11 1' correspond to the X-Node XXXXXX11 (see column ucte-x-node-code of dangling line data frame).
We can see that the dangling line 'NNL2AA1 XXXXXX11 1' correspond to the X-Node XXXXXX11 (see column pairing_key of dangling line data frame).
To calculate to sensitivity of X-Node XXXXXX11 on tie line 'BBE2AA1 FFR3AA1 1':

.. code-block:: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static NetworkDataframeMapper danglingLines() {
.strings("bus_breaker_bus_id", busBreakerViewBusId(), false)
.ints("node", dl -> getNode(dl.getTerminal()), false)
.booleans("connected", dl -> dl.getTerminal().isConnected(), connectInjection())
.strings("ucte-x-node-code", dl -> Objects.toString(dl.getPairingKey(), ""))
.strings("pairing_key", dl -> Objects.toString(dl.getPairingKey(), ""))
.booleans("fictitious", Identifiable::isFictitious, Identifiable::setFictitious, false)
.strings("tie_line_id", dl -> dl.getTieLine().map(Identifiable::getId).orElse(""))
.addProperties()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DanglingLineDataframeAdder extends AbstractSimpleAdder {
SeriesMetadata.doubles("x"),
SeriesMetadata.doubles("g"),
SeriesMetadata.doubles("b"),
SeriesMetadata.strings("ucte_xnode_code")
SeriesMetadata.strings("pairing_key")
);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ void danglingLines() {
assertThat(series)
.extracting(Series::getName)
.containsExactly("id", "name", "r", "x", "g", "b", "p0", "q0", "p", "q", "i", "voltage_level_id", "bus_id",
"connected", "ucte-x-node-code", "tie_line_id");
"connected", "pairing_key", "tie_line_id");
List<Series> allAttributeSeries = createDataFrame(DANGLING_LINE, network, new DataframeFilter(ALL_ATTRIBUTES, Collections.emptyList()));
assertThat(allAttributeSeries)
.extracting(Series::getName)
.containsExactly("id", "name", "r", "x", "g", "b", "p0", "q0", "p", "q", "i",
"voltage_level_id", "bus_id", "bus_breaker_bus_id", "node", "connected", "ucte-x-node-code", "fictitious", "tie_line_id");
"voltage_level_id", "bus_id", "bus_breaker_bus_id", "node", "connected", "pairing_key", "fictitious", "tie_line_id");
}

@Test
Expand Down
15 changes: 13 additions & 2 deletions pypowsybl/network/impl/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ def get_dangling_lines(self, all_attributes: bool = False, attributes: List[str]
- **node** (optional): node where this line is connected, in node-breaker voltage levels
- **connected**: ``True`` if the dangling line is connected to a bus
- **fictitious** (optional): ``True`` if the dangling line is part of the model and not of the actual network
- **ucte-xnode-code**: the UCTE Xnode code associated to the dangling line, to be used for creating tie lines.
- **pairing_key**: the pairing key associated to the dangling line, to be used for creating tie lines.
- **tie_line_id**: the ID of the tie line if the dangling line is paired
This dataframe is indexed by the id of the dangling lines
Expand Down Expand Up @@ -3609,7 +3609,8 @@ def create_dangling_lines(self, df: DataFrame = None, **kwargs: ArrayLike) -> No
- **x**: the reactance, in Ohms
- **g**: the shunt conductance, in S
- **b**: the shunt susceptance, in S
- **ucte-xnode-code**: the optional UCTE Xnode code associated to the dangling line, to be used for creating tie lines.
- **pairing-key**: the optional pairing key associated to the dangling line, to be used for creating tie lines.
- **ucte-x-node-code**: deprecated, use pairing-key instead.
Examples:
Using keyword arguments:
Expand All @@ -3619,6 +3620,16 @@ def create_dangling_lines(self, df: DataFrame = None, **kwargs: ArrayLike) -> No
network.create_dangling_lines(id='BAT-1', voltage_level_id='VL1', bus_id='B1',
p0=10, q0=3, r=0, x=5, g=0, b=1e-6)
"""
if df is not None:
if 'ucte-x-node-code' in df.columns:
warnings.warn("ucte-x-node-code is deprecated, use pairing_key", DeprecationWarning)
df = df.rename(columns={'ucte-x-node-code': 'pairing_key'})

ucte_x_node_code = kwargs.get('ucte-x-node-code')
if ucte_x_node_code is not None:
warnings.warn("ucte-x-node-code is deprecated, use pairing_key", DeprecationWarning)
kwargs['pairing_key'] = ucte_x_node_code
kwargs.pop('ucte-x-node-code')
return self._create_elements(ElementType.DANGLING_LINE, [df], **kwargs)

def create_lcc_converter_stations(self, df: DataFrame = None, **kwargs: ArrayLike) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ def test_dangling_lines():
expected = pd.DataFrame(index=pd.Series(name='id', data=['DL']),
columns=['name', 'r', 'x', 'g', 'b', 'p0', 'q0', 'p', 'q', 'i', 'voltage_level_id',
'bus_id',
'connected', 'ucte-x-node-code', 'tie_line_id'],
'connected', 'pairing_key', 'tie_line_id'],
data=[['', 10.0, 1.0, 0.0001, 0.00001, 50.0, 30.0, NaN, NaN, NaN, 'VL', 'VL_0', True,
'', '']])
pd.testing.assert_frame_equal(expected, n.get_dangling_lines(), check_dtype=False)
Expand All @@ -964,7 +964,7 @@ def test_dangling_lines():
updated = pd.DataFrame(index=pd.Series(name='id', data=['DL']),
columns=['name', 'r', 'x', 'g', 'b', 'p0', 'q0', 'p', 'q', 'i', 'voltage_level_id',
'bus_id',
'connected', 'ucte-x-node-code', 'tie_line_id'],
'connected', 'pairing_key', 'tie_line_id'],
data=[['', 11.0, 1.1, 0.0002, 0.00002, 40.0, 40.0, NaN, NaN, NaN, 'VL', '', False, '', '']])
pd.testing.assert_frame_equal(updated, n.get_dangling_lines(), check_dtype=False)
n = util.create_dangling_lines_network()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_per_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ def test_dangling_lines_per_unit():

expected = pd.DataFrame(index=pd.Series(name='id', data=['DL']),
columns=['name', 'r', 'x', 'g', 'b', 'p0', 'q0', 'p', 'q', 'i', 'voltage_level_id',
'bus_id', 'connected', 'ucte-x-node-code', 'tie_line_id'],
'bus_id', 'connected', 'pairing_key', 'tie_line_id'],
data=[['', 0.1, 0.01, 0.01, 0.001, 0.5, 0.3, 0.5482, 0.3029, 0.6263, 'VL', 'VL_0',
True, '', '']])
dangling_lines = n.get_dangling_lines()
pd.testing.assert_frame_equal(expected, dangling_lines, check_dtype=False, atol=10 ** -4)
n.update_dangling_lines(pd.DataFrame(index=['DL'], columns=['p0', 'q0'], data=[[0.75, 0.25]]))
expected = pd.DataFrame(index=pd.Series(name='id', data=['DL']),
columns=['name', 'r', 'x', 'g', 'b', 'p0', 'q0', 'p', 'q', 'i', 'voltage_level_id',
'bus_id', 'connected', 'ucte-x-node-code', 'tie_line_id'],
'bus_id', 'connected', 'pairing_key', 'tie_line_id'],
data=[['', 0.1, 0.01, 0.01, 0.001, 0.75, 0.25, 0.5482, 0.3029, 0.6263, 'VL', 'VL_0',
True, '', '']])
dangling_lines = n.get_dangling_lines()
Expand Down

0 comments on commit f12324e

Please sign in to comment.