diff --git a/src/core/data.jl b/src/core/data.jl index 3b56741..cc929a1 100644 --- a/src/core/data.jl +++ b/src/core/data.jl @@ -1127,15 +1127,18 @@ function add_blockers!(net) end -function create_ts_net(net, waveform; n=0, scaling=1.0) - if n <= 0 +function create_ts_net(net, waveform; ids=[], scaling=1.0) + n = length(ids) + + if length(ids) == 0 n = length(waveform["time"]) + ids = collect(range(length=n)) end ts_net = PowerModels.replicate(net, n) for i = 1:n - j = wf_ids[i] + j = ids[i] for (k, wf) in waveform["waveforms"] otype = wf["parent_type"] diff --git a/src/core/solution.jl b/src/core/solution.jl index 09a6894..7b08c5c 100644 --- a/src/core/solution.jl +++ b/src/core/solution.jl @@ -1,4 +1,4 @@ -######################## + ######################## # Solution Definitions # ######################## @@ -18,7 +18,7 @@ function solution_gmd_qloss!(pm::_PM.AbstractPowerModel, solution::Dict{String,A for (l, branch) in _PM.ref(pm,nw_id,:branch) key = (branch["index"], branch["hi_bus"], branch["lo_bus"]) branch_solution = nw_data["branch"][string(l)] - branch_solution["ieff"] = JuMP.value.(_PM.var(pm, nw_id, :i_dc_mag, l)) + branch_solution["ieff"] = JuMP.value.(_PM.var(pm, nw_id, :ieff, l)) branch_solution["gmd_qloss"] = JuMP.value.(_PM.var(pm,nw_id,:qloss,key)) end end diff --git a/test/gmd_blocker.jl b/test/gmd_blocker.jl index 944798c..8366139 100644 --- a/test/gmd_blocker.jl +++ b/test/gmd_blocker.jl @@ -130,22 +130,10 @@ δ_t = wf_time[2] - wf_time[1] # TODO: move this to a function - for i = 1:n - j = wf_ids[i] - - if (waveform !== nothing && waveform["waveforms"] !== nothing) - for (k, wf) in waveform["waveforms"] - otype = wf["parent_type"] - field = wf["parent_field"] - - ts_net["nw"]["$i"][otype][k][field] = 10 * wf["values"][j] - end - end - end - + ts_net = create_ts_net(net, waveform, ids=wf_ids, scaling=10.0) result = solve_ac_blocker_placement_multi_scenario(ts_net, juniper_solver; setting=setting) @test result["termination_status"] == _PM.LOCALLY_SOLVED - + @test isapprox(result["objective"], 1.0; atol = 1e-1) end end end