Skip to content

Conversation

cwhanse
Copy link
Member

@cwhanse cwhanse commented Oct 10, 2025

  • Closes Use scipy's new optimize.elementwise functions #2497
  • 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.

Uses 'chandralupta' when scipy>=1.15. Existing tests are good enough.

@cwhanse cwhanse added this to the v0.13.2 milestone Oct 10, 2025
@cwhanse
Copy link
Member Author

cwhanse commented Oct 10, 2025

Restart of #2567

@cwhanse
Copy link
Member Author

cwhanse commented Oct 10, 2025

Pursuing the test failures, one condition tested is photocurrent=0. For that input, i_mp=nan is returned when the scipy method is used (#2567 (comment)).

nan is returned because the convergence fails on the first iteration, due to violation of the bracket condition. Quote from the scipy documentation for find_minimum:

requires argument init to provide a three-point minimization bracket: x1 < x2 < x3 such that func(x1) >= func(x2) <= func(x3), where one of the inequalities is strict.

Here, init = (0., 0.8*v_oc, v_oc) and func=_vmp_opt in the PR.

Evaluating at photocurrent=0. and v_oc=init, I get _vmp_opt(init, 0., ...) = array([-0.00000000e+00, 2.18952885e-48, 2.73691106e-48]). Note that the negative power is actually positive. The func values at this bracket fail the check.

Digging deeper, _lambertw_i_from_v(init, 0., ...) = array([0., -4.1359e-25, -4.1359e-25]) the negative currents are the root of the problem.

We could set small negative current to zero in lambertw_i_from_v But the MPP with chandralupta would still fail since photocurrent=0. since func(init) would be array([-0., -0., -0.]) and one of the inequalities has to be strict.

I think intercepting small photocurrent and skipping the MPP (or entire IV curve) calculation is better.

Your thoughts?

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.

Use scipy's new optimize.elementwise functions

1 participant