Skip to content

Commit 40e9e97

Browse files
mikofskicwhansekandersolar
authored
fix recombination args in pvsystem.maximum_power_point (#1733)
* fix recombination args in pvsystem.maximum_power_point * d2mutau and NsVbi were hardcoded instead of passing through the arguments to the function * fix stickler * Update docs/sphinx/source/whatsnew/v0.9.6.rst remove "fix" from whatsnew Co-authored-by: Cliff Hansen <[email protected]> * Apply suggestions from code review --------- Co-authored-by: Cliff Hansen <[email protected]> Co-authored-by: Kevin Anderson <[email protected]>
1 parent ebf29a4 commit 40e9e97

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

docs/sphinx/source/whatsnew/v0.9.6.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Bug fixes
5353
~~~~~~~~~
5454
* `data` can no longer be left unspecified in
5555
:py:meth:`pvlib.modelchain.ModelChain.run_model_from_effective_irradiance`. (:issue:`1713`, :pull:`1720`)
56+
* ``d2mutau`` and ``NsVbi`` were hardcoded in :py:func:`pvlib.pvsystem.max_power_point` instead of
57+
passing through the arguments to the function. (:pull:`1733`)
5658

5759
Testing
5860
~~~~~~~

pvlib/pvsystem.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,8 +2918,7 @@ def max_power_point(photocurrent, saturation_current, resistance_series,
29182918
"""
29192919
i_mp, v_mp, p_mp = _singlediode.bishop88_mpp(
29202920
photocurrent, saturation_current, resistance_series,
2921-
resistance_shunt, nNsVth, d2mutau=0, NsVbi=np.Inf,
2922-
method=method.lower()
2921+
resistance_shunt, nNsVth, d2mutau, NsVbi, method=method.lower()
29232922
)
29242923
if isinstance(photocurrent, pd.Series):
29252924
ivp = {'i_mp': i_mp, 'v_mp': v_mp, 'p_mp': p_mp}

pvlib/tests/test_pvsystem.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from pvlib import temperature
2121
from pvlib._deprecation import pvlibDeprecationWarning
2222
from pvlib.tools import cosd
23+
from pvlib.singlediode import VOLTAGE_BUILTIN
24+
from pvlib.tests.test_singlediode import get_pvsyst_fs_495
2325

2426

2527
@pytest.mark.parametrize('iam_model,model_params', [
@@ -1246,6 +1248,43 @@ def test_mpp_floats():
12461248
assert np.isclose(v, expected[k])
12471249

12481250

1251+
def test_mpp_recombination():
1252+
"""test max_power_point"""
1253+
pvsyst_fs_495 = get_pvsyst_fs_495()
1254+
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_pvsyst(
1255+
effective_irradiance=pvsyst_fs_495['irrad_ref'],
1256+
temp_cell=pvsyst_fs_495['temp_ref'],
1257+
alpha_sc=pvsyst_fs_495['alpha_sc'],
1258+
gamma_ref=pvsyst_fs_495['gamma_ref'],
1259+
mu_gamma=pvsyst_fs_495['mu_gamma'], I_L_ref=pvsyst_fs_495['I_L_ref'],
1260+
I_o_ref=pvsyst_fs_495['I_o_ref'], R_sh_ref=pvsyst_fs_495['R_sh_ref'],
1261+
R_sh_0=pvsyst_fs_495['R_sh_0'], R_sh_exp=pvsyst_fs_495['R_sh_exp'],
1262+
R_s=pvsyst_fs_495['R_s'],
1263+
cells_in_series=pvsyst_fs_495['cells_in_series'],
1264+
EgRef=pvsyst_fs_495['EgRef'])
1265+
out = pvsystem.max_power_point(
1266+
IL, I0, Rs, Rsh, nNsVth,
1267+
d2mutau=pvsyst_fs_495['d2mutau'],
1268+
NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series'],
1269+
method='brentq')
1270+
expected_imp = pvsyst_fs_495['I_mp_ref']
1271+
expected_vmp = pvsyst_fs_495['V_mp_ref']
1272+
expected_pmp = expected_imp*expected_vmp
1273+
expected = {'i_mp': expected_imp,
1274+
'v_mp': expected_vmp,
1275+
'p_mp': expected_pmp}
1276+
assert isinstance(out, dict)
1277+
for k, v in out.items():
1278+
assert np.isclose(v, expected[k], 0.01)
1279+
out = pvsystem.max_power_point(
1280+
IL, I0, Rs, Rsh, nNsVth,
1281+
d2mutau=pvsyst_fs_495['d2mutau'],
1282+
NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series'],
1283+
method='newton')
1284+
for k, v in out.items():
1285+
assert np.isclose(v, expected[k], 0.01)
1286+
1287+
12491288
def test_mpp_array():
12501289
"""test max_power_point"""
12511290
IL, I0, Rs, Rsh, nNsVth = (np.array([7, 7]), 6e-7, .1, 20, .5)

0 commit comments

Comments
 (0)