@@ -581,13 +581,13 @@ end
581581function get_generator_data (data:: OPFData , device; use_gpu= false )
582582 ngen = length (data. generators)
583583
584- pgmin = KAArray {Float64} (ngen, device )
585- pgmax = KAArray {Float64} (ngen, device )
586- qgmin = KAArray {Float64} (ngen, device )
587- qgmax = KAArray {Float64} (ngen, device )
588- c2 = KAArray {Float64} (ngen, device )
589- c1 = KAArray {Float64} (ngen, device )
590- c0 = KAArray {Float64} (ngen, device )
584+ pgmin = adapt (device, zeros (Float64, ngen) )
585+ pgmax = adapt (device, zeros (Float64, ngen) )
586+ qgmin = adapt (device, zeros (Float64, ngen) )
587+ qgmax = adapt (device, zeros (Float64, ngen) )
588+ c2 = adapt (device, zeros (Float64, ngen) )
589+ c1 = adapt (device, zeros (Float64, ngen) )
590+ c0 = adapt (device, zeros (Float64, ngen) )
591591
592592 Pmin = Float64[data. generators[g]. Pmin for g in 1 : ngen]
593593 Pmax = Float64[data. generators[g]. Pmax for g in 1 : ngen]
@@ -666,16 +666,16 @@ function get_bus_data(data::OPFData, device; use_gpu=false)
666666 Vmin = Float64[data. buses[i]. Vmin for i= 1 : nbus]
667667 Vmax = Float64[data. buses[i]. Vmax for i= 1 : nbus]
668668
669- cuFrIdx = KAArray {Int} ( length (FrIdx), device )
670- cuToIdx = KAArray {Int} ( length (ToIdx), device )
671- cuGenIdx = KAArray {Int} ( length (GenIdx), device )
672- cuFrStart = KAArray {Int} ( length (FrStart), device )
673- cuToStart = KAArray {Int} ( length (ToStart), device )
674- cuGenStart = KAArray {Int} ( length (GenStart), device )
675- cuPd = KAArray {Float64} (nbus, device )
676- cuQd = KAArray {Float64} (nbus, device )
677- cuVmax = KAArray {Float64} (nbus, device )
678- cuVmin = KAArray {Float64} (nbus, device )
669+ cuFrIdx = adapt (device, zeros (Int, length (FrIdx)) )
670+ cuToIdx = adapt (device, zeros (Int, length (ToIdx)) )
671+ cuGenIdx = adapt (device, zeros (Int, length (GenIdx)) )
672+ cuFrStart = adapt (device, zeros (Int, length (FrStart)) )
673+ cuToStart = adapt (device, zeros (Int, length (ToStart)) )
674+ cuGenStart = adapt (device, zeros (Int, length (GenStart)) )
675+ cuPd = adapt (device, zeros (Float64, nbus) )
676+ cuQd = adapt (device, zeros (Float64, nbus) )
677+ cuVmax = adapt (device, zeros (Float64, nbus) )
678+ cuVmin = adapt (device, zeros (Float64, nbus) )
679679
680680 copyto! (cuFrIdx, FrIdx)
681681 copyto! (cuToIdx, ToIdx)
@@ -777,21 +777,22 @@ function get_branch_data(data::OPFData, device; use_gpu::Bool=false, tight_facto
777777 end
778778 rateA = [ data. lines[l]. rateA == 0.0 ? 1e3 : tight_factor* (data. lines[l]. rateA / data. baseMVA)^ 2 for l= 1 : nline ]
779779
780- cuYshR = KAArray {Float64} (length (ybus. YshR), device)
781- cuYshI = KAArray {Float64} (length (ybus. YshI), device)
782- cuYffR = KAArray {Float64} (nline, device)
783- cuYffI = KAArray {Float64} (nline, device)
784- cuYftR = KAArray {Float64} (nline, device)
785- cuYftI = KAArray {Float64} (nline, device)
786- cuYttR = KAArray {Float64} (nline, device)
787- cuYttI = KAArray {Float64} (nline, device)
788- cuYtfR = KAArray {Float64} (nline, device)
789- cuYtfI = KAArray {Float64} (nline, device)
790- cuFrVmBound = KAArray {Float64} (2 * nline, device)
791- cuToVmBound = KAArray {Float64} (2 * nline, device)
792- cuFrVaBound = KAArray {Float64} (2 * nline, device)
793- cuToVaBound = KAArray {Float64} (2 * nline, device)
794- cuRateA = KAArray {Float64} (nline, device)
780+ cuYshR = adapt (device, zeros (Float64, length (ybus. YshR)))
781+ cuYshI = adapt (device, zeros (Float64, length (ybus. YshI)))
782+ cuYffR = adapt (device, zeros (Float64, nline))
783+ cuYffI = adapt (device, zeros (Float64, nline))
784+ cuYftR = adapt (device, zeros (Float64, nline))
785+
786+ cuYftI = adapt (device, zeros (Float64, nline))
787+ cuYttR = adapt (device, zeros (Float64, nline))
788+ cuYttI = adapt (device, zeros (Float64, nline))
789+ cuYtfR = adapt (device, zeros (Float64, nline))
790+ cuYtfI = adapt (device, zeros (Float64, nline))
791+ cuFrVmBound = adapt (device, zeros (Float64, 2 * nline))
792+ cuToVmBound = adapt (device, zeros (Float64, 2 * nline))
793+ cuFrVaBound = adapt (device, zeros (Float64, 2 * nline))
794+ cuToVaBound = adapt (device, zeros (Float64, 2 * nline))
795+ cuRateA = adapt (device, zeros (Float64, nline))
795796 copyto! (cuYshR, ybus. YshR)
796797 copyto! (cuYshI, ybus. YshI)
797798 copyto! (cuYffR, ybus. YffR)
@@ -836,7 +837,7 @@ function get_branch_bus_index(data::OPFData, device; use_gpu=false)
836837
837838 brBusIdx = Int[ x for l= 1 : nline for x in (BusIdx[lines[l]. from], BusIdx[lines[l]. to]) ]
838839
839- cu_brBusIdx = KAArray {Int} ( 2 * nline, device )
840+ cu_brBusIdx = adapt (device, zeros (Int, 2 * nline) )
840841 copyto! (cu_brBusIdx, brBusIdx)
841842 return cu_brBusIdx
842843end
869870function get_generator_bus_data (data:: OPFData , device; use_gpu= false )
870871 ngen = length (data. generators)
871872
872- vgmin = KAArray {Float64} (ngen, device )
873- vgmax = KAArray {Float64} (ngen, device )
874- vm_setpoint = KAArray {Float64} (ngen, device )
873+ vgmin = adapt (device, zeros (Float64, ngen) )
874+ vgmax = adapt (device, zeros (Float64, ngen) )
875+ vm_setpoint = adapt (device, zeros (Float64, ngen) )
875876
876877 Vgmin = Float64[data. buses[data. BusIdx[data. generators[g]. bus]]. Vmin for g in 1 : ngen]
877878 Vgmax = Float64[data. buses[data. BusIdx[data. generators[g]. bus]]. Vmax for g in 1 : ngen]
909910function get_generator_primary_control (data:: OPFData , device; droop:: Float64 = 0.04 , use_gpu= false )
910911 ngen = length (data. generators)
911912
912- alpha_g = KAArray {Float64} (ngen, device )
913- pg_setpoint = KAArray {Float64} (ngen, device )
913+ alpha_g = adapt (device, zeros (Float64, ngen) )
914+ pg_setpoint = adapt (device, zeros (Float64, ngen) )
914915
915916 Alpha_g = Float64[- ((1 / droop)* data. generators[g]. Pmax) for g in 1 : ngen]
916917 Pg_setpoint = Float64[(data. generators[g]. Pmin + data. generators[g]. Pmax)/ 2 for g in 1 : ngen]
@@ -966,13 +967,13 @@ function get_storage_data(data::OPFData, device; use_gpu=false)
966967 eta_dis = Float64[data. storages[s]. eta_dischg for s= 1 : nstorage]
967968 energy_setpoint = Float64[data. storages[s]. energy_setpoint for s= 1 : nstorage]
968969
969- cuChg_min = KAArray {Float64} (nstorage, device )
970- cuChg_max = KAArray {Float64} (nstorage, device )
971- cuEnergy_min = KAArray {Float64} (nstorage, device )
972- cuEnergy_max = KAArray {Float64} (nstorage, device )
973- cuEta_chg = KAArray {Float64} (nstorage, device )
974- cuEta_dis = KAArray {Float64} (nstorage, device )
975- cuEnergy_setpoint = KAArray {Float64} (nstorage, device )
970+ cuChg_min = adapt (device, zeros (Float64, nstorage) )
971+ cuChg_max = adapt (device, zeros (Float64, nstorage) )
972+ cuEnergy_min = adapt (device, zeros (Float64, nstorage) )
973+ cuEnergy_max = adapt (device, zeros (Float64, nstorage) )
974+ cuEta_chg = adapt (device, zeros (Float64, nstorage) )
975+ cuEta_dis = adapt (device, zeros (Float64, nstorage) )
976+ cuEnergy_setpoint = adapt (device, zeros (Float64, nstorage) )
976977
977978 copyto! (cuChg_min, chg_min)
978979 copyto! (cuChg_max, chg_max)
@@ -1010,8 +1011,8 @@ function get_bus_storage_index(data::OPFData, device; use_gpu=false)
10101011 StorageIdx = Int[s for b= 1 : nbus for s in data. BusStorages[b]]
10111012 StorageStart = accumulate (+ , vcat ([1 ], [length (data. BusStorages[b]) for b= 1 : nbus]))
10121013
1013- cuStorageIdx = KAArray {Int} ( length (StorageIdx), device )
1014- cuStorageStart = KAArray {Int} ( length (StorageStart), device )
1014+ cuStorageIdx = adapt (device, zeros (Int, length (StorageIdx)) )
1015+ cuStorageStart = adapt (device, zeros (Int, length (StorageStart)) )
10151016
10161017 copyto! (cuStorageIdx, StorageIdx)
10171018 copyto! (cuStorageStart, StorageStart)
0 commit comments