Skip to content

fix recombination args in pvsystem.maximum_power_point #1733

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

Merged
merged 5 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.9.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~
Expand Down
3 changes: 1 addition & 2 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
39 changes: 39 additions & 0 deletions pvlib/tests/test_pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down Expand Up @@ -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)
Expand Down