Skip to content
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

Fixed domain mismatch bug when using lithium plating with SPM #4844

Merged
merged 14 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

## Bug fixes

- Fixed a bug that caused the variable `"Loss of lithium due to {domain} lithium plating"`to have the domain `"current collector"` (should not have any domain at all) if the `"x-average side reactions"` option was set to `"true"`. ([#4844](https://github.com/pybamm-team/PyBaMM/pull/4844))
- Fixed a bug which caused the ec-reaction limited SEI model to give
incorrect results ([#4774](https://github.com/pybamm-team/PyBaMM/pull/4774))

Expand Down
6 changes: 4 additions & 2 deletions examples/scripts/cycling_ageing.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@
"Discharge capacity [A.h]",
"Electrolyte potential [V]",
"Electrolyte concentration [mol.m-3]",
"Negative total SEI thickness [m]",
"Negative electrode porosity",
"X-averaged negative electrode porosity",
"X-averaged negative electrode SEI interfacial current density [A.m-2]",
"X-averaged negative electrode lithium plating interfacial current density "
"[A.m-2]",
"X-averaged negative total SEI thickness [m]",
"X-averaged negative dead lithium concentration [mol.m-3]",
[
"Total lithium lost [mol]",
"Loss of lithium to negative SEI [mol]",
"Loss of lithium to negative lithium plating [mol]",
],
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,43 @@ def _get_standard_concentration_variables(self, c_plated_Li, c_dead_Li):
c_to_L = self.param.V_bar_Li / phase_param.a_typ
L_k = self.param.p.L

c_plated_Li_av = pybamm.x_average(c_plated_Li)
c_plated_Li_xav = pybamm.x_average(c_plated_Li)
c_plated_Li_av = pybamm.yz_average(c_plated_Li_xav)
L_plated_Li = c_plated_Li * c_to_L # plated Li thickness
L_plated_Li_av = pybamm.x_average(L_plated_Li)
L_plated_Li_xav = pybamm.x_average(L_plated_Li)
L_plated_Li_av = pybamm.yz_average(L_plated_Li_xav)
Q_plated_Li = c_plated_Li_av * L_k * self.param.L_y * self.param.L_z

c_dead_Li_av = pybamm.x_average(c_dead_Li)
c_dead_Li_xav = pybamm.x_average(c_dead_Li)
c_dead_Li_av = pybamm.yz_average(c_dead_Li_xav)
# dead Li "thickness", required by porosity submodel
L_dead_Li = c_dead_Li * c_to_L
L_dead_Li_av = pybamm.x_average(L_dead_Li)
L_dead_Li_xav = pybamm.x_average(L_dead_Li)
L_dead_Li_av = pybamm.yz_average(L_dead_Li_xav)
Q_dead_Li = c_dead_Li_av * L_k * self.param.L_y * self.param.L_z

variables = {
f"{Domain} {phase_name}lithium plating concentration "
"[mol.m-3]": c_plated_Li,
f"X-averaged {domain} {phase_name}lithium plating concentration "
"[mol.m-3]": c_plated_Li_xav,
f"Volume-averaged {domain} {phase_name}lithium plating concentration "
"[mol.m-3]": c_plated_Li_av,
f"{Domain} {phase_name}dead lithium concentration [mol.m-3]": c_dead_Li,
f"X-averaged {domain} {phase_name}dead lithium concentration "
"[mol.m-3]": c_dead_Li_xav,
f"Volume-averaged {domain} {phase_name}dead lithium concentration "
"[mol.m-3]": c_dead_Li_av,
f"{Domain} {phase_name}lithium plating thickness [m]": L_plated_Li,
f"X-averaged {domain} {phase_name} lithium plating thickness "
f"X-averaged {domain} {phase_name}lithium plating thickness "
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @DrSOKane looks good! Can you also add the relevant “Volume-averaged…” variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be consistent with the definition of "volume-averaged" in the thermal submodel. However, in the particle submodel, "volume-averaged" is used to denoted the x-average of the r-averaged concentration. What term should be used instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is ok, since plated Lithium is on the surface (i.e. doesn’t depend on r).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I did that. Now I can start on the variable change for the SEI. That PR is so old I will probably just close it and start a new one.

"[m]": L_plated_Li_xav,
f"Volume-averaged {domain} {phase_name}lithium plating thickness "
"[m]": L_plated_Li_av,
f"{Domain} {phase_name}dead lithium thickness [m]": L_dead_Li,
f"X-averaged {domain} {phase_name}dead lithium thickness [m]": L_dead_Li_av,
f"X-averaged {domain} {phase_name}dead lithium thickness "
"[m]": L_dead_Li_xav,
f"Volume-averaged {domain} {phase_name}dead lithium thickness "
"[m]": L_dead_Li_av,
f"Loss of lithium to {domain} {phase_name}lithium plating [mol]": (
Q_plated_Li + Q_dead_Li
),
Expand Down