-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add partial shading example using new reverse bias functionality #968
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
Conversation
) | ||
vd = np.linspace(0.99*kwargs['breakdown_voltage'], v_oc, ivcurve_pnts) | ||
|
||
ivcurve_i, ivcurve_v, _ = singlediode.bishop88(vd, *sde_args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative is to use singlediode.bishop88_i_from_v
, which accepts the cell voltage rather than the diode voltage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I admit I didn't think carefully about this line. What is the reasoning to use one over the other in this context? Strictly speaking, is the breakdown voltage a cell voltage or a diode voltage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breakdown voltage is compared with diode (or junction) voltage. Cell voltage is after series resistance etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, should have been more clear -- I'm on board with breakdown voltage being related to the junction rather than the cell as a whole, but I was referring to the "breakdown voltage" value that would be included in a cell parameter dictionary. If it is inferred from measured IV curves and not adjusted for the series resistance voltage drop, it would be a cell voltage no? Not that it matters here, just curious for myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is inferred from measured IV curves
I believe this is the case.
and not adjusted for the series resistance voltage drop, it would be a cell voltage no?
That probably depends on how the value was extracted from the data. If the value was extracted by fitting the single diode equation including the reverse bias term, then the parameter should be viewed as a junction voltage.
return f_interp(i) | ||
|
||
|
||
def combine(dfs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some code to submit to pvlib.ivtools
that will include a function add_series
.
The calculation process looks correct to me. If you have the enthusiasm for it, a plot of one of the IV curves would be interesting. You might also consider accounting for a bypass diode on the modeled string. |
Have you considered using from scipy.constants import e as qe, k as kB
>>> qe
# 1.602176634e-19
>>>: kB
# 1.380649e-23 Alternately, you can take the temperature insensitive approximation and just keep the thermal voltage (Vth) at 26[mV]. Even though Vth depends on temperature, the diode equation itself is much less sensitive to Vth than it is the cubic temperature dependence of the dark current I0. IMHO the temperature dependence of Vth is misleading to new PV students and leads them in the wrong direction because it's effect is opposite that of I0. |
|
||
kb = 1.380649e-23 # J/K | ||
qe = 1.602176634e-19 # C | ||
Vth = kb * (273.15+25) / qe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
units of V
for thermal voltage to be consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also maybe giving charge in units of Joules per volt [J/V]
makes this conversion more intuitive to the reader?
Indeed -- that module has 12 cells per column and is 10% shaded, so the bottom row of cells is fully shaded and the second row is only partially shaded. Probably worth an explanation in the text. PS thanks for these wonderful and extensive comments! I will go through them tonight and make updates. |
nrow = cells_per_string//2 | ||
nrow_full_shade = int(shaded_fraction * nrow) | ||
# find the fraction of shade in the border row | ||
partial_shade_fraction = 1 - (shaded_fraction * nrow - nrow_full_shade) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might like the numpy.divmod
returns the floor-like quotient and remainder, altho maybe not here?
nrow_full_shade, partial_shade_fraction = np.divmod(shaded_fraction, 1/nrow)
partial_shade_fraction = 1 - nrow*partial_shade_fraction
Thanks again for the reviews @mikofski and @cwhanse. I very much apologize for this bypass diode fiasco -- I was focused on max power only and since the shading was uniform, I didn't bother including them. Had I known that it would prompt such a strong reverse-bias review response, I'd have certainly included them from the start 😉 I think I've addressed most of the points, but I'm uncertain about these two:
I'll fix the lint issues on the next update. |
I think it's a good idea to state the cell temperature you assume and then calculate the thermal voltage rather than assume a thermal voltage.
|
@cwhanse I tried out switching to |
Newton will be a little faster than Brent because it is vectorised (operates on arrays), whereas Brent loops over the sequence. There is an unspoken goal to replace the Python-loop Brent method with a Cythonized no-GIL method using |
Yes. Too bad that the runtime hit is that large. I do think that specifying cell rather than diode voltage is more familiar to most users, which is why I suggested using |
Unless someone else wants to make a stab at it, I will try to make a PR for the cythonized version of Brent soonish. It should greatly improve the performance, benchmarks were between 10-100x faster than |
@mikofski FYI I was actually using the newton method because brentq doesn't work with reverse bias. Per the bishop88_i_from_v docstring:
I'm not against speeding up brentq, just wanted to point out that I don't think it would help this example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).I was checking out the new reverse bias functionality to teach myself about cell-level modeling and thought it might make a good example. Here is the first pass. In addition to whether people think this is a good addition to the example gallery, I'd also be interested in any feedback about the validity of the approach in general just for my own learning.
Built version: https://pvlib-python--968.org.readthedocs.build/en/968/auto_examples/plot_partial_module_shading_simple.html