Description
Describe the bug
- related to singleaxis tracking: backtracking error #656
- in the rare case when the sun rays are below the tracker, then the top of the next row is shaded
- currently tracker backtracks away from sun, back is facing sun instead of front
- this only happens for tilted trackers and very low sun angles, either early morning or late evening when the sun rays are furthest north or south
To Reproduce
Steps to reproduce the behavior:
- create a tilted tracker
# in Brazil so facing north
axis_azimuth = 0.0
axis_tilt = 20
max_angle = 75.0
gcr = 0.35
- pick the earliest morning (or latest evening) timestamp
import pvlib
import pandas as pd
# Brazil, timezone is UTC-3[hrs]
starttime = '2017-01-01T00:30:00-0300'
stoptime = '2017-12-31T23:59:59-0300'
lat, lon = -27.597300, -48.549610
times = pd.DatetimeIndex(pd.date_range(
starttime, stoptime, freq='H'))
solpos = pvlib.solarposition.get_solarposition(
times, lat, lon)
# get the early times
ts0 = '2017-01-01 05:30:00-03:00'
ts1 = '2017-01-01 12:30:00-03:00'
apparent_zenith = solpos['apparent_zenith'][ts0:ts1]
azimuth = solpos['azimuth'][ts0:ts1]
sat = pvlib.tracking.singleaxis(
apparent_zenith, azimuth, axis_tilt, axis_azimuth, max_angle, True, gcr)
- notice that the tracker suddenly jumps from one side facing east to west
tracker_theta aoi surface_azimuth surface_tilt
2017-01-01 05:30:00-03:00 -21.964540 62.721237 310.299287 29.368272
2017-01-01 06:30:00-03:00 16.231156 69.264752 40.403367 25.546154
2017-01-01 07:30:00-03:00 69.073645 20.433849 82.548858 70.389280
2017-01-01 08:30:00-03:00 54.554616 18.683626 76.316479 56.978562
2017-01-01 09:30:00-03:00 40.131687 17.224233 67.917292 44.072837
2017-01-01 10:30:00-03:00 25.769332 16.144347 54.683567 32.194782
2017-01-01 11:30:00-03:00 11.439675 15.509532 30.610665 22.923644
2017-01-01 12:30:00-03:00 -2.877428 15.358209 351.639727 20.197537
- AOI is also wrong
Expected behavior
The tracker should avoid shade. It should not jump from one direction to the other. If the sun ray is below the tracker then it will need to track to it's max rotation or backtrack. If there is shading at it's max rotation then it should track backtrack to zero, or perhaps parallel to the sun rays. Perhaps if bifacial, then it could go backwards, 180 from the correct backtrack position to show it's backside to the sun.
proposed algorithm (updated after this comment):
if backtracking:
# cos(R) = L / Lx, R is rotation, L is surface length,
# Lx is shadow on ground, tracker shades when Lx > x
# x is row spacing related to GCR, x = L/GCR
lrot = np.cos(tr_rot_no_lim) # tracker rotation not limited by max angle
# Note: if tr_rot > 90[deg] then lrot < 0
# which *can* happen at low angles if axis tilt > 0
# tracker should never backtrack more than 90[deg], when lrot = 0
cos_rot = np.minimum(np.abs(lrot) / self.gcr, 1)
# so if lrot<0 tracker should backtrack forward
# backtrack_rot = np.sign(lrot) * np.arccos(cos_rot)
# NOTE: updated after comment from @kevinsa5 at Nov 27, 2019, 8:16 AM PST
# to remove sign()
backtrack_rot = np.arccos(cos_rot)
also remove abs from aoi calculation
pvlib-python/pvlib/tracking.py
Line 461 in c699575
Screenshots
If applicable, add screenshots to help explain your problem.
Versions:
pvlib.__version__
: 0.6.3pandas.__version__
: 0.24- python: 3.7
Additional context
Add any other context about the problem here.