Skip to content

Commit

Permalink
UPD: bank_transformers=false
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudocubic committed Sep 24, 2024
1 parent 365ecd1 commit f5a3bbd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

## v4.0.0

- Change `parse_file` to use `bank_transformers=false`, which seems to affect quality of solutions
- Upgrade to use new PowerModelsProtection fault study solver (breaking)
- Upgrade to JuMP v1.23.2, to support new NL syntax (PMD v0.16, PMS v0.4.0, PMP v0.7.1) (breaking)

Expand Down
1 change: 1 addition & 0 deletions src/io/network.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ONM version of `PowerModelsDistribution.parse_file`, which includes some `dss2en
function parse_file(network_file::String; dss2eng_extensions=Function[], transformations=Function[], import_all=true, kwargs...)
eng = PMD.parse_file(
network_file;
bank_transformers=false,
dss2eng_extensions=[
_dss2eng_protection_locations!,
dss2eng_extensions...
Expand Down
6 changes: 3 additions & 3 deletions test/graphml.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
@test length(graph.edge) == 6

save_graphml("../test/data/ieee13_nested.graphml", eng; type="nested")
@test length(EzXML.nodes(EzXML.nodes(EzXML.readxml("../test/data/ieee13_nested.graphml").node)[1])) == 185
@test length(EzXML.nodes(EzXML.nodes(EzXML.readxml("../test/data/ieee13_nested.graphml").node)[1])) == 177
rm("../test/data/ieee13_nested.graphml")
end

@testset "test unnested graph" begin
graph = build_unnested_graph(eng)
@test length(graph.node) == 57
@test length(graph.edge) == 57
@test length(graph.edge) == 59

save_graphml("../test/data/ieee13_unnested.graphml", eng; type="unnested")
@test length(EzXML.nodes(EzXML.nodes(EzXML.readxml("../test/data/ieee13_unnested.graphml").node)[1])) == 185
@test length(EzXML.nodes(EzXML.nodes(EzXML.readxml("../test/data/ieee13_unnested.graphml").node)[1])) == 177
rm("../test/data/ieee13_unnested.graphml")
end
end
22 changes: 11 additions & 11 deletions test/mld.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
r = optimize_switches!(args)

@test all(_r["termination_status"] == OPTIMAL for (n,_r) in r)
@test isapprox(sum(Float64[_r["objective"] for _r in values(r)]), 176.86; atol=1)
@test isapprox(sum(Float64[_r["objective"] for _r in values(r)]), 118.30; atol=1)
end

@testset "test rolling-horizon optimal switching - lindistflow - traditional" begin
Expand All @@ -53,7 +53,7 @@
r = optimize_switches!(args)

@test all(_r["termination_status"] == OPTIMAL for (n,_r) in r)
@test isapprox(sum(Float64[_r["objective"] for _r in values(r)]), 176.86; atol=1)
@test isapprox(sum(Float64[_r["objective"] for _r in values(r)]), 118.30; atol=1)
end

@testset "test rolling-horizon optimal switching - nfa - block" begin
Expand All @@ -69,7 +69,7 @@
r = optimize_switches!(args)

@test all(_r["termination_status"] == OPTIMAL for (n,_r) in r)
@test isapprox(sum(Float64[_r["objective"] for _r in values(r)]), 109.94; atol=1)
@test isapprox(sum(Float64[_r["objective"] for _r in values(r)]), 108.75; atol=1)
end

@testset "test rolling-horizon optimal switching - nfa - traditional" begin
Expand All @@ -85,7 +85,7 @@
r = optimize_switches!(args)

@test all(_r["termination_status"] == OPTIMAL for (n,_r) in r)
@test isapprox(sum(Float64[_r["objective"] for _r in values(r)]), 109.94; atol=1)
@test isapprox(sum(Float64[_r["objective"] for _r in values(r)]), 108.85; atol=1)
end
end

Expand All @@ -102,7 +102,7 @@
r = optimize_switches!(args)

@test first(r).second["termination_status"] == OPTIMAL
@test isapprox(r["1"]["objective"], 82.06; atol=1)
@test isapprox(r["1"]["objective"], 80.47; atol=1)
end

@testset "test full-lookahead optimal switching - lindistflow - traditional" begin
Expand Down Expand Up @@ -138,7 +138,7 @@
r = optimize_switches!(args)

@test first(r).second["termination_status"] == OPTIMAL
@test isapprox(r["1"]["objective"], 80.64; atol=1)
@test isapprox(r["1"]["objective"], 79.46; atol=1)
end

@testset "test full-lookahead optimal switching - lindistflow - traditional - radial-disabled - inverter-disabled" begin
Expand All @@ -155,7 +155,7 @@
r = optimize_switches!(args)

@test first(r).second["termination_status"] == OPTIMAL
@test isapprox(r["1"]["objective"], 80.65; atol=1)
@test isapprox(r["1"]["objective"], 79.46; atol=1)
end

@testset "test full-lookahead optimal switching - nfa - block" begin
Expand All @@ -170,7 +170,7 @@
r = optimize_switches!(args)

@test first(r).second["termination_status"] == OPTIMAL
@test isapprox(r["1"]["objective"], 72.52; atol=1)
@test isapprox(r["1"]["objective"], 71.32; atol=1)
end

@testset "test full-lookahead optimal switching - nfa - traditional" begin
Expand All @@ -185,7 +185,7 @@
r = optimize_switches!(args)

@test first(r).second["termination_status"] == OPTIMAL
@test isapprox(r["1"]["objective"], 72.52; atol=1)
@test isapprox(r["1"]["objective"], 71.32; atol=1)
end

@testset "test robust switching - lindistflow - block" begin
Expand Down Expand Up @@ -244,7 +244,7 @@ end
r = solve_block_mld(eng_s, LPUBFDiagPowerModel, solver)

@test r["solution"]["switch"]["680675"]["state"] == OPEN
@test r["solution"]["switch"]["671692"]["state"] == OPEN
@test r["solution"]["switch"]["671692"]["state"] == CLOSED
@test length(filter(x->x.second["state"]==OPEN, r["solution"]["switch"])) == 2
@test r["objective"] < 1.0

Expand All @@ -253,7 +253,7 @@ end

r = solve_block_mld(eng_s, LPUBFDiagPowerModel, solver)

@test r["solution"]["switch"]["680675"]["state"] == OPEN
@test r["solution"]["switch"]["680675"]["state"] == CLOSED
@test r["solution"]["switch"]["671692"]["state"] == OPEN
@test length(filter(x->x.second["state"]==OPEN, r["solution"]["switch"])) == 2
@test r["objective"] < 1.0
Expand Down
4 changes: 2 additions & 2 deletions test/nlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

@test result["termination_status"] == LOCALLY_SOLVED
@test length(filter(x -> x.second["state"] == CLOSED, get(get(result, "solution", Dict()), "switch", Dict()))) == 5
@test isapprox(result["objective"], 6.96; atol=0.1)
@test isapprox(result["objective"], 6.76; atol=0.1)
end

@testset "test block mld - acr" begin
result = solve_block_mld(eng, ACRUPowerModel, minlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test length(filter(x -> x.second["state"] == CLOSED, get(get(result, "solution", Dict()), "switch", Dict()))) == 5
@test isapprox(result["objective"], 6.96; atol=0.1)
@test isapprox(result["objective"], 6.75; atol=0.1)
end
end
2 changes: 1 addition & 1 deletion test/opf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@test isapprox(args["optimal_dispatch_result"]["objective"], 5.13; atol=2e-2)
@test all(isapprox.(args["optimal_dispatch_result"]["solution"]["nw"]["7"]["bus"]["801"]["vm"] ./ vbase["801"], [1.013, 1.062, 1.025]; atol=1e-2))
@test all(isapprox.(args["optimal_dispatch_result"]["solution"]["nw"]["7"]["bus"]["801"]["va"], [-3.36, -122.49, 117.39]; atol=1e0))
@test all(isapprox.(args["optimal_dispatch_result"]["solution"]["nw"]["7"]["bus"]["675"]["vm"] ./ vbase["675"], [0.979, 1.085, 1.021]; atol=1e-2))
@test all(isapprox.(args["optimal_dispatch_result"]["solution"]["nw"]["7"]["bus"]["675"]["vm"] ./ vbase["675"], [0.989, 1.082, 1.017]; atol=1e-2))
@test all(isapprox.(args["optimal_dispatch_result"]["solution"]["nw"]["7"]["bus"]["675"]["va"], [-4.77, -123.13, 116.81]; atol=1e0))
end

Expand Down
8 changes: 4 additions & 4 deletions test/stats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
@testset "test microgrid stats" begin
@test all(isapprox.(args["output_data"]["Storage SOC (%)"], [36.4, 34.8, 44.7, 46.5, 48.0, 48.0, 31.2, 16.8]; atol=1e0))

@test all(isapprox.(args["output_data"]["Load served"]["Bonus load via microgrid (%)"], [0.0, 0.0, 9.18339, 7.98514, 7.98514, 8.32841, 8.32841, 8.72574]; atol=1e-1))
@test all(isapprox.(args["output_data"]["Load served"]["Feeder load (%)"], [93.7876, 93.7822, 84.6857, 85.7495, 85.7495, 85.4536, 85.4536, 85.101]; atol=1e-1))
@test all(isapprox.(args["output_data"]["Load served"]["Bonus load via microgrid (%)"], [0.0, 0.0, 9.57997, 8.35485, 8.35485, 8.70728, 8.70728, 9.11343]; atol=1e-1))
@test all(isapprox.(args["output_data"]["Load served"]["Feeder load (%)"], [93.7930, 93.7860, 84.2933, 85.3878, 85.3878, 85.0814, 85.0814, 84.7187]; atol=1e-1))
@test all(isapprox.(args["output_data"]["Load served"]["Microgrid load (%)"], [14.2464, 17.9733, 51.9408, 64.7277, 61.1884, 53.4061, 82.2705, 81.8947]; atol=1e-1))

@test all(isapprox.(args["output_data"]["Generator profiles"]["Diesel DG (kW)"], [0.0, 0.0, 260.503, 272.498, 272.498, 268.22, 268.22, 264.266]; atol=1e0))
@test all(isapprox.(args["output_data"]["Generator profiles"]["Diesel DG (kW)"], [0.0, 0.0, 271.752, 285.112, 285.112, 280.420, 280.420, 276.006]; atol=1e0))
@test all(isapprox.(args["output_data"]["Generator profiles"]["Energy storage (kW)"], [75.0, 20.0016, 6.00045, -22.4995, -17.9993, -0.499176, 210.0, 180.0]; atol=1e0))
@test all(isapprox.(args["output_data"]["Generator profiles"]["Solar DG (kW)"], [0.0, 0.0, 14.0, 35.0, 28.0, 10.5, 0.0, 0.0]; atol=1e0))
@test all(isapprox.(args["output_data"]["Generator profiles"]["Grid mix (kW)"], [2300.61, 2385.48, 2402.26, 2926.25, 2926.25, 2752.07, 2752.07, 2577.35]; atol=1e1))
@test all(isapprox.(args["output_data"]["Generator profiles"]["Grid mix (kW)"], [2300.74, 2385.57, 2391.12, 2913.88, 2913.88, 2740.06, 2740.06, 2565.76]; atol=1e1))
end

@testset "test stability stats" begin
Expand Down

0 comments on commit f5a3bbd

Please sign in to comment.