Skip to content

Change compute_ac_pf iteration to use more standard (smaller) Jacobian - #1011

Draft
LKuhrmann wants to merge 7 commits into
lanl-ansi:masterfrom
LKuhrmann:smaller_Jacobian
Draft

Change compute_ac_pf iteration to use more standard (smaller) Jacobian#1011
LKuhrmann wants to merge 7 commits into
lanl-ansi:masterfrom
LKuhrmann:smaller_Jacobian

Conversation

@LKuhrmann

Copy link
Copy Markdown
Contributor

Change

Fixes #1009.

Reduces what is iterated in the Newton Raphson iteration from [P, Q] for all buses to [P, Q] for PQ buses and [P] for PV buses. This reduces the Jacobian size by the number of PV busses +2.

I believe the implementation I am suggesting is more standard. The first two random results I get when I google for "newton raphson power flow" support this: random university pdf 1, page 111ff and random university pdf 2, page 9

Impact

Should make compute_ac_pf slightly faster and more memory efficient with more standard convergence when compared to other power flow tools.

As this PR simplifies the Newton-Raphson iteration by no longer converging toward Q injections (for PV and slack buses) and P injection (for the slack bus) I would expect this to converge whenever the current implementation converges.
But I can't prove that, so there is a risk that this might break convergence in some (probably a bit weird) cases.

Todo

I assume this change will need some tests. One test that could be added is the one presented in #1009 that does not currently converge.

I am uncertain if the way I implemented this is inline with the broader PowerModels codebase, so I am keen for code changes/opinions!

What else would need to happen so this can be merged?
If there are reasons for the current power flow implementation I am keen to hear them!

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.08029% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.94%. Comparing base (dd45675) to head (798e373).

Files with missing lines Patch % Lines
src/core/admittance_matrix.jl 93.75% 2 Missing ⚠️
src/prob/pf.jl 98.09% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1011   +/-   ##
=======================================
  Coverage   93.94%   93.94%           
=======================================
  Files          43       43           
  Lines        9676     9731   +55     
=======================================
+ Hits         9090     9142   +52     
- Misses        586      589    +3     
Files with missing lines Coverage Δ
src/core/admittance_matrix.jl 92.62% <93.75%> (+0.11%) ⬆️
src/prob/pf.jl 95.65% <98.09%> (+0.02%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd45675...798e373. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LKuhrmann

Copy link
Copy Markdown
Contributor Author

Seems like the remaining failing tests would be fixed by #1010

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.

Newton-Raphson power flow convergence differs from other power flow tools

1 participant