Skip to content

Commit 1f25a1a

Browse files
authored
Merge pull request pybamm-team#2533 from pybamm-team/mpm-surface-form
Allow differential surface form with MPM
2 parents 18d3bc5 + 2c49aa3 commit 1f25a1a

File tree

4 files changed

+23
-23
lines changed
  • pybamm/models/full_battery_models/lithium_ion
  • tests
    • integration/test_models/test_full_battery_models/test_lithium_ion
    • unit/test_models/test_full_battery_models/test_lithium_ion

4 files changed

+23
-23
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Features
44

5+
- Allow the option "surface form" to be "differential" in the `MPM` ([#2533](https://github.com/pybamm-team/PyBaMM/pull/2533))
56
- Added variables "Loss of lithium due to loss of active material in negative/positive electrode [mol]". These should be included in the calculation of "total lithium in system" to make sure that lithium is truly conserved. ([#2529](https://github.com/pybamm-team/PyBaMM/pull/2529))
67
- `initial_soc` can now be a string "x V", in which case the simulation is initialized to start from that voltage ([#2508](https://github.com/pybamm-team/PyBaMM/pull/2508))
78
- The `ElectrodeSOH` solver can now calculate electrode balance based on a target "cell capacity" (requires cell capacity "Q" as input), as well as the default "cyclable cell capacity" (requires cyclable lithium capacity "Q_Li" as input). Use the keyword argument `known_value` to control which is used. ([#2508](https://github.com/pybamm-team/PyBaMM/pull/2508))

pybamm/models/full_battery_models/lithium_ion/mpm.py

+9-22
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,28 @@ class MPM(SPM):
4040
"""
4141

4242
def __init__(self, options=None, name="Many-Particle Model", build=True):
43-
# Necessary options
44-
if options is None:
45-
options = {"particle size": "distribution", "surface form": "algebraic"}
46-
elif "particle size" in options and options["particle size"] != "distribution":
43+
# Necessary/default options
44+
options = options or {}
45+
if "particle size" in options and options["particle size"] != "distribution":
4746
raise pybamm.OptionError(
4847
"particle size must be 'distribution' for MPM not '{}'".format(
4948
options["particle size"]
5049
)
5150
)
52-
elif "surface form" in options and options["surface form"] != "algebraic":
51+
elif "surface form" in options and options["surface form"] == "false":
5352
raise pybamm.OptionError(
54-
"surface form must be 'algebraic' for MPM not '{}'".format(
55-
options["surface form"]
56-
)
53+
"surface form must be 'algebraic' or 'differential' for MPM not 'false'"
5754
)
5855
else:
59-
options["particle size"] = "distribution"
60-
options["surface form"] = "algebraic"
56+
surface_form = options.get("surface form", "algebraic")
57+
options.update(
58+
{"particle size": "distribution", "surface form": surface_form}
59+
)
6160
super().__init__(options, name, build)
6261

6362
pybamm.citations.register("Kirk2020")
6463
pybamm.citations.register("Kirk2021")
6564

66-
def set_particle_submodel(self):
67-
for domain in ["negative", "positive"]:
68-
if self.options["particle"] == "Fickian diffusion":
69-
submod = pybamm.particle.FickianDiffusion(
70-
self.param, domain, self.options, x_average=True, phase="primary"
71-
)
72-
elif self.options["particle"] == "uniform profile":
73-
submod = pybamm.particle.XAveragedPolynomialProfile(
74-
self.param, domain, self.options, phase="primary"
75-
)
76-
self.submodels[f"{domain} particle"] = submod
77-
7865
@property
7966
def default_parameter_values(self):
8067
default_params = super().default_parameter_values

tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_mpm.py

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def test_particle_uniform(self):
4242
modeltest = tests.StandardModelTest(model)
4343
modeltest.test_all()
4444

45+
def test_differential_surface_form(self):
46+
options = {"surface form": "differential"}
47+
model = pybamm.lithium_ion.MPM(options)
48+
modeltest = tests.StandardModelTest(model)
49+
modeltest.test_all()
50+
4551
def test_voltage_control(self):
4652
options = {"operating mode": "voltage"}
4753
model = pybamm.lithium_ion.MPM(options)

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,17 @@ def test_particle_quadratic(self):
5555
with self.assertRaises(NotImplementedError):
5656
pybamm.lithium_ion.MPM(options)
5757

58+
def test_differential_surface_form(self):
59+
options = {"surface form": "differential"}
60+
model = pybamm.lithium_ion.MPM(options)
61+
model.check_well_posedness()
62+
5863
def test_necessary_options(self):
5964
options = {"particle size": "single"}
6065
with self.assertRaises(pybamm.OptionError):
6166
pybamm.lithium_ion.MPM(options)
62-
options = {"surface form": "none"}
67+
68+
options = {"surface form": "false"}
6369
with self.assertRaises(pybamm.OptionError):
6470
pybamm.lithium_ion.MPM(options)
6571

0 commit comments

Comments
 (0)