Update to PSY5#419
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the codebase for compatibility with PowerSystems v5 (PSY5) and newer PowerFlows/PowerNetworkMatrices, including adjustments to power-flow execution, Ybus construction/representation, and test expectations.
Changes:
- Bumped package compat/version and updated power-flow solving paths (including storing solutions and load-model handling).
- Changed Ybus construction/usage (excluding constant-impedance loads) and shifted multiple internal sparse matrices to
Float32. - Adjusted multiple tests’ solver tolerances/expectations and disabled one test file due to convergence issues.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| test/utils/data_utils.jl | Adds explicit source power limits to align with updated component requirements. |
| test/test_case_source_bus_voltage_change.jl | Changes solver options (removes dtmax, sets tolerances). |
| test/test_case_simple_marconato.jl | Uses solve_and_store_power_flow! instead of solve_powerflow!. |
| test/test_case_simple_anderson.jl | Uses solve_and_store_power_flow! instead of solve_powerflow!. |
| test/test_case_oneDoneQ.jl | Uses solve_and_store_power_flow! instead of solve_powerflow!. |
| test/test_case_marconato.jl | Uses solve_and_store_power_flow! instead of solve_powerflow!. |
| test/test_case_anderson.jl | Uses solve_and_store_power_flow! instead of solve_powerflow!. |
| test/test_case_activeload.jl | Loosens eigenvalue assertions to accommodate new numerics. |
| test/test_case_9bus_systems.jl | Sets solver tolerances for Rodas4 execution. |
| test/test_case_5shaft.jl | Uses solve_and_store_power_flow! instead of solve_powerflow!. |
| test/test_case57_degov.jl | Switches MethodOfSteps integrator and removes dtmax. |
| test/test_case55_esst1a.jl | Removes dtmax for IDA execution. |
| test/test_case49_csvgn1.jl | Adds source limits and removes dtmax from IDA execution. |
| test/test_case40_exac1.jl | Removes dtmax from IDA/Rodas4 execution. |
| test/test_case39_exst1.jl | Removes dtmax from IDA execution. |
| test/test_case34_exp_load.jl | Adds tspan and relaxes transient result tolerances. |
| test/test_case29_renewablemodels.jl | Adjusts IDA tolerances and removes dtmax. |
| test/test_base.jl | Builds Ybus excluding constant-impedance loads; relaxes isapprox tolerances. |
| test/runtests.jl | Disables a test file due to convergence issues. |
| test/results/results_eigenvalues.jl | Updates stored eigenvalue fixtures for new library versions. |
| test/benchmarks/psse/MultiGen/FourBusMulti.raw | Adjusts bus type classification in benchmark RAW case. |
| test/Project.toml | Removes DiffEqBase from test deps. |
| src/utils/psy_utils.jl | Changes Ybus rectangular transform typing; adds helper constructors and a new PNM.Ybus overload. |
| src/utils/pf_utils.jl | Adds power-flow helper utilities, including load conversion for PF data. |
| src/initialization/init_device.jl | Uses new get_total_p/q helpers for StandardLoad initialization. |
| src/base/simulation_inputs.jl | Switches stored sparse matrices to Float32; updates Ybus construction and load wrapper signature. |
| src/base/simulation_initialization.jl | Uses new PF helper and tweaks units base/logging. |
| src/base/perturbations.jl | Switches Ybus update internals and NetworkSwitch storage to Float32. |
| src/base/device_wrapper.jl | Uses new get_total_q and changes load aggregation to use with_units_base. |
| src/PowerSimulationsDynamics.jl | Adds inclusion of new pf_utils.jl. |
| docs/src/tutorials/tutorial_continuation_pf.md | Updates tutorial to use solve_and_store_power_flow!. |
| Project.toml | Bumps version and updates compat bounds for PSY5+ ecosystem. |
Comments suppressed due to low confidence (1)
src/base/device_wrapper.jl:1
- Calling
PSY.with_units_base(...SYSTEM_BASE)repeatedly for each scalar getter multiplies overhead inside a hot aggregation loop. Wrap once per load (or once around the whole loop if safe) and read all needed fields inside that singlewith_units_baseblock to reduce overhead and allocations.
get_inner_vars_count(::PSY.DynamicGenerator) = GEN_INNER_VARS_SIZE
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function PowerNetworkMatrices.Ybus( | ||
| lines::Vector{<:PSY.Branch}, | ||
| buses::Vector{PSY.ACBus}, | ||
| ) | ||
| sys = PSY.System(100.0) | ||
| for b in buses | ||
| bus = make_basic_bus(b) | ||
| PSY.add_component!(sys, bus) | ||
| end | ||
| for l in lines | ||
| line = make_basic_line(l, sys) | ||
| PSY.add_component!(sys, line) | ||
| end | ||
| return PowerNetworkMatrices.Ybus(sys) | ||
| end |
There was a problem hiding this comment.
Defining PowerNetworkMatrices.Ybus(::Vector{<:PSY.Branch}, ::Vector{PSY.ACBus}) inside this package is type piracy (extending a function from another module for argument types you don’t own). It also hard-codes PSY.System(100.0), which can silently produce incorrect per-unit admittances if the original system base power differs. Prefer adding a package-local helper (e.g., build_ybus_from_lines_buses(...)) or wrapping this in your own API; if you must construct a PSY.System, accept/derive the base power explicitly and document the assumptions.
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Applied in 2fc4008. I replaced the pirated PowerNetworkMatrices.Ybus overload with a package-local build_ybus_from_branches(...) helper and updated the call site to pass base_power = PSY.get_base_power(sys) explicitly.
There was a problem hiding this comment.
@copilot Can you also update the other files that are using the Ybus pirate constructor to use the new one. There should be in test/test_base.jl, test/test_case_OMIB.jl, test/data_tests/test12.jl, test/data_tests/test13.jl, test/data_tests/test14.jl and test/data_tests/test62.jl
There was a problem hiding this comment.
Done in f661893. I updated those remaining test files to use PSID.build_ybus_from_branches(...; base_power=PSY.get_base_power(...)) instead of the removed vector Ybus constructor.
|
@copilot resolve the merge conflicts in this pull request. You can remove the files as they were replaced with literate |
Agent-Logs-Url: https://github.com/Sienna-Platform/PowerSimulationsDynamics.jl/sessions/732e31d9-fc40-4ee3-96e6-e4394ba66888 Co-authored-by: rodrigomha <24548207+rodrigomha@users.noreply.github.com>
Co-authored-by: rodrigomha <24548207+rodrigomha@users.noreply.github.com>
Done in c11770d. The merge conflicts are resolved and the replaced markdown tutorial files were kept removed in favor of the Literate files. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@jd-lara Tests are passing. Documentation is missing this release in PF to pass: Sienna-Platform/PowerFlows.jl#359 |
|
@rodrigomha PF's in being registered. |
No description provided.