diff --git a/Project.toml b/Project.toml index 33cf636..b68eb04 100644 --- a/Project.toml +++ b/Project.toml @@ -19,7 +19,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9" PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655" -PowerModelsRestoration = "23adbb12-a187-11e9-26a2-eb4d4e6e68fb" +# PowerModelsRestoration = "23adbb12-a187-11e9-26a2-eb4d4e6e68fb" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" @@ -29,7 +29,7 @@ JSON = "~0.21" JuMP = "~1.9" Memento = "~1.0, ~1.1, ~1.2, ~1.3, ~1.4" PowerModels = "~0.19" -PowerModelsRestoration = "~0.7" +# PowerModelsRestoration = "~0.7" julia = "~1.6, ~1.7, ~1.8, ~1.10" [extras] diff --git a/src/PowerModelsGMD.jl b/src/PowerModelsGMD.jl index 53398ab..b97cce3 100644 --- a/src/PowerModelsGMD.jl +++ b/src/PowerModelsGMD.jl @@ -5,8 +5,8 @@ const _PMGMD = PowerModelsGMD const _IM = InfrastructureModels import PowerModels const _PM = PowerModels - import PowerModelsRestoration - const _PMR = PowerModelsRestoration + # import PowerModelsRestoration + # const _PMR = PowerModelsRestoration import PowerModels: pm_it_name, pm_it_sym, nw_ids, nws, ismultinetwork diff --git a/src/core/data.jl b/src/core/data.jl index d7c435c..809172d 100644 --- a/src/core/data.jl +++ b/src/core/data.jl @@ -100,10 +100,10 @@ function calc_ieff_current_mag_gwye_delta_xf(branch, case::Dict{String,Any}, sol if haskey(branch,"hi_3w_branch") return 0.0 else - if haskey(solution["gmd_branch"]["$khi"], "gmd_idc") - return abs(solution["gmd_branch"]["$khi"]["gmd_idc"]) + if haskey(solution["gmd_branch"]["$khi"], "dcf") + return abs(solution["gmd_branch"]["$khi"]["dcf"]) else - Memento.warn(_LOGGER, "Gwye-delta transformers $k doesn't have high-side gmd_idc, skipping calculation of ieff") + Memento.warn(_LOGGER, "Gwye-delta transformers $k doesn't have high-side dcf, skipping calculation of ieff") return 0.0 end end @@ -123,13 +123,13 @@ function calc_ieff_current_mag_gwye_gwye_xf(branch, case::Dict{String,Any}, solu if khi == -1 || khi === nothing Memento.warn(_LOGGER, "khi for gwye-gwye transformer $k is -1") else - ihi = solution["gmd_branch"]["$khi"]["gmd_idc"] + ihi = solution["gmd_branch"]["$khi"]["dcf"] end if klo == -1 || klo === nothing Memento.warn(_LOGGER, "klo for gwye-gwye transformer $k is -1") else - ilo = solution["gmd_branch"]["$klo"]["gmd_idc"] + ilo = solution["gmd_branch"]["$klo"]["dcf"] end jfr = branch["f_bus"] @@ -159,13 +159,13 @@ function calc_ieff_current_mag_gwye_gwye_auto_xf(branch, case::Dict{String,Any}, if ks == -1 || ks === nothing Memento.warn(_LOGGER, "ks for autotransformer $k is -1") else - is = solution["gmd_branch"]["$ks"]["gmd_idc"] + is = solution["gmd_branch"]["$ks"]["dcf"] end if kc == -1 || kc === nothing Memento.warn(_LOGGER, "kc for autotransformer $k is -1") else - ic = solution["gmd_branch"]["$kc"]["gmd_idc"] + ic = solution["gmd_branch"]["$kc"]["dcf"] end jfr = branch["f_bus"] @@ -189,13 +189,13 @@ function calc_ieff_current_mag_gwye_gwye_auto_xf(branch, case::Dict{String,Any}, if ks == -1 || ks === nothing Memento.warn(_LOGGER, "ks for autotransformer $k is -1") else - is = solution["gmd_branch"]["$ks"]["gmd_idc"] + is = solution["gmd_branch"]["$ks"]["dcf"] end if kc == -1 || kc === nothing Memento.warn(_LOGGER, "kc for autotransformer $k is -1") else - ic = solution["gmd_branch"]["$kc"]["gmd_idc"] + ic = solution["gmd_branch"]["$kc"]["dcf"] end # ihi = -is @@ -226,19 +226,19 @@ function calc_ieff_current_mag_3w_xf(branch, case::Dict{String,Any}, solution) if khi == -1 || khi === nothing Memento.warn(_LOGGER, "khi for three-winding transformer $k is -1") else - ihi = solution["gmd_branch"]["$khi"]["gmd_idc"] + ihi = solution["gmd_branch"]["$khi"]["dcf"] end if klo == -1 || klo === nothing Memento.warn(_LOGGER, "klo for three-winding transformer $k is -1") else - ilo = solution["gmd_branch"]["$klo"]["gmd_idc"] + ilo = solution["gmd_branch"]["$klo"]["dcf"] end if kter == -1 || kter === nothing Memento.warn(_LOGGER, "kter for three-winding transformer $k is -1") else - iter = solution["gmd_branch"]["$ter"]["gmd_idc"] + iter = solution["gmd_branch"]["$ter"]["dcf"] end jfr = branch["source_id"][2] @@ -308,7 +308,7 @@ function calc_ieff_current_mag_gwye_delta_xf(branch, case::Dict{Symbol,Any}, sol Memento.warn(_LOGGER, "khi for gwye-delta transformer $k is -1") return 0.0 else - return abs(solution["gmd_branch"]["$khi"]["gmd_idc"]) + return abs(solution["gmd_branch"]["$khi"]["dcf"]) end end @@ -326,13 +326,13 @@ function calc_ieff_current_mag_gwye_gwye_xf(branch, case::Dict{Symbol,Any}, solu if khi == -1 || khi === nothing Memento.warn(_LOGGER, "khi for gwye-gwye transformer $k is -1") else - ihi = solution["gmd_branch"]["$khi"]["gmd_idc"] + ihi = solution["gmd_branch"]["$khi"]["dcf"] end if klo == -1 || klo === nothing Memento.warn(_LOGGER, "klo for gwye-gwye transformer $k is -1") else - ilo = solution["gmd_branch"]["$klo"]["gmd_idc"] + ilo = solution["gmd_branch"]["$klo"]["dcf"] end jfr = branch["f_bus"] @@ -357,13 +357,13 @@ function calc_ieff_current_mag_gwye_gwye_auto_xf(branch, case::Dict{Symbol,Any}, if ks == -1 || ks === nothing Memento.warn(_LOGGER, "ks for autotransformer $k is -1") else - is = solution["gmd_branch"]["$ks"]["gmd_idc"] + is = solution["gmd_branch"]["$ks"]["dcf"] end if kc == -1 || kc === nothing Memento.warn(_LOGGER, "kc for autotransformer $k is -1") else - ic = solution["gmd_branch"]["$kc"]["gmd_idc"] + ic = solution["gmd_branch"]["$kc"]["dcf"] end # ihi = -is @@ -394,19 +394,19 @@ function calc_ieff_current_mag_3w_xf(branch, case::Dict{Symbol,Any}, solution) if khi == -1 || khi === nothing Memento.warn(_LOGGER, "khi for three-winding transformer $k is -1") else - ihi = solution["gmd_branch"]["$khi"]["gmd_idc"] + ihi = solution["gmd_branch"]["$khi"]["dcf"] end if klo == -1 || klo === nothing Memento.warn(_LOGGER, "klo for three-winding transformer $k is -1") else - ilo = solution["gmd_branch"]["$klo"]["gmd_idc"] + ilo = solution["gmd_branch"]["$klo"]["dcf"] end if kter == -1 || kter === nothing Memento.warn(_LOGGER, "kter for three-winding transformer $k is -1") else - iter = solution["gmd_branch"]["$ter"]["gmd_idc"] + iter = solution["gmd_branch"]["$ter"]["dcf"] end jfr = branch["source_id"][2] @@ -423,15 +423,15 @@ function calc_ieff_current_mag_3w_xf(branch, case::Dict{Symbol,Any}, solution) end -function calc_dc_current_mag(branch, type, solution) +function calc_dc_current(branch, type, solution) if type == "line" - return calc_dc_current_mag_line(branch, solution) + return calc_dc_current_line(branch, solution) elseif type == "xfmr" - return calc_dc_current_mag_xfmr(branch, solution) + return calc_dc_current_xfmr(branch, solution) else - return calc_dc_current_mag_sub(branch, solution) + return calc_dc_current_sub(branch, solution) end @@ -439,7 +439,7 @@ function calc_dc_current_mag(branch, type, solution) end -function calc_dc_current_mag_line(branch, solution) +function calc_dc_current_line(branch, solution) nf = branch["f_bus"] nt = branch["t_bus"] g = 1 / branch["br_r"] @@ -449,7 +449,7 @@ function calc_dc_current_mag_line(branch, solution) end -function calc_dc_current_mag_xfmr(branch, solution) +function calc_dc_current_xfmr(branch, solution) nf = branch["f_bus"] nt = branch["t_bus"] g = 1 / branch["br_r"] @@ -459,7 +459,7 @@ function calc_dc_current_mag_xfmr(branch, solution) end -function calc_dc_current_mag_sub(branch, solution) +function calc_dc_current_sub(branch, solution) nf = branch["f_bus"] nt = branch["t_bus"] g = 1 / branch["br_r"] @@ -804,7 +804,7 @@ function adjust_gmd_phasing!(result) gmd_branches = result["solution"]["gmd_branch"] for branch in values(gmd_branches) - branch["gmd_idc"] = branch["gmd_idc"] / 3 + branch["dcf"] /= 3 end return result @@ -831,15 +831,15 @@ function add_gmd_data!(case::Dict{String,Any}, solution::Dict{String,<:Any}; dec if br["type"] == "line" k = "$(br["gmd_br"])" - br["gmd_idc"] = solution["gmd_branch"][k]["gmd_idc"]/3.0 + br["dcf"] = solution["gmd_branch"][k]["dcf"]/3.0 else if decoupled # TODO: add calculations from constraint_dc_current_mag k = br["dc_brid_hi"] # high-side gmd branch - br["gmd_idc"] = 0.0 - br["ieff"] = abs(br["gmd_idc"]) + br["dcf"] = 0.0 + br["ieff"] = abs(br["dcf"]) br["qloss"] = calc_qloss(i, case, solution) else diff --git a/src/core/solution.jl b/src/core/solution.jl index 8870cce..d78b901 100644 --- a/src/core/solution.jl +++ b/src/core/solution.jl @@ -77,17 +77,22 @@ function solution_gmd(v::Vector{Float64}, case::Dict{String,Any}) solution["gmd_bus"]["$bus"]["gmd_vdc"] = val end - # TODO: check if calc_dc_current_mag is redundant with calc_ieff_current_mag + # Note: calc_dc_current (formely calc_dc_current_mag) is different from + # calc_ieff_current_mag as the latter is for ieff rather than idc + # and associated with branches rather than gmd_branches for (n, branch) in case["gmd_branch"] solution["gmd_branch"]["$n"] = Dict() if haskey(branch, "parent_type") && branch["parent_type"] == "branch" type = case["branch"]["$(branch["parent_index"])"]["type"] - solution["gmd_branch"]["$n"]["gmd_idc"] = calc_dc_current_mag(branch, type, solution) + idc = calc_dc_current(branch, type, solution) + solution["gmd_branch"]["$n"]["dcf"] = idc + solution["gmd_branch"]["$n"]["dcf"] = -idc else Memento.warn(_LOGGER, "Branch $n doesn't have parent_type, skipping") end end + # TODO: solution["ieff"] = Dict{String,Any}() for (n, branch) in case["branch"] diff --git a/test/gmd.jl b/test/gmd.jl index 9180147..ddd6605 100644 --- a/test/gmd.jl +++ b/test/gmd.jl @@ -71,7 +71,7 @@ @test isapprox(result["solution"]["ieff"]["25"], 19.075, rtol=1e-3) @test isapprox(result["solution"]["ieff"]["29"], 17.183, rtol=1e-3) @test isapprox(result["solution"]["ieff"]["30"], 17.183, rtol=1e-3) - println(result["solution"]["qloss"]) + # println(result["solution"]["qloss"]) end end @testset "opt solve of gmd" begin @@ -151,7 +151,7 @@ @test isapprox(result["solution"]["ieff"]["25"], 19.075, rtol=1e-3) @test isapprox(result["solution"]["ieff"]["29"], 17.183, rtol=1e-3) @test isapprox(result["solution"]["ieff"]["30"], 17.183, rtol=1e-3) - println(result["solution"]["qloss"]) + # println(result["solution"]["qloss"]) end end end diff --git a/test/runtests.jl b/test/runtests.jl index 74f2532..93b22e9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -44,7 +44,7 @@ include("test_cases.jl") include("gmd.jl") # include("gmd_pf.jl") # include("gmd_opf.jl") - include("gmd_mld.jl") + # include("gmd_mld.jl") # include("gmd_ots.jl") # include("gmd_blocker.jl") include("parse.jl") # GIC parser