From ea6b715b202195b761faf40ced217ed8e87287b7 Mon Sep 17 00:00:00 2001 From: Shaurya Shukla Date: Sun, 11 Oct 2026 23:33:54 -0400 Subject: [PATCH 1/3] fix: broadcast the average SEI film overpotential with a size distribution With "SEI film resistance": "average", eta_sei is the x-averaged film drop on the current collector. With "particle size": "distribution" resolved through the electrode (SPMe, DFN, Newman-Tobias), eta_r lives on the particle-size domain with the electrode as its secondary domain, so adding eta_sei raised DomainError: children must have same or empty domains, not ['negative particle size'] and ['current collector']. Broadcast eta_sei onto the electrode in that case. Models that already built are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../submodels/interface/kinetics/base_kinetics.py | 4 ++++ .../test_lithium_ion/base_lithium_ion_tests.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/pybamm/src/pybamm/models/submodels/interface/kinetics/base_kinetics.py b/packages/pybamm/src/pybamm/models/submodels/interface/kinetics/base_kinetics.py index 365daa1ca3..e3d12bb28b 100644 --- a/packages/pybamm/src/pybamm/models/submodels/interface/kinetics/base_kinetics.py +++ b/packages/pybamm/src/pybamm/models/submodels/interface/kinetics/base_kinetics.py @@ -132,6 +132,10 @@ def get_coupled_variables(self, variables): R_sei = self.phase_param.R_sei L_sei_av = variables[f"X-averaged {domain} {phase_name}SEI thickness [m]"] eta_sei = -j_tot_av * L_sei_av * R_sei + # With a size distribution resolved through the electrode, eta_r has the + # electrode as its secondary domain, which a current collector term skips + if eta_r.domains["secondary"] == [f"{domain} electrode"]: + eta_sei = pybamm.PrimaryBroadcast(eta_sei, f"{domain} electrode") elif self.options["SEI film resistance"] == "distributed": R_sei = self.phase_param.R_sei L_sei = variables[f"{Domain} {phase_name}SEI thickness [m]"] diff --git a/packages/pybamm/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py b/packages/pybamm/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py index 965f5b8949..8cd44dcfdc 100644 --- a/packages/pybamm/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py +++ b/packages/pybamm/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py @@ -589,6 +589,16 @@ def test_well_posed_psd_swelling_only(self): } self.check_well_posedness(options) + def test_well_posed_psd_sei_film_resistance(self): + for film in ["average", "distributed"]: + options = { + "particle size": "distribution", + "surface form": "algebraic", + "SEI": "constant", + "SEI film resistance": film, + } + self.check_well_posedness(options) + def test_well_posed_psd_hysteresis_thermal(self): # Regression test: hysteresis OCP + particle size distribution + a # non-isothermal thermal submodel previously raised a DomainError in From 8bf37082a6dc1afe11fd428a9c6290c19c639391 Mon Sep 17 00:00:00 2001 From: Shaurya Shukla Date: Sun, 11 Oct 2026 23:35:41 -0400 Subject: [PATCH 2/3] add changelog entry for #5892 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9f8ccc197..637ac4dd1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # [Unreleased](https://github.com/pybamm-team/PyBaMM/) +## Bug fixes + +- `"SEI film resistance": "average"` now works with `"particle size": "distribution"` in SPMe, DFN and Newman-Tobias, which raised a `DomainError` when building the model. ([#5892](https://github.com/pybamm-team/PyBaMM/pull/5892)) + # [v26.10.0.0](https://github.com/pybamm-team/PyBaMM/tree/pybamm-v26.10.0.0) - 2026-10-09 ## Breaking changes From e78ee2ff79c4f1181bb8ac36d930c99ac72ba6af Mon Sep 17 00:00:00 2001 From: Shaurya Shukla Date: Mon, 12 Oct 2026 03:06:57 -0400 Subject: [PATCH 3/3] test: pass the total interfacial current density option explicitly Co-Authored-By: Claude Opus 5.5 --- .../test_lithium_ion/base_lithium_ion_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/pybamm/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py b/packages/pybamm/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py index 8cd44dcfdc..e9011afb51 100644 --- a/packages/pybamm/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py +++ b/packages/pybamm/tests/unit/test_models/test_full_battery_models/test_lithium_ion/base_lithium_ion_tests.py @@ -590,12 +590,13 @@ def test_well_posed_psd_swelling_only(self): self.check_well_posedness(options) def test_well_posed_psd_sei_film_resistance(self): - for film in ["average", "distributed"]: + for film, j_tot_state in [("average", "false"), ("distributed", "true")]: options = { "particle size": "distribution", "surface form": "algebraic", "SEI": "constant", "SEI film resistance": film, + "total interfacial current density as a state": j_tot_state, } self.check_well_posedness(options)