Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <[email protected]>
  • Loading branch information
geofjamg committed Nov 10, 2023
1 parent 2e2fccc commit ffb06cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pypowsybl/sensitivity/impl/ac_sensitivity_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pypowsybl.loadflow import Parameters as LfParameters
from pypowsybl._pypowsybl import ContingencyContextType, SensitivityFunctionType, SensitivityVariableType
from .ac_sensitivity_analysis_result import AcSensitivityAnalysisResult
from .sensitivity_analysis_result import DEFAULT_MATRIX_ID
from .sensitivity import SensitivityAnalysis
from .parameters import Parameters

Expand All @@ -35,7 +36,7 @@ def set_bus_voltage_factor_matrix(self, bus_ids: List[str], target_voltage_ids:
"""
self.add_bus_voltage_factor_matrix(bus_ids, target_voltage_ids)

def add_bus_voltage_factor_matrix(self, bus_ids: List[str], target_voltage_ids: List[str], matrix_id: str = 'default') -> None:
def add_bus_voltage_factor_matrix(self, bus_ids: List[str], target_voltage_ids: List[str], matrix_id: str = DEFAULT_MATRIX_ID) -> None:
"""
Defines buses voltage sensitivities to be computed.
Expand Down
11 changes: 5 additions & 6 deletions pypowsybl/sensitivity/impl/sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

from pypowsybl import _pypowsybl
from pypowsybl.security import ContingencyContainer
from .sensitivity_analysis_result import DEFAULT_MATRIX_ID, TO_REMOVE
from pypowsybl._pypowsybl import PyPowsyblError, ContingencyContextType, SensitivityFunctionType, SensitivityVariableType
from .zone import Zone

TO_REMOVE = 'TO_REMOVE'


class SensitivityAnalysis(ContingencyContainer):
""" Base class for sensitivity analysis. Do not instantiate it directly!"""
Expand Down Expand Up @@ -74,7 +73,7 @@ def set_branch_flow_factor_matrix(self, branches_ids: List[str], variables_ids:
self.add_branch_flow_factor_matrix(branches_ids, variables_ids)

def add_branch_flow_factor_matrix(self, branches_ids: List[str], variables_ids: List[str],
matrix_id: str = 'default') -> None:
matrix_id: str = DEFAULT_MATRIX_ID) -> None:
"""
Defines branch active power flow factor matrix, with a list of branches IDs and a list of variables.
Expand All @@ -92,7 +91,7 @@ def add_branch_flow_factor_matrix(self, branches_ids: List[str], variables_ids:
SensitivityFunctionType.BRANCH_ACTIVE_POWER_1, SensitivityVariableType.AUTO_DETECT, matrix_id)

def add_precontingency_branch_flow_factor_matrix(self, branches_ids: List[str], variables_ids: List[str],
matrix_id: str = 'default') -> None:
matrix_id: str = DEFAULT_MATRIX_ID) -> None:
"""
Defines branch active power flow factor matrix for the base case, with a list of branches IDs and a list of variables.
Expand All @@ -111,7 +110,7 @@ def add_precontingency_branch_flow_factor_matrix(self, branches_ids: List[str],

def add_postcontingency_branch_flow_factor_matrix(self, branches_ids: List[str], variables_ids: List[str],
contingencies_ids: List[str],
matrix_id: str = 'default') -> None:
matrix_id: str = DEFAULT_MATRIX_ID) -> None:
"""
Defines branch active power flow factor matrix for specific post contingencies states, with a list of branches IDs and a list of variables.
Expand All @@ -133,7 +132,7 @@ def add_factor_matrix(self, functions_ids: List[str], variables_ids: List[str],
contingency_context_type: ContingencyContextType,
sensitivity_function_type: SensitivityFunctionType,
sensitivity_variable_type: SensitivityVariableType = SensitivityVariableType.AUTO_DETECT,
matrix_id: str = 'default') -> None:
matrix_id: str = DEFAULT_MATRIX_ID) -> None:
"""
Defines branch active power factor matrix, with a list of branches IDs and a list of variables.
Expand Down
4 changes: 2 additions & 2 deletions pypowsybl/sensitivity/impl/sensitivity_analysis_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def __init__(self,
self.function_data_frame_index = function_data_frame_index

@staticmethod
def clean_contingency_id(contingency_id):
def clean_contingency_id(contingency_id: str) -> str:
return '' if contingency_id is None else contingency_id

def process_ptdf(self, df, matrix_id):
def process_ptdf(self, df: pd.DataFrame, matrix_id: str) -> pd.DataFrame:
# substract second power transfer zone to first one
i = 0
while i < len(self.function_data_frame_index[matrix_id]):
Expand Down

0 comments on commit ffb06cc

Please sign in to comment.