Skip to content

Commit

Permalink
Merge pull request #2533 from pybamm-team/mpm-surface-form
Browse files Browse the repository at this point in the history
Allow differential surface form with MPM
  • Loading branch information
rtimms authored Dec 15, 2022
2 parents 18d3bc5 + 2c49aa3 commit 1f25a1a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- Allow the option "surface form" to be "differential" in the `MPM` ([#2533](https://github.com/pybamm-team/PyBaMM/pull/2533))
- 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))
- `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))
- 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))
Expand Down
31 changes: 9 additions & 22 deletions pybamm/models/full_battery_models/lithium_ion/mpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,41 +40,28 @@ class MPM(SPM):
"""

def __init__(self, options=None, name="Many-Particle Model", build=True):
# Necessary options
if options is None:
options = {"particle size": "distribution", "surface form": "algebraic"}
elif "particle size" in options and options["particle size"] != "distribution":
# Necessary/default options
options = options or {}
if "particle size" in options and options["particle size"] != "distribution":
raise pybamm.OptionError(
"particle size must be 'distribution' for MPM not '{}'".format(
options["particle size"]
)
)
elif "surface form" in options and options["surface form"] != "algebraic":
elif "surface form" in options and options["surface form"] == "false":
raise pybamm.OptionError(
"surface form must be 'algebraic' for MPM not '{}'".format(
options["surface form"]
)
"surface form must be 'algebraic' or 'differential' for MPM not 'false'"
)
else:
options["particle size"] = "distribution"
options["surface form"] = "algebraic"
surface_form = options.get("surface form", "algebraic")
options.update(
{"particle size": "distribution", "surface form": surface_form}
)
super().__init__(options, name, build)

pybamm.citations.register("Kirk2020")
pybamm.citations.register("Kirk2021")

def set_particle_submodel(self):
for domain in ["negative", "positive"]:
if self.options["particle"] == "Fickian diffusion":
submod = pybamm.particle.FickianDiffusion(
self.param, domain, self.options, x_average=True, phase="primary"
)
elif self.options["particle"] == "uniform profile":
submod = pybamm.particle.XAveragedPolynomialProfile(
self.param, domain, self.options, phase="primary"
)
self.submodels[f"{domain} particle"] = submod

@property
def default_parameter_values(self):
default_params = super().default_parameter_values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def test_particle_uniform(self):
modeltest = tests.StandardModelTest(model)
modeltest.test_all()

def test_differential_surface_form(self):
options = {"surface form": "differential"}
model = pybamm.lithium_ion.MPM(options)
modeltest = tests.StandardModelTest(model)
modeltest.test_all()

def test_voltage_control(self):
options = {"operating mode": "voltage"}
model = pybamm.lithium_ion.MPM(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ def test_particle_quadratic(self):
with self.assertRaises(NotImplementedError):
pybamm.lithium_ion.MPM(options)

def test_differential_surface_form(self):
options = {"surface form": "differential"}
model = pybamm.lithium_ion.MPM(options)
model.check_well_posedness()

def test_necessary_options(self):
options = {"particle size": "single"}
with self.assertRaises(pybamm.OptionError):
pybamm.lithium_ion.MPM(options)
options = {"surface form": "none"}

options = {"surface form": "false"}
with self.assertRaises(pybamm.OptionError):
pybamm.lithium_ion.MPM(options)

Expand Down

0 comments on commit 1f25a1a

Please sign in to comment.