Skip to content

Commit 4b66810

Browse files
committed
Enhance Huld model with EU JRC coefficients
- Introduced a new function to infer updated coefficients for the Huld model based on EU JRC research. - Added a parameter to the existing Huld function to optionally use these updated coefficients. - Updated documentation to reflect the new functionality and included references to the EU JRC paper. - Added tests to verify the implementation and ensure compatibility with existing functionality. (cherry picked from commit f0ba338)
1 parent a27c686 commit 4b66810

File tree

2 files changed

+75
-3
lines changed

2 files changed

+75
-3
lines changed

pvlib/pvarray.py

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def pvefficiency_adr(effective_irradiance, temp_cell,
3737
the reference conditions. [unitless]
3838
3939
k_d : numeric, negative
40-
Dark irradiance or diode coefficient which influences the voltage
40+
"Dark irradiance" or diode coefficient which influences the voltage
4141
increase with irradiance. [unitless]
4242
4343
tc_d : numeric
@@ -242,7 +242,45 @@ def _infer_k_huld(cell_type, pdc0):
242242
return k
243243

244244

245-
def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None):
245+
def _infer_k_huld_eu_jrc(cell_type, pdc0):
246+
"""
247+
Get the EU JRC updated coefficients for the Huld model.
248+
249+
Parameters
250+
----------
251+
cell_type : str
252+
Must be one of 'csi', 'cis', or 'cdte'
253+
pdc0 : numeric
254+
Power of the modules at reference conditions [W]
255+
256+
Returns
257+
-------
258+
tuple
259+
The six coefficients (k1-k6) for the Huld model, scaled by pdc0
260+
261+
Notes
262+
-----
263+
These coefficients are from the EU JRC paper [1]_. The coefficients are
264+
for the version of Huld's equation that has factored Pdc0 out of the
265+
polynomial, so they are multiplied by pdc0 before being returned.
266+
267+
References
268+
----------
269+
.. [1] EU JRC paper, "Updated coefficients for the Huld model",
270+
https://doi.org/10.1002/pip.3926
271+
"""
272+
# Updated coefficients from EU JRC paper
273+
huld_params = {'csi': (-0.017162, -0.040289, -0.004681, 0.000148,
274+
0.000169, 0.000005),
275+
'cis': (-0.005521, -0.038576, -0.003711, -0.000901,
276+
-0.001251, 0.000001),
277+
'cdte': (-0.046477, -0.072509, -0.002252, 0.000275,
278+
0.000158, -0.000006)}
279+
k = tuple([x*pdc0 for x in huld_params[cell_type.lower()]])
280+
return k
281+
282+
283+
def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None, use_eu_jrc=False):
246284
r"""
247285
Power (DC) using the Huld model.
248286
@@ -274,6 +312,9 @@ def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None):
274312
cell_type : str, optional
275313
If provided, must be one of ``'cSi'``, ``'CIS'``, or ``'CdTe'``.
276314
Used to look up default values for ``k`` if ``k`` is not specified.
315+
use_eu_jrc : bool, default False
316+
If True, use the updated coefficients from the EU JRC paper [2]_.
317+
Only used if ``k`` is not provided and ``cell_type`` is specified.
277318
278319
Returns
279320
-------
@@ -332,10 +373,15 @@ def huld(effective_irradiance, temp_mod, pdc0, k=None, cell_type=None):
332373
E. Dunlop. A power-rating model for crystalline silicon PV modules.
333374
Solar Energy Materials and Solar Cells 95, (2011), pp. 3359-3369.
334375
:doi:`10.1016/j.solmat.2011.07.026`.
376+
.. [2] EU JRC paper, "Updated coefficients for the Huld model",
377+
https://doi.org/10.1002/pip.3926
335378
"""
336379
if k is None:
337380
if cell_type is not None:
338-
k = _infer_k_huld(cell_type, pdc0)
381+
if use_eu_jrc:
382+
k = _infer_k_huld_eu_jrc(cell_type, pdc0)
383+
else:
384+
k = _infer_k_huld(cell_type, pdc0)
339385
else:
340386
raise ValueError('Either k or cell_type must be specified')
341387

tests/test_pvarray.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,29 @@ def test_huld():
6969
with pytest.raises(ValueError,
7070
match='Either k or cell_type must be specified'):
7171
res = pvarray.huld(1000, 25, 100)
72+
73+
74+
def test_huld_eu_jrc():
75+
"""Test the EU JRC updated coefficients for the Huld model."""
76+
pdc0 = 100
77+
78+
# Test that EU JRC coefficients give different results than original
79+
res_orig = pvarray.huld(1000, 25, pdc0, cell_type='cSi')
80+
res_eu_jrc = pvarray.huld(1000, 25, pdc0, cell_type='cSi', use_eu_jrc=True)
81+
assert not np.isclose(res_orig, res_eu_jrc)
82+
83+
# Test that coefficients are properly scaled by pdc0
84+
k_orig = pvarray._infer_k_huld('cSi', pdc0)
85+
k_eu_jrc = pvarray._infer_k_huld_eu_jrc('cSi', pdc0)
86+
assert len(k_orig) == len(k_eu_jrc) == 6
87+
assert all(np.isclose(k1/pdc0, k2/pdc0) for k1, k2 in zip(k_orig, k_eu_jrc))
88+
89+
# Test that all cell types are supported
90+
for cell_type in ['csi', 'cis', 'cdte']:
91+
k = pvarray._infer_k_huld_eu_jrc(cell_type, pdc0)
92+
assert len(k) == 6
93+
assert all(isinstance(x, float) for x in k)
94+
95+
# Test invalid cell type
96+
with pytest.raises(KeyError):
97+
pvarray._infer_k_huld_eu_jrc('invalid', pdc0)

0 commit comments

Comments
 (0)