Skip to content

Commit

Permalink
Fix Ixx equation in pvsystem.sapm (pvlib#2019)
Browse files Browse the repository at this point in the history
* fix Ixx equation, use Aimp

* Update docs/sphinx/source/whatsnew/v0.10.5.rst

* lint

* lint

* get the spacing right

* more spacing

---------

Co-authored-by: Kevin Anderson <kevin.anderso@gmail.com>
  • Loading branch information
2 people authored and echedey-ls committed May 22, 2024
1 parent 572c48f commit efa8ace
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew/v0.10.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Enhancements

Bug fixes
~~~~~~~~~
* Corrected equation for Ixx0 in :py:func:`pvlib.pvsystem.sapm` (:issue:`2016`, :pull:`2019`)
* Fixed :py:func:`pvlib.pvsystem.retrieve_sam` silently ignoring the `path` parameter
when `name` was provided. Now an exception is raised requesting to only provide one
of the two parameters. (:issue:`2018`, :pull:`2020`)
Expand Down
3 changes: 1 addition & 2 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,10 +2264,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)
Expand Down
32 changes: 15 additions & 17 deletions pvlib/tests/test_pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,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, nan, nan,
nan, -4.91119927, -4.15367716],
[ 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]]),
[[-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)

Expand All @@ -184,13 +182,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)
Expand Down

0 comments on commit efa8ace

Please sign in to comment.