From 9ba006b9f30a3a4b9fc147cee9c4d52132d8e6eb Mon Sep 17 00:00:00 2001 From: Michel Schanen Date: Fri, 19 Aug 2022 18:49:17 -0500 Subject: [PATCH] Make sure v_curr is on the host --- src/ExaAdmmBackend/interface.jl | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/ExaAdmmBackend/interface.jl b/src/ExaAdmmBackend/interface.jl index 30d210c..0679ec1 100644 --- a/src/ExaAdmmBackend/interface.jl +++ b/src/ExaAdmmBackend/interface.jl @@ -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