diff --git a/docs/sphinx/source/whatsnew/v0.9.6.rst b/docs/sphinx/source/whatsnew/v0.9.6.rst index 729de3e457..889f456e0c 100644 --- a/docs/sphinx/source/whatsnew/v0.9.6.rst +++ b/docs/sphinx/source/whatsnew/v0.9.6.rst @@ -53,6 +53,8 @@ Bug fixes ~~~~~~~~~ * `data` can no longer be left unspecified in :py:meth:`pvlib.modelchain.ModelChain.run_model_from_effective_irradiance`. (:issue:`1713`, :pull:`1720`) +* ``d2mutau`` and ``NsVbi`` were hardcoded in :py:func:`pvlib.pvsystem.max_power_point` instead of + passing through the arguments to the function. (:pull:`1733`) Testing ~~~~~~~ diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index 6d5a5b2ef4..bdab5d604d 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -2918,8 +2918,7 @@ def max_power_point(photocurrent, saturation_current, resistance_series, """ i_mp, v_mp, p_mp = _singlediode.bishop88_mpp( photocurrent, saturation_current, resistance_series, - resistance_shunt, nNsVth, d2mutau=0, NsVbi=np.Inf, - method=method.lower() + resistance_shunt, nNsVth, d2mutau, NsVbi, method=method.lower() ) if isinstance(photocurrent, pd.Series): ivp = {'i_mp': i_mp, 'v_mp': v_mp, 'p_mp': p_mp} diff --git a/pvlib/tests/test_pvsystem.py b/pvlib/tests/test_pvsystem.py index 8d3caca477..d5dcfc1420 100644 --- a/pvlib/tests/test_pvsystem.py +++ b/pvlib/tests/test_pvsystem.py @@ -20,6 +20,8 @@ from pvlib import temperature from pvlib._deprecation import pvlibDeprecationWarning from pvlib.tools import cosd +from pvlib.singlediode import VOLTAGE_BUILTIN +from pvlib.tests.test_singlediode import get_pvsyst_fs_495 @pytest.mark.parametrize('iam_model,model_params', [ @@ -1246,6 +1248,43 @@ def test_mpp_floats(): assert np.isclose(v, expected[k]) +def test_mpp_recombination(): + """test max_power_point""" + pvsyst_fs_495 = get_pvsyst_fs_495() + IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_pvsyst( + effective_irradiance=pvsyst_fs_495['irrad_ref'], + temp_cell=pvsyst_fs_495['temp_ref'], + alpha_sc=pvsyst_fs_495['alpha_sc'], + gamma_ref=pvsyst_fs_495['gamma_ref'], + mu_gamma=pvsyst_fs_495['mu_gamma'], I_L_ref=pvsyst_fs_495['I_L_ref'], + I_o_ref=pvsyst_fs_495['I_o_ref'], R_sh_ref=pvsyst_fs_495['R_sh_ref'], + R_sh_0=pvsyst_fs_495['R_sh_0'], R_sh_exp=pvsyst_fs_495['R_sh_exp'], + R_s=pvsyst_fs_495['R_s'], + cells_in_series=pvsyst_fs_495['cells_in_series'], + EgRef=pvsyst_fs_495['EgRef']) + out = pvsystem.max_power_point( + IL, I0, Rs, Rsh, nNsVth, + d2mutau=pvsyst_fs_495['d2mutau'], + NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series'], + method='brentq') + expected_imp = pvsyst_fs_495['I_mp_ref'] + expected_vmp = pvsyst_fs_495['V_mp_ref'] + expected_pmp = expected_imp*expected_vmp + expected = {'i_mp': expected_imp, + 'v_mp': expected_vmp, + 'p_mp': expected_pmp} + assert isinstance(out, dict) + for k, v in out.items(): + assert np.isclose(v, expected[k], 0.01) + out = pvsystem.max_power_point( + IL, I0, Rs, Rsh, nNsVth, + d2mutau=pvsyst_fs_495['d2mutau'], + NsVbi=VOLTAGE_BUILTIN*pvsyst_fs_495['cells_in_series'], + method='newton') + for k, v in out.items(): + assert np.isclose(v, expected[k], 0.01) + + def test_mpp_array(): """test max_power_point""" IL, I0, Rs, Rsh, nNsVth = (np.array([7, 7]), 6e-7, .1, 20, .5)