-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use scipy's find_minimum in lambertw for MPP #2567
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
Changes from 1 commit
0b147e8
480c01b
22d51ee
d65b57f
bc01aa7
ae4346b
1901b20
3dbbefd
30cda13
ef87465
5188ee9
a181438
3657298
11ce601
c62e6d1
ac500d5
4827334
b36b297
edb5535
5c79696
2bdea49
facdd7e
ff20bef
92dcb4d
1d4d40c
75a55f7
a754adf
c748752
c08abb3
9ff3970
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -913,8 +913,28 @@ | |
v_oc = 0. | ||
|
||
# Find the voltage, v_mp, where the power is maximized. | ||
# Start the golden section search at v_oc * 1.14 | ||
p_mp, v_mp = _golden_sect_DataFrame(params, 0., v_oc * 1.14, _pwr_optfcn) | ||
# use scipy.elementwise if available | ||
use_gs = False | ||
try: | ||
from scipy.optimize.elementwise import find_minimum | ||
init = (0., 0.8*v_oc, 1.01*v_oc) | ||
res = find_minimum(_vmp_opt, init, | ||
args=(params['photocurrent'], | ||
params['saturation_current'], | ||
params['resistance_series'], | ||
params['resistance_shunt'], | ||
params['nNsVth'],)) | ||
if res.success.all(): | ||
v_mp = res.x | ||
p_mp = -1.*res.f_x | ||
else: | ||
use_gs = True | ||
|
||
except ModuleNotFoundError: | ||
use_gs = True | ||
|
||
if use_gs: | ||
# gracefully switch to old golden section method | ||
p_mp, v_mp = _golden_sect_DataFrame(params, 0., v_oc * 1.14, _pwr_optfcn) | ||
|
||
# Find Imp using Lambert W | ||
i_mp = _lambertw_i_from_v(v_mp, **params) | ||
|
||
|
@@ -938,6 +958,15 @@ | |
return out | ||
|
||
|
||
def _vmp_opt(v, iph, io, rs, rsh, nNsVth): | ||
''' | ||
Function to find power from ``i_from_v``. | ||
''' | ||
current = _lambertw_i_from_v(v, iph, io, rs, rsh, nNsVth) | ||
|
||
return -v * current | ||
|
||
|
||
def _pwr_optfcn(df, loc): | ||
''' | ||
Function to find power from ``i_from_v``. | ||
|
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.
Just curious... I wonder if anyone knows why
1.14
is the magic number. I see it goes back to the early early days of pvlib-python.Uh oh!
There was an error while loading. Please reload this page.
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.
That was
1.14 * Voc_ref
, the STC value of Voc. The factor of 1.14 was meant to push the right endpoint out when temperature is lower than STC.In pvlib, v_oc reflects temperature and irradiance. I included
1.01 * v_oc
in case the algorithm needs to start with a negative value of power at the right endpoint, since it is minimizing negative power. Now that I write this, I don't think that's necessary - it is provable that power has a unique maximum betweenv=0
andv=v_oc
.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 was wondering why it is
1.14 * Voc_ref
rather than (for example)1.15 * Voc_ref
or1.13 * Voc_ref
or1.2 * Voc_ref
. Maybe computed from some suitable low temperature and a representative temperature coefficient? Just idle curiosity.