Skip to content

Commit

Permalink
small fix ACPowerFlow type; add test for results consistency for 2000…
Browse files Browse the repository at this point in the history
… bus system
  • Loading branch information
Roman Bolgaryn committed Dec 17, 2024
1 parent 42f02ab commit e6a0364
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/powerflow_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ Base.@kwdef struct ACPowerFlow{ACSolver <: ACPowerFlowSolverType} <:
end

# Create a constructor that defaults to KLUACPowerFlow
function ACPowerFlow(;
function ACPowerFlow(ACSolver::Type{<:ACPowerFlowSolverType} = KLUACPowerFlow;
check_reactive_power_limits::Bool = false,
ACSolver::Type{<:ACPowerFlowSolverType} = KLUACPowerFlow,
)
return ACPowerFlow{ACSolver}(check_reactive_power_limits)
end
Expand Down
20 changes: 20 additions & 0 deletions test/test_newton_ac_powerflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,23 @@ end
atol = 0.001,
)
end


@testset "Compare larger grid results KLU vs NLSolve" begin
sys = build_system(MatpowerTestSystems, "matpower_ACTIVSg2000_sys")

pf_default = ACPowerFlow()
pf_klu = ACPowerFlow(KLUACPowerFlow)
pf_nlsolve = ACPowerFlow(NLSolveACPowerFlow)

res_default = solve_powerflow(pf_default, sys) # must be the same as KLU
res_klu = solve_powerflow(pf_klu, sys)
res_nlsolve = solve_powerflow(pf_nlsolve, sys)


@test all(isapprox.(res_klu["bus_results"][!, :Vm], res_default["bus_results"][!, :Vm], rtol=0, atol=1e-12))
@test all(isapprox.(res_klu["bus_results"][!, ], res_default["bus_results"][!, ], rtol=0, atol=1e-12))

@test all(isapprox.(res_klu["bus_results"][!, :Vm], res_nlsolve["bus_results"][!, :Vm], rtol=0, atol=1e-8))
@test all(isapprox.(res_klu["bus_results"][!, ], res_nlsolve["bus_results"][!, ], rtol=0, atol=1e-8))
end

0 comments on commit e6a0364

Please sign in to comment.