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

Extend infinite_sheds to optionally use haydavies transposition #1668

Merged
merged 11 commits into from
Feb 28, 2023

Conversation

spaneja
Copy link
Contributor

@spaneja spaneja commented Feb 15, 2023

  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries in docs/sphinx/source/reference for API changes.
  • Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for all changes. Includes link to the GitHub Issue with :issue:`num` or this Pull Request with :pull:`num`. Includes contributor name and/or GitHub username (link with :ghuser:`user`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

Description
This PR adds functionality for users to use the haydavies sky-diffuse transposition model with the get_irradiance() and get_irradiance_poa() functions in the infinite_sheds engine. The works by calling the haydavies() function inside get_irradiance_poa(), and using its return_components functionality to isolate circumsolar. Once isolated, it is removed from dhi, and incorporated into dni.

I have not completed checkboxes yet, as I believe this PR warrants a larger discussion from the maintainers and community. Mainly - is this method acceptable from a technical perspective, and even if so, is this the right way to implement it (ie - if we think about adding future sky diffuse models, would the implementation be similar and/or would this approach complicate things).

I appreciate feedback and guidence from the community. This is inspired by #1551, and was brought to my attention again with @mikofski's most recent comment from #1553.

Updating the infinite_sheds irradiance engine to use the haydavies sky diffuse model. This will help the sensitivity issue with circumsolar on the backside of bifacial systems.
use solar_zenith and solar_azimuth, instead of projection_ratio, in the haydavies() call.
removed unused functions from imports
@spaneja spaneja marked this pull request as draft February 15, 2023 23:35
@cwhanse
Copy link
Member

cwhanse commented Feb 16, 2023

In my view, shifting circumsolar from DHI to beam is acceptable, but we should make sure to inform users of what is being done for them with the input irradiance, and note this is a departure from the cited reference.

@kandersolar
Copy link
Member

Regarding correctness and future expansions, two things come to my mind:

  • Adding circumsolar to DNI is a reasonable approximation, but a more conceptually correct treatment would have it come from a disc rather than a point, which would have some small implications for shading and AOI. I'm not sure of the details but I think pvfactors makes some attempt at this.
  • Future addition of perez, klucher, or reindl will face additional complication due to infinite_sheds having no concept of a diffuse horizon component.

Neither of those is a blocker here IMHO -- I'm +1 to proceeding with the approach in this PR.

cc @johnMoseleyArray as an interested party

@mikofski
Copy link
Member

mikofski commented Feb 17, 2023

more conceptually correct treatment would have it come from a disc rather than a point

My understanding from my days in concentrators is that circumsolar is more of an angular distribution, vs a disc of rays parallel to the DNI. I don’t know if that’s what you meant, but the way it’s modeled in SOLTRACE is as rays at a distribution of angles fanning out from like 5mrad to like 20mrad and decaying to zero at some larger angle. This distribution includes DNI within the 5mrad circumsolar disc and is frequently called a sunshape. Maybe that’s what you meant by a ring?

Anyway I have often thought it would be interesting to see “lighter” shadows being cast by circumsolar bending around objects according this distribution, but I think doing this verges on ray tracing which is computationally intense even for simple systems.

@kandersolar
Copy link
Member

Sure, I should have said "come from a [nonuniform] disc instead of a point" :) Here's some relevant code in pvfactors: https://github.com/SunPower/pvfactors/blob/master/pvfactors/irradiance/utils.py#L196

@mikofski
Copy link
Member

having no concept of a diffuse horizon component.

Does pvfactors have something for this too? @jdnewmil had some ideas about this he shared with me seems right:

horizon diffuse is normally modeled as a ring around the horizon… it is either visible to the surface (at incidence angle equal to tilt) or not (if the tilt is zero).

I wonder if this means that any module with non-zero tilt can always see the horizon (=horizon_irradiance * cos(fixed_tilt)), and that near shade obstructions like adjacent rows don't matter? Also I read this as saying HSAT at solar noon facing skyward have zero horizon component, but have horizon_irradiance * cos(tracker_tilt) all other times.

@cwhanse
Copy link
Member

cwhanse commented Feb 17, 2023

Can we move the discussion of further enhancements (beyond Hay-Davies) to a separate Discussion or Issue? I don't want our contributor to become confused about the scope of this PR :)

@kandersolar kandersolar added this to the 0.9.5 milestone Feb 20, 2023
Added test and updating documentation.
Corrected white-space errors and added test for when haydavies is selected, but dni_extra is not supplied.
@spaneja spaneja marked this pull request as ready for review February 20, 2023 22:10
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

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

Thanks @spaneja! It's interesting to use a transposition model this way -- in a way it's more of a decomposition model...

Updated docstrings and implemented a second call to haydavies to avoid 1/cos(zenith) issues with DNI where zenith nears 90 deg.
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

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

I think we should have something like this text somewhere in the docs, but there are a few places it could go (docstring Notes section, docstring model parameter description, user_guide/bifacial.rst). I don't love that there is so much duplication in the get_irradiance and get_irradiance_poa docstrings, but maybe that's just the way it has to be.

If ``model='isotropic'`` (the default), ``dhi`` is assumed to
be isotropically distributed across the sky dome as in [1]_.
This implementation provides an optional extension to [1]_ to
model sky anisotropy: if ``model='haydavies'``, the input ``dhi``
is decomposed into circumsolar and isotropic components using
:py:func:`~pvlib.irradiance.haydavies`, with the circumsolar
component treated as additional ``dni`` for transposition
and shading purposes.  

Besides a bit more docs stuff, I think this PR is looking pretty good.

Copy link
Member

@cwhanse cwhanse left a comment

Choose a reason for hiding this comment

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

Nicely done @spaneja thank you

@adriesse
Copy link
Member

Reading this thread it struck me as rather odd that shifting circumsolar from DHI to beam was discussed as if it were something odd or novel. I thought it was common practice. Maybe I just misread the comments though.

solar_azimuth,
return_components=True)
circumsolar_normal = sky_diffuse_comps_normal['circumsolar']

Copy link
Member

Choose a reason for hiding this comment

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

I think that instead of calling haydavies twice, you should just calculate the anisotropy index here and use the relevant cosines of angles/projection ratios.

Copy link
Member

Choose a reason for hiding this comment

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

My 2 cents: maybe it's a bit unthrifty to call haydavies 4x for each get_irradiance call, but being able to do this was part of the motivation for #1553, and I think the simplicity of calling functions in pvlib.irradiance is worth the slight hit to efficiency (which I bet is tiny compared with other parts of infinite_sheds anyway). Also, if we add more options for model in the future, are we going to reimplement all of them here?

Copy link
Member

@adriesse adriesse Feb 23, 2023

Choose a reason for hiding this comment

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

I don't know what the future holds. I do know that in the past and again very recently I have found the functions in pvlib irradiance not suitable for my purposes in a similar way to this example. Each offers a little bundle of calculations, but sometimes I just need them bundled differently.

@jdnewmil
Copy link

jdnewmil commented Feb 23, 2023 via email

reorganize order of function inputs.
Updated tests give have correct ordering of inputs.
Whitespace errors - these will be the end of me!
Added detail to docstring in infinite_sheds.py and note on haydavies implementation in bifacial.rst (based on comments from PR).
Updated bifacial.rst file for formatting and ordering. Had added note detailing to user what occurs when 'haydavies' model is selected.
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @spaneja!

@kandersolar kandersolar changed the title Infinite sheds haydavies mod Extend infinite_sheds to optionally use haydavies transposition Feb 28, 2023
@kandersolar kandersolar merged commit 7bb30ad into pvlib:main Feb 28, 2023
@pasquierjb
Copy link

Is there another issue about adding Perez transposition model to inifinite_sheds #1668 (comment) ?

@kandersolar
Copy link
Member

I don't think there's an issue tracking that idea yet. Feel free to open it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants