Skip to content

iam.schlick_diffuse returns inf and nan at surface_tilt=180 #2939

Open

Description

@G26karthik

Describe the bug
pvlib.iam.schlick_diffuse(180) returns {'sky': inf, 'ground': nan} with a RuntimeWarning: divide by zero. Eq 4 for the sky term divides by 1 + cos(surface_tilt), which is 0/0 at 180. The ground term is already special-cased at tilt 0 (surface_tilt < 1e-6); the sky term has no equivalent at 180.

To Reproduce

import pvlib
pvlib.iam.schlick_diffuse(180)
# {'sky': inf, 'ground': nan}

Expected behavior
sky is 0 (a surface facing straight down sees no sky; the value tends to 0 as the tilt approaches 180) and ground is 20/21 = 0.9524, the same as sky at tilt 0. marion_diffuse('schlick', surface_tilt=180) gives 0 and 0.95236.

Versions:

  • pvlib.__version__: 0.16.2.dev19+gc5de586d7
  • pandas.__version__: 3.1.1
  • python: 3.12.12

Additional context
Found while reading the code. PVSystem.get_iam_diffuse(180, iam_model='schlick_diffuse') returns the same. I can open a PR that applies the same 1e-6 clamp to the sky term.

Activity

  1. cwhanse commented on Nov 8, 2026

    @cwhanse
    Member

    applies the same 1e-6 clamp to the sky term.

    Seems to me like a good idea. Please wait for other maintainers to comment.

  2. kandersolar commented on Nov 9, 2026

    @kandersolar
    Member

    Thanks for the good bug report. A PR would be welcome, and please include test(s) as well.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions