Skip to content

Commit 5218c9d

Browse files
authored
refactor sapm to be consistent with matlab (#218)
* refactor sapm to be consistent with matlab * add pvsystem tests * update modelchain to work with new sapm api * update docs * add upper limit to sapm_aoi_loss * update tests for clipped aoi losses * and upper keyword argument, roll back mc tests * update whatsnew
1 parent 792ab99 commit 5218c9d

File tree

5 files changed

+417
-117
lines changed

5 files changed

+417
-117
lines changed

docs/sphinx/source/package_overview.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ to accomplish our system modeling goal:
104104
model='haydavies')
105105
temps = pvlib.pvsystem.sapm_celltemp(total_irrad['poa_global'],
106106
wind_speed, temp_air)
107-
dc = pvlib.pvsystem.sapm(module, total_irrad['poa_direct'],
108-
total_irrad['poa_diffuse'], temps['temp_cell'],
109-
am_abs, aoi)
107+
effective_irradiance = pvlib.pvsystem.sapm_effective_irradiance(
108+
module, total_irrad['poa_direct'], total_irrad['poa_diffuse'],
109+
am_abs, aoi)
110+
dc = pvlib.pvsystem.sapm(module, effective_irradiance, temps['temp_cell'])
110111
ac = pvlib.pvsystem.snlinverter(inverter, dc['v_mp'], dc['p_mp'])
111112
annual_energy = ac.sum()
112113
energies[name] = annual_energy
@@ -240,11 +241,10 @@ object to accomplish our modeling goal:
240241
aoi = localized_system.get_aoi(solar_position['apparent_zenith'],
241242
solar_position['azimuth'])
242243
airmass = localized_system.get_airmass(solar_position=solar_position)
243-
dc = localized_system.sapm(total_irrad['poa_direct'],
244-
total_irrad['poa_diffuse'],
245-
temps['temp_cell'],
246-
airmass['airmass_absolute'],
247-
aoi)
244+
effective_irradiance = localized_system.sapm_effective_irradiance(
245+
total_irrad['poa_direct'], total_irrad['poa_diffuse'],
246+
airmass['airmass_absolute'], aoi)
247+
dc = localized_system.sapm(effective_irradiance, temps['temp_cell'])
248248
ac = localized_system.snlinverter(dc['v_mp'], dc['p_mp'])
249249
annual_energy = ac.sum()
250250
energies[name] = annual_energy

docs/sphinx/source/whatsnew/v0.4.0.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
v0.4.0 (July xx, 2016)
44
-----------------------
55

6-
This is a major release from 0.3.3.
7-
We recommend that all users upgrade to this version after reviewing
8-
the API changes.
6+
This is a major release from 0.3.3. We recommend that all users upgrade
7+
to this version after reviewing the API Changes. Please see the Bug
8+
Fixes for changes that will result in slightly different modeling
9+
results.
910

1011

1112
API Changes
@@ -18,6 +19,14 @@ API Changes
1819
in addition to arrays and Series. Furthermore, these functions no
1920
longer promote scalar or array input to Series output.
2021
Also applies to atmosphere.relativeairmass. (:issue:`201`, :issue:`214`)
22+
* Updated to pvsystem.sapm to be consistent with the PVLIB MATLAB API.
23+
pvsystem.sapm now takes an effective irradiance argument instead of
24+
POA irradiances, airmass, and AOI. Implements closely related
25+
sapm_spectral_loss, sapm_aoi_loss, and sapm_effective_irradiance
26+
functions, as well as PVSystem methods. The sapm_aoi_loss function
27+
includes an optional argument to apply an upper limit to the output
28+
(output can be ~1% larger than 1 for AOI of ~30 degrees).
29+
(:issue:`198`, :issue:`205`, :issue:`218`)
2130

2231

2332
Enhancements

pvlib/modelchain.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,12 @@ def basic_chain(times, latitude, longitude,
169169
weather['wind_speed'],
170170
weather['temp_air'])
171171

172-
dc = pvsystem.sapm(module_parameters, total_irrad['poa_direct'],
173-
total_irrad['poa_diffuse'],
174-
temps['temp_cell'],
175-
airmass,
176-
aoi)
172+
effective_irradiance = pvsystem.sapm_effective_irradiance(
173+
module_parameters, total_irrad['poa_direct'],
174+
total_irrad['poa_diffuse'], airmass, aoi)
175+
176+
dc = pvsystem.sapm(module_parameters, effective_irradiance,
177+
temps['temp_cell'])
177178

178179
ac = pvsystem.snlinverter(inverter_parameters, dc['v_mp'], dc['p_mp'])
179180

@@ -365,6 +366,9 @@ def run_model(self, times, irradiance=None, weather=None):
365366
model=self.transposition_model,
366367
airmass=self.airmass['airmass_relative'])
367368

369+
self.aoi = self.system.get_aoi(self.solar_position['apparent_zenith'],
370+
self.solar_position['azimuth'])
371+
368372
if weather is None:
369373
weather = {'wind_speed': 0, 'temp_air': 20}
370374
self.weather = weather
@@ -373,14 +377,14 @@ def run_model(self, times, irradiance=None, weather=None):
373377
self.weather['wind_speed'],
374378
self.weather['temp_air'])
375379

376-
self.aoi = self.system.get_aoi(self.solar_position['apparent_zenith'],
377-
self.solar_position['azimuth'])
380+
self.effective_irradiance = self.system.sapm_effective_irradiance(
381+
self.total_irrad['poa_direct'],
382+
self.total_irrad['poa_diffuse'],
383+
self.airmass['airmass_absolute'],
384+
self.aoi)
378385

379-
self.dc = self.system.sapm(self.total_irrad['poa_direct'],
380-
self.total_irrad['poa_diffuse'],
381-
self.temps['temp_cell'],
382-
self.airmass['airmass_absolute'],
383-
self.aoi)
386+
self.dc = self.system.sapm(self.effective_irradiance,
387+
self.temps['temp_cell'])
384388

385389
self.dc = self.system.scale_voltage_current_power(self.dc)
386390

0 commit comments

Comments
 (0)