8000 add support for zero gcr in bifacial.infinite_sheds and shading.maski… · ooprathamm/pvlib-python@eefc35c · GitHub
[go: up one dir, main page]

Skip to content

Commit eefc35c

Browse files
kdebrabkandersolar
andauthored
add support for zero gcr in bifacial.infinite_sheds and shading.masking_angle (pvlib#1589)
* add support for zero gcr * update whatsnew Co-authored-by: Kevin Anderson <kevin.anderson@nrel.gov>
1 parent bd86597 commit eefc35c

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Enhancements
2020
Bug fixes
2121
~~~~~~~~~
2222

23+
* Fixed bug in :py:func:`pvlib.shading.masking_angle` and :py:func:`pvlib.bifacial.infinite_sheds._ground_angle`
24+
where zero ``gcr`` input caused a ZeroDivisionError (:issue:`1576`, :pull:`1589`)
2325

2426
Testing
2527
~~~~~~~
@@ -44,5 +46,5 @@ Contributors
4446
* Christian Orner (:ghuser:`chrisorner`)
4547
* Saurabh Aneja (:ghuser:`spaneja`)
4648
* Marcus Boumans (:ghuser:`bowie2211`)
49+
* Karel De Brabandere (:ghuser:`kdebrab`)
4750
* Naman Priyadarshi (:ghuser:`Naman-Priyadarshi`)
48-

pvlib/bifacial/infinite_sheds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def _ground_angle(x, surface_tilt, gcr):
216< 10000 code>216
# : \ v *-.\
217217
# : \<-----P---->\
218218

219-
x1 = x * sind(surface_tilt)
220-
x2 = (x * cosd(surface_tilt) + 1 / gcr)
219+
x1 = gcr * x * sind(surface_tilt)
220+
x2 = gcr * x * cosd(surface_tilt) + 1
221221
psi = np.arctan2(x1, x2) # do this first because it handles 0 / 0
222222
return np.rad2deg(psi)
223223

pvlib/shading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def masking_angle(surface_tilt, gcr, slant_height):
5252
# The original equation (8 in [1]) requires pitch and collector width,
5353
# but it's easy to non-dimensionalize it to make it a function of GCR
5454
# by factoring out B from the argument to arctan.
55-
numerator = (1 - slant_height) * sind(surface_tilt)
56-
denominator = 1/gcr - (1 - slant_height) * cosd(surface_tilt)
55+
numerator = gcr * (1 - slant_height) * sind(surface_tilt)
56+
denominator = 1 - gcr * (1 - slant_height) * cosd(surface_tilt)
5757
phi = np.arctan(numerator / denominator)
5858
return np.degrees(phi)
5959

pvlib/tests/bifacial/test_infinite_sheds.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ def test__ground_angle(test_system):
106106
assert np.allclose(angles, expected_angles)
107107

108108

109+
def test__ground_angle_zero_gcr():
110+
surface_tilt = 30.0
111+
x = np.array([0.0, 0.5, 1.0])
112+
angles = infinite_sheds._ground_angle(x, surface_tilt, 0)
113+
expected_angles = np.array([0, 0, 0])
114+
assert np.allclose(angles, expected_angles)
115+
116+
109117
def test__vf_row_ground(test_system):
110118
ts, _, _ = test_system
111119
x = np.array([0., 0.5, 1.0])

pvlib/tests/test_shading.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ def test_masking_angle_scalar(surface_tilt, masking_angle):
4545
assert np.isclose(masking_angle_actual, angle)
4646

4747

48+
def test_masking_angle_zero_gcr(surface_tilt):
49+
# scalar inputs and outputs, including zero
50+
for tilt in surface_tilt:
51+
masking_angle_actual = shading.masking_angle(tilt, 0, 0.25)
52+
assert np.isclose(masking_angle_actual, 0)
53+
54+
4855
def test_masking_angle_passias_series(surface_tilt, average_masking_angle):
4956
# pandas series inputs and outputs
5057
masking_angle_actual = shading.masking_angle_passias(surface_tilt, 0.5)

0 commit comments

Comments
 (0)
2906
0