diff --git a/Project.toml b/Project.toml index 8ae07ff87..3aefc6f55 100644 --- a/Project.toml +++ b/Project.toml @@ -31,8 +31,8 @@ ForwardDiff = "~v0.10" InfrastructureSystems = "2" NLsolve = "4" PowerSystems = "4" -PowerFlows = "^0.7" -PowerNetworkMatrices = "^0.11" +PowerFlows = "^0.9" +PowerNetworkMatrices = "^0.12.1" PrettyTables = "1, 2" SciMLBase = "2" TimerOutputs = "~0.5" diff --git a/docs/src/tutorials/tutorial_continuation_pf.md b/docs/src/tutorials/tutorial_continuation_pf.md index 364e30ff9..2904532b7 100644 --- a/docs/src/tutorials/tutorial_continuation_pf.md +++ b/docs/src/tutorials/tutorial_continuation_pf.md @@ -77,7 +77,8 @@ for p in P_range q_power = power * tan(acos(load_pf)) set_reactive_power!(load, q_power) # Run Power Flow - status = solve_ac_powerflow!(sys_static) + pf = ACPowerFlow() + status = solve_powerflow!(pf, sys_static) if !status # Finish the loop if the power flow fails print("Power Flow failed at p = $(power)") @@ -143,7 +144,8 @@ for p in P_range q_power = power * tan(acos(load_pf)) set_reactive_power!(load, q_power) # Run Power Flow - status = solve_ac_powerflow!(sys_static) + pf = ACPowerFlow() + status = solve_powerflow!(pf, sys_static) if !status # Finish the loop if the power flow fails print("Power Flow failed at p = $(power)") diff --git a/src/base/nlsolve_wrapper.jl b/src/base/nlsolve_wrapper.jl index 371e29bcf..c58778bf6 100644 --- a/src/base/nlsolve_wrapper.jl +++ b/src/base/nlsolve_wrapper.jl @@ -133,6 +133,7 @@ function _check_residual( Generator = $gen_name, state = $state. Residual error is too large to continue") else + bus_count = get_bus_count(inputs) bus_no = ix > bus_count ? ix - bus_count : ix component = ix > bus_count ? "imag" : "real" error("The initial residual in the state located at $ix has a value of $val. diff --git a/src/base/simulation_initialization.jl b/src/base/simulation_initialization.jl index a37786cd8..eba0e5903 100644 --- a/src/base/simulation_initialization.jl +++ b/src/base/simulation_initialization.jl @@ -11,7 +11,8 @@ function power_flow_solution!( sys::PSY.System, inputs::SimulationInputs, ) - res = PF.solve_ac_powerflow!(sys) + pf = PF.ACPowerFlow{PF.TrustRegionACPowerFlow}() + res = PF.solve_powerflow!(pf, sys) if !res @error("PowerFlow failed to solve") return BUILD_FAILED diff --git a/test/test_case_5shaft.jl b/test/test_case_5shaft.jl index 9f5946ed4..f0911632b 100644 --- a/test/test_case_5shaft.jl +++ b/test/test_case_5shaft.jl @@ -11,7 +11,8 @@ The fault disconnects a circuit between buses 1 and 2, doubling its impedance. ################################################## threebus_sys = build_system(PSIDTestSystems, "psid_test_threebus_5shaft") -solve_ac_powerflow!(threebus_sys) +pf = ACPowerFlow() +solve_powerflow!(pf, threebus_sys) Ybus_fault = get_ybus_fault_threebus_sys(threebus_sys) ################################################## diff --git a/test/test_case_anderson.jl b/test/test_case_anderson.jl index d6361d59a..87c57bfb1 100644 --- a/test/test_case_anderson.jl +++ b/test/test_case_anderson.jl @@ -10,7 +10,8 @@ and the generator located in bus 3. ################################################## threebus_sys = build_system(PSIDTestSystems, "psid_test_threebus_anderson") -solve_ac_powerflow!(threebus_sys) +pf = ACPowerFlow() +solve_powerflow!(pf, threebus_sys) Ybus_fault = get_ybus_fault_threebus_sys(threebus_sys) ################################################## diff --git a/test/test_case_marconato.jl b/test/test_case_marconato.jl index 26e8cc66d..6d7b7f388 100644 --- a/test/test_case_marconato.jl +++ b/test/test_case_marconato.jl @@ -10,7 +10,8 @@ and the generator located in bus 3. ################################################## threebus_sys = build_system(PSIDTestSystems, "psid_test_threebus_marconato") -solve_ac_powerflow!(threebus_sys) +pf = ACPowerFlow() +solve_powerflow!(pf, threebus_sys) Ybus_fault = get_ybus_fault_threebus_sys(threebus_sys) ################################################## diff --git a/test/test_case_oneDoneQ.jl b/test/test_case_oneDoneQ.jl index 32898d2ee..3daf6583b 100644 --- a/test/test_case_oneDoneQ.jl +++ b/test/test_case_oneDoneQ.jl @@ -10,7 +10,8 @@ and the generator located in bus 3. ################################################## threebus_sys = build_system(PSIDTestSystems, "psid_test_threebus_oneDoneQ") -solve_ac_powerflow!(threebus_sys) +pf = ACPowerFlow() +solve_powerflow!(pf, threebus_sys) Ybus_fault = get_ybus_fault_threebus_sys(threebus_sys) ################################################## diff --git a/test/test_case_simple_anderson.jl b/test/test_case_simple_anderson.jl index a75fe5f29..7f0a72855 100644 --- a/test/test_case_simple_anderson.jl +++ b/test/test_case_simple_anderson.jl @@ -10,7 +10,8 @@ and the generator located in bus 3. ################################################## threebus_sys = build_system(PSIDTestSystems, "psid_test_threebus_simple_anderson") -solve_ac_powerflow!(threebus_sys) +pf = ACPowerFlow() +solve_powerflow!(pf, threebus_sys) Ybus_fault = get_ybus_fault_threebus_sys(threebus_sys) ################################################## diff --git a/test/test_case_simple_marconato.jl b/test/test_case_simple_marconato.jl index 73138b5cd..1ec5aa408 100644 --- a/test/test_case_simple_marconato.jl +++ b/test/test_case_simple_marconato.jl @@ -10,7 +10,8 @@ and the generator located in bus 3. ################################################## threebus_sys = build_system(PSIDTestSystems, "psid_test_threebus_simple_marconato") -solve_ac_powerflow!(threebus_sys) +pf = ACPowerFlow() +solve_powerflow!(pf, threebus_sys) Ybus_fault = get_ybus_fault_threebus_sys(threebus_sys) ##################################################