Skip to content

Commit

Permalink
Make sure v_curr is on the host
Browse files Browse the repository at this point in the history
  • Loading branch information
michel2323 committed Aug 20, 2022
1 parent b3a72d1 commit 9ba006b
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/ExaAdmmBackend/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,45 @@ function reactive_power_generation(model::ModelProxAL, sol::ExaAdmm.Solution)
end
function voltage_magnitude(model::ModelProxAL, sol::ExaAdmm.Solution)
data, line_start = model.grid_data, model.line_start
nbus, FrIdx, FrStart, ToIdx, ToStart = data.nbus, data.FrIdx, data.FrStart, data.ToIdx, data.ToStart
nbus = data.nbus
FrIdx = data.FrIdx |> Array
FrStart = data.FrStart |> Array
ToIdx = data.ToIdx |> Array
ToStart = data.ToStart |> Array
v_curr = sol.v_curr |> Array

vm = zeros(nbus)
for I=1:nbus
for j=FrStart[I]:FrStart[I+1]-1
pij_idx = line_start + 8*(FrIdx[j]-1)
vm[I] = sqrt(sol.v_curr[pij_idx+4])
vm[I] = sqrt(v_curr[pij_idx+4])
end
for j=ToStart[I]:ToStart[I+1]-1
pij_idx = line_start + 8*(ToIdx[j]-1)
vm[I] = sqrt(sol.v_curr[pij_idx+5])
vm[I] = sqrt(v_curr[pij_idx+5])
end
end
return vm
end
function voltage_angle(model::ModelProxAL, sol::ExaAdmm.Solution)
data, line_start = model.grid_data, model.line_start
nbus, FrIdx, FrStart, ToIdx, ToStart = data.nbus, data.FrIdx, data.FrStart, data.ToIdx, data.ToStart
data, line_start = model.grid_data, model.line_start
nbus = data.nbus
FrIdx = data.FrIdx |> Array
FrStart = data.FrStart |> Array
ToIdx = data.ToIdx |> Array
ToStart = data.ToStart |> Array
v_curr = sol.v_curr |> Array

va = zeros(nbus)
for I=1:nbus
for j=FrStart[I]:FrStart[I+1]-1
pij_idx = line_start + 8*(FrIdx[j]-1)
va[I] = sol.v_curr[pij_idx+6]
va[I] = v_curr[pij_idx+6]
end
for j=ToStart[I]:ToStart[I+1]-1
pij_idx = line_start + 8*(ToIdx[j]-1)
va[I] = sol.v_curr[pij_idx+7]
va[I] = v_curr[pij_idx+7]
end
end
return va
Expand Down

0 comments on commit 9ba006b

Please sign in to comment.