Closed alefcastelli closed 1 year ago
When executing the following code:
using PowerNetworkMatrices using PowerSystemCaseBuilder const PNM = PowerNetworkMatrices const PSB = PowerSystemCaseBuilder sys = PSB.build_system(PSB.PSITestSystems, "c_sys5"); ba_matrix = BA_Matrix(sys); buses = PNM.get_ac_branches(sys); # get bus and slack numbers bus_number = length(buses); ref_bus_number = length(ba_matrix.ref_bus_positions); # define dist_slack vector dist_slack_values = 1/bus_n*ones(bus_number-ref_bus_number); # compute PTDF matrix with distributed slack buses ptdf_6 = PTDF(sys, dist_slack=dist_slack_values)
This error is thrown:
ERROR: ArgumentError: invalid index: Set([4]) of type Set{Int64} Stacktrace: [1] to_index(i::Set{Int64}) @ Base ./indices.jl:300 [2] to_index(A::Matrix{Float64}, i::Set{Int64}) @ Base ./indices.jl:277 [3] to_indices @ ./indices.jl:333 [inlined] [4] to_indices @ ./indices.jl:324 [inlined] [5] view @ ./subarray.jl:176 [inlined] [6] maybeview @ ./views.jl:146 [inlined] [7] dotview @ ./broadcast.jl:1201 [inlined] [8] _calculate_PTDF_matrix_KLU(A::SparseArrays.SparseMatrixCSC{Int8, Int64}, BA::SparseArrays.SparseMatrixCSC{Float64, Int64}, ref_bus_positions::Set{Int64}, dist_slack::Vector{Float64}) @ PowerNetworkMatrices ~/Documents/GitHub/PowerNetworkMatrices.jl/src/ptdf_calculations.jl:156 [9] calculate_PTDF_matrix_KLU @ ~/Documents/GitHub/PowerNetworkMatrices.jl/src/ptdf_calculations.jl:185 [inlined] [10] _buildptdf(branches::Vector{PowerSystems.ACBranch}, buses::Vector{PowerSystems.Bus}, bus_lookup::Dict{Int64, Int64}, dist_slack::Vector{Float64}, linear_solver::String) @ PowerNetworkMatrices ~/Documents/GitHub/PowerNetworkMatrices.jl/src/ptdf_calculations.jl:67 [11] PTDF(branches::Vector{PowerSystems.ACBranch}, buses::Vector{PowerSystems.Bus}; dist_slack::Vector{Float64}, linear_solver::String, tol::Float64) @ PowerNetworkMatrices ~/Documents/GitHub/PowerNetworkMatrices.jl/src/ptdf_calculations.jl:402 [12] #PTDF#33 @ ~/Documents/GitHub/PowerNetworkMatrices.jl/src/ptdf_calculations.jl:435 [inlined]
Solution to this error is to change Line 156 in ptdf_calculation.jl with the following line: PTDFm_t[collect(ref_bus_positions), :] .= 0.0
PTDFm_t[collect(ref_bus_positions), :] .= 0.0
When executing the following code:
This error is thrown:
Solution to this error is to change Line 156 in ptdf_calculation.jl with the following line:
PTDFm_t[collect(ref_bus_positions), :] .= 0.0