PowerFlows.jl icon indicating copy to clipboard operation
PowerFlows.jl copied to clipboard

Add Vm Validation and autoscaling to Trust Region Method

Open luke-kiernan opened this issue 6 months ago • 5 comments

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:

  1. Log a warning when the voltage magnitude for any PQ bus leaves the 0.5-1.5 range.
  2. Re-normalize the different components in the TrustRegion method. I followed NLSolve.jl and set d[i] = max(0.1 * d[i], norm(J[:, i])): then we do the math like we're minimzing norm(F(x ./ d)), instead of F(x). This makes it so all but 2 of the voltage magnitudes above are sensible.
  3. The problematic voltage magnitudes were among those with the smallest d values: reasoning that the iterative procedure was taking too big of steps in certain directions, I added a constant factor to the autoscaling weights via d .+= 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.

luke-kiernan avatar May 22 '25 21:05 luke-kiernan

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.

luke-kiernan avatar May 23 '25 01:05 luke-kiernan

I fail to reproduce on psy5: 9dda1194-0d8e-40e5-a0c2-243bf67b8532

GabrielKS avatar May 23 '25 20:05 GabrielKS

Just 2 days ago, Rodrigo and I both were getting the following: image (1) 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.

luke-kiernan avatar May 23 '25 20:05 luke-kiernan

I fail to reproduce on psy5: 9dda1194-0d8e-40e5-a0c2-243bf67b8532

can we put these into a test please?

jd-lara avatar May 23 '25 21:05 jd-lara

I added that test and turned autoscale off by default. Any other changes I should make?

luke-kiernan avatar May 24 '25 00:05 luke-kiernan