Skip to content

Commit 9e92a46

Browse files
committed
#2669 PSD with SPM
1 parent eb84a83 commit 9e92a46

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

pybamm/models/full_battery_models/base_battery_model.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -847,12 +847,14 @@ def options(self, extra_options):
847847
raise pybamm.OptionError(
848848
"x-average side reactions cannot be 'false' for SPM models"
849849
)
850-
if isinstance(self, pybamm.lithium_ion.SPM) and not isinstance(
851-
self, pybamm.lithium_ion.MPM
852-
):
853-
if options["particle size"] == "distribution":
850+
if isinstance(self, pybamm.lithium_ion.SPM):
851+
if (
852+
"distribution" in options["particle size"]
853+
and options["surface form"] == "false"
854+
):
854855
raise pybamm.OptionError(
855-
"'particle size' should be 'single' for SPM and SPMe models"
856+
"surface form must be 'algebraic' or 'differential' if "
857+
" 'particle size' contains a 'distribution'"
856858
)
857859
if isinstance(self, pybamm.lead_acid.BaseModel):
858860
if options["thermal"] != "isothermal" and options["dimensionality"] != 0:

tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ def test_well_posed_size_distribution_tuple(self):
2727
options = {"particle size": ("single", "distribution")}
2828
self.check_well_posedness(options)
2929

30+
def test_well_posed_current_sigmoid_ocp_with_psd(self):
31+
options = {
32+
"open circuit potential": "current sigmoid",
33+
"particle size": "distribution",
34+
}
35+
self.check_well_posedness(options)
36+
3037
def test_well_posed_external_circuit_explicit_power(self):
3138
options = {"operating mode": "explicit power"}
3239
self.check_well_posedness(options)

tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ def test_x_average_options(self):
4040
pybamm.lithium_ion.SPM(options)
4141

4242
def test_distribution_options(self):
43-
with self.assertRaisesRegex(pybamm.OptionError, "particle size"):
43+
with self.assertRaisesRegex(pybamm.OptionError, "surface form"):
4444
pybamm.lithium_ion.SPM({"particle size": "distribution"})
4545

46+
def test_particle_size_distribution(self):
47+
options = {"surface form": "algebraic", "particle size": "distribution"}
48+
self.check_well_posedness(options)
49+
4650
def test_new_model(self):
4751
model = pybamm.lithium_ion.SPM({"thermal": "x-full"})
4852
new_model = model.new_copy()

0 commit comments

Comments
 (0)