Skip to content

Commit

Permalink
REF: prob. formulations to remove unnecessary loops when creating the…
Browse files Browse the repository at this point in the history
… KCL constraints. This significantly reduces the time to create the ITD JuMP models.
  • Loading branch information
juanjospina committed Apr 26, 2024
1 parent 71bde43 commit a719b27
Show file tree
Hide file tree
Showing 19 changed files with 845 additions and 513 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## staged

- none.
- Refactored code in `ref.jl` function `_ref_filter_transmission_integration_loads!` to allow connecting multiple distro. systems to same trans. system bus.
- Refactored `/prob/` formulations to avoid unnecessary loops when deciding KCL contraints for boundary buses vs. regular buses.
- This refactor significantly reduces loops and should reduce time to build ITD JuMP models.
- This refactor also allows building ITD models where multiple distro. systems can be connected to same trans. system bus and KCL constraints are not duplicated.
- Bumped PMITD compatibility of `PMD` to the latest version (i.e., v0.15.2).

## v0.8.1

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ JSON = "~0.18, ~0.19, ~0.20, ~0.21"
JuMP = "~0.22, ~0.23, 1"
LinearAlgebra = "1.6"
PowerModels = "0.20"
PowerModelsDistribution = "0.15.1"
PowerModelsDistribution = "0.15.2"
SCS = "~1.0, ~1.1"
julia = "1.6"

Expand Down
4 changes: 2 additions & 2 deletions src/core/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ function solve_model(
result = _IM.optimize_model!(
pmitd, optimizer=optimizer, solution_processors=solution_processors)

# Inform about the time for solving the problem (*change to @debug)
@info "pmitd model solution time (instantiate + optimization): $(time() - start_time)"
# Inform about the time for solving the problem (*change to @debug)
@info "pmitd model solution time (instantiate + optimization): $(time() - start_time)"

# Transform solution (both T&D) - SI or per unit - MATH or ENG.
if (make_si == false)
Expand Down
13 changes: 9 additions & 4 deletions src/core/ref.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ function _ref_filter_transmission_integration_loads!(ref::Dict{Symbol,<:Any})
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
# 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

conn["pbound_fr_start"] = 0.0
conn["qbound_fr_start"] = 0.0

# Remove loads
nw_ref[:load] = Dict(x for x in nw_ref[:load] if x.second["load_bus"] != conn["transmission_boundary"] )
Expand Down
7 changes: 3 additions & 4 deletions src/form/acp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
pmitd::AbstractPowerModelITD,
pm::_PM.AbstractACPModel,
n::Int,
j::Int,
i::Int,
bus_arcs,
bus_arcs_dc,
Expand All @@ -21,7 +20,7 @@
ACP transmission constraint power balance.
"""
function constraint_transmission_power_balance(pmitd::AbstractPowerModelITD, pm::_PM.AbstractACPModel, n::Int, j::Int, i::Int, bus_arcs, bus_arcs_dc, bus_arcs_sw, bus_gens, bus_storage, bus_pd, bus_qd, bus_gs, bus_bs, bus_arcs_boundary_from)
function constraint_transmission_power_balance(pmitd::AbstractPowerModelITD, pm::_PM.AbstractACPModel, n::Int, i::Int, bus_arcs, bus_arcs_dc, bus_arcs_sw, bus_gens, bus_storage, bus_pd, bus_qd, bus_gs, bus_bs, bus_arcs_boundary_from)

vm = _PM.var(pm, n, :vm, i)

Expand Down Expand Up @@ -111,7 +110,6 @@ end
pmitd::AbstractPowerModelITD,
pmd::_PMD.AbstractUnbalancedACPModel,
n::Int,
j::Int,
i::Int,
terminals::Vector{Int},
grounded::Vector{Bool},
Expand All @@ -127,7 +125,8 @@ end
ACPU distribution constraint power balance.
"""
function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd::_PMD.AbstractUnbalancedACPModel, n::Int, j::Int, i::Int, terminals::Vector{Int}, grounded::Vector{Bool}, bus_arcs::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_arcs_sw::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_arcs_trans::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_gens::Vector{Tuple{Int,Vector{Int}}}, bus_storage::Vector{Tuple{Int,Vector{Int}}}, bus_loads::Vector{Tuple{Int,Vector{Int}}}, bus_shunts::Vector{Tuple{Int,Vector{Int}}}, bus_arcs_boundary_to)
function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd::_PMD.AbstractUnbalancedACPModel, n::Int, i::Int, terminals::Vector{Int}, grounded::Vector{Bool}, bus_arcs::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_arcs_sw::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_arcs_trans::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_gens::Vector{Tuple{Int,Vector{Int}}}, bus_storage::Vector{Tuple{Int,Vector{Int}}}, bus_loads::Vector{Tuple{Int,Vector{Int}}}, bus_shunts::Vector{Tuple{Int,Vector{Int}}}, bus_arcs_boundary_to)

vm = _PMD.var(pmd, n, :vm, i)
va = _PMD.var(pmd, n, :va, i)

Expand Down
6 changes: 2 additions & 4 deletions src/form/acr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
pmitd::AbstractPowerModelITD,
pm::_PM.AbstractACRModel,
n::Int,
j::Int,
i::Int,
bus_arcs,
bus_arcs_dc,
Expand All @@ -21,7 +20,7 @@
ACR transmission constraint power balance.
"""
function constraint_transmission_power_balance(pmitd::AbstractPowerModelITD, pm::_PM.AbstractACRModel, n::Int, j::Int, i::Int, bus_arcs, bus_arcs_dc, bus_arcs_sw, bus_gens, bus_storage, bus_pd, bus_qd, bus_gs, bus_bs, bus_arcs_boundary_from)
function constraint_transmission_power_balance(pmitd::AbstractPowerModelITD, pm::_PM.AbstractACRModel, n::Int, i::Int, bus_arcs, bus_arcs_dc, bus_arcs_sw, bus_gens, bus_storage, bus_pd, bus_qd, bus_gs, bus_bs, bus_arcs_boundary_from)
vr = _PM.var(pm, n, :vr, i)
vi = _PM.var(pm, n, :vi, i)

Expand Down Expand Up @@ -76,7 +75,6 @@ end
pmitd::AbstractPowerModelITD,
pmd::_PMD.AbstractUnbalancedACRModel,
n::Int,
j::Int,
i::Int,
terminals::Vector{Int},
grounded::Vector{Bool},
Expand All @@ -92,7 +90,7 @@ end
ACRU distribution constraint power balance.
"""
function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd::_PMD.AbstractUnbalancedACRModel, n::Int, j::Int, i::Int, terminals::Vector{Int}, grounded::Vector{Bool}, bus_arcs::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_arcs_sw::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_arcs_trans::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_gens::Vector{Tuple{Int,Vector{Int}}}, bus_storage::Vector{Tuple{Int,Vector{Int}}}, bus_loads::Vector{Tuple{Int,Vector{Int}}}, bus_shunts::Vector{Tuple{Int,Vector{Int}}}, bus_arcs_boundary_to)
function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd::_PMD.AbstractUnbalancedACRModel, n::Int, i::Int, terminals::Vector{Int}, grounded::Vector{Bool}, bus_arcs::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_arcs_sw::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_arcs_trans::Vector{Tuple{Tuple{Int,Int,Int},Vector{Int}}}, bus_gens::Vector{Tuple{Int,Vector{Int}}}, bus_storage::Vector{Tuple{Int,Vector{Int}}}, bus_loads::Vector{Tuple{Int,Vector{Int}}}, bus_shunts::Vector{Tuple{Int,Vector{Int}}}, bus_arcs_boundary_to)
vr = _PMD.var(pmd, n, :vr, i)
vi = _PMD.var(pmd, n, :vi, i)

Expand Down
162 changes: 66 additions & 96 deletions src/form/boundary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,169 +158,139 @@ end
"""
function constraint_transmission_power_balance_boundary(
pmitd::AbstractPowerModelITD,
i::Int,
j::Int,
boundary_buses::Vector;
i::Int;
nw_pmitd::Int=nw_id_default
)
General power balance contraints for boundary buses in the transmission system-side.
"""
function constraint_transmission_power_balance_boundary(pmitd::AbstractPowerModelITD, i::Int, j::Int, boundary_buses::Vector; nw_pmitd::Int=nw_id_default)
function constraint_transmission_power_balance_boundary(pmitd::AbstractPowerModelITD, i::Int; nw_pmitd::Int=nw_id_default)

# Extract the transmission model
pm_model = _get_powermodel_from_powermodelitd(pmitd)
bus = _PM.ref(pm_model, nw_pmitd, :bus, i)

boundary_pmitd = ref(pmitd, nw_pmitd, :boundary, j)
bus_pm = boundary_pmitd["f_bus"]
bus_arcs = _PM.ref(pm_model, nw_pmitd, :bus_arcs, i)
bus_arcs_dc = _PM.ref(pm_model, nw_pmitd, :bus_arcs_dc, i)
bus_arcs_sw = _PM.ref(pm_model, nw_pmitd, :bus_arcs_sw, i)
bus_gens = _PM.ref(pm_model, nw_pmitd, :bus_gens, i)
bus_loads = _PM.ref(pm_model, nw_pmitd, :bus_loads, i)
bus_shunts = _PM.ref(pm_model, nw_pmitd, :bus_shunts, i)
bus_storage = _PM.ref(pm_model, nw_pmitd, :bus_storage, i)

if bus["bus_i"] == bus_pm # consider Power flowing through respective boundary connection
bus_arcs = _PM.ref(pm_model, nw_pmitd, :bus_arcs, i)
bus_arcs_dc = _PM.ref(pm_model, nw_pmitd, :bus_arcs_dc, i)
bus_arcs_sw = _PM.ref(pm_model, nw_pmitd, :bus_arcs_sw, i)
bus_gens = _PM.ref(pm_model, nw_pmitd, :bus_gens, i)
bus_loads = _PM.ref(pm_model, nw_pmitd, :bus_loads, i)
bus_shunts = _PM.ref(pm_model, nw_pmitd, :bus_shunts, i)
bus_storage = _PM.ref(pm_model, nw_pmitd, :bus_storage, i)
bus_pd = Dict(k => _PM.ref(pm_model, nw_pmitd, :load, k, "pd") for k in bus_loads)
bus_qd = Dict(k => _PM.ref(pm_model, nw_pmitd, :load, k, "qd") for k in bus_loads)

bus_pd = Dict(k => _PM.ref(pm_model, nw_pmitd, :load, k, "pd") for k in bus_loads)
bus_qd = Dict(k => _PM.ref(pm_model, nw_pmitd, :load, k, "qd") for k in bus_loads)
bus_gs = Dict(k => _PM.ref(pm_model, nw_pmitd, :shunt, k, "gs") for k in bus_shunts)
bus_bs = Dict(k => _PM.ref(pm_model, nw_pmitd, :shunt, k, "bs") for k in bus_shunts)

bus_gs = Dict(k => _PM.ref(pm_model, nw_pmitd, :shunt, k, "gs") for k in bus_shunts)
bus_bs = Dict(k => _PM.ref(pm_model, nw_pmitd, :shunt, k, "bs") for k in bus_shunts)
bus_arcs_boundary_from = ref(pmitd, nw_pmitd, :bus_arcs_boundary_from, i)
constraint_transmission_power_balance(pmitd, pm_model, nw_pmitd, i, bus_arcs, bus_arcs_dc, bus_arcs_sw, bus_gens, bus_storage, bus_pd, bus_qd, bus_gs, bus_bs, bus_arcs_boundary_from)

bus_arcs_boundary_from = ref(pmitd, nw_pmitd, :bus_arcs_boundary_from, i)
constraint_transmission_power_balance(pmitd, pm_model, nw_pmitd, j, i, bus_arcs, bus_arcs_dc, bus_arcs_sw, bus_gens, bus_storage, bus_pd, bus_qd, bus_gs, bus_bs, bus_arcs_boundary_from)
push!(boundary_buses, bus_pm) # add to vector storage
end
end


"""
function constraint_distribution_power_balance_boundary(
pmitd::AbstractPowerModelITD,
i::Int,
j::Int,
boundary_buses::Vector;
i::Int;
nw_pmitd::Int=nw_id_default
)
General power balance contraints for boundary buses in the distribution system-side.
"""
function constraint_distribution_power_balance_boundary(pmitd::AbstractPowerModelITD, i::Int, j::Int, boundary_buses::Vector; nw_pmitd::Int=nw_id_default)
function constraint_distribution_power_balance_boundary(pmitd::AbstractPowerModelITD, i::Int; nw_pmitd::Int=nw_id_default)

# Extract the distribution model
pmd_model = _get_powermodeldistribution_from_powermodelitd(pmitd)
bus = _PMD.ref(pmd_model, nw_pmitd, :bus, i)

boundary_pmitd = ref(pmitd, nw_pmitd, :boundary, j)
bus_pmd = boundary_pmitd["t_bus"]

if bus["bus_i"] == bus_pmd # consider Power flowing through respective boundary connection
bus_arcs = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_branch, i)
bus_arcs_sw = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_switch, i)
bus_arcs_trans = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_transformer, i)
bus_gens = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_gen, i)
bus_storage = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_storage, i)
bus_loads = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_load, i)
bus_shunts = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_shunt, i)

if !haskey(_PMD.con(pmd_model, nw_pmitd), :lam_kcl_r)
_PMD.con(pmd_model, nw_pmitd)[:lam_kcl_r] = Dict{Int,Array{JuMP.ConstraintRef}}()
end

if !haskey(_PMD.con(pmd_model, nw_pmitd), :lam_kcl_i)
_PMD.con(pmd_model, nw_pmitd)[:lam_kcl_i] = Dict{Int,Array{JuMP.ConstraintRef}}()
end

bus_arcs_boundary_to = ref(pmitd, nw_pmitd, :bus_arcs_boundary_to, i)
constraint_distribution_power_balance(pmitd, pmd_model, nw_pmitd, j, i, bus["terminals"], bus["grounded"], bus_arcs, bus_arcs_sw, bus_arcs_trans, bus_gens, bus_storage, bus_loads, bus_shunts, bus_arcs_boundary_to)
push!(boundary_buses, bus_pmd) # add to vector storage
bus_arcs = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_branch, i)
bus_arcs_sw = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_switch, i)
bus_arcs_trans = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_transformer, i)
bus_gens = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_gen, i)
bus_storage = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_storage, i)
bus_loads = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_load, i)
bus_shunts = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_shunt, i)

if !haskey(_PMD.con(pmd_model, nw_pmitd), :lam_kcl_r)
_PMD.con(pmd_model, nw_pmitd)[:lam_kcl_r] = Dict{Int,Array{JuMP.ConstraintRef}}()
end

if !haskey(_PMD.con(pmd_model, nw_pmitd), :lam_kcl_i)
_PMD.con(pmd_model, nw_pmitd)[:lam_kcl_i] = Dict{Int,Array{JuMP.ConstraintRef}}()
end

bus_arcs_boundary_to = ref(pmitd, nw_pmitd, :bus_arcs_boundary_to, i)
constraint_distribution_power_balance(pmitd, pmd_model, nw_pmitd, i, bus["terminals"], bus["grounded"], bus_arcs, bus_arcs_sw, bus_arcs_trans, bus_gens, bus_storage, bus_loads, bus_shunts, bus_arcs_boundary_to)

end


"""
function constraint_transmission_current_balance_boundary(
pmitd::AbstractIVRPowerModelITD,
i::Int,
j::Int,
boundary_buses::Vector;
i::Int;
nw_pmitd::Int=nw_id_default
)
General current balance contraints for boundary buses in the transmission system-side.
"""
function constraint_transmission_current_balance_boundary(pmitd::AbstractIVRPowerModelITD, i::Int, j::Int, boundary_buses::Vector; nw_pmitd::Int=nw_id_default)
function constraint_transmission_current_balance_boundary(pmitd::AbstractIVRPowerModelITD, i::Int; nw_pmitd::Int=nw_id_default)

# Extract the transmission model
pm_model = _get_powermodel_from_powermodelitd(pmitd)
bus = _PM.ref(pm_model, nw_pmitd, :bus, i)

boundary_pmitd = ref(pmitd, nw_pmitd, :boundary, j)
bus_pm = boundary_pmitd["f_bus"]

if bus["bus_i"] == bus_pm # consider Current flowing through respective boundary connection
if !haskey(_PM.con(pm_model, nw_pmitd), :kcl_cr)
_PM.con(pm_model, nw_pmitd)[:kcl_cr] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PM.con(pm_model, nw_pmitd), :kcl_ci)
_PM.con(pm_model, nw_pmitd)[:kcl_ci] = Dict{Int,JuMP.ConstraintRef}()
end

if !haskey(_PM.con(pm_model, nw_pmitd), :kcl_cr)
_PM.con(pm_model, nw_pmitd)[:kcl_cr] = Dict{Int,JuMP.ConstraintRef}()
end
if !haskey(_PM.con(pm_model, nw_pmitd), :kcl_ci)
_PM.con(pm_model, nw_pmitd)[:kcl_ci] = Dict{Int,JuMP.ConstraintRef}()
end
bus_arcs = _PM.ref(pm_model, nw_pmitd, :bus_arcs, i)
bus_arcs_dc = _PM.ref(pm_model, nw_pmitd, :bus_arcs_dc, i)
bus_gens = _PM.ref(pm_model, nw_pmitd, :bus_gens, i)
bus_loads = _PM.ref(pm_model, nw_pmitd, :bus_loads, i)
bus_shunts = _PM.ref(pm_model, nw_pmitd, :bus_shunts, i)

bus_arcs = _PM.ref(pm_model, nw_pmitd, :bus_arcs, i)
bus_arcs_dc = _PM.ref(pm_model, nw_pmitd, :bus_arcs_dc, i)
bus_gens = _PM.ref(pm_model, nw_pmitd, :bus_gens, i)
bus_loads = _PM.ref(pm_model, nw_pmitd, :bus_loads, i)
bus_shunts = _PM.ref(pm_model, nw_pmitd, :bus_shunts, i)
bus_pd = Dict(k => _PM.ref(pm_model, nw_pmitd, :load, k, "pd") for k in bus_loads)
bus_qd = Dict(k => _PM.ref(pm_model, nw_pmitd, :load, k, "qd") for k in bus_loads)

bus_pd = Dict(k => _PM.ref(pm_model, nw_pmitd, :load, k, "pd") for k in bus_loads)
bus_qd = Dict(k => _PM.ref(pm_model, nw_pmitd, :load, k, "qd") for k in bus_loads)
bus_gs = Dict(k => _PM.ref(pm_model, nw_pmitd, :shunt, k, "gs") for k in bus_shunts)
bus_bs = Dict(k => _PM.ref(pm_model, nw_pmitd, :shunt, k, "bs") for k in bus_shunts)

bus_gs = Dict(k => _PM.ref(pm_model, nw_pmitd, :shunt, k, "gs") for k in bus_shunts)
bus_bs = Dict(k => _PM.ref(pm_model, nw_pmitd, :shunt, k, "bs") for k in bus_shunts)
bus_arcs_boundary_from = ref(pmitd, nw_pmitd, :bus_arcs_boundary_from, i)
constraint_transmission_current_balance(pmitd, pm_model, nw_pmitd, i, bus_arcs, bus_arcs_dc, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs, bus_arcs_boundary_from)

bus_arcs_boundary_from = ref(pmitd, nw_pmitd, :bus_arcs_boundary_from, i)
constraint_transmission_current_balance(pmitd, pm_model, nw_pmitd, j, i, bus_arcs, bus_arcs_dc, bus_gens, bus_pd, bus_qd, bus_gs, bus_bs, bus_arcs_boundary_from)
push!(boundary_buses, bus_pm) # add to vector storage
end
end


"""
function constraint_distribution_current_balance_boundary(
pmitd::AbstractIVRPowerModelITD,
i::Int,
j::Int,
boundary_buses::Vector;
i::Int;
nw_pmitd::Int=nw_id_default
)
General current balance contraints for boundary buses in the distribution system-side.
"""
function constraint_distribution_current_balance_boundary(pmitd::AbstractIVRPowerModelITD, i::Int, j::Int, boundary_buses::Vector; nw_pmitd::Int=nw_id_default)
function constraint_distribution_current_balance_boundary(pmitd::AbstractIVRPowerModelITD, i::Int; nw_pmitd::Int=nw_id_default)

# Extract the distribution model
pmd_model = _get_powermodeldistribution_from_powermodelitd(pmitd)
bus = _PMD.ref(pmd_model, nw_pmitd, :bus, i)

boundary_pmitd = ref(pmitd, nw_pmitd, :boundary, j)
bus_pmd = boundary_pmitd["t_bus"]

if bus["bus_i"] == bus_pmd # consider Current flowing through respective boundary connection
bus_arcs = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_branch, i)
bus_arcs_sw = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_switch, i)
bus_arcs_trans = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_transformer, i)
bus_gens = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_gen, i)
bus_storage = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_storage, i)
bus_loads = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_load, i)
bus_shunts = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_shunt, i)

bus_arcs_boundary_to = ref(pmitd, nw_pmitd, :bus_arcs_boundary_to, i)
constraint_distribution_current_balance(pmitd, pmd_model, nw_pmitd, j, i, bus["terminals"], bus["grounded"], bus_arcs, bus_arcs_sw, bus_arcs_trans, bus_gens, bus_storage, bus_loads, bus_shunts, bus_arcs_boundary_to)
push!(boundary_buses, bus_pmd) # add to vector storage
end
bus_arcs = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_branch, i)
bus_arcs_sw = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_switch, i)
bus_arcs_trans = _PMD.ref(pmd_model, nw_pmitd, :bus_arcs_conns_transformer, i)
bus_gens = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_gen, i)
bus_storage = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_storage, i)
bus_loads = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_load, i)
bus_shunts = _PMD.ref(pmd_model, nw_pmitd, :bus_conns_shunt, i)

bus_arcs_boundary_to = ref(pmitd, nw_pmitd, :bus_arcs_boundary_to, i)
constraint_distribution_current_balance(pmitd, pmd_model, nw_pmitd, i, bus["terminals"], bus["grounded"], bus_arcs, bus_arcs_sw, bus_arcs_trans, bus_gens, bus_storage, bus_loads, bus_shunts, bus_arcs_boundary_to)

end
Loading

0 comments on commit a719b27

Please sign in to comment.