-
-
Notifications
You must be signed in to change notification settings - Fork 590
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
Differential method from Axen et al. (2022) for OCP with hysteresis #4816
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @chtamar, the implementation looks great! Just a couple of comments, and could you also add some tests, please? Let me know if you need help with where to get started with the tests.
src/pybamm/models/submodels/interface/open_circuit_potential/axen_ocp.py
Outdated
Show resolved
Hide resolved
src/pybamm/models/submodels/interface/open_circuit_potential/axen_ocp.py
Outdated
Show resolved
Hide resolved
…Issue pybamm-team#4808) Test functions have been added. Minor modifications have been added to the module axen_ocp to pass all the tests.
Hi @rtimms, I added the requested tests, and everything seems to be working fine. Initially, some tests failed with the error: pybamm.expression_tree.exceptions.DomainError: children must have same or empty domains, not ['positive particle size'] and ['negative particle size'] To solve this problem, instead of defining
This modification seems to solve the failed tests. |
Thanks, this looks great! As discussed in #4332, I would like to unify all the hysteresis options in PyBaMM. To help with that, I suggest we make it so that in all models, the hysteresis state variable goes between -1 and 1, with 0 corresponding to "equilibrium". Could you update it so that |
…Issue pybamm-team#4808) The module axen_ocp has been modified so the state variable h varies from -1 to 1, instead of 0 to 1.
Hi @rtimms, the modification has been made and now the state variable Regarding the comment explaining the different implementation from the original paper, should I add this as a jupyter notebook in PyBaMM\docs\source\examples\notebooks\models? |
Great, thanks! I would add a comment directly in the docstring of the new class and then update the existing Wycisk hysteresis notebook to compare all three models. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4816 +/- ##
========================================
Coverage 98.70% 98.70%
========================================
Files 303 304 +1
Lines 23353 23432 +79
========================================
+ Hits 23050 23129 +79
Misses 303 303 ☔ View full report in Codecov by Sentry. |
Hi @rtimms, in the current PR, there are three different decay rates defined within the function
Would it be better to define
The module |
Yes, sounds good! Anything that moves us towards unifying the hysteresis models is good. Doesn’t need to be for this PR, but we should make it so that the current sigmoid OCP also uses the state variable |
…Issue pybamm-team#4808) The name of the decay rate for lithiation and delithiation has been changed to follow the format "{self.phase_prefactor}{Domain} particle {lithiation}hysteresis decay rate".
…Issue pybamm-team#4808) A function is defined to read the parameter "hysteresis decay rate", allowing to select a value for "lithiation" and "delithiation".
Hi @rtimms, I added the docstring to the model Also, the three parameters The only request that is still to be done is updating the existing Wycisk hysteresis notebook to compare the three models. This may take few days, to be sure it is right. I am wondering whether updating this notebook could be split into a separate issue? |
Thanks, this looks great, just needs a changelog entry. Please go ahead and make a new issue to update the notebook and we can do it in a separate PR. |
…Issue pybamm-team#4808) CHANGELOG.md file has been updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your work on this @chtamar , looks great!
@all-contributors please add @chtamar for code, docs and tests |
I've put up a pull request to add @chtamar! 🎉 |
@chtamar can you resolve the merge conflicts? Then this is good to merge |
Description
Fixes Another method for OCP with hysteresis #4808
Motivation: This method has been proposed by Axen et al. https://doi.org/10.1016/j.est.2022.103985, and like the Wycisk approach, it employs an ODE system to track the evolution of the ocp between the empirical lithiation and delithiation branches of the hysteresis. Although the Wycisk and Axen methods perform similarly, the proposed implementation does not need to compute the differentiation
self.phase_param.U(sto_surf, T_bulk).diff(sto_surf)
, which makes it faster, and it also allows to choose separate decay rates for the lithiation and delithiation branches of the hysteresis. Important to note that more than one expression is proposed in https://doi.org/10.1016/j.est.2022.103985 for the delithiation branch, expression (9) in that paper is used here.Summary of the change:
wycisk_ocp
as starting point, the new method is implemented in the module axen_ocp, which has been added in pybamm/models/submodels/interface/open_circuit_potentialaxen_ocp
module available in the namespace and import the classAxenOpenCircuitPotential
U_hysteresis_branch
, which includes the effect of temperature in the hysteresis branches, and to define the parametersK_lith
andK_delith
No extra dependencies are required
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ pre-commit run
(or$ nox -s pre-commit
) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python -m pytest
(or$ nox -s tests
)$ python -m pytest --doctest-plus src
(or$ nox -s doctests
)You can run integration tests, unit tests, and doctests together at once, using
$ nox -s quick
.Further checks: