Skip to content

NREL non-uniform irradiance mismatch loss for bifacial modules #2046

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

Merged
merged 87 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
9c68605
Preliminar implementation, tests, docs and gallery example
echedey-ls Apr 26, 2024
7c17712
Merge branch 'main' into nrel-mismatch-loss
echedey-ls May 6, 2024
23320db
Update versionadded
echedey-ls May 10, 2024
47fa80d
Add example
echedey-ls May 10, 2024
84346d2
docstring update
echedey-ls May 10, 2024
bdb9955
Update v0.11.0.rst
echedey-ls May 10, 2024
914d009
who would have guessed it's always the linter?
echedey-ls May 10, 2024
29f4c66
Update plot_irradiance_nonuniformity_loss.py
echedey-ls May 10, 2024
03011d3
equation fixes
echedey-ls May 10, 2024
de1744a
RMAD properties application typo
echedey-ls May 10, 2024
7f27c9f
does this fix the link?
echedey-ls May 10, 2024
2cdc95f
yet another link
echedey-ls May 10, 2024
0698839
These links will never work, I suppose
echedey-ls May 10, 2024
7f27f1c
Move some "Notes" equations to example and rearrange things there
echedey-ls May 11, 2024
58c05bd
give this equation it's space
echedey-ls May 11, 2024
b973959
eq rendering fixes?
echedey-ls May 11, 2024
448b647
maths are not mathing today
echedey-ls May 11, 2024
5768473
???
echedey-ls May 11, 2024
b1a7e4a
??? x2
echedey-ls May 11, 2024
d1b476d
??? x3
echedey-ls May 11, 2024
d037314
i feel stupid for this
echedey-ls May 11, 2024
4ec952b
Change preprint ref to published one
echedey-ls May 14, 2024
b0cadb5
Published paper coeffs
echedey-ls May 18, 2024
9f51b68
Lots of improvements
echedey-ls May 19, 2024
67d3737
Linter - also missing Eq (7)
echedey-ls May 19, 2024
10ac204
Test polynomial input
echedey-ls May 19, 2024
9290f41
Math
echedey-ls May 20, 2024
c7b94a0
Test exception
echedey-ls May 20, 2024
3599991
Update pvsystem.py
echedey-ls May 20, 2024
c965225
Update plot_irradiance_nonuniformity_loss.py
echedey-ls May 20, 2024
0c15443
Add fill factor ratio
echedey-ls May 20, 2024
d141189
ª
echedey-ls May 20, 2024
8a19a4d
Trying new things
echedey-ls May 21, 2024
c32f78a
Revert "Trying new things"
echedey-ls May 21, 2024
5f69b6d
Update pvsystem.py
echedey-ls May 21, 2024
4c354ea
:(
echedey-ls May 21, 2024
a2de166
:((
echedey-ls May 21, 2024
b572f45
I hope we dont miss that reference
echedey-ls May 22, 2024
1b0565b
Update pvsystem.py
echedey-ls May 22, 2024
87f46f0
Remove second section of the example
echedey-ls May 27, 2024
ae775ec
Minor text upgrade
echedey-ls May 27, 2024
4c75534
Merge branch 'main' into nrel-mismatch-loss
echedey-ls May 27, 2024
1906e20
Update pvsystem.py
echedey-ls May 27, 2024
f5863ce
Port to namespace `pvlib.bifacial`
echedey-ls May 28, 2024
a7d3f7e
Rename to ``power_mismatch_deline``, document in ``bifacial.rst``
echedey-ls May 28, 2024
84f702f
fillfactor only for predefined models
echedey-ls May 28, 2024
3ad18a6
Docstring rewording
echedey-ls May 28, 2024
b6c6fb2
Linter
echedey-ls May 28, 2024
18a397f
More docs rewording
echedey-ls May 28, 2024
1d7d86c
Merge branch 'main' into nrel-mismatch-loss
echedey-ls Jun 11, 2024
8bae370
Apply suggestions from Dax
echedey-ls Jun 12, 2024
75ae58b
Unneded image Dominguez_et_al_PVSC2023.png
echedey-ls Jun 12, 2024
b106ff8
Rename file
echedey-ls Jun 12, 2024
4c78987
Fix equations
echedey-ls Jun 12, 2024
56c7d2e
yup it didnt save
echedey-ls Jun 12, 2024
d225a6d
lintaaaaaaarrrr
echedey-ls Jun 12, 2024
36f3be0
Eq 7 numbering
echedey-ls Jun 12, 2024
0c99269
Revert unintended changes
echedey-ls Jun 12, 2024
a46245a
Adam code review
echedey-ls Jun 12, 2024
a4a32e0
Links?
echedey-ls Jun 12, 2024
88273ba
Referencing equations manually
echedey-ls Jun 12, 2024
f096a0a
Polynomial links
echedey-ls Jun 12, 2024
5945b74
Dont abuse math mode
echedey-ls Jun 12, 2024
adbcbeb
Update loss_models.py
echedey-ls Jun 12, 2024
6f5c69f
I forgot
echedey-ls Jun 12, 2024
770b4a5
Adam Code Review
echedey-ls Jun 12, 2024
329312a
Merge branch 'main' into nrel-mismatch-loss
echedey-ls Jun 20, 2024
9d0411b
Merge branch 'main' into nrel-mismatch-loss
echedey-ls Jun 21, 2024
a9d507f
whatsnews
echedey-ls Jun 21, 2024
243de31
Update v0.11.0.rst
echedey-ls Jun 21, 2024
204f8b7
Weird that some tests pass and others dont
echedey-ls Jun 21, 2024
a88cb4c
Update loss_models.py
echedey-ls Jun 21, 2024
0136b3a
document
echedey-ls Jun 21, 2024
c6ca308
Update loss_models.py
echedey-ls Jun 21, 2024
adad0c1
Kevin's review (I)
echedey-ls Jun 27, 2024
6fafcb4
Kevin's review (II)
echedey-ls Jun 27, 2024
436b0e2
Kevin's review (III)
echedey-ls Jun 28, 2024
7d91db6
Update v0.11.1.rst
echedey-ls Jun 28, 2024
b1b51bd
minor changes
echedey-ls Jun 28, 2024
3991800
Forgot to update tests
echedey-ls Jun 28, 2024
aeaabb4
Accordingly modify model, IO, docs to unitless model
echedey-ls Jun 28, 2024
9289412
Update loss_models.py
echedey-ls Jun 28, 2024
f025133
Update loss_models.py
echedey-ls Jun 28, 2024
69a5acf
Apply suggestions from code review
echedey-ls Jun 30, 2024
945d61a
Code review from Cliff
echedey-ls Jun 30, 2024
cecc337
Rendering issues, code review from Kevin
echedey-ls Jul 1, 2024
289dbeb
Little missing newline
echedey-ls Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
265 changes: 265 additions & 0 deletions docs/examples/bifacial/plot_irradiance_nonuniformity_loss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
"""
Plot Irradiance Non-uniformity Loss
===================================

Calculate the incident irradiance lost to non-uniformity in a bifacial PV array
"""

# %%
# The incident irradiance on the backside of a bifacial PV module is
# not uniform due to neighboring rows, the ground albedo and site conditions.
# Cells with different irradiance levels produce less power that the sum of
# the power produced by each cell individually. This is known as irradiance
# non-uniformity loss.
#
# This example demonstrates how to model the irradiance non-uniformity loss
# due to different global irradiance levels on a bifacial PV module through
# two different approaches:
#
# - Given the irradiance levels of each cell in an instant,
# in the first section.
# - Modelling the irradiance non-uniformity RMAD through the day thanks to a
# mock-up horizontal axis tracker system, in the second section.
# See [2]_ and [3]_ for more information.
#
# The function :py:func:`pvlib.pvsystem.nonuniform_irradiance_loss` will be
# used to transform the Relative Mean Absolute Deviation (RMAD) of the
# irradiance into a power loss percentage. Down below you will find a
# numpy-based implementation of the RMAD function.
#
# References
# ----------
# .. [1] C. Deline, S. Ayala Pelaez, S. MacAlpine, and C. Olalla, 'Estimating
# and parameterizing mismatch power loss in bifacial photovoltaic
# systems', Progress in Photovoltaics: Research and Applications, vol. 28,
# no. 7, pp. 691-703, 2020, :doi:`10.1002/pip.3259`.
# .. [2] C. Domínguez, J. Marcos, S. Ures, S. Askins, and I. Antón, 'A
# Horizontal Single-Axis Tracker Mock-Up to Quickly Assess the Influence
# of Geometrical Factors on Bifacial Energy Gain', in 2023 IEEE 50th
# Photovoltaic Specialists Conference (PVSC), Jun. 2023, pp. 1–3.
# :doi:`10.1109/PVSC48320.2023.10359580`.
# .. [3] C. Domínguez, J. Marcos, S. Ures, S. Askins, I. Antón, A Horizontal
# Single-Axis Tracker Mock-Up to Quickly Assess the Influence of Geometrical
# Factors on Bifacial Energy Gain. Zenodo, 2023.
# :doi:`10.5281/zenodo.11125039`.
#
# .. sectionauthor:: Echedey Luis <echelual (at) gmail.com>

import numpy as np
import pandas as pd
import scipy.stats
import matplotlib.pyplot as plt
from matplotlib.cm import ScalarMappable
from matplotlib.colors import Normalize

from pvlib.pvsystem import nonuniform_irradiance_loss

# %%
# Theoretical and straightforward problem
# ---------------------------------------
# Let's set a fixed irradiance to each cell row of the PV array with the values
# described in Figure 1 (a), [1]_. We will cover this case for educational
# purposes.
# Here we set and plot the global irradiance levels of each cell.

x = np.arange(6, 0, -1)
y = np.arange(6, 0, -1)
cells_irrad = np.repeat([1059, 976, 967, 986, 1034, 1128], 6).reshape(6, 6)

color_map = "gray"
color_norm = Normalize(930, 1150)

fig, ax = plt.subplots()
fig.suptitle("Global Irradiance Levels of Each Cell")
fig.colorbar(
ScalarMappable(cmap=color_map, norm=color_norm),
ax=ax,
orientation="vertical",
label="$[W/m^2]$",
)
ax.set_aspect("equal")
ax.pcolormesh(
x,
y,
cells_irrad,
shading="nearest",
edgecolors="black",
cmap=color_map,
norm=color_norm,
)

# %%
# Relative Mean Absolute Deviation
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Calculate the Relative Mean Absolute Deviation (RMAD) of the cells'
# irradiance with the following function, Eq. (4) of [1]_:
#
# .. math::
#
# \Delta \left[ \% \right] = \frac{1}{n^2 \bar{G}_{total}}
# \sum_{i=1}^{n} \sum_{j=1}^{n} \lvert G_{total,i} - G_{total,j} \rvert
#


def rmad(data, axis=None):
"""
Relative Mean Absolute Deviation.
https://stackoverflow.com/a/19472336/19371110
"""
mad = np.mean(np.absolute(data - np.mean(data, axis)), axis)
return mad / np.mean(data, axis)


rmad_cells = rmad(cells_irrad)

# this is the same as a column's RMAD!
print(rmad_cells == rmad(cells_irrad[:, 0]))

# %%
# Mismatch Loss
# ^^^^^^^^^^^^^
# Calculate the power loss percentage due to the irradiance non-uniformity
# with the function :py:func:`pvlib.pvsystem.nonuniform_irradiance_loss`.

mismatch_loss = nonuniform_irradiance_loss(rmad_cells)

# %%
# Total power incident on the module cells
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# It is the sum of the irradiance of each cell

total_irrad = np.sum(cells_irrad)

# %%
# Mismatch-corrected irradiance
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# The power incident on the module cells is multiplied by the mismatch loss
# as follows:

mismatch_corrected_irrad = total_irrad * (1 - mismatch_loss)

# %%
# Results
# ^^^^^^^

print(f"Total power incident on the module cells: {total_irrad}")
print(f"RMAD of the cells' irradiance: {rmad_cells}")
print(f"Power loss % due to the irradiance non-uniformity: {mismatch_loss}")
print(f"Effective power after mismatch correction: {mismatch_corrected_irrad}")

# %%
# A practical approach
# --------------------
# In practice, simulating each cell irradiance is computationally expensive,
# and measuring each of the cells irradiance of a real system can also be
# challenging. Nevertheless, a mock-up system can be used to estimate the
# non-uniformity through the day.
#
# Here we will base our calculations on the work of Domínguez et al. [2]_.
# The following image in [3]_ shows the backside irradiance non-uniformity of a
# HSAT mock-up system:
#
# .. figure:: ../../_images/Dominguez_et_al_PVSC2023.png
# :alt: Plot of backside reference cells of an HSAT mock-up and their RMAD.
# :align: center
#
# Blue dots represent the backside irradiance non-uniformity.
# *BE* stands for *backside east*.


def hsat_backside_rmad_model_through_day(hour):
"""Model of the blue dots in the image above."""
# For demonstration purposes only. Model roughly fit to show an example of
# the RMAD variation through the day without including all the data.
# fmt: off
morning_polynom = [6.71787833e-02, -4.50442998e+00, 1.18114757e+02,
-1.51725679e+03, 9.56439547e+03, -2.36835920e+04]
afternoon_polynom = [7.14947943e-01, -6.02541075e+01, 2.02789031e+03,
-3.40677727e+04, 2.85671091e+05, -9.56469320e+05]
# fmt: on
day_rmad = np.where(
hour < 14.75,
np.polyval(morning_polynom, hour),
np.polyval(afternoon_polynom, hour),
)
return day_rmad / 100 # RMAD is a percentage


# %%
# Calculating Global RMAD from Backside RMAD
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# .. note::
# The global irradiance RMAD is different from the backside irradiance RMAD.
#
# The global irradiance is the sum of the front irradiance and the backside
# irradiance by the bifaciality factor, see equation (2) in [1]_.
#
# .. math::
#
# G_{total,i} = G_{front,i} + \phi_{Bifi} G_{rear,i}
#
# where :math:`\phi_{Bifi}` is the bifaciality factor.
#
# Here we will model front and backside irradiances with normal distributions
# for simplicity, then calculate the global RMAD and plot the results.
#
# The backside irradiance is the one that presents the most significant
# non-uniformity. The front irradiance is way more uniform, so it will be
# neglected in this example.
#
# Let's calculate the **global RMAD** through the day - it's **different** from
# the backside RMAD since
#
# .. math::
#
# RMAD(k \cdot X + c) = RMAD(X) \cdot k \frac{k \bar{X}}{k \bar{X} + c}
# = RMAD(X) \cdot k \frac{1}{1 + \frac{c}{k \bar{X}}}
#
# where :math:`X` is a random variable and :math:`k>0, c \neq \bar{X}` are
# constants (`source
# <https://en.wikipedia.org/wiki/Mean_absolute_difference#Properties>`_).

times = pd.date_range("2023-06-06T09:30", "2023-06-06T18:30", freq="30min")
hours = times.hour + times.minute / 60
bifaciality = 0.65
front_irrad = scipy.stats.norm.pdf(hours, loc=12.5, scale=1600)
backside_irrad = scipy.stats.norm.pdf(hours, loc=12.5, scale=180)

global_irrad = front_irrad + bifaciality * backside_irrad
# See RMAD properties above
# Here we calculate RMAD(global_irrad)
# backside_irrad := X, bifaciality := k, front_irrad := c
backside_rmad = hsat_backside_rmad_model_through_day(hours)
global_rmad = (
backside_rmad
* bifaciality
/ (1 + front_irrad / backside_irrad / bifaciality)
)

# Get the mismatch loss
mismatch_loss = nonuniform_irradiance_loss(global_rmad)

# Plot results
fig, ax1 = plt.subplots()
fig.suptitle("Irradiance RMAD and Mismatch Losses")

ax1.plot(hours, global_rmad, label="RMAD: global", color="k")
ax1.plot(
hours, backside_rmad, label="RMAD: backside", color="b", linestyle="--"
)
ax1.set_xlabel("Hour of the day")
ax1.set_ylabel("RMAD")
ax1.legend(loc="upper left")

ax2 = ax1.twinx()
ax2.plot(
hours, mismatch_loss, label="Mismatch loss", color="red", linestyle=":"
)
ax2.grid()
ax2.legend(loc="upper right")
ax2.set_ylabel("Mismatch loss")

fig.show()

# %%
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Loss models

pvsystem.combine_loss_factors
pvsystem.dc_ohms_from_percent
pvsystem.nonuniform_irradiance_loss
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.11.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Deprecations

Enhancements
~~~~~~~~~~~~
* Add new losses function that accounts for non-uniform irradiance of bifacial
modules, :py:func:`pvlib.pvsystem.nonuniform_irradiance_loss`.
(:issue:`2045`, :pr:`2046`)


Bug fixes
Expand Down
60 changes: 60 additions & 0 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3030,3 +3030,63 @@ def combine_loss_factors(index, *losses, fill_method='ffill'):
combined_factor *= (1 - loss)

return 1 - combined_factor


def nonuniform_irradiance_loss(rmad):
r"""
Calculate the incident irradiance loss due to irradiance non-uniformity.

This model is described for bifacial modules in [1]_, where the backside
irradiance is less uniform due to mounting and site conditions.

.. versionadded:: 0.11.0

Parameters
----------
rmad : numeric
The Relative Mean Absolute Difference of the irradiance.
See the definition in [2]_ and the example
:ref:`sphx_glr_gallery_bifacial_plot_irradiance_nonuniformity_loss.py`.

Returns
-------
loss : numeric
The irradiance loss.

Notes
-----
The function this model implements is equation (7) of [1]_:

.. math::

M[%] = 0.12 \Delta[%] + 2.77 \Delta[%]^2

where :math:`\Delta[%]` is the Relative Mean Absolute Difference of the
global irradiance, Eq. (4) of [1]_ and [2]_.

The losses definition is done in Eq. (1) of [1]_:

.. math::

M[%] = 1 - \frac{P_{Array}}{\sum P_{Cells}}

It is recommended to see the example
:ref:`sphx_glr_gallery_bifacial_plot_irradiance_nonuniformity_loss.py`
for a complete use case and the RMAD function implementation.

See Also
--------
pvlib.pvsystem.combine_loss_factors

References
----------
.. [1] C. Deline, S. Ayala Pelaez, S. MacAlpine, and C. Olalla, 'Estimating
and parameterizing mismatch power loss in bifacial photovoltaic
systems', Progress in Photovoltaics: Research and Applications, vol. 28,
no. 7, pp. 691-703, 2020, :doi:`10.1002/pip.3259`.
.. [2] “Mean absolute difference,” Wikipedia, Sep. 05, 2023.
https://en.wikipedia.org/wiki/Mean_absolute_difference#Relative_mean_absolute_difference
(accessed 2024-04-14).
""" # noqa: E501
# Eq. (7) of [1]
return rmad * (0.12 + 2.77 * rmad)
12 changes: 12 additions & 0 deletions pvlib/tests/test_pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2521,3 +2521,15 @@ def test_Array_temperature_missing_parameters(model, keys):
array.temperature_model_parameters = params
with pytest.raises(KeyError, match=match):
array.get_cell_temperature(irrads, temps, winds, model)


def test_nonuniform_irradiance_loss():
"""tests pvsystem.nonuniform_irradiance_loss"""
premise_rmads = np.array([0.0, 0.05, 0.1, 0.15, 0.2, 0.25])
expected_mms = np.array([0, 0.012925, 0.0397, 0.080325, 0.1348, 0.203125])
result_mms = pvsystem.nonuniform_irradiance_loss(premise_rmads)
assert_allclose(result_mms, expected_mms, atol=1e-5)

# test datatypes Series IO
result_mms = pvsystem.nonuniform_irradiance_loss(pd.Series(premise_rmads))
assert isinstance(result_mms, pd.Series)
Loading