Skip to content

Commit

Permalink
fix constraints for Interchange
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Jun 11, 2024
1 parent 4e597ef commit b71335e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/devices_models/device_constructors/branch_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -942,19 +942,24 @@ function construct_device!(
# Not ideal to do this here, but it is a not terrible workaround
# The area interchanges are like a services/device mix.
# Doesn't include the possibility of Multi-terminal HVDC
inter_area_branch_map = Dict{Tuple{PSY.Area, PSY.Area}, Dict{DataType, Vector}}()
inter_area_branch_map = Dict{Tuple{PSY.Area, PSY.Area}, Dict{DataType, Vector{<:PSY.ACBranch}}}()
for d in get_available_components(network_model, PSY.ACBranch, sys)
area_from = PSY.get_area(PSY.get_arc(d).from)
area_to = PSY.get_area(PSY.get_arc(d).to)
if area_from != area_to
branch_type = typeof(d)
branch_typed_dict = get!(
inter_area_branch_map,
(area_from, area_to),
Dict(branch_type => Vector{branch_type}()),
)
branch_vector = get!(branch_typed_dict, branch_type, branch_type[])
push!(branch_vector, d)
if !haskey(inter_area_branch_map, (area_from, area_to))
branch_vector = [d]
inter_area_branch_map[(area_from, area_to)] = Dict{DataType, Vector{<:PSY.ACBranch}}(branch_type => branch_vector)
continue
else
branch_typed_dict = inter_area_branch_map[(area_from, area_to)]
end
if !haskey(branch_typed_dict, branch_type)
branch_typed_dict[branch_type] = [d]
else
push!(branch_typed_dict[branch_type], d)
end
end
end
add_constraints!(
Expand Down

0 comments on commit b71335e

Please sign in to comment.