-
Notifications
You must be signed in to change notification settings - Fork 23
enable ward + dc power flow with warning #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request enables Ward reduction for DC power flow methods with a warning message. Previously, Ward reduction was completely unsupported and would throw a NotImplementedError. The changes allow Ward reduction to be used with DC power flow methods (DCPowerFlow, PTDFDCPowerFlow, and vPTDFDCPowerFlow) but warn users that branch flows for branches in parallel with equivalent branches added by Ward reduction may give unexpected results.
Changes:
- Modified the network_reduction_message function to allow Ward reduction with DC power flow methods while emitting a warning instead of throwing an error
- Added a new test suite for Ward reduction with DC power flow methods
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/PowerFlowData.jl | Modified network_reduction_message to allow Ward reduction with DC power flow (with warning) instead of throwing NotImplementedError |
| test/test_reduced_dc_power_flow.jl | Added new test suite for Ward reduction with all DC power flow types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| results = PF.solve_power_flow( | ||
| dc_pf, | ||
| sys; | ||
| network_reductions = NetworkReduction[WardReduction(study_buses)], |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing namespace prefix for NetworkReduction and WardReduction. These should be PNM.NetworkReduction and PNM.WardReduction to be consistent with the rest of the file (see lines 6-10).
| network_reductions = NetworkReduction[WardReduction(study_buses)], | |
| network_reductions = PNM.NetworkReduction[PNM.WardReduction(study_buses)], |
| ), | ||
| ) | ||
| end | ||
| if m isa DCPowerFlow && any(isa.(nrs, (PNM.WardReduction,))) |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks for DCPowerFlow specifically, but should check for AbstractDCPowerFlow to cover all DC power flow types (DCPowerFlow, PTDFDCPowerFlow, and vPTDFDCPowerFlow). The test in test_reduced_dc_power_flow.jl iterates over all subtypes of AbstractDCPowerFlow, so PTDFDCPowerFlow and vPTDFDCPowerFlow with WardReduction would not trigger this warning.
| if m isa DCPowerFlow && any(isa.(nrs, (PNM.WardReduction,))) | |
| if m isa AbstractDCPowerFlow && any(isa.(nrs, (PNM.WardReduction,))) |
| ) | ||
| end | ||
| if m isa DCPowerFlow && any(isa.(nrs, (PNM.WardReduction,))) | ||
| @warn "Use ward reduction with DC power flow with caution. Flows for arcs in parallel with equivalent branches added during Ward will give unexpected results." |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent capitalization: "ward" should be "Ward" to match the capitalization used in the error message on line 404 and to be consistent with proper noun capitalization for the Ward reduction method.
| @warn "Use ward reduction with DC power flow with caution. Flows for arcs in parallel with equivalent branches added during Ward will give unexpected results." | |
| @warn "Use Ward reduction with DC power flow with caution. Flows for arcs in parallel with equivalent branches added during Ward will give unexpected results." |
| end | ||
| end | ||
|
|
||
| # Ward reduction tested separately from Radial/Degree Two reductions because power flow results for retained buses is not expected to match exactly. |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammatical error: "results ... is not expected" should be "results ... are not expected" since "results" is plural.
| # Ward reduction tested separately from Radial/Degree Two reductions because power flow results for retained buses is not expected to match exactly. | |
| # Ward reduction tested separately from Radial/Degree Two reductions because power flow results for retained buses are not expected to match exactly. |
| end | ||
|
|
||
| # Ward reduction tested separately from Radial/Degree Two reductions because power flow results for retained buses is not expected to match exactly. | ||
| @testset "RTS: Ward Reduction and DC Power Flow" begin |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UNSUPPORTED list in test/test_reduced_ac_power_flow.jl still includes Ward reduction with DC power flow types (DCPowerFlow, PTDFDCPowerFlow, vPTDFDCPowerFlow on lines 5-7 of that file). Since this PR enables Ward reduction with DC power flow, those entries should be removed from the UNSUPPORTED list to maintain consistency across the test suite.
| ) | ||
| end | ||
| if m isa DCPowerFlow && any(isa.(nrs, (PNM.WardReduction,))) | ||
| @warn "Use ward reduction with DC power flow with caution. Flows for arcs in parallel with equivalent branches added during Ward will give unexpected results." |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning message could be clearer. The phrase "Flows for arcs in parallel with equivalent branches added during Ward" is somewhat unclear. Consider rephrasing to something like "Branch flows for branches in parallel with equivalent branches added by Ward reduction may be incorrect" for better clarity.
| @warn "Use ward reduction with DC power flow with caution. Flows for arcs in parallel with equivalent branches added during Ward will give unexpected results." | |
| @warn "Use Ward reduction with DC power flow with caution. Branch flows for branches in parallel with equivalent branches added by Ward reduction may be incorrect." |
|
Performance Results
|
No description provided.