Skip to content

Commit

Permalink
fix and waiting for powsybl correction
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
  • Loading branch information
EtienneLt committed Feb 15, 2024
1 parent 4993a56 commit 7697eb9
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cpp/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ PYBIND11_MODULE(_pypowsybl, m) {
py::enum_<contingency_context_type>(m, "ContingencyContextType")
.value("ALL", contingency_context_type::ALL)
.value("NONE", contingency_context_type::NONE)
.value("SPECIFIC", contingency_context_type::SPECIFIC);
.value("SPECIFIC", contingency_context_type::SPECIFIC)
.value("ONLY_CONTINGENCIES", contingency_context_type::ONLY_CONTINGENCIES);

py::enum_<sensitivity_function_type>(m, "SensitivityFunctionType")
.value("BRANCH_ACTIVE_POWER_1", sensitivity_function_type::BRANCH_ACTIVE_POWER_1)
Expand Down
1 change: 1 addition & 0 deletions cpp/src/pypowsybl-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ typedef enum {
ALL = 0,
NONE,
SPECIFIC,
ONLY_CONTINGENCIES,
} contingency_context_type;

typedef enum {
Expand Down
3 changes: 0 additions & 3 deletions docs/user_guide/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Information can be obtained on buses, branches and three windings transformers.
>>> security_analysis.add_single_element_contingency('NHV1_NHV2_1', 'NHV1_NHV2_1')
>>> security_analysis.add_single_element_contingency('NGEN_NHV1', 'NGEN_NHV1')
>>> security_analysis.add_monitored_elements(voltage_level_ids=['VLHV2'])
>>> security_analysis.add_monitored_elements(voltage_level_ids=['VLHV2'], contingency_ids=['NHV1_NHV2_1', 'NGEN_NHV1'])
>>> security_analysis.add_postcontingency_monitored_elements(branch_ids=['NHV1_NHV2_2'], contingency_ids=['NHV1_NHV2_1', 'NGEN_NHV1'])
>>> security_analysis.add_postcontingency_monitored_elements(branch_ids=['NHV1_NHV2_1'], contingency_ids='NGEN_NHV1')
>>> security_analysis.add_precontingency_monitored_elements(branch_ids=['NHV1_NHV2_2'])
Expand All @@ -75,8 +74,6 @@ Information can be obtained on buses, branches and three windings transformers.
v_mag v_angle
contingency_id operator_strategy_id voltage_level_id bus_id
VLHV2 NHV2 389.95 -3.51
NGEN_NHV1 VLHV2 NHV2 569.04 -1.71
NHV1_NHV2_1 VLHV2 NHV2 366.58 -7.50
>>> results.branch_results
p1 q1 i1 p2 q2 i2 flow_transfer
contingency_id operator_strategy_id branch_id
Expand Down
Binary file added java/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,9 @@ public enum RawContingencyContextType {

ALL,
NONE,
SPECIFIC;
SPECIFIC,

ONLY_CONTINGENCIES;

@CEnumValue
public native int getCValue();
Expand Down
1 change: 1 addition & 0 deletions java/src/main/java/com/powsybl/python/commons/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public static ContingencyContextType convert(PyPowsyblApiHeader.RawContingencyCo
case ALL -> ContingencyContextType.ALL;
case NONE -> ContingencyContextType.NONE;
case SPECIFIC -> ContingencyContextType.SPECIFIC;
case ONLY_CONTINGENCIES -> ContingencyContextType.ONLY_CONTINGENCIES;
};
}

Expand Down
1 change: 1 addition & 0 deletions pypowsybl/_pypowsybl.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ContingencyContextType:
ALL: ClassVar[ContingencyContextType] = ...
NONE: ClassVar[ContingencyContextType] = ...
SPECIFIC: ClassVar[ContingencyContextType] = ...
ONLY_CONTINGENCIES: ClassVar[ContingencyContextType] = ...
def __init__(self, arg0: int) -> None: ...
def __eq__(self, arg0: object) -> bool: ...
def __getstate__(self) -> int: ...
Expand Down
3 changes: 2 additions & 1 deletion pypowsybl/security/impl/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def add_monitored_elements(self, contingency_context_type: ContingencyContextTyp
"""

if contingency_context_type in (ContingencyContextType.ALL, ContingencyContextType.NONE) and contingency_ids:
contingency_context_type = ContingencyContextType.SPECIFIC
raise ValueError('Contingencies list must be empty when defining monitored elements '
'for NONE or ALL contingencies')

if three_windings_transformer_ids is None:
three_windings_transformer_ids = []
Expand Down
1 change: 0 additions & 1 deletion tests/test_security_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def test_monitored_elements():

assert bus_results.index.to_frame().columns.tolist() == ['contingency_id', 'operator_strategy_id', 'voltage_level_id', 'bus_id']
assert bus_results.columns.tolist() == ['v_mag', 'v_angle']
print(bus_results)
assert len(bus_results) == 1
assert bus_results.loc['', '', 'VLHV2', 'NHV2']['v_mag'] == pytest.approx(389.95, abs=1e-2)

Expand Down

0 comments on commit 7697eb9

Please sign in to comment.