Skip to content

Add optional initial guess to fit_desoto #2291

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

Merged
merged 30 commits into from
Nov 15, 2024
Merged

Conversation

cwhanse
Copy link
Member

@cwhanse cwhanse commented Nov 5, 2024

  • Closes fit_sdm_desoto fails with certain valid inputs #1014
  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries in docs/sphinx/source/reference for API changes.
  • Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for 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`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

Also corrects the references in the docstring of fit_desoto

Copy link
Contributor

@RDaxini RDaxini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a full read through but only noticed a couple of very minor non-code things.
One more: some parameter descriptions end with a period and some don't. Just for neatness if nothing else, might be worth sticking with one style

@@ -166,6 +166,9 @@ def fit_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc, cells_in_series,
Reference temperature condition [C]
irrad_ref: float, default 1000
Reference irradiance condition [W/m2]
init_guess: dict, optional
Initial values for optimization, must have keys `'Rsh_0'`, `'a_0'`,
`'IL_0'`, `'Io_0'`, `'Rs_0'`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be useful to accept a subset of these as input? (And use the internal values for the rest?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Convergence of this method appears to be somewhat sensitive to the initial guess and the built-in may not always work.

@@ -120,107 +120,121 @@ def fit_cec_sam(celltype, v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc,

def fit_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc, cells_in_series,
EgRef=1.121, dEgdT=-0.0002677, temp_ref=25, irrad_ref=1000,
root_kwargs={}):
init_guess={}, root_kwargs={}):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice is to avoid mutable types for default parameter values, but this function already has another one (root_kwargs) so I won't object to it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I'm happy to replace that default if we concoct a clean way to pass that input. Positions in a tuple feel clumsy; if init_guess is not None: if isinstance(init_guess, dict) is an option, I suppose.

@kandersolar kandersolar merged commit 891778c into pvlib:main Nov 15, 2024
26 checks passed
@kandersolar
Copy link
Member

Thanks @cwhanse!

kandersolar added a commit to kandersolar/pvlib-python that referenced this pull request Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fit_sdm_desoto fails with certain valid inputs
4 participants