From 9e69e91f91f3fda5ceaf582c77f0a676998943bf Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Sat, 12 Nov 2016 10:15:21 -0700 Subject: [PATCH 1/4] 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/4] 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 From fc575d94df488281d5920c15d55205abc0d3ea60 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Mon, 21 Nov 2016 20:54:02 -0700 Subject: [PATCH 3/4] fix typing to accomodate series input --- .spyproject/codestyle.ini | 6 ++++++ .spyproject/encoding.ini | 6 ++++++ .spyproject/vcs.ini | 7 +++++++ .spyproject/workspace.ini | 10 ++++++++++ pvlib/pvsystem.py | 2 +- 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .spyproject/codestyle.ini create mode 100644 .spyproject/encoding.ini create mode 100644 .spyproject/vcs.ini create mode 100644 .spyproject/workspace.ini diff --git a/.spyproject/codestyle.ini b/.spyproject/codestyle.ini new file mode 100644 index 0000000000..f2f445723a --- /dev/null +++ b/.spyproject/codestyle.ini @@ -0,0 +1,6 @@ +[codestyle] +indentation = True + +[main] +version = '0.1.0' + diff --git a/.spyproject/encoding.ini b/.spyproject/encoding.ini new file mode 100644 index 0000000000..ce799dff06 --- /dev/null +++ b/.spyproject/encoding.ini @@ -0,0 +1,6 @@ +[encoding] +text_encoding = utf-8 + +[main] +version = '0.1.0' + diff --git a/.spyproject/vcs.ini b/.spyproject/vcs.ini new file mode 100644 index 0000000000..d317b1e4be --- /dev/null +++ b/.spyproject/vcs.ini @@ -0,0 +1,7 @@ +[vcs] +use_version_control = False +version_control_system = + +[main] +version = '0.1.0' + diff --git a/.spyproject/workspace.ini b/.spyproject/workspace.ini new file mode 100644 index 0000000000..e09f08291f --- /dev/null +++ b/.spyproject/workspace.ini @@ -0,0 +1,10 @@ +[workspace] +save_data_on_exit = True +restore_data_on_startup = True +save_history = True +save_non_project_files = False + +[main] +version = '0.1.0' +recent_files = [u'C:\\python\\pvlib-python\\pvlib-python\\pvlib\\test\\test_modelchain.py', u'C:\\python\\pvlib-python\\pvlib-python\\pvlib\\test\\test_pvsystem.py', u'C:\\python\\pvlib-python\\pvlib-python\\pvlib\\pvsystem.py'] + diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 47dfbcabec..8f140f1ac6 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.ceil(np.log10(w)).astype(int) + order = np.max(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 From 5e7eb06cc36ba5b82586ada08c152c53159d5b75 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Mon, 21 Nov 2016 21:02:56 -0700 Subject: [PATCH 4/4] Revert "fix typing" This reverts commit fc575d94df488281d5920c15d55205abc0d3ea60. --- .spyproject/codestyle.ini | 6 ------ .spyproject/encoding.ini | 6 ------ .spyproject/vcs.ini | 7 ------- .spyproject/workspace.ini | 10 ---------- pvlib/pvsystem.py | 2 +- 5 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 .spyproject/codestyle.ini delete mode 100644 .spyproject/encoding.ini delete mode 100644 .spyproject/vcs.ini delete mode 100644 .spyproject/workspace.ini diff --git a/.spyproject/codestyle.ini b/.spyproject/codestyle.ini deleted file mode 100644 index f2f445723a..0000000000 --- a/.spyproject/codestyle.ini +++ /dev/null @@ -1,6 +0,0 @@ -[codestyle] -indentation = True - -[main] -version = '0.1.0' - diff --git a/.spyproject/encoding.ini b/.spyproject/encoding.ini deleted file mode 100644 index ce799dff06..0000000000 --- a/.spyproject/encoding.ini +++ /dev/null @@ -1,6 +0,0 @@ -[encoding] -text_encoding = utf-8 - -[main] -version = '0.1.0' - diff --git a/.spyproject/vcs.ini b/.spyproject/vcs.ini deleted file mode 100644 index d317b1e4be..0000000000 --- a/.spyproject/vcs.ini +++ /dev/null @@ -1,7 +0,0 @@ -[vcs] -use_version_control = False -version_control_system = - -[main] -version = '0.1.0' - diff --git a/.spyproject/workspace.ini b/.spyproject/workspace.ini deleted file mode 100644 index e09f08291f..0000000000 --- a/.spyproject/workspace.ini +++ /dev/null @@ -1,10 +0,0 @@ -[workspace] -save_data_on_exit = True -restore_data_on_startup = True -save_history = True -save_non_project_files = False - -[main] -version = '0.1.0' -recent_files = [u'C:\\python\\pvlib-python\\pvlib-python\\pvlib\\test\\test_modelchain.py', u'C:\\python\\pvlib-python\\pvlib-python\\pvlib\\test\\test_pvsystem.py', u'C:\\python\\pvlib-python\\pvlib-python\\pvlib\\pvsystem.py'] - diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 8f140f1ac6..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.max(np.ceil(np.log10(w))).astype(int) + 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