Hi,
I’ve encountered an issue while working with PyBaMM, specifically with the SEI on cracks model when used in conjunction with a composite model. The following error was raised:
KeyError: "'X-averaged negative particle crack length [m]' not found. Best matches are ['X-averaged negative primary particle crack length [m]', 'X-averaged positive particle crack length [m]', 'X-averaged negative secondary particle crack length [m]']"
After a deep check, I resolved the issue by modifying the sei_growth.py file. The fix involves adding {self.phase} to the variable names to properly account for the phase in composite models. Here’s the updated code snippet for reference:
# The spreading term acts to spread out SEI along the cracks as they grow.
# For SEI on initial surface (as opposed to cracks), it is zero.
if self.reaction == "SEI on cracks":
if self.reaction_loc == "x-average":
l_cr = variables[f"X-averaged {domain} {self.phase} particle crack length [m]"]
dl_cr = variables[f"X-averaged {domain} {self.phase} particle cracking rate [m.s-1]"]
else:
l_cr = variables[f"{Domain} {self.phase} particle crack length [m]"]
dl_cr = variables[f"{Domain} {self.phase} particle cracking rate [m.s-1]"]
spreading = dl_cr / l_cr * (self.phase_param.L_sei_crack_0 - L_sei)
else:
spreading = 0
I wanted to bring this to your attention for consideration in a future update. Thank you for your fantastic library!
Sincerely yours,