Skip to content

Commit

Permalink
add unit test for time-extended
Browse files Browse the repository at this point in the history
having some errors with gmd_mld tests
  • Loading branch information
akbarnes committed Jan 5, 2025
1 parent cd90968 commit e3839c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
9 changes: 6 additions & 3 deletions src/core/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions src/core/solution.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
########################
########################
# Solution Definitions #
########################

Expand All @@ -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
Expand Down
16 changes: 2 additions & 14 deletions test/gmd_blocker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e3839c6

Please sign in to comment.