Fix interpolation bound errors in sodium-ion DFN by enabling safe extrapolation#5307
Fix interpolation bound errors in sodium-ion DFN by enabling safe extrapolation#5307aaryan-iiitu wants to merge 19 commits intopybamm-team:mainfrom
Conversation
… (pybamm-team#5253) Co-authored-by: Valentin Sulzer <valentinsulzer@hotmail.com>
) * Fix typo in concentration description in notebook * Add CHANGELOG.md entry for typo fix * Remove unneccesary changelog entry Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> --------- Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
main -> develop
* fix `InputParameter` serialisation * Update CHANGELOG.md
…rialisation-fix Don't be too strict with func_args longer than symbol.children
…-team#5285) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* feat: add`silence_sundial_warnings` solver option * refactor: `silence_sundials_warnings` -> `silence_sundials_errors`
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* raise `SolverError` at failure to init sundials * Update simulation.py * Update idaklu_solver.py * reuse `pybammsolvers` error messages * Update test_idaklu_solver.py * bump `pybammsolvers` * Update CHANGELOG.md * Update CHANGELOG.md Update CHANGELOG.md
|
|
|
Thanks for the review .You are completely correct. I have re ran the tests on the current branch without my changes, and I am unable to reproduce the crash as the simulation completes successfully.It appears the default handling in the current codebase is already robust enough to prevent it. Since I cannot reproduce the failure locally, I understand this PR might be redundant. However, I am still very keen to work on resolving the original issue for the user. Could you guide me on how to solve this issue if possible , otherwise I would be happy to close the PR. |
Summary
This PR fixes the interpolation bound errors occurring in the sodium-ion DFN model (
Chayambuka2022parameter set), where OCP and exchange-current interpolants would exceed their defined stoichiometry or concentration ranges during deep-discharge conditions. This caused solver failures such as:Fix
I updated the sodium-ion parameter functions to enable
extrapolate=Truefor:This ensures that DFN simulations do not crash when stoichiometry or concentration slightly exceeds tabulated data ranges.
Tests
Added a regression test
test_sodium_ion_extrapolation.pythat:Chayambuka2022parameter setextrapolate=TrueThis test runs quickly and confirms the fix without requiring long DFN simulations.
Motivation
The sodium-ion DFN demo fails to complete cycles in recent PyBaMM versions due to strict interpolation bounds. This PR improves robustness while matching expected physical behavior.