Skip to content

Commit

Permalink
extending constraint_power_magnitude_link to asymetric line charge, c…
Browse files Browse the repository at this point in the history
…loses #284
  • Loading branch information
ccoffrin committed Jun 25, 2018
1 parent 0723e57 commit 83f6a10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 6 additions & 8 deletions src/form/wr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -488,16 +488,15 @@ end
function constraint_power_magnitude_link(pm::GenericPowerModel{T}, n::Int, h::Int, f_bus, t_bus, arc_from, g, b, g_fr, b_fr, g_to, b_to, tr, ti, tm) where T <: QCWRForm
w_fr = var(pm, n, h, :w, f_bus)
w_to = var(pm, n, h, :w, t_bus)
p_fr = var(pm, n, h, :p, arc_from)
q_fr = var(pm, n, h, :q, arc_from)
wr = var(pm, n, h, :wr, (f_bus, t_bus))
wi = var(pm, n, h, :wi, (f_bus, t_bus))
cm = var(pm, n, h, :cm, (f_bus, t_bus))

assert(g_fr == 0 && g_to == 0)
c = b_fr + b_to
ym_sh_sqr = g_fr^2 + b_fr^2

# TODO: Derive updated constraint from first principles
@constraint(pm.model, cm == (g^2 + b^2)*(w_fr/tm^2 + w_to - 2*(tr*wr + ti*wi)/tm^2) - c*q_fr - ((c/2)/tm^2)^2*w_fr)
@constraint(pm.model, cm == (g^2 + b^2)*(w_fr/tm^2 + w_to - 2*(tr*wr + ti*wi)/tm^2) - ym_sh_sqr*(w_fr/tm^2) + 2*(g_fr*p_fr - b_fr*q_fr))
end

"`t[ref_bus] == 0`"
Expand Down Expand Up @@ -733,16 +732,15 @@ end
function constraint_power_magnitude_link_on_off(pm::GenericPowerModel{T}, n::Int, h::Int, i, arc_from, g, b, g_fr, b_fr, g_to, b_to, tr, ti, tm) where T <: QCWRForm
w_fr = var(pm, n, h, :w_fr, i)
w_to = var(pm, n, h, :w_to, i)
p_fr = var(pm, n, h, :p, arc_from)
q_fr = var(pm, n, h, :q, arc_from)
wr = var(pm, n, h, :wr, i)
wi = var(pm, n, h, :wi, i)
cm = var(pm, n, h, :cm, i)

assert(g_fr == 0.0 && g_to == 0.0)
c = b_fr + b_to
ym_sh_sqr = g_fr^2 + b_fr^2

# TODO: Derive updated constraint from first principles
@constraint(pm.model, cm == (g^2 + b^2)*(w_fr/tm^2 + w_to - 2*(tr*wr + ti*wi)/tm^2) - c*q_fr - ((c/2)/tm^2)^2*w_fr)
@constraint(pm.model, cm == (g^2 + b^2)*(w_fr/tm^2 + w_to - 2*(tr*wr + ti*wi)/tm^2) - ym_sh_sqr*(w_fr/tm^2) + 2*(g_fr*p_fr - b_fr*q_fr))
end


Expand Down
6 changes: 3 additions & 3 deletions test/ots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ end
@testset "5-bus with asymmetric line charge" begin
result = run_ots("../test/data/pti/case5_alc.raw", SOCWRPowerModel, pajarito_solver)

@test result["status"] == :LocalOptimal
@test result["status"] == :Optimal
@test isapprox(result["objective"], 1004.8; atol = 1e0)
end
@testset "6-bus case" begin
Expand Down Expand Up @@ -162,8 +162,8 @@ end
@testset "5-bus with asymmetric line charge" begin
result = run_ots("../test/data/pti/case5_alc.raw", QCWRPowerModel, pajarito_solver)

@test result["status"] == :LocalOptimal
@test isapprox(result["objective"], 1005.31; atol = 1e0)
@test result["status"] == :Optimal
@test isapprox(result["objective"], 1003.97; atol = 1e0)
end
@testset "6-bus case" begin
result = run_ots("../test/data/matpower/case6.m", QCWRPowerModel, pajarito_solver)
Expand Down

0 comments on commit 83f6a10

Please sign in to comment.