Skip to content

fix: handle zero reactances - #892

Open
BenjPetr wants to merge 2 commits into
mainfrom
fix/zero_x_elements
Open

BenjPetr wants to merge 2 commits into
mainfrom
fix/zero_x_elements

Conversation

@BenjPetr

@BenjPetr BenjPetr commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Signed-off-by: Benjamin Petrick 170433522+BenjPetr@users.noreply.github.com

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?

Closes #838

What is the new behavior and why?

introduction of a zero reactance threshold parameter to handle data issues

Does this PR introduce a breaking change?

  • Yes, because
  • No

Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 12:02
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>

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.

🟡 Changes recommended

Reactance regularization corrupts valid negative reactances and tap susceptances while leaving DC-flow corrections inconsistent with the solver’s modified model.

3 open issues
What changed in this PR

This PR adds configurable reactance flooring to the Powsybl preprocessing backend to keep zero-reactance branches from producing undefined DC solver results.

Changes:

  • Adds a nonnegative reactance threshold, defaulting to 1e-6, and passes it into the backend.
  • Floors branch reactances below the configured threshold.
  • Adds a regression test checking finite susceptances and PTDF values for a zero-reactance line and transformer.
File Description
packages/​interfaces_pkg/​src/​toop_engine_interfaces/​messages/​preprocess/​preprocess_commands.py Defines and documents the threshold parameter.
packages/​dc_solver_pkg/​tests/​preprocessing/​test_powsybl_backend.py Tests zero-reactance branch handling and finite PTDF results.
packages/​dc_solver_pkg/​src/​toop_engine_dc_solver/​preprocess/​powsybl/​powsybl_backend.py Accepts the threshold and applies reactance flooring.
packages/​dc_solver_pkg/​src/​toop_engine_dc_solver/​preprocess/​convert_to_jax.py Passes the preprocessing threshold to the Powsybl backend.

Review effort: Balanced

)
branches[["p_max_mw", "p_max_mw_n_1"]] = get_p_max(self.net)
if self.zero_reactances_threshold > 0.0:
branches.loc[branches["x"] < self.zero_reactances_threshold, "x"] = self.zero_reactances_threshold
Comment on lines +225 to +226
if self.zero_reactances_threshold > 0.0:
branches.loc[branches["x"] < self.zero_reactances_threshold, "x"] = self.zero_reactances_threshold
)
branches[["p_max_mw", "p_max_mw_n_1"]] = get_p_max(self.net)
if self.zero_reactances_threshold > 0.0:
branches.loc[branches["x"] < self.zero_reactances_threshold, "x"] = self.zero_reactances_threshold
@sonarqube-mccs

sonarqube-mccs Bot commented Nov 6, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

Intended way to configure/specify excluded elements, monitored elements, relevant substations, and contingencies?

2 participants