Skip to content

[Feature Preview] Shadow casting on and by flat surfaces #2106

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

Closed
wants to merge 27 commits into from

Conversation

echedey-ls
Copy link
Contributor

@echedey-ls echedey-ls commented Jun 23, 2024

Briefing

Objectives

  • Provide an API to calculate shades
  • Intuitive
  • Trying to follow the references

Possibly there's only one I have achieved.
⚠️ Trigger warning for reviewers: crap unfinished code

General modifications this PR introduces

  • pvlib.spatial module with two classes:
    • FlatSurface, can shade and can be shaded
    • RectangularSurface, inherits from above but allows for easy building of the common instance
  • Two examples
  • New config option of sphinx-gallery to allow animations
  • New dependency, shapely (probably should be pinned to >= 2)

What is pending

  • Completing the test suite
  • Polishing docs
  • Implement the generic FlatSurface.plot() method
  • Implement FlatSurface.combine_2D_shades() to avoid overlapping shades (make it the default in .get_2D_shades_from()

Long-term roadmap

  • Add 3D objects (the same projection of points, but using a ConvexHull to calculate the shade boundaries for certain objects or maybe composing of flat surfaces)
  • Add opacity and the inclusion-exclusion algorithm to calculate the resulting shade transparency
  • Add conical objects, i.e. trees

Where & why I did not follow the references in some cases:

  • Angle convention used has been the one described by the familiar reference Slope-Aware Backtracking for Single-Axis Trackers - NREL
  • Added rotation of surfaces, the known axis_tilt
  • Added a surface point to the calculation of the interceptions. The original reference describes projecting the shadows onto the plane that goes through the origin, but I thought that is super-antiintuitive for any kind of user since it would make the coordinate system fixed to each item being shaded. In other words, a shading scene per shaded object. The extra step is a translation (points difference) of the projected object.

Other information about the solution

  • Does not use rotation matrices (originally it did): it uses the scipy spatial Rotation object, faster (quaternions), implements broadcasting, handy ways of instantiating the object
  • Relies on shapely Polygons for a lot of things

Controversial features (like if there weren't already enough)

  • Does not allow the input to be a timeseries, only an instant (scalar solar zenith and azimuth)

Status and discussion

You see, this is unfinished. I wouldn't allow myself to do this to you, but in one of the GSoC meetings I was hinted (fairly) that maybe this does not fit this repo. That maybe it does creating another repo under the pvlib organization. Maybe not even that.

And since there wasn't much conversation at #2069, opening this PR is partly to kickstart the discussion regarding that.

Regarding the model, the simulated plot:
image

Does not match the results for the Winter Solstice:
image

Docs

@echedey-ls echedey-ls changed the title [DRAFT] Shadow casting on and by flat surfaces [Feature Preview] Shadow casting on and by flat surfaces Jun 27, 2024
@echedey-ls
Copy link
Contributor Author

Ready for preview @kandersolar , @AdamRJensen , @cwhanse , the rest of @pvlib/maintainers (I can't ping the team)

Feel free to weight in whatever comes to your mind, but firstly focus on whether pvlib is a good place for this please. TIA.

@AdamRJensen AdamRJensen added enhancement GSoC Contributions related to Google Summer of Code. labels Jul 4, 2024
@adriesse
Copy link
Member

@mikofski , @adriesse , @markcampanelli would you like to weight in whether pvlib is a good place to include this? So I can determine if I should continue working on the code or not.

My initial reaction is that it is probably a good basic functionality for the pvlib toolbox. I haven't looked under the hood, but maybe the PR can be split up a bit. Also details of OO interface could perhaps be debated.

@cwhanse
Copy link
Member

cwhanse commented Jul 18, 2024

I am not in favor of building 3D lighting/shade calculators into pvlib-python. My reasons:

  • I think the code base will necessarily be large and I worry about long-term maintenance
  • it is likely to introduce dependencies that aren't used elsewhere in pvlib (e.g. shapely)
  • I can't help but think that lighting/shade calculations are already being done in other libraries and pvlib would only need some shim code. Perhaps that's wishful thinking.

For these reasons, I think a new project (pvlib3d?) makes more sense than pvlib.spatial.

@echedey-ls
Copy link
Contributor Author

Seems like there is consensus on not including something like this here, so I'm closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement GSoC Contributions related to Google Summer of Code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Direct and diffuse shading factors - spatial approach (for Photosynthetically Active Radiation)
4 participants