Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow differential surface form with MPM #2533

Merged
merged 6 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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