Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for operator strategies in security analysis API #621

Merged
merged 28 commits into from Jan 18, 2024

Conversation

obrix
Copy link
Member

@obrix obrix commented Jun 28, 2023

Add support for operator strategies in security analysis API.

#557

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change or deprecate an API?

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
@obrix
Copy link
Member Author

obrix commented Aug 31, 2023

@EtienneLt Some of the actions support are still missing but what do you think of the global approach ?

@EtienneLt
Copy link
Contributor

@EtienneLt Some of the actions support are still missing but what do you think of the global approach ?

Yes the approach is quite good but I have some questions
why do you create active_power actions ? there are also Current, Voltage ...

@obrix
Copy link
Member Author

obrix commented Sep 1, 2023

@EtienneLt Some of the actions support are still missing but what do you think of the global approach ?

Yes the approach is quite good but I have some questions why do you create active_power actions ? there are also Current, Voltage ...

If you are talking about LoadAction it only support active and reactive power modifications. Generator action support active power modification but also regulation / targetV / targetQ. Like discussed in original issue I think we should add an API for each of these use cases. So in the end we should have :

def add_generator_active_power_action

def add_generator_voltage_regulation_action

def add_generator_target_v_action

def add_generator_target_q_action

@obrix
Copy link
Member Author

obrix commented Oct 20, 2023

Development was on hold on this feature, I'll try to finish implementing the last missing features and add some documentation shortly.

Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
@obrix obrix requested a review from geofjamg January 15, 2024 12:39
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Copy link
Member

@geofjamg geofjamg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't yet look deep in the code but just played with the API and look at results:

  • get_table() has not been updated to show operator strategies:
>>> import pypowsybl as pp
>>> n = pp.network.create_eurostag_tutorial_example1_network()
>>> sa = pp.security.create_analysis()
>>> sa.add_single_element_contingency('NHV1_NHV2_1', 'Line contingency')
>>> sa.add_load_active_power_action('LoadAction1', 'LOAD', False, 750.0)
>>> sa.add_operator_strategy('OperatorStrategy1', 'Line contingency', ['LoadAction1'])
>>> sa_result = sa.run_ac(n)
>>> print(sa_result.get_table())
+------------------+-----------+--------------+----------------+--------------+-------+------------+---------------------+-----------------+--------+------+
|  Contingency ID  |   Status  | Equipment ID | Equipment name |  Limit type  | Limit | Limit name | Acceptable duration | Limit reduction | Value  | Side |
+------------------+-----------+--------------+----------------+--------------+-------+------------+---------------------+-----------------+--------+------+
| Line contingency | CONVERGED |              |                |              |       |            |                     |                 |        |      |
|                  |           | NHV1_NHV2_2  |                | HIGH_VOLTAGE | 500.0 | permanent  |      2147483647     |       1.0       | 1047.8 | TWO  |
|                  |           |    VLHV1     |                |     ???      | 400.0 |            |      2147483647     |       1.0       | 398.3  | NONE |
+------------------+-----------+--------------+----------------+--------------+-------+------------+---------------------+-----------------+--------+------+

Also it looks like there is a bug (probably existing) in the limit type, the violation 'high voltage' seems to be a current violation and ??? is not nomal. @obrix could you have a look at it ?

  • Operator strategy result is not printable as for contingency result:
>>> sa_result.find_post_contingency_result('Line contingency')
PostContingencyResult(contingency_id='Line contingency', status=CONVERGED, limit_violations=[2])
>>> sa_result.find_operator_strategy_results('OperatorStrategy1')
<pypowsybl._pypowsybl.OperatorStrategyResult object at 0x7f4fe93ad8b0>
  • Existing problem too but limit_violations should be a list and not just an iterable to allow
>>> sa_result.find_post_contingency_result('Line contingency').limit_violations[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'pypowsybl._pypowsybl.LimitViolationArray' object is not subscriptable

Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
Signed-off-by: Bertrand Rix <bertrand.rix@artelys.com>
@geofjamg geofjamg changed the title [WIP] Support for operator strategies in security analysis API Support for operator strategies in security analysis API Jan 18, 2024
@geofjamg geofjamg merged commit 2fb7b5d into main Jan 18, 2024
6 checks passed
@geofjamg geofjamg deleted the sa_operator_strategies branch January 18, 2024 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants