Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4b66810
Enhance Huld model with EU JRC coefficients
OmarBahamida Jun 15, 2025
928207e
Refactor Huld model tests for EU JRC coefficients
OmarBahamida Jun 15, 2025
1833dc1
Fix Flake8 linter errors
OmarBahamida Jul 20, 2025
98846e6
Fix Flake8 errors:
OmarBahamida Jul 20, 2025
241c272
restructure lookup and test
cwhanse Jul 21, 2025
79f490f
fix test and formatting
cwhanse Jul 21, 2025
a5a5ae8
adjust error message
cwhanse Jul 21, 2025
aa7d3ee
Merge branch 'main' of https://github.com/pvlib/pvlib-python into fix…
cwhanse Jul 22, 2025
91da25c
add whatsnew
cwhanse Jul 22, 2025
140b55b
Apply suggestions from code review
cwhanse Jul 23, 2025
752ef05
Update pvlib/pvarray.py
cwhanse Jul 23, 2025
0703ac1
Update pvlib/pvarray.py
cwhanse Jul 23, 2025
889805b
Update pvlib/pvarray.py
cwhanse Jul 23, 2025
57edf70
correct coefficients for 2025 and references
cwhanse Jul 24, 2025
92b5cde
fix conflict
cwhanse Jul 24, 2025
8b41911
fix docstring
cwhanse Jul 24, 2025
89727f3
change parameter key to pvgis5, etc.
cwhanse Aug 6, 2025
5052843
Merge branch 'main' of https://github.com/pvlib/pvlib-python into fix…
cwhanse Aug 6, 2025
607938d
error message
cwhanse Aug 6, 2025
cafd131
lint
cwhanse Aug 6, 2025
d078e74
fix test
cwhanse Aug 6, 2025
a23f5cd
Merge branch 'main' into fix2461
cwhanse Sep 19, 2025
c74a279
Merge branch 'main' into fix2461
kandersolar Sep 23, 2025
a1ea251
Apply suggestions from code review
kandersolar Sep 23, 2025
4d56803
Merge remote-tracking branch 'upstream/main' into pr/2486
kandersolar Sep 23, 2025
a72d557
Merge branch 'fix2461' of https://github.com/OmarBahamida/pvlib-pytho…
kandersolar Sep 23, 2025
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
52 changes: 49 additions & 3 deletions pvlib/pvarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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 @@
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.

Check failure on line 248 in pvlib/pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

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

Check failure on line 255 in pvlib/pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W293 blank line contains whitespace
Returns
-------
tuple
The six coefficients (k1-k6) for the Huld model, scaled by pdc0

Check failure on line 260 in pvlib/pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W293 blank line contains whitespace
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.

Check failure on line 266 in pvlib/pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W293 blank line contains whitespace
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):

Check failure on line 283 in pvlib/pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (89 > 79 characters)
r"""
Power (DC) using the Huld model.
Expand Down Expand Up @@ -274,6 +312,9 @@
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 @@
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
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 Down
20 changes: 20 additions & 0 deletions tests/test_pvarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,23 @@
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

Check failure on line 80 in tests/test_pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (91 > 79 characters)
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)

Check failure on line 83 in tests/test_pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (96 > 79 characters)
assert not np.isclose(res_orig, res_eu_jrc), f"Results should differ for {cell_type}: {res_orig} vs {res_eu_jrc}"

Check failure on line 84 in tests/test_pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (121 > 79 characters)
# Also check that all cell types are supported and error is raised for invalid type

Check failure on line 85 in tests/test_pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (87 > 79 characters)
try:
pvarray.huld(eff_irr, temp_mod, pdc0, cell_type='invalid', use_eu_jrc=True)

Check failure on line 87 in tests/test_pvarray.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (83 > 79 characters)
except KeyError:
pass
else:
assert False, "Expected KeyError for invalid cell_type"

Check warning on line 91 in tests/test_pvarray.py

View check run for this annotation

Codecov / codecov/patch

tests/test_pvarray.py#L91

Added line #L91 was not covered by tests
Loading