Skip to content

Commit 8aec267

Browse files
cwhansewholmgren
authored andcommitted
Clarify Egref and dEgdT values, changes calcparams_desoto api (#471)
* Fix total_irrad docstring * Correct formatting in irradiance.py; update whatsnew.rst * Update irradiance.py * update CEC module and inverter files * Add files via upload * Change pvsystem.calcparams_desoto API to keywords, add _build_kwargs to PVSystem.calcparams_desoto * Change signature of pvsystem.calcparams_desoto to all keyword arguments, remove M argument, change poa_irradiance to effective_irradiance, and add _build_kwargs to PVSystem.calcparams_desoto * Change signature of pvsystem.calcparams_desoto to all keyword arguments, remove M argument, change poa_irradiance to effective_irradiance, and add _build_kwargs to PVSystem.calcparams_desoto * fix merge conflict in irradiance.py * fix merge conflict in cec inverter file * fix merge conflicts * fix typo in test_pvsystem.test_calcparams_desoto * Correct test condition * correct alpha_isc to alpha_sc * update test_singlediode_** for change in calcparams_desoto api * "Fix merge conflict" * Change units on effective_irradiance input to calcparams_desoto from suns to W/m2 * Correct irradiance units in test_singlediode_series_ivcurve * Updates to pvsystem tutorial, modelchain documentation, whatsnew * Edit whatsnew text, add graceful exit from calcparams_desoto if old arguments detected * Edits to warning messages in calcparams_desoto * Improve comments * Improve comments
1 parent 1872ae8 commit 8aec267

File tree

5 files changed

+1181
-1220
lines changed

5 files changed

+1181
-1220
lines changed

docs/sphinx/source/modelchain.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@
730730
"name": "python",
731731
"nbconvert_exporter": "python",
732732
"pygments_lexer": "ipython3",
733-
"version": "3.6.1"
733+
"version": "3.6.4"
734734
}
735735
},
736736
"nbformat": 4,

docs/sphinx/source/whatsnew/v0.6.0.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ v0.6.0 (___, 2018)
55

66
API Changes
77
~~~~~~~~~~~
8-
8+
* pvsystem.calcparams_desoto now requires arguments for each module model parameter.
99

1010

1111
Enhancements
1212
~~~~~~~~~~~~
1313
* Add sea surface albedo in irradiance.py (:issue:`458`)
14-
* Implement first_solar_spectral_loss in modelchain.py (:issue:'359')
14+
* Implement first_solar_spectral_loss in modelchain.py (:issue:`359`)
15+
* Clarify arguments Egref and dEgdT for calcparams_desoto (:issue:`462`)
1516

1617

1718
Bug fixes

docs/tutorials/pvsystem.ipynb

Lines changed: 1052 additions & 1122 deletions
Large diffs are not rendered by default.

pvlib/pvsystem.py

Lines changed: 90 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,16 @@ def physicaliam(self, aoi):
279279

280280
return physicaliam(aoi, **kwargs)
281281

282-
def calcparams_desoto(self, poa_global, temp_cell, **kwargs):
282+
def calcparams_desoto(self, effective_irradiance, temp_cell, **kwargs):
283283
"""
284284
Use the :py:func:`calcparams_desoto` function, the input
285285
parameters and ``self.module_parameters`` to calculate the
286286
module currents and resistances.
287287
288288
Parameters
289289
----------
290-
poa_global : float or Series
291-
The irradiance (in W/m^2) absorbed by the module.
290+
effective_irradiance : numeric
291+
The irradiance (W/m2) that is converted to photocurrent.
292292
293293
temp_cell : float or Series
294294
The average cell temperature of cells within a module in C.
@@ -300,11 +300,12 @@ def calcparams_desoto(self, poa_global, temp_cell, **kwargs):
300300
-------
301301
See pvsystem.calcparams_desoto for details
302302
"""
303-
return calcparams_desoto(poa_global, temp_cell,
304-
self.module_parameters['alpha_sc'],
305-
self.module_parameters,
306-
self.module_parameters['EgRef'],
307-
self.module_parameters['dEgdT'], **kwargs)
303+
304+
kwargs = _build_kwargs(['a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref',
305+
'R_s', 'alpha_sc', 'EgRef', 'dEgdT'],
306+
self.module_parameters)
307+
308+
return calcparams_desoto(effective_irradiance, temp_cell, **kwargs)
308309

309310
def sapm(self, effective_irradiance, temp_cell, **kwargs):
310311
"""
@@ -944,75 +945,60 @@ def physicaliam(aoi, n=1.526, K=4., L=0.002):
944945
return iam
945946

946947

947-
def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,
948-
EgRef, dEgdT, M=1, irrad_ref=1000, temp_ref=25):
948+
def calcparams_desoto(effective_irradiance, temp_cell,
949+
alpha_sc, a_ref, I_L_ref, I_o_ref, R_sh_ref, R_s,
950+
EgRef=1.121, dEgdT=-0.0002677,
951+
irrad_ref=1000, temp_ref=25):
949952
'''
950-
Applies the temperature and irradiance corrections to inputs for
951-
singlediode.
952-
953-
Applies the temperature and irradiance corrections to the IL, I0,
954-
Rs, Rsh, and a parameters at reference conditions (IL_ref, I0_ref,
955-
etc.) according to the De Soto et. al description given in [1]. The
956-
results of this correction procedure may be used in a single diode
957-
model to determine IV curves at irradiance = S, cell temperature =
958-
Tcell.
953+
Calculates five parameter values for the single diode equation at
954+
effective irradiance and cell temperature using the De Soto et al.
955+
model described in [1]. The five values returned by calcparams_desoto
956+
can be used by singlediode to calculate an IV curve.
959957
960958
Parameters
961959
----------
962-
poa_global : numeric
963-
The irradiance (in W/m^2) absorbed by the module.
960+
effective_irradiance : numeric
961+
The irradiance (W/m2) that is converted to photocurrent.
964962
965963
temp_cell : numeric
966964
The average cell temperature of cells within a module in C.
967965
968-
alpha_isc : float
966+
alpha_sc : float
969967
The short-circuit current temperature coefficient of the
970-
module in units of 1/C.
971-
972-
module_parameters : dict
973-
Parameters describing PV module performance at reference
974-
conditions according to DeSoto's paper. Parameters may be
975-
generated or found by lookup. For ease of use,
976-
retrieve_sam can automatically generate a dict based on the
977-
most recent SAM CEC module
978-
database. The module_parameters dict must contain the
979-
following 5 fields:
980-
981-
* a_ref - modified diode ideality factor parameter at
982-
reference conditions (units of eV), a_ref can be calculated
983-
from the usual diode ideality factor (n),
984-
number of cells in series (Ns),
985-
and cell temperature (Tcell) per equation (2) in [1].
986-
* I_L_ref - Light-generated current (or photocurrent)
987-
in amperes at reference conditions. This value is referred to
988-
as Iph in some literature.
989-
* I_o_ref - diode reverse saturation current in amperes,
990-
under reference conditions.
991-
* R_sh_ref - shunt resistance under reference conditions (ohms).
992-
* R_s - series resistance under reference conditions (ohms).
968+
module in units of A/C.
969+
970+
a_ref : float
971+
The product of the usual diode ideality factor (n, unitless),
972+
number of cells in series (Ns), and cell thermal voltage at reference
973+
conditions, in units of V.
974+
975+
I_L_ref : float
976+
The light-generated current (or photocurrent) at reference conditions,
977+
in amperes.
978+
979+
I_o_ref : float
980+
The dark or diode reverse saturation current at reference conditions,
981+
in amperes.
982+
983+
R_sh_ref : float
984+
The shunt resistance at reference conditions, in ohms.
985+
986+
R_s : float
987+
The series resistance at reference conditions, in ohms.
993988
994989
EgRef : float
995-
The energy bandgap at reference temperature (in eV).
996-
1.121 eV for silicon. EgRef must be >0.
990+
The energy bandgap at reference temperature in units of eV.
991+
1.121 eV for crystalline silicon. EgRef must be >0. For parameters
992+
from the SAM CEC module database, EgRef=1.121 is implicit for all
993+
cell types in the parameter estimation algorithm used by NREL.
997994
998995
dEgdT : float
999-
The temperature dependence of the energy bandgap at SRC (in
1000-
1/C). May be either a scalar value (e.g. -0.0002677 as in [1])
1001-
or a DataFrame of dEgdT values corresponding to each input
1002-
condition (this may be useful if dEgdT is a function of
1003-
temperature).
1004-
1005-
M : numeric (optional, default=1)
1006-
An optional airmass modifier, if omitted, M is given a value of
1007-
1, which assumes absolute (pressure corrected) airmass = 1.5. In
1008-
this code, M is equal to M/Mref as described in [1] (i.e. Mref
1009-
is assumed to be 1). Source [1] suggests that an appropriate
1010-
value for M as a function absolute airmass (AMa) may be:
1011-
1012-
>>> M = np.polyval([-0.000126, 0.002816, -0.024459, 0.086257, 0.918093],
1013-
... AMa) # doctest: +SKIP
1014-
1015-
M may be a Series.
996+
The temperature dependence of the energy bandgap at reference
997+
conditions in units of 1/K. May be either a scalar value
998+
(e.g. -0.0002677 as in [1]) or a DataFrame (this may be useful if
999+
dEgdT is a modeled as a function of temperature). For parameters from
1000+
the SAM CEC module database, dEgdT=-0.0002677 is implicit for all cell
1001+
types in the parameter estimation algorithm used by NREL.
10161002
10171003
irrad_ref : float (optional, default=1000)
10181004
Reference irradiance in W/m^2.
@@ -1090,7 +1076,7 @@ def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,
10901076
and modifying the reference parameters (for irradiance, temperature,
10911077
and airmass) per DeSoto's equations.
10921078
1093-
Silicon (Si):
1079+
Crystalline Silicon (Si):
10941080
* EgRef = 1.121
10951081
* dEgdT = -0.0002677
10961082
@@ -1134,26 +1120,54 @@ def calcparams_desoto(poa_global, temp_cell, alpha_isc, module_parameters,
11341120
Source: [4]
11351121
'''
11361122

1137-
M = np.maximum(M, 0)
1138-
a_ref = module_parameters['a_ref']
1139-
IL_ref = module_parameters['I_L_ref']
1140-
I0_ref = module_parameters['I_o_ref']
1141-
Rsh_ref = module_parameters['R_sh_ref']
1142-
Rs_ref = module_parameters['R_s']
1143-
1123+
# test for use of function pre-v0.6.0 API change
1124+
if isinstance(a_ref, dict) or \
1125+
(isinstance(a_ref, pd.Series) and ('a_ref' in a_ref.keys())):
1126+
import warnings
1127+
warnings.warn('module_parameters detected as fourth positional'
1128+
+ ' argument of calcparams_desoto. calcparams_desoto'
1129+
+ ' will require one argument for each module model'
1130+
+ ' parameter in v0.7.0 and later', DeprecationWarning)
1131+
try:
1132+
module_parameters = a_ref
1133+
a_ref = module_parameters['a_ref']
1134+
I_L_ref = module_parameters['I_L_ref']
1135+
I_o_ref = module_parameters['I_o_ref']
1136+
R_sh_ref = module_parameters['R_sh_ref']
1137+
R_s = module_parameters['R_s']
1138+
except Exception as e:
1139+
raise e('Module parameters could not be extracted from fourth'
1140+
+ ' positional argument of calcparams_desoto. Check that'
1141+
+ ' parameters are from the CEC database and/or update'
1142+
+ ' your code for the new API for calcparams_desoto')
1143+
1144+
# Boltzmann constant in eV/K
11441145
k = 8.617332478e-05
1146+
1147+
# reference temperature
11451148
Tref_K = temp_ref + 273.15
11461149
Tcell_K = temp_cell + 273.15
11471150

11481151
E_g = EgRef * (1 + dEgdT*(Tcell_K - Tref_K))
11491152

11501153
nNsVth = a_ref * (Tcell_K / Tref_K)
11511154

1152-
IL = (poa_global/irrad_ref) * M * (IL_ref + alpha_isc * (Tcell_K - Tref_K))
1153-
I0 = (I0_ref * ((Tcell_K / Tref_K) ** 3) *
1155+
# In the equation for IL, the single factor effective_irradiance is
1156+
# used, in place of the product S*M in [1]. effective_irradiance is
1157+
# equivalent to the product of S (irradiance reaching a module's cells) *
1158+
# M (spectral adjustment factor) as described in [1].
1159+
IL = effective_irradiance / irrad_ref * \
1160+
(I_L_ref + alpha_sc * (Tcell_K - Tref_K))
1161+
I0 = (I_o_ref * ((Tcell_K / Tref_K) ** 3) *
11541162
(np.exp(EgRef / (k*(Tref_K)) - (E_g / (k*(Tcell_K))))))
1155-
Rsh = Rsh_ref * (irrad_ref / poa_global)
1156-
Rs = Rs_ref
1163+
# Note that the equation for Rsh differs from [1]. In [1] Rsh is given as
1164+
# Rsh = Rsh_ref * (S_ref / S) where S is broadband irradiance reaching
1165+
# the module's cells. If desired this model behavior can be duplicated
1166+
# by applying reflection and soiling losses to broadband plane of array
1167+
# irradiance and not applying a spectral loss modifier, i.e.,
1168+
# spectral_modifier = 1.0.
1169+
Rsh = R_sh_ref * (irrad_ref / effective_irradiance)
1170+
Rs = R_s
11571171

11581172
return IL, I0, Rs, Rsh, nNsVth
11591173

pvlib/test/test_pvsystem.py

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,18 @@ def test_PVSystem_sapm_effective_irradiance(sapm_module_params):
358358

359359
def test_calcparams_desoto(cec_module_params):
360360
times = pd.DatetimeIndex(start='2015-01-01', periods=2, freq='12H')
361-
poa_data = pd.Series([0, 800], index=times)
361+
effective_irradiance = pd.Series([0.0, 800.0], index=times)
362+
temp_cell = pd.Series([25, 25], index=times)
362363

363364
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
364-
poa_data,
365-
temp_cell=25,
366-
alpha_isc=cec_module_params['alpha_sc'],
367-
module_parameters=cec_module_params,
365+
effective_irradiance,
366+
temp_cell,
367+
alpha_sc=cec_module_params['alpha_sc'],
368+
a_ref=cec_module_params['a_ref'],
369+
I_L_ref=cec_module_params['I_L_ref'],
370+
I_o_ref=cec_module_params['I_o_ref'],
371+
R_sh_ref=cec_module_params['R_sh_ref'],
372+
R_s=cec_module_params['R_s'],
368373
EgRef=1.121,
369374
dEgdT=-0.0002677)
370375

@@ -382,10 +387,11 @@ def test_PVSystem_calcparams_desoto(cec_module_params):
382387
module_parameters['dEgdT'] = -0.0002677
383388
system = pvsystem.PVSystem(module_parameters=module_parameters)
384389
times = pd.DatetimeIndex(start='2015-01-01', periods=2, freq='12H')
385-
poa_data = pd.Series([0, 800], index=times)
390+
effective_irradiance = pd.Series([0.0, 800.0], index=times)
386391
temp_cell = 25
387392

388-
IL, I0, Rs, Rsh, nNsVth = system.calcparams_desoto(poa_data, temp_cell)
393+
IL, I0, Rs, Rsh, nNsVth = system.calcparams_desoto(effective_irradiance,
394+
temp_cell)
389395

390396
assert_series_equal(np.round(IL, 3), pd.Series([0.0, 6.036], index=times))
391397
# changed value in GH 444 for 2017-6-5 module file
@@ -639,14 +645,18 @@ def test_PVSystem_i_from_v():
639645
@requires_scipy
640646
def test_singlediode_series(cec_module_params):
641647
times = pd.DatetimeIndex(start='2015-01-01', periods=2, freq='12H')
642-
poa_data = pd.Series([0, 800], index=times)
648+
effective_irradiance = pd.Series([0.0, 800.0], index=times)
643649
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
644-
poa_data,
645-
temp_cell=25,
646-
alpha_isc=cec_module_params['alpha_sc'],
647-
module_parameters=cec_module_params,
648-
EgRef=1.121,
649-
dEgdT=-0.0002677)
650+
effective_irradiance,
651+
temp_cell=25,
652+
alpha_sc=cec_module_params['alpha_sc'],
653+
a_ref=cec_module_params['a_ref'],
654+
I_L_ref=cec_module_params['I_L_ref'],
655+
I_o_ref=cec_module_params['I_o_ref'],
656+
R_sh_ref=cec_module_params['R_sh_ref'],
657+
R_s=cec_module_params['R_s'],
658+
EgRef=1.121,
659+
dEgdT=-0.0002677)
650660
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth)
651661
assert isinstance(out, pd.DataFrame)
652662

@@ -713,12 +723,18 @@ def test_singlediode_floats_ivcurve():
713723
@requires_scipy
714724
def test_singlediode_series_ivcurve(cec_module_params):
715725
times = pd.DatetimeIndex(start='2015-06-01', periods=3, freq='6H')
716-
poa_data = pd.Series([0, 400, 800], index=times)
726+
effective_irradiance = pd.Series([0.0, 400.0, 800.0], index=times)
717727
IL, I0, Rs, Rsh, nNsVth = pvsystem.calcparams_desoto(
718-
poa_data, temp_cell=25,
719-
alpha_isc=cec_module_params['alpha_sc'],
720-
module_parameters=cec_module_params,
721-
EgRef=1.121, dEgdT=-0.0002677)
728+
effective_irradiance,
729+
temp_cell=25,
730+
alpha_sc=cec_module_params['alpha_sc'],
731+
a_ref=cec_module_params['a_ref'],
732+
I_L_ref=cec_module_params['I_L_ref'],
733+
I_o_ref=cec_module_params['I_o_ref'],
734+
R_sh_ref=cec_module_params['R_sh_ref'],
735+
R_s=cec_module_params['R_s'],
736+
EgRef=1.121,
737+
dEgdT=-0.0002677)
722738

723739
out = pvsystem.singlediode(IL, I0, Rs, Rsh, nNsVth, ivcurve_pnts=3)
724740

0 commit comments

Comments
 (0)