Repository navigation
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
| aoi = np.degrees(np.arccos(np.abs(np.sum(sun_vec*panel_norm, axis=0)))) |
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.
Activity
cwhanse commentedon Nov 22, 2019
Related to #65 is a typo? I'm not following step 1, what is
system_planedefining?mikofski commentedon Nov 22, 2019
Thanks, I updated the description to reference #656, sorry.
oops re: system plane, that's related to the new PR, #823, it's the plane that contains all the trackers, but it isn't necessary here, because we can have this same issue on a tilted tracker that is parallel to the slope (system plane) it's on.
mikofski commentedon Nov 26, 2019
PTAL @kevinsa5 thx!
kevinsa5 commentedon Nov 26, 2019
To make sure I understand the geometry -- here's a sideview truetracking vs backtracking diagram I have laying around, so apologies for the extraneous labeling. The math behind "normal" backtracking when the sun is above the array is to align points C and H (or D and F, with backtracking enabled) such that their tangent line is parallel to the sun's rays. This tangent line coincides with the edge of the shadow cast by the row in front. As the sun crosses the system plane (dashed line) and passes "underneath" the array, each row's shadow crosses over the row behind it, which means that the relevant shadow edge switches -- instead of aligning points D and F, the goal is now to align points I and J. As such, the correct backtracking behavior is for tracker angle to momentarily touch zero right when the sun crosses the system plane, then to increase again until sun is below horizon (or max angle is reached). For instance, if position I-D in the figure represents the correct backtracking angle for some solar position where the sun is above the array as it sets, the row should proceed to track flatter until the sun crosses the dashed line, and then reverse course back to I-D and beyond as the sun continues to drop below the plane.
@mikofski does that sound right?
mikofski commentedon Nov 27, 2019
Thanks so much for commenting!
Yes this is what I am also suggesting.
Maybe it's easier to visualize if we flip the sketch, unfortunately you also have to mentally switch I & D if you want the front of the PV surface to face the sun:

Interesting, from this perspective, it appears that at the instant after the sun crosses the "system" plane and the sun drops below it, the PV surface if backtracking would have to flip 180[deg] forward in order to face downward at the sun, but then would rotate back again as the true tracking position continued forward until backtracking was no longer necessary.
So I think my proposed algorithm is correct:
satis the current backtracking algorithmsat180nois no backtracking with max angle at 180[deg]tracker_wbacktrackis the proposed backtracking algorithmExpand to see code...
Details
kevinsa5 commentedon Nov 27, 2019
I'm not sure that this point is necessarily true:
From my understanding, there are two backtracking positions that eliminate row-to-row shading and present the same cross section to incoming beam irradiance. In the below diagram (another that I already had laying around), the sun has crossed below the system plane and it shows the two possible backtracking positions. P1 is what you're describing where the front face of the module has rotated around and is now facing backwards/down and P2 is what I tried to describe above where the modules are still facing forwards/up. I believe the two are equivalent in terms of DNI collection and shading, but the forwards/up variant would presumably have better diffuse collection and is more accommodating of tracker rotation limits.
I don't have the math already coded up for this so I can't generate a comparison plot of tracker angle, but I think it would look something like the absolute value of your blue line -- a moment where tracker_angle=0 when the sun crosses the system plane, with positive tracker angle on both sides of the zero.
mikofski commentedon Nov 27, 2019
Excellent insight! I agree, and I think your proposal is much better!!
Here's what I get now:

I just made the one change you suggested to take absolute value, actually because
abs(lrot)was already in there, I just removed thesign(backtrack_rot)(click to expand):Details
mikofski commentedon Nov 27, 2019
Here is a visual double check that this does what we want using Shapely:

Just tack on this code the bottom of the snippet (click to exp and, also at this gist):
Details
kevinsa5 commentedon Nov 28, 2019
Yep, I think we're on the same page now. I like the results your code gives in the morning, but I'm getting bad results in the evening, I believe because of a combination of two things: pvlib returns truetracking angles in [-90,+270] (see the responsible line of code) which means
sat180noangle rolls over to +270 towards the end of the day. Thenmax_angle=180clips the truetracking angle to +180 and messes uplrotas a result. I believe changingmax_angleto 360 and remapping to [-180,+180] makes the afternoon work as well in your code. So in short, I think this only needs two modifications to the current pvlib implementation:wid = (wid+180) % 360 - 180or equivalentcosd(wid)Does that look right?
A couple other thoughts:
backtrack_condition = np.cos(np.radians(truetracking_theta)) < gcr. Just a minor personal preference.[-]backtracking should track forward for rare case when sun below tracker[/-][+]backtracking for rare case when sun below tracker improvement[/+]fix pvlib#824 update tests
Singleaxis tracking with non-parallel slope (pvlib#823)