Skip to content
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

Townsend snow (building on #1251) #1468

Merged
merged 29 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0b736d4
first experimental commit
Jun 25, 2021
3f2c40d
Added numpy array support
Jul 2, 2021
974d516
changed var names
Jul 16, 2021
655fa79
changed townsend_Se to private
Jul 20, 2021
c0c8b4d
removed snow.loss_townsend in api.rst
abhisheksparikh Mar 17, 2022
f0e1f3a
Merge branch 'master' of https://github.com/abhisheksparikh/pvlib-pyt…
abhisheksparikh Mar 17, 2022
78716f7
added loss_townsend description in effects_on_pv_system_output.rst
abhisheksparikh Mar 17, 2022
5e06a40
fixed stickler checks
abhisheksparikh Mar 17, 2022
a5c5315
removed rounding of loss and changed to 0-1 range
abhisheksparikh Mar 18, 2022
f79e906
Merge branch 'master' into townsend_snow
abhisheksparikh Mar 18, 2022
f7ba1ad
Merge branch 'master' of https://github.com/pvlib/pvlib-python into t…
reepoi May 26, 2022
c2d6d4f
implementing changes suggested in PR #1251
reepoi May 26, 2022
68c85f7
removing new line
reepoi May 26, 2022
e5118ef
removing new line
reepoi May 26, 2022
c253f59
remove new line
reepoi Jun 7, 2022
e2c1f76
Se to effective_snow
reepoi Jun 7, 2022
4783556
adding PR number to whatsnew
reepoi Jun 7, 2022
588115e
address stickler line too long
reepoi Jun 7, 2022
36ae264
remove links and noqa E501, and fix long lines
reepoi Jun 13, 2022
d9dad34
converting to metric system
reepoi Jun 13, 2022
1d5eb88
poa_global from kWh/m2 to Wh/m2
reepoi Jun 13, 2022
bbe5bc3
changing returned loss from kWh to Wh
reepoi Jun 13, 2022
b3ab5aa
fixing capacity loss calculation units to keep correct C1 value
reepoi Jun 14, 2022
cff9345
Merge branch 'master' into townsend_snow_loss
reepoi Jun 16, 2022
b759bcf
convert relative humidity from percent to fraction
reepoi Jun 20, 2022
febe4a2
Merge branch 'townsend_snow_loss' of https://github.com/reepoi/pvlib-…
reepoi Jun 20, 2022
f46fc00
neatening docstrings and adjusting variable names
reepoi Jun 22, 2022
03e7dcf
Merge branch 'master' of github.com:reepoi/pvlib-python into townsend…
reepoi Sep 11, 2022
0d1542f
changing eqn 3 percentage loss to fractional loss and adding comment …
reepoi Sep 11, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Snow
snow.coverage_nrel
snow.fully_covered_nrel
snow.dc_loss_nrel
snow.loss_townsend

Soiling
-------
Expand Down
5 changes: 4 additions & 1 deletion docs/sphinx/source/whatsnew/v0.9.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Deprecations

Enhancements
~~~~~~~~~~~~
* Added Townsend-Powers monthly snow loss model: :py:func:`pvlib.snow.loss_townsend`
(:issue:`1246`, :pull:`1251`, :pull:`1468`)

Bug fixes
~~~~~~~~~
Expand All @@ -19,7 +21,6 @@ Bug fixes
rise/set/transit times for the wrong day in recent versions of ``ephem``
(:issue:`1449`, :pull:`1448`)


Testing
~~~~~~~
* Switched CI testing provider from Azure to GitHub Actions (:pull:`1306`)
Expand All @@ -44,3 +45,5 @@ Contributors
* Chencheng Luo (:ghuser:`roger-lcc`)
* Prajwal Borkar (:ghuser:`PrajwalBorkar`)
* Kevin Anderson (:ghuser:`kanderso-nrel`)
* Abhishek Parikh (:ghuser:`abhisheksparikh`)
* Taos Transue (:ghuser:`reepoi`)
133 changes: 132 additions & 1 deletion pvlib/snow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
import pandas as pd
from pvlib.tools import sind
from pvlib.tools import sind, cosd, tand


def _time_delta_in_hours(times):
Expand Down Expand Up @@ -185,3 +185,134 @@ def dc_loss_nrel(snow_coverage, num_strings):
Available at https://www.nrel.gov/docs/fy18osti/67399.pdf
'''
return np.ceil(snow_coverage * num_strings) / num_strings


def _townsend_effective_snow(snow_total, snow_events):
'''
Calculates effective snow using the total snowfall received each month and
the number of snowfall events each month.

Parameters
----------
snow_total : array-like
Snow received each month. Referred to as S in [1]_. [cm]

snow_events : array-like
Number of snowfall events each month. Referred to as N in [1]_. [-]

Returns
-------
effective_snowfall : array-like
Effective snowfall as defined in the Townsend model. [cm]

References
----------
.. [1] Townsend, Tim & Powers, Loren. (2011). Photovoltaics and snow: An
update from two winters of measurements in the SIERRA. 37th IEEE
Photovoltaic Specialists Conference, Seattle, WA, USA.
:doi:`10.1109/PVSC.2011.6186627`
'''
snow_events_no_zeros = np.maximum(snow_events, 1)
effective_snow = 0.5 * snow_total * (1 + 1 / snow_events_no_zeros)
return np.where(snow_events > 0, effective_snow, 0)


def loss_townsend(snow_total, snow_events, surface_tilt, relative_humidity,
temp_air, poa_global, slant_height, lower_edge_height,
angle_of_repose=40):
'''
Calculates monthly snow loss based on the Townsend monthly snow loss
model [1]_.

Parameters
----------
snow_total : array-like
Snow received each month. Referred to as S in [1]_. [cm]

snow_events : array-like
Number of snowfall events each month. Referred to as N in [1]_. [-]

surface_tilt : float
Tilt angle of the array. [deg]

relative_humidity : array-like
Monthly average relative humidity. [%]

temp_air : array-like
Monthly average ambient temperature. [C]

poa_global : array-like
Monthly plane of array insolation. [Wh/m2]

slant_height : float
Row length in the slanted plane of array dimension. [m]

lower_edge_height : float
Distance from array lower edge to the ground. [m]

angle_of_repose : float, default 40
Piled snow angle, assumed to stabilize at 40°, the midpoint of
25°-55° avalanching slope angles. [deg]

Returns
-------
loss : array-like
Monthly average DC capacity loss fraction due to snow coverage.

Notes
-----
This model has not been validated for tracking arrays; however, for
tracking arrays [1]_ suggests using the maximum rotation angle in place
of ``surface_tilt``.

References
----------
.. [1] Townsend, Tim & Powers, Loren. (2011). Photovoltaics and snow: An
update from two winters of measurements in the SIERRA. 37th IEEE
Photovoltaic Specialists Conference, Seattle, WA, USA.
:doi:`10.1109/PVSC.2011.6186627`
'''

C1 = 5.7e04
C2 = 0.51

snow_total_prev = np.roll(snow_total, 1)
snow_events_prev = np.roll(snow_events, 1)

effective_snow = _townsend_effective_snow(snow_total, snow_events)
effective_snow_prev = _townsend_effective_snow(
snow_total_prev,
snow_events_prev
)
effective_snow_weighted = (
1 / 3 * effective_snow_prev
+ 2 / 3 * effective_snow
)
effective_snow_weighted_m = effective_snow_weighted / 100

lower_edge_height_clipped = np.maximum(lower_edge_height, 0.01)
gamma = (
slant_height
* effective_snow_weighted_m
* cosd(surface_tilt)
/ (lower_edge_height_clipped**2 - effective_snow_weighted_m**2)
* 2
* tand(angle_of_repose)
)

ground_interference_term = 1 - C2 * np.exp(-gamma)
relative_humidity_fraction = relative_humidity / 100
temp_air_kelvin = temp_air + 273.15
effective_snow_weighted_in = effective_snow_weighted / 2.54
poa_global_kWh = poa_global / 1000
loss_percentage = (
C1
* effective_snow_weighted_in
* cosd(surface_tilt)**2
* ground_interference_term
* relative_humidity_fraction
/ temp_air_kelvin**2
/ poa_global_kWh**0.67
)

return loss_percentage / 100
33 changes: 33 additions & 0 deletions pvlib/tests/test_snow.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,36 @@ def test_dc_loss_nrel():
expected = pd.Series([1, 1, .5, .625, .25, .5, 0])
actual = snow.dc_loss_nrel(snow_coverage, num_strings)
assert_series_equal(expected, actual)


def test__townsend_effective_snow():
snow_total = np.array([25.4, 25.4, 12.7, 2.54, 0, 0, 0, 0, 0, 0, 12.7,
25.4])
snow_events = np.array([2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 2, 3])
expected = np.array([19.05, 19.05, 12.7, 0, 0, 0, 0, 0, 0, 0, 9.525,
254 / 15])
actual = snow._townsend_effective_snow(snow_total, snow_events)
np.testing.assert_allclose(expected, actual, rtol=1e-07)


def test_loss_townsend():
snow_total = np.array([25.4, 25.4, 12.7, 2.54, 0, 0, 0, 0, 0, 0, 12.7,
25.4])
snow_events = np.array([2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 2, 3])
surface_tilt = 20
relative_humidity = np.array([80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
80, 80])
temp_air = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
poa_global = np.array([350000, 350000, 350000, 350000, 350000, 350000,
350000, 350000, 350000, 350000, 350000, 350000])
angle_of_repose = 40
slant_height = 2.54
lower_edge_height = 0.254
expected = np.array([0.0007696253, 0.0007992262, 0.0006216201,
0.0001715392, 0, 0, 0, 0, 0, 0, 0.0002643821,
0.0006068194])
actual = snow.loss_townsend(snow_total, snow_events, surface_tilt,
relative_humidity, temp_air,
poa_global, slant_height,
lower_edge_height, angle_of_repose)
np.testing.assert_allclose(expected, actual, rtol=1e-05)