Skip to content

Branch switching events for applications - #610

Merged
pelesh merged 10 commits into
developfrom
lukel/component-enable-dev
Oct 14, 2026
Merged

pelesh merged 10 commits into
developfrom
lukel/component-enable-dev

Conversation

@lukelowry

@lukelowry lukelowry commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds solver events that take a branch in and out of service. Part 1 of #606, modern attempt of #391. This Branch model is designed specifically for ContingencyAnalysis , as introducing breaker and relay raises the same problem we faced with BusFault. Next PR will be a smooth breaker and relay.

@pelesh

(+ Added worked out examples with diagrams to demonstrate topology scenarios that may be encountered and how that impacts the Jacobian)

Proposed changes

  • Branch::setEnabled(bool), Implemented using an admittance mask on the branch equations.
  • SystemModel::getComponent(id) looks up a branch by its case-file id.
  • Solver events enable / disable take a device id and are handled like fault events.
  • Example DynamicSimulation/Toy/ThreeBusBasic: BR_1_2 opens at 1 s and recloses at 5 s.
  • Tests: BranchTests::singularJacobian (pattern kept, values zero)

Checklist

  • All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • The CHANGELOG.md has been updated to reflect the changes.

Further comments

  • Islanding is not handled yet

Repsonse

ThreeBusBasic speed

@lukelowry
lukelowry requested a review from pelesh October 5, 2026 20:38
@lukelowry
lukelowry force-pushed the lukel/component-enable-dev branch 2 times, most recently from 1df5bb8 to 959899f Compare October 6, 2026 08:29
@nkoukpaizan nkoukpaizan added the development Features/Tools related to development of GridKit, rather than use as a library. label Oct 6, 2026
@lukelowry
lukelowry force-pushed the lukel/component-enable-dev branch from 959899f to 3cb2a38 Compare October 6, 2026 20:54
@nkoukpaizan nkoukpaizan added new study New study or event capability and removed development Features/Tools related to development of GridKit, rather than use as a library. labels Oct 6, 2026

@pelesh pelesh left a comment

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.

Great work!

There is one major item that needs to be addressed and that is to identify cases when taking line out of service makes underlying linear system singular. That needs to be clearly identified in this PR, so that a remedy can be implemented subsequently.

My guess is that islanding would be one such instance. This can be easily checked with ten-gen example. There may be other instances where zeroing out branch Jacobian stamp may lead to singular system Jacobian.

@abirchfield and @shakedregev: please chime in.

The rest are nitpicking suggestions.

Comment thread GridKit/Model/PhasorDynamics/Branch/Branch.hpp Outdated
Comment thread application/PhasorDynamics/ContingencyAnalysis.cpp Outdated
Comment thread application/PhasorDynamics/DynamicSimulation.cpp Outdated
Comment thread application/PhasorDynamics/README.md Outdated
Comment thread GridKit/Model/PhasorDynamics/Branch/BranchImpl.hpp Outdated
@lukelowry

Copy link
Copy Markdown
Collaborator Author

Addressed!

@lukelowry
lukelowry requested a review from pelesh October 6, 2026 22:02
@lukelowry
lukelowry force-pushed the lukel/component-enable-dev branch 2 times, most recently from d24aae9 to f48c538 Compare October 10, 2026 21:02
@lukelowry

lukelowry commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

@pelesh Four examples added of some trivial and non trivial examples that we may feasibly run into, in Branch/README.md

success *= isEqual(bus.Ir(), ScalarT{0.0});
success *= isEqual(bus.Ii(), ScalarT{0.0});

// Both voltage variables remain, but their KCL rows are identically zero.

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.

Where do you set the diagonal on the removed rows to 1?

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.

This implementation does not do such, because its not clear how to determine when that should be done (algo for algebraic connectivity, which we could implement but it would certainly be flaky)

@shakedregev shakedregev Oct 12, 2026 •

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.

If a row + column is all 0s, set diagonal to 1. So how are you dealing with this?

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.

That is not the only path to singular Jacobian, for example: (Branch/README.md)

image

And an edge case that is feasible but not probable:

image

Applications like MATPOWER or PSSE have island-detection but that is not a catch-all. The goal is to be able to catch/detect these scenarios and communicate an expected failure to converge. Any assistance appreciated

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.

Are the matrices symmetric? If they are, then any symmetric matrix has what's known as an LBL^T factorization. L is lower triangular and B has 1X1 or 2x2 blocks on the diagonal. If any of those blocks are singular, the matrix is singular.

What does red convey? A removed element?

@lukelowry lukelowry Oct 12, 2026 •

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.

No unfortunately because of the tap&phase shifting transformer model the admittance matrix is not guaranteed to be Hermitian

And yes red was my attempt to indicate "this element has just been removed"

@shakedregev shakedregev Oct 12, 2026 •

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.

If you just want to flag a problematic system, you can use rank revealing LU (I think KLU does this). If you factorize to L*U, by convention L has a diagonal of 1s. So you will get some 0s on the diagonals of U, say in place $U_{j,j}$. Simply set $U_{j,j}=1$, $U_{i<j,j}=0$, $L_{j,i}<j=0$ for all such $j$ s. This will solve an equivalent system to the original one, except it will be nonsingular. Whatever value you get for $x_j$ will just be meaningless.

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.

You may have to use SPQR.

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.

If all examples fall into 0s on the diagonal, or singular 2X2 blocks, you can simply check for these. You can fix the first by setting the diagonal to 1. For the 2X2, I think it depends on the domain knowledge of what this actually means, but maybe setting the off diagonals to 0 is sufficient.

@pelesh pelesh left a comment

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.

I think this can be merged as preliminary capability to take branches out of service. Follow up work should include:

  • Better documentation and more examples on possible singular systems when a branch is taken out of service.
  • Ability to access branches through a unique ID at O(1) complexity (see #370).
  • Remediation of singular systems.

This branch needs rebasing before merging.

Comment thread GridKit/Model/PhasorDynamics/SystemModel.hpp Outdated
@lukelowry
lukelowry force-pushed the lukel/component-enable-dev branch from 0496367 to e747476 Compare October 13, 2026 22:04
Co-authored-by: pelesh <peless@ornl.gov>
@lukelowry

Copy link
Copy Markdown
Collaborator Author

Rebased! I think its ready.

@pelesh
pelesh merged commit c077b17 into develop Oct 14, 2026
6 checks passed
@lukelowry
lukelowry deleted the lukel/component-enable-dev branch October 14, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new study New study or event capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants