Skip to content
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

Fix Ixx equation in pvsystem.sapm #2019

Merged
merged 8 commits into from May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/v0.10.5.rst
Expand Up @@ -15,7 +15,7 @@ Enhancements

Bug fixes
~~~~~~~~~

* Corrected equation for Ixx0 in :py:func:`pvlib.pvsystem.sapm` (:issue:`2016`, :pull:`2019`)

Testing
~~~~~~~
Expand Down
3 changes: 1 addition & 2 deletions pvlib/pvsystem.py
Expand Up @@ -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)
Expand Down
28 changes: 14 additions & 14 deletions pvlib/tests/test_pvsystem.py
Expand Up @@ -191,16 +191,16 @@
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,

Check failure on line 194 in pvlib/tests/test_pvsystem.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E121 continuation line under-indented for hanging indent

Check failure on line 194 in pvlib/tests/test_pvsystem.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E221 multiple spaces before operator

Check failure on line 194 in pvlib/tests/test_pvsystem.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E203 whitespace before ','
np.nan, -4.91119927, -4.16721569],

Check failure on line 195 in pvlib/tests/test_pvsystem.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E127 continuation line over-indented for visual indent
[ 2.545575 , 2.28773882, 56.86182059, 47.21121608,

Check failure on line 196 in pvlib/tests/test_pvsystem.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E203 whitespace before ','
108.00693168, 2.48357383, 1.71782772],

Check failure on line 197 in pvlib/tests/test_pvsystem.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E128 continuation line under-indented for visual indent
[ 5.65584763, 5.01709903, 54.1943277 , 42.51861718,

Check failure on line 198 in pvlib/tests/test_pvsystem.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E203 whitespace before ','
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],

Check failure on line 199 in pvlib/tests/test_pvsystem.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E128 continuation line under-indented for visual indent
[ 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 @@ -209,13 +209,13 @@
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