{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Operator strategy notebook " ], "id": "1b0280a047f95aea" }, { "cell_type": "markdown", "metadata": { "raw_mimetype": "text/markdown" }, "source": [ "This notebook illustrates how to run a security analysis with remedial actions. For a contingency, an operator strategy groups a list of actions and a condition to apply them. This small tutorial is based on a 6 nodes network, called Metrix, that is easily understandable. We are going to simulate contingencies and various operator strategies to show the available features. Network elements can be monitored in pre-contingency state, after a contingency and after each operator strategy." ], "id": "4f07e59e693da262" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.369752Z", "start_time": "2025-09-15T11:41:33.361231Z" } }, "source": [ "import pypowsybl as pp\n", "import pandas as pd\n", "import numpy as np\n", "from pypowsybl._pypowsybl import ConditionType" ], "id": "dc0fa4c0ea4328ed", "outputs": [], "execution_count": 189 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.402804Z", "start_time": "2025-09-15T11:41:33.379187Z" } }, "source": [ "six_nodes = pp.network.create_metrix_tutorial_six_buses_network()" ], "id": "14e8f5d999dd7e91", "outputs": [], "execution_count": 190 }, { "cell_type": "markdown", "metadata": {}, "source": "![6 nodes network](images/network_6_nodes_without_HDVC.png)", "id": "7e21c296f88d2989" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.453853Z", "start_time": "2025-09-15T11:41:33.433647Z" } }, "source": [ "six_nodes.get_network_area_diagram()" ], "id": "3ad43659504d12cf", "outputs": [ { "data": { "text/plain": [ "" ], "image/svg+xml": "\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -48\n \n \n \n \n \n \n \n \n \n \n \n 48\n \n \n \n \n \n \n \n \n \n \n \n \n \n -48\n \n \n \n \n \n \n \n \n \n \n \n 48\n \n \n \n \n \n \n \n \n \n \n \n \n \n -96\n \n \n \n \n \n \n \n \n \n \n \n 96\n \n \n \n \n \n \n \n \n \n \n \n \n \n -96\n \n \n \n \n \n \n \n \n \n \n \n 96\n \n \n \n \n \n \n \n \n \n \n \n \n \n -96\n \n \n \n \n \n \n \n \n \n \n \n 96\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 48\n \n \n \n \n \n \n \n \n \n \n \n -48\n \n \n \n \n \n \n \n \n \n \n \n \n \n 48\n \n \n \n \n \n \n \n \n \n \n \n -48\n \n \n \n \n \n \n \n \n \n \n \n \n \n 96\n \n \n \n \n \n \n \n \n \n \n \n -96\n \n \n \n \n \n \n \n \n \n \n \n \n \n 96\n \n \n \n \n \n \n \n \n \n \n \n -96\n \n \n \n \n \n \n \n \n \n \n \n \n \n 144\n \n \n \n \n \n \n \n \n \n \n \n -144\n \n \n \n \n \n \n \n \n \n \n \n \n \n 144\n \n \n \n \n \n \n \n \n \n \n \n -144\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -144\n \n \n \n \n \n \n \n \n \n \n \n 144\n \n \n \n \n \n \n \n \n \n \n \n \n \n -144\n \n \n \n \n \n \n \n \n \n \n \n 144\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n
NE_poste
\n
\n 380.0 kV / -0.0°
\n
\n
\n
NO_poste
\n
\n 380.0 kV / 0.0°
\n
\n
\n
N_poste
\n
\n 380.0 kV / -0.0°
\n
\n
\n
SE_poste
\n
\n 380.0 kV / -0.1°
\n
\n
\n
SO_poste
\n
\n 380.0 kV / 0.0°
\n
\n
\n
S_poste
\n
\n 380.0 kV / -0.0°
\n
\n
\n
\n
\n" }, "execution_count": 191, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 191 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.514614Z", "start_time": "2025-09-15T11:41:33.508695Z" } }, "source": [ "sa = pp.security.create_analysis()" ], "id": "bcb3ce751e3c18f4", "outputs": [], "execution_count": 192 }, { "cell_type": "markdown", "metadata": { "raw_mimetype": "text/markdown" }, "source": [ "We simulate a contingency on line S_SO_1. When loosing this line, flows are redirected and line S_SO_2 is overloaded. We are going to test various operator strategies to remove the limit violation." ], "id": "e3fce4e38cd1b21a" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.572162Z", "start_time": "2025-09-15T11:41:33.567011Z" } }, "source": [ "sa.add_single_element_contingency('S_SO_1', 'S_SO_1_contingency')" ], "id": "cfb39506a50ada0d", "outputs": [], "execution_count": 193 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.627730Z", "start_time": "2025-09-15T11:41:33.623954Z" } }, "source": [ "sa.add_monitored_elements(branch_ids=['S_SO_2', 'SO_NO_1'])" ], "id": "bd361396f785bcd9", "outputs": [], "execution_count": 194 }, { "cell_type": "markdown", "metadata": {}, "source": [ "We add a current limit on line S_SO_2" ], "id": "7ee406c85a45c88b" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.689327Z", "start_time": "2025-09-15T11:41:33.680899Z" } }, "source": [ "six_nodes.create_operational_limits(pd.DataFrame.from_records(index='element_id', data=[\n", " {'element_id': 'S_SO_2', 'name': 'permanent_limit', 'element_type': 'LINE', 'side': 'TWO',\n", " 'type': 'CURRENT', 'value': 400,\n", " 'acceptable_duration': np.inf, 'is_fictitious': False}\n", " ]))" ], "id": "a91145c3468656aa", "outputs": [], "execution_count": 195 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Detailed topology" ], "id": "4d50fb96cd1231c5" }, { "cell_type": "markdown", "metadata": {}, "source": [ "### SO_poste" ], "id": "9d46aafb1ee45846" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.769801Z", "start_time": "2025-09-15T11:41:33.745198Z" } }, "source": [ "six_nodes.get_single_line_diagram('SO_poste')" ], "id": "d63f9a70d0617c48", "outputs": [ { "data": { "text/plain": [ "" ], "image/svg+xml": "\n\n \n \n \n \n \n \n SOO1_1\n \n \n \n SOO1_mnv\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -480\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SO_G1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 96\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SO_NO_1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 96\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SO_NO_2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n AC / DC - VSC\n HVDC1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n AC / DC - VSC\n HVDC2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 144\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n S_SO_1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 144\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n S_SO_2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 480\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SO_L\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -480\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SO_G2\n \n \n \n \n \n \n \n \n\n" }, "execution_count": 196, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 196 }, { "cell_type": "markdown", "metadata": {}, "source": [ "### SE_poste" ], "id": "c9fdaeda67f90947" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.840565Z", "start_time": "2025-09-15T11:41:33.820027Z" } }, "source": [ "six_nodes.get_single_line_diagram('SE_poste')" ], "id": "d1c444ff76b5274a", "outputs": [ { "data": { "text/plain": [ "" ], "image/svg+xml": "\n\n \n \n \n \n \n \n SEI1_1\n \n \n \n SEI1_mnv\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SE_G\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -144\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n S_SE_1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -144\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n S_SE_2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -96\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SE_NE_1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n -96\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SE_NE_2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n AC / DC - VSC\n HVDC1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n AC / DC - VSC\n HVDC2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 480\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SE_L1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n SE_L2\n \n \n \n \n \n \n \n \n\n" }, "execution_count": 197, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 197 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Topological remedial actions" ], "id": "9d43113842d0c203" }, { "cell_type": "markdown", "metadata": { "raw_mimetype": "text/markdown" }, "source": [ "You have to add all the actions involved in the strategies you want to test. Here, we want to see the effect of opening switches SS1_SS1_DJ_OMN or/and SOO1_SOO1_DJ_OMN: opening only the first one, only the second one or both.\n", "Operator strategies have the condition ANY_VIOLATION_CONDITION " ], "id": "d6f86589013952a1" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.901914Z", "start_time": "2025-09-15T11:41:33.897759Z" } }, "source": [ "sa.add_switch_action(action_id='Switch_SS1_SS1_DJ_OMN_OPEN', switch_id='SS1_SS1_DJ_OMN', open=True)" ], "id": "647af507098f6e3", "outputs": [], "execution_count": 198 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:33.956010Z", "start_time": "2025-09-15T11:41:33.952334Z" } }, "source": [ "sa.add_switch_action(action_id='Switch_SOO1_SOO1_DJ_OMN_OPEN', switch_id='SOO1_SOO1_DJ_OMN', open=True)" ], "id": "92ae9b8777f508ef", "outputs": [], "execution_count": 199 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.013685Z", "start_time": "2025-09-15T11:41:34.008558Z" } }, "source": [ "sa.add_operator_strategy('StrategyOpenSS1_SS1', 'S_SO_1_contingency', ['Switch_SS1_SS1_DJ_OMN_OPEN'], ConditionType.ANY_VIOLATION_CONDITION) " ], "id": "a92d5ab2f749d3d4", "outputs": [], "execution_count": 200 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.069289Z", "start_time": "2025-09-15T11:41:34.064093Z" } }, "source": [ "sa.add_operator_strategy('StrategyOpenSOO1_SOO1', 'S_SO_1_contingency', ['Switch_SOO1_SOO1_DJ_OMN_OPEN'], ConditionType.ANY_VIOLATION_CONDITION) " ], "id": "519c2de05c20647a", "outputs": [], "execution_count": 201 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.124810Z", "start_time": "2025-09-15T11:41:34.121324Z" } }, "source": [ "sa.add_operator_strategy('StrategyOpenBothSwitchs', 'S_SO_1_contingency', ['Switch_SS1_SS1_DJ_OMN_OPEN', 'Switch_SOO1_SOO1_DJ_OMN_OPEN'], ConditionType.ANY_VIOLATION_CONDITION) " ], "id": "35fa47a5301cf143", "outputs": [], "execution_count": 202 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Redispatch remedial actions" ], "id": "b257fa60aae196ee" }, { "cell_type": "markdown", "metadata": { "raw_mimetype": "text/markdown" }, "source": [ "An other strategy could be to modify the active power target of some generators, in a way the two modifications compensate (also called re-dispatching). Decreasing active power target of generator SO_G2 and increasing active power of SE_G (closer to loads) could be efficient." ], "id": "666ac7b1aa783de9" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.181168Z", "start_time": "2025-09-15T11:41:34.176223Z" } }, "source": [ "sa.add_generator_active_power_action(action_id='Simple_Redispatch_SO_G2', generator_id='SO_G2', is_relative=True, active_power=-100)\n", "sa.add_generator_active_power_action(action_id='Simple_Redispatch_SE_G', generator_id='SE_G', is_relative=True, active_power=100)" ], "id": "5ab7c10f9bd71676", "outputs": [], "execution_count": 203 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.238793Z", "start_time": "2025-09-15T11:41:34.235181Z" } }, "source": [ "sa.add_operator_strategy('StrategyRedispatch', 'S_SO_1_contingency', ['Simple_Redispatch_SO_G2', 'Simple_Redispatch_SE_G'], ConditionType.ANY_VIOLATION_CONDITION)" ], "id": "bf1ce6bee49176b0", "outputs": [], "execution_count": 204 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Run the security analysis " ], "id": "af204906980f0e20" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.305639Z", "start_time": "2025-09-15T11:41:34.291887Z" } }, "source": [ "sa_result = sa.run_ac(six_nodes)" ], "id": "43ae2463b4d09085", "outputs": [], "execution_count": 205 }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Check the results at each steps" ], "id": "fb32175c4cdfc1ba" }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Pre contingency step" ], "id": "a83c52bfe9b129e5" }, { "cell_type": "markdown", "metadata": {}, "source": [ "We should have no limit violations at the pre contingency state." ], "id": "89166bdd75b36cd" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.356305Z", "start_time": "2025-09-15T11:41:34.349906Z" } }, "source": [ "sa_result.pre_contingency_result" ], "id": "47c05b893ec1b062", "outputs": [ { "data": { "text/plain": [ "PreContingencyResult(, status=CONVERGED, limit_violations=[0])" ] }, "execution_count": 206, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 206 }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Post contingency step" ], "id": "58fa05fb3c90eb27" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then the first contingency trigger the current limit installed on S_SO_2" ], "id": "7e8ed3b0c79c1b18" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.418804Z", "start_time": "2025-09-15T11:41:34.412276Z" } }, "source": [ "sa_result.find_post_contingency_result('S_SO_1_contingency')" ], "id": "5d9ab85a779a3b5d", "outputs": [ { "data": { "text/plain": [ "PostContingencyResult(contingency_id='S_SO_1_contingency', status=CONVERGED, limit_violations=[1])" ] }, "execution_count": 207, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 207 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.484330Z", "start_time": "2025-09-15T11:41:34.474789Z" } }, "source": [ "sa_result.find_post_contingency_result('S_SO_1_contingency').limit_violations[0]" ], "id": "11306df26b311f86", "outputs": [ { "data": { "text/plain": [ "LimitViolation(subject_id='S_SO_2', subject_name='', limit_type=CURRENT, limit=400.0, limit_name='permanent', acceptable_duration=2147483647, limit_reduction=1.0, value=419.25779086638283, side=TWO)" ] }, "execution_count": 208, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 208 }, { "cell_type": "markdown", "metadata": {}, "source": [ "We see that the flow is at 419.25." ], "id": "e571b6f51eb0f24d" }, { "cell_type": "markdown", "metadata": {}, "source": [ "### StrategyOpenSS1_SS1" ], "id": "ecb73b22d5542449" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's check results for StrategyOpenSS1_SS1 :" ], "id": "3d35d85ccb6e31d1" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.547807Z", "start_time": "2025-09-15T11:41:34.540530Z" } }, "source": "sa_result.operator_strategy_results['StrategyOpenSS1_SS1']", "id": "4596b24f0b81143e", "outputs": [ { "data": { "text/plain": [ "OperatorStrategyResult(operator_strategy_id='StrategyOpenSS1_SS1', status=CONVERGED, limit_violations=[0])" ] }, "execution_count": 209, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 209 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.614515Z", "start_time": "2025-09-15T11:41:34.604387Z" } }, "source": [ "sa_result.branch_results.loc['S_SO_1_contingency', 'StrategyOpenSS1_SS1', 'S_SO_2']['i2']" ], "id": "26d5d2be34df1fa7", "outputs": [ { "data": { "text/plain": [ "np.float64(378.3380062100348)" ] }, "execution_count": 210, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 210 }, { "cell_type": "markdown", "metadata": {}, "source": [ "We no longer have a limit violation, and we see that flow on S_SO2 is under 400." ], "id": "3598bf16ad30c1e2" }, { "cell_type": "markdown", "metadata": {}, "source": [ "### StrategyOpenSOO1_SOO1" ], "id": "39bfb255e04836ec" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's check results for StrategyOpenSOO1_SOO1 :" ], "id": "35d7f311615a83d5" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.674994Z", "start_time": "2025-09-15T11:41:34.669052Z" } }, "source": "sa_result.operator_strategy_results['StrategyOpenSOO1_SOO1']", "id": "7771bd4cd9f297b1", "outputs": [ { "data": { "text/plain": [ "OperatorStrategyResult(operator_strategy_id='StrategyOpenSOO1_SOO1', status=CONVERGED, limit_violations=[2])" ] }, "execution_count": 211, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 211 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.737651Z", "start_time": "2025-09-15T11:41:34.731059Z" } }, "source": "sa_result.operator_strategy_results['StrategyOpenSOO1_SOO1'].limit_violations[0]", "id": "9b2f75a1d140e946", "outputs": [ { "data": { "text/plain": [ "LimitViolation(subject_id='SO_NO_1', subject_name='', limit_type=CURRENT, limit=700.0, limit_name=\"10'\", acceptable_duration=1, limit_reduction=1.0, value=1044.4966633667482, side=ONE)" ] }, "execution_count": 212, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 212 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.795858Z", "start_time": "2025-09-15T11:41:34.789530Z" } }, "source": [ "sa_result.operator_strategy_results['StrategyOpenSOO1_SOO1'].limit_violations[1]" ], "id": "8dcd1830734d74a5", "outputs": [ { "data": { "text/plain": [ "LimitViolation(subject_id='SO_NO_1', subject_name='', limit_type=CURRENT, limit=600.0, limit_name='permanent', acceptable_duration=2147483647, limit_reduction=1.0, value=1044.4966633667477, side=TWO)" ] }, "execution_count": 213, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 213 }, { "cell_type": "markdown", "metadata": {}, "source": [ "We see that we have two new limit violation on SO_NO_1. But still no limit violation on S_SO2" ], "id": "acc51c99fff318fb" }, { "cell_type": "markdown", "metadata": {}, "source": [ "### StrategyOpenBothSwitchs" ], "id": "4c7e60050aea7936" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's check results for StrategyOpenBothSwitchs :" ], "id": "6c05427aab4ad741" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.869027Z", "start_time": "2025-09-15T11:41:34.864124Z" } }, "source": "sa_result.operator_strategy_results['StrategyOpenBothSwitchs']", "id": "a61c5a890e6ed82a", "outputs": [ { "data": { "text/plain": [ "OperatorStrategyResult(operator_strategy_id='StrategyOpenBothSwitchs', status=CONVERGED, limit_violations=[2])" ] }, "execution_count": 214, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 214 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.920379Z", "start_time": "2025-09-15T11:41:34.917504Z" } }, "source": [ "sa_result.operator_strategy_results['StrategyOpenSOO1_SOO1'].limit_violations[0]" ], "id": "b6ac97e8f513b01c", "outputs": [ { "data": { "text/plain": [ "LimitViolation(subject_id='SO_NO_1', subject_name='', limit_type=CURRENT, limit=700.0, limit_name=\"10'\", acceptable_duration=1, limit_reduction=1.0, value=1044.4966633667482, side=ONE)" ] }, "execution_count": 215, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 215 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:34.971744Z", "start_time": "2025-09-15T11:41:34.967955Z" } }, "source": [ "sa_result.operator_strategy_results['StrategyOpenSOO1_SOO1'].limit_violations[1]" ], "id": "f187ed1370f6b05b", "outputs": [ { "data": { "text/plain": [ "LimitViolation(subject_id='SO_NO_1', subject_name='', limit_type=CURRENT, limit=600.0, limit_name='permanent', acceptable_duration=2147483647, limit_reduction=1.0, value=1044.4966633667477, side=TWO)" ] }, "execution_count": 216, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 216 }, { "cell_type": "markdown", "metadata": {}, "source": [ "We also have some violations on SO_NO_1 but still no violation on S_SO2." ], "id": "46c16bee67991daa" }, { "cell_type": "markdown", "metadata": {}, "source": [ "### StrategyRedispatch" ], "id": "e4d658e0eb0acf95" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally the StrategyRedispatch :" ], "id": "3a79790e2cc6dff6" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:35.023737Z", "start_time": "2025-09-15T11:41:35.020447Z" } }, "source": "sa_result.operator_strategy_results['StrategyRedispatch']", "id": "e32d2c03037446a0", "outputs": [ { "data": { "text/plain": [ "OperatorStrategyResult(operator_strategy_id='StrategyRedispatch', status=CONVERGED, limit_violations=[0])" ] }, "execution_count": 217, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 217 }, { "cell_type": "markdown", "metadata": {}, "source": [ "No more limit violations !" ], "id": "8b60a6945b213cbf" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Observe the flow on each step of the analysis" ], "id": "b17f517a80399ebd" }, { "cell_type": "markdown", "metadata": {}, "source": [ "To have an overview on the flows on S_SO_2 you can print the whole monitored branche results : " ], "id": "c55402d21b4e20e4" }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:35.094560Z", "start_time": "2025-09-15T11:41:35.080416Z" } }, "source": [ "sa_result.branch_results" ], "id": "118cc45a700bc16", "outputs": [ { "data": { "text/plain": [ " p1 q1 \\\n", "contingency_id operator_strategy_id branch_id \n", " SO_NO_1 54.531480 -110.016475 \n", " S_SO_2 -133.377630 85.519336 \n", "S_SO_1_contingency SO_NO_1 79.418783 -124.999658 \n", " S_SO_2 -249.100890 153.754036 \n", " StrategyOpenSS1_SS1 SO_NO_1 92.554967 -133.720643 \n", " S_SO_2 -226.152625 136.898071 \n", " StrategyOpenSOO1_SOO1 SO_NO_1 451.041734 -580.734940 \n", " S_SO_2 -136.449843 11.254213 \n", " StrategyOpenBothSwitchs SO_NO_1 451.153915 -580.693806 \n", " S_SO_2 -125.372756 9.603396 \n", " StrategyRedispatch SO_NO_1 59.361505 -124.265372 \n", " S_SO_2 -185.947605 155.624093 \n", "\n", " i1 p2 \\\n", "contingency_id operator_strategy_id branch_id \n", " SO_NO_1 174.419119 -53.892618 \n", " S_SO_2 226.042956 134.297347 \n", "S_SO_1_contingency SO_NO_1 210.365186 -78.489460 \n", " S_SO_2 419.257791 252.264878 \n", " StrategyOpenSS1_SS1 SO_NO_1 231.007243 -91.434316 \n", " S_SO_2 378.338006 228.729139 \n", " StrategyOpenSOO1_SOO1 SO_NO_1 1044.496663 -428.131295 \n", " S_SO_2 199.930622 137.169344 \n", " StrategyOpenBothSwitchs SO_NO_1 1044.548275 -428.241212 \n", " S_SO_2 183.434100 125.978421 \n", " StrategyRedispatch SO_NO_1 195.621373 -58.557883 \n", " S_SO_2 346.465621 188.108297 \n", "\n", " q2 i2 \\\n", "contingency_id operator_strategy_id branch_id \n", " SO_NO_1 110.107741 174.419119 \n", " S_SO_2 -85.366050 226.042956 \n", "S_SO_1_contingency SO_NO_1 125.132419 210.365186 \n", " S_SO_2 -153.226705 419.257791 \n", " StrategyOpenSS1_SS1 SO_NO_1 133.880736 231.007243 \n", " S_SO_2 -136.468652 378.338006 \n", " StrategyOpenSOO1_SOO1 SO_NO_1 584.007860 1044.496663 \n", " S_SO_2 -11.134296 199.930622 \n", " StrategyOpenBothSwitchs SO_NO_1 583.967050 1044.548275 \n", " S_SO_2 -9.502452 183.434100 \n", " StrategyRedispatch SO_NO_1 124.380175 195.621373 \n", " S_SO_2 -155.263977 346.465621 \n", "\n", " flow_transfer \n", "contingency_id operator_strategy_id branch_id \n", " SO_NO_1 NaN \n", " S_SO_2 NaN \n", "S_SO_1_contingency SO_NO_1 NaN \n", " S_SO_2 NaN \n", " StrategyOpenSS1_SS1 SO_NO_1 NaN \n", " S_SO_2 NaN \n", " StrategyOpenSOO1_SOO1 SO_NO_1 NaN \n", " S_SO_2 NaN \n", " StrategyOpenBothSwitchs SO_NO_1 NaN \n", " S_SO_2 NaN \n", " StrategyRedispatch SO_NO_1 NaN \n", " S_SO_2 NaN " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
p1q1i1p2q2i2flow_transfer
contingency_idoperator_strategy_idbranch_id
SO_NO_154.531480-110.016475174.419119-53.892618110.107741174.419119NaN
S_SO_2-133.37763085.519336226.042956134.297347-85.366050226.042956NaN
S_SO_1_contingencySO_NO_179.418783-124.999658210.365186-78.489460125.132419210.365186NaN
S_SO_2-249.100890153.754036419.257791252.264878-153.226705419.257791NaN
StrategyOpenSS1_SS1SO_NO_192.554967-133.720643231.007243-91.434316133.880736231.007243NaN
S_SO_2-226.152625136.898071378.338006228.729139-136.468652378.338006NaN
StrategyOpenSOO1_SOO1SO_NO_1451.041734-580.7349401044.496663-428.131295584.0078601044.496663NaN
S_SO_2-136.44984311.254213199.930622137.169344-11.134296199.930622NaN
StrategyOpenBothSwitchsSO_NO_1451.153915-580.6938061044.548275-428.241212583.9670501044.548275NaN
S_SO_2-125.3727569.603396183.434100125.978421-9.502452183.434100NaN
StrategyRedispatchSO_NO_159.361505-124.265372195.621373-58.557883124.380175195.621373NaN
S_SO_2-185.947605155.624093346.465621188.108297-155.263977346.465621NaN
\n", "
" ] }, "execution_count": 218, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 218 }, { "cell_type": "code", "metadata": { "ExecuteTime": { "end_time": "2025-09-15T11:41:35.228244Z", "start_time": "2025-09-15T11:41:35.224977Z" } }, "source": [], "id": "cc1702be081c3fe2", "outputs": [], "execution_count": null } ], "metadata": { "celltoolbar": "Format de la Cellule Texte Brut", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }