Skip to content

Commit cb8be87

Browse files
authored
Remove diffuse_fraction calculation from infinite_sheds (#2451)
* get rid of `diffuse_fraction` * adjust test * whatsnew * lint
1 parent 216386e commit cb8be87

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Enhancements
3030
:py:func:`~pvlib.iotools.get_nsrdb_psm4_full_disc`,
3131
:py:func:`~pvlib.iotools.read_nsrdb_psm4`, and
3232
:py:func:`~pvlib.iotools.parse_nsrdb_psm4`. (:issue:`2326`, :pull:`2378`)
33+
* :py:mod:`pvlib.bifacial.infinite_sheds` no longer emits "invalid value" warnings
34+
when supplying irradiance arrays with nighttime zero values. (:issue:`2450`, :pull:`2451`)
3335

3436
Documentation
3537
~~~~~~~~~~~~~

pvlib/bifacial/infinite_sheds.py

+11-16
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@
99
from pvlib.irradiance import beam_component, aoi, haydavies
1010

1111

12-
def _poa_ground_shadows(poa_ground, f_gnd_beam, df, vf_gnd_sky):
12+
def _poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam, vf_gnd_sky):
1313
"""
1414
Reduce ground-reflected irradiance to the tilted plane (poa_ground) to
1515
account for shadows on the ground.
1616
1717
Parameters
1818
----------
19-
poa_ground : numeric
20-
Ground reflected irradiance on the tilted surface, assuming full GHI
21-
illumination on all of the ground. [W/m^2]
19+
ghi : numeric
20+
Global horizontal irradiance, with no adjustments. [W/m^2]
21+
dhi : numeric
22+
Diffuse horizontal irradiance, with no adjustments. [W/m^2]
23+
albedo : numeric
24+
Ground albedo, the ratio of reflected to incident irradiance of the
25+
ground surface. [W/m^2]
2226
f_gnd_beam : numeric
2327
Fraction of the distance between rows that is illuminated (unshaded).
2428
[unitless]
25-
df : numeric
26-
Diffuse fraction, the ratio of DHI to GHI. [unitless]
2729
vf_gnd_sky : numeric
2830
View factor from the ground to the sky, integrated along the distance
2931
between rows. [unitless]
@@ -35,7 +37,7 @@ def _poa_ground_shadows(poa_ground, f_gnd_beam, df, vf_gnd_sky):
3537
ground. [W/m^2]
3638
3739
"""
38-
return poa_ground * (f_gnd_beam*(1 - df) + df*vf_gnd_sky)
40+
return albedo * (f_gnd_beam * (ghi - dhi) + vf_gnd_sky * dhi)
3941

4042

4143
def _poa_sky_diffuse_pv(dhi, gcr, surface_tilt):
@@ -339,18 +341,11 @@ def get_irradiance_poa(surface_tilt, surface_azimuth, solar_zenith,
339341
# and restricted views
340342
# this is a deviation from [1], because the row to ground view factor
341343
# is accounted for in a different manner
342-
ground_diffuse = ghi * albedo
343-
344-
# diffuse fraction
345-
diffuse_fraction = np.clip(dhi / ghi, 0., 1.)
346-
# make diffuse fraction 0 when ghi is small
347-
diffuse_fraction = np.where(ghi < 0.0001, 0., diffuse_fraction)
348-
349344
# Reduce ground-reflected irradiance because other rows in the array
350345
# block irradiance from reaching the ground.
351346
# [2], Eq. 9
352-
ground_diffuse = _poa_ground_shadows(
353-
ground_diffuse, f_gnd_beam, diffuse_fraction, vf_gnd_sky)
347+
ground_diffuse = _poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam,
348+
vf_gnd_sky)
354349

355350
# Ground-reflected irradiance on the row surface accounting for
356351
# the view to the ground. This deviates from [1], Eq. 10, 11 and

tests/bifacial/test_infinite_sheds.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,20 @@ def test_system():
4242

4343

4444
def test__poa_ground_shadows():
45-
poa_ground, f_gnd_beam, df, vf_gnd_sky = (300., 0.5, 0.5, 0.2)
46-
result = infinite_sheds._poa_ground_shadows(
47-
poa_ground, f_gnd_beam, df, vf_gnd_sky)
48-
expected = 300. * (0.5 * 0.5 + 0.5 * 0.2)
45+
ghi, dhi, albedo, f_gnd_beam, vf_gnd_sky = (300., 100, 0.3, 0.5, 0.2)
46+
result = infinite_sheds._poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam,
47+
vf_gnd_sky)
48+
49+
expected = 0.3 * (200 * 0.5 + 100 * 0.2)
4950
assert np.isclose(result, expected)
5051
# vector inputs
51-
poa_ground = np.array([300., 300.])
52-
f_gnd_beam = np.array([0.5, 0.5])
53-
df = np.array([0.5, 0.])
54-
vf_gnd_sky = np.array([0.2, 0.2])
55-
result = infinite_sheds._poa_ground_shadows(
56-
poa_ground, f_gnd_beam, df, vf_gnd_sky)
57-
expected_vec = np.array([expected, 300. * 0.5])
52+
ghi = np.array([ghi, ghi])
53+
dhi = np.array([dhi, 0])
54+
f_gnd_beam = np.array([f_gnd_beam, f_gnd_beam])
55+
vf_gnd_sky = np.array([vf_gnd_sky, vf_gnd_sky])
56+
result = infinite_sheds._poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam,
57+
vf_gnd_sky)
58+
expected_vec = np.array([expected, 300. * 0.5 * 0.3])
5859
assert np.allclose(result, expected_vec)
5960

6061

0 commit comments

Comments
 (0)