Plot voltage components for composite electrodes
Description
The goal here is to allow for plotting of overpotential components in a composite electrode. Attempting to do so first in a composite half-cell
Fixes #4434
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.
- [x] New feature (non-breaking change which adds functionality)
- [ ] Optimization (back-end change that speeds up the code)
- [ ] Bug fix (non-breaking change which fixes an issue)
Key checklist:
- [ ] No style issues:
$ 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) - [ ] All tests pass:
$ python run-tests.py --all(or$ nox -s tests) - [ ] The documentation builds:
$ python run-tests.py --doctest(or$ nox -s doctests)
You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).
Further checks:
- [ ] Code is commented, particularly in hard-to-understand areas
- [ ] Tests added that prove fix is effective or that feature works
Check out this pull request on ![]()
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
I added a Chen2020_composite parameter set as part of PR #4463, which may be useful for this
Reviving this discussion as it may be of interest to some people.
Stacking the primary and secondary overpotentials in this plot doesn't really make sense to me as these values are not additive in the model. Rather, the mathematical relationship for a 2-phase model is:
$$OCV_{prim} + \eta_{conc, prim} + \eta_{reac, prim} = OCV_{sec} + \eta_{conc, sec} + \eta_{reac, sec}$$
That's why your dashed line is below the top of the fill_betweens, you're not meant to add up all of these quantities. If you wanted to show all 6 of these voltages together, you would need to stack the 3 components of the primary starting from 0V, then overlap the 3 components of the secondary, again starting from 0V, and finally stack the remaining OPs on top of all that.
IMO that wouldn't make for a very useful plot, as the voltages you're probably most interested in will be so cluttered.
What we can do is add a keyword argument to sol.plot_voltage_components() to select which phase you want to plot. Something like this:
sol.plot_voltage_components(split_by_electrode=True, electrode_phases=("secondary", "primary"))
This is a Si-Gr model, you can see the different behaviours during the rest.
I'm happy to open another draft PR with the code for the plot_voltage_components(), if people would like this feature.
@Daniel-Nicolae23 I'd welcome a PR with this!
@Daniel-Nicolae23 i could see it being useful to have the phases overlapping, potentially at 25% opacity with different fill patterns. This would potentially allow the user to visualize which phase is limiting, by what margin, and due to which overpotential compared to the other. What do you think?
@Daniel-Nicolae23 i could see it being useful to have the phases overlapping, potentially at 25% opacity with different fill patterns. This would potentially allow the user to visualize which phase is limiting, by what margin, and due to which overpotential compared to the other. What do you think?
It could be useful, yes. And there could be a "both" option for electrode_phases. But do you think this would require re-ordering all the components? I.e., changing from
OCV_n, OCV_p, concentration_n, concentration_p, reaction_n, reaction_p, etc.
to
OCV_n, concentration_n, reaction_n (with overlaps of primary/secondary in these 3), then OCV_p, concentration_p, reaction_p, etc.
@mleot @rtimms I just opened PR #5229 which does the plotting with the phase kwarg. You can see it in the composite particle example notebook. It currently doesn't have the option to plot both, but I guess we could discuss if we want that and the component re-ordering there?