Skip to content
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

Better optimizer for initializing half-cell soc #4873

Merged
merged 6 commits into from
Mar 5, 2025

Conversation

d-cogswell
Copy link
Contributor

@d-cogswell d-cogswell commented Feb 24, 2025

Description

scipy.opimize.root() occasionally causes numerical crashes during initialization of half-cell simulations. Switching to scipy.optimize.minimize() resolves the issue.

Fixes #4868

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #)

Important checks:

Please confirm the following before marking the PR as ready for review:

  • No style issues: nox -s pre-commit
  • All tests pass: nox -s tests
  • The documentation builds: nox -s doctests
  • Code is commented for hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@agriyakhetarpal
Copy link
Member

Thanks, @d-cogswell – I've triggered the workflows for you.

Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.71%. Comparing base (998c18f) to head (515e609).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4873   +/-   ##
========================================
  Coverage    98.71%   98.71%           
========================================
  Files          304      304           
  Lines        23495    23495           
========================================
  Hits         23193    23193           
  Misses         302      302           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@d-cogswell d-cogswell changed the title Better optimizer for solving initializing half-cell soc Better optimizer for initializing half-cell soc Feb 25, 2025
Copy link
Contributor

@martinjrobins martinjrobins left a comment

Choose a reason for hiding this comment

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

Thanks @d-cogswell, largely this looks good and works for me as well, I've got a couple of questions below that should be addressed

@d-cogswell d-cogswell requested a review from martinjrobins March 3, 2025 18:57
Copy link
Contributor

@martinjrobins martinjrobins left a comment

Choose a reason for hiding this comment

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

Thanks @d-cogswell , LGTM 😊

@martinjrobins martinjrobins marked this pull request as ready for review March 4, 2025 07:53
@martinjrobins martinjrobins requested a review from a team as a code owner March 4, 2025 07:53
Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

I can't comment on the half-cell equations side, but the change looks good to me, thanks!

@agriyakhetarpal
Copy link
Member

@all-contributors please add @d-cogswell for code

Copy link
Contributor

@agriyakhetarpal

I've put up a pull request to add @d-cogswell! 🎉

@kratman kratman merged commit e91120f into pybamm-team:develop Mar 5, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: SolverError when simulating a half-cell and setting initial_soc
5 participants