Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tentative fix for #125 #128

Merged

Conversation

kandersolar
Copy link
Contributor

Playing around with more test cases like the ones in #125, I noticed a relationship between the discontinuity and the sign of the zero in pvarray.rotation_vec (recall that +0.0 and -0.0 are distinct floating point values). The sign of the zero depends on the relationship between surface_azimuth and axis_azimuth. I did not trace the code to understand what exactly changes downstream based on that sign, but standardizing the sign appears to resolve the problem -- no more negative viewfactors and no more irradiance discontinuity.

I'm a little hesitant to consider this a proper fix without a full understanding of why it fixes the problem. Curious what others think!

Copy link
Contributor

@anomam anomam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow thanks so much for catching this @kanderso-nrel 🙏 🚀
I gotta admit I'm not sure to understand the distinction between +0.0 and -0.0 in python so I'll have to look more into that...
image
I think this is a great fix and I would like to get it merged because the bug is serious IMO; and merging now doesn't prevent us from circling back to it at a later time.

out = pvarray.ts_pvrows[1].back.get_param_weighted('qinc')
assert np.all(pvarray.ts_vf_matrix >= 0)
assert np.all(pvarray.ts_vf_matrix <= 1)
assert rear_qinc_expected == pytest.approx(out[0], abs=1e-2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -122,7 +122,7 @@ def _get_rotation_from_tilt_azimuth(surface_azimuth, axis_azimuth, tilt):
# Calculate rotation of PV row (signed tilt angle)
is_pointing_right = ((surface_azimuth - axis_azimuth) % 360.) > 180.
rotation = np.where(is_pointing_right, tilt, -tilt)

rotation = np.where(tilt == 0, -0.0, rotation) # GH 125
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow I have no idea what's going on here 😅 but your test definitely shows that it's working so great catch! 🚀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kanderso-nrel I don't know what array sizes we are dealing with here, but this is likely faster and more memory efficient:

rotation[tilt==0] = -0.0

@anomam
Copy link
Contributor

anomam commented Dec 6, 2021

@campanelli-sunpower please feel free to add you review as well, otherwise I'd appreciate it if you could merge this PR

@campanelli-sunpower campanelli-sunpower added the bug Something isn't working label Dec 7, 2021
Copy link
Contributor

@campanelli-sunpower campanelli-sunpower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this tentative fix. It would be nice to know where exactly the sign on zero makes a difference. Do we leave #125 open for a more permanent fix?

@@ -122,7 +122,7 @@ def _get_rotation_from_tilt_azimuth(surface_azimuth, axis_azimuth, tilt):
# Calculate rotation of PV row (signed tilt angle)
is_pointing_right = ((surface_azimuth - axis_azimuth) % 360.) > 180.
rotation = np.where(is_pointing_right, tilt, -tilt)

rotation = np.where(tilt == 0, -0.0, rotation) # GH 125
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kanderso-nrel I don't know what array sizes we are dealing with here, but this is likely faster and more memory efficient:

rotation[tilt==0] = -0.0

@kandersolar
Copy link
Contributor Author

Yeah, +1 from me to leave #125 open or at least close it and open a new issue for the follow-up.

Copy link
Contributor

@campanelli-sunpower campanelli-sunpower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave #125 open with a note about this tentative fix. Thanks.

@campanelli-sunpower campanelli-sunpower merged commit 213d050 into SunPower:master Dec 7, 2021
@kandersolar kandersolar deleted the tilt_zero_discontinuity branch December 7, 2021 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants