Skip to content

Discontinuous Diffuse Sky Irradiance from Perez Model #2043

Closed
@jmobrecht

Description

@jmobrecht

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions