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

Discontinuous Diffuse Sky Irradiance from Perez Model #2043

Closed
jmobrecht opened this issue May 9, 2024 · 2 comments · Fixed by #2098
Closed

Discontinuous Diffuse Sky Irradiance from Perez Model #2043

jmobrecht opened this issue May 9, 2024 · 2 comments · Fixed by #2098
Milestone

Comments

@jmobrecht
Copy link

jmobrecht commented May 9, 2024

Describe the bug
Using PVLib functions, I calculate a clear sky irradiance and find small ~1% discontinuities originating from the Perez model. I have isolated the issue in the source code and can correct the issue with only a few additional lines and without any cost in computational time.

To Reproduce
Steps to reproduce the behavior:

  1. Calculate solar position using pvlib.solar_position.get_solarposition
  2. Calculate air pressure pvlib.atmosphere.alt2pres
  3. Calculate airmass pvlib.atmosphere.get_relative_airmass
  4. Calculate Linke Turbidity pvlib.clearsky.lookup_linke_turbidity
  5. Calculate DNI_extra pvlib.irradiance.get_extra_radiation
  6. Calculate GHI, DNI, DHI from pvlib.clearsky.ineichen

From the above inputs, I calculate the diffuse sky irradiance using the pvlib.irradiance.perez model. The output results show a sharp discontinuity, which arises from calculation of the F1 & F2 coefficients in the 'perez' function. When an interpolation is used, the discontinuity is eliminated.

Expected behavior
Attached is an image showing the discontinuity of the diffuse sky irradiance from PVLib (blue) and the irradiance from my solution (JMO - red).
pvlib_error

Solution
image

Note
Just spoke with PVLib maintainer Adam who told me that this solution is already solved (Perez-Driesse model)... regardless I'm posting my solution for anyone who wants to use it (see comparison below)

Comparison
The edited code runs just as fast as (and sometimes faster than) the original 'perez' code, while the 'perez-driesse' code runs 50% slower than 'perez' (on my laptop).

@AdamRJensen
Copy link
Member

Thanks for bringing this up @jmobrecht.

Would it be an idea to add a warning admonition on the Perez documentation page, stating that there are small discontinuities and point to the Perez-Driesse model?

@kandersolar
Copy link
Member

These minor discontinuities in the output of the Perez model are a frequent source of surprise. I think a brief explanatory note in the docstring is a good idea.

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

Successfully merging a pull request may close this issue.

3 participants