-
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 6 commits
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,23 @@ def _lambertw(photocurrent, saturation_current, resistance_series, | |
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious... I wonder if anyone knows why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was In pvlib, v_oc reflects temperature and irradiance. I included There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering why it is |
||
# use scipy.elementwise if available | ||
# remove try/except when scipy>=1.15, and golden mean is retired | ||
try: | ||
from scipy.optimize.elementwise import find_minimum | ||
init = (0., 0.8*v_oc, v_oc) | ||
res = find_minimum(_vmp_opt, init, | ||
args=(params['photocurrent'], | ||
params['saturation_current'], | ||
params['resistance_series'], | ||
params['resistance_shunt'], | ||
params['nNsVth'],)) | ||
v_mp = res.x | ||
p_mp = -1.*res.f_x | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test failure is because the test expects
We could detect |
||
except ModuleNotFoundError: | ||
# 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 +953,15 @@ def _lambertw(photocurrent, saturation_current, resistance_series, | |
return out | ||
|
||
|
||
def _vmp_opt(v, iph, io, rs, rsh, nNsVth): | ||
''' | ||
Function to find negative of 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``. | ||
|
Uh oh!
There was an error while loading. Please reload this page.