From 9e69e91f91f3fda5ceaf582c77f0a676998943bf Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Sat, 12 Nov 2016 10:15:21 -0700 Subject: [PATCH 1/2] Improve precision of v_from_i for large arguments Number of iterations of Newton method should increase with the order of the argument, to maintain precision. Not expected to have a significant effect on most calculated IV curves. --- pvlib/pvsystem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index ba64fc200b..63aae7883d 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1843,7 +1843,8 @@ def v_from_i(resistance_shunt, resistance_series, nNsVth, current, # evaluation (above) results in NaN from overflow, 3 iterations # of Newton's method gives approximately 8 digits of precision. w = logargW - for i in range(0, 3): + order = np.log10(w) + for i in range(0, 3*order): w = w * (1 - np.log(w) + logargW) / (1 + w) lambertwterm_log = w From dc142a5c04e082ce286b53e193cfbcd0a1b45fc1 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Wed, 16 Nov 2016 10:22:34 -0700 Subject: [PATCH 2/2] Update pvsystem.py --- pvlib/pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 63aae7883d..47dfbcabec 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1843,7 +1843,7 @@ def v_from_i(resistance_shunt, resistance_series, nNsVth, current, # evaluation (above) results in NaN from overflow, 3 iterations # of Newton's method gives approximately 8 digits of precision. w = logargW - order = np.log10(w) + order = np.ceil(np.log10(w)).astype(int) for i in range(0, 3*order): w = w * (1 - np.log(w) + logargW) / (1 + w) lambertwterm_log = w