Skip to content

fix: voltage calculation and max values everywhere#611

Open
LeonHilf wants to merge 6 commits into
mainfrom
fix/voltage_validations
Open

fix: voltage calculation and max values everywhere#611
LeonHilf wants to merge 6 commits into
mainfrom
fix/voltage_validations

Conversation

@LeonHilf

@LeonHilf LeonHilf commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Checklist

Please check if the PR fulfills these requirements:

  • PR Title follows conventional commit messages
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • All commits in this PR are DCO signed-off (see CONTRIBUTING.md)

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?

  • Yes
  • No

Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Copilot AI review requested due to automatic review settings July 3, 2026 11:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_diff to critical_va_diff_degree throughout the topology optimizer.
  • Moves voltage-jump counting in AC metrics to rely on vm_basecase_deviation computed in node-results helpers, and threads a configurable critical_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.

LeonHilf added 5 commits July 6, 2026 16:44
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>
@sonarqube-mccs

sonarqube-mccs Bot commented Jul 7, 2026

Copy link
Copy Markdown



@pytest.mark.timeout(180)
def test_ac_acceptance_off_evaluates_candidates_with_production_flow(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what is production flow?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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)[

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we extend the node result schema here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

vm_basecase_deviation is already part of it. Or do you mean something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants