pvlib / pvlib-python

A set of documented functions for simulating the performance of photovoltaic energy systems.
https://pvlib-python.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.17k stars 991 forks source link

Accelerate singlediode._lambertw #1649

Open cwhanse opened 1 year ago

cwhanse commented 1 year ago

I've found a way to replace the calculation of the maximum power point in singlediode._lambertw with a more analytic approach. The speedup is not quite 10x, and would make pvsystem.singlediode(...method='lambertw') and pvsystem.singlediode(...method='newton') comparable.

I'm not sure if the maths are new, they might be. In any case, it would not be difficult to document on pvpmc.sandia.gov, if not in a conference paper.

We could remove the golden mean search, or retain it. I lean towards retaining it. The new way would use scipy.optimize.newton which should converge with quite high confidence, but, not guaranteed for some pathological case. golden mean search would always converge.

gist with new method.

adriesse commented 1 year ago

I looked at the gist but was unable to get the gist of it. :( But if it works, why not?

cwhanse commented 1 year ago

@adriesse fair point, I will document this work before proposing changes to pvlib code.