Skip to content

refactor sapm to be consistent with matlab #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/sphinx/source/package_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ to accomplish our system modeling goal:
model='haydavies')
temps = pvlib.pvsystem.sapm_celltemp(total_irrad['poa_global'],
wind_speed, temp_air)
dc = pvlib.pvsystem.sapm(module, total_irrad['poa_direct'],
total_irrad['poa_diffuse'], temps['temp_cell'],
am_abs, aoi)
effective_irradiance = pvlib.pvsystem.sapm_effective_irradiance(
module, total_irrad['poa_direct'], total_irrad['poa_diffuse'],
am_abs, aoi)
dc = pvlib.pvsystem.sapm(module, effective_irradiance, temps['temp_cell'])
ac = pvlib.pvsystem.snlinverter(inverter, dc['v_mp'], dc['p_mp'])
annual_energy = ac.sum()
energies[name] = annual_energy
Expand Down Expand Up @@ -240,11 +241,10 @@ object to accomplish our modeling goal:
aoi = localized_system.get_aoi(solar_position['apparent_zenith'],
solar_position['azimuth'])
airmass = localized_system.get_airmass(solar_position=solar_position)
dc = localized_system.sapm(total_irrad['poa_direct'],
total_irrad['poa_diffuse'],
temps['temp_cell'],
airmass['airmass_absolute'],
aoi)
effective_irradiance = localized_system.sapm_effective_irradiance(
total_irrad['poa_direct'], total_irrad['poa_diffuse'],
airmass['airmass_absolute'], aoi)
dc = localized_system.sapm(effective_irradiance, temps['temp_cell'])
ac = localized_system.snlinverter(dc['v_mp'], dc['p_mp'])
annual_energy = ac.sum()
energies[name] = annual_energy
Expand Down
15 changes: 12 additions & 3 deletions docs/sphinx/source/whatsnew/v0.4.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
v0.4.0 (July xx, 2016)
-----------------------

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


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


Enhancements
Expand Down
28 changes: 16 additions & 12 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ def basic_chain(times, latitude, longitude,
weather['wind_speed'],
weather['temp_air'])

dc = pvsystem.sapm(module_parameters, total_irrad['poa_direct'],
total_irrad['poa_diffuse'],
temps['temp_cell'],
airmass,
aoi)
effective_irradiance = pvsystem.sapm_effective_irradiance(
module_parameters, total_irrad['poa_direct'],
total_irrad['poa_diffuse'], airmass, aoi)

dc = pvsystem.sapm(module_parameters, effective_irradiance,
temps['temp_cell'])

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

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

self.aoi = self.system.get_aoi(self.solar_position['apparent_zenith'],
self.solar_position['azimuth'])

if weather is None:
weather = {'wind_speed': 0, 'temp_air': 20}
self.weather = weather
Expand All @@ -373,14 +377,14 @@ def run_model(self, times, irradiance=None, weather=None):
self.weather['wind_speed'],
self.weather['temp_air'])

self.aoi = self.system.get_aoi(self.solar_position['apparent_zenith'],
self.solar_position['azimuth'])
self.effective_irradiance = self.system.sapm_effective_irradiance(
self.total_irrad['poa_direct'],
self.total_irrad['poa_diffuse'],
self.airmass['airmass_absolute'],
self.aoi)

self.dc = self.system.sapm(self.total_irrad['poa_direct'],
self.total_irrad['poa_diffuse'],
self.temps['temp_cell'],
self.airmass['airmass_absolute'],
self.aoi)
self.dc = self.system.sapm(self.effective_irradiance,
self.temps['temp_cell'])

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

Expand Down
Loading