Skip to content

DynamicBranch field access fails ("not attached to a system") on psy6 #1689

@luke-kiernan

Description

@luke-kiernan

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

  1. 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!).
  2. DynamicBranch delegates all field access to that branch, e.g. get_r(d::DynamicBranch, units) = get_r(d.branch, units).
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions