-
-
Notifications
You must be signed in to change notification settings - Fork 636
Issue 4884 unify hysteresis #4893
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
base: develop
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@ejfdickinson would appreciate your feedback on this |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4893 +/- ##
===========================================
- Coverage 99.12% 99.11% -0.02%
===========================================
Files 304 305 +1
Lines 23573 23606 +33
===========================================
+ Hits 23366 23396 +30
- Misses 207 210 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@rtimms I'll look over it. Relating to #4884 incomplete items currently excluded from the PR:
|
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.
In addition to specific comments on the docs, one additional comment:
- Should we use this as an opportunity to move from arbitrary author-name definitions to more descriptive inputs options, e.g.
"Axen"
-> "one-state"
"Wycisk"
-> "one-state differential capacity"
and similarly for module names? Although they may be the original reports, I don't think that "Axen" or "Wycisk" are really that intuitively descriptive for what are actually quite general hysteresis descriptions.
docs/source/examples/notebooks/models/hysteresis-state-models.ipynb
Outdated
Show resolved
Hide resolved
docs/source/examples/notebooks/models/hysteresis-state-models.ipynb
Outdated
Show resolved
Hide resolved
docs/source/examples/notebooks/models/hysteresis-state-models.ipynb
Outdated
Show resolved
Hide resolved
docs/source/examples/notebooks/models/hysteresis-state-models.ipynb
Outdated
Show resolved
Hide resolved
docs/source/examples/notebooks/models/hysteresis-state-models.ipynb
Outdated
Show resolved
Hide resolved
To do: Fix #5038 and
|
src/pybamm/models/submodels/interface/open_circuit_potential/wycisk_ocp.py
Outdated
Show resolved
Hide resolved
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.
Overall looks fine. Forgive my ignorance, but Wycisk/Axen are specific cases of the "new models" right? In that case, should they be kept as options to make this a non-breaking change? In any case, I don't think they should be both kept as subclasses and deleted as options -- I'd be surprised if there are any users that use submodels directly rather than going through the options, so this effectively just creates non-accessible code.
"$$ U = \\text{sigmoid}\\left(-\\frac{KI}{Q_{\\text{cell}}}\\right) U_{\\text{delith}} + \\text{sigmoid}\\left(\\frac{KI}{Q_{\\text{cell}}}\\right) U_{\\text{lith}}\n", | ||
"$$\n", | ||
"\n", | ||
"Where $K$ is a fitting parameter (in the current implementation this is hard-coded to 100, as in the original publication), $I$ is the cell current, and $Q_{\\text{cell}}$ is the cell capacity. To simplify the comparison with the other models, we can rewrite this expression in terms of the hysteresis state variable $h$ given by\n", |
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.
didn't look at this all that closely but I think it's important here to make the things which are functions of time functions of time in the documentation
if (isinstance(ocp_option, str) and ocp_option == "Wycisk") or ( | ||
isinstance(ocp_option, tuple) and "Wycisk" in ocp_option | ||
): | ||
raise pybamm.OptionError( |
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.
is there a good reason to throw an error rather than a deprecation warning here? This could be less breaking
if (isinstance(ocp_option, str) and ocp_option == "Axen") or ( | ||
isinstance(ocp_option, tuple) and "Axen" in ocp_option | ||
): | ||
raise pybamm.OptionError( |
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.
here too
|
||
variables.update( | ||
{ | ||
f"{Domain} electrode {phase_name}equilibrium open-circuit potential [V]": ocp_surf, |
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.
I think it's going to be pretty confusing for users to have this variable...
self.rhs[h] = dhdt | ||
|
||
|
||
class WyciskOpenCircuitPotential( |
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.
these can't really be accessed without a lot of work right? What's the point in keeping it?
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.
What if this implemented the old model, since the new model is slightly different? And then remove the option errors. That would make this a non-breaking change.
@@ -146,11 +150,27 @@ def _get_standard_coupled_variables(self, variables): | |||
# Reversible electrochemical heating | |||
dUdT_p = variables[f"Positive electrode {phase}entropic change [V.K-1]"] | |||
Q_rev_p += a_j_p * T_p * dUdT_p | |||
# Hysteresis electrochemical heating | |||
if ocp_option == "single": |
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.
I think this should cite something, it's not necessarily obvious to most engineers that it should be included.
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.
Looks good, a couple of minor comments for the notebook.
I also prefer the previous names (Axen/Wycisk) over the new names which are a real mouthful, but not a strong opinion
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.
unfinished sentence "We add some"
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.
Could also do with a sentence at the end describing the results
I am looking into the docs failure now, probably something pretty minor |
I pushed a temporary fix for the failing citation so that review could continue, I will push a in a real fix once I get it working again |
Docs are fixed now. I also updated the description to make sure all tickets get closed |
Description
Fixes #5038
Fixes #5081
Fixes #5021
Unifies the hysteresis models in PyBaMM and adds heat generation due to hysteresis. In particular:
BaseHysteresisOpenCircuitPotential
class that sets variables for the lithiation and delithiation OCP, as well as the average (simply the mean), and the hysteresis voltage (H = U_lith - U_delith
).CurrentSigmoidOpenCircuitPotential
, are expressed in terms of a hysteresis state variable-1<h<1
Q_hys = i_vol * (U - U_eq)
wherei_vol
is the volumetric interfacial current density,U
is the OCP (i.e. includes hysteresis), andU_eq
is the "equilibrium OCP"differential-capacity-hysteresis-state.ipynb
tohysteresis-state-models.ipynb
and extends it to include a comparison of all of the existing hysteresis modelsRelated #4884
What this doesn't do from #4884:
\gamma
in the subclasses. This would be an easy change to make, but I'm not sure it is much harder to just specify the wholerhs
in the base class and it makes the code more readable (even if there is some repetition). The way it currently is, you see the whole ODE in theset_rhs
method and don't need to chase back to the base class. Happy to take input on this.Breaking
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:
nox -s pre-commit
nox -s tests
nox -s doctests