Skip to content

Commit

Permalink
WIP: storage balance constraints.
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjospina committed Jul 24, 2024
1 parent 36b8c46 commit cb0be21
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/PowerModelsITD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module PowerModelsITD
include("form/fotr.jl")
include("form/fotp.jl")
include("form/lindist3flow.jl")
include("form/storage.jl")

include("prob/pfitd.jl")
include("prob/opfitd.jl")
Expand Down
42 changes: 42 additions & 0 deletions src/form/storage.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Storage constraints

function constraint_storage_phase_unbalance_distribution(pmd::_PMD.AbstractUnbalancedPowerModel, i::Int; nw::Int=nw_id_default, unbalance_factor::Float64=0.05)

ps = _PMD.var(pmd, nw, :ps, i)
qs = _PMD.var(pmd, nw, :qs, i)

sc = _PMD.var(pmd, nw, :sc, i)
sd = _PMD.var(pmd, nw, :sd, i)

conns = length(ps)
connections = collect(range(1, stop=conns))

# sd_ps = JuMP.@variable(pmd.model, [c in connections], base_name="$(nw)_sd_ps_$(i)")
# sc_ps = JuMP.@variable(pmd.model, [c in connections], base_name="$(nw)_sc_ps_$(i)")
# sd_qs = JuMP.@variable(pmd.model, [c in connections], base_name="$(nw)_sd_qs_$(i)")
# sc_qs = JuMP.@variable(pmd.model, [c in connections], base_name="$(nw)_sc_qs_$(i)")

# JuMP.@constraint(pmd.model, sum(ps) == (-1*sd + 1*sc))

JuMP.@constraint(pmd.model, ((sum(ps))^2+(sum(qs))^2) == (-1*sd + 1*sc)^2)


for (idx,c) in enumerate(connections)
if idx < length(connections)
for d in connections[idx+1:end]

# JuMP.@constraint(pmd.model, ps[c] >= ps[d] - unbalance_factor*(-1*sd_ps[d] + 1*sc_ps[d]))
# JuMP.@constraint(pmd.model, ps[c] <= ps[d] + unbalance_factor*(-1*sd_ps[d] + 1*sc_ps[d]))
# JuMP.@constraint(pmd.model, qs[c] >= qs[d] - unbalance_factor*(-1*sd_qs[d] + 1*sc_qs[d]))
# JuMP.@constraint(pmd.model, qs[c] <= qs[d] + unbalance_factor*(-1*sd_qs[d] + 1*sc_qs[d]))

JuMP.@constraint(pmd.model, ps[c] >= ps[d] - unbalance_factor*(-1*sd + 1*sc))
JuMP.@constraint(pmd.model, ps[c] <= ps[d] + unbalance_factor*(-1*sd + 1*sc))

end


end
end

end
1 change: 1 addition & 0 deletions src/prob/opfitd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ function build_mn_opfitd(pmitd::AbstractPowerModelITD)
_PMD.constraint_storage_complementarity_nl(pmd_model, i; nw=n)
_PMD.constraint_mc_storage_losses(pmd_model, i; nw=n)
_PMD.constraint_mc_storage_thermal_limit(pmd_model, i; nw=n)
constraint_storage_phase_unbalance_distribution(pmd_model, i; nw=n)
end

for i in _PMD.ids(pmd_model, n, :branch)
Expand Down
1 change: 1 addition & 0 deletions src/prob/opfitd_storage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ function build_mn_opfitd_storage(pmitd::AbstractPowerModelITD)
_PMD.constraint_storage_complementarity_nl(pmd_model, i; nw=n)
_PMD.constraint_mc_storage_losses(pmd_model, i; nw=n)
_PMD.constraint_mc_storage_thermal_limit(pmd_model, i; nw=n)
constraint_storage_phase_unbalance_distribution(pmd_model, i; nw=n)
end

for i in _PMD.ids(pmd_model, n, :branch)
Expand Down

0 comments on commit cb0be21

Please sign in to comment.