Skip to content

Commit

Permalink
Merge branch 'develop' into black_action
Browse files Browse the repository at this point in the history
  • Loading branch information
priyanshuone6 committed Sep 18, 2022
2 parents c95d238 + 96e57ec commit 381aca7
Show file tree
Hide file tree
Showing 55 changed files with 808 additions and 620 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Features

- Added function `pybamm.get_git_commit_info()`, which returns information about the last git commit, useful for reproducibility ([#2293](https://github.com/pybamm-team/PyBaMM/pull/2293))
- Added SEI model for composite electrodes ([#2290](https://github.com/pybamm-team/PyBaMM/pull/2290))
- For experiments, the simulation now automatically checks and skips steps that cannot be performed (e.g. "Charge at 1C until 4.2V" from 100% SOC) ([#2212](https://github.com/pybamm-team/PyBaMM/pull/2212))

## Bug fixes
Expand Down
6 changes: 3 additions & 3 deletions examples/notebooks/models/using-submodels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@
"model.submodels[\n",
" \"Positive particle mechanics\"\n",
"] = pybamm.particle_mechanics.NoMechanics(model.param, \"Positive\", model.options)\n",
"model.submodels[\"sei\"] = pybamm.sei.NoSEI(model.param)\n",
"model.submodels[\"sei on cracks\"] = pybamm.sei.NoSEI(model.param, cracks=True)\n",
"model.submodels[\"sei\"] = pybamm.sei.NoSEI(model.param, model.options)\n",
"model.submodels[\"sei on cracks\"] = pybamm.sei.NoSEI(model.param, model.options, cracks=True)\n",
"model.submodels[\"lithium plating\"] = pybamm.lithium_plating.NoPlating(model.param)"
]
},
Expand Down Expand Up @@ -632,7 +632,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.9.13"
},
"toc": {
"base_numbering": 1,
Expand Down
6 changes: 4 additions & 2 deletions examples/scripts/custom_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@
model.submodels["Positive particle mechanics"] = pybamm.particle_mechanics.NoMechanics(
model.param, "Positive", model.options
)
model.submodels["sei"] = pybamm.sei.NoSEI(model.param)
model.submodels["sei on cracks"] = pybamm.sei.NoSEI(model.param, cracks=True)
model.submodels["sei"] = pybamm.sei.NoSEI(model.param, model.options)
model.submodels["sei on cracks"] = pybamm.sei.NoSEI(
model.param, model.options, cracks=True
)
model.submodels["lithium plating"] = pybamm.lithium_plating.NoPlating(model.param)

# build model
Expand Down
2 changes: 1 addition & 1 deletion pybamm/expression_tree/concatenations.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _concatenation_new_copy(self, children):

def _concatenation_jac(self, children_jacs):
"""Calculate the jacobian of a concatenation."""
return NotImplementedError
raise NotImplementedError

def _evaluate_for_shape(self):
"""See :meth:`pybamm.Symbol.evaluate_for_shape`"""
Expand Down
6 changes: 3 additions & 3 deletions pybamm/expression_tree/operations/evaluate_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class JaxCooMatrix:
"""

def __init__(self, row, col, data, shape):
if not pybamm.have_jax():
if not pybamm.have_jax(): # pragma: no cover
raise ModuleNotFoundError(
"Jax or jaxlib is not installed, please see https://pybamm.readthedocs.io/en/latest/install/GNU-linux.html#optional-jaxsolver" # noqa: E501
)
Expand Down Expand Up @@ -413,7 +413,7 @@ def to_python(symbol, debug=False, output_jax=False):

line_format = "{} = {}"

if debug:
if debug: # pragma: no cover
variable_lines = [
"print('{}'); ".format(
line_format.format(id_to_python_variable(symbol_id, False), symbol_line)
Expand Down Expand Up @@ -540,7 +540,7 @@ class EvaluatorJax:
"""

def __init__(self, symbol):
if not pybamm.have_jax():
if not pybamm.have_jax(): # pragma: no cover
raise ModuleNotFoundError(
"Jax or jaxlib is not installed, please see https://pybamm.readthedocs.io/en/latest/install/GNU-linux.html#optional-jaxsolver" # noqa: E501
)
Expand Down
12 changes: 7 additions & 5 deletions pybamm/expression_tree/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,14 +811,16 @@ def evaluate_ignoring_errors(self, t=0):
return None
elif error.args[0] == "StateVectorDot cannot evaluate input 'y_dot=None'":
return None
else:
else: # pragma: no cover
raise error
except ValueError as e:
except ValueError as error:
# return None if specific ValueError is raised
# (there is a e.g. Time in the tree)
if e.args[0] == "t must be provided":
if error.args[0] == "t must be provided":
return None
raise pybamm.ShapeError("Cannot find shape (original error: {})".format(e))
raise pybamm.ShapeError(
f"Cannot find shape (original error: {error})"
) # pragma: no cover
return result

def evaluates_to_number(self):
Expand Down Expand Up @@ -891,7 +893,7 @@ def create_copy(self):
"""
raise NotImplementedError(
"""method self.new_copy() not implemented
for symbol {!s} of type {}""".format(
for symbol {!s} of type {}""".format(
self, type(self)
)
)
Expand Down
2 changes: 1 addition & 1 deletion pybamm/input/discharge_data/Ecker2015/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Experimental data (Time [s], Terminal voltage [V]) for a 1C and 5C constant current discharge of a Kokam SLPB 75106100 cell at a temperature of 25°C from

>Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
The data were collected from Figure 8 of

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Parameters for a Kokam SLPB 75106100 cell, from the papers

> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery I. determination of parameters." Journal of the Electrochemical Society 162.9 (2015): A1836-A1848.
>Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
The tab placement parameters are taken from measurements in

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

Discharge lithium-ion battery from full charge at 1C, using the initial conditions from the paper

>Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857..
> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857..

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Parameters for a graphite negative electrode, from the papers:

> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery I. determination of parameters." Journal of the Electrochemical Society 162.9 (2015): A1836-A1848.
>Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
The fits to data for the electrode and electrolyte properties are those provided
by Dr. Simon O’Kane in the paper:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Parameters for a Lithium Nickel Cobalt Oxide positive electrode, from the papers

> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery i. determination of parameters." Journal of the Electrochemical Society 162.9 (2015): A1836-A1848.
>Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
The fits to data for the electrode and electrolyte properties are those provided
by Dr. Simon O’Kane in the paper:
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SEI parameters

Example parameters for composite SEI on silicon/graphite. Both phases use the same values, from the paper

> Yang, X., Leng, Y., Zhang, G., Ge, S., Wang, C. (2017). Modeling of lithium plating induced aging of lithium-ion batteries: Transition from linear to nonlinear aging. Journal of Power Sources, 360, 28-40.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Name [units],Value,Reference,Notes
# Empty rows and rows starting with ‘#’ will be ignored,,,
,,,
# SEI properties,,,
Primary: Ratio of lithium moles to SEI moles,2,,Assume SEI made of LEDC and/or Li2CO3
Primary: Inner SEI partial molar volume [m3.mol-1],9.585e-5, Safari paper,
Primary: Outer SEI partial molar volume [m3.mol-1],9.585e-5, Safari paper,
Primary: SEI resistivity [Ohm.m],2e5, Safari paper,
Primary: Initial inner SEI thickness [m], 2.5E-9, 2.5E-9 1/2 of initial thickness in Safari paper,
Primary: Initial outer SEI thickness [m], 2.5E-9, 1/2 of initial thickness in Safari paper,
Primary: EC initial concentration in electrolyte [mol.m-3], 4.541E3, Safari paper,
Primary: EC diffusivity [m2.s-1], 2E-18, adjusted parameter in Yang paper,
Primary: SEI kinetic rate constant [m.s-1], 1e-12, adjusted parameter in Yang paper,
Primary: SEI open-circuit potential [V], 0.4, Safari paper,
Primary: SEI growth activation energy [J.mol-1], 0,,
,,,
Secondary: Ratio of lithium moles to SEI moles,2,,Assume SEI made of LEDC and/or Li2CO3
Secondary: Inner SEI partial molar volume [m3.mol-1],9.585e-5, Safari paper,
Secondary: Outer SEI partial molar volume [m3.mol-1],9.585e-5, Safari paper,
Secondary: SEI resistivity [Ohm.m],2e5, Safari paper,
Secondary: Initial inner SEI thickness [m], 2.5E-9, 2.5E-9 1/2 of initial thickness in Safari paper,
Secondary: Initial outer SEI thickness [m], 2.5E-9, 1/2 of initial thickness in Safari paper,
Secondary: EC initial concentration in electrolyte [mol.m-3], 4.541E3, Safari paper,
Secondary: EC diffusivity [m2.s-1], 2E-18, adjusted parameter in Yang paper,
Secondary: SEI kinetic rate constant [m.s-1], 1e-12, adjusted parameter in Yang paper,
Secondary: SEI open-circuit potential [V], 0.4, Safari paper,
Secondary: SEI growth activation energy [J.mol-1], 0,,
,,,
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Parameters for the separator from the papers

> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery i. determination of parameters." Journal of the Electrochemical Society 162.9 (2015): A1836-A1848.
>Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
> Ecker, Madeleine, et al. "Parameterization of a physico-chemical model of a lithium-ion battery II. Model validation." Journal of The Electrochemical Society 162.9 (2015): A1849-A1857.
The thermal material properties are for a 5 Ah power pouch cell by Kokam. The data are extracted from

Expand Down
13 changes: 8 additions & 5 deletions pybamm/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class EventType(Enum):
should return the time that the discontinuity occurs. The solver will integrate up
to the discontinuity and then restart just after the discontinuity.
INTERPOLANT_EXTRAPOLATION indicates that a pybamm.Interpolant object has been
evaluated outside of the range.
SWITCH indicates an event switch that is used in CasADI "fast with events" model.
"""

TERMINATION = 0
Expand All @@ -29,12 +33,11 @@ class Event:
----------
name: str
A string giving the name of the event
event_type: :class:`pybamm.EventType`
An enum defining the type of event
A string giving the name of the event.
expression: :class:`pybamm.Symbol`
An expression that defines when the event occurs
An expression that defines when the event occurs.
event_type: :class:`pybamm.EventType` (optional)
An enum defining the type of event. By default it is set to TERMINATION.
"""

Expand Down
9 changes: 5 additions & 4 deletions pybamm/models/full_battery_models/base_battery_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ def __init__(self, extra_options):
options["surface form"] != "false"
and options["particle size"] == "single"
and options["particle"] == "Fickian diffusion"
and options["SEI"] == "none"
and options["particle mechanics"] == "none"
and options["loss of active material"] == "none"
and options["lithium plating"] == "none"
Expand All @@ -519,7 +518,7 @@ def __init__(self, extra_options):
"If there are multiple particle phases: 'surface form' cannot be "
"'false', 'particle size' must be 'false', 'particle' must be "
"'Fickian diffusion'. Also the following must "
"be 'none': 'SEI', 'particle mechanics', "
"be 'none': 'particle mechanics', "
"'loss of active material', 'lithium plating'"
)

Expand Down Expand Up @@ -1256,8 +1255,10 @@ def set_voltage_variables(self):
eta_sei_av = self.variables["SEI film overpotential"]
eta_sei_av_dim = self.variables["SEI film overpotential [V]"]
else:
eta_sei_av = self.variables["X-averaged SEI film overpotential"]
eta_sei_av_dim = self.variables["X-averaged SEI film overpotential [V]"]
eta_sei_av = self.variables[f"X-averaged {phase_n}SEI film overpotential"]
eta_sei_av_dim = self.variables[
f"X-averaged {phase_n}SEI film overpotential [V]"
]

# TODO: add current collector losses to the voltage in 3D

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def set_active_material_submodel(self):

def set_sei_submodel(self):

self.submodels["sei"] = pybamm.sei.NoSEI(self.param)
self.submodels["sei"] = pybamm.sei.NoSEI(self.param, self.options)

def set_lithium_plating_submodel(self):

Expand Down
Loading

0 comments on commit 381aca7

Please sign in to comment.