Uh oh!
There was an error while loading. Please reload this page.
Add "logwright" SDE solver functions - #1884
Conversation
kandersolar
commented
Oct 6, 2023
@cwhanse I wonder if you can provide some insight on the calculation result differences I am seeing, relative to the values from |
cwhanse
commented
Oct 6, 2023
@kandersolar you are plotting Vmp (logWright) - Vmp (lambertw)? What happens if you increase the iterations in |
cwhanse
commented
Oct 6, 2023
The curves in the |
kandersolar
commented
Oct 6, 2023
Yep.
No meaningful change. I also tried switching to scipy's implementation of the Wright Omega function, and no change there either.
Good idea! I will try that. |
kandersolar
commented
Oct 10, 2023
Here is a comparison of the various methods, calculating error relative to the "Case 1" known values in https://github.com/cwhanse/ivcurves/tree/main/ivcurves/test_sets: So newton and brentq do quite well, but the two lambertw-style approaches have some trouble finding the MPP. Putting aside logwright for the moment, I think I have narrowed the MPP issue down to the golden section search function performing poorly at the peak of the P-V curve, which is relatively flat and broad. Specifically, P varies by only an ULP or two (~10^-15) over a voltage range of order 10^-7, so unsurprisingly the golden section search has trouble navigating that region. Here is a plot showing the P-V curve and comparing identified MPPs (horizontal lines show a 1-ULP step, since matplotlib refuses to show tick labels at such a small scale): Just to see if another search method might work better, I swapped scipy's powell in place of our golden section search and got somewhat better convergence in this single example, but still not as good as the bishop/brentq method. I am curious how it is that brentq seems to handle this problem so reliably. Anyway, this is starting to sound like a bug report for |
cwhanse
commented
Oct 10, 2023
Nicely laid out. Your findings are consistent with my own assessments. The lambert W methods find the maximum of the (V, P) curve. The bishop88 methods find the zero of the dP/dV curve. I'm not sure the difference is a bug in the usual sense. When that approach was taken, I'm sure we thought 8 digits of accuracy sufficed, and may not have realized the shortcoming in that approach. |
adriesse
commented
Oct 10, 2023
Interesting observations and discussions! If the blue line above from the precise IV curve, would it be possible to make it even more precise, or perhaps more ideal, by removing the dithering so it steps up on the left and down on the right of Pmp? |
adriesse
commented
Oct 10, 2023
I seem to recall another discussion about (vectorized?) root finding recently, but I can't remember where. Could someone point me to it? |
cwhanse
commented
Oct 10, 2023
kandersolar
commented
Oct 10, 2023
Or #974.
Shame on me for not labeling it! The blue line in that plot was from |
adriesse
commented
Oct 10, 2023
That's the one, thanks! |
mikofski
commented
Oct 11, 2023
there was a similar issue in pvmismatch which was using |
adriesse
commented
Oct 11, 2023
Does the dithering also appear in V and I, or only their product? If only the latter, perhaps there is a way to make a cleaner product? |
echedey-ls
commented
Feb 28, 2024
Mmmm, can I be of help with this PR? I see the discussion revolves around the precision of each algorithm, but that doesn't invalidate the fact that logwright is still faster (if I understood correctly). |
kandersolar
commented
Feb 29, 2024
The convergence error discussed above is large enough to make me uncomfortable, but probably not too large to keep the method from being useful. The other thing is that only the This PR currently shows that the logwright method has promise, but IMHO a short paper defining the complete method and comparing speed+accuracy with other methods needs to be written before this PR gets picked up again. |



docs/sphinx/source/referencefor API changes.docs/sphinx/source/whatsnewfor 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`).remote-data) and Milestone are assigned to the Pull Request and linked Issue.This PR implements two new functions in
pvlib.singlediode:_logwright_v_from_iand_logwright_i_from_v. The reference from #1856 (link) provides thev_from_iequation. I used the same technique to derive thei_from_vequation. I plan to document the equations in oursinglediode.rstpage.The new base functions are then integrated into the rest of the SDE solving machinery. Here are some runtimes for the
pvsystem.i_from_v,v_from_i, andsinglediodefunctions comparingmethod='lambertw'withmethod='logwright':