Skip to content

Commit cb3ad43

Browse files
authored
Merge pull request #1130 from pybamm-team/polynomial-concentration
Polynomial concentration
2 parents 71630c5 + fbb9af4 commit cb3ad43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1549
-501
lines changed

CHANGELOG.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## Features
44

5+
- Added particle submodel that use a polynomial approximation to the concentration within the electrode particles ([#1130](https://github.com/pybamm-team/PyBaMM/pull/1130))
56
- Added Modulo, Floor and Ceiling operators ([#1121](https://github.com/pybamm-team/PyBaMM/pull/1121))
67
- Added DFN model for a half cell ([#1121](https://github.com/pybamm-team/PyBaMM/pull/1121))
7-
- Automatically compute surface area per unit volume based on particle shape for li-ion models ([#1120])(https://github.com/pybamm-team/PyBaMM/pull/1120)
8+
- Automatically compute surface area per unit volume based on particle shape for li-ion models ([#1120](https://github.com/pybamm-team/PyBaMM/pull/1120))
89
- Added "R-averaged particle concentration" variables ([#1118](https://github.com/pybamm-team/PyBaMM/pull/1118))
910
- Added support for sensitivity calculations to the casadi solver ([#1109](https://github.com/pybamm-team/PyBaMM/pull/1109))
1011
- Added support for index 1 semi-explicit dae equations and sensitivity calculations to JAX BDF solver ([#1107](https://github.com/pybamm-team/PyBaMM/pull/1107))
@@ -22,9 +23,10 @@
2223

2324
## Breaking changes
2425

25-
- The modules containing standard parameters are now classes so they can take options
26-
(e.g. `standard_parameters_lithium_ion` is now `LithiumIonParameters`) ([#1120])(https://github.com/pybamm-team/PyBaMM/pull/1120)
27-
- Renamed `quick_plot_vars` to `output_variables` in `Simulation` to be consistent with `QuickPlot`. Passing `quick_plot_vars` to `Simulation.plot()` has been deprecated and `output_variables` should be passed instead ([#1099](https://github.com/pybamm-team/PyBaMM/pull/1099))
26+
- The "fast diffusion" particle option has been renamed "uniform profile" ([#1130](https://github.com/pybamm-team/PyBaMM/pull/1130))
27+
- The modules containing standard parameters are now classes so they can take options
28+
(e.g. `standard_parameters_lithium_ion` is now `LithiumIonParameters`) ([#1120](https://github.com/pybamm-team/PyBaMM/pull/1120))
29+
- Renamed `quick_plot_vars` to `output_variables` in `Simulation` to be consistent with `QuickPlot`. Passing `quick_plot_vars` to `Simulation.plot()` has been deprecated and `output_variables` should be passed instead ([#1099](https://github.com/pybamm-team/PyBaMM/pull/1099))
2830

2931

3032
# [v0.2.3](https://github.com/pybamm-team/PyBaMM/tree/v0.2.3) - 2020-07-01

docs/source/models/submodels/particle/fast_many_particles.rst

-5
This file was deleted.

docs/source/models/submodels/particle/fast_single_particle.rst

-5
This file was deleted.

docs/source/models/submodels/particle/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Particle
77
base_particle
88
fickian_single_particle
99
fickian_many_particles
10-
fast_single_particle
11-
fast_many_particles
10+
polynomial_single_particle
11+
polynomial_many_particles
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Polynomial Many Particles
2+
=========================
3+
4+
.. autoclass:: pybamm.particle.PolynomialManyParticles
5+
:members:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Polynomial Single Particle
2+
===========================
3+
4+
.. autoclass:: pybamm.particle.PolynomialSingleParticle
5+
:members:

examples/notebooks/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ For more advanced usage, new sets of parameters, spatial methods and solvers can
4141

4242
PyBaMM is built around an expression tree structure.
4343

44-
- [The expression tree notebook](expression_tree/expression-tree.ipynb) explains how this works, from model creation to solution.
45-
- [The broadcast notebook](expression_tree/broadcasts.ipynb) explains the different types of broadcast.
44+
- [The expression tree notebook](expression_tree/expression-tree.ipynb) explains how this works, from model creation to solution.
45+
- [The broadcast notebook](expression_tree/broadcasts.ipynb) explains the different types of broadcast.
4646

4747
The following notebooks are specific to different stages of the PyBaMM pipeline, such as choosing a model, spatial method, or solver.
4848

examples/notebooks/compare-particle-diffusion-models.ipynb

+327
Large diffs are not rendered by default.

examples/notebooks/using-submodels.ipynb

+78-63
Large diffs are not rendered by default.

examples/scripts/compare_SPM_diffusion_models.py

-56
This file was deleted.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Compare models for diffusion within the electrode particles
3+
#
4+
import pybamm
5+
6+
# load models
7+
models = [
8+
pybamm.lithium_ion.DFN(
9+
options={"particle": "Fickian diffusion"}, name="Fickian diffusion"
10+
),
11+
pybamm.lithium_ion.DFN(
12+
options={"particle": "uniform profile"}, name="uniform profile"
13+
),
14+
pybamm.lithium_ion.DFN(
15+
options={"particle": "quadratic profile"}, name="quadratic profile"
16+
),
17+
pybamm.lithium_ion.DFN(
18+
options={"particle": "quartic profile"}, name="quartic profile"
19+
),
20+
]
21+
22+
# pick parameter values
23+
parameter_values = pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Ecker2015)
24+
25+
# create and solve simulations
26+
sims = []
27+
for model in models:
28+
sim = pybamm.Simulation(model, parameter_values=parameter_values)
29+
sim.solve([0, 3600])
30+
sims.append(sim)
31+
print("Particle model: {}".format(model.name))
32+
print("Solve time: {}s".format(sim.solution.solve_time))
33+
34+
# plot results
35+
pybamm.dynamic_plot(sims)
File renamed without changes.

examples/scripts/custom_model.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
model.submodels["positive electrode"] = pybamm.electrode.ohm.LeadingOrder(
2323
model.param, "Positive"
2424
)
25-
model.submodels["negative particle"] = pybamm.particle.FastSingleParticle(
26-
model.param, "Negative"
25+
model.submodels["negative particle"] = pybamm.particle.PolynomialSingleParticle(
26+
model.param, "Negative", "uniform profile"
2727
)
28-
model.submodels["positive particle"] = pybamm.particle.FastSingleParticle(
29-
model.param, "Positive"
28+
model.submodels["positive particle"] = pybamm.particle.PolynomialSingleParticle(
29+
model.param, "Positive", "uniform profile"
3030
)
3131
model.submodels["negative interface"] = pybamm.interface.InverseButlerVolmer(
3232
model.param, "Negative", "lithium-ion main"

pybamm/CITATIONS.txt

+11
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,14 @@ eprint={2005.05127},
193193
archivePrefix={arXiv},
194194
primaryClass={physics.app-ph},
195195
}
196+
197+
@article{subramanian2005,
198+
title={Efficient macro-micro scale coupled modeling of batteries},
199+
author={Subramanian, Venkat R and Diwakar, Vinten D and Tapriyal, Deepak},
200+
journal={Journal of The Electrochemical Society},
201+
volume={152},
202+
number={10},
203+
pages={A2002},
204+
year={2005},
205+
publisher={IOP Publishing}
206+
}

pybamm/models/full_battery_models/base_battery_model.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class BaseBatteryModel(pybamm.BaseModel):
4646
"potential pair" or "potential pair quite conductive".
4747
* "particle" : str, optional
4848
Sets the submodel to use to describe behaviour within the particle.
49-
Can be "Fickian diffusion" (default) or "fast diffusion".
49+
Can be "Fickian diffusion" (default), "uniform profile",
50+
"quadratic profile", or "quartic profile".
5051
* "particle shape" : str, optional
5152
Sets the model shape of the electrode particles. This is used to
5253
calculate the surface area per unit volume. Can be "spherical"
@@ -348,10 +349,21 @@ def options(self, extra_options):
348349
raise pybamm.OptionError(
349350
"cannot have transverse convection in 0D model"
350351
)
351-
if options["particle"] not in ["Fickian diffusion", "fast diffusion"]:
352+
if options["particle"] not in [
353+
"Fickian diffusion",
354+
"fast diffusion",
355+
"uniform profile",
356+
"quadratic profile",
357+
"quartic profile",
358+
]:
352359
raise pybamm.OptionError(
353360
"particle model '{}' not recognised".format(options["particle"])
354361
)
362+
if options["particle"] == "fast diffusion":
363+
raise NotImplementedError(
364+
"The 'fast diffusion' option has been renamed. "
365+
"Use 'uniform profile' instead."
366+
)
355367
if options["particle shape"] not in ["spherical", "user"]:
356368
raise pybamm.OptionError(
357369
"particle shape '{}' not recognised".format(options["particle shape"])

pybamm/models/full_battery_models/lithium_ion/dfn.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,20 @@ def set_particle_submodel(self):
8585
self.submodels["positive particle"] = pybamm.particle.FickianManyParticles(
8686
self.param, "Positive"
8787
)
88-
elif self.options["particle"] == "fast diffusion":
89-
self.submodels["negative particle"] = pybamm.particle.FastManyParticles(
90-
self.param, "Negative"
88+
elif self.options["particle"] in [
89+
"uniform profile",
90+
"quadratic profile",
91+
"quartic profile",
92+
]:
93+
self.submodels[
94+
"negative particle"
95+
] = pybamm.particle.PolynomialManyParticles(
96+
self.param, "Negative", self.options["particle"]
9197
)
92-
self.submodels["positive particle"] = pybamm.particle.FastManyParticles(
93-
self.param, "Positive"
98+
self.submodels[
99+
"positive particle"
100+
] = pybamm.particle.PolynomialManyParticles(
101+
self.param, "Positive", self.options["particle"]
94102
)
95103

96104
def set_solid_submodel(self):

pybamm/models/full_battery_models/lithium_ion/spm.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,20 @@ def set_particle_submodel(self):
104104
self.submodels["positive particle"] = pybamm.particle.FickianSingleParticle(
105105
self.param, "Positive"
106106
)
107-
elif self.options["particle"] == "fast diffusion":
108-
self.submodels["negative particle"] = pybamm.particle.FastSingleParticle(
109-
self.param, "Negative"
107+
elif self.options["particle"] in [
108+
"uniform profile",
109+
"quadratic profile",
110+
"quartic profile",
111+
]:
112+
self.submodels[
113+
"negative particle"
114+
] = pybamm.particle.PolynomialSingleParticle(
115+
self.param, "Negative", self.options["particle"]
110116
)
111-
self.submodels["positive particle"] = pybamm.particle.FastSingleParticle(
112-
self.param, "Positive"
117+
self.submodels[
118+
"positive particle"
119+
] = pybamm.particle.PolynomialSingleParticle(
120+
self.param, "Positive", self.options["particle"]
113121
)
114122

115123
def set_negative_electrode_submodel(self):

pybamm/models/full_battery_models/lithium_ion/spme.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,20 @@ def set_particle_submodel(self):
106106
self.submodels["positive particle"] = pybamm.particle.FickianSingleParticle(
107107
self.param, "Positive"
108108
)
109-
elif self.options["particle"] == "fast diffusion":
110-
self.submodels["negative particle"] = pybamm.particle.FastSingleParticle(
111-
self.param, "Negative"
109+
elif self.options["particle"] in [
110+
"uniform profile",
111+
"quadratic profile",
112+
"quartic profile",
113+
]:
114+
self.submodels[
115+
"negative particle"
116+
] = pybamm.particle.PolynomialSingleParticle(
117+
self.param, "Negative", self.options["particle"]
112118
)
113-
self.submodels["positive particle"] = pybamm.particle.FastSingleParticle(
114-
self.param, "Positive"
119+
self.submodels[
120+
"positive particle"
121+
] = pybamm.particle.PolynomialSingleParticle(
122+
self.param, "Positive", self.options["particle"]
115123
)
116124

117125
def set_negative_electrode_submodel(self):

pybamm/models/standard_variables.py

+43-3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,28 @@
134134
auxiliary_domains={"secondary": "current collector"},
135135
bounds=(0, 1),
136136
)
137+
c_s_n_rav = pybamm.Variable(
138+
"R-averaged negative particle concentration",
139+
domain="negative electrode",
140+
auxiliary_domains={"secondary": "current collector"},
141+
bounds=(0, 1),
142+
)
143+
c_s_p_rav = pybamm.Variable(
144+
"R-averaged positive particle concentration",
145+
domain="positive electrode",
146+
auxiliary_domains={"secondary": "current collector"},
147+
bounds=(0, 1),
148+
)
149+
c_s_n_rxav = pybamm.Variable(
150+
"R-X-averaged negative particle concentration",
151+
domain="current collector",
152+
bounds=(0, 1),
153+
)
154+
c_s_p_rxav = pybamm.Variable(
155+
"R-X-averaged positive particle concentration",
156+
domain="current collector",
157+
bounds=(0, 1),
158+
)
137159
c_s_n_surf = pybamm.Variable(
138160
"Negative particle surface concentration",
139161
domain="negative electrode",
@@ -156,7 +178,25 @@
156178
domain="current collector",
157179
bounds=(0, 1),
158180
)
159-
181+
# Average particle concentration gradient (for polynomial particle concentration
182+
# models). Note: we make the distinction here between the flux defined as
183+
# N = -D*dc/dr and the concentration gradient q = dc/dr
184+
q_s_n_rav = pybamm.Variable(
185+
"R-averaged negative particle concentration gradient",
186+
domain="negative electrode",
187+
auxiliary_domains={"secondary": "current collector"},
188+
)
189+
q_s_p_rav = pybamm.Variable(
190+
"R-averaged positive particle concentration gradient",
191+
domain="positive electrode",
192+
auxiliary_domains={"secondary": "current collector"},
193+
)
194+
q_s_n_rxav = pybamm.Variable(
195+
"R-X-averaged negative particle concentration gradient", domain="current collector"
196+
)
197+
q_s_p_rxav = pybamm.Variable(
198+
"R-X-averaged positive particle concentration gradient", domain="current collector"
199+
)
160200

161201
# Porosity
162202
eps_n = pybamm.Variable(
@@ -181,13 +221,13 @@
181221

182222
# Piecewise constant (for asymptotic models)
183223
eps_n_pc = pybamm.Variable(
184-
"X-averaged negative electrode porosity", domain="current collector", bounds=(0, 1),
224+
"X-averaged negative electrode porosity", domain="current collector", bounds=(0, 1)
185225
)
186226
eps_s_pc = pybamm.Variable(
187227
"X-averaged separator porosity", domain="current collector", bounds=(0, 1)
188228
)
189229
eps_p_pc = pybamm.Variable(
190-
"X-averaged positive electrode porosity", domain="current collector", bounds=(0, 1),
230+
"X-averaged positive electrode porosity", domain="current collector", bounds=(0, 1)
191231
)
192232

193233
eps_piecewise_constant = pybamm.Concatenation(
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .base_particle import BaseParticle
22
from .fickian_many_particles import FickianManyParticles
33
from .fickian_single_particle import FickianSingleParticle
4-
from .fast_many_particles import FastManyParticles
5-
from .fast_single_particle import FastSingleParticle
4+
from .polynomial_single_particle import PolynomialSingleParticle
5+
from .polynomial_many_particles import PolynomialManyParticles

0 commit comments

Comments
 (0)