From b7306f5c36f2c2252c0e1b62f4d7fb51d4c82ee1 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 26 Apr 2024 15:03:18 -0600 Subject: [PATCH 1/6] fix Ixx equation, use Aimp --- docs/sphinx/source/whatsnew/v0.10.5.rst | 2 +- pvlib/pvsystem.py | 3 +-- pvlib/tests/test_pvsystem.py | 28 ++++++++++++------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.5.rst b/docs/sphinx/source/whatsnew/v0.10.5.rst index fe64879c8a..07e1603050 100644 --- a/docs/sphinx/source/whatsnew/v0.10.5.rst +++ b/docs/sphinx/source/whatsnew/v0.10.5.rst @@ -15,7 +15,7 @@ Enhancements Bug fixes ~~~~~~~~~ - +* Corrected equation for Ixx0 in :py:func:`pvlib.pvsystem.sapm` (:issue:`2016`, :pull:`XXXX`) Testing ~~~~~~~ diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 7b2f662b13..8a3138b836 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -2254,10 +2254,9 @@ def sapm(effective_irradiance, temp_cell, module): module['IXO'] * (module['C4']*Ee + module['C5']*(Ee**2)) * (1 + module['Aisc']*(temp_cell - temp_ref))) - # the Ixx calculation in King 2004 has a typo (mixes up Aisc and Aimp) out['i_xx'] = ( module['IXXO'] * (module['C6']*Ee + module['C7']*(Ee**2)) * - (1 + module['Aisc']*(temp_cell - temp_ref))) + (1 + module['Aimp']*(temp_cell - temp_ref))) if isinstance(out['i_sc'], pd.Series): out = pd.DataFrame(out) diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index 52de0fcc5b..89c505ee6a 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -191,16 +191,16 @@ def test_sapm(sapm_module_params): out = pvsystem.sapm(effective_irradiance, temp_cell, sapm_module_params) expected = pd.DataFrame(np.array( - [[ -5.0608322 , -4.65037767, nan, nan, - nan, -4.91119927, -4.15367716], + [[ -5.0608322 , -4.65037767, np.nan, np.nan, + np.nan, -4.91119927, -4.16721569], [ 2.545575 , 2.28773882, 56.86182059, 47.21121608, 108.00693168, 2.48357383, 1.71782772], [ 5.65584763, 5.01709903, 54.1943277 , 42.51861718, - 213.32011294, 5.52987899, 3.48660728], - [ nan, nan, nan, nan, - nan, nan, nan], - [ nan, nan, nan, nan, - nan, nan, nan]]), + 213.32011294, 5.52987899, 3.46796463], + [ np.nan, np.nan, np.nan, np.nan, + np.nan, np.nan, np.nan], + [ np.nan, np.nan, np.nan, np.nan, + np.nan, np.nan, np.nan]]), columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'], index=times) @@ -209,13 +209,13 @@ def test_sapm(sapm_module_params): out = pvsystem.sapm(1000, 25, sapm_module_params) expected = OrderedDict() - expected['i_sc'] = 5.09115 - expected['i_mp'] = 4.5462909092579995 - expected['v_oc'] = 59.260800000000003 - expected['v_mp'] = 48.315600000000003 - expected['p_mp'] = 219.65677305534581 - expected['i_x'] = 4.9759899999999995 - expected['i_xx'] = 3.1880204359100004 + expected['i_sc'] = sapm_module_params['Isco'] + expected['i_mp'] = sapm_module_params['Impo'] + expected['v_oc'] = sapm_module_params['Voco'] + expected['v_mp'] = sapm_module_params['Vmpo'] + expected['p_mp'] = sapm_module_params['Impo'] * sapm_module_params['Vmpo'] + expected['i_x'] = sapm_module_params['IXO'] + expected['i_xx'] = sapm_module_params['IXXO'] for k, v in expected.items(): assert_allclose(out[k], v, atol=1e-4) From 97afd2aab262778997f8bddf994331dd1db7b5cc Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Fri, 26 Apr 2024 15:05:23 -0600 Subject: [PATCH 2/6] Update docs/sphinx/source/whatsnew/v0.10.5.rst --- docs/sphinx/source/whatsnew/v0.10.5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.10.5.rst b/docs/sphinx/source/whatsnew/v0.10.5.rst index 07e1603050..26347e86f8 100644 --- a/docs/sphinx/source/whatsnew/v0.10.5.rst +++ b/docs/sphinx/source/whatsnew/v0.10.5.rst @@ -15,7 +15,7 @@ Enhancements Bug fixes ~~~~~~~~~ -* Corrected equation for Ixx0 in :py:func:`pvlib.pvsystem.sapm` (:issue:`2016`, :pull:`XXXX`) +* Corrected equation for Ixx0 in :py:func:`pvlib.pvsystem.sapm` (:issue:`2016`, :pull:`2019`) Testing ~~~~~~~ From a48a9f06b95397711098be8751a4f293cc70ebaa Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 30 Apr 2024 16:08:01 -0600 Subject: [PATCH 3/6] lint --- pvlib/tests/test_pvsystem.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index 89c505ee6a..5c896056e6 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -191,16 +191,14 @@ def test_sapm(sapm_module_params): out = pvsystem.sapm(effective_irradiance, temp_cell, sapm_module_params) expected = pd.DataFrame(np.array( - [[ -5.0608322 , -4.65037767, np.nan, np.nan, - np.nan, -4.91119927, -4.16721569], - [ 2.545575 , 2.28773882, 56.86182059, 47.21121608, - 108.00693168, 2.48357383, 1.71782772], - [ 5.65584763, 5.01709903, 54.1943277 , 42.51861718, - 213.32011294, 5.52987899, 3.46796463], - [ np.nan, np.nan, np.nan, np.nan, - np.nan, np.nan, np.nan], - [ np.nan, np.nan, np.nan, np.nan, - np.nan, np.nan, np.nan]]), + [[-5.0608322, -4.65037767, np.nan, np.nan, np.nan, + -4.91119927, -4.16721569], + [2.545575, 2.28773882, 56.86182059, 47.21121608, 108.00693168, + 2.48357383, 1.71782772], + [5.65584763, 5.01709903, 54.1943277, 42.51861718, 213.32011294, + 5.52987899, 3.46796463], + [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan], + [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]]), columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'], index=times) From 394bd0ffede373c28b2b3cacd6ef5dd2d40d9fdb Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 30 Apr 2024 16:12:16 -0600 Subject: [PATCH 4/6] lint --- pvlib/tests/test_pvsystem.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index 5c896056e6..f16b037361 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -191,16 +191,16 @@ def test_sapm(sapm_module_params): out = pvsystem.sapm(effective_irradiance, temp_cell, sapm_module_params) expected = pd.DataFrame(np.array( - [[-5.0608322, -4.65037767, np.nan, np.nan, np.nan, - -4.91119927, -4.16721569], - [2.545575, 2.28773882, 56.86182059, 47.21121608, 108.00693168, - 2.48357383, 1.71782772], - [5.65584763, 5.01709903, 54.1943277, 42.51861718, 213.32011294, - 5.52987899, 3.46796463], - [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan], - [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]]), - columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'], - index=times) + [[-5.0608322, -4.65037767, np.nan, np.nan, np.nan, + -4.91119927, -4.16721569], + [2.545575, 2.28773882, 56.86182059, 47.21121608, 108.00693168, + 2.48357383, 1.71782772], + [5.65584763, 5.01709903, 54.1943277, 42.51861718, 213.32011294, + 5.52987899, 3.46796463], + [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan], + [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]]), + columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'], + index=times) assert_frame_equal(out, expected, check_less_precise=4) From f9424d60509b28984f698ec0c7fa8f9ce9c590d1 Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 30 Apr 2024 16:26:35 -0600 Subject: [PATCH 5/6] get the spacing right --- pvlib/tests/test_pvsystem.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index f16b037361..51f5f84192 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -191,14 +191,14 @@ def test_sapm(sapm_module_params): out = pvsystem.sapm(effective_irradiance, temp_cell, sapm_module_params) expected = pd.DataFrame(np.array( - [[-5.0608322, -4.65037767, np.nan, np.nan, np.nan, - -4.91119927, -4.16721569], - [2.545575, 2.28773882, 56.86182059, 47.21121608, 108.00693168, - 2.48357383, 1.71782772], - [5.65584763, 5.01709903, 54.1943277, 42.51861718, 213.32011294, - 5.52987899, 3.46796463], - [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan], - [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]]), + [[-5.0608322, -4.65037767, np.nan, np.nan, np.nan, + -4.91119927, -4.16721569], + [2.545575, 2.28773882, 56.86182059, 47.21121608, 108.00693168, + 2.48357383, 1.71782772], + [5.65584763, 5.01709903, 54.1943277, 42.51861718, 213.32011294, + 5.52987899, 3.46796463], + [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan], + [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]]), columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'], index=times) From 40b35ba13fc33098fa20478dc137feb47c176abf Mon Sep 17 00:00:00 2001 From: Cliff Hansen Date: Tue, 30 Apr 2024 16:28:18 -0600 Subject: [PATCH 6/6] more spacing --- pvlib/tests/test_pvsystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index 51f5f84192..682b105e8e 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -199,8 +199,8 @@ def test_sapm(sapm_module_params): 5.52987899, 3.46796463], [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]]), - columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'], - index=times) + columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'], + index=times) assert_frame_equal(out, expected, check_less_precise=4)