Skip to content

Commit 373dc41

Browse files
authored
Merge pull request #36 from LAMPSPUC/fix-elements
Adjust tap control and shunts
2 parents be6a7f4 + 02b2b25 commit 373dc41

File tree

5 files changed

+19
-40
lines changed

5 files changed

+19
-40
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ jobs:
1515
- version: "1"
1616
os: ubuntu-latest
1717
arch: x64
18-
- version: "1.0"
19-
os: ubuntu-latest
20-
arch: x64
2118
steps:
2219
- uses: actions/checkout@v2
2320
- uses: julia-actions/setup-julia@v1

src/pwf2pm/bus.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ function _pwf2pm_bus!(pm_data::Dict, pwf_data::Dict, bus::Dict, dict_dgbt, dict_
9999
sub_data["control_data"]["voltage_controlled_bus"] = bus["CONTROLLED BUS"]
100100
sub_data["control_data"]["vmmin"] = sub_data["vmin"]
101101
sub_data["control_data"]["vmmax"] = sub_data["vmax"]
102+
sub_data["control_data"]["tap_control"] = nothing
103+
sub_data["control_data"]["constraint_type"] = nothing
102104
end
103105

104106
idx = string(sub_data["index"])

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

src/pwf2pm/transformer.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,24 @@ function _pwf2pm_transformer!(pm_data::Dict, pwf_data::Dict, branch::Dict; add_c
103103
sub_data["control_data"]["shift_control_variable"] = nothing
104104
sub_data["control_data"]["shiftmin"] = nothing
105105
sub_data["control_data"]["shiftmax"] = nothing
106+
106107
if constraint_type == "VOLTAGE CONTROL"
108+
107109
sub_data["control_data"]["constraint_type"] = "bounds"
108110
sub_data["control_data"]["valsp"] = branch_dctr[circuit]["SPECIFIED VALUE"]
109111
sub_data["control_data"]["controlled_bus"] = branch_dctr[circuit]["MEASUREMENT EXTREMITY"]
112+
113+
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["control_type"] = "tap_control"
114+
if isnothing(pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["constraint_type"]) # setpoint is more restrict than bounds
115+
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["constraint_type"] = "bounds"
116+
end
110117

111118
else
119+
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["control_type"] = "tap_control"
120+
112121
sub_data["control_data"]["constraint_type"] = "setpoint"
113122
sub_data["control_data"]["valsp"] = nothing
123+
pm_data["bus"]["$(sub_data["control_data"]["controlled_bus"])"]["control_data"]["constraint_type"] = "setpoint"
114124
end
115125

116126
elseif constraint_type == "PHASE CONTROL" # phase control

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)