From 8200b8fbbd6ccd3f56aee020d141e4ef86e6b927 Mon Sep 17 00:00:00 2001 From: "Caitlin D. Parke" Date: Fri, 7 Jun 2024 16:45:39 -0400 Subject: [PATCH] Issue 4123 fix: SEI + Composite Integrations and lithium plating functions updated (#4153) * #4123 fix * Updated plating.py with same bug fix from issue 4123 * Bug fix combined to one line * style: pre-commit fixes --------- Co-authored-by: Caitlin Parke Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../models/submodels/interface/lithium_plating/plating.py | 8 ++++++-- pybamm/models/submodels/interface/sei/sei_growth.py | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pybamm/models/submodels/interface/lithium_plating/plating.py b/pybamm/models/submodels/interface/lithium_plating/plating.py index cd130ab483..f019c3b9d8 100644 --- a/pybamm/models/submodels/interface/lithium_plating/plating.py +++ b/pybamm/models/submodels/interface/lithium_plating/plating.py @@ -83,7 +83,9 @@ def get_coupled_variables(self, variables): alpha_stripping = phase_param.alpha_stripping alpha_plating = phase_param.alpha_plating - lithium_plating_option = getattr(self.options, domain)["lithium plating"] + lithium_plating_option = getattr(getattr(self.options, domain), self.phase)[ + "lithium plating" + ] if lithium_plating_option in ["reversible", "partially reversible"]: j_stripping = j0_stripping * pybamm.exp( F_RT * alpha_stripping * eta_stripping @@ -132,7 +134,9 @@ def set_rhs(self, variables): ] L_sei = variables[f"{Domain} total {phase_name}SEI thickness [m]"] - lithium_plating_option = getattr(self.options, domain)["lithium plating"] + lithium_plating_option = getattr(getattr(self.options, domain), self.phase)[ + "lithium plating" + ] if lithium_plating_option == "reversible": # In the reversible plating model, there is no dead lithium dc_plated_Li = -a_j_stripping / self.param.F diff --git a/pybamm/models/submodels/interface/sei/sei_growth.py b/pybamm/models/submodels/interface/sei/sei_growth.py index 89bb662fbc..bed4b04952 100644 --- a/pybamm/models/submodels/interface/sei/sei_growth.py +++ b/pybamm/models/submodels/interface/sei/sei_growth.py @@ -71,7 +71,7 @@ def get_fundamental_variables(self): L_inner, L_outer = Ls - SEI_option = getattr(self.options, domain)["SEI"] + SEI_option = getattr(getattr(self.options, domain), self.phase)["SEI"] if SEI_option.startswith("ec reaction limited"): L_inner = 0 * L_inner # Set L_inner to zero, copying domains @@ -83,7 +83,7 @@ def get_coupled_variables(self, variables): param = self.param phase_param = self.phase_param domain, Domain = self.domain_Domain - SEI_option = getattr(self.options, domain)["SEI"] + SEI_option = getattr(getattr(self.options, domain), self.phase)["SEI"] T = variables[f"{Domain} electrode temperature [K]"] # delta_phi = phi_s - phi_e if self.reaction_loc == "interface": @@ -256,7 +256,7 @@ def set_rhs(self, variables): ) # we have to add the spreading rate to account for cracking - SEI_option = getattr(self.options, domain)["SEI"] + SEI_option = getattr(getattr(self.options, domain), self.phase)["SEI"] if SEI_option.startswith("ec reaction limited"): self.rhs = {L_outer: -dLdt_SEI_outer + spreading_outer} else: @@ -284,7 +284,7 @@ def set_initial_conditions(self, variables): else: L_inner_0 = self.phase_param.L_inner_0 L_outer_0 = self.phase_param.L_outer_0 - SEI_option = getattr(self.options, domain)["SEI"] + SEI_option = getattr(getattr(self.options, domain), self.phase)["SEI"] if SEI_option.startswith("ec reaction limited"): self.initial_conditions = {L_outer: L_inner_0 + L_outer_0} else: