Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add PST constraints for DCPPowerModels #874

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/form/dcp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ function expression_branch_power_ohms_yt_to(pm::AbstractDCPModel, n::Int, f_bus,
# omit reactive constraint
end

function constraint_ohms_y_oltc_pst_from(pm::AbstractDCPModel, n::Int, f_bus, t_bus, f_idx, t_idx, g, b, g_fr, b_fr)
p_fr = var(pm, n, :p, f_idx)
va_fr = var(pm, n, :va, f_bus)
va_to = var(pm, n, :va, t_bus)
ta = var(pm, n, :ta, f_idx[1])

JuMP.@constraint(pm.model, p_fr == -b*(va_fr - va_to - ta))
end

function constraint_ohms_y_oltc_pst_to(pm::AbstractDCPModel, n::Int, f_bus, t_bus, f_idx, t_idx, g, b, g_to, b_to)
p_to = var(pm, n, :p, t_idx)
va_fr = var(pm, n, :va, f_bus)
va_to = var(pm, n, :va, t_bus)
ta = var(pm, n, :ta, f_idx[1])

JuMP.@constraint(pm.model, p_to == -b*(va_to - va_fr + ta))
end


function constraint_ne_ohms_yt_from(pm::AbstractDCPModel, n::Int, i, f_bus, t_bus, f_idx, t_idx, g, b, g_fr, b_fr, tr, ti, tm, vad_min, vad_max)
p_fr = var(pm, n, :p_ne, f_idx)
va_fr = var(pm, n, :va, f_bus)
Expand Down
44 changes: 44 additions & 0 deletions test/opf-var.jl
Original file line number Diff line number Diff line change
Expand Up @@ -941,4 +941,48 @@ end
@test isapprox(result["solution"]["branch"]["3"]["ta"], 5.0/180*pi; atol = 1e-1)
end
end

@testset "test dc polar opf" begin
@testset "3-bus case with fixed phase shift / tap" begin
file = "../test/data/matpower/case3_oltc_pst.m"
data = PowerModels.parse_file(file)
result = PowerModels.run_opf(data, DCPPowerModel, milp_solver)

@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 5782.0; atol = 1e0)
end

@testset "3-bus case with optimal phase shifting / tap changing" begin
file = "../test/data/matpower/case3_oltc_pst.m"
data = PowerModels.parse_file(file)
result = PowerModels._solve_opf_oltc_pst(data, DCPPowerModel, milp_solver)

@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 5639.0; atol = 1e0)

@test haskey(result["solution"]["branch"]["1"], "ta")

@test isapprox(result["solution"]["branch"]["1"]["ta"], 0.000; atol = 1e-3)
@test isapprox(result["solution"]["branch"]["2"]["ta"], 0.000; atol = 1e-3)
@test isapprox(result["solution"]["branch"]["3"]["ta"], 15.0/180*pi; atol = 1e-1)
end


@testset "3-bus case with optimal phase shifting / tap changing with equal lb/ub" begin
file = "../test/data/matpower/case3_oltc_pst.m"
data = PowerModels.parse_file(file)
for (i, branch) in data["branch"]
branch["ta_min"] = branch["shift"]
branch["ta_max"] = branch["shift"]
end
result = PowerModels._solve_opf_oltc_pst(data, DCPPowerModel, milp_solver)

@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 5698.1; atol = 1e0)

@test isapprox(result["solution"]["branch"]["1"]["ta"], 0.000; atol = 1e-3)
@test isapprox(result["solution"]["branch"]["2"]["ta"], 0.000; atol = 1e-3)
@test isapprox(result["solution"]["branch"]["3"]["ta"], 5.0/180*pi; atol = 1e-1)
end
end
end