Skip to content

Commit 3bbedd3

Browse files
authored
More pp tests (#30)
1 parent 226eb67 commit 3bbedd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+947
-262
lines changed

stubs/pandapower-stubs/_typing.pyi

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ from typing_extensions import TypeAlias
44

55
import numpy as np
66

7-
_T = TypeVar("_T", bound=Any)
7+
_T = TypeVar("_T")
8+
_G = TypeVar("_G", bound=np.generic)
9+
_Generic_co = TypeVar("_Generic_co", covariant=True, bound=np.generic)
810

911
# Wide primitives for input types
1012
Bool: TypeAlias = bool | np.bool
@@ -13,8 +15,14 @@ Float: TypeAlias = SupportsFloat | Int
1315

1416
# Vector-related
1517
ScalarOrVector: TypeAlias = _T | Collection[_T]
16-
Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_T]]
17-
Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_T]]
18+
Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_G]]
19+
Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_G]]
20+
21+
class SupportsArray(Protocol[_Generic_co]):
22+
def __array__(self) -> np.ndarray[Any, np.dtype[_Generic_co]]: ...
23+
24+
VectorLike: TypeAlias = Collection[_T] | SupportsArray[_G]
25+
FloatVectorLike: TypeAlias = VectorLike[Float, np.floating | np.integer | np.bool]
1826

1927
# File I/O related
2028
@type_check_only

stubs/pandapower-stubs/control/__init__.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ from pandapower.control.controller.const_control import ConstControl as ConstCon
33
from pandapower.control.controller.trafo.ContinuousTapControl import ContinuousTapControl as ContinuousTapControl
44
from pandapower.control.controller.trafo.DiscreteTapControl import DiscreteTapControl as DiscreteTapControl
55
from pandapower.control.controller.trafo.TapDependentImpedance import TapDependentImpedance as TapDependentImpedance
6-
from pandapower.control.controller.trafo.USetTapControl import USetTapControl as USetTapControl
76
from pandapower.control.controller.trafo.VmSetTapControl import VmSetTapControl as VmSetTapControl
87
from pandapower.control.controller.trafo_control import TrafoController as TrafoController
98
from pandapower.control.run_control import *
109
from pandapower.control.run_control import ControllerNotConverged as ControllerNotConverged
1110
from pandapower.control.util.auxiliary import (
12-
create_trafo_characteristics as create_trafo_characteristics,
11+
_create_trafo_characteristics as _create_trafo_characteristics,
1312
get_controller_index as get_controller_index,
1413
plot_characteristic as plot_characteristic,
1514
)
1615
from pandapower.control.util.characteristic import Characteristic as Characteristic, SplineCharacteristic as SplineCharacteristic
1716
from pandapower.control.util.diagnostic import (
1817
control_diagnostic as control_diagnostic,
19-
trafo_characteristics_diagnostic as trafo_characteristics_diagnostic,
18+
trafo_characteristic_table_diagnostic as trafo_characteristic_table_diagnostic,
2019
)

stubs/pandapower-stubs/control/basic_controller.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Any, SupportsIndex as Int
22

3+
import numpy as np
4+
35
from pandapower.auxiliary import pandapowerNet
46
from pandapower.io_utils import JSONSerializableClass
57

@@ -46,10 +48,10 @@ class Controller(BasicCtrl):
4648
drop_same_existing_ctrl: bool,
4749
overwrite: bool,
4850
**kwargs,
49-
) -> int: ...
51+
) -> np.int64: ...
5052
def time_step(self, net: pandapowerNet, time: Any) -> None: ...
5153
def initialize_control(self, net: pandapowerNet) -> None: ...
52-
def is_converged(self, net: pandapowerNet): ...
54+
def is_converged(self, net: pandapowerNet) -> bool | np.bool: ...
5355
def control_step(self, net: pandapowerNet) -> None: ...
5456
def repair_control(self, net: pandapowerNet) -> None: ...
5557
def restore_init_state(self, net: pandapowerNet) -> None: ...
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import numpy as np
2+
3+
from pandapower._typing import Array1D, FloatVectorLike
4+
5+
class BaseModel:
6+
@classmethod
7+
def name(cls) -> str: ...
8+
9+
class QVCurve:
10+
vm_points_pu: FloatVectorLike
11+
q_points_pu: FloatVectorLike
12+
def __init__(self, vm_points_pu: FloatVectorLike, q_points_pu: FloatVectorLike) -> None: ...
13+
def step(self, vm_pu) -> Array1D[np.float64]: ...
14+
15+
class CosphiVCurve:
16+
vm_points_pu: FloatVectorLike
17+
cosphi_points: FloatVectorLike
18+
cosphi_pos: Array1D[np.float64]
19+
def __init__(self, vm_points_pu: FloatVectorLike, cosphi_points: FloatVectorLike) -> None: ...
20+
def step(self, vm_pu, p_pu) -> Array1D[np.float64]: ...
21+
22+
class CosphiPCurve:
23+
p_points_pu: FloatVectorLike
24+
cosphi_points: FloatVectorLike
25+
cosphi_pos: Array1D[np.float64]
26+
def __init__(self, p_points_pu: FloatVectorLike, cosphi_points: FloatVectorLike) -> None: ...
27+
def step(self, p_pu) -> Array1D[np.float64]: ...
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import numpy as np
2+
import shapely
3+
4+
from pandapower._typing import Array1D, Array2D, Float, FloatVectorLike
5+
from pandapower.control.controller.DERController.DERBasics import BaseModel
6+
7+
class BaseArea(BaseModel):
8+
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array1D[np.bool]: ...
9+
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...
10+
11+
class BasePQVArea(BaseArea):
12+
raise_merge_overlap: bool
13+
def __init__(self, raise_merge_overlap: bool = True) -> None: ...
14+
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array1D[np.bool]: ...
15+
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...
16+
17+
class PQAreaPOLYGON(BaseArea):
18+
p_points_pu: FloatVectorLike
19+
q_points_pu: FloatVectorLike
20+
polygon: shapely.Polygon
21+
def __init__(self, p_points_pu: FloatVectorLike, q_points_pu: FloatVectorLike) -> None: ...
22+
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array1D[np.bool]: ...
23+
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array2D[np.float64]: ...
24+
25+
class QVAreaPOLYGON(BaseArea):
26+
q_points_pu: FloatVectorLike
27+
vm_points_pu: FloatVectorLike
28+
polygon: shapely.Polygon
29+
def __init__(self, q_points_pu: FloatVectorLike, vm_points_pu: FloatVectorLike) -> None: ...
30+
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array1D[np.bool]: ...
31+
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...
32+
33+
class PQVAreaPOLYGON(BasePQVArea):
34+
pq_area: PQAreaPOLYGON
35+
qv_area: QVAreaPOLYGON
36+
def __init__(
37+
self,
38+
p_points_pu: FloatVectorLike,
39+
q_pq_points_pu: FloatVectorLike,
40+
q_qv_points_pu: FloatVectorLike,
41+
vm_points_pu: FloatVectorLike,
42+
raise_merge_overlap: bool = True,
43+
) -> None: ...
44+
45+
class PQAreaSTATCOM(BaseArea):
46+
min_q_pu: FloatVectorLike
47+
max_q_pu: FloatVectorLike
48+
def __init__(self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike) -> None: ...
49+
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array1D[np.bool]: ...
50+
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array2D[np.float64]: ...
51+
52+
class PQArea4120(BaseArea):
53+
version: int
54+
p_points_pu: list[float]
55+
min_q_pu: FloatVectorLike
56+
max_q_pu: FloatVectorLike
57+
q_max_under_p_point: float
58+
linear_factor_ind: FloatVectorLike
59+
linear_factor_cap: FloatVectorLike
60+
def __init__(self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike, version: int = 2018, **kwargs) -> None: ...
61+
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array1D[np.bool]: ...
62+
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array2D[np.float64]: ...
63+
64+
class QVArea4120(BaseArea):
65+
min_q_pu: FloatVectorLike
66+
max_q_pu: FloatVectorLike
67+
max_vm_pu: float
68+
min_vm_pu: float
69+
delta_vm_pu: float
70+
linear_factor: FloatVectorLike
71+
def __init__(self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike) -> None: ...
72+
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...
73+
74+
class PQVArea4120Base(BasePQVArea):
75+
pq_area: PQArea4120
76+
qv_area: QVArea4120
77+
def __init__(
78+
self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike, version: int = 2018, raise_merge_overlap: bool = True
79+
) -> None: ...
80+
81+
class PQVArea4120V1(PQVArea4120Base):
82+
def __init__(self, version: int = 2018, raise_merge_overlap: bool = True) -> None: ...
83+
84+
class PQVArea4120V2(PQVArea4120Base):
85+
def __init__(self, version: int = 2018, raise_merge_overlap: bool = True) -> None: ...
86+
87+
class PQVArea4120V3(PQVArea4120Base):
88+
def __init__(self, version: int = 2018, raise_merge_overlap: bool = True) -> None: ...
89+
90+
class PQArea4130(PQArea4120):
91+
def __init__(self, min_q_pu, max_q_pu) -> None: ...
92+
93+
class QVArea4130(QVArea4120):
94+
min_q_pu: FloatVectorLike
95+
max_q_pu: FloatVectorLike
96+
vn_kv: Float
97+
variant: int
98+
min_vm_points_pu: Array1D[np.float64]
99+
max_vm_points_pu: Array1D[np.float64]
100+
min_q_points_pu: Array1D[np.float64]
101+
max_q_points_pu: Array1D[np.float64]
102+
def __init__(self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike, vn_kv: Float, variant: int) -> None: ...
103+
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...
104+
105+
class PQVArea4130Base(BasePQVArea):
106+
pq_area: PQArea4130
107+
qv_area: QVArea4130
108+
def __init__(
109+
self,
110+
min_q_pu: FloatVectorLike,
111+
max_q_pu: FloatVectorLike,
112+
variant: int,
113+
vn_kv: Float = 380,
114+
raise_merge_overlap: bool = True,
115+
) -> None: ...
116+
117+
class PQVArea4130V1(PQVArea4130Base):
118+
def __init__(self, vn_kv: Float = 380, raise_merge_overlap: bool = True) -> None: ...
119+
120+
class PQVArea4130V2(PQVArea4130Base):
121+
def __init__(self, vn_kv: Float = 380, raise_merge_overlap: bool = True) -> None: ...
122+
123+
class PQVArea4130V3(PQVArea4130Base):
124+
def __init__(self, vn_kv: Float = 380, raise_merge_overlap: bool = True) -> None: ...
125+
126+
class PQArea4110(PQAreaPOLYGON):
127+
def __init__(self) -> None: ...
128+
129+
class QVArea4110(QVAreaPOLYGON):
130+
def __init__(self) -> None: ...
131+
132+
class PQVArea4110(BasePQVArea):
133+
pq_area: PQArea4110
134+
qv_area: QVArea4110
135+
def __init__(self, raise_merge_overlap: bool = True) -> None: ...
136+
137+
class PQArea4105(PQAreaPOLYGON):
138+
def __init__(self, variant: int) -> None: ...
139+
140+
class QVArea4105(QVAreaPOLYGON):
141+
def __init__(self, variant: int) -> None: ...
142+
143+
class PQVArea4105(BasePQVArea):
144+
pq_area: PQArea4105
145+
qv_area: QVArea4105
146+
def __init__(self, variant: int, raise_merge_overlap: bool = True) -> None: ...
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from _typeshed import Incomplete
2+
3+
import numpy as np
4+
5+
from pandapower._typing import Float
6+
from pandapower.control.controller.DERController.DERBasics import BaseModel, CosphiPCurve, CosphiVCurve, QVCurve
7+
8+
class QModel(BaseModel):
9+
def __init__(self, **kwargs) -> None: ...
10+
def step(self, vm_pu=None, p_pu=None): ...
11+
12+
class QModelConstQ(QModel):
13+
q_pu: Incomplete
14+
def __init__(self, q_pu) -> None: ...
15+
def step(self, vm_pu=None, p_pu=None): ...
16+
17+
class QModelCosphiVCurve(QModel):
18+
cosphi_v_curve: CosphiVCurve
19+
def __init__(self, cosphi_v_curve: dict[str, Incomplete] | CosphiVCurve) -> None: ...
20+
def step(self, vm_pu, p_pu=None): ... # type: ignore[override]
21+
22+
class QModelCosphiP(QModel):
23+
cosphi: Float
24+
q_setpoint_pu: np.float64
25+
def __init__(self, cosphi: Float) -> None: ...
26+
def step(self, vm_pu=None, p_pu=None): ...
27+
28+
class QModelCosphiSn(QModel):
29+
cosphi: Float
30+
def __init__(self, cosphi: Float = 0.2) -> None: ...
31+
def step(self, vm_pu=None, p_pu=None): ...
32+
33+
class QModelCosphiPQ(QModel):
34+
cosphi: Float
35+
q_setpoint_pu: np.float64
36+
def __init__(self, cosphi: Float) -> None: ...
37+
def step(self, vm_pu=None, p_pu=None): ...
38+
39+
class QModelCosphiPCurve(QModel):
40+
cosphi_p_curve: CosphiPCurve
41+
def __init__(self, cosphi_p_curve) -> None: ...
42+
def step(self, vm_pu=None, p_pu=None): ...
43+
44+
class QModelQVCurve(QModel):
45+
qv_curve: QVCurve
46+
def __init__(self, qv_curve: dict[str, Incomplete] | QVCurve) -> None: ...
47+
def step(self, vm_pu, p_pu=None): ... # type: ignore[override]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .der_control import *
2+
from .DERBasics import *
3+
from .PQVAreas import *
4+
from .QModels import *
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from pandapower.auxiliary import pandapowerNet
2+
from pandapower.control.controller.pq_control import PQController
3+
4+
class DERController(PQController):
5+
def __init__(
6+
self,
7+
net: pandapowerNet,
8+
element_index,
9+
element: str = "sgen",
10+
q_model=None,
11+
pqv_area=None,
12+
saturate_sn_mva=...,
13+
q_prio=True,
14+
damping_coef=2,
15+
max_p_error=1e-6,
16+
max_q_error=1e-6,
17+
pq_simultaneity_factor=1.0,
18+
f_sizing=1.0,
19+
data_source=None,
20+
p_profile=None,
21+
profile_from_name=False,
22+
profile_scale=1.0,
23+
in_service=True,
24+
ts_absolute=True,
25+
order=0,
26+
level=0,
27+
drop_same_existing_ctrl=False,
28+
matching_params=None,
29+
**kwargs,
30+
) -> None: ...
31+
def time_step(self, net: pandapowerNet, time) -> None: ...
32+
def is_converged(self, net: pandapowerNet) -> bool: ...
33+
def control_step(self, net: pandapowerNet) -> None: ...
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from matplotlib.axes import Axes
2+
3+
from pandapower._typing import Float, Int
4+
5+
def plot_pq_area(
6+
pq_area,
7+
*,
8+
title: str | None = None,
9+
ax: Axes | None = None,
10+
saturate_sn_pu: Float = ...,
11+
circle_segment: Int = 90,
12+
p_samples=None,
13+
tex: bool = False,
14+
) -> None: ...
15+
def plot_qv_area(qv_area, title=None, ax: Axes | None = None, prune_to_flexibility=False, vm_samples=None, tex: bool = False): ...
16+
def generate_circle_segment(center_x, center_y, radius, start, stop, step): ...
Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
from _typeshed import Incomplete
22

3+
import numpy as np
4+
5+
from pandapower.auxiliary import pandapowerNet
36
from pandapower.control.basic_controller import Controller
47

58
class CharacteristicControl(Controller):
6-
input_element: Incomplete
9+
input_element: str
710
input_element_index: Incomplete
8-
output_element: Incomplete
11+
output_element: str
912
output_element_index: Incomplete
1013
characteristic_index: Incomplete
11-
tol: Incomplete
14+
tol: float
1215
applied: bool
1316
values: Incomplete
1417
def __init__(
1518
self,
16-
net,
17-
output_element,
18-
output_variable,
19+
net: pandapowerNet,
20+
output_element: str,
21+
output_variable: str,
1922
output_element_index,
20-
input_element,
21-
input_variable,
23+
input_element: str,
24+
input_variable: str,
2225
input_element_index,
2326
characteristic_index,
2427
tol: float = 0.001,
2528
in_service: bool = True,
2629
order: int = 0,
2730
level: int = 0,
2831
drop_same_existing_ctrl: bool = False,
29-
matching_params: Incomplete | None = None,
32+
matching_params=None,
3033
**kwargs,
3134
) -> None: ...
32-
def initialize_control(self, net) -> None: ...
33-
def is_converged(self, net): ...
34-
def control_step(self, net) -> None: ...
35+
def initialize_control(self, net: pandapowerNet) -> None: ...
36+
def is_converged(self, net: pandapowerNet) -> bool | np.bool: ...
37+
def control_step(self, net: pandapowerNet) -> None: ...

0 commit comments

Comments
 (0)