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

Fix element type of Dict in pf.jl #939

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PowerModels.jl Change Log
=========================

### Staged
- nothing
- Fix InexactError in `compute_ac_pf` (#939)

### v0.21.3
- Fix no-buses bug in `calc_connected_components` (#933)
Expand Down
4 changes: 2 additions & 2 deletions src/prob/pf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function compute_ac_pf(pf_data::PowerFlowData; kwargs...)
if bus["bus_type"] != 4
bus_idx = am.bus_to_idx[bus["index"]]

bus_assignment[i] = Dict(
bus_assignment[i] = Dict{String,Float64}(
"vm" => pf_data.vm_idx[bus_idx],
"va" => pf_data.va_idx[bus_idx]
)
Expand All @@ -322,7 +322,7 @@ function compute_ac_pf(pf_data::PowerFlowData; kwargs...)
gen_assignment= Dict{String,Any}()
for (i,gen) in data["gen"]
if gen["gen_status"] != 0
gen_assignment[i] = Dict(
gen_assignment[i] = Dict{String,Float64}(
"pg" => gen["pg"],
"qg" => gen["qg"]
)
Expand Down
118 changes: 118 additions & 0 deletions test/data/json/issue_938.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"baseMVA": 1000,
"per_unit": true,
"shunt": {},
"storage": {},
"switch": {},
"dcline": {},
"load": {
"1": {
"load_bus": 1,
"pd": 0.1,
"qd": 0,
"index": 1,
"status": 1
}
},
"gen": {
"2": {
"gen_bus": 2,
"pg": 0.1,
"qg": 0,
"pmax": 1,
"pmin": 0,
"qmax": 9999,
"qmin": -9999,
"index": 2,
"vg": 1,
"gen_status": 1
},
"3": {
"gen_bus": 3,
"pg": 0,
"qg": 0,
"pmax": 9999,
"pmin": 0,
"qmax": 9999,
"qmin": -9999,
"index": 3,
"vg": 1,
"gen_status": 1
}
},
"branch": {
"5": {
"index": 5,
"f_bus": 1,
"t_bus": 2,
"br_r": 0.06815,
"br_x": 1.096,
"b_fr": 0.03092,
"b_to": 0.03092,
"br_status": 1,
"base_kv": 220,
"c_rating_a": 1.959,
"angmin": -0.17453292519943295,
"angmax": 0.17453292519943295,
"transformer": false,
"tap": 1,
"shift": 0,
"g_fr": 0,
"g_to": 0
},
"6": {
"index": 6,
"f_bus": 2,
"t_bus": 3,
"br_r": 0.06744,
"br_x": 1.084,
"b_fr": 0.03059,
"b_to": 0.03059,
"br_status": 1,
"base_kv": 220,
"c_rating_a": 1.959,
"angmin": -0.17453292519943295,
"angmax": 0.17453292519943295,
"transformer": false,
"tap": 1,
"shift": 0,
"g_fr": 0,
"g_to": 0
}
},
"bus": {
"1": {
"bus_type": 1,
"vm": 1,
"va": 0,
"vmin": 0.5,
"vmax": 1.5,
"index": 1,
"gen_status": 1,
"base_kv": 400.0,
"bus_i": 1
},
"2": {
"bus_type": 2,
"vm": 1,
"va": 0,
"vmin": 0.5,
"vmax": 1.5,
"index": 2,
"gen_status": 1,
"base_kv": 400.0,
"bus_i": 2
},
"3": {
"bus_type": 3,
"vm": 1,
"va": 0,
"vmin": 0.5,
"vmax": 1.5,
"index": 3,
"gen_status": 1,
"base_kv": 220.0,
"bus_i": 3
}
}
}
6 changes: 6 additions & 0 deletions test/pf-native.jl
Original file line number Diff line number Diff line change
Expand Up @@ -501,5 +501,11 @@ end
@test isapprox(data["gen"][i]["qg"], gen["qg"]; atol = 1e-6)
end
end
@testset "test_issue_938" begin
filename = joinpath(@__DIR__, "data/json/issue_938.json")
data = PowerModels.parse_file(filename)
native = PowerModels.compute_ac_pf(data)
@test native["termination_status"]
end
end

Loading