[PowerModelsDistribution] Error in indexing during Kron reduction with 1ph loads

Back again with another question! I’m trying to implement the IEEE-13 bus in PMD and I’m getting an issue with indexing when using the test case defined in the OpenDSS program files.

On import, before adding the vbounds I get the following when calling calc_start_voltage(data_math_mn["nw"]["0"]) as part of add_start_vrvi!(data_math_mn);:

DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 3 and 2")

1. <mark>**_bcs1**</mark>@*broadcast.jl:516* [inlined]
2. <mark>**_bcs**</mark>@*broadcast.jl:510* [inlined]
3. <mark>**broadcast_shape**</mark>@*broadcast.jl:504* [inlined]
4. <mark>**combine_axes**</mark>@*broadcast.jl:499* [inlined]
5. <mark>**instantiate**</mark>@*broadcast.jl:281* [inlined]
6. <mark>**materialize**(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(*), Tuple{Vector{Float64}, Vector{Any}}})</mark>@*broadcast.jl:860*
7. <mark>**var"#calc_start_voltage#3226"**(::Float64, ::Float64, ::typeof(PowerModelsDistribution.calc_start_voltage), ::Dict{String, Any})</mark>@*transformations.jl:1728*
8. <mark>**calc_start_voltage**</mark>@*transformations.jl:1627* [inlined]
9. <mark>**top-level scope**</mark>@*[Local: 1](http://localhost:1234/edit?id=5fa13d08-2ec4-11ed-2a62-ffda01b116d9#)* [inlined]

Since I want to include vbounds anyways I went ahead and tried adding them, but I noticed on PMD.add_bus_absolute_vbounds! PMD wants to add the vbounds for the ground conductor as well. Since that doesn’t seem to align with the docs which want vm_lb and vm_ub to be of length nphases I tried removing the last vbound for all buses that are grounded. I got this stack trace for the same calc_start_voltages command:

BoundsError: attempt to access 3-element Vector{Float64} at index [4-element BitVector]

    throw_boundserror(::Vector{Float64}, ::Tuple{Base.LogicalIndex{Int64, BitVector}})@abstractarray.jl:691
    getindex(::Vector{Float64}, ::BitVector)@abstractarray.jl:1218
    _apply_filter!(::Dict{String, Any}, ::Vector{String}, ::BitVector)@utils.jl:578
    var"#_apply_kron_reduction!#3130"(::Vector{Int64}, ::Int64, ::typeof(PowerModelsDistribution._apply_kron_reduction!), ::Dict{String, Any})@transformations.jl:374
    var"#apply_pmd!#13"(::Bool, ::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:kr_phases, :kr_neutral), Tuple{Vector{Int64}, Int64}}}, ::typeof(PowerModelsDistribution.apply_pmd!), ::typeof(PowerModelsDistribution._apply_kron_reduction!), ::Dict{String, Any})@data.jl:52
    apply_kron_reduction!(::Dict{String, Any})@transformations.jl:354
    var"#_map_eng2math#3015"(::Bool, ::Bool, ::Vector{Function}, ::Dict{String, Vector{String}}, ::Set{String}, ::typeof(PowerModelsDistribution._map_eng2math), ::Dict{String, Any})@eng2math.jl:188
    var"#transform_data_model#3014"(::Bool, ::Bool, ::Bool, ::Set{String}, ::Dict{String, Vector{String}}, ::Vector{Function}, ::Bool, ::Vector{Function}, ::Bool, ::typeof(PowerModelsDistribution.transform_data_model), ::Dict{String, Any})@eng2math.jl:152
    top-level scope@Local: 1[inlined]

So somewhere it seems like it’s trying to access the voltage on the ground (4 conductors) but on a non-grounded 3ph bus. I’m stumped!

Without removing the voltage bounds on the ground conductor I get the exact same stack trace as not calling PMD.add_bus_absolute_vbounds! at all so I assume PMD.add_bus_absolute_vbounds! is called from calc_start_voltage if there aren’t any bounds.

I’m using OpenDSS’s test case implementation of IEEE 13 but I’ve copied it here as well

ETA: I didn’t use the PMD.jl IEEE13 implementation because it doesn’t seem to have all the buses – so I’m extremely oblivious to something w/r/t that but it also is giving me the same dimension mismatch issues