From c90b7d0263c94d526f4c70613a75c16421e7897b Mon Sep 17 00:00:00 2001 From: ejmiller2 Date: Tue, 22 Mar 2016 18:09:53 -0700 Subject: [PATCH 01/10] Resolve #140 snlinverter night tare power issue Fixing #140 by changing the start power (Pso) comparison to use the DC input power (p_dc) instead of the calculated AC power (ac_power). --- pvlib/pvsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/pvsystem.py b/pvlib/pvsystem.py index bc158b8652..3c9eb03aed 100644 --- a/pvlib/pvsystem.py +++ b/pvlib/pvsystem.py @@ -1662,7 +1662,7 @@ def snlinverter(inverter, v_dc, p_dc): ac_power = (Paco/(A-B) - C*(A-B)) * (p_dc-B) + C*((p_dc-B)**2) ac_power[ac_power > Paco] = Paco - ac_power[ac_power < Pso] = - 1.0 * abs(Pnt) + ac_power[p_dc < Pso] = - 1.0 * abs(Pnt) if len(ac_power) == 1: ac_power = ac_power.ix[0] From e5d591d2e674533b7c8cecc7007dd0074cb21ab1 Mon Sep 17 00:00:00 2001 From: Ed Miller Date: Wed, 23 Mar 2016 10:20:54 -0700 Subject: [PATCH 02/10] Test for Pnt error with microinverter Testing for issue #140. --- pvlib/test/test_pvsystem.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pvlib/test/test_pvsystem.py b/pvlib/test/test_pvsystem.py index f2b4974a47..7253dfcbbb 100644 --- a/pvlib/test/test_pvsystem.py +++ b/pvlib/test/test_pvsystem.py @@ -384,6 +384,17 @@ def test_snlinverter_float(): assert_almost_equals(pacs, 132.004278, 5) +def test_snlinverter_Pnt_micro(): + inverters = sam_data['cecinverter'] + testinv = 'Enphase_Energy__M250_60_2LL_S2x___ZC____NA__208V_208V__CEC_2013_' + vdcs = pd.Series(np.linspace(0,50,3)) + idcs = pd.Series(np.linspace(0,11,3)) + pdcs = idcs * vdcs + + pacs = pvsystem.snlinverter(inverters[testinv], vdcs, pdcs) + assert_series_equal(pacs, pd.Series([-0.043000, 132.545914746, 240.000000])) + + def test_PVSystem_creation(): pv_system = pvsystem.PVSystem(module='blah', inverter='blarg') From 1371b4dc196c3f28971dc90380bb8443f6da4764 Mon Sep 17 00:00:00 2001 From: Ed Miller Date: Wed, 23 Mar 2016 10:26:37 -0700 Subject: [PATCH 03/10] Update v0.3.1.txt Added note and contribution for fix to issue #140. --- docs/sphinx/source/whatsnew/v0.3.1.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/sphinx/source/whatsnew/v0.3.1.txt b/docs/sphinx/source/whatsnew/v0.3.1.txt index d2b91c2e77..2806373ad3 100644 --- a/docs/sphinx/source/whatsnew/v0.3.1.txt +++ b/docs/sphinx/source/whatsnew/v0.3.1.txt @@ -15,8 +15,10 @@ Enhancements Bug fixes ~~~~~~~~~ +* Fixes snlinverter Pnt problem (:issue:`140`) Contributors ~~~~~~~~~~~~ +* ejmiller2 From edc41775220b65825bbb21750121ad149920e3c4 Mon Sep 17 00:00:00 2001 From: Ed Miller Date: Thu, 24 Mar 2016 10:26:46 -0700 Subject: [PATCH 04/10] Update night tare issue description. Improved the night tare issue description. --- docs/sphinx/source/whatsnew/v0.3.1.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.3.1.txt b/docs/sphinx/source/whatsnew/v0.3.1.txt index 2806373ad3..fd4a47133f 100644 --- a/docs/sphinx/source/whatsnew/v0.3.1.txt +++ b/docs/sphinx/source/whatsnew/v0.3.1.txt @@ -15,7 +15,7 @@ Enhancements Bug fixes ~~~~~~~~~ -* Fixes snlinverter Pnt problem (:issue:`140`) +* Fixes night tare issue in snlinverter. When the DC input power (p_dc) to an inverter is below the inversion startup power (Ps0), the model should set the AC output (ac_power) to the night tare value (Pnt). The night tare power indicates the power consumed by the inverter to sense PV array voltage. The model was erroneously comparing Ps0 with the AC output power (ac_power), rather than the DC input power (p_dc). Contributors From 2a9d4cc5c01036b5a559ac1f67e60c88ef8c9879 Mon Sep 17 00:00:00 2001 From: Ed Miller Date: Thu, 24 Mar 2016 10:42:02 -0700 Subject: [PATCH 05/10] Reformatted bug fix description. Added carriage returns for improved readability. --- docs/sphinx/source/whatsnew/v0.3.1.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.3.1.txt b/docs/sphinx/source/whatsnew/v0.3.1.txt index fd4a47133f..f375781fef 100644 --- a/docs/sphinx/source/whatsnew/v0.3.1.txt +++ b/docs/sphinx/source/whatsnew/v0.3.1.txt @@ -15,7 +15,12 @@ Enhancements Bug fixes ~~~~~~~~~ -* Fixes night tare issue in snlinverter. When the DC input power (p_dc) to an inverter is below the inversion startup power (Ps0), the model should set the AC output (ac_power) to the night tare value (Pnt). The night tare power indicates the power consumed by the inverter to sense PV array voltage. The model was erroneously comparing Ps0 with the AC output power (ac_power), rather than the DC input power (p_dc). +* Fixes night tare issue in snlinverter. When the DC input power (p_dc) + to an inverter is below the inversion startup power (Ps0), the model + should set the AC output (ac_power) to the night tare value (Pnt). + The night tare power indicates the power consumed by the inverter to + sense PV array voltage. The model was erroneously comparing Ps0 with + the AC output power (ac_power), rather than the DC input power (p_dc). Contributors From 7254a7f9ee283a726424373d626d3e25c8a30782 Mon Sep 17 00:00:00 2001 From: mayudong Date: Mon, 11 Apr 2016 17:53:11 -0700 Subject: [PATCH 06/10] fixed the calculation of rotated panel azimuth calculations so that the results are consistent with PVsyst. Also the tests are updated to cover that issue --- pvlib/test/test_tracking.py | 23 +++++++++++++++++++---- pvlib/tracking.py | 3 ++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pvlib/test/test_tracking.py b/pvlib/test/test_tracking.py index 488edf65a6..b691e00233 100644 --- a/pvlib/test/test_tracking.py +++ b/pvlib/test/test_tracking.py @@ -107,7 +107,7 @@ def test_axis_tilt(): max_angle=90, backtrack=True, gcr=2.0/7.0) - expect = pd.DataFrame({'aoi': 7.286245, 'surface_azimuth': 37.3427, + expect = pd.DataFrame({'aoi': 7.286245, 'surface_azimuth': 142.65730, 'surface_tilt': 35.98741, 'tracker_theta': -20.88121}, index=[0], dtype=np.float64) @@ -118,7 +118,7 @@ def test_axis_tilt(): max_angle=90, backtrack=True, gcr=2.0/7.0) - expect = pd.DataFrame({'aoi': 47.6632, 'surface_azimuth': 129.0303, + expect = pd.DataFrame({'aoi': 47.6632, 'surface_azimuth': 50.96969, 'surface_tilt': 42.5152, 'tracker_theta': 31.6655}, index=[0], dtype=np.float64) @@ -188,12 +188,27 @@ def test_SingleAxisTracker_tracking(): tracker_data = system.singleaxis(apparent_zenith, apparent_azimuth) - expect = pd.DataFrame({'aoi': 7.286245, 'surface_azimuth': 37.3427, + expect = pd.DataFrame({'aoi': 7.286245, 'surface_azimuth': 142.65730 , 'surface_tilt': 35.98741, 'tracker_theta': -20.88121}, index=[0], dtype=np.float64) assert_frame_equal(expect, tracker_data) + ### results calculated using PVsyst + system.backtrack = False + system.max_angle = 60. + system.axis_tilt = 20. + system.axis_azimuth = 200. + apparent_azimuth = pd.Series([180+7.1609]) + apparent_zenith = pd.Series([90-27.315]) + tracker_data = system.singleaxis(apparent_zenith, apparent_azimuth) + expect = pd.DataFrame({'aoi': 41.07852 , 'surface_azimuth': 180-18.432 , + 'surface_tilt': 24.92122 , 'tracker_theta': -15.18391}, + index=[0], dtype=np.float64) + + assert_frame_equal(expect, tracker_data) + + def test_LocalizedSingleAxisTracker_creation(): localized_system = tracking.LocalizedSingleAxisTracker(latitude=32, @@ -254,7 +269,7 @@ def test_get_irradiance(): surface_azimuth=tracker_data['surface_azimuth']) expected = pd.DataFrame(data=np.array( - [[ 142.71652464, 87.50125991, 55.21526473, 44.68768982, + [[ 961.80070, 815.94490, 145.85580, 135.32820, 10.52757492], [ nan, nan, nan, nan, nan]]), diff --git a/pvlib/tracking.py b/pvlib/tracking.py index 0b37224a60..445768a25f 100644 --- a/pvlib/tracking.py +++ b/pvlib/tracking.py @@ -485,7 +485,8 @@ def singleaxis(apparent_zenith, apparent_azimuth, # 4. Rotate 0 reference from panel's x axis to it's y axis and # then back to North. - surface_azimuth += 90 + axis_azimuth + # surface_azimuth += 90+ axis_azimuth + surface_azimuth = 90-surface_azimuth + axis_azimuth # 5. Map azimuth into [0,360) domain. surface_azimuth[surface_azimuth<0] += 360 From 50eb415bbde9e0f363e625fe604f79cc8ea81cc5 Mon Sep 17 00:00:00 2001 From: mayudong Date: Mon, 11 Apr 2016 17:56:34 -0700 Subject: [PATCH 07/10] fixed the calculation of rotated panel azimuth calculations so that the results are consistent with PVsyst. Also the tests are updated to cover that issue --- pvlib/test/test_tracking.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pvlib/test/test_tracking.py b/pvlib/test/test_tracking.py index b691e00233..c0711bc315 100644 --- a/pvlib/test/test_tracking.py +++ b/pvlib/test/test_tracking.py @@ -195,12 +195,16 @@ def test_SingleAxisTracker_tracking(): assert_frame_equal(expect, tracker_data) ### results calculated using PVsyst + pvsyst_solar_azimuth = 7.1609 + pvsyst_solar_height = 27.315 + pvsyst_axis_tilt = 20. + pvsyst_axis_azimuth = 20. system.backtrack = False system.max_angle = 60. - system.axis_tilt = 20. - system.axis_azimuth = 200. - apparent_azimuth = pd.Series([180+7.1609]) - apparent_zenith = pd.Series([90-27.315]) + system.axis_tilt = pvsyst_axis_tilt + system.axis_azimuth = 180+pvsyst_axis_azimuth + apparent_azimuth = pd.Series([180+pvsyst_solar_azimuth]) # the definition of azimuth is different from PYsyst + apparent_zenith = pd.Series([90-pvsyst_solar_height]) tracker_data = system.singleaxis(apparent_zenith, apparent_azimuth) expect = pd.DataFrame({'aoi': 41.07852 , 'surface_azimuth': 180-18.432 , 'surface_tilt': 24.92122 , 'tracker_theta': -15.18391}, From 9172a5d513bd443ac2b3b13ebb54ba78951912e7 Mon Sep 17 00:00:00 2001 From: mayudong Date: Tue, 12 Apr 2016 10:45:14 -0700 Subject: [PATCH 08/10] construct a pvsyst_system object in single axis tracker test to ensure the consistency with PVsyst results. move the comment line up to reduce the line length --- pvlib/test/test_tracking.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pvlib/test/test_tracking.py b/pvlib/test/test_tracking.py index c0711bc315..f77a33d7e4 100644 --- a/pvlib/test/test_tracking.py +++ b/pvlib/test/test_tracking.py @@ -199,13 +199,14 @@ def test_SingleAxisTracker_tracking(): pvsyst_solar_height = 27.315 pvsyst_axis_tilt = 20. pvsyst_axis_azimuth = 20. - system.backtrack = False - system.max_angle = 60. - system.axis_tilt = pvsyst_axis_tilt - system.axis_azimuth = 180+pvsyst_axis_azimuth - apparent_azimuth = pd.Series([180+pvsyst_solar_azimuth]) # the definition of azimuth is different from PYsyst + pvsyst_system = tracking.SingleAxisTracker(max_angle=60., + axis_tilt=pvsyst_axis_tilt, + axis_azimuth=180+pvsyst_axis_azimuth, + backtrack=False) + # the definition of azimuth is different from PYsyst + apparent_azimuth = pd.Series([180+pvsyst_solar_azimuth]) apparent_zenith = pd.Series([90-pvsyst_solar_height]) - tracker_data = system.singleaxis(apparent_zenith, apparent_azimuth) + tracker_data = pvsyst_system.singleaxis(apparent_zenith, apparent_azimuth) expect = pd.DataFrame({'aoi': 41.07852 , 'surface_azimuth': 180-18.432 , 'surface_tilt': 24.92122 , 'tracker_theta': -15.18391}, index=[0], dtype=np.float64) From 26e3c94507ec788f6185217b1e54fd0aeb78a9a8 Mon Sep 17 00:00:00 2001 From: mayudong Date: Tue, 12 Apr 2016 10:48:29 -0700 Subject: [PATCH 09/10] remove the commented old line --- pvlib/tracking.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pvlib/tracking.py b/pvlib/tracking.py index 445768a25f..4feee28706 100644 --- a/pvlib/tracking.py +++ b/pvlib/tracking.py @@ -485,7 +485,6 @@ def singleaxis(apparent_zenith, apparent_azimuth, # 4. Rotate 0 reference from panel's x axis to it's y axis and # then back to North. - # surface_azimuth += 90+ axis_azimuth surface_azimuth = 90-surface_azimuth + axis_azimuth # 5. Map azimuth into [0,360) domain. From 41628c620097c4235991936706b03bbd822dc053 Mon Sep 17 00:00:00 2001 From: mayudong Date: Tue, 12 Apr 2016 10:58:14 -0700 Subject: [PATCH 10/10] add info to whatsnew.rst file including a note to the bug and contributor's name --- docs/sphinx/source/whatsnew/v0.3.1.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.3.1.txt b/docs/sphinx/source/whatsnew/v0.3.1.txt index d2b91c2e77..7d1da5c4f3 100644 --- a/docs/sphinx/source/whatsnew/v0.3.1.txt +++ b/docs/sphinx/source/whatsnew/v0.3.1.txt @@ -14,9 +14,11 @@ Enhancements Bug fixes ~~~~~~~~~ - +* Fixed the azimuth calculation of rotated PV panel in function + pvlib.tracking.singleaxis(...) so that the results are consistent + with PVsyst Contributors ~~~~~~~~~~~~ - +* Yudong Ma