Skip to content

Commit 57d382d

Browse files
authored
fix bug in calc_theta_delta_bounds (lanl-ansi#908)
closes lanl-ansi#907
1 parent 8a1dc36 commit 57d382d

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ PowerModels.jl Change Log
44
### Staged
55
- nothing
66

7+
### v0.21.1
8+
- Fix bug in `calc_theta_delta_bounds` (#907)
9+
710
### v0.21.0
811
- Update to new JuMP nonlinear interface (breaking)
912

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "PowerModels"
22
uuid = "c36e90e8-916a-50a6-bd94-075b64ef4655"
33
authors = ["Carleton Coffrin"]
44
repo = "https://github.com/lanl-ansi/PowerModels.jl"
5-
version = "0.21.0"
5+
version = "0.21.1"
66

77
[deps]
88
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"

src/core/data.jl

+12-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,18 @@ function calc_theta_delta_bounds(data::Dict{String,<:Any})
5050
sort!(angle_mins)
5151
sort!(angle_maxs, rev=true)
5252

53-
return angle_mins[1], angle_maxs[1]
53+
if length(angle_mins) > 1
54+
# note that, this can occur when dclines are present
55+
angle_count = min(bus_count-1, length(branches))
56+
57+
angle_min_val = sum(angle_mins[1:angle_count])
58+
angle_max_val = sum(angle_maxs[1:angle_count])
59+
else
60+
angle_min_val = angle_mins[1]
61+
angle_max_val = angle_maxs[1]
62+
end
63+
64+
return angle_min_val, angle_max_val
5465
end
5566

5667

test/data.jl

+29
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,35 @@ end
603603
end
604604

605605

606+
@testset "test theta delta bounds" begin
607+
608+
@testset "5-bus test" begin
609+
data = PowerModels.parse_file("../test/data/matpower/case5.m")
610+
theta_lb, theta_ub = calc_theta_delta_bounds(data)
611+
612+
@test theta_lb[1] <= -2.0
613+
@test theta_ub[1] >= 2.0
614+
end
615+
616+
@testset "14-bus test" begin
617+
data = PowerModels.parse_file("../test/data/matpower/case14.m")
618+
theta_lb, theta_ub = calc_theta_delta_bounds(data)
619+
620+
@test theta_lb[1] <= -13.0
621+
@test theta_ub[1] >= 13.0
622+
end
623+
624+
@testset "30-bus test" begin
625+
data = PowerModels.parse_file("../test/data/matpower/case30.m")
626+
theta_lb, theta_ub = calc_theta_delta_bounds(data)
627+
628+
@test theta_lb[1] <= -15.0
629+
@test theta_ub[1] >= 15.0
630+
end
631+
632+
end
633+
634+
606635
@testset "test branch flow computations" begin
607636

608637
@testset "5-bus ac polar flow" begin

0 commit comments

Comments
 (0)