Skip to content

Commit 496b568

Browse files
RDaxiniechedey-ls
andauthored
Add optional arguments temperature_ref and irradiance_ref to pvsystem.sapm (#2434)
* add ref irr/t as optional args, rename * add terms to docs * linter * Update v0.12.1.rst * move whatsnew entry from docs to enhancements * multiple instances of C -> °C * name change (#825) * Update v0.12.1.rst * missing ` * remove unused package * change to kwarg only parameters Co-Authored-By: Echedey Luis <[email protected]> * Revert "Update v0.12.1.rst" This reverts commit e8a7b10. * update names, remove duplicate entry * remove ivtools line. mistakenly added during merge branch? * Update docs/sphinx/source/whatsnew/v0.12.1.rst Co-authored-by: Echedey Luis <[email protected]> --------- Co-authored-by: Echedey Luis <[email protected]>
1 parent 580037a commit 496b568

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Enhancements
1717
* :py:mod:`pvlib.ivtools.sdm` is now a subpackage. (:issue:`2252`, :pull:`2256`)
1818
* Add a function for estimating PVsyst SDM parameters from IEC 61853-1 matrix
1919
data (:py:func:`~pvlib.ivtools.sdm.fit_pvsyst_iec61853_sandia_2025`). (:issue:`2185`, :pull:`2429`)
20+
* Add optional arguments ``temperature_ref`` and ``irradiance_ref`` to
21+
:py:func:`~pvlib.pvsystem.sapm`(:issue:`2432`, :pull:`2434`)
2022

2123
Documentation
2224
~~~~~~~~~~~~~

pvlib/pvsystem.py

+24-23
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
from abc import ABC, abstractmethod
1818
from typing import Optional, Union
1919

20-
from pvlib._deprecation import deprecated
21-
2220
import pvlib # used to avoid albedo name collision in the Array class
2321
from pvlib import (atmosphere, iam, inverter, irradiance,
2422
singlediode as _singlediode, spectrum, temperature)
@@ -2195,25 +2193,32 @@ def _parse_raw_sam_df(csvdata):
21952193
return df
21962194

21972195

2198-
def sapm(effective_irradiance, temp_cell, module):
2196+
def sapm(effective_irradiance, temp_cell, module, *, temperature_ref=25,
2197+
irradiance_ref=1000):
21992198
'''
22002199
The Sandia PV Array Performance Model (SAPM) generates 5 points on a
22012200
PV module's I-V curve (Voc, Isc, Ix, Ixx, Vmp/Imp) according to
2202-
SAND2004-3535. Assumes a reference cell temperature of 25 C.
2201+
SAND2004-3535. Assumes a reference cell temperature of 25°C.
22032202
22042203
Parameters
22052204
----------
22062205
effective_irradiance : numeric
22072206
Irradiance reaching the module's cells, after reflections and
2208-
adjustment for spectrum. [W/m2]
2207+
adjustment for spectrum. [Wm⁻²]
22092208
22102209
temp_cell : numeric
2211-
Cell temperature [C].
2210+
Cell temperature [°C].
22122211
22132212
module : dict-like
22142213
A dict or Series defining the SAPM parameters. See the notes section
22152214
for more details.
22162215
2216+
temperature_ref : numeric, optional
2217+
Reference temperature [°C]
2218+
2219+
irradiance_ref : numeric, optional
2220+
Reference irradiance [Wm⁻²]
2221+
22172222
Returns
22182223
-------
22192224
A DataFrame with the columns:
@@ -2251,19 +2256,19 @@ def sapm(effective_irradiance, temp_cell, module):
22512256
Voco Open circuit voltage at reference condition (amps)
22522257
Vmpo Maximum power voltage at reference condition (amps)
22532258
Aisc Short circuit current temperature coefficient at
2254-
reference condition (1/C)
2259+
reference condition (1/°C)
22552260
Aimp Maximum power current temperature coefficient at
2256-
reference condition (1/C)
2261+
reference condition (1/°C)
22572262
Bvoco Open circuit voltage temperature coefficient at
2258-
reference condition (V/C)
2263+
reference condition (V/°C)
22592264
Mbvoc Coefficient providing the irradiance dependence for the
22602265
BetaVoc temperature coefficient at reference irradiance
2261-
(V/C)
2266+
(V/°C)
22622267
Bvmpo Maximum power voltage temperature coefficient at
22632268
reference condition
22642269
Mbvmp Coefficient providing the irradiance dependence for the
22652270
BetaVmp temperature coefficient at reference irradiance
2266-
(V/C)
2271+
(V/°C)
22672272
N Empirically determined "diode factor" (dimensionless)
22682273
Cells_in_Series Number of cells in series in a module's cell string(s)
22692274
IXO Ix at reference conditions
@@ -2284,16 +2289,11 @@ def sapm(effective_irradiance, temp_cell, module):
22842289
pvlib.temperature.sapm_module
22852290
'''
22862291

2287-
# TODO: someday, change temp_ref and irrad_ref to reference_temperature and
2288-
# reference_irradiance and expose
2289-
temp_ref = 25
2290-
irrad_ref = 1000
2291-
22922292
q = constants.e # Elementary charge in units of coulombs
22932293
kb = constants.k # Boltzmann's constant in units of J/K
22942294

22952295
# avoid problem with integer input
2296-
Ee = np.array(effective_irradiance, dtype='float64') / irrad_ref
2296+
Ee = np.array(effective_irradiance, dtype='float64') / irradiance_ref
22972297

22982298
# set up masking for 0, positive, and nan inputs
22992299
Ee_gt_0 = np.full_like(Ee, False, dtype='bool')
@@ -2316,31 +2316,32 @@ def sapm(effective_irradiance, temp_cell, module):
23162316
out = OrderedDict()
23172317

23182318
out['i_sc'] = (
2319-
module['Isco'] * Ee * (1 + module['Aisc']*(temp_cell - temp_ref)))
2319+
module['Isco'] * Ee * (1 + module['Aisc']*(temp_cell -
2320+
temperature_ref)))
23202321

23212322
out['i_mp'] = (
23222323
module['Impo'] * (module['C0']*Ee + module['C1']*(Ee**2)) *
2323-
(1 + module['Aimp']*(temp_cell - temp_ref)))
2324+
(1 + module['Aimp']*(temp_cell - temperature_ref)))
23242325

23252326
out['v_oc'] = np.maximum(0, (
23262327
module['Voco'] + cells_in_series * delta * logEe +
2327-
Bvoco*(temp_cell - temp_ref)))
2328+
Bvoco*(temp_cell - temperature_ref)))
23282329

23292330
out['v_mp'] = np.maximum(0, (
23302331
module['Vmpo'] +
23312332
module['C2'] * cells_in_series * delta * logEe +
23322333
module['C3'] * cells_in_series * ((delta * logEe) ** 2) +
2333-
Bvmpo*(temp_cell - temp_ref)))
2334+
Bvmpo*(temp_cell - temperature_ref)))
23342335

23352336
out['p_mp'] = out['i_mp'] * out['v_mp']
23362337

23372338
out['i_x'] = (
23382339
module['IXO'] * (module['C4']*Ee + module['C5']*(Ee**2)) *
2339-
(1 + module['Aisc']*(temp_cell - temp_ref)))
2340+
(1 + module['Aisc']*(temp_cell - temperature_ref)))
23402341

23412342
out['i_xx'] = (
23422343
module['IXXO'] * (module['C6']*Ee + module['C7']*(Ee**2)) *
2343-
(1 + module['Aimp']*(temp_cell - temp_ref)))
2344+
(1 + module['Aimp']*(temp_cell - temperature_ref)))
23442345

23452346
if isinstance(out['i_sc'], pd.Series):
23462347
out = pd.DataFrame(out)

0 commit comments

Comments
 (0)