Skip to content

Commit

Permalink
Merge pull request #25 from lanl-ansi/pms-0.7
Browse files Browse the repository at this point in the history
Update to PowerModels v0.7
  • Loading branch information
rb004f authored May 15, 2018
2 parents 0207dec + bfb4761 commit 5bc5dfc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
julia 0.6

PowerModels 0.6 0.7-
PowerModels 0.7 0.8-
InfrastructureModels 0.0.4 0.2-
CurveFit

Compat 0.26.0
Expand Down
3 changes: 2 additions & 1 deletion src/PowerModelsGMD.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
isdefined(Base, :__precompile__) && __precompile__()

module PowerModelsGMD
using PowerModels
using JuMP
using InfrastructureModels
using PowerModels
using CurveFit
using Memento

Expand Down
2 changes: 1 addition & 1 deletion src/core/constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function constraint_dc_ohms_on_off{T}(pm::GenericPowerModel{T}, n::Int, i, gs, v
z = pm.var[:nw][n][:branch_z][ac_branch]

@constraint(pm.model, v_dc_diff == vf - vt)
PowerModels.relaxation_product(pm.model, z, v_dc_diff, vz)
InfrastructureModels.relaxation_product(pm.model, z, v_dc_diff, vz)
@constraint(pm.model, dc == gs*(vz + z*vs) )
end

Expand Down
20 changes: 10 additions & 10 deletions src/form/wr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ function constraint_current(pm::GenericPowerModel{T}, n::Int, i, f_idx, f_bus, t
if buspair["branch"] == i
# p_fr^2 + q_fr^2 <= l * w comes for free with constraint_power_magnitude_sqr of PowerModels.jl
l = pm.var[:nw][n][:cm][(f_bus, t_bus)]
PowerModels.relaxation_sqr(pm.model, i_ac_mag, l)
InfrastructureModels.relaxation_sqr(pm.model, i_ac_mag, l)
else
l = pm.var[:nw][n][:cm_p][i]
w = pm.var[:nw][n][:w][f_bus]
p_fr = pm.var[:nw][n][:p][arc_from]
q_fr = pm.var[:nw][n][:q][arc_from]

@constraint(pm.model, p_fr^2 + q_fr^2 <= l * w)
PowerModels.relaxation_sqr(pm.model, i_ac_mag, l)
InfrastructureModels.relaxation_sqr(pm.model, i_ac_mag, l)
end
end

Expand All @@ -110,27 +110,27 @@ function constraint_thermal_protection(pm::GenericPowerModel{T}, n::Int, i, coef
ieff = pm.var[:nw][n][:i_dc_mag][i]
ieff_sqr = pm.var[:nw][n][:i_dc_mag_sqr][i]

@constraint(pm.model, i_ac_mag <= coeff[1] + coeff[2]*ieff/ibase + coeff[3]*ieff_sqr/(ibase^2))
PowerModels.relaxation_sqr(pm.model, ieff, ieff_sqr)
@constraint(pm.model, i_ac_mag <= coeff[1] + coeff[2]*ieff/ibase + coeff[3]*ieff_sqr/(ibase^2))
InfrastructureModels.relaxation_sqr(pm.model, ieff, ieff_sqr)
end

"Constraint for computing qloss"
function constraint_qloss(pm::GenericPowerModel{T}, n::Int, k, i, j) where T <: PowerModels.AbstractWRForm
i_dc_mag = pm.var[:nw][n][:i_dc_mag][k]
qloss = pm.var[:nw][n][:qloss]
iv = pm.var[:nw][n][:iv][(k,i,j)]
iv = pm.var[:nw][n][:iv][(k,i,j)]
vm = pm.var[:nw][n][:vm][i]

@constraint(pm.model, qloss[(k,i,j)] == 0.0)
@constraint(pm.model, qloss[(k,j,i)] == 0.0)
PowerModels.relaxation_product(pm.model, i_dc_mag, vm, iv)
@constraint(pm.model, qloss[(k,j,i)] == 0.0)
InfrastructureModels.relaxation_product(pm.model, i_dc_mag, vm, iv)
end

"Constraint for computing qloss"
function constraint_qloss(pm::GenericPowerModel{T}, n::Int, k, i, j, K, branchMVA) where T <: PowerModels.AbstractWRForm
i_dc_mag = pm.var[:nw][n][:i_dc_mag][k]
qloss = pm.var[:nw][n][:qloss]
iv = pm.var[:nw][n][:iv][(k,i,j)]
iv = pm.var[:nw][n][:iv][(k,i,j)]
vm = pm.var[:nw][n][:vm][i]

if getlowerbound(i_dc_mag) > 0.0 || getupperbound(i_dc_mag) < 0.0
Expand All @@ -139,6 +139,6 @@ function constraint_qloss(pm::GenericPowerModel{T}, n::Int, k, i, j, K, branchMV

# K is per phase
@constraint(pm.model, qloss[(k,i,j)] == K*iv/(3.0*branchMVA))
@constraint(pm.model, qloss[(k,j,i)] == 0.0)
PowerModels.relaxation_product(pm.model, i_dc_mag, vm, iv)
@constraint(pm.model, qloss[(k,j,i)] == 0.0)
InfrastructureModels.relaxation_product(pm.model, i_dc_mag, vm, iv)
end

0 comments on commit 5bc5dfc

Please sign in to comment.