Skip to content

Commit

Permalink
Slightly improved typing on the controllable branch
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Oct 28, 2024
1 parent e38badd commit 4200032
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 84 deletions.
71 changes: 12 additions & 59 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/GridCalEngine/Devices/Branches/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
class Transformer2W(ControllableBranchParent):

def __init__(self,
bus_from: Bus = None,
bus_to: Bus = None,
bus_from: Bus | None = None,
bus_to: Bus | None = None,
name='Branch',
idtag: Union[None, str] = None,
idtag: str | None = None,
code: str = '',
cn_from: ConnectivityNode = None,
cn_to: ConnectivityNode = None,
HV: Union[None, float] = None,
LV: Union[None, float] = None,
cn_from: ConnectivityNode | None = None,
cn_to: ConnectivityNode | None = None,
HV: float | None = None,
LV: float | None = None,
nominal_power: float = 0.001,
copper_losses: float = 0.0,
iron_losses: float = 0.0,
Expand Down Expand Up @@ -71,7 +71,7 @@ def __init__(self,
alpha: float = 0.00330,
tap_module_control_mode: TapModuleControl = TapModuleControl.fixed,
tap_phase_control_mode: TapPhaseControl = TapPhaseControl.fixed,
template: TransformerType = None,
template: TransformerType | None = None,
contingency_factor: float = 1.0,
protection_rating_factor: float = 1.4,
contingency_enabled: bool = True,
Expand Down
11 changes: 6 additions & 5 deletions src/GridCalEngine/Devices/Branches/vsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from __future__ import annotations

import pandas as pd
import numpy as np
Expand All @@ -30,12 +31,12 @@
class VSC(ControllableBranchParent):

def __init__(self,
bus_from: Bus = None,
bus_to: Bus = None,
cn_from: ConnectivityNode = None,
cn_to: ConnectivityNode = None,
bus_from: Bus | None = None,
bus_to: Bus | None = None,
cn_from: ConnectivityNode | None = None,
cn_to: ConnectivityNode | None = None,
name='VSC',
idtag=None,
idtag: str | None = None,
code='',
active=True,
r=0.0001,
Expand Down
21 changes: 9 additions & 12 deletions src/GridCalEngine/Devices/Parents/controllable_branch_parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from __future__ import annotations

import numpy as np
from typing import Union
Expand All @@ -29,13 +30,13 @@
class ControllableBranchParent(BranchParent):

def __init__(self,
bus_from: Bus,
bus_to: Bus,
bus_from: Bus | None,
bus_to: Bus | None,
name: str,
idtag: Union[None, str],
idtag: str | None,
code: str,
cn_from: ConnectivityNode,
cn_to: ConnectivityNode,
cn_from: ConnectivityNode | None,
cn_to: ConnectivityNode | None,
active: bool,
rate: float,
r: float,
Expand All @@ -52,13 +53,12 @@ def __init__(self,
vset: float,
Pset: float,
Qset: float,
regulation_branch: Union[BranchParent, None],
regulation_bus: Union[Bus, None],
regulation_cn: Union[ConnectivityNode, None],
regulation_branch: BranchParent | None,
regulation_bus: Bus | None,
regulation_cn: ConnectivityNode | None,
temp_base: float,
temp_oper: float,
alpha: float,
# control_mode: TransformerControlType,
tap_module_control_mode: TapModuleControl,
tap_phase_control_mode: TapPhaseControl,
contingency_factor: float,
Expand Down Expand Up @@ -293,9 +293,6 @@ def __init__(self,
definition='Objective power at the selected side.',
profile_name='Pset_prof', old_names=['Pdc_set'])

# self.register(key='regulation_branch', units='', tpe=DeviceType.BranchDevice,
# definition='Branch where the controls are applied.', editable=False)

self.register(key='temp_base', units='ºC', tpe=float, definition='Base temperature at which R was measured.')
self.register(key='temp_oper', units='ºC', tpe=float, definition='Operation temperature to modify R.',
profile_name='temp_oper_prof')
Expand Down

0 comments on commit 4200032

Please sign in to comment.