diff --git a/src/virtual_lodf_calculations.jl b/src/virtual_lodf_calculations.jl index 5ae1ced7..314a24f5 100644 --- a/src/virtual_lodf_calculations.jl +++ b/src/virtual_lodf_calculations.jl @@ -242,10 +242,9 @@ function _getindex( lodf_row[row] = -1.0 # add slack bus value (zero) and make copy of temp into the cache if get_tol(vlodf) > eps() - vlodf.cache[row] = make_entries_zero!(deepcopy(lodf_row), get_tol(vlodf)) - else - vlodf.cache[row] = deepcopy(lodf_row) + make_entries_zero!(lodf_row, get_tol(vlodf)) end + vlodf.cache[row] = deepcopy(lodf_row) return vlodf.cache[row][column] end end diff --git a/test/test_virtual_ptdf.jl b/test/test_virtual_ptdf.jl index fb2d6c57..6ba5d0e6 100644 --- a/test/test_virtual_ptdf.jl +++ b/test/test_virtual_ptdf.jl @@ -71,10 +71,12 @@ end @testset "Test virtual PTDF with distributed slack" begin # get 5 bus system sys = PSB.build_system(PSB.PSITestSystems, "c_sys5") + bus_number = length(PNM.get_buses(sys)) + dist_slack = 1 / bus_number * ones(bus_number) # compute full PTDF - ptdf = PTDF(sys; dist_slack = slack_array) + ptdf = PTDF(sys; dist_slack = dist_slack) # compute each row of the virtual PTDF and compare values - vptdf = VirtualPTDF(sys; dist_slack = slack_array) + vptdf = VirtualPTDF(sys; dist_slack = dist_slack) for row in 1:size(ptdf.data, 2) # evaluate the column (just needs one element) vptdf[row, 1]