From e88fd31b1c1edc0be373edc89fc77a512684d8a7 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Mon, 8 Nov 2021 20:30:02 -0500 Subject: [PATCH 1/4] #1489 add surface area to volume ratio factor --- examples/scripts/compare_lithium_ion.py | 8 ++++---- .../interface/lithium_plating/irreversible_plating.py | 5 ++++- .../interface/lithium_plating/reversible_plating.py | 5 ++++- .../submodels/interface/sei/ec_reaction_limited.py | 7 ++++++- .../interface/sei/electron_migration_limited.py | 9 +++++++-- .../interface/sei/interstitial_diffusion_limited.py | 10 +++++++--- .../submodels/interface/sei/reaction_limited.py | 9 +++++++-- .../interface/sei/solvent_diffusion_limited.py | 11 ++++++++--- pybamm/util.py | 5 ++++- 9 files changed, 51 insertions(+), 18 deletions(-) diff --git a/examples/scripts/compare_lithium_ion.py b/examples/scripts/compare_lithium_ion.py index 6108036b9b..f27fb95177 100644 --- a/examples/scripts/compare_lithium_ion.py +++ b/examples/scripts/compare_lithium_ion.py @@ -7,10 +7,10 @@ # load models models = [ - pybamm.lithium_ion.SPM(), - pybamm.lithium_ion.SPMe(), + # pybamm.lithium_ion.SPM(), + # pybamm.lithium_ion.SPMe(), pybamm.lithium_ion.DFN(), - pybamm.lithium_ion.NewmanTobias(), + # pybamm.lithium_ion.NewmanTobias(), ] # create and run simulations @@ -21,4 +21,4 @@ sims.append(sim) # plot -pybamm.dynamic_plot(sims) +pybamm.dynamic_plot(sims, ["Negative electrode surface area to volume ratio"]) diff --git a/pybamm/models/submodels/interface/lithium_plating/irreversible_plating.py b/pybamm/models/submodels/interface/lithium_plating/irreversible_plating.py index 9d8422a238..f82f738b81 100644 --- a/pybamm/models/submodels/interface/lithium_plating/irreversible_plating.py +++ b/pybamm/models/submodels/interface/lithium_plating/irreversible_plating.py @@ -77,12 +77,15 @@ def set_rhs(self, variables): j_stripping = variables[ "X-averaged lithium plating interfacial current density" ] + a = variables["X-averaged negative electrode surface area to volume ratio"] else: c_plated_Li = variables["Lithium plating concentration"] j_stripping = variables["Lithium plating interfacial current density"] + a = variables["Negative electrode surface area to volume ratio"] Gamma_plating = self.param.Gamma_plating - self.rhs = {c_plated_Li: -Gamma_plating * j_stripping} + + self.rhs = {c_plated_Li: -Gamma_plating * a * j_stripping} def set_initial_conditions(self, variables): if self.x_average is True: diff --git a/pybamm/models/submodels/interface/lithium_plating/reversible_plating.py b/pybamm/models/submodels/interface/lithium_plating/reversible_plating.py index 14e4894170..68a476b406 100644 --- a/pybamm/models/submodels/interface/lithium_plating/reversible_plating.py +++ b/pybamm/models/submodels/interface/lithium_plating/reversible_plating.py @@ -77,12 +77,15 @@ def set_rhs(self, variables): j_stripping = variables[ "X-averaged lithium plating interfacial current density" ] + a = variables["X-averaged negative electrode surface area to volume ratio"] else: c_plated_Li = variables["Lithium plating concentration"] j_stripping = variables["Lithium plating interfacial current density"] + a = variables["Negative electrode surface area to volume ratio"] Gamma_plating = self.param.Gamma_plating - self.rhs = {c_plated_Li: -Gamma_plating * j_stripping} + + self.rhs = {c_plated_Li: -Gamma_plating * a * j_stripping} def set_initial_conditions(self, variables): if self.x_average is True: diff --git a/pybamm/models/submodels/interface/sei/ec_reaction_limited.py b/pybamm/models/submodels/interface/sei/ec_reaction_limited.py index c07862632d..063a0fb45f 100644 --- a/pybamm/models/submodels/interface/sei/ec_reaction_limited.py +++ b/pybamm/models/submodels/interface/sei/ec_reaction_limited.py @@ -123,9 +123,14 @@ def set_rhs(self, variables): L_sei = variables["Outer SEI thickness"] j_sei = variables["Outer SEI interfacial current density"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] + Gamma_SEI = self.param.Gamma_SEI - self.rhs = {L_sei: -Gamma_SEI * j_sei / 2} + self.rhs = {L_sei: -Gamma_SEI * a * j_sei / 2} def set_initial_conditions(self, variables): if self.reaction_loc == "x-average": diff --git a/pybamm/models/submodels/interface/sei/electron_migration_limited.py b/pybamm/models/submodels/interface/sei/electron_migration_limited.py index 6a5504b7cd..a0c6cf16ab 100644 --- a/pybamm/models/submodels/interface/sei/electron_migration_limited.py +++ b/pybamm/models/submodels/interface/sei/electron_migration_limited.py @@ -79,12 +79,17 @@ def set_rhs(self, variables): j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] + v_bar = self.param.v_bar Gamma_SEI = self.param.Gamma_SEI self.rhs = { - L_inner: -Gamma_SEI * j_inner, - L_outer: -v_bar * Gamma_SEI * j_outer, + L_inner: -Gamma_SEI * a * j_inner, + L_outer: -v_bar * Gamma_SEI * a * j_outer, } def set_initial_conditions(self, variables): diff --git a/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py b/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py index ab399f7fbc..a11da214d4 100644 --- a/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py +++ b/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py @@ -81,13 +81,17 @@ def set_rhs(self, variables): j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - v_bar = self.param.v_bar + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] + v_bar = self.param.v_bar Gamma_SEI = self.param.Gamma_SEI self.rhs = { - L_inner: -Gamma_SEI * j_inner, - L_outer: -v_bar * Gamma_SEI * j_outer, + L_inner: -Gamma_SEI * a * j_inner, + L_outer: -v_bar * Gamma_SEI * a * j_outer, } def set_initial_conditions(self, variables): diff --git a/pybamm/models/submodels/interface/sei/reaction_limited.py b/pybamm/models/submodels/interface/sei/reaction_limited.py index b4d188eb81..9fd3e688c2 100644 --- a/pybamm/models/submodels/interface/sei/reaction_limited.py +++ b/pybamm/models/submodels/interface/sei/reaction_limited.py @@ -101,12 +101,17 @@ def set_rhs(self, variables): j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] + v_bar = self.param.v_bar Gamma_SEI = self.param.Gamma_SEI self.rhs = { - L_inner: -Gamma_SEI * j_inner, - L_outer: -v_bar * Gamma_SEI * j_outer, + L_inner: -Gamma_SEI * a * j_inner, + L_outer: -v_bar * Gamma_SEI * a * j_outer, } def set_initial_conditions(self, variables): diff --git a/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py b/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py index 251e5250f5..04de5f2ae9 100644 --- a/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py +++ b/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py @@ -73,13 +73,18 @@ def set_rhs(self, variables): L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - v_bar = self.param.v_bar + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] + + v_bar = self.param.v_bar Gamma_SEI = self.param.Gamma_SEI self.rhs = { - L_inner: -Gamma_SEI * j_inner, - L_outer: -v_bar * Gamma_SEI * j_outer, + L_inner: -Gamma_SEI * a * j_inner, + L_outer: -v_bar * Gamma_SEI * a * j_outer, } def set_initial_conditions(self, variables): diff --git a/pybamm/util.py b/pybamm/util.py index cab5d995b3..786dd0a3f7 100644 --- a/pybamm/util.py +++ b/pybamm/util.py @@ -285,7 +285,10 @@ def load_function(filename): path = root_path.replace("/", ".") path = path.replace("\\", ".") - module_object = importlib.import_module(path) + try: + module_object = importlib.import_module(path) + except ModuleNotFoundError: + module_object = importlib.import_module("pybamm.input.parameters." + path) return getattr(module_object, tail) From 03d2dec32b34eb1b1c1f20b99dc4e4b59275a354 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Tue, 9 Nov 2021 10:14:40 -0500 Subject: [PATCH 2/4] #1489 revert example and fix tests --- examples/scripts/compare_lithium_ion.py | 8 ++++---- .../submodels/interface/sei/ec_reaction_limited.py | 10 ++++++---- .../interface/sei/electron_migration_limited.py | 10 ++++++---- .../interface/sei/interstitial_diffusion_limited.py | 10 ++++++---- .../models/submodels/interface/sei/reaction_limited.py | 10 ++++++---- .../interface/sei/solvent_diffusion_limited.py | 10 ++++++---- 6 files changed, 34 insertions(+), 24 deletions(-) diff --git a/examples/scripts/compare_lithium_ion.py b/examples/scripts/compare_lithium_ion.py index f27fb95177..6108036b9b 100644 --- a/examples/scripts/compare_lithium_ion.py +++ b/examples/scripts/compare_lithium_ion.py @@ -7,10 +7,10 @@ # load models models = [ - # pybamm.lithium_ion.SPM(), - # pybamm.lithium_ion.SPMe(), + pybamm.lithium_ion.SPM(), + pybamm.lithium_ion.SPMe(), pybamm.lithium_ion.DFN(), - # pybamm.lithium_ion.NewmanTobias(), + pybamm.lithium_ion.NewmanTobias(), ] # create and run simulations @@ -21,4 +21,4 @@ sims.append(sim) # plot -pybamm.dynamic_plot(sims, ["Negative electrode surface area to volume ratio"]) +pybamm.dynamic_plot(sims) diff --git a/pybamm/models/submodels/interface/sei/ec_reaction_limited.py b/pybamm/models/submodels/interface/sei/ec_reaction_limited.py index 063a0fb45f..f78943e928 100644 --- a/pybamm/models/submodels/interface/sei/ec_reaction_limited.py +++ b/pybamm/models/submodels/interface/sei/ec_reaction_limited.py @@ -119,13 +119,15 @@ def set_rhs(self, variables): if self.reaction_loc == "x-average": L_sei = variables["X-averaged outer SEI thickness"] j_sei = variables["X-averaged outer SEI interfacial current density"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables[ + "X-averaged negative electrode surface area to volume ratio" + ] else: L_sei = variables["Outer SEI thickness"] j_sei = variables["Outer SEI interfacial current density"] - - if self.reaction_loc == "interface": - a = 1 - else: a = variables["Negative electrode surface area to volume ratio"] Gamma_SEI = self.param.Gamma_SEI diff --git a/pybamm/models/submodels/interface/sei/electron_migration_limited.py b/pybamm/models/submodels/interface/sei/electron_migration_limited.py index a0c6cf16ab..0bc3ddf01d 100644 --- a/pybamm/models/submodels/interface/sei/electron_migration_limited.py +++ b/pybamm/models/submodels/interface/sei/electron_migration_limited.py @@ -73,15 +73,17 @@ def set_rhs(self, variables): L_outer = variables["X-averaged outer SEI thickness"] j_inner = variables["X-averaged inner SEI interfacial current density"] j_outer = variables["X-averaged outer SEI interfacial current density"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables[ + "X-averaged negative electrode surface area to volume ratio" + ] else: L_inner = variables["Inner SEI thickness"] L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - - if self.reaction_loc == "interface": - a = 1 - else: a = variables["Negative electrode surface area to volume ratio"] v_bar = self.param.v_bar diff --git a/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py b/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py index a11da214d4..0afaf2c293 100644 --- a/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py +++ b/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py @@ -75,15 +75,17 @@ def set_rhs(self, variables): L_outer = variables["X-averaged outer SEI thickness"] j_inner = variables["X-averaged inner SEI interfacial current density"] j_outer = variables["X-averaged outer SEI interfacial current density"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables[ + "X-averaged negative electrode surface area to volume ratio" + ] else: L_inner = variables["Inner SEI thickness"] L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - - if self.reaction_loc == "interface": - a = 1 - else: a = variables["Negative electrode surface area to volume ratio"] v_bar = self.param.v_bar diff --git a/pybamm/models/submodels/interface/sei/reaction_limited.py b/pybamm/models/submodels/interface/sei/reaction_limited.py index 9fd3e688c2..3095e02e3d 100644 --- a/pybamm/models/submodels/interface/sei/reaction_limited.py +++ b/pybamm/models/submodels/interface/sei/reaction_limited.py @@ -95,15 +95,17 @@ def set_rhs(self, variables): L_outer = variables["X-averaged outer SEI thickness"] j_inner = variables["X-averaged inner SEI interfacial current density"] j_outer = variables["X-averaged outer SEI interfacial current density"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables[ + "X-averaged negative electrode surface area to volume ratio" + ] else: L_inner = variables["Inner SEI thickness"] L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - - if self.reaction_loc == "interface": - a = 1 - else: a = variables["Negative electrode surface area to volume ratio"] v_bar = self.param.v_bar diff --git a/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py b/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py index 04de5f2ae9..c127e89171 100644 --- a/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py +++ b/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py @@ -68,15 +68,17 @@ def set_rhs(self, variables): L_outer = variables["X-averaged outer SEI thickness"] j_inner = variables["X-averaged inner SEI interfacial current density"] j_outer = variables["X-averaged outer SEI interfacial current density"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables[ + "X-averaged negative electrode surface area to volume ratio" + ] else: L_inner = variables["Inner SEI thickness"] L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - - if self.reaction_loc == "interface": - a = 1 - else: a = variables["Negative electrode surface area to volume ratio"] v_bar = self.param.v_bar From 5b160d43811ac67748db9245515bad6a6d718cf1 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Tue, 9 Nov 2021 10:17:51 -0500 Subject: [PATCH 3/4] #1489 add comment on dimensionless --- CHANGELOG.md | 5 ++++- .../interface/lithium_plating/irreversible_plating.py | 2 ++ .../interface/lithium_plating/reversible_plating.py | 2 ++ pybamm/models/submodels/interface/sei/ec_reaction_limited.py | 2 ++ .../submodels/interface/sei/electron_migration_limited.py | 2 ++ .../interface/sei/interstitial_diffusion_limited.py | 2 ++ pybamm/models/submodels/interface/sei/reaction_limited.py | 2 ++ .../submodels/interface/sei/solvent_diffusion_limited.py | 2 ++ 8 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7403a17edb..a264dfc6b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## Features -- Half-cell SPM and SPMe have been implemented ( [#1731](https://github.com/pybamm-team/PyBaMM/pull/1731)) +- Added surface area to volume ratio as a factor to the SEI equations ([#1790](https://github.com/pybamm-team/PyBaMM/pull/1790)) +- Half-cell SPM and SPMe have been implemented ([#1731](https://github.com/pybamm-team/PyBaMM/pull/1731)) + ## Bug fixes - Fixed `sympy` operators for `Arctan` and `Exponential` ([#1786](https://github.com/pybamm-team/PyBaMM/pull/1786)) @@ -11,6 +13,7 @@ ## Breaking changes - Raise error if `Concatenation` is used directly with `Variable` objects (`concatenation` should be used instead) ([#1789](https://github.com/pybamm-team/PyBaMM/pull/1789)) + # [v21.10](https://github.com/pybamm-team/PyBaMM/tree/v21.9) - 2021-10-31 ## Features diff --git a/pybamm/models/submodels/interface/lithium_plating/irreversible_plating.py b/pybamm/models/submodels/interface/lithium_plating/irreversible_plating.py index f82f738b81..870f620fec 100644 --- a/pybamm/models/submodels/interface/lithium_plating/irreversible_plating.py +++ b/pybamm/models/submodels/interface/lithium_plating/irreversible_plating.py @@ -77,6 +77,8 @@ def set_rhs(self, variables): j_stripping = variables[ "X-averaged lithium plating interfacial current density" ] + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) a = variables["X-averaged negative electrode surface area to volume ratio"] else: c_plated_Li = variables["Lithium plating concentration"] diff --git a/pybamm/models/submodels/interface/lithium_plating/reversible_plating.py b/pybamm/models/submodels/interface/lithium_plating/reversible_plating.py index 68a476b406..fbaa478fe0 100644 --- a/pybamm/models/submodels/interface/lithium_plating/reversible_plating.py +++ b/pybamm/models/submodels/interface/lithium_plating/reversible_plating.py @@ -77,6 +77,8 @@ def set_rhs(self, variables): j_stripping = variables[ "X-averaged lithium plating interfacial current density" ] + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) a = variables["X-averaged negative electrode surface area to volume ratio"] else: c_plated_Li = variables["Lithium plating concentration"] diff --git a/pybamm/models/submodels/interface/sei/ec_reaction_limited.py b/pybamm/models/submodels/interface/sei/ec_reaction_limited.py index f78943e928..c71fd41b19 100644 --- a/pybamm/models/submodels/interface/sei/ec_reaction_limited.py +++ b/pybamm/models/submodels/interface/sei/ec_reaction_limited.py @@ -122,6 +122,8 @@ def set_rhs(self, variables): if self.reaction_loc == "interface": a = 1 else: + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) a = variables[ "X-averaged negative electrode surface area to volume ratio" ] diff --git a/pybamm/models/submodels/interface/sei/electron_migration_limited.py b/pybamm/models/submodels/interface/sei/electron_migration_limited.py index 0bc3ddf01d..4fb8b6ba07 100644 --- a/pybamm/models/submodels/interface/sei/electron_migration_limited.py +++ b/pybamm/models/submodels/interface/sei/electron_migration_limited.py @@ -76,6 +76,8 @@ def set_rhs(self, variables): if self.reaction_loc == "interface": a = 1 else: + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) a = variables[ "X-averaged negative electrode surface area to volume ratio" ] diff --git a/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py b/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py index 0afaf2c293..7a059c8e93 100644 --- a/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py +++ b/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py @@ -78,6 +78,8 @@ def set_rhs(self, variables): if self.reaction_loc == "interface": a = 1 else: + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) a = variables[ "X-averaged negative electrode surface area to volume ratio" ] diff --git a/pybamm/models/submodels/interface/sei/reaction_limited.py b/pybamm/models/submodels/interface/sei/reaction_limited.py index 3095e02e3d..8d8d2d4be6 100644 --- a/pybamm/models/submodels/interface/sei/reaction_limited.py +++ b/pybamm/models/submodels/interface/sei/reaction_limited.py @@ -98,6 +98,8 @@ def set_rhs(self, variables): if self.reaction_loc == "interface": a = 1 else: + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) a = variables[ "X-averaged negative electrode surface area to volume ratio" ] diff --git a/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py b/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py index c127e89171..1091225f1f 100644 --- a/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py +++ b/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py @@ -71,6 +71,8 @@ def set_rhs(self, variables): if self.reaction_loc == "interface": a = 1 else: + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) a = variables[ "X-averaged negative electrode surface area to volume ratio" ] From 1de9c110798f18f75138a0df835f5d580acf5e38 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Tue, 9 Nov 2021 12:15:58 -0500 Subject: [PATCH 4/4] #1489 fix half-cell models --- .../scripts/compare_lithium_ion_half_cell.py | 12 +++++++++--- .../interface/sei/ec_reaction_limited.py | 16 +++++++--------- .../interface/sei/electron_migration_limited.py | 16 +++++++--------- .../sei/interstitial_diffusion_limited.py | 16 +++++++--------- .../submodels/interface/sei/reaction_limited.py | 16 +++++++--------- .../interface/sei/solvent_diffusion_limited.py | 16 +++++++--------- pybamm/util.py | 5 +---- 7 files changed, 45 insertions(+), 52 deletions(-) diff --git a/examples/scripts/compare_lithium_ion_half_cell.py b/examples/scripts/compare_lithium_ion_half_cell.py index 0686e53314..b6dcac3f3e 100644 --- a/examples/scripts/compare_lithium_ion_half_cell.py +++ b/examples/scripts/compare_lithium_ion_half_cell.py @@ -7,9 +7,15 @@ # load models models = [ - pybamm.lithium_ion.SPM({"working electrode": "positive"}), - pybamm.lithium_ion.SPMe({"working electrode": "positive"}), - pybamm.lithium_ion.DFN({"working electrode": "positive"}), + pybamm.lithium_ion.SPM( + {"working electrode": "positive", "SEI": "ec reaction limited"} + ), + pybamm.lithium_ion.SPMe( + {"working electrode": "positive", "SEI": "ec reaction limited"} + ), + pybamm.lithium_ion.DFN( + {"working electrode": "positive", "SEI": "ec reaction limited"} + ), ] chemistry = pybamm.parameter_sets.Xu2019 diff --git a/pybamm/models/submodels/interface/sei/ec_reaction_limited.py b/pybamm/models/submodels/interface/sei/ec_reaction_limited.py index c71fd41b19..be9bc1edc6 100644 --- a/pybamm/models/submodels/interface/sei/ec_reaction_limited.py +++ b/pybamm/models/submodels/interface/sei/ec_reaction_limited.py @@ -119,18 +119,16 @@ def set_rhs(self, variables): if self.reaction_loc == "x-average": L_sei = variables["X-averaged outer SEI thickness"] j_sei = variables["X-averaged outer SEI interfacial current density"] - if self.reaction_loc == "interface": - a = 1 - else: - # Note a is dimensionless (has a constant value of 1 if the surface - # area does not change) - a = variables[ - "X-averaged negative electrode surface area to volume ratio" - ] + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) + a = variables["X-averaged negative electrode surface area to volume ratio"] else: L_sei = variables["Outer SEI thickness"] j_sei = variables["Outer SEI interfacial current density"] - a = variables["Negative electrode surface area to volume ratio"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] Gamma_SEI = self.param.Gamma_SEI diff --git a/pybamm/models/submodels/interface/sei/electron_migration_limited.py b/pybamm/models/submodels/interface/sei/electron_migration_limited.py index 4fb8b6ba07..b52200fcff 100644 --- a/pybamm/models/submodels/interface/sei/electron_migration_limited.py +++ b/pybamm/models/submodels/interface/sei/electron_migration_limited.py @@ -73,20 +73,18 @@ def set_rhs(self, variables): L_outer = variables["X-averaged outer SEI thickness"] j_inner = variables["X-averaged inner SEI interfacial current density"] j_outer = variables["X-averaged outer SEI interfacial current density"] - if self.reaction_loc == "interface": - a = 1 - else: - # Note a is dimensionless (has a constant value of 1 if the surface - # area does not change) - a = variables[ - "X-averaged negative electrode surface area to volume ratio" - ] + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) + a = variables["X-averaged negative electrode surface area to volume ratio"] else: L_inner = variables["Inner SEI thickness"] L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - a = variables["Negative electrode surface area to volume ratio"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] v_bar = self.param.v_bar Gamma_SEI = self.param.Gamma_SEI diff --git a/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py b/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py index 7a059c8e93..0c265fc13a 100644 --- a/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py +++ b/pybamm/models/submodels/interface/sei/interstitial_diffusion_limited.py @@ -75,20 +75,18 @@ def set_rhs(self, variables): L_outer = variables["X-averaged outer SEI thickness"] j_inner = variables["X-averaged inner SEI interfacial current density"] j_outer = variables["X-averaged outer SEI interfacial current density"] - if self.reaction_loc == "interface": - a = 1 - else: - # Note a is dimensionless (has a constant value of 1 if the surface - # area does not change) - a = variables[ - "X-averaged negative electrode surface area to volume ratio" - ] + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) + a = variables["X-averaged negative electrode surface area to volume ratio"] else: L_inner = variables["Inner SEI thickness"] L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - a = variables["Negative electrode surface area to volume ratio"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] v_bar = self.param.v_bar Gamma_SEI = self.param.Gamma_SEI diff --git a/pybamm/models/submodels/interface/sei/reaction_limited.py b/pybamm/models/submodels/interface/sei/reaction_limited.py index 8d8d2d4be6..9de7438408 100644 --- a/pybamm/models/submodels/interface/sei/reaction_limited.py +++ b/pybamm/models/submodels/interface/sei/reaction_limited.py @@ -95,20 +95,18 @@ def set_rhs(self, variables): L_outer = variables["X-averaged outer SEI thickness"] j_inner = variables["X-averaged inner SEI interfacial current density"] j_outer = variables["X-averaged outer SEI interfacial current density"] - if self.reaction_loc == "interface": - a = 1 - else: - # Note a is dimensionless (has a constant value of 1 if the surface - # area does not change) - a = variables[ - "X-averaged negative electrode surface area to volume ratio" - ] + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) + a = variables["X-averaged negative electrode surface area to volume ratio"] else: L_inner = variables["Inner SEI thickness"] L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - a = variables["Negative electrode surface area to volume ratio"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] v_bar = self.param.v_bar Gamma_SEI = self.param.Gamma_SEI diff --git a/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py b/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py index 1091225f1f..5d4e235e0c 100644 --- a/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py +++ b/pybamm/models/submodels/interface/sei/solvent_diffusion_limited.py @@ -68,20 +68,18 @@ def set_rhs(self, variables): L_outer = variables["X-averaged outer SEI thickness"] j_inner = variables["X-averaged inner SEI interfacial current density"] j_outer = variables["X-averaged outer SEI interfacial current density"] - if self.reaction_loc == "interface": - a = 1 - else: - # Note a is dimensionless (has a constant value of 1 if the surface - # area does not change) - a = variables[ - "X-averaged negative electrode surface area to volume ratio" - ] + # Note a is dimensionless (has a constant value of 1 if the surface + # area does not change) + a = variables["X-averaged negative electrode surface area to volume ratio"] else: L_inner = variables["Inner SEI thickness"] L_outer = variables["Outer SEI thickness"] j_inner = variables["Inner SEI interfacial current density"] j_outer = variables["Outer SEI interfacial current density"] - a = variables["Negative electrode surface area to volume ratio"] + if self.reaction_loc == "interface": + a = 1 + else: + a = variables["Negative electrode surface area to volume ratio"] v_bar = self.param.v_bar Gamma_SEI = self.param.Gamma_SEI diff --git a/pybamm/util.py b/pybamm/util.py index 786dd0a3f7..cab5d995b3 100644 --- a/pybamm/util.py +++ b/pybamm/util.py @@ -285,10 +285,7 @@ def load_function(filename): path = root_path.replace("/", ".") path = path.replace("\\", ".") - try: - module_object = importlib.import_module(path) - except ModuleNotFoundError: - module_object = importlib.import_module("pybamm.input.parameters." + path) + module_object = importlib.import_module(path) return getattr(module_object, tail)