Skip to content

Expand and correct math details in the power flow docs#64

Merged
cameronkhanpour merged 3 commits into
mainfrom
ck/docs-math
Jul 2, 2026
Merged

Expand and correct math details in the power flow docs#64
cameronkhanpour merged 3 commits into
mainfrom
ck/docs-math

Conversation

@cameronkhanpour

Copy link
Copy Markdown
Collaborator

Improves the mathematical detail in the docs/src/math/ pages, with every added formula checked against the sensitivity code. Docs only; no code changes.

DC Power Flow

  • Spell out the switching flow sensitivity as explicit direct and indirect terms, and expand the angle sensitivity into closed form.

DC OPF

  • Gate the angle difference limits by sw to match the model and KKT system.
  • Add the explicit per-branch KKT switching derivative blocks.

AC Power Flow

  • New Admittance and Topology Sensitivity section: voltage sensitivity to branch conductance and susceptance via implicit differentiation, plus the sw gate in the bus admittance matrix.

AC OPF

  • Note the implicit function framing of the KKT differentiation.

Cites Talkington et al. (arXiv:2510.17071) in the AC docs.

Verify each added formula against the sensitivity implementations.

- DC power flow: write out the switching flow sensitivity (direct and indirect parts) and expand the angle sensitivity term into explicit form
- DC OPF: gate the angle difference limits by sw to match the model, and add the explicit per-branch KKT switching derivative blocks
- AC power flow: add an Admittance and Topology Sensitivity section and show the sw gate in the bus admittance matrix
- AC OPF: note the implicit function framing of the KKT differentiation
- Cite Talkington et al. (arXiv:2510.17071) in the AC docs
@cameronkhanpour cameronkhanpour added the documentation Improvements or additions to documentation label Jun 16, 2026
@cameronkhanpour cameronkhanpour requested a review from samtalki June 16, 2026 08:05
Branch current and flow sensitivities to g and b include a direct term on
the perturbed branch (its own admittance acting on its voltage drop), in
addition to the term through the voltage change. This matches the
implementation (the direct topology current contribution) and the paper's
line current and flow sensitivity equations.

@samtalki samtalki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Resolve the doc conflicts in dc-power-flow.md and dc-opf.md by combining
main's per-island reference support (multiple reference buses, E_ref, refs)
with this branch's math improvements (sw-gated angle limits, explicit
switching KKT derivative blocks, expanded flow sensitivity). Both sides
independently added the diag(sw) factor to the theta stationarity; kept
main's E_ref form which already includes it.
@cameronkhanpour cameronkhanpour merged commit b659d3a into main Jul 2, 2026
5 checks passed
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Benchmark Results (Julia v1)

Time benchmarks
main 728f5aa... main / 728f5aa...
ac_opf/kkt_jacobian/case30.m 3.37 ± 0.056 ms 3.36 ± 0.056 ms 1 ± 0.024
ac_opf/kkt_param/case30.m/switching 0.106 ± 0.0096 ms 0.108 ± 0.0085 ms 0.978 ± 0.12
dc_opf/kkt_jacobian/case30.m/cost_linear 0.251 ± 0.02 μs 0.241 ± 0.011 μs 1.04 ± 0.096
dc_opf/kkt_jacobian/case30.m/cost_quadratic 0.151 ± 0.01 μs 0.16 ± 0.011 μs 0.944 ± 0.09
dc_opf/kkt_jacobian/case30.m/demand 0.38 ± 0.03 μs 0.381 ± 0.06 μs 0.997 ± 0.18
dc_opf/kkt_jacobian/case30.m/flowlimit 0.411 ± 0.12 μs 0.391 ± 0.081 μs 1.05 ± 0.38
dc_opf/kkt_jacobian/case30.m/full 13.1 ± 3.9 μs 13.3 ± 6.3 μs 0.981 ± 0.55
dc_opf/kkt_jacobian/case30.m/susceptance 0.0867 ± 0.0047 ms 0.0893 ± 0.0044 ms 0.971 ± 0.072
parser/case30.m 0.173 ± 0.0098 ms 0.174 ± 0.014 ms 0.991 ± 0.095
time_to_load 1.81 ± 0.0044 s 1.81 ± 0.0066 s 0.997 ± 0.0044
Memory benchmarks
main 728f5aa... main / 728f5aa...
ac_opf/kkt_jacobian/case30.m 0.033 M allocs: 1.17 MB 0.033 M allocs: 1.17 MB 1
ac_opf/kkt_param/case30.m/switching 1.48 k allocs: 0.603 MB 1.48 k allocs: 0.603 MB 1
dc_opf/kkt_jacobian/case30.m/cost_linear 6 allocs: 0.328 kB 6 allocs: 0.328 kB 1
dc_opf/kkt_jacobian/case30.m/cost_quadratic 6 allocs: 0.328 kB 6 allocs: 0.328 kB 1
dc_opf/kkt_jacobian/case30.m/demand 6 allocs: 1.42 kB 6 allocs: 1.42 kB 1
dc_opf/kkt_jacobian/case30.m/flowlimit 6 allocs: 1.89 kB 6 allocs: 1.89 kB 1
dc_opf/kkt_jacobian/case30.m/full 0.081 k allocs: 0.0824 MB 0.081 k allocs: 0.0824 MB 1
dc_opf/kkt_jacobian/case30.m/susceptance 2.28 k allocs: 0.291 MB 2.28 k allocs: 0.291 MB 1
parser/case30.m 21 allocs: 0.1 MB 21 allocs: 0.1 MB 1
time_to_load 0.149 k allocs: 11.1 kB 0.149 k allocs: 11.1 kB 1

@cameronkhanpour cameronkhanpour deleted the ck/docs-math branch July 2, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants