8000 WIP: Speed up singlediode._lambertw by cwhanse · Pull Request #1661 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

WIP: Speed up singlediode._lambertw #1661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
pacify stickler
  • Loading branch information
cwhanse committed Feb 13, 2023
commit d84c83c3c73f481348699912f5d5f21d6daece45
7 changes: 5 additions & 2 deletions pvlib/singlediode.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def _split_on_gsh(gsh):
idx_z = 0. == gsh
return idx_p, idx_z


def _imp_zero(i, il, io, rs, gsh, a):
''' Root of this function is at imp
'''
Expand All @@ -763,6 +763,8 @@ def _imp_zero(i, il, io, rs, gsh, a):


def _imp_zero_prime(i, il, io, rs, gsh, a):
''' Derivative of _imp_zero with respect to current i
'''
idx_p, idx_z = _split_on_gsh(gsh)
res = np.full_like(i, np.nan, dtype=np.float64)
if np.any(idx_z):
Expand All @@ -771,7 +773,8 @@ def _imp_zero_prime(i, il, io, rs, gsh, a):
res[idx_z] = 2. / t + i[idx_z] / t**2.
Copy link
Member
@kandersolar kandersolar Feb 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on whether my previous comment regarding a missing term is in error, this may also need an additional term

if np.any(idx_p):
wma = _w_psi(i[idx_p], il[idx_p], io[idx_p], gsh[idx_p], a[idx_p])
f = (il[idx_p] + io[idx_p] - i[idx_p]) / gsh[idx_p] - i[idx_p] * rs[idx_p] - a[idx_p] * wma
f = (il[idx_p] + io[idx_p] - i[idx_p]) / gsh[idx_p] - \
i[idx_p] * rs[idx_p] - a[idx_p] * wma
fprime = -rs[idx_p] - 1. / (gsh[idx_p] * (1. + wma))
fprime2 = -1. / (gsh[idx_p]**2. * a[idx_p]) * wma / (1 + wma)**3.
res[idx_p] = f / fprime**2. * fprime2 - 2.
Expand Down
0