You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Single diode model helper function to wrap Lambert w and other methods #410
It appears that singlediode() does not expose a way to compute i-from-v at an arbitrary array of v. One would use i_from_v() for that. Also, singlediode() makes a choice for i_from_v(), v_from_i(), and the maximum power computation.
Also, I have vectorized max power and fill factor functions that I think can be very useful for plotting max power and ff as a function of temperature and/or photocurrent, for example.
I think this will first and foremost require some careful thinking about what the current API definition is and what we want it to be going forward with alternative implementations.
Sent from my iPhone
On Jan 29, 2018, at 4:49 PM, Mark Campanelli <notifications@github.com<mailto:notifications@github.com>> wrote:
It appears that singlediode() does not expose a way to compute i-from-v at an arbitrary array of v. One would use i_from_v() for that. Also, singlediode() makes a choice for i_from_v(), v_from_i(), and the maximum power computation.
Also, I have vectorized max power and fill factor functions that I think can be very useful for plotting max power and ff as a function of temperature and/or photocurrent, for example.
I think this will first and foremost require some careful thinking about what the current API definition is and what we want it to be going forward with alternative implementations.
-
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#410 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AFJNLzHXrvN9cs_hGI88KWWjylUT5Nfbks5tPeh-gaJpZM4RwCs->.
I'd really like to know where pandas support starts and ends in the API. I was told earlier that I didn't need to match output to pandas input in i_from_v() and v_from_i(). I realize folks love pandas, but it's hard enough just wrangling numpy types into some sort of consistency (esp. python scalar vs. numpy scalar vs. dim-0 array vs. dimensioned array)!
The rule of thumb is pandas in, pandas out. Beyond that, I'd just say don't remove pandas consistency from functions that do already support it. *_from_* does not, singlediode does.
I'm guessing that most users would consider pandas consistency to be more important than numpy type consistency.
Thanks. I think the i_from_v() and v_from_i() docstrings indicate that pandas.Series are ok inputs, but won't be the output. I propose removing that promise on the inputs and leave it to higher level functions.
In general, it's ok with me to remove it as a promise on the inputs of a function if it's not also a promise on the outputs. In most cases I think it's much better to have a feature that only supports numpy than a feature that doesn't exist.
✔️ the Ix and Ixx values are returned using any method: ('lambertw', 'fast', default: 'gold')
Exact expressions for gradients from bishop88(gradients=True)
✔️ both dynamic resistances: dI/dV @ (V, I) = (0, Isc), and dI/dV @ (V, I) = (Voc, 0) can both be evaluated using exact expressions from pvsystem.bishop88(gradients=True):
>>> from pvlib import pvsystem
>>> IL, I0, Rs, Rsh, nNsVth = (7, 6e-7, .1, 20, .5)
>>> out = singlediode(IL, I0, Rs, Rsh, nNsVth)
>>> vd_sc = out['i_sc']*Rs # diode voltage at short circuit
>>> short_circuit = bishop88(vd_sc, IL, I0, Rs, Rsh, nNsVth, gradients=True)
>>> short_circuit
(6.965172322158323, # i_sc, idx=0
-9.9920072216264089e-16, # v_sc, idx=1
-6.9596052142878349e-15, # p_sc, idx=2
-0.05000483246177085, # di/dvd, idx=3
1.0050004832461772, # dv/dvd, idx=4
-0.049756028275980489, # di/dv, idx=5
6.965172322158323, # dp/dv, idx=6
-0.1000096649235417) # d2p/dv/dvd, idx=7
>>> grad_sc = short_circuit[5]
>>> -1 / grad_sc
20.098067202095102 # super close to Rsh = 20.
etc.
The important thing to note is that Bishop expected the diode voltage, vd, not the cell voltage, that's how it's explicit, but it's easy to convert between them, and I suppose we could make a conversion method if required:
def diode_voltage(i, v, rs):
"""calculate diode voltage"""
return v + i * rs
def v_from_vd(vd, i, rs):
"""calculate cell voltage from diode voltage"""
return vd - i * rs
So #412 offers alternatives to working with vd. There is some groundwork to do before I would try to add them to pvlib (i.e., #411), but if they test and benchmark well, I will offer them up. Note that the idea in #412 for (1) brentq is to upper bound the 1st quadrant I-V curve with the corresponding ideal-device curve, and (2) newton/halley is to use a partially ideal device as the initial condition (all quadrants). I suspect that (2) may not converge globally, esp. for really poor quality devices. I'd also like to try out numba on both of these methods.
nit: I prefer p_mp and p_mp() for maximum power variable and function-that-computes maximum power names, respectively. Jibes better with i_sc and v_oc in my own mind.
nit: I prefer p_mp and p_mp() for maximum power variable and function-that-computes maximum power names, respectively. Jibes better with i_sc and v_oc in my own mind.
Are you referring to mpp()? The output is alreadyp_mp as you suggest. Personally, I don't think that the function that calculates an output and the output itself should have the same name, unless it's a property, but that's just my opinion. So I'm okay with it as it is. Is that okay with you?
I am starting to feel for sanity sake that we should probably start to think of a class to hold all of these single diode model methods and attributes, but let's save that for another day.
@mikofski @thunderfish24 do you have any updates on this and related issues #409#411? Will and I are campaigning to get pvlib to 0.6.0 and to clear up the backlog of issues and pull requests.
I'm supposed to have a considerable chunk of free time on Saturday, so if all goes well I can address the reviews on PR #426 for issue #411 and it should then be ready to go in. IIRC, #411 has two additional pieces after #426: (1) Adding gold data for Isc, Ix, Pmp, Ixx, and Voc, and (2) Adding unit tests that actually fail if the pvsystem functions don't produce values sufficiently close to the gold values. (A further followup could add logging/tracking of the benchmarks in CI.) Of course, I see no reason that these additional items cannot happen after 0.6.0.
@cwhanse I have been waiting for SciPy pr8357 to merge. It's almost there. The last reviewers remaining issue pr8907 / gh8904 was merged today, coincidentally, I can work on it tomorrow and then we should see vectorized Newton in SciPy-1.2.0 but when will that be released? Is it okay for us to use a vendorized version until SciPy is updated? Or should we do some Numba hack in the meantime? Or just add Bishop explicit method but leave everything else the same. Sorry, I don't have a good answer. I will try to wrap this up as soon as possible
OK if I move _golden_sect_DataFrame to tools.py also? no changes to API. makes it easier to not have circular references. thanks! You'll probably dislike this, but I'm calling that instead of brentq until I get scipy/scipy#8431
Activity
markcampanelli commentedon Jan 29, 2018
It appears that
singlediode()does not expose a way to compute i-from-v at an arbitrary array of v. One would use i_from_v() for that. Also, singlediode() makes a choice for i_from_v(), v_from_i(), and the maximum power computation.Also, I have vectorized max power and fill factor functions that I think can be very useful for plotting max power and ff as a function of temperature and/or photocurrent, for example.
I think this will first and foremost require some careful thinking about what the current API definition is and what we want it to be going forward with alternative implementations.
cwhanse commentedon Jan 29, 2018
wholmgren commentedon Jan 30, 2018
Makes sense to me. We can do this without any breaking API changes, right?
mikofski commentedon Jan 30, 2018
Yes, that's my view - the api will remain the same. Is it okay to make
bishop88and it's relatedi_from_v,v_from_i, etc. methods the defaults?wholmgren commentedon Jan 30, 2018
I need to review the paper and probably see a clean PR before I can recommend a default.
add numeric type to args in docstrings
markcampanelli commentedon Jan 31, 2018
I'd really like to know where pandas support starts and ends in the API. I was told earlier that I didn't need to match output to pandas input in i_from_v() and v_from_i(). I realize folks love pandas, but it's hard enough just wrangling numpy types into some sort of consistency (esp. python scalar vs. numpy scalar vs. dim-0 array vs. dimensioned array)!
wholmgren commentedon Jan 31, 2018
The rule of thumb is pandas in, pandas out. Beyond that, I'd just say don't remove pandas consistency from functions that do already support it.
*_from_*does not,singlediodedoes.I'm guessing that most users would consider pandas consistency to be more important than numpy type consistency.
markcampanelli commentedon Jan 31, 2018
Thanks. I think the i_from_v() and v_from_i() docstrings indicate that pandas.Series are ok inputs, but won't be the output. I propose removing that promise on the inputs and leave it to higher level functions.
wholmgren commentedon Jan 31, 2018
In general, it's ok with me to remove it as a promise on the inputs of a function if it's not also a promise on the outputs. In most cases I think it's much better to have a feature that only supports numpy than a feature that doesn't exist.
markcampanelli commentedon Jan 31, 2018
@mikofski Note the above pandas support discussion for #409.
markcampanelli commentedon Jan 31, 2018
@wholmgren Is numba used in pvlib-python yet? If not, then are there remaining blockers to using it?
wholmgren commentedon Jan 31, 2018
@thunderfish24 yes, numba can be used in solar position calculations. See spa.py and get_solarposition(method='nrel_numba').
10 remaining items
mikofski commentedon Feb 1, 2018
✔️ the Ix and Ixx values are returned using any method: (
'lambertw','fast', default:'gold')Exact expressions for gradients from
bishop88(gradients=True)✔️ both dynamic resistances: dI/dV @ (V, I) = (0, Isc), and dI/dV @ (V, I) = (Voc, 0) can both be evaluated using exact expressions from
pvsystem.bishop88(gradients=True):etc.
The important thing to note is that Bishop expected the diode voltage,
vd, not the cell voltage, that's how it's explicit, but it's easy to convert between them, and I suppose we could make a conversion method if required:markcampanelli commentedon Feb 1, 2018
So #412 offers alternatives to working with
vd. There is some groundwork to do before I would try to add them to pvlib (i.e., #411), but if they test and benchmark well, I will offer them up. Note that the idea in #412 for (1) brentq is to upper bound the 1st quadrant I-V curve with the corresponding ideal-device curve, and (2) newton/halley is to use a partially ideal device as the initial condition (all quadrants). I suspect that (2) may not converge globally, esp. for really poor quality devices. I'd also like to try out numba on both of these methods.nit: I prefer p_mp and p_mp() for maximum power variable and function-that-computes maximum power names, respectively. Jibes better with i_sc and v_oc in my own mind.
mikofski commentedon Feb 1, 2018
Are you referring to
mpp()? The output is alreadyp_mpas you suggest. Personally, I don't think that the function that calculates an output and the output itself should have the same name, unless it's a property, but that's just my opinion. So I'm okay with it as it is. Is that okay with you?I am starting to feel for sanity sake that we should probably start to think of a class to hold all of these single diode model methods and attributes, but let's save that for another day.
cwhanse commentedon Feb 1, 2018
Agree with the class idea, but not now. I suspect it will break the current API.
cwhanse commentedon Jun 13, 2018
@mikofski @thunderfish24 do you have any updates on this and related issues #409 #411? Will and I are campaigning to get pvlib to 0.6.0 and to clear up the backlog of issues and pull requests.
markcampanelli commentedon Jun 14, 2018
I'm supposed to have a considerable chunk of free time on Saturday, so if all goes well I can address the reviews on PR #426 for issue #411 and it should then be ready to go in. IIRC, #411 has two additional pieces after #426: (1) Adding gold data for Isc, Ix, Pmp, Ixx, and Voc, and (2) Adding unit tests that actually fail if the
pvsystemfunctions don't produce values sufficiently close to the gold values. (A further followup could add logging/tracking of the benchmarks in CI.) Of course, I see no reason that these additional items cannot happen after 0.6.0.mikofski commentedon Jun 14, 2018
@cwhanse I have been waiting for SciPy pr8357 to merge. It's almost there. The last reviewers remaining issue pr8907 / gh8904 was merged today, coincidentally, I can work on it tomorrow and then we should see vectorized Newton in SciPy-1.2.0 but when will that be released? Is it okay for us to use a vendorized version until SciPy is updated? Or should we do some Numba hack in the meantime? Or just add Bishop explicit method but leave everything else the same. Sorry, I don't have a good answer. I will try to wrap this up as soon as possible
wholmgren commentedon Jun 14, 2018
I recommend copying the vectorized newton function into
_tools.pyfor now.mikofski commentedon Jun 27, 2018
@wholmgren you mean
tools.pyno underscore right?wholmgren commentedon Jun 27, 2018
Yes. But I think the function should be private.
mikofski commentedon Jun 27, 2018
OK if I move
_golden_sect_DataFrametotools.pyalso? no changes to API. makes it easier to not have circular references. thanks! You'll probably dislike this, but I'm calling that instead ofbrentquntil I get scipy/scipy#8431wholmgren commentedon Jun 27, 2018
Sure.
I am confused. What will I dislike? And I thought you were going to use your new vectorized newton for single diode.
mikofski commentedon Jun 27, 2018
#409 is long and convoluted. We agreed in the end to have 3 methods:
ENH: WIP: add methods and tests for a explicit IV curve calculation o…