Repository navigation
Description
Bad news. I discovered a major error in the singlediode p_mp calculation: given a time series input, the numerical solver exits if the solution for any single time is within the error tolerance, rather than requiring that the solution for all times be close enough. The error is in this line.
Here's some sample code:
photocurrent = np.linspace(0, 10, 11)
resistance_shunt = 16
resistance_series = 0.094
nNsVth = 0.473
saturation_current = 1.943e-09
sd = pvsystem.singlediode(photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth)
sd['i_mp']
array([ 0. , 0.59453544, 1.56145498, 2.54105091, 3.52353436,
4.50658749, 5.4890739 , 6.47016579, 7.44909413, 8.42504244,
9.39708533])
# change .all() to .any()
pvsystem = reload(pvlib.pvsystem)
sd_any = pvsystem.singlediode(photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth)
sd_any['i_mp']
array([ 0. , 0.54538398, 1.43273966, 2.36328163, 3.29255606,
4.23101358, 5.16177031, 6.09368251, 7.02197553, 7.96846051,
8.88220557])
sd['i_mp']/sd_any['i_mp']
array([ nan, 1.09012266, 1.0898386 , 1.07522137, 1.07015167,
1.06513189, 1.06340917, 1.06178256, 1.06082599, 1.05729864,
1.05796756])
sd['p_mp']/sd_any['p_mp']
array([ nan, 0.98250248, 0.92482996, 0.91242588, 0.91052337,
0.91256532, 0.9165425 , 0.92159883, 0.92731275, 0.93339723,
0.93974898])So the error here is on the order of 5 to 10%, but the results will depend on your exact input.
The blue dots on the IV curve below show the p_mp points in the old code. The black dots show the p_mp points in fixed code. These IV curves are generated using a fix for #83 that I'll make a PR for soon. They're also what led me to discovering the problem.
On a related note, someone should put more effort into verifying that the matlab and python libraries give the same results. Not me.

Activity
jforbess commentedon Jul 21, 2016
Wow. Good catch.
On Wed, Jul 20, 2016 at 4:49 PM, Will Holmgren [email protected]
wrote:
jforbess commentedon Jul 21, 2016
Also, will this fix trigger a new release 0.3.4? Seems pretty important.
On Thu, Jul 21, 2016 at 9:39 AM, Jessica Forbess [email protected] wrote:
wholmgren commentedon Jul 21, 2016
I want to release 0.4 next week, but I am sympathetic to the fact that people may not be happy about dealing with a lot of API changes just so that they can get this fix. So, I figured that I'd wait to see if anyone requested it.
jforbess commentedon Jul 21, 2016
Ok. I have a project I'm dealing with this week, but I can make the
individual fix myself. I didn't realize 0.4.0 was so close. I can accept
the API changes as well as the fix, so I'll let others request if they need
it.
On Thu, Jul 21, 2016 at 10:05 AM, Will Holmgren [email protected]
wrote:
cwhanse commentedon Jul 21, 2016
Will,
I'll take this on - test case for single diode functions.
Can you point me to an example of a test implemented as you like it?
Cliff
Sent from my iPhone
On Jul 20, 2016, at 5:49 PM, Will Holmgren <[email protected]mailto:[email protected]> wrote:
Bad news. I discovered a major error in the singlediode p_mp calculation: given a time series input, the numerical solver exits if the solution for any single time is within the error tolerance, rather than requiring that the solution for all times be close enough. The error is in this linehttps://github.com/pvlib/pvlib-python/blob/5218c9d3dd2d5a4e410140de3180b7ef00e8b1ee/pvlib/pvsystem.py#L1728.
Here's some sample code:
photocurrent = np.linspace(0, 10, 11)
resistance_shunt = 16
resistance_series = 0.094
nNsVth = 0.473
saturation_current = 1.943e-09
sd = pvsystem.singlediode(photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth)
sd['i_mp']
array([ 0. , 0.59453544, 1.56145498, 2.54105091, 3.52353436,
4.50658749, 5.4890739 , 6.47016579, 7.44909413, 8.42504244,
9.39708533])
change .all() to .any()
pvsystem = reload(pvlib.pvsystem)
sd_any = pvsystem.singlediode(photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth)
sd_any['i_mp']
array([ 0. , 0.54538398, 1.43273966, 2.36328163, 3.29255606,
4.23101358, 5.16177031, 6.09368251, 7.02197553, 7.96846051,
8.88220557])
sd['i_mp']/sd_any['i_mp']
array([ nan, 1.09012266, 1.0898386 , 1.07522137, 1.07015167,
1.06513189, 1.06340917, 1.06178256, 1.06082599, 1.05729864,
1.05796756])
So the error here is on the order of 5 to 10%, but the results will depend on your exact input.
The blue dots on the IV curve below show the p_mp points in the old code. The black dots show the p_mp points in fixed code. These IV curves are generated using a fix for #83#83 that I'll make a PR for soon. They're also what led me to discovering the problem.
[ivcurves]https://cloud.githubusercontent.com/assets/4383303/17006598/cedaa96c-4e96-11e6-9e9a-64ed1377536c.png
On a related note, someone should put more effort into verifying that the matlab and python libraries give the same results. Not me.
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com//issues/221, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFJNL8QHFLEBDsIwVzBZAJkVsD2ruKNYks5qXrQLgaJpZM4JRUWz.
wholmgren commentedon Jul 22, 2016
Thanks, Cliff.
You could base your test on the example above, but you probably don't need as many points.
For slightly more realistic input, you could base your test on something similar to the test suite's test_singlediode_series_ivcurve function.
The function is called with the 'Example_Module' parameters. Note that the numbers above are generated using the corrected solver.