Summary
On psy6, building a network matrix from a system containing a DynamicBranch errors:
Component Line12 is not attached to a system.
Reproduction
sys = build_system(PSITestSystems, "c_sys14"; add_forecasts = false)
branch = first(get_components(Line, sys))
add_component!(sys, DynamicBranch(branch))
PowerNetworkMatrices.Ybus(sys) # ERROR
Cause
handle_component_addition!(sys, ::DynamicBranch) (src/base.jl) calls remove_component!(sys, component.branch), which detaches the wrapped static branch and nulls its internal.units_info (via clear_units!).
DynamicBranch delegates all field access to that branch, e.g. get_r(d::DynamicBranch, units) = get_r(d.branch, units).
- On psy6, fields are stored in device base, so
get_r(::Line, units) converts via _convert_from_device_base -> _get_system_base_power, which reads units_info.base_value and errors when units_info === nothing.
Pre-units, get_r returned the stored field with no system lookup, so the wrapped branch being detached was harmless. The unit-aware getters introduced on psy6 are what expose the long-standing detach behavior. Affects any unit-aware read off a DynamicBranch (get_r/get_x/get_b, ...); Ybus is just the first path to hit it.
Not present on main: the detach is identical there, but main's _get_multiplier(c, ::Nothing, _) = 1.0 returns the stored value unchanged for a component with units_info === nothing (no system-base lookup, no error). psy6's _get_system_base_power removed that fallback and errors instead -- so this is a psy6 regression, not a pre-existing bug.
Environment
PowerSystems.jl psy6, InfrastructureSystems.jl IS4, PowerNetworkMatrices.jl lk/units-table-driven-v2, Julia 1.12.
Summary
On
psy6, building a network matrix from a system containing aDynamicBrancherrors:Reproduction
Cause
handle_component_addition!(sys, ::DynamicBranch)(src/base.jl) callsremove_component!(sys, component.branch), which detaches the wrapped static branch and nulls itsinternal.units_info(viaclear_units!).DynamicBranchdelegates all field access to that branch, e.g.get_r(d::DynamicBranch, units) = get_r(d.branch, units).get_r(::Line, units)converts via_convert_from_device_base->_get_system_base_power, which readsunits_info.base_valueand errors whenunits_info === nothing.Pre-units,
get_rreturned the stored field with no system lookup, so the wrapped branch being detached was harmless. The unit-aware getters introduced on psy6 are what expose the long-standing detach behavior. Affects any unit-aware read off aDynamicBranch(get_r/get_x/get_b, ...);Ybusis just the first path to hit it.Not present on
main: the detach is identical there, butmain's_get_multiplier(c, ::Nothing, _) = 1.0returns the stored value unchanged for a component withunits_info === nothing(no system-base lookup, no error). psy6's_get_system_base_powerremoved that fallback and errors instead -- so this is a psy6 regression, not a pre-existing bug.Environment
PowerSystems.jl
psy6, InfrastructureSystems.jlIS4, PowerNetworkMatrices.jllk/units-table-driven-v2, Julia 1.12.