Skip to content

power_mismatch_deline docstring: the rear-to-total RMAD conversion has an extra bifaciality factor #2929

Closed

Description

@anasnedos

Describe the bug
The Notes of pvlib.bifacial.power_mismatch_deline convert the RMAD of the rear irradiance to the RMAD of the total irradiance with one bifaciality factor too many. The docstring says

$$RMAD(k \cdot X + c) = RMAD(X) \cdot k \frac{k \bar{X}}{k \bar{X} + c} = RMAD(X) \cdot \frac{k}{1 + \frac{c}{k \bar{X}}}$$

and so

$$RMAD_{total} = RMAD_{rear} \frac{\phi_{Bifi}}{1 + \frac{G_{front}}{\phi_{Bifi} \bar{G}_{rear}}}$$

RMAD doesn't change with scale, though. For $Y = kX + c$, each $|Y_i - Y_j| = k |X_i - X_j|$ and $\bar{Y} = k\bar{X} + c$, so

$$RMAD(k \cdot X + c) = \frac{k \sum_i \sum_j |X_i - X_j|}{n^2 (k \bar{X} + c)} = RMAD(X) \cdot \frac{k \bar{X}}{k \bar{X} + c} = \frac{RMAD(X)}{1 + \frac{c}{k \bar{X}}}$$

which gives

$$RMAD_{total} = \frac{RMAD_{rear}}{1 + \frac{G_{front}}{\phi_{Bifi} \bar{G}_{rear}}}$$

Following the docstring understates the total RMAD by the factor $\phi_{Bifi}$, about 30 % for a bifaciality of 0.7, and so the mismatch loss as well. The function's code isn't affected: it takes the total RMAD as given. Only the formula in the Notes is.

To Reproduce

import numpy as np

rng = np.random.default_rng(0)
g_rear = rng.uniform(80, 160, 72)  # W/m2, one value per cell
g_front = 900.0                    # W/m2, uniform front
phi = 0.7                          # bifaciality
g_total = g_front + phi * g_rear   # Eq. (2) of Deline et al. (2020)


def rmad(x):
    x = np.asarray(x, dtype=float)
    return np.abs(x[:, None] - x[None, :]).sum() / (x.size**2 * x.mean())


rmad_rear = rmad(g_rear)
print(rmad(g_total))                                            # 0.0193862763
print(rmad_rear / (1 + g_front / (phi * g_rear.mean())))        # 0.0193862763
print(rmad_rear * phi / (1 + g_front / (phi * g_rear.mean())))  # 0.0135703934, the docstring's form

Expected behavior
The Notes would read $RMAD(k \cdot X + c) = RMAD(X) \cdot \frac{k \bar{X}}{k \bar{X} + c} = \frac{RMAD(X)}{1 + \frac{c}{k \bar{X}}}$, and $RMAD_{total} = \frac{RMAD_{rear}}{1 + \frac{G_{front}}{\phi_{Bifi} \bar{G}_{rear}}}$. The text is in pvlib/bifacial/loss_models.py, lines 118–132 on main today.

Versions:

  • pvlib.__version__: 0.16.1 (the same text is on main)
  • pandas.__version__: 3.0.6
  • python: 3.12.15

Activity

  1. cwhanse commented on Oct 31, 2026

    @cwhanse
    Member

    Confirmed, thanks for reporting. The docstring is incorrect; should be (unless I've mistyped here)

        .. math::
    
           RMAD(k \cdot X + c) = RMAD(X) \cdot \frac{k \bar{X}}{k \bar{X} + c}
           = RMAD(X) \cdot \frac{1}{1 + \frac{c}{k \bar{X}}}
    

    and

        .. math::
    
           RMAD_{total} = RMAD_{rear} \frac{1}
           {1 + \frac{G_{front}}{\phi_{Bifi} \bar{G}_{rear}}}
    
  2. echedey-ls commented on Nov 1, 2026

    @echedey-ls
    Member

    Dang it, I don't remember what I did to derive that. Well spotted and tested @anasnedos! Thanks!
    The underestimation is exactly that of $$1 - \phi_{Bifi}$$. I will fix that in short.

  3. added this to the v0.16.2 milestone on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions