Skip to content

Commit

Permalink
ADD: support for adding the correct starting value to boundary variab…
Browse files Browse the repository at this point in the history
…les and allow to solve problems where multiple distribution systems can be connected to the same transmission system bus.
  • Loading branch information
juanjospina committed Jul 9, 2024
1 parent edc3eb1 commit 3344959
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 23 deletions.
36 changes: 23 additions & 13 deletions src/core/ref.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,32 @@ Removes/filters-out the loads at buses (i.e., boundary buses) where distribution
function _ref_filter_transmission_integration_loads!(ref::Dict{Symbol,<:Any})
# Loops over all nws
for (nw, nw_ref) in ref[:it][:pm][:nw]
# Filters only the ones that have the "transmission_boundary" key
for (i, conn) in filter(x -> "transmission_boundary" in keys(x.second), ref[:it][:pmitd][:nw][nw])

## Note: This initialization causes error when solving problems where multiple distro. systems are connected to same transmission system.
# Get init (start) values before deleting the boundary load info.
# pbound_fr_start = nw_ref[:load][nw_ref[:bus_loads][conn["transmission_boundary"]][1]]["pd"]
# qbound_fr_start = nw_ref[:load][nw_ref[:bus_loads][conn["transmission_boundary"]][1]]["qd"]
# conn["pbound_fr_start"] = pbound_fr_start
# conn["qbound_fr_start"] = qbound_fr_start
# Dictionary (temporary) to store the boundary buses transmission where loads have already been removed
boundary_buses_transmission = Dict{String, Any}()

conn["pbound_fr_start"] = 0.0
conn["qbound_fr_start"] = 0.0
# Filters only the ones that have the "transmission_boundary" key
for (i, conn) in filter(x -> "transmission_boundary" in keys(x.second), ref[:it][:pmitd][:nw][nw])

# Remove loads
nw_ref[:load] = Dict(x for x in nw_ref[:load] if x.second["load_bus"] != conn["transmission_boundary"] )
nw_ref[:bus_loads][conn["transmission_boundary"]] = []
if !haskey(boundary_buses_transmission, string(conn["transmission_boundary"]))
# Get init (start) values before deleting the boundary load info.
pbound_fr_start = nw_ref[:load][nw_ref[:bus_loads][conn["transmission_boundary"]][1]]["pd"]
qbound_fr_start = nw_ref[:load][nw_ref[:bus_loads][conn["transmission_boundary"]][1]]["qd"]
conn["pbound_fr_start"] = pbound_fr_start
conn["qbound_fr_start"] = qbound_fr_start

# Add start values to local dict to use only when a conn (boundary) is repeated
boundary_buses_transmission[string(conn["transmission_boundary"])] = Dict("pbound_fr_start" => pbound_fr_start,
"qbound_fr_start" => qbound_fr_start
)

# Remove loads - Delete the boundary load info.
nw_ref[:load] = Dict(x for x in nw_ref[:load] if x.second["load_bus"] != conn["transmission_boundary"] )
nw_ref[:bus_loads][conn["transmission_boundary"]] = []
else
conn["pbound_fr_start"] = boundary_buses_transmission[string(conn["transmission_boundary"])]["pbound_fr_start"]
conn["qbound_fr_start"] = boundary_buses_transmission[string(conn["transmission_boundary"])]["qbound_fr_start"]
end
end
end
end
Expand Down
41 changes: 31 additions & 10 deletions src/core/ref_decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,41 @@ Removes/filters-out the loads at buses (i.e., boundary buses) where distribution
function _ref_filter_transmission_integration_loads_decomposition!(ref::Dict{Symbol,<:Any})
# Loops over all nws
for (nw, nw_ref) in ref[:it][:pm][:nw]

# boundary info.
boundaries = nw_ref[:pmitd]

# Dictionary (temporary) to store the boundary buses transmission where loads have already been removed
boundary_buses_transmission = Dict{String, Any}()

# Filters only the ones that have the "transmission_boundary" key
for (i, conn) in filter(x -> "transmission_boundary" in keys(x.second), boundaries)
# Get init (start) values before deleting the boundary load info.
pd_start = nw_ref[:load][nw_ref[:bus_loads][conn["transmission_boundary"]][1]]["pd"]
qd_start = nw_ref[:load][nw_ref[:bus_loads][conn["transmission_boundary"]][1]]["qd"]
conn["pbound_load_start"] = pd_start
conn["qbound_load_start"] = qd_start
conn["pbound_load_scaled_start"] = pd_start*(conn["base_conv_factor"])
conn["qbound_load_scaled_start"] = qd_start*(conn["base_conv_factor"])

nw_ref[:load] = Dict(x for x in nw_ref[:load] if x.second["load_bus"] != conn["transmission_boundary"] )
nw_ref[:bus_loads][conn["transmission_boundary"]] = []

if !haskey(boundary_buses_transmission, string(conn["transmission_boundary"]))
# Get init (start) values before deleting the boundary load info.
pd_start = nw_ref[:load][nw_ref[:bus_loads][conn["transmission_boundary"]][1]]["pd"]
qd_start = nw_ref[:load][nw_ref[:bus_loads][conn["transmission_boundary"]][1]]["qd"]
conn["pbound_load_start"] = pd_start
conn["qbound_load_start"] = qd_start
conn["pbound_load_scaled_start"] = pd_start*(conn["base_conv_factor"])
conn["qbound_load_scaled_start"] = qd_start*(conn["base_conv_factor"])

# Add start values to local dict to use only when a conn (boundary) is repeated
boundary_buses_transmission[string(conn["transmission_boundary"])] = Dict("pbound_load_start" => pd_start,
"qbound_load_start" => qd_start,
"pbound_load_scaled_start" => conn["pbound_load_scaled_start"],
"qbound_load_scaled_start" => conn["qbound_load_scaled_start"]
)

# Remove loads - Delete the boundary load info.
nw_ref[:load] = Dict(x for x in nw_ref[:load] if x.second["load_bus"] != conn["transmission_boundary"] )
nw_ref[:bus_loads][conn["transmission_boundary"]] = []
else
conn["pbound_load_start"] = boundary_buses_transmission[string(conn["transmission_boundary"])]["pbound_load_start"]
conn["qbound_load_start"] = boundary_buses_transmission[string(conn["transmission_boundary"])]["qbound_load_start"]
conn["pbound_load_scaled_start"] = boundary_buses_transmission[string(conn["transmission_boundary"])]["pbound_load_scaled_start"]
conn["qbound_load_scaled_start"] = boundary_buses_transmission[string(conn["transmission_boundary"])]["qbound_load_scaled_start"]
end
end
end
end
Expand Down

0 comments on commit 3344959

Please sign in to comment.