Skip to content
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
31 changes: 24 additions & 7 deletions src/power_grid_model_ds/_core/model/dtypes/branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
from power_grid_model_ds._core.model.dtypes.id import Id


class Branch(Id):
"""Branch data type"""
class BasicBranch(Id):
"""Branch that matches the PGM Branch data type"""

from_node: NDArray[np.int32] # node id (from-side)
to_node: NDArray[np.int32] # node id (to-side)
from_status: NDArray[np.int8] # 1 = closed, 0 = open
to_status: NDArray[np.int8] # 1 = closed, 0 = open


class Branch(BasicBranch):
"""PGM Branch with additional feeder information"""

feeder_branch_id: NDArray[np.int32] # branch id of the feeding branch
feeder_node_id: NDArray[np.int32] # node id of the feeding node
is_feeder: NDArray[np.bool_] # whether or not this branch is from the substation
Expand All @@ -29,12 +34,16 @@ class Branch(Id):
}


class BasicLink(BasicBranch):
"""Basic Link data type"""


class Link(Branch):
"""Link data type"""
"""Link data type including feeder information"""


class Line(Branch):
"""Line data type"""
class BasicLine(BasicBranch):
"""Basic Line data type"""

r1: NDArray[np.float64] # serial resistance
x1: NDArray[np.float64] # serial reactance
Expand All @@ -43,8 +52,12 @@ class Line(Branch):
i_n: NDArray[np.float64] # rated current


class Transformer(Branch):
"""Transformer data type"""
class Line(Branch, BasicLine):
"""Line data type including feeder information"""


class BasicTransformer(BasicBranch):
"""Basic Transformer data type"""

u1: NDArray[np.float64] # rated voltage (from-side)
u2: NDArray[np.float64] # rated voltage (to-side)
Expand All @@ -64,6 +77,10 @@ class Transformer(Branch):
tap_nom: NDArray[np.int8] # nominal position of tap changer


class Transformer(Branch, BasicTransformer):
"""Transformer including feeder information"""


class Branch3(Id):
"""Branch3 data type"""

Expand Down
9 changes: 7 additions & 2 deletions src/power_grid_model_ds/_core/model/dtypes/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
from power_grid_model_ds._core.model.enums.nodes import NodeType


class Node(Id):
"""Node data type"""
class BasicNode(Id):
"""Basic Node that matches the PGM Node data type"""

u_rated: NDArray[np.float64] # rated line-line voltage


class Node(BasicNode):
"""Node data type, including node type and feeder information"""

node_type: NDArray[np.int8]
feeder_branch_id: NDArray[np.int32] # branch id of the feeder
feeder_node_id: NDArray[np.int32] # node id of the first substation node
Expand Down
18 changes: 9 additions & 9 deletions tests/integration/loadflow/test_power_grid_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,29 +225,29 @@ def test_create_grid_from_input_data(self, input_data_pgm):
2,
1,
1,
-2147483648,
-2147483648,
False,
0.00396133,
4.53865336e-05,
0.0,
0.0,
303.91942029,
-2147483648,
-2147483648,
False,
),
(
10,
7,
1,
1,
1,
-2147483648,
-2147483648,
False,
0.32598809,
1.34716591e-02,
0.0,
0.0,
210.06857453,
-2147483648,
-2147483648,
False,
),
],
dtype=[
Expand All @@ -256,14 +256,14 @@ def test_create_grid_from_input_data(self, input_data_pgm):
("to_node", "<i4"),
("from_status", "i1"),
("to_status", "i1"),
("feeder_branch_id", "<i4"),
("feeder_node_id", "<i4"),
("is_feeder", "?"),
("r1", "<f8"),
("x1", "<f8"),
("c1", "<f8"),
("tan1", "<f8"),
("i_n", "<f8"),
("feeder_branch_id", "<i4"),
("feeder_node_id", "<i4"),
("is_feeder", "?"),
],
),
)
Expand Down
Loading