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

Martinez shading factor #2070

Merged
merged 197 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 192 commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
c87885c
Update shading.py
echedey-ls Nov 6, 2023
4fc6cd8
Minimal test
echedey-ls Nov 6, 2023
2a72f33
Implementation
echedey-ls Nov 8, 2023
d6e8067
Fix, fix, fix, fix & format
echedey-ls Nov 8, 2023
13a56d4
Format issues
echedey-ls Nov 8, 2023
f012aae
Extend tests (compare with singleaxis) & format with ruff
echedey-ls Nov 8, 2023
6dd9a3b
Format fixes
echedey-ls Nov 8, 2023
e8743db
Upgrade tests
echedey-ls Nov 9, 2023
6030774
Array -> Axis
echedey-ls Nov 9, 2023
6276382
type
echedey-ls Nov 9, 2023
509699f
Whatsnew
echedey-ls Nov 9, 2023
5ff8fd8
xd
echedey-ls Nov 9, 2023
04126e0
bruh
echedey-ls Nov 9, 2023
607a246
Minor Python optimization a la tracking.singleaxis
echedey-ls Nov 9, 2023
240b551
Comment and minor optimizations
echedey-ls Nov 9, 2023
997def6
Surface -> Axis
echedey-ls Nov 9, 2023
7912055
Elevation -> Zenith
echedey-ls Nov 9, 2023
f068e3e
Elev -> Zenith
echedey-ls Nov 9, 2023
a5f4a85
Update shading.py
echedey-ls Jan 24, 2024
a854e27
Update docstring
echedey-ls Jan 24, 2024
2d82375
Add comments from `tracking.singleaxis`
echedey-ls Jan 24, 2024
5f24721
Singleaxis implementation port & test addition, based on old pvlib.tr…
echedey-ls Jan 25, 2024
049a8cc
Update v0.10.4.rst
echedey-ls Jan 25, 2024
a3185df
Linter
echedey-ls Jan 25, 2024
b9f1a76
Code review
echedey-ls Jan 25, 2024
f7d1d80
Add Fig 5 [1] (still gotta check the built output)
echedey-ls Jan 27, 2024
1880f6a
Add caption, change size and describe in alternate text
echedey-ls Jan 27, 2024
d9f242a
rST fixes ?
echedey-ls Jan 27, 2024
379ca95
Figures have captions, images do not
echedey-ls Jan 27, 2024
62e99ad
Flip arguments order
echedey-ls Feb 8, 2024
4f584ea
I forgot :skull:
echedey-ls Feb 8, 2024
238d123
Linter are you happy now?
echedey-ls Feb 8, 2024
98a254d
Remove port test and add edge cases test
echedey-ls Feb 9, 2024
4616175
Update test_shading.py
echedey-ls Feb 9, 2024
33ffd28
Indentation xd
echedey-ls Feb 9, 2024
8526bc6
Update test_shading.py
echedey-ls Feb 9, 2024
bde3656
I forgot how to code
echedey-ls Feb 9, 2024
51e3750
Align data
echedey-ls Feb 9, 2024
35738a4
Docstring suggestion from Kevin
echedey-ls Feb 27, 2024
8d679c3
Update link to example?
echedey-ls Feb 27, 2024
4a907c1
add linear shade loss for thin films
mikofski May 4, 2023
234288d
add tests, update docs, what's new
mikofski May 4, 2023
fb0e5d1
fix what's new gh issue and pr links
mikofski May 4, 2023
aa4b6e8
fix trailing whitespace
mikofski May 4, 2023
18b2187
responding to comments
mikofski May 6, 2023
4163a72
update docstring for linear shade loss
mikofski May 6, 2023
1ebf8ea
update example in linear_shade_loss
mikofski May 6, 2023
de2144f
add figure and formulas to shaded fraction
mikofski May 6, 2023
6aa43f0
shaded fraction consistently
mikofski May 11, 2023
c34a2f6
Add alternative text to image
echedey-ls Feb 3, 2024
6b9f478
Update implementation based on PSZ PR. See description.
echedey-ls Feb 3, 2024
c3a9569
Whatsnew entries
echedey-ls Feb 3, 2024
4bb02ab
Linter
echedey-ls Feb 3, 2024
78c481e
Clear things, convert Mark's reference to a reference
echedey-ls Feb 4, 2024
0ce0d68
Linter
echedey-ls Feb 4, 2024
74b4215
Update according to changes at PSZA PR
echedey-ls Feb 15, 2024
909cc23
Another commit, another try
echedey-ls Feb 27, 2024
e3e73f6
Ahhh, I rebased too fast
echedey-ls Mar 8, 2024
cbb0b04
whatsnews
echedey-ls Mar 8, 2024
96b61a8
Update v0.10.4.rst
echedey-ls Mar 8, 2024
d2b9291
Update v0.10.3.rst
echedey-ls Mar 8, 2024
7ec4d64
Merge branch 'main' into pr1725-continuation-shaded-fraction-mikofski
echedey-ls Mar 11, 2024
bbc6115
Rename to `shaded_fraction1d`, change params to `surface_*` instead o…
echedey-ls Mar 14, 2024
39a3ba9
Left this tracker refs behind
echedey-ls Mar 14, 2024
a3ccf3e
Change rename in rst entries
echedey-ls Mar 14, 2024
e5fffca
Add another testcase
echedey-ls Mar 14, 2024
457d4b4
Improve docs references, clarify nomenclature
echedey-ls Mar 14, 2024
f11858e
Update test_shading.py
echedey-ls Mar 14, 2024
f321cc1
Merge branch 'main' into linear-shade-mikofski-pr-1725
echedey-ls Mar 24, 2024
0ab3720
Remove linear_shade_loss
echedey-ls Mar 24, 2024
e6da6e8
First implementation of the new shaded fraction model (missing figure)
echedey-ls Mar 28, 2024
4ce1655
Create Anderson_Jensen_2024_Fig3.png
echedey-ls Mar 29, 2024
60b7e2e
Update shading.py
echedey-ls Mar 29, 2024
2d23cb2
Update shading.py
echedey-ls Mar 29, 2024
78a451c
Update shading.py
echedey-ls Apr 1, 2024
28128f6
lintaaargggg
echedey-ls Apr 1, 2024
f4acf39
Fill reference
echedey-ls Apr 2, 2024
104d185
Next release 0.10.5?
echedey-ls Apr 2, 2024
894ff9f
Fix tests
echedey-ls Apr 5, 2024
f147881
Update test_shading.py
echedey-ls Apr 5, 2024
4d11294
Little improvement to table definitions
echedey-ls Apr 10, 2024
69c76cf
Change `l` to `\ell`
echedey-ls Apr 15, 2024
758f5e7
`pvlib.tracking.projected_solar_zenith_angle` to `pvlib.shading.proje…
echedey-ls Apr 15, 2024
6882dfa
pitch references to `pitch`
echedey-ls Apr 15, 2024
4ef4567
`trackers_axis_azimuth` to `axis_azimuth`
echedey-ls Apr 15, 2024
574a1a2
whatsnews
echedey-ls Apr 15, 2024
efac0b3
Update v0.10.5.rst
echedey-ls Apr 15, 2024
3a726b8
Change `tilt`s to `rotation`s and add `axis_tilt`
echedey-ls Apr 15, 2024
300b912
Forgot to update tests :skull:
echedey-ls Apr 15, 2024
497a62e
Merge branch 'main' into terrain-slope-mikofski-pr-1725
echedey-ls Apr 15, 2024
2a34f43
Merge branch 'main' into pr1725-continuation-shaded-fraction-mikofski
echedey-ls Apr 16, 2024
c1b3978
Add examples section
echedey-ls Apr 16, 2024
db8edd6
roles assumption messin w/ me docs :astonished:
echedey-ls Apr 21, 2024
d65e64d
roles assumption messin w/ me docs :astonished:
echedey-ls Apr 21, 2024
51a2dfa
Merge branch 'pr1725-continuation-shaded-fraction-mikofski' of https:…
echedey-ls Apr 22, 2024
9038097
Update shading.py
echedey-ls Apr 22, 2024
5652801
Update shading.py
echedey-ls Apr 23, 2024
31affba
Add gallery example
echedey-ls Apr 23, 2024
80ab494
This was fixed in recent sphinx-gallery releases IIRC
echedey-ls Apr 23, 2024
facde21
Extra empty line or admonition type unsupported
echedey-ls Apr 23, 2024
5a807b7
Fix example link (hopefully :pray: )
echedey-ls Apr 23, 2024
25a0f19
Update shading.py
echedey-ls Apr 23, 2024
8bdd469
Fix subsubsections?
echedey-ls Apr 24, 2024
a2e8be7
Nah, bulleted list didn't work
echedey-ls Apr 24, 2024
9f1fa97
tilted -> tracker, only affects text
echedey-ls Apr 24, 2024
37ab496
Typos and unreasonable physical values
echedey-ls Apr 24, 2024
6303583
See the Examples section below, not the unlinkable link
echedey-ls Apr 24, 2024
e785292
tracker -> row, param names, code and docs
echedey-ls Apr 24, 2024
9b98d9e
Fix broken example :wrench:
echedey-ls Apr 26, 2024
3726e4d
Apply suggestions from code review
echedey-ls May 23, 2024
4e7e36f
"the row axis/axes" instead of ``axis_azimuth``
echedey-ls May 23, 2024
59465c8
Unnecessary math mode
echedey-ls May 23, 2024
9fa2bb4
Example suggestions and text trimming
echedey-ls May 23, 2024
1be1d3e
Merge branch 'main' into terrain-slope-mikofski-pr-1725
echedey-ls May 23, 2024
0d521ee
whatsmes
echedey-ls May 23, 2024
f01bd6f
Add test to fix coverage issue
echedey-ls May 23, 2024
28f8bb4
Initial work
echedey-ls Apr 7, 2024
6d1755e
Can't test with the paper data, wtf
echedey-ls Apr 7, 2024
60030ca
Little things
echedey-ls Apr 13, 2024
6dcb517
Update plot_martinez_shade_loss.py
echedey-ls Apr 13, 2024
55b89bc
More improvements
echedey-ls Apr 17, 2024
fd4eded
Be4 rebase
echedey-ls Apr 17, 2024
b640c24
Fix fixture
echedey-ls Apr 17, 2024
ba15ab1
Initial work
echedey-ls Apr 7, 2024
beee0f1
Fix tests
echedey-ls Apr 18, 2024
56a4f46
docstring
echedey-ls Apr 18, 2024
7a57310
whatsnew :pencil:
echedey-ls Apr 18, 2024
adf6dcc
Minor thingies
echedey-ls Apr 18, 2024
ec717a9
Add figure, improve docs :100:
echedey-ls Apr 18, 2024
a357c11
Fix silently ignoring file path in `pvsystem.retrieve_sam` when `name…
echedey-ls May 1, 2024
de46cc0
Fix Ixx equation in pvsystem.sapm (#2019)
cwhanse May 2, 2024
1d5a9e6
Increase python requirement to >= 3.8 (#2029)
kandersolar May 3, 2024
cdb50ba
Finalize 0.10.5 (#2035)
kandersolar May 6, 2024
d697e76
update whatsnews
echedey-ls May 23, 2024
bc8598e
Update test_shading.py
echedey-ls May 23, 2024
6153c46
Merge branch 'main' into martinez-shading-factor
echedey-ls May 27, 2024
bc79bb8
Example
echedey-ls May 27, 2024
74e1e44
Fix whatsmes
echedey-ls May 28, 2024
76eb1ca
Update v0.11.0.rst
echedey-ls May 28, 2024
6db8f7c
other img
echedey-ls May 28, 2024
8db5e55
lintarrrrrr :sob:
echedey-ls May 28, 2024
b4d255b
docs
echedey-ls May 28, 2024
5e0677c
docs refurbishment
echedey-ls May 28, 2024
2e52cf9
Update plot_martinez_shade_loss.py
echedey-ls May 28, 2024
847ae5c
Fix parameter names
echedey-ls Jun 2, 2024
19734dc
More explicit 2D shaded fraction
echedey-ls Jun 2, 2024
da32fd3
Explicitier explicit
echedey-ls Jun 2, 2024
cc7ce5d
Update shading.py
echedey-ls Jun 3, 2024
15ec5c4
Only if life was VCS to revert my errors so easily
echedey-ls Jun 3, 2024
610fd97
Nix image in docstring
echedey-ls Jun 3, 2024
d6430bb
Clear-up irrdiance loss, not pwr loss - yet again
echedey-ls Jun 3, 2024
161f828
rewording
echedey-ls Jun 3, 2024
bccd3da
Remove figure of junction boxes in example
echedey-ls Jun 3, 2024
0f2fb31
Duplicated singleaxis call
echedey-ls Jun 3, 2024
48be1c8
When did I change this?
echedey-ls Jun 3, 2024
6f2ed39
Rename function
echedey-ls Jun 3, 2024
9d5c918
Make times just one statement
echedey-ls Jun 3, 2024
c54020a
Fix uncomplete example in docstring
echedey-ls Jun 3, 2024
6116c64
flake is a snowflake :snowflake:
echedey-ls Jun 3, 2024
b20b9cc
Delete Centralized_and_split_PV_junction_boxes_cesardd.jpg
echedey-ls Jun 3, 2024
9b84ed5
Remove example description
echedey-ls Jun 3, 2024
b20c535
Change example title
echedey-ls Jun 3, 2024
820ffbf
Ints for number of blocks
echedey-ls Jun 3, 2024
46df544
Rephrasing of shaded fraction 2D
echedey-ls Jun 3, 2024
d3343a5
Merge branch 'main' into martinez-shading-factor
echedey-ls Jun 11, 2024
d7a5cad
typo
echedey-ls Jun 12, 2024
6e030aa
Code review from Ioannis
echedey-ls Jun 12, 2024
b0b4e7c
no more noqa e501
echedey-ls Jun 12, 2024
dee5d49
Will this work to hide code?
echedey-ls Jun 12, 2024
14fe993
Update plot_martinez_shade_loss.py
echedey-ls Jun 12, 2024
94c2d23
play time with the matplotlib statements
echedey-ls Jun 12, 2024
e70090f
This fixes it (I believe :pray: )
echedey-ls Jun 12, 2024
69e6771
Update plot_martinez_shade_loss.py
echedey-ls Jun 12, 2024
dc4fbc0
Nah, let's see how this does
echedey-ls Jun 12, 2024
b071ba4
Revert attempt to colapse code
echedey-ls Jun 12, 2024
5cd4f9b
Merge branch 'main' into martinez-shading-factor
echedey-ls Jun 14, 2024
192a039
Power losses model
echedey-ls Jun 15, 2024
91862f5
equations rendering
echedey-ls Jun 15, 2024
c444639
Merge branch 'main' into martinez-shading-factor
echedey-ls Jun 17, 2024
48a9004
Change `poa_direct_and_circumsolar` to `poa_direct`
echedey-ls Jun 17, 2024
e4076f7
Merge branch 'martinez-shading-factor' of https://github.com/echedey-…
echedey-ls Jun 17, 2024
9da4834
Example link
echedey-ls Jun 18, 2024
6ef91b8
`power_loss` -> `loss_fraction`
echedey-ls Jun 18, 2024
37d4ca0
Typo when applying Ioannis suggestion
echedey-ls Jun 18, 2024
329fe23
Re-arrange POA to its own section in example
echedey-ls Jun 18, 2024
cf9acec
Mis-redaction in normal/half-cut modules comparison
echedey-ls Jun 18, 2024
8180654
Add edge cases
echedey-ls Jun 18, 2024
874c0a4
Link yet again
echedey-ls Jun 18, 2024
46cedd8
Fix link for sure
echedey-ls Jun 18, 2024
954b05f
Remove critical error from docs build
echedey-ls Jun 18, 2024
00f1eff
Apply suggestions from code review (Cliff)
echedey-ls Jun 18, 2024
ec3931f
Linter
echedey-ls Jun 18, 2024
8ed87b6
Apply suggestions from Adam
echedey-ls Jun 20, 2024
da0b75d
Merge branch 'main' into martinez-shading-factor
echedey-ls Jun 20, 2024
95769bf
Rewording from code review
echedey-ls Jun 20, 2024
8841020
More unitless
echedey-ls Jun 20, 2024
9483fda
Apply suggestions from Cliff
echedey-ls Jun 20, 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
276 changes: 276 additions & 0 deletions docs/examples/shading/plot_martinez_shade_loss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
"""
Modelling shading losses in modules with bypass diodes
======================================================
"""

# %%
# This example illustrates how to use the model proposed by Martinez et al.
# [1]_. The model proposes a power output losses factor by adjusting
echedey-ls marked this conversation as resolved.
Show resolved Hide resolved
# the incident direct and circumsolar beam irradiance fraction of a PV module
# based on the number of shaded *blocks*. A *block* is defined as a group of
# cells protected by a bypass diode. More information on *blocks* can be found
# in the original paper [1]_ and in the
# :py:func:`pvlib.shading.direct_martinez` documentation.
#
# The following key functions are used in this example:
#
# 1. :py:func:`pvlib.shading.direct_martinez` to calculate the power output
# losses fraction due to shading.
# 2. :py:func:`pvlib.shading.shaded_fraction1d` to calculate the fraction of
# shaded surface and consequently the number of shaded *blocks* due to
# row-to-row shading.
# 3. :py:func:`pvlib.tracking.singleaxis` to calculate the rotation angle of
# the trackers.
#
# .. sectionauthor:: Echedey Luis <echelual (at) gmail.com>
#
# Problem description
# -------------------
# Let's consider a PV system with the following characteristics:
#
# - Two north-south single-axis trackers, each one having 6 modules.
# - The rows have the same true-tracking tilt angles. True tracking
# is chosen in this example, so shading is significant.
# - Terrain slope is 7 degrees downward to the east.
# - Rows' axes are horizontal.
echedey-ls marked this conversation as resolved.
Show resolved Hide resolved
# - The modules are comprised of multiple cells. We will compare these cases:
# - modules with one bypass diode
# - modules with three bypass diodes
# - half-cut cell modules with three bypass diodes on portrait and landscape
echedey-ls marked this conversation as resolved.
Show resolved Hide resolved
#
# Setting up the system
# ----------------------
# Let's start by defining the system characteristics, location and the time
# range for the analysis.

import pvlib
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.dates import ConciseDateFormatter

pitch = 4 # meters
width = 1.5 # meters
gcr = width / pitch # ground coverage ratio
N_modules_per_row = 6
axis_azimuth = 180 # N-S axis
axis_tilt = 0 # flat because the axis is perpendicular to the slope
cross_axis_tilt = -7 # 7 degrees downward to the east

latitude, longitude = 40.2712, -3.7277
locus = pvlib.location.Location(
latitude,
longitude,
tz="Europe/Madrid",
altitude=pvlib.location.lookup_altitude(latitude, longitude),
)

times = pd.date_range("2001-04-11T04", "2001-04-11T20", freq="10min")

# %%
# True-tracking algorithm and shaded fraction
# -------------------------------------------
# Since this model is about row-to-row shading, we will use the true-tracking
# algorithm to calculate the trackers rotation. Back-tracking reduces the
# shading between rows, but since this example is about shading, we will not
# use it.
echedey-ls marked this conversation as resolved.
Show resolved Hide resolved
#
# Then, the next step is to calculate the fraction of shaded surface. This is
# done using :py:func:`pvlib.shading.shaded_fraction1d`. Using this function is
# straightforward with the variables we already have defined.
# Then, we can calculate the number of shaded blocks by rounding up the shaded
# fraction by the number of blocks along the shaded length.

# Calculate solar position to get single-axis tracker rotation and irradiance
solar_pos = locus.get_solarposition(times)
solar_apparent_zenith, solar_azimuth = (
solar_pos["apparent_zenith"],
solar_pos["azimuth"],
) # unpack for better readability

tracking_result = pvlib.tracking.singleaxis(
apparent_zenith=solar_apparent_zenith,
apparent_azimuth=solar_azimuth,
axis_tilt=axis_tilt,
axis_azimuth=axis_azimuth,
max_angle=(-90 + cross_axis_tilt, 90 + cross_axis_tilt), # (min, max)
backtrack=False,
gcr=gcr,
cross_axis_tilt=cross_axis_tilt,
)

tracker_theta, aoi, surface_tilt, surface_azimuth = (
tracking_result["tracker_theta"],
tracking_result["aoi"],
tracking_result["surface_tilt"],
tracking_result["surface_azimuth"],
) # unpack for better readability

# Calculate the shade fraction
shaded_fraction = pvlib.shading.shaded_fraction1d(
solar_apparent_zenith,
solar_azimuth,
axis_azimuth,
axis_tilt=axis_tilt,
shaded_row_rotation=tracker_theta,
shading_row_rotation=tracker_theta,
collector_width=width,
pitch=pitch,
cross_axis_slope=cross_axis_tilt,
)

# %%
# Number of shaded blocks
# -----------------------
# The number of shaded blocks depends on the module configuration and number
# of bypass diodes. For example,
# modules with one bypass diode will behave like one block.
# On the other hand, modules with three bypass diodes will have three blocks,
# except for the half-cut cell modules, which will have six blocks; 2x3 blocks
# where the two rows are along the longest side of the module.
# We can argue that the dimensions of the system change when you switch from
# portrait to landscape, but for this example, we will consider it the same.
#
# The number of shaded blocks is calculated by rounding up the shaded fraction
# by the number of blocks along the shaded length. So let's define the number
# of blocks for each module configuration:
#
# - 1 bypass diode: 1 block
# - 3 bypass diodes: 3 blocks in landscape; 1 in portrait
# - 3 bypass diodes half-cut cells:
# - 2 blocks in portrait
# - 3 blocks in landscape
#
# .. figure:: ../../_images/PV_module_layout_cesardd.jpg
# :align: center
# :width: 75%
# :alt: Normal and half-cut cells module layouts
#
# Left: common module layout. Right: half-cut cells module layout.
# Each module has three bypass diodes. On the left, they connect cell
# columns 1-2, 2-3 & 3-4. On the right, they connect cell columns 1-2, 3-4 &
# 5-6.
# *Source: César Domínguez. CC BY-SA 4.0, Wikimedia Commons*
#
# In the image above, each orange U-shaped string section is a block.
# By symmetry, the yellow inverted-U's of the subcircuit are also blocks.
# For this reason, the half-cut cell modules have 6 blocks in total: two along
# the longest side and three along the shortest side.

blocks_per_module = {
"1 bypass diode": 1,
"3 bypass diodes": 3,
"3 bypass diodes half-cut, portrait": 2,
"3 bypass diodes half-cut, landscape": 3,
}

# Calculate the number of shaded blocks during the day
shaded_blocks_per_module = {
k: np.ceil(blocks_N * shaded_fraction)
for k, blocks_N in blocks_per_module.items()
}

# %%
# Plane of array irradiance example data
# --------------------------------------
# To calculate the power output losses due to shading, we need the plane of
# array irradiance. For this example, we will use synthetic data:

clearsky = locus.get_clearsky(
times, solar_position=solar_pos, model="ineichen"
)
dhi, dni = (
clearsky["dhi"],
clearsky["dni"],
)
dni_extra = pvlib.irradiance.get_extra_radiation(times)
airmass = pvlib.atmosphere.get_relative_airmass(solar_apparent_zenith)
sky_diffuse = pvlib.irradiance.perez_driesse(
surface_tilt, surface_azimuth, dhi, dni,
solar_apparent_zenith, solar_azimuth, dni_extra, airmass,
) # fmt: skip
poa_components = pvlib.irradiance.poa_components(
aoi, dni, sky_diffuse, poa_ground_diffuse=0
echedey-ls marked this conversation as resolved.
Show resolved Hide resolved
) # ignore ground diffuse for brevity
poa_global, poa_direct = (
poa_components["poa_global"],
poa_components["poa_direct"],
)

# %%
# Results
# -------
# Now that we have the number of shaded blocks for each module configuration,
# we can apply the model and estimate the power loss due to shading.
#
# Note that this model is not linear with the shaded blocks ratio, so there is
# a difference between applying it to just a module or a whole row.

shade_losses_per_module = {
k: pvlib.shading.direct_martinez(
poa_global=poa_global,
poa_direct=poa_direct,
shaded_fraction=shaded_fraction,
shaded_blocks=module_shaded_blocks,
total_blocks=blocks_per_module[k],
)
for k, module_shaded_blocks in shaded_blocks_per_module.items()
}

shade_losses_per_row = {
k: pvlib.shading.direct_martinez(
poa_global=poa_global,
poa_direct=poa_direct,
shaded_fraction=shaded_fraction,
shaded_blocks=module_shaded_blocks * N_modules_per_row,
total_blocks=blocks_per_module[k] * N_modules_per_row,
)
for k, module_shaded_blocks in shaded_blocks_per_module.items()
}

# %%
# Plotting the results
# ^^^^^^^^^^^^^^^^^^^^

fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
fig.suptitle("Martinez power losses due to shading")
for k, shade_losses in shade_losses_per_module.items():
linestyle = "--" if k == "3 bypass diodes half-cut, landscape" else "-"
ax1.plot(times, shade_losses, label=k, linestyle=linestyle)
ax1.legend(loc="upper center")
ax1.grid()
ax1.set_xlabel("Time")
ax1.xaxis.set_major_formatter(
ConciseDateFormatter("%H:%M", tz="Europe/Madrid")
)
ax1.set_ylabel(r"$P_{out}$ losses")
ax1.set_title("Per module")

for k, shade_losses in shade_losses_per_row.items():
linestyle = "--" if k == "3 bypass diodes half-cut, landscape" else "-"
ax2.plot(times, shade_losses, label=k, linestyle=linestyle)
ax2.legend(loc="upper center")
ax2.grid()
ax2.set_xlabel("Time")
ax2.xaxis.set_major_formatter(
ConciseDateFormatter("%H:%M", tz="Europe/Madrid")
)
ax2.set_ylabel(r"$P_{out}$ losses")
ax2.set_title("Per row")
fig.tight_layout()
fig.show()

# %%
# Note how the half-cut cell module in portrait performs better than the
# normal module with three bypass diodes. This is because the number of shaded
# blocks is less along the shaded length is higher in the half-cut module.
# This is the reason why half-cut cell modules are preferred in portrait
# orientation.

# %%
# References
# ----------
# .. [1] F. Martínez-Moreno, J. Muñoz, and E. Lorenzo, 'Experimental model
# to estimate shading losses on PV arrays', Solar Energy Materials and
# Solar Cells, vol. 94, no. 12, pp. 2298-2303, Dec. 2010,
# :doi:`10.1016/j.solmat.2010.07.029`.
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 @@ -12,4 +12,4 @@ Shading
shading.sky_diffuse_passias
shading.projected_solar_zenith_angle
shading.shaded_fraction1d

shading.direct_martinez
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 @@ -45,6 +45,9 @@ Enhancements
* Added extraterrestrial and direct spectra of the ASTM G173-03 standard with
the new function :py:func:`pvlib.spectrum.get_reference_spectra`.
(:issue:`1963`, :pull:`2039`)
* Added function :py:func:`pvlib.shading.direct_martinez` to calculate
shading losses by taking into account the amount of bypass diodes of a module.
(:issue:`2063`, :pull:`2070`)

Bug fixes
~~~~~~~~~
Expand Down
Loading
Loading