Skip to content

Improve composite eSOH#5347

Merged
rtimms merged 19 commits intodevelopfrom
more-robust-composite-esoh
Jan 20, 2026
Merged

Improve composite eSOH#5347
rtimms merged 19 commits intodevelopfrom
more-robust-composite-esoh

Conversation

@rtimms
Copy link
Contributor

@rtimms rtimms commented Jan 13, 2026

Description

The current ElectrodeSOHComposite is not very robust and often gives solver failures. This adds a "split solve" method that first solves the standard eSOH model using the "primary" OCV curves and total capacities, then solves that all the OCP must be equal in all phases in the electrode at equilibrium. The set_initial_state method now tries to solve the full eSOH model. If it fails, it uses the "split" model (which is only approximately correct) to obtain initial conditions, then retries solving the full eSOH model. This improves the robustness considerably based on the test cases I have run.

This PR also ensures the _0 and _100 stoichiometry variables are defined consistently when a model contains hysteresis. Specifically, it implements the same definition as used in BPX: "Stoichiometry limits (x_0, x_100, y_0, y_100) are evaluated in a temperature-independent manner (at the reference temperature, ignoring entropy effects), so that the SOC range is not temperature-dependent. In the presence of a hysteresis model, equilibration in the charging direction is assumed for 100% SOC (charging OCP branch), and equilibration in the discharging direction is assumed for 0% SOC (discharging OCP branch)."

Fixes # (issue)

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

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 87.57062% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.39%. Comparing base (da40ed4) to head (dc59def).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...tery_models/lithium_ion/electrode_soh_composite.py 88.05% 19 Missing ⚠️
...amm/models/full_battery_models/lithium_ion/util.py 72.72% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5347      +/-   ##
===========================================
- Coverage    98.47%   98.39%   -0.09%     
===========================================
  Files          326      326              
  Lines        28519    28661     +142     
===========================================
+ Hits         28085    28201     +116     
- Misses         434      460      +26     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@rtimms rtimms marked this pull request as ready for review January 20, 2026 11:12
@rtimms rtimms requested a review from a team as a code owner January 20, 2026 11:12
Copy link
Member

@BradyPlanden BradyPlanden left a comment

Choose a reason for hiding this comment

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

Just a few general comments

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the robustness of the ElectrodeSOHComposite model by implementing a split solve approach as a fallback mechanism, and ensures consistent calculation of equilibrium stoichiometries for models with hysteresis. The split solve first computes primary phase stoichiometries using a simplified model, then solves for secondary phase stoichiometries by enforcing equal OCP across phases. When the full solve fails, the code automatically falls back to the split solve for initial conditions and retries.

Changes:

  • Added _get_equilibrium_direction() helper function to correctly determine OCP branch for equilibrium stoichiometries (100% SOC uses charging branch, 0% SOC uses discharging branch)
  • Implemented solve_split() and solve_full() static methods in ElectrodeSOHComposite with automatic fallback mechanism
  • Updated _ElectrodeSOH and ElectrodeSOHComposite to use equilibrium directions for stoichiometry limits, making them temperature-independent and consistent with BPX definitions

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/pybamm/models/full_battery_models/lithium_ion/util.py Added _get_equilibrium_direction() function to determine correct OCP branch for equilibrium stoichiometries based on SOC state and hysteresis presence
src/pybamm/models/full_battery_models/lithium_ion/electrode_soh_composite.py Implemented split solve methodology with solve_split() and solve_full() methods, added fallback mechanism in get_initial_stoichiometries_composite(), and updated equilibrium stoichiometry calculations
src/pybamm/models/full_battery_models/lithium_ion/electrode_soh.py Updated to use _get_equilibrium_direction() for calculating stoichiometry limits, ensuring consistency with hysteresis models
tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_electrode_soh.py Expanded test coverage with more initial values, added tests for split solve mechanism, and tests for hysteresis handling
CHANGELOG.md Documented the improvement to ElectrodeSOHComposite robustness and equilibrium stoichiometry consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…h_composite.py

Co-authored-by: Marc Berliner <34451391+MarcBerliner@users.noreply.github.com>
Copy link
Member

@BradyPlanden BradyPlanden left a comment

Choose a reason for hiding this comment

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

Looks good to me - thanks!

@rtimms rtimms enabled auto-merge (squash) January 20, 2026 14:54
@rtimms rtimms merged commit 18461a1 into develop Jan 20, 2026
24 of 26 checks passed
@rtimms rtimms deleted the more-robust-composite-esoh branch January 20, 2026 14:56
BradyPlanden pushed a commit that referenced this pull request Jan 21, 2026
* minor composite esoh fixes

* style: pre-commit fixes

* try split composite eSOH solve

* use split for initial conditions on failure

* style: pre-commit fixes

* fix v_low/high vs soc_0/100

* consisten min/max sto calculations

* update changelog

* style: pre-commit fixes

* PR comments

* fix direction in solve_split

* Update src/pybamm/models/full_battery_models/lithium_ion/electrode_soh_composite.py

Co-authored-by: Marc Berliner <34451391+MarcBerliner@users.noreply.github.com>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Marc Berliner <34451391+MarcBerliner@users.noreply.github.com>

(cherry picked from commit 18461a1)
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.

4 participants