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

Many-Particle Models #1529

Merged
merged 82 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
0d94d25
added BasicMPM class to lithium_ion
tobykirk Jun 17, 2020
fbfe2d2
Merge branch 'develop' into add-PSD-models
tobykirk Jun 17, 2020
095484c
expanded output variables
tobykirk Jun 18, 2020
ec61fb3
rename model class
tobykirk Jun 24, 2020
86a21b5
renamed PSD model file
tobykirk Jun 24, 2020
bf9949b
Merge branch 'develop' into add-PSD-models
tobykirk Jun 24, 2020
1360cc5
added interp for 1D ProcessedVariables in particle-size domain R
tobykirk Jun 24, 2020
274413c
fixed style to black
tobykirk Jun 25, 2020
6b081c2
Merge branch 'develop' into add-PSD-models
tobykirk Jun 26, 2020
4bbc39b
added PSDModel incorporating submodel structure
tobykirk Jul 13, 2020
ad2b172
tidied up PSDModel
tobykirk Jul 13, 2020
1a97965
Merge branch 'develop' into add-PSD-models
tobykirk Jul 13, 2020
a2b7df8
quick plotting for 2D vars of particle size
tobykirk Jul 13, 2020
534b60b
tidied up PSD output variables
tobykirk Jul 14, 2020
8487ef9
added fast diffusion PSD submodels
tobykirk Jul 14, 2020
9eb72e4
Default geometry and meshes etc for PSDs
tobykirk Jul 16, 2020
0c2850f
added R-average
tobykirk Jul 17, 2020
5f489df
fied typos and style
tobykirk Jul 17, 2020
5d938a8
added ManyPSD submodels, and the option to DFN
tobykirk Jul 17, 2020
6e41c07
added option to use SPM as MPM
tobykirk Jul 17, 2020
61ee854
added PSD with fast diffusion submodel to DFN
tobykirk Jul 17, 2020
af48cf0
add distribution parameters to Marquis2019 set
tobykirk Jul 30, 2020
010ac48
automatic distribution normalising
tobykirk Aug 18, 2020
4525057
changed event tolerance
tobykirk Nov 13, 2020
11f1188
revert submodel selection changes to SPM
tobykirk Jun 1, 2021
af4e016
fix SPM interface submodel selection
tobykirk Jun 1, 2021
686c5e2
fix tests
tobykirk Jun 1, 2021
7c91e3f
Merge branch 'develop' into many-particle-models
tobykirk Jun 1, 2021
683f008
fixed MPM
tobykirk Jun 2, 2021
5784af9
name changes to domains, options, spatial vars
tobykirk Jun 4, 2021
65d568f
refactor of size distribution submodels
tobykirk Jun 4, 2021
0a379ab
fix fast diffusion MP submodels and output vars
tobykirk Jun 4, 2021
ba8988b
fix tests
tobykirk Jun 4, 2021
003bff6
added citations to Kirk et al 2020
tobykirk Jun 4, 2021
9050cf2
add unit tests for MPM and submodels
tobykirk Jun 8, 2021
b1a33f8
added standard integration tests for MPM
tobykirk Jun 8, 2021
df13141
change MPM submodels to surface form
tobykirk Jun 10, 2021
415ee98
delete plots_of_MPM script
tobykirk Jun 10, 2021
a6aa477
remove test for Fickian MPDFN
tobykirk Jun 10, 2021
b7d95d8
Merge branch 'develop' into many-particle-models
tobykirk Jun 10, 2021
ea72822
fixed surface area for MP models and tests
tobykirk Jun 11, 2021
31855e7
incompatible options with size distributions
tobykirk Jun 11, 2021
23b9f4a
rename mean radii variables
tobykirk Jun 11, 2021
582d56b
Merge branch 'develop' into many-particle-models
tobykirk Jun 15, 2021
ea1c372
added voltage control to MPM
tobykirk Jun 15, 2021
57b706a
added more distribution output vars
tobykirk Jun 15, 2021
8f4b30e
added doc index files for MPM and submodels
tobykirk Jun 15, 2021
a11b5ec
fix distribution output variables
tobykirk Jun 15, 2021
a6582b6
add output vars to fix lead acid tests
tobykirk Jun 30, 2021
e2a0840
added Kirk2021 citation
tobykirk Jun 30, 2021
e0de928
added MPM notebook
tobykirk Jun 30, 2021
95aecaf
Merge branch 'develop' into many-particle-models
tobykirk Jun 30, 2021
683674c
removed the 'ManyDistributions' submodels
tobykirk Jun 30, 2021
532d47a
revert DFN to develop
tobykirk Jun 30, 2021
b3c12eb
remove size distributions from Marquis param set
tobykirk Jun 30, 2021
f93fa09
remove test for 'FastManyDistributions' submodel
tobykirk Jun 30, 2021
f00d86d
change name of R_average
tobykirk Jul 5, 2021
e081d08
fix exchange current density tests
tobykirk Jul 5, 2021
c955d72
add function get_size_distribution_parameters
tobykirk Jul 6, 2021
23fa913
refactor interface distribution variables
tobykirk Jul 6, 2021
009752f
reduce code duplication in quick_plot
tobykirk Jul 6, 2021
a8e5c16
Merge branch 'develop' into add-mpm
tobykirk Jul 6, 2021
2ca98d4
remove some mpm tests
tobykirk Jul 6, 2021
b9eb06e
change MPM init and reduce tests
tobykirk Jul 7, 2021
339b9f0
moved particle size params to geometric parameters
tobykirk Jul 7, 2021
c2f284b
Merge branch 'develop' into add-mpm
tobykirk Jul 7, 2021
494bf0c
Merge branch 'develop' into add-mpm
tobykirk Jul 16, 2021
82ea288
move default standard deviations
tobykirk Jul 16, 2021
edf67bb
change definition of particle flux
tobykirk Jul 16, 2021
de5afe3
fix notebooks
tobykirk Jul 16, 2021
3fbe86a
add broadcast tests with particle size
tobykirk Jul 20, 2021
c7472ec
add particle size processed variable tests
tobykirk Jul 20, 2021
3e9261d
add mpm tests for coverage
tobykirk Jul 20, 2021
85989da
remove untested code for size distr in DFN
tobykirk Jul 22, 2021
7b87152
tests to increase coverage
tobykirk Jul 22, 2021
681826a
Merge branch 'develop' into add-mpm
tobykirk Jul 27, 2021
8a964b3
update changelog
tobykirk Jul 27, 2021
49a00d6
Merge branch 'develop' into add-mpm
valentinsulzer Jul 28, 2021
7c50b99
reduced code duplication in processed var tests
tobykirk Jul 29, 2021
57f9e08
Merge remote-tracking branch 'upstream/develop' into add-mpm
tobykirk Jul 29, 2021
515590d
remove unusued variable to fix codacy
tobykirk Jul 29, 2021
34700c0
Merge branch 'develop' into add-mpm
tobykirk Jul 29, 2021
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
2 changes: 1 addition & 1 deletion docs/source/expression_tree/unary_operator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Unary Operators

.. autofunction:: pybamm.r_average

.. autofunction:: pybamm.R_average
.. autofunction:: pybamm.size_average

.. autofunction:: pybamm.z_average

Expand Down
55 changes: 19 additions & 36 deletions examples/notebooks/models/MPM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fb2cf1a877d243cea4aa5eae1144b78b",
"model_id": "b66ea72826fe48e69565e67441ebc889",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -312,7 +312,7 @@
{
"data": {
"text/plain": [
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f1c534be160>"
"<pybamm.plotting.quick_plot.QuickPlot at 0x7fd1e0c47fd0>"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -448,24 +448,6 @@
"metadata": {},
"outputs": [],
"source": [
"# Define a lognormal distribution\n",
"def lognormal(R, R_av, sd):\n",
" '''\n",
" A lognormal distribution with arguments\n",
" R : particle radius\n",
" R_av: mean particle radius\n",
" sd : standard deviation\n",
" '''\n",
" # calculate usual lognormal parameters\n",
" mu_ln = pybamm.log(R_av ** 2 / pybamm.sqrt(R_av ** 2 + sd ** 2))\n",
" sigma_ln = pybamm.sqrt(pybamm.log(1 + sd ** 2 / R_av ** 2))\n",
" return (\n",
" pybamm.exp(-((pybamm.log(R) - mu_ln) ** 2) / (2 * sigma_ln ** 2))\n",
" / pybamm.sqrt(2 * np.pi * sigma_ln ** 2)\n",
" / R\n",
" )\n",
"\n",
"\n",
"# Parameter set (no distribution parameters by default)\n",
"params = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)\n",
"\n",
Expand All @@ -483,15 +465,16 @@
"R_max_n = 2 * R_a_n_dim\n",
"R_max_p = 3 * R_a_p_dim\n",
"\n",
"# Set the area-weighted particle-size distributions\n",
"# Note: the only argument must be the particle size R\n",
"# Set the area-weighted particle-size distributions.\n",
"# Choose a lognormal (but any pybamm function could be used)\n",
"def f_a_dist_n_dim(R):\n",
" return lognormal(R, R_a_n_dim, sd_a_n_dim)\n",
" return pybamm.lognormal(R, R_a_n_dim, sd_a_n_dim)\n",
"\n",
"\n",
"def f_a_dist_p_dim(R):\n",
" return lognormal(R, R_a_p_dim, sd_a_p_dim)\n",
"\n"
" return pybamm.lognormal(R, R_a_p_dim, sd_a_p_dim)\n",
"\n",
"# Note: the only argument must be the particle size R\n"
]
},
{
Expand Down Expand Up @@ -522,7 +505,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5dff78a1e2bc4a1884d5811ff443897c",
"model_id": "8b545ec433484ec1b738983bb0d90b80",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -536,7 +519,7 @@
{
"data": {
"text/plain": [
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f1c5299d1d0>"
"<pybamm.plotting.quick_plot.QuickPlot at 0x7fd1dfe1cf28>"
]
},
"execution_count": 12,
Expand Down Expand Up @@ -621,7 +604,7 @@
"\n",
"# Set the area-weighted particle-size distribution\n",
"def f_a_dist_p_dim(R):\n",
" return lognormal(R, R_a_p_dim, sd_a_p_dim)\n",
" return pybamm.lognormal(R, R_a_p_dim, sd_a_p_dim)\n",
"\n",
"# input to param dictionary\n",
"distribution_params = {\n",
Expand All @@ -641,7 +624,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1d8c9493b65344a580dbe0cd7fef4081",
"model_id": "9e0887e23c884591bdd97caac3e670d5",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -655,7 +638,7 @@
{
"data": {
"text/plain": [
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f1c48b02c88>"
"<pybamm.plotting.quick_plot.QuickPlot at 0x7fd1dfe74c18>"
]
},
"execution_count": 15,
Expand Down Expand Up @@ -766,7 +749,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "30e5982a7e1345d7912e3aa131fa6ff7",
"model_id": "ca33360fe25f423fbae0fe20bad989e1",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -780,7 +763,7 @@
{
"data": {
"text/plain": [
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f1c482d2278>"
"<pybamm.plotting.quick_plot.QuickPlot at 0x7fd1e18b4550>"
]
},
"execution_count": 18,
Expand Down Expand Up @@ -830,7 +813,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6938c3cab8f14709985552080e01355e",
"model_id": "4cfa09f7cdac41cfac0c38ab4be1cf38",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -844,7 +827,7 @@
{
"data": {
"text/plain": [
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f1c3fd2d940>"
"<pybamm.plotting.quick_plot.QuickPlot at 0x7fd1d48c5550>"
]
},
"execution_count": 19,
Expand Down Expand Up @@ -884,7 +867,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0ff76ec97d994aed8415b4088e84b925",
"model_id": "462351065ca445868719ac5a85a66cf7",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -898,7 +881,7 @@
{
"data": {
"text/plain": [
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f1c3f0f9e48>"
"<pybamm.plotting.quick_plot.QuickPlot at 0x7fd1cd3f6438>"
]
},
"execution_count": 20,
Expand Down
13 changes: 12 additions & 1 deletion pybamm/CITATIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,15 @@ doi={10.1149/2.0661810jes}
pages = {060554},
doi = {10.1149/1945-7111/ac0bf7},
url = {https://doi.org/10.1149/1945-7111/ac0bf7},
}
}

@article{Xu2019,
title={Evolution of Dead Lithium Growth in Lithium Metal Batteries: Experimentally Validated Model of the Apparent Capacity Loss},
author={Xu, Shanshan and Chen, Kuan-Hung and Dasgupta, Neil P and Siegel, Jason B and Stefanopoulou, Anna G},
journal={Journal of The Electrochemical Society},
volume={166},
number={14},
pages={A3456},
year={2019},
publisher={IOP Publishing}
}
1 change: 1 addition & 0 deletions pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def version(formatted=False):
from .parameters.thermal_parameters import thermal_parameters, ThermalParameters
from .parameters.lithium_ion_parameters import LithiumIonParameters
from .parameters.lead_acid_parameters import LeadAcidParameters
from .parameters.size_distribution_parameters import *
from .parameters import parameter_sets

#
Expand Down
14 changes: 7 additions & 7 deletions pybamm/expression_tree/unary_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,25 +1413,24 @@ def r_average(symbol):
return Integral(symbol, r) / Integral(v, r)


def R_average(symbol, param):
def size_average(symbol):
"""convenience function for averaging over particle size R using the area-weighted
particle-size distribution.

Parameters
----------
symbol : :class:`pybamm.Symbol`
The function to be averaged
param : :class:`pybamm.LithiumIonParameters`
The parameter object containing the area-weighted particle-size distributions
f_a_dist_n and f_a_dist_p.
Returns
-------
:class:`Symbol`
the new averaged symbol
"""
# Can't take average if the symbol evaluates on edges
if symbol.evaluates_on_edges("primary"):
raise ValueError("Can't take the R-average of a symbol that evaluates on edges")
raise ValueError(
"""Can't take the size-average of a symbol that evaluates on edges"""
)

# If symbol doesn't have a domain, or doesn't have "negative particle size"
# or "positive particle size" as a domain, it's average value is itself
Expand Down Expand Up @@ -1465,10 +1464,11 @@ def R_average(symbol, param):
auxiliary_domains=symbol.auxiliary_domains,
coord_sys="cartesian",
)
geo = pybamm.geometric_parameters
if ["negative particle size"] in list(symbol.domains.values()):
f_a_dist = param.f_a_dist_n(R)
f_a_dist = geo.f_a_dist_n(R)
elif ["positive particle size"] in list(symbol.domains.values()):
f_a_dist = param.f_a_dist_p(R)
f_a_dist = geo.f_a_dist_p(R)

# take average using Integral and distribution f_a_dist
return Integral(f_a_dist * symbol, R) / Integral(f_a_dist, R)
Expand Down
9 changes: 4 additions & 5 deletions pybamm/geometry/battery_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ def battery_geometry(
options is not None and
options["particle size"] == "distribution"
):
param = pybamm.LithiumIonParameters(options)
R_min_n = param.R_min_n
R_min_p = param.R_min_p
R_max_n = param.R_max_n
R_max_p = param.R_max_p
R_min_n = geo.R_min_n
R_min_p = geo.R_min_p
R_max_n = geo.R_max_n
R_max_p = geo.R_max_p
geometry.update(
{
"negative particle size": {
Expand Down
Loading