8000 clean up and test sapm_celltemp · Lamaf/pvlib-python@f438fdb · GitHub
[go: up one dir, main page]

Skip to content

Commit f438fdb

Browse files
committed
clean up and test sapm_celltemp
1 parent d76909b commit f438fdb

File tree

2 files changed

+68
-70
lines changed

2 files changed

+68
-70
lines changed

pvlib/pvsystem.py

Lines changed: 60 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import division
2+
13
import logging
24
pvl_logger = logging.getLogger('pvlib')
35

@@ -676,104 +678,93 @@ def sapm(Module,Eb,Ediff,Tcell,AM,AOI):
676678
return DFOut
677679

678680

679-
def sapmcelltemp(E, Wspd, Tamb,modelt='Open_rack_cell_glassback',**kwargs):
681+
def sapm_celltemp(irrad, wind, temp, model='open_rack_cell_glassback'):
680682
'''
681-
Estimate cell temperature from irradiance, windspeed, ambient temperature, and module parameters (SAPM)
682-
683683
Estimate cell and module temperatures per the Sandia PV Array
684684
Performance model (SAPM, SAND2004-3535), when given the incident
685685
irradiance, wind speed, ambient temperature, and SAPM module
686686
parameters.
687687
688688
Parameters
689689
----------
690+
irrad : float or DataFrame
691+
Total incident irradiance in W/m^2.
690692
691-
E : float or DataFrame
692-
Total incident irradiance in W/m^2. Must be >=0.
693-
694-
695-
windspeed : float or DataFrame
696-
Wind speed in m/s at a height of 10 meters. Must be >=0
697-
698-
Tamb : float or DataFrame
699-
Ambient dry bulb temperature in degrees C. Must be >= -273.15.
700-
701-
702-
Other Parameters
703-
----------------
693+
wind : float or DataFrame
694+
Wind speed in m/s at a height of 10 meters.
704695
705-
modelt : string
696+
temp : float or DataFrame
697+
Ambient dry bulb temperature in degrees C.
706698
707-
Model to be used for parameters, can be:
699+
model : string or list
700+
Model to be used.
701+
702+
If string, can be:
708703
709704
* 'Open_rack_cell_glassback' (DEFAULT)
710705
* 'Roof_mount_cell_glassback'
711706
* 'Open_rack_cell_polymerback'
712707
* 'Insulated_back_polumerback'
713708
* 'Open_rack_Polymer_thinfilm_steel'
714709
* '22X_Concentrator_tracker'
715-
716-
a : float (optional)
717-
SAPM module parameter for establishing the upper limit for module
718-
temperature at low wind speeds and high solar irradiance (see SAPM
719-
eqn. 11). Must be a scalar.If not input, this value will be taken from the chosen
720-
model
721-
b : float (optional)
722-
723-
SAPM module parameter for establishing the rate at which the module
724-
temperature drops as wind speed increases (see SAPM eqn. 11). Must be
725-
a scalar.If not input, this value will be taken from the chosen
726-
model
727-
728-
deltaT : float (optional)
729-
730-
SAPM module parameter giving the temperature difference
731-
between the cell and module back surface at the reference irradiance,
732-
E0. Must be a numeric scalar >=0. If not input, this value will be taken from the chosen
733-
model
710+
711+
If list, supply the following parameters in the following order:
712+
713+
* a : float
714+
SAPM module parameter for establishing the upper limit for module
715+
temperature at low wind speeds and high solar irradiance (see SAPM
716+
eqn. 11).
717+
718+
* b : float
719+
SAPM module parameter for establishing the rate at which the module
720+
temperature drops as wind speed increases (see SAPM eqn. 11). Must be
721+
a scalar.
722+
723+
* deltaT : float
724+
SAPM module parameter giving the temperature difference
725+
between the cell and module back surface at the reference irradiance,
726+
E0.
734727
735728
Returns
736729
--------
737-
Tcell : float or DataFrame
738-
Cell temperatures in degrees C.
739-
740-
Tmodule : float or DataFrame
741-
Module back temperature in degrees C.
730+
dict with keys tcell and tmodule. Values in degrees C.
742731
743732
References
744733
----------
745-
746-
[1] King, D. et al, 2004, "Sandia Photovoltaic Array Performance Model", SAND Report
747-
3535, Sandia National Laboratories, Albuquerque, NM
734+
[1] King, D. et al, 2004, "Sandia Photovoltaic Array Performance Model",
735+
SAND Report 3535, Sandia National Laboratories, Albuquerque, NM.
748736
749737
See Also
750738
--------
751-
752-
pvl_sapm
739+
sapm
753740
'''
754741

755-
TempModel={'Open_rack_cell_glassback':[-3.47, -.0594, 3],
756-
'Roof_mount_cell_glassback':[-2.98, -.0471, 1],
757-
'Open_rack_cell_polymerback': [-3.56, -.0750, 3],
758-
'Insulated_back_polumerback': [-2.81, -.0455, 0 ],
759-
'Open_rack_Polymer_thinfilm_steel':[-3.58, -.113, 3],
760-
'22X_Concentrator_tracker':[-3.23, -.130, 13]
761-
}
762-
try:
763-
a=a
764-
b=b
765-
deltaT=deltaT
766-
except:
767-
a=TempModel[modelt][0]
768-
b=TempModel[modelt][1]
769-
deltaT=TempModel[modelt][2]
770-
771-
E0=1000 # Reference irradiance
772-
Tmodule=E*((np.exp(a + b*Wspd))) + Tamb
773-
774-
Tcell=Tmodule + E / E0*(deltaT)
775-
776-
return pd.DataFrame({'Tcell':Tcell,'Tmodule':Tmodule})
742+
temp_models = {'open_rack_cell_glassback':[-3.47, -.0594, 3],
743+
'roof_mount_cell_glassback':[-2.98, -.0471, 1],
744+
'open_rack_cell_polymerback': [-3.56, -.0750, 3],
745+
'insulated_back_polumerback': [-2.81, -.0455, 0 ],
746+
'open_rack_polymer_thinfilm_steel':[-3.58, -.113, 3],
747+
'22x_concentrator_tracker':[-3.23, -.130, 13]
748+
}
749+
750+
if isinstance(model, str):
751+
model = temp_models[model.lower()]
752+
elif isinstance(model, list):
753+
model = model
754+
755+
a = model[0]
756+
b = model[1]
757+
deltaT = model[2]
758+
759+
E0 = 1000. # Reference irradiance
760+
761+
tmodule = irrad*np.exp(a + b*wind) + temp
762+
763+
tcell = tmodule + (irrad / E0)*(deltaT)
764+
765+
return {'tcell':tcell, 'tmodule':tmodule}
766+
767+
777768

778769
def singlediode(Module,IL,I0,Rs,Rsh,nNsVth,**kwargs):
779770
'''

pvlib/test/test_pvsystem.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import numpy as np
88
import pandas as pd
99

10-
from nose.tools import assert_equals
10+
from nose.tools import assert_equals, assert_almost_equals
1111

1212
from pvlib import tmy
1313
from pvlib import pvsystem
@@ -64,6 +64,13 @@ def test_retrieve_sam_network():
6464
pvsystem.retrieve_sam('cecmod')
6565
pvsystem.retrieve_sam('sandiamod')
6666
pvsystem.retrieve_sam('sandiainverter')
67+
68+
6769

70+
def test_sapm_celltemp():
71+
default = pvsystem.sapm_celltemp(900, 5, 20)
72+
assert_almost_equals(43.509, default['tcell'], 3)
73+
assert_almost_equals(40.809, default['tmodule'], 3)
74+
assert_equals(default, pvsystem.sapm_celltemp(900, 5, 20, [-3.47, -.0594, 3]))
6875

6976

0 commit comments

Comments
 (0)
0