Skip to content

Fix2461 #2486

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fix2461 #2486

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
55 changes: 51 additions & 4 deletions pvlib/pvarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def pvefficiency_adr(effective_irradiance, temp_cell,
the reference conditions. [unitless]

k_d : numeric, negative
Dark irradiance or diode coefficient which influences the voltage
"Dark irradiance" or diode coefficient which influences the voltage
increase with irradiance. [unitless]

tc_d : numeric
Expand Down Expand Up @@ -242,7 +242,45 @@ def _infer_k_huld(cell_type, pdc0):
return k


def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None):
def _infer_k_huld_eu_jrc(cell_type, pdc0):
"""
Get the EU JRC updated coefficients for the Huld model.

Parameters
----------
cell_type : str
Must be one of 'csi', 'cis', or 'cdte'
pdc0 : numeric
Power of the modules at reference conditions [W]

Returns
-------
tuple
The six coefficients (k1-k6) for the Huld model, scaled by pdc0

Notes
-----
These coefficients are from the EU JRC paper [1]_. The coefficients are
for the version of Huld's equation that has factored Pdc0 out of the
polynomial, so they are multiplied by pdc0 before being returned.

References
----------
.. [1] EU JRC paper, "Updated coefficients for the Huld model",
https://doi.org/10.1002/pip.3926
"""
# Updated coefficients from EU JRC paper
huld_params = {'csi': (-0.017162, -0.040289, -0.004681, 0.000148,
0.000169, 0.000005),
'cis': (-0.005521, -0.038576, -0.003711, -0.000901,
-0.001251, 0.000001),
'cdte': (-0.046477, -0.072509, -0.002252, 0.000275,
0.000158, -0.000006)}
k = tuple([x*pdc0 for x in huld_params[cell_type.lower()]])
return k


def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None, use_eu_jrc=False):
r"""
Power (DC) using the Huld model.

Expand Down Expand Up @@ -274,6 +312,9 @@ def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None):
cell_type : str, optional
If provided, must be one of ``'cSi'``, ``'CIS'``, or ``'CdTe'``.
Used to look up default values for ``k`` if ``k`` is not specified.
use_eu_jrc : bool, default False
If True, use the updated coefficients from the EU JRC paper [2]_.
Only used if ``k`` is not provided and ``cell_type`` is specified.

Returns
-------
Expand Down Expand Up @@ -332,10 +373,15 @@ def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None):
E. Dunlop. A power-rating model for crystalline silicon PV modules.
Solar Energy Materials and Solar Cells 95, (2011), pp. 3359-3369.
:doi:`10.1016/j.solmat.2011.07.026`.
.. [2] EU JRC paper, "Updated coefficients for the Huld model",
https://doi.org/10.1002/pip.3926
Comment on lines +376 to +377
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you didn't change this to fit the IEEE citation format nor the :doi: directive (see the citation just above).

I recommend you to read https://pvlib-python.readthedocs.io/en/latest/contributing/style_guide.html

"""
if k is None:
if cell_type is not None:
k = _infer_k_huld(cell_type, pdc0)
if use_eu_jrc:
k = _infer_k_huld_eu_jrc(cell_type, pdc0)
else:
k = _infer_k_huld(cell_type, pdc0)
else:
raise ValueError('Either k or cell_type must be specified')

Expand All @@ -348,5 +394,6 @@ def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None):
# Eq. 1 in [1]
pdc = gprime * (pdc0 + k[0] * logGprime + k[1] * logGprime**2 +
k[2] * tprime + k[3] * tprime * logGprime +
k[4] * tprime * logGprime**2 + k[5] * tprime**2)
k[4] * tprime * logGprime**2 +
k[5] * tprime**2)
return pdc
23 changes: 23 additions & 0 deletions tests/test_pvarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,26 @@ def test_huld():
with pytest.raises(ValueError,
match='Either k or cell_type must be specified'):
res = pvarray.huld(1000, 25, 100)


def test_huld_eu_jrc():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check for some specific values, up to 4-5 decimals? It would be better if you calculate them outside of your Python implementation.

"""Test the EU JRC updated coefficients for the Huld model."""
pdc0 = 100
# Use non-reference values so coefficients affect the result
eff_irr = 800 # W/m^2 (not 1000)
temp_mod = 35 # deg C (not 25)
# Test that EU JRC coefficients give different results than original for all cell types
for cell_type in ['cSi', 'CIS', 'CdTe']:
res_orig = pvarray.huld(eff_irr, temp_mod, pdc0, cell_type=cell_type)
res_eu_jrc = pvarray.huld(
eff_irr, temp_mod, pdc0, cell_type=cell_type, use_eu_jrc=True)
assert not np.isclose(res_orig, res_eu_jrc), (
f"Results should differ for {cell_type}: {res_orig} vs {res_eu_jrc}")
# Also check that all cell types are supported and error is raised for invalid type
try:
pvarray.huld(
eff_irr, temp_mod, pdc0, cell_type='invalid', use_eu_jrc=True)
except KeyError:
pass
else:
assert False, "Expected KeyError for invalid cell_type"