From 16556c554ad24548b3aa184bb25001d251cc5d8e Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 30 Apr 2025 13:20:32 -0400 Subject: [PATCH 1/4] get rid of `diffuse_fraction` --- pvlib/bifacial/infinite_sheds.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/pvlib/bifacial/infinite_sheds.py b/pvlib/bifacial/infinite_sheds.py index c1a5d91468..2418fd71bb 100644 --- a/pvlib/bifacial/infinite_sheds.py +++ b/pvlib/bifacial/infinite_sheds.py @@ -9,21 +9,23 @@ from pvlib.irradiance import beam_component, aoi, haydavies -def _poa_ground_shadows(poa_ground, f_gnd_beam, df, vf_gnd_sky): +def _poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam, vf_gnd_sky): """ Reduce ground-reflected irradiance to the tilted plane (poa_ground) to account for shadows on the ground. Parameters ---------- - poa_ground : numeric - Ground reflected irradiance on the tilted surface, assuming full GHI - illumination on all of the ground. [W/m^2] + ghi : numeric + Global horizontal irradiance, with no adjustments. [W/m^2] + dhi : numeric + Diffuse horizontal irradiance, with no adjustments. [W/m^2] + albedo : numeric + Ground albedo, the ratio of reflected to incident irradiance of the + ground surface. [W/m^2] f_gnd_beam : numeric Fraction of the distance between rows that is illuminated (unshaded). [unitless] - df : numeric - Diffuse fraction, the ratio of DHI to GHI. [unitless] vf_gnd_sky : numeric View factor from the ground to the sky, integrated along the distance between rows. [unitless] @@ -35,7 +37,7 @@ def _poa_ground_shadows(poa_ground, f_gnd_beam, df, vf_gnd_sky): ground. [W/m^2] """ - return poa_ground * (f_gnd_beam*(1 - df) + df*vf_gnd_sky) + return albedo * (f_gnd_beam * (ghi - dhi) + vf_gnd_sky * dhi) def _poa_sky_diffuse_pv(dhi, gcr, surface_tilt): @@ -339,18 +341,11 @@ def get_irradiance_poa(surface_tilt, surface_azimuth, solar_zenith, # and restricted views # this is a deviation from [1], because the row to ground view factor # is accounted for in a different manner - ground_diffuse = ghi * albedo - - # diffuse fraction - diffuse_fraction = np.clip(dhi / ghi, 0., 1.) - # make diffuse fraction 0 when ghi is small - diffuse_fraction = np.where(ghi < 0.0001, 0., diffuse_fraction) - # Reduce ground-reflected irradiance because other rows in the array # block irradiance from reaching the ground. # [2], Eq. 9 - ground_diffuse = _poa_ground_shadows( - ground_diffuse, f_gnd_beam, diffuse_fraction, vf_gnd_sky) + ground_diffuse = _poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam, + vf_gnd_sky) # Ground-reflected irradiance on the row surface accounting for # the view to the ground. This deviates from [1], Eq. 10, 11 and From ae9d4365109eeaed504ce174a95afbf655d8583e Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 30 Apr 2025 13:26:50 -0400 Subject: [PATCH 2/4] adjust test --- tests/bifacial/test_infinite_sheds.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/bifacial/test_infinite_sheds.py b/tests/bifacial/test_infinite_sheds.py index b689b419d1..819a8b4926 100644 --- a/tests/bifacial/test_infinite_sheds.py +++ b/tests/bifacial/test_infinite_sheds.py @@ -42,19 +42,20 @@ def test_system(): def test__poa_ground_shadows(): - poa_ground, f_gnd_beam, df, vf_gnd_sky = (300., 0.5, 0.5, 0.2) - result = infinite_sheds._poa_ground_shadows( - poa_ground, f_gnd_beam, df, vf_gnd_sky) - expected = 300. * (0.5 * 0.5 + 0.5 * 0.2) + ghi, dhi, albedo, f_gnd_beam, vf_gnd_sky = (300., 100, 0.3, 0.5, 0.2) + result = infinite_sheds._poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam, + vf_gnd_sky) + + expected = 0.3 * (200 * 0.5 + 100 * 0.2) assert np.isclose(result, expected) # vector inputs - poa_ground = np.array([300., 300.]) - f_gnd_beam = np.array([0.5, 0.5]) - df = np.array([0.5, 0.]) - vf_gnd_sky = np.array([0.2, 0.2]) - result = infinite_sheds._poa_ground_shadows( - poa_ground, f_gnd_beam, df, vf_gnd_sky) - expected_vec = np.array([expected, 300. * 0.5]) + ghi = np.array([ghi, ghi]) + dhi = np.array([dhi, 0]) + f_gnd_beam = np.array([f_gnd_beam, f_gnd_beam]) + vf_gnd_sky = np.array([vf_gnd_sky, vf_gnd_sky]) + result = infinite_sheds._poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam, + vf_gnd_sky) + expected_vec = np.array([expected, 300. * 0.5 * 0.3]) assert np.allclose(result, expected_vec) From a74c8352b932cce8cda793f5b85f410b466383ad Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 30 Apr 2025 13:30:42 -0400 Subject: [PATCH 3/4] whatsnew --- docs/sphinx/source/whatsnew/v0.12.1.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.12.1.rst b/docs/sphinx/source/whatsnew/v0.12.1.rst index 88cdfc6848..37c458cad2 100644 --- a/docs/sphinx/source/whatsnew/v0.12.1.rst +++ b/docs/sphinx/source/whatsnew/v0.12.1.rst @@ -30,6 +30,8 @@ Enhancements :py:func:`~pvlib.iotools.get_nsrdb_psm4_full_disc`, :py:func:`~pvlib.iotools.read_nsrdb_psm4`, and :py:func:`~pvlib.iotools.parse_nsrdb_psm4`. (:issue:`2326`, :pull:`2378`) +* :py:mod:`pvlib.bifacial.infinite_sheds` no longer emits "invalid value" warnings + when supplying irradiance arrays with nighttime zero values. (:issue:`2450`, :pull:`2451`) Documentation ~~~~~~~~~~~~~ From 7010c0f8238f8839363f20826b11d73df5326e32 Mon Sep 17 00:00:00 2001 From: Kevin Anderson Date: Wed, 30 Apr 2025 13:41:12 -0400 Subject: [PATCH 4/4] lint --- tests/bifacial/test_infinite_sheds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bifacial/test_infinite_sheds.py b/tests/bifacial/test_infinite_sheds.py index 819a8b4926..5459b9d575 100644 --- a/tests/bifacial/test_infinite_sheds.py +++ b/tests/bifacial/test_infinite_sheds.py @@ -45,7 +45,7 @@ def test__poa_ground_shadows(): ghi, dhi, albedo, f_gnd_beam, vf_gnd_sky = (300., 100, 0.3, 0.5, 0.2) result = infinite_sheds._poa_ground_shadows(ghi, dhi, albedo, f_gnd_beam, vf_gnd_sky) - + expected = 0.3 * (200 * 0.5 + 100 * 0.2) assert np.isclose(result, expected) # vector inputs