Skip to content

Commit 4f9a6e1

Browse files
committed
Correct inconsistency between disconnected bus and branch status
1 parent c09ac61 commit 4f9a6e1

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

src/pwf2pm/branch.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ function _create_dict_dshl(data::Dict)
2525
return dshl_dict
2626
end
2727

28+
function _handle_br_status!(pm_data::Dict, sub_data::Dict, branch::Dict)
29+
f_bus = sub_data["f_bus"]
30+
t_bus = sub_data["t_bus"]
31+
32+
if pm_data["bus"]["$f_bus"]["bus_type"] != 4 && pm_data["bus"]["$t_bus"]["bus_type"] != 4
33+
if branch["STATUS"] == branch["OPENING FROM BUS"] == branch["OPENING TO BUS"] == 'L'
34+
sub_data["br_status"] = 1
35+
end
36+
else
37+
sub_data["br_status"] = 0
38+
end
39+
40+
return sub_data
41+
end
42+
2843
function _pwf2pm_branch!(pm_data::Dict, pwf_data::Dict, branch::Dict; add_control_data::Bool=false)
2944
sub_data = Dict{String,Any}()
3045

@@ -46,11 +61,7 @@ function _pwf2pm_branch!(pm_data::Dict, pwf_data::Dict, branch::Dict; add_contro
4661
sub_data["angmax"] = 60.0 # PowerModels.jl standard
4762
sub_data["transformer"] = false
4863

49-
if branch["STATUS"] == branch["OPENING FROM BUS"] == branch["OPENING TO BUS"] == 'L'
50-
sub_data["br_status"] = 1
51-
else
52-
sub_data["br_status"] = 0
53-
end
64+
_handle_br_status!(pm_data, sub_data, branch)
5465

5566
if add_control_data
5667
sub_data["control_data"] = Dict{String,Any}()

src/pwf2pm/transformer.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ function _pwf2pm_transformer!(pm_data::Dict, pwf_data::Dict, branch::Dict; add_c
5454
sub_data["angmax"] = 60.0 # PowerModels.jl standard
5555
sub_data["transformer"] = true
5656

57-
if branch["STATUS"] == branch["OPENING FROM BUS"] == branch["OPENING TO BUS"] == 'L'
58-
sub_data["br_status"] = 1
59-
else
60-
sub_data["br_status"] = 0
61-
end
57+
_handle_br_status!(pm_data, sub_data, branch)
6258

6359
n = 0 # count(x -> x["f_bus"] == sub_data["f_bus"] && x["t_bus"] == sub_data["t_bus"], values(pm_data["branch"]))
6460
sub_data["source_id"] = ["transformer", sub_data["f_bus"], sub_data["t_bus"], 0, "0$(n + 1)", 0]

test/data/pwf/test_system.pwf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ LFPO .1
2222
99999
2323
DBAR
2424
(Num)OETGb( nome )Gl( V)( A)( Pg)( Qg)( Qn)( Qm)(Bc )( Pl)( Ql)( Sh)Are(Vf)M(1)(2)(3)(4)(5)(6)(7)(8)(9)(10
25-
21 L1 ABus 1 A10408.88 19.6 -3.2 -130130.4 11000
25+
21 D1 ABus 1 A10408.88 19.6 -3.2 -130130.4 11000
2626
22 L2 BBus 2 A1025 9.339.2 -4.6 -99999999. 11000
2727
23 L2 BBus 3 A10257.5325.5 -11.4-99999999. 11000
2828
24 L CBus 4 A1060 8.4 34.6 6.9 11000

test/test_pwf_to_powermodels.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,21 @@
147147
@test solution["multiinfrastructure"] == false
148148
@test solution["multinetwork"] == false
149149
@test solution["per_unit"] == true
150-
@test length(solution["bus"]) == 9
150+
@test length(solution["bus"]) == 8
151151
end
152152

153153
end
154154

155155
end
156156

157+
@testset "Bus Disconnected - Branch Status" begin
158+
# If a branch whose extremity is in a disconnected bus (bus_type = 4)
159+
# the branch status must be off
157160

161+
file = open(joinpath(@__DIR__,"data/pwf/test_system.pwf"))
162+
pm_data = PWF.parse_pwf_to_powermodels(file)
163+
@test pm_data["branch"]["5"]["br_status"] == 0
164+
end
158165

159166
@testset "Power Flow results" begin
160167
filenames = ["3bus", "9bus"]

0 commit comments

Comments
 (0)