PowerFlows.jl
PowerFlows.jl copied to clipboard
Add Vm Validation and autoscaling to Trust Region Method
I realized that the trust region method is converging to nonsense solutions on the large ACTIVSg10k test system:
using PowerFlows, PowerSystemCaseBuilder
sys = build_system(MatpowerTestSystems, "matpower_ACTIVSg10k_sys")
pf_tr = ACPowerFlow{TrustRegionACPowerFlow}()
data_tr = PowerFlowData(pf_tr, sys)
solve_powerflow!(data_tr; pf = pf_tr, maxIterations = 200, factor = 0.1)
v = deepcopy(data_tr.bus_magnitude[:, 1])
sort!(v)
display(v)
All entries of v should be between 0.9 and 1.1, yet under the current branch, that is far from the case. In this PR, I add the following:
- Log a warning when the voltage magnitude for any PQ bus leaves the 0.5-1.5 range.
- Re-normalize the different components in the TrustRegion method. I followed
NLSolve.jland setd[i] = max(0.1 * d[i], norm(J[:, i])): then we do the math like we're minimzingnorm(F(x ./ d)), instead ofF(x). This makes it so all but 2 of the voltage magnitudes above are sensible. - The problematic voltage magnitudes were among those with the smallest
dvalues: reasoning that the iterative procedure was taking too big of steps in certain directions, I added a constant factor to the autoscaling weights viad .+= 10*minimum(d). This resolves those last 2 voltage magnitudes.
That 3rd change was rather arbitrary: I left a TODO reminder in the code to look into a more principled solution.
On second thought, maybe we should wait to merge this until there's a test case that compares the result of our powerflow with what matpower or PSS/e gets. I'm only validating the entries corresponding to voltage magnitude: there could be unresolved issues with other entries.
I fail to reproduce on psy5:
Just 2 days ago, Rodrigo and I both were getting the following:
But now I get the same output as Gabriel: everything looks fine, without the autoscaling. There must've been some issue upstream in PSY or PNM, that's since been resolved.
It's probably still worth adding warnings for when the voltage magnitudes stray outside an acceptable range. But I'll revert by ad-hoc change that I described in (3) above. I'll also check if it converges faster or slower with autoscaling: if it's slower, I'll put the default as autoscaling = false.
I fail to reproduce on
psy5:
can we put these into a test please?
I added that test and turned autoscale off by default. Any other changes I should make?
