Skip to content

Commit

Permalink
Merge branch 'issue-923-reformat-electrolyte' into issue-546-convection
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Apr 5, 2020
2 parents 90e15d5 + 803a94e commit 9508f6b
Show file tree
Hide file tree
Showing 66 changed files with 778 additions and 171 deletions.
26 changes: 16 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# [Unreleased](https://github.com/pybamm-team/PyBaMM)
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)

## Optimizations

- Made `QuickPlot` compatible with Google Colab ([#935](https://github.com/pybamm-team/PyBaMM/pull/935))
- Sped up model building ([#927](https://github.com/pybamm-team/PyBaMM/pull/927))
- Changed default solver for lead-acid to `CasadiSolver` ([#927](https://github.com/pybamm-team/PyBaMM/pull/927))

## Bug fixes

- Reformatted electrolyte submodels ([#927](https://github.com/pybamm-team/PyBaMM/pull/927))

# [v0.2.1](https://github.com/pybamm-team/PyBaMM/tree/v0.2.1) - 2020-03-31

New expression tree node types, models, parameter sets and solvers, as well as general bug fixes and new examples.

## Features

Expand All @@ -9,9 +23,6 @@
- Added functionality to broadcast to edges ([#891](https://github.com/pybamm-team/PyBaMM/pull/891))
- Reformatted and cleaned up `QuickPlot` ([#886](https://github.com/pybamm-team/PyBaMM/pull/886))
- Added thermal effects to lead-acid models ([#885](https://github.com/pybamm-team/PyBaMM/pull/885))
- Add new symbols `VariableDot`, representing the derivative of a variable wrt time,
and `StateVectorDot`, representing the derivative of a state vector wrt time
([#858](https://github.com/pybamm-team/PyBaMM/issues/858))
- Added a helper function for info on function parameters ([#881](https://github.com/pybamm-team/PyBaMM/pull/881))
- Added additional notebooks showing how to create and compare models ([#877](https://github.com/pybamm-team/PyBaMM/pull/877))
- Added `Minimum`, `Maximum` and `Sign` operators
Expand All @@ -24,14 +35,9 @@
and `StateVectorDot`, representing the derivative of a state vector wrt time
([#858](https://github.com/pybamm-team/PyBaMM/issues/858))

## Optimizations

- Sped up model building ([#927](https://github.com/pybamm-team/PyBaMM/pull/927))
- Changed default solver for lead-acid to `CasadiSolver` ([#927](https://github.com/pybamm-team/PyBaMM/pull/927))

## Bug fixes

- Reformatted electrolyte submodels ([#927](https://github.com/pybamm-team/PyBaMM/pull/927))
- Fixed tight layout for QuickPlot in jupyter notebooks ([#930](https://github.com/pybamm-team/PyBaMM/pull/930))
- Fixed bug raised if function returns a scalar ([#919](https://github.com/pybamm-team/PyBaMM/pull/919))
- Fixed event handling in `ScipySolver` ([#905](https://github.com/pybamm-team/PyBaMM/pull/905))
- Made input handling clearer in solvers ([#905](https://github.com/pybamm-team/PyBaMM/pull/905))
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# The short X.Y version
version = "0.2"
# The full version, including alpha/beta/rc tags
release = "0.2.0"
release = "0.2.1"


# -- General configuration ---------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Surface Form

.. toctree::

full_surface_form_stefan_maxwell_conductivity
leading_surface_form_stefan_maxwell_conductivity
full_surface_form_conductivity
leading_surface_form_conductivity
8 changes: 4 additions & 4 deletions examples/scripts/compare_lead_acid.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

# load models
models = [
# pybamm.lead_acid.LOQS(),
# # pybamm.lead_acid.FOQS(),
# pybamm.lead_acid.Composite(),
pybamm.lead_acid.LOQS(),
pybamm.lead_acid.FOQS(),
pybamm.lead_acid.CompositeExtended(),
pybamm.lead_acid.Full(),
]

# load parameter values and process models and geometry
param = models[0].default_parameter_values
param.update({"Current function [A]": 10, "Initial State of Charge": 1})
param.update({"Current function [A]": 85, "Initial State of Charge": 1})
for model in models:
param.process_model(model)

Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/drive_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# create and run simulation using the CasadiSolver in "fast" mode, remembering to
# pass in the updated parameters
sim = pybamm.Simulation(
model, parameter_values=param, solver=pybamm.CasadiSolver(mode="fast"),
model, parameter_values=param, solver=pybamm.CasadiSolver(mode="fast")
)
sim.solve()
sim.plot(
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/experimental_protocols/cccv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Hold at 4.1 V until 50 mA",
"Rest for 1 hour",
]
* 3,
* 3
)
model = pybamm.lithium_ion.DFN()
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver())
Expand Down
4 changes: 1 addition & 3 deletions examples/scripts/experimental_protocols/gitt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import pybamm

pybamm.set_logging_level("INFO")
experiment = pybamm.Experiment(
["Discharge at C/20 for 1 hour", "Rest for 1 hour"] * 20,
)
experiment = pybamm.Experiment(["Discharge at C/20 for 1 hour", "Rest for 1 hour"] * 20)
model = pybamm.lithium_ion.DFN()
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver())
sim.solve()
Expand Down
8 changes: 8 additions & 0 deletions pybamm/CITATIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ year={2019},
publisher={The Electrochemical Society}
}

@article{Mohtat2020,
author = {Mohtat, Peyman and Siegel, Jason B and Stefanopoulou, Anna G},
title = {{High C-rate Differential Expansion and Voltage Model for Li-ion Batteries}},
journal = {Submitted for publication},
year = {2019},
publisher={ECSarXiv}
}

@article{scikits-odes,
year = {2018},
month = {feb},
Expand Down
2 changes: 1 addition & 1 deletion pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def version(formatted=False):
# other
#
from .processed_variable import ProcessedVariable
from .quick_plot import QuickPlot, ax_min, ax_max
from .quick_plot import QuickPlot, dynamic_plot, ax_min, ax_max

from .simulation import Simulation, load_sim, is_notebook

Expand Down
4 changes: 2 additions & 2 deletions pybamm/expression_tree/broadcasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ class FullBroadcast(Broadcast):
"A class for full broadcasts"

def __init__(self, child, broadcast_domain, auxiliary_domains, name=None):
if auxiliary_domains == "current collector":
auxiliary_domains = {"secondary": "current collector"}
if isinstance(auxiliary_domains, str):
auxiliary_domains = {"secondary": auxiliary_domains}
super().__init__(
child,
broadcast_domain,
Expand Down
40 changes: 26 additions & 14 deletions pybamm/expression_tree/state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ def __init__(
if y_slices[0].start is None:
name = base_name + "[:{:d}]".format(y_slice.stop)
else:
name = base_name + \
"[{:d}:{:d}".format(y_slices[0].start, y_slices[0].stop)
name = base_name + "[{:d}:{:d}".format(
y_slices[0].start, y_slices[0].stop
)
if len(y_slices) > 1:
name += ",{:d}:{:d}".format(y_slices[1].start, y_slices[1].stop)
if len(y_slices) > 2:
Expand Down Expand Up @@ -222,10 +223,14 @@ def __init__(
auxiliary_domains=None,
evaluation_array=None,
):
super().__init__(*y_slices,
base_name="y", name=name, domain=domain,
auxiliary_domains=auxiliary_domains,
evaluation_array=evaluation_array)
super().__init__(
*y_slices,
base_name="y",
name=name,
domain=domain,
auxiliary_domains=auxiliary_domains,
evaluation_array=evaluation_array,
)

def _base_evaluate(self, t=None, y=None, y_dot=None, inputs=None):
""" See :meth:`pybamm.Symbol._base_evaluate()`. """
Expand All @@ -245,10 +250,13 @@ def diff(self, variable):
if variable.id == self.id:
return pybamm.Scalar(1)
if variable.id == pybamm.t.id:
return StateVectorDot(*self._y_slices, name=self.name + "'",
domain=self.domain,
auxiliary_domains=self.auxiliary_domains,
evaluation_array=self.evaluation_array)
return StateVectorDot(
*self._y_slices,
name=self.name + "'",
domain=self.domain,
auxiliary_domains=self.auxiliary_domains,
evaluation_array=self.evaluation_array,
)
else:
return pybamm.Scalar(0)

Expand Down Expand Up @@ -289,10 +297,14 @@ def __init__(
auxiliary_domains=None,
evaluation_array=None,
):
super().__init__(*y_slices,
base_name="y_dot", name=name, domain=domain,
auxiliary_domains=auxiliary_domains,
evaluation_array=evaluation_array)
super().__init__(
*y_slices,
base_name="y_dot",
name=name,
domain=domain,
auxiliary_domains=auxiliary_domains,
evaluation_array=evaluation_array,
)

def _base_evaluate(self, t=None, y=None, y_dot=None, inputs=None):
""" See :meth:`pybamm.Symbol._base_evaluate()`. """
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import pybamm


def graphite_diffusivity_PeymanMPM(sto, T, T_inf, E_D_s, R_g):
"""
Graphite diffusivity as a function of stochiometry, in this case the
diffusivity is taken to be a constant. The value is taken from Peyman MPM.
References
----------
.. [1] http://www.cchem.berkeley.edu/jsngrp/fortran.html
Parameters
----------
sto: :class: `numpy.Array`
Electrode stochiometry
T: :class: `numpy.Array`
Dimensional temperature
T_inf: double
Reference temperature
E_D_s: double
Solid diffusion activation energy
R_g: double
The ideal gas constant
Returns
-------
: double
Solid diffusivity
"""

D_ref = 5.0 * 10 ** (-15)
arrhenius = pybamm.exp(E_D_s / R_g * (1 / T_inf - 1 / T))

# Removing the fudge factor 0 * sto requires different handling of either
# either simplifications or how sto is passed into this function.
# See #547
return D_ref * arrhenius + 0 * sto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pybamm


def graphite_electrolyte_reaction_rate_PeymanMPM(T, T_inf, E_r, R_g):
"""
Reaction rate for Butler-Volmer reactions between graphite and LiPF6 in EC:DMC.
Check the unit of Reaction rate constant k0 is from Peyman MPM.
References
----------
.. [2] http://www.cchem.berkeley.edu/jsngrp/fortran.html
Parameters
----------
T: :class: `numpy.Array`
Dimensional temperature
T_inf: double
Reference temperature
E_r: double
Reaction activation energy
R_g: double
The ideal gas constant
Returns
-------
:`numpy.Array`
Reaction rate
"""
m_ref = 1.061 * 10 ** (-6) # unit has been converted
arrhenius = pybamm.exp(E_r / R_g * (1 / T_inf - 1 / T))

return m_ref * arrhenius
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def graphite_entropic_change_PeymanMPM(sto, c_n_max):
"""
Graphite entropic change in open circuit potential (OCP) at a temperature of
298.15K as a function of the stochiometry taken from [1]
References
----------
.. [1] K.E. Thomas, J. Newman, "Heats of mixing and entropy in porous insertion
electrode", J. of Power Sources 119 (2003) 844-849
Parameters
----------
sto: double
Stochiometry of material (li-fraction)
"""

du_dT = 10 ** (-3) * (
0.28
- 1.56 * sto
- 8.92 * sto ** (2)
+ 57.21 * sto ** (3)
- 110.7 * sto ** (4)
+ 90.71 * sto ** (5)
- 27.14 * sto ** (6)
)

return du_dT
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pybamm


def graphite_ocp_PeymanMPM(sto):
"""
Graphite Open Circuit Potential (OCP) as a function of the
stochiometry. The fit is taken from Peyman MPM [1].
References
----------
.. [1] Peyman Mohtat et al, MPM (to be submitted)
"""

u_eq = (
0.063
+ 0.8 * pybamm.exp(-75 * (sto + 0.007))
- 0.0120 * pybamm.tanh((sto - 0.127) / 0.016)
- 0.0118 * pybamm.tanh((sto - 0.155) / 0.016)
- 0.0035 * pybamm.tanh((sto - 0.220) / 0.020)
- 0.0095 * pybamm.tanh((sto - 0.190) / 0.013)
- 0.0145 * pybamm.tanh((sto - 0.490) / 0.020)
- 0.0800 * pybamm.tanh((sto - 1.030) / 0.055)
)

# u_eq = 1.0 + (0 * sto)

return u_eq


# if __name__ == "__main__": # pragma: no cover
# import matplotlib.pyplot as plt
# import numpy as np

# x = np.linspace(0, 1)
# plt.plot(x, graphite_ocp_PeymanMPM(x))
# plt.show()
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Name [units],Value,Reference,Notes
# Empty rows and rows starting with ‘#’ will be ignored,,,
,,,
# Electrode properties,,,
Negative electrode conductivity [S.m-1],100,Scott Moura FastDFN,no info from Peyman MPM
Maximum concentration in negative electrode [mol.m-3],28746,Peyman MPM,
Negative electrode diffusion coefficient [m2.s-1],5.0E-15,Peyman MPM,
Negative electrode diffusivity [m2.s-1],[function]graphite_diffusivity_PeymanMPM,,
Negative electrode OCP [V],[function]graphite_ocp_PeymanMPM,Peyman MPM,
,,,
# Microstructure,,,
Negative electrode porosity,0.3,Peyman MPM,
Negative electrode active material volume fraction,0.61,Peyman MPM,rest is binder
Negative particle radius [m],2.5E-06,Peyman MPM,
Negative particle distribution in x,1,,
Negative electrode surface area density [m-1],732000,Peyman MPM,Eq. (48)
Negative electrode Bruggeman coefficient (electrode),1.5,Peyman MPM,
Negative electrode Bruggeman coefficient (electrolyte),1.5,Peyman MPM,
Negative electrode tortuosity, 0.16,
,,,
# Interfacial reactions,,,
Negative electrode cation signed stoichiometry,-1,,no info from Peyman MPM
Negative electrode electrons in reaction,1,,no info from Peyman MPM
Negative electrode reference exchange-current density [A.m-2(m3.mol)1.5],1.061E-6,Peyman MPM,convert unit
Reference OCP vs SHE in the negative electrode [V],,,
Negative electrode charge transfer coefficient,0.5,Peyman MPM,
Negative electrode double-layer capacity [F.m-2],0.2,,no info from Peyman MPM
,,,
# Density,,,
Negative electrode density [kg.m-3],3100,Peyman MPM, cell lumped value
,,,
# Thermal parameters,,,
Negative electrode specific heat capacity [J.kg-1.K-1],1100,Peyman MPM,cell lumped value
Negative electrode thermal conductivity [W.m-1.K-1],1.7,,no info from Peyman MPM
Negative electrode OCP entropic change [V.K-1],[function]graphite_entropic_change_PeymanMPM,,
,,,
# Activation energies,,,
Reference temperature [K],298.15,25C,
Negative electrode reaction rate,[function]graphite_electrolyte_reaction_rate_PeymanMPM,,
Negative reaction rate activation energy [J.mol-1],37480,,no info from Peyman MPM
Negative solid diffusion activation energy [J.mol-1],42770,,no info from Peyman MPM
Loading

0 comments on commit 9508f6b

Please sign in to comment.