Skip to content

Commit

Permalink
Merge pull request #1808 from pybamm-team/reformat-sei
Browse files Browse the repository at this point in the history
unify sei models and unify plating models
  • Loading branch information
valentinsulzer authored Nov 17, 2021
2 parents b7f3eba + d66e133 commit 69845c6
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 641 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

- Reformatted SEI growth models into a single submodel with conditionals ([#1808](https://github.com/pybamm-team/PyBaMM/pull/1808))
- Stress-induced diffusion is now a separate model option instead of being automatically included when using the particle mechanics submodels ([#1797](https://github.com/pybamm-team/PyBaMM/pull/1797))
- `Experiment`s with drive cycles can be solved ([#1793](https://github.com/pybamm-team/PyBaMM/pull/1793))
- Added surface area to volume ratio as a factor to the SEI equations ([#1790](https://github.com/pybamm-team/PyBaMM/pull/1790))
Expand Down
14 changes: 1 addition & 13 deletions docs/source/models/submodels/interface/sei.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,8 @@ SEI models
.. autoclass:: pybamm.sei.ConstantSEI
:members:

.. autoclass:: pybamm.sei.ElectronMigrationLimited
:members:

.. autoclass:: pybamm.sei.InterstitialDiffusionLimited
.. autoclass:: pybamm.sei.SEIGrowth
:members:

.. autoclass:: pybamm.sei.NoSEI
:members:

.. autoclass:: pybamm.sei.ReactionLimited
:members:

.. autoclass:: pybamm.sei.SolventDiffusionLimited
:members:

.. autoclass:: pybamm.sei.EcReactionLimited
:members:
12 changes: 3 additions & 9 deletions pybamm/models/full_battery_models/base_battery_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,9 @@ class BatteryModelOptions(pybamm.FuzzyDict):
- "none": :class:`pybamm.sei.NoSEI` (no SEI growth)
- "constant": :class:`pybamm.sei.Constant` (constant SEI thickness)
- "reaction limited": :class:`pybamm.sei.ReactionLimited`
- "solvent-diffusion limited":\
:class:`pybamm.sei.SolventDiffusionLimited`
- "electron-migration limited": \
:class:`pybamm.sei.ElectronMigrationLimited`
- "interstitial-diffusion limited": \
:class:`pybamm.sei.InterstitialDiffusionLimited`
- "ec reaction limited": \
:class:`pybamm.sei.EcReactionLimited`
- "reaction limited", "solvent-diffusion limited",\
"electron-migration limited", "interstitial-diffusion limited", \
or "ec reaction limited": :class:`pybamm.sei.SEIGrowth`
* "SEI film resistance" : str
Set the submodel for additional term in the overpotential due to SEI.
The default value is "none" if the "SEI" option is "none", and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,24 +198,8 @@ def set_sei_submodel(self):
self.submodels["sei"] = pybamm.sei.NoSEI(self.param, self.options)
elif self.options["SEI"] == "constant":
self.submodels["sei"] = pybamm.sei.ConstantSEI(self.param, self.options)
elif self.options["SEI"] == "reaction limited":
self.submodels["sei"] = pybamm.sei.ReactionLimited(
self.param, reaction_loc, self.options
)
elif self.options["SEI"] == "solvent-diffusion limited":
self.submodels["sei"] = pybamm.sei.SolventDiffusionLimited(
self.param, reaction_loc, self.options
)
elif self.options["SEI"] == "electron-migration limited":
self.submodels["sei"] = pybamm.sei.ElectronMigrationLimited(
self.param, reaction_loc, self.options
)
elif self.options["SEI"] == "interstitial-diffusion limited":
self.submodels["sei"] = pybamm.sei.InterstitialDiffusionLimited(
self.param, reaction_loc, self.options
)
elif self.options["SEI"] == "ec reaction limited":
self.submodels["sei"] = pybamm.sei.EcReactionLimited(
else:
self.submodels["sei"] = pybamm.sei.SEIGrowth(
self.param, reaction_loc, self.options
)

Expand All @@ -224,14 +208,10 @@ def set_lithium_plating_submodel(self):
self.submodels["lithium plating"] = pybamm.lithium_plating.NoPlating(
self.param, self.options
)
elif self.options["lithium plating"] == "reversible":
self.submodels[
"lithium plating"
] = pybamm.lithium_plating.ReversiblePlating(self.param, self.x_average)
elif self.options["lithium plating"] == "irreversible":
self.submodels[
"lithium plating"
] = pybamm.lithium_plating.IrreversiblePlating(self.param, self.x_average)
else:
self.submodels["lithium plating"] = pybamm.lithium_plating.Plating(
self.param, self.x_average, self.options
)

def set_other_reaction_submodels_to_zero(self):
self.submodels["negative oxygen interface"] = pybamm.interface.NoReaction(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .base_plating import BasePlating
from .no_plating import NoPlating
from .reversible_plating import ReversiblePlating
from .irreversible_plating import IrreversiblePlating
from .plating import Plating
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class BasePlating(BaseInterface):
Origin of the Differential Voltage Minimum Associated with Li Plating in
Lithium-Ion Batteries". Journal of The Electrochemical Society,
167:090540, 2019
**Extends:** :class:`pybamm.interface.BaseInterface`
"""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#
# Class for irreversible lithium plating
# Class for lithium plating
#
import pybamm
from .base_plating import BasePlating


class IrreversiblePlating(BasePlating):
"""Base class for irreversible lithium plating.
class Plating(BasePlating):
"""Class for lithium plating.
Parameters
----------
param : parameter class
The parameters to use for this submodel
x_average : bool
Whether to use x-averaged variables (SPM, SPMe, etc) or full variables (DFN)
options : dict, optional
A dictionary of options to be passed to the model.
References
----------
Expand All @@ -24,8 +27,8 @@ class IrreversiblePlating(BasePlating):
**Extends:** :class:`pybamm.lithium_plating.BasePlating`
"""

def __init__(self, param, x_average):
super().__init__(param)
def __init__(self, param, x_average, options):
super().__init__(param, options)
self.x_average = x_average
pybamm.citations.register("OKane2020")

Expand Down Expand Up @@ -54,14 +57,22 @@ def get_coupled_variables(self, variables):
T = variables["Negative electrode temperature"]
eta_sei = variables["SEI film overpotential"]
c_plated_Li = variables["Lithium plating concentration"]
j0_stripping = param.j0_stripping(c_e_n, c_plated_Li, T)
j0_plating = param.j0_plating(c_e_n, c_plated_Li, T)
phi_ref = param.U_n_ref / param.potential_scale

eta_stripping = delta_phi + phi_ref + eta_sei
eta_plating = -eta_stripping
prefactor = 1 / (2 * (1 + self.param.Theta * T))
# j_stripping is always negative, because there is no stripping, only plating
j_stripping = -j0_plating * pybamm.exp(prefactor * eta_plating)

if self.options["lithium plating"] == "reversible":
j_stripping = j0_stripping * pybamm.exp(
prefactor * eta_stripping
) - j0_plating * pybamm.exp(prefactor * eta_plating)
elif self.options["lithium plating"] == "irreversible":
# j_stripping is always negative, because there is no stripping, only
# plating
j_stripping = -j0_plating * pybamm.exp(prefactor * eta_plating)

variables.update(self._get_standard_overpotential_variables(eta_stripping))
variables.update(self._get_standard_reaction_variables(j_stripping))
Expand Down

This file was deleted.

6 changes: 1 addition & 5 deletions pybamm/models/submodels/interface/sei/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
from .base_sei import BaseModel
from .no_sei import NoSEI
from .constant_sei import ConstantSEI
from .reaction_limited import ReactionLimited
from .solvent_diffusion_limited import SolventDiffusionLimited
from .electron_migration_limited import ElectronMigrationLimited
from .interstitial_diffusion_limited import InterstitialDiffusionLimited
from .ec_reaction_limited import EcReactionLimited
from .sei_growth import SEIGrowth
2 changes: 1 addition & 1 deletion pybamm/models/submodels/interface/sei/base_sei.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _get_standard_concentration_variables(self, variables):
)
v_bar = param.v_bar
# Set scales for the "EC Reaction Limited" model
if isinstance(self, pybamm.sei.EcReactionLimited):
if self.options["SEI"] == "ec reaction limited":
L_inner_0 = 0
L_outer_0 = 1
li_mols_per_sei_mols = 2
Expand Down
Loading

0 comments on commit 69845c6

Please sign in to comment.