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
RuntimeError while using the fit_desoto function, caused by optimize.root (SciPy) #1226
Comments
I'm not opposed to adding a kwarg to You could use
Here, I estimated the temperature coefficient of power by assuming that the temperature coefficients for current and voltage at max power are the same as at Isc and Voc, but of course the proper value should be used. The The optimization routines accessed by the pysam package have some built-in intelligence for initial guesses and updating parameters, and are more likely to converge. |
I agree with Cliff, it may be the initial guess, not the solver. But I don't think pvlib-python/pvlib/ivtools/sdm.py Lines 210 to 218 in 50dcc7f
Sometimes I find that restarting the solver with the exit conditions from the last run or with slightly modified initial guess will converge. For example see this discussion: SunPower/PVMismatch#143 I would recommend letting the user override |
I think the first problem in |
similar dialogue over at scipy on similar issue, scipy/scipy#8904 (comment), is it runtime error or warning?
They opted for pvlib-python/pvlib/ivtools/sdm.py Lines 228 to 232 in 5bdad64
so if we change this, then we can get the output of the |
@ cwhanse: Thanks a lot for your contribution. I choosed to go around the fit_desoto function by using the fit_cec_sam_function and it worked out well! Yes, exactly. the problem in the fit desoto function is occuring because optimize_result.success is delivered as false. & Yes, the console gives out a runtime error which causes the programm to cancel, not a warning. |
Hello everyone,
while using the fit_desoto function to estimate parameters for further solar module calculations, I received the following error:
RuntimeError: Parameter estimation failed: The iteration is not making good progress, as measured by the improvement from the last five Jacobian evaluations.
The error comes from the optimize.root function from the SciPy library, which is used within the fit_desoto function.
Even if I use only 1s for the initial values of the fit_desoto function, I get this error.
The code for the function call in the main programm:
self.mp_desoto_fit = pvlib.ivtools.sdm.fit_desoto(v_mp=module['Vmpo'], i_mp=module['Impo'], v_oc=module['Voco'], i_sc=module['Isco'], alpha_sc=module['Aisc'], beta_voc=module['Bvoco'], cells_in_series=module['Cells_in_Series'], EgRef=1.121, dEgdT=-0.0002677, temp_ref=25, irrad_ref=1000, root_kwargs={'options': {'col_deriv': 0, 'xtol': 1.49012e-05, 'maxfev': 0, 'band': None, 'eps': None, 'factor': 100, 'diag': None}})
The root_kwargs in the function call of the fit_desoto function influence the solver of the root function, but different properties for the solver don't fix the problem.
To Reproduce the error
You can easily reproduce the error by simply using the fit_desoto function. It doesn't make a difference if you use concrete values of a photovoltaic cell or just 1s. All values after cells in series (8) are default values.
mp_desoto_fit_num = pvlib.ivtools.sdm.fit_desoto(4.568, 3.3, 5.36, 3.5, 0.0010, -0.0158, 8, EgRef=1.121, dEgdT=-0.0002677, temp_ref=25, irrad_ref=1000, root_kwargs={})
or
mp_desoto_fit_ones = pvlib.ivtools.sdm.fit_desoto(1, 1, 1, 1, 1, 1, 1, EgRef=1.121, dEgdT=-0.0002677, temp_ref=25, irrad_ref=1000, root_kwargs={})
When using those code examples the error message changes to:
RuntimeError: Parameter estimation failed:
The iteration is not making good progress, as measured by the
improvement from the last ten iterations.
Do you have any ideas on this issue?
What I already tried:
Checked all types of initial values for the fit_desoto function (temperature coefficients are handed over in [A/K]).
Choosed different options for the root function solver with the method 'hybr'
Code debugged and checked the variables inside the root_function. No NaN values or similar arise while the function is calculating
Suggestions
perhaps the problem could be solved by choosing a different method for the root function via the function call of fit_desoto. The kwargs of the fit_desoto function itself can only change the options of the solver, but not which method is used. The default method is "hybr" which is only one of several.
Thanks in advance!
Versions:
numpy 1.20.2
pandas 1.2.4
pvlib 0.8.1
scipy 1.6.3
python 3.9.0
I am using Spyder and/or PyCharm
The text was updated successfully, but these errors were encountered: