Skip to content
Merged
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
14 changes: 11 additions & 3 deletions stubs/pandapower-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ from typing_extensions import TypeAlias

import numpy as np

_T = TypeVar("_T", bound=Any)
_T = TypeVar("_T")
_G = TypeVar("_G", bound=np.generic)
_Generic_co = TypeVar("_Generic_co", covariant=True, bound=np.generic)

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

# Vector-related
ScalarOrVector: TypeAlias = _T | Collection[_T]
Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_T]]
Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_T]]
Array1D: TypeAlias = np.ndarray[tuple[int], np.dtype[_G]]
Array2D: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_G]]

class SupportsArray(Protocol[_Generic_co]):
def __array__(self) -> np.ndarray[Any, np.dtype[_Generic_co]]: ...

VectorLike: TypeAlias = Collection[_T] | SupportsArray[_G]
FloatVectorLike: TypeAlias = VectorLike[Float, np.floating | np.integer | np.bool]

# File I/O related
@type_check_only
Expand Down
5 changes: 2 additions & 3 deletions stubs/pandapower-stubs/control/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ from pandapower.control.controller.const_control import ConstControl as ConstCon
from pandapower.control.controller.trafo.ContinuousTapControl import ContinuousTapControl as ContinuousTapControl
from pandapower.control.controller.trafo.DiscreteTapControl import DiscreteTapControl as DiscreteTapControl
from pandapower.control.controller.trafo.TapDependentImpedance import TapDependentImpedance as TapDependentImpedance
from pandapower.control.controller.trafo.USetTapControl import USetTapControl as USetTapControl
from pandapower.control.controller.trafo.VmSetTapControl import VmSetTapControl as VmSetTapControl
from pandapower.control.controller.trafo_control import TrafoController as TrafoController
from pandapower.control.run_control import *
from pandapower.control.run_control import ControllerNotConverged as ControllerNotConverged
from pandapower.control.util.auxiliary import (
create_trafo_characteristics as create_trafo_characteristics,
_create_trafo_characteristics as _create_trafo_characteristics,
get_controller_index as get_controller_index,
plot_characteristic as plot_characteristic,
)
from pandapower.control.util.characteristic import Characteristic as Characteristic, SplineCharacteristic as SplineCharacteristic
from pandapower.control.util.diagnostic import (
control_diagnostic as control_diagnostic,
trafo_characteristics_diagnostic as trafo_characteristics_diagnostic,
trafo_characteristic_table_diagnostic as trafo_characteristic_table_diagnostic,
)
6 changes: 4 additions & 2 deletions stubs/pandapower-stubs/control/basic_controller.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Any, SupportsIndex as Int

import numpy as np

from pandapower.auxiliary import pandapowerNet
from pandapower.io_utils import JSONSerializableClass

Expand Down Expand Up @@ -46,10 +48,10 @@ class Controller(BasicCtrl):
drop_same_existing_ctrl: bool,
overwrite: bool,
**kwargs,
) -> int: ...
) -> np.int64: ...
def time_step(self, net: pandapowerNet, time: Any) -> None: ...
def initialize_control(self, net: pandapowerNet) -> None: ...
def is_converged(self, net: pandapowerNet): ...
def is_converged(self, net: pandapowerNet) -> bool | np.bool: ...
def control_step(self, net: pandapowerNet) -> None: ...
def repair_control(self, net: pandapowerNet) -> None: ...
def restore_init_state(self, net: pandapowerNet) -> None: ...
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import numpy as np

from pandapower._typing import Array1D, FloatVectorLike

class BaseModel:
@classmethod
def name(cls) -> str: ...

class QVCurve:
vm_points_pu: FloatVectorLike
q_points_pu: FloatVectorLike
def __init__(self, vm_points_pu: FloatVectorLike, q_points_pu: FloatVectorLike) -> None: ...
def step(self, vm_pu) -> Array1D[np.float64]: ...

class CosphiVCurve:
vm_points_pu: FloatVectorLike
cosphi_points: FloatVectorLike
cosphi_pos: Array1D[np.float64]
def __init__(self, vm_points_pu: FloatVectorLike, cosphi_points: FloatVectorLike) -> None: ...
def step(self, vm_pu, p_pu) -> Array1D[np.float64]: ...

class CosphiPCurve:
p_points_pu: FloatVectorLike
cosphi_points: FloatVectorLike
cosphi_pos: Array1D[np.float64]
def __init__(self, p_points_pu: FloatVectorLike, cosphi_points: FloatVectorLike) -> None: ...
def step(self, p_pu) -> Array1D[np.float64]: ...
146 changes: 146 additions & 0 deletions stubs/pandapower-stubs/control/controller/DERController/PQVAreas.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import numpy as np
import shapely

from pandapower._typing import Array1D, Array2D, Float, FloatVectorLike
from pandapower.control.controller.DERController.DERBasics import BaseModel

class BaseArea(BaseModel):
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array1D[np.bool]: ...
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...

class BasePQVArea(BaseArea):
raise_merge_overlap: bool
def __init__(self, raise_merge_overlap: bool = True) -> None: ...
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array1D[np.bool]: ...
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...

class PQAreaPOLYGON(BaseArea):
p_points_pu: FloatVectorLike
q_points_pu: FloatVectorLike
polygon: shapely.Polygon
def __init__(self, p_points_pu: FloatVectorLike, q_points_pu: FloatVectorLike) -> None: ...
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array1D[np.bool]: ...
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array2D[np.float64]: ...

class QVAreaPOLYGON(BaseArea):
q_points_pu: FloatVectorLike
vm_points_pu: FloatVectorLike
polygon: shapely.Polygon
def __init__(self, q_points_pu: FloatVectorLike, vm_points_pu: FloatVectorLike) -> None: ...
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array1D[np.bool]: ...
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...

class PQVAreaPOLYGON(BasePQVArea):
pq_area: PQAreaPOLYGON
qv_area: QVAreaPOLYGON
def __init__(
self,
p_points_pu: FloatVectorLike,
q_pq_points_pu: FloatVectorLike,
q_qv_points_pu: FloatVectorLike,
vm_points_pu: FloatVectorLike,
raise_merge_overlap: bool = True,
) -> None: ...

class PQAreaSTATCOM(BaseArea):
min_q_pu: FloatVectorLike
max_q_pu: FloatVectorLike
def __init__(self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike) -> None: ...
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array1D[np.bool]: ...
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array2D[np.float64]: ...

class PQArea4120(BaseArea):
version: int
p_points_pu: list[float]
min_q_pu: FloatVectorLike
max_q_pu: FloatVectorLike
q_max_under_p_point: float
linear_factor_ind: FloatVectorLike
linear_factor_cap: FloatVectorLike
def __init__(self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike, version: int = 2018, **kwargs) -> None: ...
def in_area(self, p_pu: FloatVectorLike, q_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array1D[np.bool]: ...
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike | None = None) -> Array2D[np.float64]: ...

class QVArea4120(BaseArea):
min_q_pu: FloatVectorLike
max_q_pu: FloatVectorLike
max_vm_pu: float
min_vm_pu: float
delta_vm_pu: float
linear_factor: FloatVectorLike
def __init__(self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike) -> None: ...
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...

class PQVArea4120Base(BasePQVArea):
pq_area: PQArea4120
qv_area: QVArea4120
def __init__(
self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike, version: int = 2018, raise_merge_overlap: bool = True
) -> None: ...

class PQVArea4120V1(PQVArea4120Base):
def __init__(self, version: int = 2018, raise_merge_overlap: bool = True) -> None: ...

class PQVArea4120V2(PQVArea4120Base):
def __init__(self, version: int = 2018, raise_merge_overlap: bool = True) -> None: ...

class PQVArea4120V3(PQVArea4120Base):
def __init__(self, version: int = 2018, raise_merge_overlap: bool = True) -> None: ...

class PQArea4130(PQArea4120):
def __init__(self, min_q_pu, max_q_pu) -> None: ...

class QVArea4130(QVArea4120):
min_q_pu: FloatVectorLike
max_q_pu: FloatVectorLike
vn_kv: Float
variant: int
min_vm_points_pu: Array1D[np.float64]
max_vm_points_pu: Array1D[np.float64]
min_q_points_pu: Array1D[np.float64]
max_q_points_pu: Array1D[np.float64]
def __init__(self, min_q_pu: FloatVectorLike, max_q_pu: FloatVectorLike, vn_kv: Float, variant: int) -> None: ...
def q_flexibility(self, p_pu: FloatVectorLike, vm_pu: FloatVectorLike) -> Array2D[np.float64]: ...

class PQVArea4130Base(BasePQVArea):
pq_area: PQArea4130
qv_area: QVArea4130
def __init__(
self,
min_q_pu: FloatVectorLike,
max_q_pu: FloatVectorLike,
variant: int,
vn_kv: Float = 380,
raise_merge_overlap: bool = True,
) -> None: ...

class PQVArea4130V1(PQVArea4130Base):
def __init__(self, vn_kv: Float = 380, raise_merge_overlap: bool = True) -> None: ...

class PQVArea4130V2(PQVArea4130Base):
def __init__(self, vn_kv: Float = 380, raise_merge_overlap: bool = True) -> None: ...

class PQVArea4130V3(PQVArea4130Base):
def __init__(self, vn_kv: Float = 380, raise_merge_overlap: bool = True) -> None: ...

class PQArea4110(PQAreaPOLYGON):
def __init__(self) -> None: ...

class QVArea4110(QVAreaPOLYGON):
def __init__(self) -> None: ...

class PQVArea4110(BasePQVArea):
pq_area: PQArea4110
qv_area: QVArea4110
def __init__(self, raise_merge_overlap: bool = True) -> None: ...

class PQArea4105(PQAreaPOLYGON):
def __init__(self, variant: int) -> None: ...

class QVArea4105(QVAreaPOLYGON):
def __init__(self, variant: int) -> None: ...

class PQVArea4105(BasePQVArea):
pq_area: PQArea4105
qv_area: QVArea4105
def __init__(self, variant: int, raise_merge_overlap: bool = True) -> None: ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from _typeshed import Incomplete

import numpy as np

from pandapower._typing import Float
from pandapower.control.controller.DERController.DERBasics import BaseModel, CosphiPCurve, CosphiVCurve, QVCurve

class QModel(BaseModel):
def __init__(self, **kwargs) -> None: ...
def step(self, vm_pu=None, p_pu=None): ...

class QModelConstQ(QModel):
q_pu: Incomplete
def __init__(self, q_pu) -> None: ...
def step(self, vm_pu=None, p_pu=None): ...

class QModelCosphiVCurve(QModel):
cosphi_v_curve: CosphiVCurve
def __init__(self, cosphi_v_curve: dict[str, Incomplete] | CosphiVCurve) -> None: ...
def step(self, vm_pu, p_pu=None): ... # type: ignore[override]

class QModelCosphiP(QModel):
cosphi: Float
q_setpoint_pu: np.float64
def __init__(self, cosphi: Float) -> None: ...
def step(self, vm_pu=None, p_pu=None): ...

class QModelCosphiSn(QModel):
cosphi: Float
def __init__(self, cosphi: Float = 0.2) -> None: ...
def step(self, vm_pu=None, p_pu=None): ...

class QModelCosphiPQ(QModel):
cosphi: Float
q_setpoint_pu: np.float64
def __init__(self, cosphi: Float) -> None: ...
def step(self, vm_pu=None, p_pu=None): ...

class QModelCosphiPCurve(QModel):
cosphi_p_curve: CosphiPCurve
def __init__(self, cosphi_p_curve) -> None: ...
def step(self, vm_pu=None, p_pu=None): ...

class QModelQVCurve(QModel):
qv_curve: QVCurve
def __init__(self, qv_curve: dict[str, Incomplete] | QVCurve) -> None: ...
def step(self, vm_pu, p_pu=None): ... # type: ignore[override]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .der_control import *
from .DERBasics import *
from .PQVAreas import *
from .QModels import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pandapower.auxiliary import pandapowerNet
from pandapower.control.controller.pq_control import PQController

class DERController(PQController):
def __init__(
self,
net: pandapowerNet,
element_index,
element: str = "sgen",
q_model=None,
pqv_area=None,
saturate_sn_mva=...,
q_prio=True,
damping_coef=2,
max_p_error=1e-6,
max_q_error=1e-6,
pq_simultaneity_factor=1.0,
f_sizing=1.0,
data_source=None,
p_profile=None,
profile_from_name=False,
profile_scale=1.0,
in_service=True,
ts_absolute=True,
order=0,
level=0,
drop_same_existing_ctrl=False,
matching_params=None,
**kwargs,
) -> None: ...
def time_step(self, net: pandapowerNet, time) -> None: ...
def is_converged(self, net: pandapowerNet) -> bool: ...
def control_step(self, net: pandapowerNet) -> None: ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from matplotlib.axes import Axes

from pandapower._typing import Float, Int

def plot_pq_area(
pq_area,
*,
title: str | None = None,
ax: Axes | None = None,
saturate_sn_pu: Float = ...,
circle_segment: Int = 90,
p_samples=None,
tex: bool = False,
) -> None: ...
def plot_qv_area(qv_area, title=None, ax: Axes | None = None, prune_to_flexibility=False, vm_samples=None, tex: bool = False): ...
def generate_circle_segment(center_x, center_y, radius, start, stop, step): ...
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
from _typeshed import Incomplete

import numpy as np

from pandapower.auxiliary import pandapowerNet
from pandapower.control.basic_controller import Controller

class CharacteristicControl(Controller):
input_element: Incomplete
input_element: str
input_element_index: Incomplete
output_element: Incomplete
output_element: str
output_element_index: Incomplete
characteristic_index: Incomplete
tol: Incomplete
tol: float
applied: bool
values: Incomplete
def __init__(
self,
net,
output_element,
output_variable,
net: pandapowerNet,
output_element: str,
output_variable: str,
output_element_index,
input_element,
input_variable,
input_element: str,
input_variable: str,
input_element_index,
characteristic_index,
tol: float = 0.001,
in_service: bool = True,
order: int = 0,
level: int = 0,
drop_same_existing_ctrl: bool = False,
matching_params: Incomplete | None = None,
matching_params=None,
**kwargs,
) -> None: ...
def initialize_control(self, net) -> None: ...
def is_converged(self, net): ...
def control_step(self, net) -> None: ...
def initialize_control(self, net: pandapowerNet) -> None: ...
def is_converged(self, net: pandapowerNet) -> bool | np.bool: ...
def control_step(self, net: pandapowerNet) -> None: ...
Loading