Skip to content

Commit aae6212

Browse files
committed
Branch -> ACTransmission for all network reduction structs
1 parent 452a6e5 commit aae6212

File tree

6 files changed

+36
-33
lines changed

6 files changed

+36
-33
lines changed

src/BA_ABA_matrices.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ function _get_series_susceptance(series_chain::Vector{Any})
9898
total_susceptance = 1 / (sum((1.0 ./ series_susceptances)))
9999
return total_susceptance
100100
end
101-
function _get_series_susceptance(segment::PSY.Branch)
101+
function _get_series_susceptance(segment::PSY.ACTransmission)
102102
return PSY.get_series_susceptance(segment)
103103
end
104-
function _get_series_susceptance(segment::Set{PSY.Branch})
104+
function _get_series_susceptance(segment::Set{PSY.ACTransmission})
105105
return sum([_get_series_susceptance(branch) for branch in segment])
106106
end
107107
function _get_series_susceptance(segment::Tuple{PSY.ThreeWindingTransformer, Int})

src/NetworkReductionData.jl

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
irreducible_buses::Set{Int} = Set{Int}() # Buses that are not reduced in the network reduction
33
bus_reduction_map::Dict{Int, Set{Int}} = Dict{Int, Set{Int}}() # Maps reduced bus to the set of buses it was reduced to
44
reverse_bus_search_map::Dict{Int, Int} = Dict{Int, Int}()
5-
direct_branch_map::Dict{Tuple{Int, Int}, PSY.Branch} =
6-
Dict{Tuple{Int, Int}, PSY.Branch}()
7-
reverse_direct_branch_map::Dict{PSY.Branch, Tuple{Int, Int}} =
8-
Dict{PSY.Branch, Tuple{Int, Int}}()
9-
parallel_branch_map::Dict{Tuple{Int, Int}, Set{PSY.Branch}} =
10-
Dict{Tuple{Int, Int}, Set{PSY.Branch}}()
11-
reverse_parallel_branch_map::Dict{PSY.Branch, Tuple{Int, Int}} =
12-
Dict{PSY.Branch, Tuple{Int, Int}}()
5+
direct_branch_map::Dict{Tuple{Int, Int}, PSY.ACTransmission} =
6+
Dict{Tuple{Int, Int}, PSY.ACTransmission}()
7+
reverse_direct_branch_map::Dict{PSY.ACTransmission, Tuple{Int, Int}} =
8+
Dict{PSY.ACTransmission, Tuple{Int, Int}}()
9+
parallel_branch_map::Dict{Tuple{Int, Int}, Set{PSY.ACTransmission}} =
10+
Dict{Tuple{Int, Int}, Set{PSY.ACTransmission}}()
11+
reverse_parallel_branch_map::Dict{PSY.ACTransmission, Tuple{Int, Int}} =
12+
Dict{PSY.ACTransmission, Tuple{Int, Int}}()
1313
series_branch_map::Dict{Tuple{Int, Int}, Vector{Any}} =
1414
Dict{Tuple{Int, Int}, Vector{Any}}()
1515
reverse_series_branch_map::Dict{Any, Tuple{Int, Int}} =
@@ -34,17 +34,20 @@ end
3434
function populate_branch_maps_by_type!(nrd::NetworkReductionData)
3535
all_branch_maps_by_type = Dict(
3636
"direct_branch_map" =>
37-
Dict{Type{<:PSY.Branch}, Dict{Tuple{Int, Int}, PSY.Branch}}(),
37+
Dict{Type{<:PSY.ACTransmission}, Dict{Tuple{Int, Int}, PSY.ACTransmission}}(),
3838
"reverse_direct_branch_map" =>
39-
Dict{Type{<:PSY.Branch}, Dict{PSY.Branch, Tuple{Int, Int}}}(),
39+
Dict{Type{<:PSY.ACTransmission}, Dict{PSY.ACTransmission, Tuple{Int, Int}}}(),
4040
"parallel_branch_map" =>
41-
Dict{Type{<:PSY.Branch}, Dict{Tuple{Int, Int}, Set{PSY.Branch}}}(),
41+
Dict{
42+
Type{<:PSY.ACTransmission},
43+
Dict{Tuple{Int, Int}, Set{PSY.ACTransmission}},
44+
}(),
4245
"reverse_parallel_branch_map" =>
43-
Dict{Type{<:PSY.Branch}, Dict{PSY.Branch, Tuple{Int, Int}}}(),
46+
Dict{Type{<:PSY.ACTransmission}, Dict{PSY.ACTransmission, Tuple{Int, Int}}}(),
4447
"series_branch_map" =>
45-
Dict{Type{<:PSY.Branch}, Dict{Tuple{Int, Int}, Vector{Any}}}(),
48+
Dict{Type{<:PSY.ACTransmission}, Dict{Tuple{Int, Int}, Vector{Any}}}(),
4649
"reverse_series_branch_map" =>
47-
Dict{Type{<:PSY.Branch}, Dict{Any, Tuple{Int, Int}}}(),
50+
Dict{Type{<:PSY.ACTransmission}, Dict{Any, Tuple{Int, Int}}}(),
4851
"transformer3W_map" => Dict{
4952
Type{<:PSY.ThreeWindingTransformer},
5053
Dict{
@@ -64,31 +67,31 @@ function populate_branch_maps_by_type!(nrd::NetworkReductionData)
6467
map_by_type = get!(
6568
all_branch_maps_by_type["direct_branch_map"],
6669
_get_segment_type(v),
67-
Dict{Tuple{Int, Int}, PSY.Branch}(),
70+
Dict{Tuple{Int, Int}, PSY.ACTransmission}(),
6871
)
6972
map_by_type[k] = v
7073
end
7174
for (k, v) in nrd.reverse_direct_branch_map
7275
map_by_type = get!(
7376
all_branch_maps_by_type["reverse_direct_branch_map"],
7477
_get_segment_type(k),
75-
Dict{PSY.Branch, Tuple{Int, Int}}(),
78+
Dict{PSY.ACTransmission, Tuple{Int, Int}}(),
7679
)
7780
map_by_type[k] = v
7881
end
7982
for (k, v) in nrd.parallel_branch_map
8083
map_by_type = get!(
8184
all_branch_maps_by_type["parallel_branch_map"],
8285
_get_segment_type(v),
83-
Dict{Tuple{Int, Int}, Set{PSY.Branch}}(),
86+
Dict{Tuple{Int, Int}, Set{PSY.ACTransmission}}(),
8487
)
8588
map_by_type[k] = v
8689
end
8790
for (k, v) in nrd.reverse_parallel_branch_map
8891
map_by_type = get!(
8992
all_branch_maps_by_type["reverse_parallel_branch_map"],
9093
_get_segment_type(k),
91-
Dict{PSY.Branch, Tuple{Int, Int}}(),
94+
Dict{PSY.ACTransmission, Tuple{Int, Int}}(),
9295
)
9396
map_by_type[k] = v
9497
end
@@ -133,7 +136,7 @@ function populate_branch_maps_by_type!(nrd::NetworkReductionData)
133136
end
134137

135138
_get_segment_type(::T) where {T <: PSY.ACBranch} = T
136-
_get_segment_type(x::Set{PSY.Branch}) = typeof(first(x))
139+
_get_segment_type(x::Set{PSY.ACTransmission}) = typeof(first(x))
137140
_get_segment_type(x::Tuple{PSY.ThreeWindingTransformer, Int}) = typeof(first(x))
138141

139142
get_irreducible_buses(rb::NetworkReductionData) = rb.irreducible_buses

src/PowerNetworkMatrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function get_branch_multiplier(A::T, branch_name::String) where {T <: PowerNetwo
335335
end
336336

337337
function _compute_parallel_multiplier(
338-
parallel_branch_set::Set{PSY.Branch},
338+
parallel_branch_set::Set{PSY.ACTransmission},
339339
branch_name::String,
340340
)
341341
b_total = 0.0

src/Ybus.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function get_reduction(
4545
return get_reduction(A, sys, reduction)
4646
end
4747

48-
function add_to_branch_maps!(nr::NetworkReductionData, arc::PSY.Arc, br::PSY.Branch)
48+
function add_to_branch_maps!(nr::NetworkReductionData, arc::PSY.Arc, br::PSY.ACTransmission)
4949
direct_branch_map = get_direct_branch_map(nr)
5050
reverse_direct_branch_map = get_reverse_direct_branch_map(nr)
5151
parallel_branch_map = get_parallel_branch_map(nr)
@@ -1020,7 +1020,7 @@ function _build_chain_ybus(series_chain::Vector{Any}, segment_orientations::Vect
10201020
end
10211021

10221022
function add_segment_to_ybus!(
1023-
segment::Union{PSY.Branch, Tuple{PSY.ThreeWindingTransformer, Int}},
1023+
segment::Union{PSY.ACTransmission, Tuple{PSY.ThreeWindingTransformer, Int}},
10241024
y11::Vector{ComplexF32},
10251025
y12::Vector{ComplexF32},
10261026
y21::Vector{ComplexF32},
@@ -1048,7 +1048,7 @@ function add_segment_to_ybus!(
10481048
end
10491049
end
10501050
function add_segment_to_ybus!(
1051-
segment::Set{PSY.Branch},
1051+
segment::Set{PSY.ACTransmission},
10521052
y11::Vector{ComplexF32},
10531053
y12::Vector{ComplexF32},
10541054
y21::Vector{ComplexF32},
@@ -1099,15 +1099,15 @@ function _reduce_internal_nodes(Y::Matrix{ComplexF32})
10991099
end
11001100

11011101
function _remake_reverse_direct_branch_map!(nr::NetworkReductionData)
1102-
reverse_direct_branch_map = Dict{PSY.Branch, Tuple{Int, Int}}()
1102+
reverse_direct_branch_map = Dict{PSY.ACTransmission, Tuple{Int, Int}}()
11031103
for (k, v) in nr.direct_branch_map
11041104
reverse_direct_branch_map[v] = k
11051105
end
11061106
nr.reverse_direct_branch_map = reverse_direct_branch_map
11071107
return
11081108
end
11091109
function _remake_reverse_parallel_branch_map!(nr::NetworkReductionData)
1110-
reverse_parallel_branch_map = Dict{PSY.Branch, Tuple{Int, Int}}()
1110+
reverse_parallel_branch_map = Dict{PSY.ACTransmission, Tuple{Int, Int}}()
11111111
for (k, v) in nr.parallel_branch_map
11121112
for x in v
11131113
reverse_parallel_branch_map[x] = k
@@ -1117,7 +1117,7 @@ function _remake_reverse_parallel_branch_map!(nr::NetworkReductionData)
11171117
return
11181118
end
11191119
function _remake_reverse_series_branch_map!(nr::NetworkReductionData)
1120-
reverse_series_branch_map = Dict{PSY.Branch, Tuple{Int, Int}}()
1120+
reverse_series_branch_map = Dict{PSY.ACTransmission, Tuple{Int, Int}}()
11211121
for (k, v) in nr.series_branch_map
11221122
for x in v
11231123
reverse_series_branch_map[x] = k

src/common.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function get_arc_tuple(br::PSY.ACTransmission, nr::NetworkReductionData)
8989
end
9090

9191
#Assumes set of branches are in parallel
92-
function get_arc_tuple(br::Set{PSY.Branch}, nr::NetworkReductionData)
92+
function get_arc_tuple(br::Set{PSY.ACTransmission}, nr::NetworkReductionData)
9393
get_arc_tuple(PSY.get_arc(first(br)), nr)
9494
end
9595

src/degree_two_reduction.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function get_degree2_reduction(
1010
data::SparseArrays.SparseMatrixCSC{Int8, Int},
1111
bus_lookup::Dict{Int, Int},
1212
exempt_bus_positions::Set{Int},
13-
direct_branch_map::Dict{Tuple{Int, Int}, PSY.Branch},
14-
parallel_branch_map::Dict{Tuple{Int, Int}, Set{PSY.Branch}},
13+
direct_branch_map::Dict{Tuple{Int, Int}, PSY.ACTransmission},
14+
parallel_branch_map::Dict{Tuple{Int, Int}, Set{PSY.ACTransmission}},
1515
transformer3W_map::Dict{Tuple{Int, Int}, Tuple{PSY.ThreeWindingTransformer, Int}},
1616
)
1717
reverse_bus_lookup = Dict(v => k for (k, v) in bus_lookup)
@@ -68,8 +68,8 @@ function _make_reverse_series_branch_map(
6868
end
6969

7070
function _get_branch_map_entry(
71-
direct_branch_map::Dict{Tuple{Int, Int}, PSY.Branch},
72-
parallel_branch_map::Dict{Tuple{Int, Int}, Set{PSY.Branch}},
71+
direct_branch_map::Dict{Tuple{Int, Int}, PSY.ACTransmission},
72+
parallel_branch_map::Dict{Tuple{Int, Int}, Set{PSY.ACTransmission}},
7373
transformer3W_map::Dict{Tuple{Int, Int}, Tuple{PSY.ThreeWindingTransformer, Int}},
7474
arc::Tuple{Int, Int},
7575
)

0 commit comments

Comments
 (0)