Skip to content

Commit ee03ed4

Browse files
cwhansewholmgren
authored andcommitted
Implement calcparams_pvsyst and tests (#486)
* initial version of calcparams_pvsyst and test * fix argument list in tests * Fix typo in test argument R_sh_0 * remove EgRef from PVSystem.test_calcparams_pvsyst * add documentation for mugamma, fix typo * edits and fix to test error * Fix argument list and expected result * Fix error in calculation of nNsVth * Add note to whatsnew.rst * Add line to api.rst * Edits to function signatures, variable names * Change mugamma to mu_gamma, add issue to whatsnew text * Change to mu_gamma in tests * remove **kwargs from method calcparams_pvsyst signature, add irrad_ref and temp_ref keyword * fix typo in Boltzmann constant J/K * Remove scope=session from pvsyst fixture
1 parent e6aa17c commit ee03ed4

File tree

4 files changed

+269
-34
lines changed

4 files changed

+269
-34
lines changed

docs/sphinx/source/api.rst

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ Functions relevant for the single diode model.
202202
:toctree: generated/
203203

204204
pvsystem.calcparams_desoto
205+
pvsystem.calcparams_pvsyst
205206
pvsystem.i_from_v
206207
pvsystem.singlediode
207208
pvsystem.v_from_i

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

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Enhancements
1414
* Add sea surface albedo in irradiance.py (:issue:`458`)
1515
* Implement first_solar_spectral_loss in modelchain.py (:issue:`359`)
1616
* Clarify arguments Egref and dEgdT for calcparams_desoto (:issue:`462`)
17+
* Add pvsystem.calcparams_pvsyst to compute values for the single diode equation using the PVsyst v6 model (:issue:'470')
1718

1819

1920
Bug fixes

pvlib/pvsystem.py

+191-34
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,40 @@ def calcparams_desoto(self, effective_irradiance, temp_cell, **kwargs):
302302
"""
303303

304304
kwargs = _build_kwargs(['a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref',
305-
'R_s', 'alpha_sc', 'EgRef', 'dEgdT'],
305+
'R_s', 'alpha_sc', 'EgRef', 'dEgdT',
306+
'irrad_ref', 'temp_ref'],
306307
self.module_parameters)
307-
308+
308309
return calcparams_desoto(effective_irradiance, temp_cell, **kwargs)
309310

311+
def calcparams_pvsyst(self, effective_irradiance, temp_cell):
312+
"""
313+
Use the :py:func:`calcparams_pvsyst` function, the input
314+
parameters and ``self.module_parameters`` to calculate the
315+
module currents and resistances.
316+
317+
Parameters
318+
----------
319+
effective_irradiance : numeric
320+
The irradiance (W/m2) that is converted to photocurrent.
321+
322+
temp_cell : float or Series
323+
The average cell temperature of cells within a module in C.
324+
325+
Returns
326+
-------
327+
See pvsystem.calcparams_pvsyst for details
328+
"""
329+
330+
kwargs = _build_kwargs(['gamma_ref', 'mu_gamma', 'I_L_ref', 'I_o_ref',
331+
'R_sh_ref', 'R_sh_0', 'R_sh_exp',
332+
'R_s', 'alpha_sc', 'EgRef',
333+
'irrad_ref', 'temp_ref',
334+
'cells_in_series'],
335+
self.module_parameters)
336+
337+
return calcparams_pvsyst(effective_irradiance, temp_cell, **kwargs)
338+
310339
def sapm(self, effective_irradiance, temp_cell, **kwargs):
311340
"""
312341
Use the :py:func:`sapm` function, the input parameters,
@@ -462,7 +491,7 @@ def first_solar_spectral_loss(self, pw, airmass_absolute):
462491
coefficients = None
463492

464493
return atmosphere.first_solar_spectral_correction(pw,
465-
airmass_absolute,
494+
airmass_absolute,
466495
module_type,
467496
coefficients)
468497

@@ -946,12 +975,12 @@ def physicaliam(aoi, n=1.526, K=4., L=0.002):
946975

947976

948977
def calcparams_desoto(effective_irradiance, temp_cell,
949-
alpha_sc, a_ref, I_L_ref, I_o_ref, R_sh_ref, R_s,
978+
alpha_sc, a_ref, I_L_ref, I_o_ref, R_sh_ref, R_s,
950979
EgRef=1.121, dEgdT=-0.0002677,
951980
irrad_ref=1000, temp_ref=25):
952981
'''
953-
Calculates five parameter values for the single diode equation at
954-
effective irradiance and cell temperature using the De Soto et al.
982+
Calculates five parameter values for the single diode equation at
983+
effective irradiance and cell temperature using the De Soto et al.
955984
model described in [1]. The five values returned by calcparams_desoto
956985
can be used by singlediode to calculate an IV curve.
957986
@@ -968,34 +997,34 @@ def calcparams_desoto(effective_irradiance, temp_cell,
968997
module in units of A/C.
969998
970999
a_ref : float
971-
The product of the usual diode ideality factor (n, unitless),
1000+
The product of the usual diode ideality factor (n, unitless),
9721001
number of cells in series (Ns), and cell thermal voltage at reference
9731002
conditions, in units of V.
9741003
9751004
I_L_ref : float
9761005
The light-generated current (or photocurrent) at reference conditions,
9771006
in amperes.
978-
1007+
9791008
I_o_ref : float
9801009
The dark or diode reverse saturation current at reference conditions,
9811010
in amperes.
982-
1011+
9831012
R_sh_ref : float
9841013
The shunt resistance at reference conditions, in ohms.
985-
1014+
9861015
R_s : float
9871016
The series resistance at reference conditions, in ohms.
9881017
9891018
EgRef : float
9901019
The energy bandgap at reference temperature in units of eV.
991-
1.121 eV for crystalline silicon. EgRef must be >0. For parameters
1020+
1.121 eV for crystalline silicon. EgRef must be >0. For parameters
9921021
from the SAM CEC module database, EgRef=1.121 is implicit for all
9931022
cell types in the parameter estimation algorithm used by NREL.
9941023
9951024
dEgdT : float
9961025
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
1026+
conditions in units of 1/K. May be either a scalar value
1027+
(e.g. -0.0002677 as in [1]) or a DataFrame (this may be useful if
9991028
dEgdT is a modeled as a function of temperature). For parameters from
10001029
the SAM CEC module database, dEgdT=-0.0002677 is implicit for all cell
10011030
types in the parameter estimation algorithm used by NREL.
@@ -1011,28 +1040,21 @@ def calcparams_desoto(effective_irradiance, temp_cell,
10111040
Tuple of the following results:
10121041
10131042
photocurrent : numeric
1014-
Light-generated current in amperes at irradiance=S and
1015-
cell temperature=Tcell.
1043+
Light-generated current in amperes
10161044
10171045
saturation_current : numeric
1018-
Diode saturation curent in amperes at irradiance
1019-
S and cell temperature Tcell.
1046+
Diode saturation curent in amperes
10201047
10211048
resistance_series : float
1022-
Series resistance in ohms at irradiance S and cell temperature
1023-
Tcell.
1049+
Series resistance in ohms
10241050
10251051
resistance_shunt : numeric
1026-
Shunt resistance in ohms at irradiance S and cell temperature
1027-
Tcell.
1052+
Shunt resistance in ohms
10281053
10291054
nNsVth : numeric
1030-
Modified diode ideality factor at irradiance S and cell
1031-
temperature Tcell. Note that in source [1] nNsVth = a (equation
1032-
2). nNsVth is the product of the usual diode ideality factor
1033-
(n), the number of series-connected cells in the module (Ns),
1034-
and the thermal voltage of a cell in the module (Vth) at a cell
1035-
temperature of Tcell.
1055+
The product of the usual diode ideality factor (n, unitless),
1056+
number of cells in series (Ns), and cell thermal voltage at
1057+
specified effective irradiance and cell temperature.
10361058
10371059
References
10381060
----------
@@ -1051,8 +1073,6 @@ def calcparams_desoto(effective_irradiance, temp_cell,
10511073
10521074
See Also
10531075
--------
1054-
sapm
1055-
sapm_celltemp
10561076
singlediode
10571077
retrieve_sam
10581078
@@ -1143,7 +1163,7 @@ def calcparams_desoto(effective_irradiance, temp_cell,
11431163

11441164
# Boltzmann constant in eV/K
11451165
k = 8.617332478e-05
1146-
1166+
11471167
# reference temperature
11481168
Tref_K = temp_ref + 273.15
11491169
Tcell_K = temp_cell + 273.15
@@ -1152,9 +1172,9 @@ def calcparams_desoto(effective_irradiance, temp_cell,
11521172

11531173
nNsVth = a_ref * (Tcell_K / Tref_K)
11541174

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) *
1175+
# In the equation for IL, the single factor effective_irradiance is
1176+
# used, in place of the product S*M in [1]. effective_irradiance is
1177+
# equivalent to the product of S (irradiance reaching a module's cells) *
11581178
# M (spectral adjustment factor) as described in [1].
11591179
IL = effective_irradiance / irrad_ref * \
11601180
(I_L_ref + alpha_sc * (Tcell_K - Tref_K))
@@ -1164,14 +1184,151 @@ def calcparams_desoto(effective_irradiance, temp_cell,
11641184
# Rsh = Rsh_ref * (S_ref / S) where S is broadband irradiance reaching
11651185
# the module's cells. If desired this model behavior can be duplicated
11661186
# by applying reflection and soiling losses to broadband plane of array
1167-
# irradiance and not applying a spectral loss modifier, i.e.,
1187+
# irradiance and not applying a spectral loss modifier, i.e.,
11681188
# spectral_modifier = 1.0.
11691189
Rsh = R_sh_ref * (irrad_ref / effective_irradiance)
11701190
Rs = R_s
11711191

11721192
return IL, I0, Rs, Rsh, nNsVth
11731193

11741194

1195+
def calcparams_pvsyst(effective_irradiance, temp_cell,
1196+
alpha_sc, gamma_ref, mu_gamma,
1197+
I_L_ref, I_o_ref,
1198+
R_sh_ref, R_sh_0, R_s,
1199+
cells_in_series,
1200+
R_sh_exp=5.5,
1201+
EgRef=1.121,
1202+
irrad_ref=1000, temp_ref=25):
1203+
'''
1204+
Calculates five parameter values for the single diode equation at
1205+
effective irradiance and cell temperature using the PVsyst v6
1206+
model described in [1,2,3]. The five values returned by calcparams_pvsyst
1207+
can be used by singlediode to calculate an IV curve.
1208+
1209+
Parameters
1210+
----------
1211+
effective_irradiance : numeric
1212+
The irradiance (W/m2) that is converted to photocurrent.
1213+
1214+
temp_cell : numeric
1215+
The average cell temperature of cells within a module in C.
1216+
1217+
alpha_sc : float
1218+
The short-circuit current temperature coefficient of the
1219+
module in units of A/C.
1220+
1221+
gamma_ref : float
1222+
The diode ideality factor
1223+
1224+
mu_gamma : float
1225+
The temperature coefficient for the diode ideality factor, 1/K
1226+
1227+
I_L_ref : float
1228+
The light-generated current (or photocurrent) at reference conditions,
1229+
in amperes.
1230+
1231+
I_o_ref : float
1232+
The dark or diode reverse saturation current at reference conditions,
1233+
in amperes.
1234+
1235+
R_sh_ref : float
1236+
The shunt resistance at reference conditions, in ohms.
1237+
1238+
R_sh_0 : float
1239+
The shunt resistance at zero irradiance conditions, in ohms.
1240+
1241+
R_s : float
1242+
The series resistance at reference conditions, in ohms.
1243+
1244+
cells_in_series : integer
1245+
The number of cells connected in series.
1246+
1247+
R_sh_exp : float
1248+
The exponent in the equation for shunt resistance, unitless. Defaults
1249+
to 5.5.
1250+
1251+
EgRef : float
1252+
The energy bandgap at reference temperature in units of eV.
1253+
1.121 eV for crystalline silicon. EgRef must be >0.
1254+
1255+
irrad_ref : float (optional, default=1000)
1256+
Reference irradiance in W/m^2.
1257+
1258+
temp_ref : float (optional, default=25)
1259+
Reference cell temperature in C.
1260+
1261+
Returns
1262+
-------
1263+
Tuple of the following results:
1264+
1265+
photocurrent : numeric
1266+
Light-generated current in amperes
1267+
1268+
saturation_current : numeric
1269+
Diode saturation current in amperes
1270+
1271+
resistance_series : float
1272+
Series resistance in ohms
1273+
1274+
resistance_shunt : numeric
1275+
Shunt resistance in ohms
1276+
1277+
nNsVth : numeric
1278+
The product of the usual diode ideality factor (n, unitless),
1279+
number of cells in series (Ns), and cell thermal voltage at
1280+
specified effective irradiance and cell temperature.
1281+
1282+
References
1283+
----------
1284+
[1] K. Sauer, T. Roessler, C. W. Hansen, Modeling the Irradiance and
1285+
Temperature Dependence of Photovoltaic Modules in PVsyst,
1286+
IEEE Journal of Photovoltaics v5(1), January 2015.
1287+
1288+
[2] A. Mermoud, PV modules modelling, Presentation at the 2nd PV
1289+
Performance Modeling Workshop, Santa Clara, CA, May 2013
1290+
1291+
[3] A. Mermoud, T. Lejeune, Performance Assessment of a Simulation Model
1292+
for PV modules of any available technology, 25th European Photovoltaic
1293+
Solar Energy Conference, Valencia, Spain, Sept. 2010
1294+
1295+
See Also
1296+
--------
1297+
calcparams_desoto
1298+
singlediode
1299+
1300+
'''
1301+
1302+
# Boltzmann constant in J/K
1303+
k = 1.38064852e-23
1304+
1305+
# elementary charge in coulomb
1306+
q = 1.6021766e-19
1307+
1308+
# reference temperature
1309+
Tref_K = temp_ref + 273.15
1310+
Tcell_K = temp_cell + 273.15
1311+
1312+
gamma = gamma_ref + mu_gamma * (Tcell_K - Tref_K)
1313+
nNsVth = gamma * k / q * cells_in_series * Tcell_K
1314+
1315+
IL = effective_irradiance / irrad_ref * \
1316+
(I_L_ref + alpha_sc * (Tcell_K - Tref_K))
1317+
1318+
I0 = I_o_ref * ((Tcell_K / Tref_K) ** 3) * \
1319+
(np.exp((q * EgRef) / (k * gamma) * (1 / Tref_K - 1 / Tcell_K)))
1320+
1321+
Rsh_tmp = (R_sh_ref - R_sh_0 * np.exp(-R_sh_exp)) / (1.0 - np.exp(-R_sh_exp))
1322+
Rsh_base = np.maximum(0.0, Rsh_tmp)
1323+
1324+
Rsh = Rsh_base + (R_sh_0 - Rsh_base) * \
1325+
np.exp(-R_sh_exp * effective_irradiance / irrad_ref)
1326+
1327+
Rs = R_s
1328+
1329+
return IL, I0, Rs, Rsh, nNsVth
1330+
1331+
11751332
def retrieve_sam(name=None, path=None):
11761333
'''
11771334
Retrieve latest module and inverter info from a local file or the

0 commit comments

Comments
 (0)