Skip to content

Commit 39e00a7

Browse files
committed
Model each shunt individually
1 parent be6a7f4 commit 39e00a7

File tree

2 files changed

+7
-37
lines changed

2 files changed

+7
-37
lines changed

src/pwf2pm/shunt.jl

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
function _create_new_shunt(sub_data::Dict, pm_data::Dict)
2-
for (idx, value) in pm_data["shunt"]
3-
if value["shunt_bus"] == sub_data["shunt_bus"] && value["source_id"][1] == sub_data["source_id"][1]
4-
return false, idx
5-
end
6-
end
7-
return true
8-
end
9-
101
function _handle_bs_bounds(shunt::Dict{String, Any})
112
bsmin, bsmax = 0.0, 0.0
123
for (i,el) in shunt["REACTANCE GROUPS"]
@@ -76,18 +67,8 @@ function _pwf2pm_DBSH_shunt!(pm_data::Dict, pwf_data::Dict, shunt::Dict; add_con
7667
sub_data["source_id"] = ["switched shunt", sub_data["shunt_bus"], "0$(n+1)"]
7768
sub_data["index"] = length(pm_data["shunt"]) + 1
7869

79-
if _create_new_shunt(sub_data, pm_data)[1]
80-
idx = string(sub_data["index"])
81-
pm_data["shunt"][idx] = sub_data
82-
else
83-
idx = _create_new_shunt(sub_data, pm_data)[2]
84-
pm_data["shunt"][idx]["gs"] += sub_data["gs"]
85-
pm_data["shunt"][idx]["bs"] += sub_data["bs"]
86-
if add_control_data
87-
pm_data["shunt"][idx]["control_data"]["bsmin"] += sub_data["control_data"]["bsmin"]
88-
pm_data["shunt"][idx]["control_data"]["bsmax"] += sub_data["control_data"]["bsmax"]
89-
end
90-
end
70+
idx = string(sub_data["index"])
71+
pm_data["shunt"][idx] = sub_data
9172
end
9273

9374
function _pwf2pm_DBSH_shunt!(pm_data::Dict, pwf_data::Dict; add_control_data::Bool=false)
@@ -139,18 +120,8 @@ function _pwf2pm_DCER_shunt!(pm_data::Dict, pwf_data::Dict, shunt::Dict; add_con
139120
sub_data["source_id"] = ["switched shunt", sub_data["shunt_bus"], "0$(n+1)"]
140121
sub_data["index"] = length(pm_data["shunt"]) + 1
141122

142-
if _create_new_shunt(sub_data, pm_data)[1]
143-
idx = string(sub_data["index"])
144-
pm_data["shunt"][idx] = sub_data
145-
else
146-
idx = _create_new_shunt(sub_data, pm_data)[2]
147-
pm_data["shunt"][idx]["gs"] += sub_data["gs"]
148-
pm_data["shunt"][idx]["bs"] += sub_data["bs"]
149-
if add_control_data
150-
pm_data["shunt"][idx]["control_data"]["bsmin"] += sub_data["control_data"]["bsmin"]
151-
pm_data["shunt"][idx]["control_data"]["bsmax"] += sub_data["control_data"]["bsmax"]
152-
end
153-
end
123+
idx = string(sub_data["index"])
124+
pm_data["shunt"][idx] = sub_data
154125
end
155126

156127
function _pwf2pm_DCER_shunt!(pm_data::Dict, pwf_data::Dict; add_control_data::Bool=false)
@@ -212,8 +183,6 @@ function _pwf2pm_DBAR_shunt!(pm_data::Dict, pwf_data::Dict; add_control_data::Bo
212183
end
213184
end
214185

215-
# Assumption - if there are more than one shunt for the same bus we sum their values into one shunt (source: Organon)
216-
# CAUTION: this might be an Organon error
217186
function _pwf2pm_shunt!(pm_data::Dict, pwf_data::Dict; add_control_data::Bool=false)
218187
pm_data["shunt"] = Dict{String, Any}()
219188

test/test_pwf_to_powermodels.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,9 @@
246246
@test pm_data["branch"]["2"]["b_to"] == -0.07
247247
@test pm_data["branch"]["3"]["b_fr"] == 0.0
248248
@test pm_data["branch"]["3"]["b_to"] == 0.0
249-
@test length(pm_data["shunt"]) == 1
250-
@test pm_data["shunt"]["1"]["bs"] == -1.755
249+
@test length(pm_data["shunt"]) == 2
250+
@test pm_data["shunt"]["1"]["bs"] == -1.5
251+
@test pm_data["shunt"]["2"]["bs"] == -0.255
251252
end
252253

253254
@testset "Transformer control fields" begin

0 commit comments

Comments
 (0)