Skip to content

Commit

Permalink
fix bfa sign bug, closes #779 (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoffrin authored Jun 16, 2021
1 parent 7b62b50 commit 97ef99f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PowerModels.jl Change Log
=========================

### Staged
- Fixed sign bug in BFA models (#779)
- Fixed `correct_component_refrence_bus!` when no active generators are present (#776)

### v0.18.1
Expand Down
4 changes: 2 additions & 2 deletions src/form/bf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ function constraint_power_losses(pm::AbstractBFAModel, n::Int, i, f_bus, t_bus,
w_fr = var(pm, n, :w, f_bus)
w_to = var(pm, n, :w, t_bus)

JuMP.@constraint(pm.model, p_fr + p_to == g_sh_fr*(w_fr/tm^2) + g_sh_to*w_to)
JuMP.@constraint(pm.model, q_fr + q_to == b_sh_fr*(w_fr/tm^2) + b_sh_to*w_to)
JuMP.@constraint(pm.model, p_fr + p_to == g_sh_fr*(w_fr/tm^2) + g_sh_to*w_to)
JuMP.@constraint(pm.model, q_fr + q_to == -b_sh_fr*(w_fr/tm^2) - b_sh_to*w_to)
end


Expand Down
8 changes: 4 additions & 4 deletions test/multinetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,22 +385,22 @@ TESTLOG = Memento.getlogger(PowerModels)
@test isapprox(result["objective"], 57980.0; atol = 1e0)

@test isapprox(result["solution"]["nw"]["1"]["storage"]["1"]["ps"], 0.0000000; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["1"]["storage"]["1"]["qs"], 0.0543982; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["1"]["storage"]["1"]["qs"], 0.0562204; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["1"]["storage"]["2"]["ps"], -0.0834412; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["1"]["storage"]["2"]["qs"], 0.0801070; atol = 1e-3)

@test isapprox(result["solution"]["nw"]["2"]["storage"]["1"]["ps"], 0.0000000; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["2"]["storage"]["1"]["qs"], 0.0552175; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["2"]["storage"]["1"]["qs"], 0.0569621; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["2"]["storage"]["2"]["ps"], 0.0000000; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["2"]["storage"]["2"]["qs"], 0.0803519; atol = 1e-3)

@test isapprox(result["solution"]["nw"]["3"]["storage"]["1"]["ps"], 0.0000000; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["3"]["storage"]["1"]["qs"], 0.0535058; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["3"]["storage"]["1"]["qs"], 0.0553956; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["3"]["storage"]["2"]["ps"], -0.1565587; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["3"]["storage"]["2"]["qs"], 0.0806228; atol = 1e-3)

@test isapprox(result["solution"]["nw"]["4"]["storage"]["1"]["ps"], -0.1800000; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["4"]["storage"]["1"]["qs"], 0.0549343; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["4"]["storage"]["1"]["qs"], 0.0566681; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["4"]["storage"]["2"]["ps"], 0.0000000; atol = 1e-3)
@test isapprox(result["solution"]["nw"]["4"]["storage"]["2"]["qs"], 0.0802049; atol = 1e-3)

Expand Down
2 changes: 1 addition & 1 deletion test/opf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ end
result = run_opf_bf("../test/data/matpower/case3.m", BFAPowerModel, ipopt_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 5658.22; atol = 1e0)
@test isapprox(result["objective"], 5638.97; atol = 1e0)
end
@testset "5-bus transformer swap case" begin
data = PowerModels.parse_file("../test/data/matpower/case5.m")
Expand Down

0 comments on commit 97ef99f

Please sign in to comment.