Skip to content

Commit

Permalink
fix bug in calc_theta_delta_bounds (#908)
Browse files Browse the repository at this point in the history
 closes #907
  • Loading branch information
ccoffrin committed Mar 16, 2024
1 parent 8a1dc36 commit 57d382d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ PowerModels.jl Change Log
### Staged
- nothing

### v0.21.1
- Fix bug in `calc_theta_delta_bounds` (#907)

### v0.21.0
- Update to new JuMP nonlinear interface (breaking)

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "PowerModels"
uuid = "c36e90e8-916a-50a6-bd94-075b64ef4655"
authors = ["Carleton Coffrin"]
repo = "https://github.com/lanl-ansi/PowerModels.jl"
version = "0.21.0"
version = "0.21.1"

[deps]
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
Expand Down
13 changes: 12 additions & 1 deletion src/core/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,18 @@ function calc_theta_delta_bounds(data::Dict{String,<:Any})
sort!(angle_mins)
sort!(angle_maxs, rev=true)

return angle_mins[1], angle_maxs[1]
if length(angle_mins) > 1
# note that, this can occur when dclines are present
angle_count = min(bus_count-1, length(branches))

angle_min_val = sum(angle_mins[1:angle_count])
angle_max_val = sum(angle_maxs[1:angle_count])
else
angle_min_val = angle_mins[1]
angle_max_val = angle_maxs[1]
end

return angle_min_val, angle_max_val
end


Expand Down
29 changes: 29 additions & 0 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,35 @@ end
end


@testset "test theta delta bounds" begin

@testset "5-bus test" begin
data = PowerModels.parse_file("../test/data/matpower/case5.m")
theta_lb, theta_ub = calc_theta_delta_bounds(data)

@test theta_lb[1] <= -2.0
@test theta_ub[1] >= 2.0
end

@testset "14-bus test" begin
data = PowerModels.parse_file("../test/data/matpower/case14.m")
theta_lb, theta_ub = calc_theta_delta_bounds(data)

@test theta_lb[1] <= -13.0
@test theta_ub[1] >= 13.0
end

@testset "30-bus test" begin
data = PowerModels.parse_file("../test/data/matpower/case30.m")
theta_lb, theta_ub = calc_theta_delta_bounds(data)

@test theta_lb[1] <= -15.0
@test theta_ub[1] >= 15.0
end

end


@testset "test branch flow computations" begin

@testset "5-bus ac polar flow" begin
Expand Down

0 comments on commit 57d382d

Please sign in to comment.