Closed
Description
Describe the bug
Since pvlib 0.9.4 release (#1606) I get an error while running the single-diode model with some very low effective irradiance values.
To Reproduce
from pvlib import pvsystem
effective_irradiance=1.341083e-17
temp_cell=13.7
cec_modules = pvsystem.retrieve_sam('CECMod')
cec_module = cec_modules['Trina_Solar_TSM_300DEG5C_07_II_']
mount = pvsystem.FixedMount()
array = pvsystem.Array(mount=mount,
module_parameters=cec_module)
system = pvsystem.PVSystem(arrays=[array])
params = system.calcparams_cec(effective_irradiance,
temp_cell)
system.singlediode(*params)
303 """
304 Vectorized golden section search for finding maximum of a function of a
305 single variable.
(...)
342 pvlib.singlediode._pwr_optfcn
343 """
344 if np.any(upper - lower < 0.):
--> 345 raise ValueError('upper >= lower is required')
347 phim1 = (np.sqrt(5) - 1) / 2
349 df = params
ValueError: upper >= lower is required
Expected behavior
This complicates the bifacial modeling procedure as run_model_from_effective_irradiance
can be called with very low irradiance values estimated by pvfactors (at sunrise or sunset for instance).
Versions:
pvlib.__version__
: 0.9.4pandas.__version__
: 1.5.3- python: 3.10
Additional context
v_oc is negative in this case which causes the error.
from pvlib.singlediode import _lambertw_v_from_i
photocurrent = params[0]
saturation_current = params[1]
resistance_series = params[2]
resistance_shunt = params[3]
nNsVth = params[4]
v_oc = _lambertw_v_from_i(resistance_shunt, resistance_series, nNsVth, 0.,
saturation_current, photocurrent)