pvlib-python icon indicating copy to clipboard operation
pvlib-python copied to clipboard

A method of finding the MPP using Newton with guaranteed convergence

Open kandersolar opened this issue 3 months ago • 2 comments

This paper provides a Newton-based method of finding the MPP, with the function and starting point constructed in such a way that they claim guarantees convergence. Rough timing (for 1000 sets of SDE parameters) compared with our existing methods:

  • method='lambertw': 42.5 ms ± 1.64 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
  • method='newton': 8.57 ms ± 236 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
  • method='brentq': 877 ms ± 20.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
  • method='chandrupatla': 22.3 ms ± 974 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)
  • Toledo et al. : 9.4 ms ± 713 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)

The implementation is fewer than 100 lines of code (although Isc and Vmp are calculated using pvlib's i_from_v and v_from_i functions instead of the method in the paper).

Reference:

Toledo, F.J., Galiano, V., Herranz, V. et al. A comparison of methods for the calculation of all the key points of the PV single-diode model including a new algorithm for the maximum power point. Optim Eng 25, 1469–1503 (2024). https://doi.org/10.1007/s11081-023-09850-8

Worth including in pvlib?

kandersolar avatar Oct 01 '25 18:10 kandersolar

Does your exploratory code use Toledo's method for computing Lambert's W? At first glance through the paper, it doesn't appear to be necessary, but want to understand better. Also, I assume the comparison involves computing all of Isc, Voc, Imp, and Vmp - what method was paired with Toledo to get Isc and Voc from pvlib's existing code?

One technical point:

  1. Convergence is guaranteed if the derivative of the function g(x) (Eq. 33) is always positive and sufficiently large not to introduce numerical issues. It may be that convergence is a problem for some parameter combinations. The expression for g' is in Section 6.3, involves natural log(x) where x may be very small (1e-9). It may be possible to show that this expression is always positive, at least, for some range of parameters. If g' is negative in some region of small x, there will be a basin in the graph of g(x) that has a minimum, which can cause Newton-Raphson to fail. Guaranteed convergence is one advantage of the slower 'lambertw' method, which using a golden ratio search to find the MPP.

If convergence can be guaranteed, and numerical overflow is handled, I think adding this MPP method has merit, and could replace the golden mean search in 'lambertw'.

cwhanse avatar Oct 01 '25 19:10 cwhanse

Does your exploratory code use Toledo's method for computing Lambert's W?

It did originally (and seemed fine), although in the end I switched to pvlib's functions for simplicity.

At first glance through the paper, it doesn't appear to be necessary, but want to understand better.

I believe the need is to get around the usual overflow issue when calculating lambertw(a*exp(b)), but I didn't dig into it to be sure.

Also, I assume the comparison involves computing all of Isc, Voc, Imp, and Vmp - what method was paired with Toledo to get Isc and Voc from pvlib's existing code?

Correct, and Isc/Voc were computed with pvlib.pvsystem.i_from_v(..., method='lambertw') and same for v_from_i.

kandersolar avatar Oct 01 '25 19:10 kandersolar