fix: voltage calculation and max values everywhere#611
Conversation
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
There was a problem hiding this comment.
Pull request overview
This PR updates AC validation/scoring to use explicit “critical” thresholds for voltage-angle differences and voltage jumps, and ensures voltage jump counting is based on a precomputed basecase deviation (vm_basecase_deviation) across backends.
Changes:
- Renames and propagates the AC angle-difference threshold parameter from
max_allowed_va_difftocritical_va_diff_degreethroughout the topology optimizer. - Moves voltage-jump counting in AC metrics to rely on
vm_basecase_deviationcomputed in node-results helpers, and threads a configurablecritical_voltage_jump_threshold. - Updates benchmark output generation to pass AC validation thresholds into metric computation, and adds/adjusts tests around the new behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/topology_optimizer_pkg/tests/ac/test_ac_scoring_functions.py | Updates scoring parameter names in tests and adjusts mocking expectations for voltage-jump counting. |
| packages/topology_optimizer_pkg/src/toop_engine_topology_optimizer/benchmark/benchmark_utils.py | Threads AC validation config into metric summary generation. |
| packages/topology_optimizer_pkg/src/toop_engine_topology_optimizer/ac/scoring_functions.py | Renames/threads critical thresholds into metric computation and simplifies voltage-jump counting integration. |
| packages/topology_optimizer_pkg/src/toop_engine_topology_optimizer/ac/optimizer.py | Updates optimizer call sites to pass critical_va_diff_degree. |
| packages/contingency_analysis_pkg/tests/powsybl/test_ca_powsybl_helpers_polars.py | Adds test coverage for vm_basecase_deviation computation in Polars node results. |
| packages/contingency_analysis_pkg/tests/ac_service/test_compute_metrics.py | Adjusts compute-metrics tests for new voltage-jump threshold plumbing. |
| packages/contingency_analysis_pkg/src/toop_engine_contingency_analysis/pypowsybl/powsybl_helpers.py | Computes and exports vm_basecase_deviation for Pandas node results. |
| packages/contingency_analysis_pkg/src/toop_engine_contingency_analysis/pypowsybl/powsybl_helpers_polars.py | Computes and exports vm_basecase_deviation for Polars node results. |
| packages/contingency_analysis_pkg/src/toop_engine_contingency_analysis/ac_loadflow_service/compute_metrics.py | Updates voltage-jump counting to use vm_basecase_deviation and adds a configurable critical jump threshold. |
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
|
|
|
||
|
|
||
| @pytest.mark.timeout(180) | ||
| def test_ac_acceptance_off_evaluates_candidates_with_production_flow( |
There was a problem hiding this comment.
what is production flow?
There was a problem hiding this comment.
The _run_ac_epoch flow with fast failing and remaning loadflows
| failed_node_results = get_failed_node_results(timestep, failed_outages, monitored_buses) | ||
|
|
||
| all_node_results = pd.concat([node_results, failed_node_results], axis=0)[["vm", "va", "vm_loading"]] | ||
| all_node_results = pd.concat([node_results, failed_node_results], axis=0)[ |
There was a problem hiding this comment.
Should we extend the node result schema here?
There was a problem hiding this comment.
vm_basecase_deviation is already part of it. Or do you mean something else?




Checklist
Please check if the PR fulfills these requirements:
Does this PR already have an issue describing the problem?
Fixes #
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change?