Skip to content

Commit

Permalink
Fix generator action with non relative target P (#693)
Browse files Browse the repository at this point in the history
Signed-off-by: Bertrand Rix <[email protected]>
  • Loading branch information
obrix authored Jan 29, 2024
1 parent 3747f49 commit 87b7004
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,9 @@ public static void addGeneratorActivePowerAction(IsolateThread thread, ObjectHan
String actionIdStr = CTypeUtil.toString(actionId);
String generatorIdStr = CTypeUtil.toString(generatorId);
GeneratorActionBuilder builder = new GeneratorActionBuilder().withId(actionIdStr)
.withGeneratorId(generatorIdStr);
if (relativeValue) {
builder.withActivePowerRelativeValue(relativeValue);
}
builder.withActivePowerValue(activePower);
.withGeneratorId(generatorIdStr)
.withActivePowerRelativeValue(relativeValue)
.withActivePowerValue(activePower);
analysisContext.addAction(builder.build());
});
}
Expand Down
13 changes: 13 additions & 0 deletions tests/test_security_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,19 @@ def test_load_action_with_all_violation_condition():
assert len(sa_result.find_operator_strategy_results('OperatorStrategy1').limit_violations) == 3
assert 'OperatorStrategy2' not in sa_result.operator_strategy_results.keys()

def test_generator_action():
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_generator_active_power_action(action_id='GeneratorActionAbsolute', generator_id='GEN', is_relative=False, active_power=750.0)
sa.add_generator_active_power_action(action_id='GeneratorActionRelative', generator_id='GEN', is_relative=True, active_power=150.0)
sa.add_operator_strategy('OperatorStrategy1', 'Line contingency', ['GeneratorActionAbsolute'])
sa.add_operator_strategy('OperatorStrategy2', 'Line contingency', ['GeneratorActionRelative'])
sa_result = sa.run_ac(n)
assert 'Line contingency' in sa_result.post_contingency_results.keys()
assert 'OperatorStrategy1' in sa_result.operator_strategy_results.keys()
assert 'OperatorStrategy2' in sa_result.operator_strategy_results.keys()

def test_switch_action():
n = pp.network.create_four_substations_node_breaker_network()
sa = pp.security.create_analysis()
Expand Down

0 comments on commit 87b7004

Please sign in to comment.