Skip to content

Commit 8ff9640

Browse files
#492 merge master
2 parents c16b916 + 7a36dde commit 8ff9640

File tree

54 files changed

+403
-133
lines changed

Some content is hidden

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

54 files changed

+403
-133
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Features
44

5+
- Separated active and inactive material volume fractions ([#726](https://github.com/pybamm-team/PyBaMM/pull/726))
6+
- Added submodels for tortuosity ([#726](https://github.com/pybamm-team/PyBaMM/pull/726))
57
- Simplified the interface for setting current functions ([#723](https://github.com/pybamm-team/PyBaMM/pull/723))
68
- Added Heaviside operator ([#723](https://github.com/pybamm-team/PyBaMM/pull/723))
79
- Added Simulation class ([#693](https://github.com/pybamm-team/PyBaMM/pull/693))

docs/source/models/submodels/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Submodels
1414
particle/index
1515
porosity/index
1616
thermal/index
17+
tortuosity/index
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Base Model
2+
===========
3+
4+
.. autoclass:: pybamm.tortuosity.BaseModel
5+
:members:
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Bruggeman Model
2+
===============
3+
4+
.. autoclass:: pybamm.tortuosity.Bruggeman
5+
:members:
6+
7+
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Tortuosity
2+
==========
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
7+
base_tortuosity
8+
bruggeman_tortuosity
9+

input/parameters/lead-acid/anodes/lead_Sulzer2019/parameters.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Negative electrode open-circuit potential [V],[function]lead_ocp_Bode1977,,
1212
,,,
1313
# Microstructure,,,
1414
Negative electrode surface area density [m-1],2300000,,
15-
Negative electrode Bruggeman coefficient,1.5,,
15+
Negative electrode Bruggeman coefficient (electrolyte),1.5,,
16+
Negative electrode Bruggeman coefficient (electrode),1.5,,
1617
Negative electrode morphological parameter,0.6,srinivasan2003mathematical,
1718
Negative electrode capacity [C.m-3],3473000000,,
1819
,,,

input/parameters/lead-acid/cathodes/lead_dioxide_Sulzer2019/parameters.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Positive electrode open-circuit potential [V],[function]lead_dioxide_ocp_Bode197
1212
,,,
1313
# Microstructure,,,
1414
Positive electrode surface area density [m-1],23000000,,
15-
Positive electrode Bruggeman coefficient,1.5,,
15+
Positive electrode Bruggeman coefficient (electrolyte),1.5,,
16+
Positive electrode Bruggeman coefficient (electrode),1.5,,
1617
Positive electrode morphological parameter,0.6,srinivasan2003mathematical,
1718
Positive electrode capacity [C.m-3],2745000000,,
1819
,,,

input/parameters/lead-acid/separators/agm_Sulzer2019/parameters.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ Name [units],Value,Reference,Notes
22
# Empty rows and rows starting with ‘#’ will be ignored,,,
33
,,,
44
Maximum porosity of separator,0.92,,
5-
Separator Bruggeman coefficient,1.5,,
5+
Separator Bruggeman coefficient (electrolyte),1.5,,
6+
Separator Bruggeman coefficient (electrode),1.5,,

input/parameters/lithium-ion/anodes/graphite_mcmb2528_Marquis2019/parameters.csv

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ Negative electrode diffusivity [m2.s-1],[function]graphite_mcmb2528_diffusivity_
88
Negative electrode OCP [V],[function]graphite_mcmb2528_ocp_Dualfoil1998,
99
,,,
1010
# Microstructure,,,
11-
Negative electrode porosity,0.3,Scott Moura FastDFN,
11+
Negative electrode porosity,0.3,Scott Moura FastDFN,electrolyte volume fraction
12+
Negative electrode active material volume fraction,0.7,,assuming zero binder volume fraction
1213
Negative particle radius [m],1E-05,Scott Moura FastDFN,
1314
Negative electrode surface area density [m-1],180000,Scott Moura FastDFN,
14-
Negative electrode Bruggeman coefficient,1.5,Scott Moura FastDFN,
15+
Negative electrode Bruggeman coefficient (electrolyte),1.5,Scott Moura FastDFN,
16+
Negative electrode Bruggeman coefficient (electrode),1.5,Scott Moura FastDFN,
1517
,,,
1618
# Interfacial reactions,,,
1719
Negative electrode cation signed stoichiometry,-1,,

input/parameters/lithium-ion/cathodes/lico2_Marquis2019/parameters.csv

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ Positive electrode diffusivity [m2.s-1],[function]lico2_diffusivity_Dualfoil1998
88
Positive electrode OCP [V],[function]lico2_ocp_Dualfoil1998,
99
,,,
1010
# Microstructure,,,
11-
Positive electrode porosity,0.3,Scott Moura FastDFN,
11+
Positive electrode porosity,0.3,Scott Moura FastDFN,electrolyte volume fraction
12+
Positive electrode active material volume fraction,0.7,,assuming zero binder volume fraction
1213
Positive particle radius [m],1E-05,Scott Moura FastDFN,
1314
Positive electrode surface area density [m-1],150000,Scott Moura FastDFN,
14-
Positive electrode Bruggeman coefficient,1.5,Scott Moura FastDFN,
15+
Positive electrode Bruggeman coefficient (electrolyte),1.5,Scott Moura FastDFN,
16+
Positive electrode Bruggeman coefficient (electrode),1.5,Scott Moura FastDFN,
1517
,,,
1618
# Interfacial reactions,,,
1719
Positive electrode cation signed stoichiometry,-1,,

input/parameters/lithium-ion/separators/separator_Marquis2019/parameters.csv

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Name [units],Value,Reference,Notes
22
# Empty rows and rows starting with ‘#’ will be ignored,,,
33
,,,
44
Separator porosity,1,Scott Moura FastDFN,
5-
Separator Bruggeman coefficient,1.5,Scott Moura FastDFN,
5+
Separator Bruggeman coefficient (electrolyte),1.5,Scott Moura FastDFN,
6+
Separator Bruggeman coefficient (electrode),1.5,Scott Moura FastDFN,
67
Separator density [kg.m-3],397,,
78
Separator specific heat capacity [J.kg-1.K-1],700,,
89
Separator thermal conductivity [W.m-1.K-1],0.16,,

pybamm/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def version(formatted=False):
165165
particle,
166166
porosity,
167167
thermal,
168+
tortuosity,
168169
)
169170

170171
#

pybamm/models/full_battery_models/base_battery_model.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ def build_model(self):
407407
# return to it later and try again. If setting coupled variables fails and
408408
# there are no more submodels to try, raise an error.
409409
submodels = list(self.submodels.keys())
410+
count = 0
410411
while len(submodels) > 0:
412+
count += 1
411413
for submodel_name, submodel in self.submodels.items():
412414
if submodel_name in submodels:
413415
pybamm.logger.debug(
@@ -421,7 +423,7 @@ def build_model(self):
421423
)
422424
submodels.remove(submodel_name)
423425
except KeyError as key:
424-
if len(submodels) == 1:
426+
if len(submodels) == 1 or count == 100:
425427
# no more submodels to try
426428
raise pybamm.ModelError(
427429
"""Submodel "{}" requires the variable {}, but it cannot be found.
@@ -496,6 +498,14 @@ def set_external_circuit_submodel(self):
496498
self.submodels[
497499
"external circuit"
498500
] = pybamm.external_circuit.ConstantVoltage(self.param)
501+
502+
def set_tortuosity_submodels(self):
503+
self.submodels["electrolyte tortuosity"] = pybamm.tortuosity.Bruggeman(
504+
self.param, "Electrolyte"
505+
)
506+
self.submodels["electrode tortuosity"] = pybamm.tortuosity.Bruggeman(
507+
self.param, "Electrode"
508+
)
499509

500510
def set_thermal_submodel(self):
501511

pybamm/models/full_battery_models/lead_acid/full.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(self, options=None, name="Full model", build=True):
3737
self.set_reactions()
3838
self.set_interfacial_submodel()
3939
self.set_porosity_submodel()
40+
self.set_tortuosity_submodels()
4041
self.set_convection_submodel()
4142
self.set_electrolyte_submodel()
4243
self.set_solid_submodel()

pybamm/models/full_battery_models/lead_acid/higher_order.py

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(self, options=None, name="Composite model", build=True):
4949
self.set_full_interface_submodel()
5050
self.set_full_convection_submodel()
5151
self.set_full_porosity_submodel()
52+
self.set_tortuosity_submodels()
5253
self.set_thermal_submodel()
5354
self.set_current_collector_submodel()
5455

pybamm/models/full_battery_models/lead_acid/loqs.py

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(self, options=None, name="LOQS model", build=True):
3737
self.set_interfacial_submodel()
3838
self.set_convection_submodel()
3939
self.set_porosity_submodel()
40+
self.set_tortuosity_submodels()
4041
self.set_negative_electrode_submodel()
4142
self.set_electrolyte_submodel()
4243
self.set_positive_electrode_submodel()
@@ -70,6 +71,14 @@ def set_porosity_submodel(self):
7071
self.param
7172
)
7273

74+
def set_tortuosity_submodels(self):
75+
self.submodels[
76+
"leading-order electrolyte tortuosity"
77+
] = pybamm.tortuosity.Bruggeman(self.param, "Electrolyte")
78+
self.submodels[
79+
"leading-order electrode tortuosity"
80+
] = pybamm.tortuosity.Bruggeman(self.param, "Electrode")
81+
7382
def set_convection_submodel(self):
7483

7584
if self.options["convection"] is False:

pybamm/models/full_battery_models/lithium_ion/dfn.py

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(self, options=None, name="Doyle-Fuller-Newman model", build=True):
3535

3636
self.set_reactions()
3737
self.set_porosity_submodel()
38+
self.set_tortuosity_submodels()
3839
self.set_convection_submodel()
3940
self.set_interfacial_submodel()
4041
self.set_particle_submodel()

pybamm/models/full_battery_models/lithium_ion/spm.py

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(self, options=None, name="Single Particle Model", build=True):
3333
super().__init__(options, name)
3434

3535
self.set_porosity_submodel()
36+
self.set_tortuosity_submodels()
3637
self.set_convection_submodel()
3738
self.set_interfacial_submodel()
3839
self.set_particle_submodel()

pybamm/models/full_battery_models/lithium_ion/spme.py

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(
3737

3838
self.set_reactions()
3939
self.set_porosity_submodel()
40+
self.set_tortuosity_submodels()
4041
self.set_convection_submodel()
4142
self.set_interfacial_submodel()
4243
self.set_particle_submodel()
@@ -53,6 +54,14 @@ def set_porosity_submodel(self):
5354

5455
self.submodels["porosity"] = pybamm.porosity.Constant(self.param)
5556

57+
def set_tortuosity_submodels(self):
58+
self.submodels["electrolyte tortuosity"] = pybamm.tortuosity.Bruggeman(
59+
self.param, "Electrolyte", True
60+
)
61+
self.submodels["electrode tortuosity"] = pybamm.tortuosity.Bruggeman(
62+
self.param, "Electrode", True
63+
)
64+
5665
def set_convection_submodel(self):
5766

5867
self.submodels["convection"] = pybamm.convection.NoConvection(self.param)

pybamm/models/submodels/base_submodel.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,25 @@ def domain(self):
6868

6969
@domain.setter
7070
def domain(self, domain):
71-
if domain in ["Negative", "Separator", "Positive"]:
71+
ok_domain_list = [
72+
"Negative",
73+
"Separator",
74+
"Positive",
75+
"Negative electrode",
76+
"Negative electrolyte",
77+
"Separator electrolyte",
78+
"Positive electrode",
79+
"Positive electrolyte",
80+
]
81+
if domain in ok_domain_list:
7282
self._domain = domain
7383
elif domain is None:
7484
pass
7585
else:
7686
raise pybamm.DomainError(
77-
"Domain must be either 'Negative' or 'Positive' not {}".format(domain)
87+
"Domain '{}' not recognised (must be one of {})".format(
88+
domain, ok_domain_list
89+
)
7890
)
7991

8092
def set_domain_for_broadcast(self):

pybamm/models/submodels/electrode/ohm/base_ohm.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,19 @@ def __init__(self, param, domain, reactions=None, set_positive_potential=True):
2525

2626
def set_boundary_conditions(self, variables):
2727

28-
phi_s = variables[self.domain + " electrode potential"]
29-
eps = variables[self.domain + " electrode porosity"]
30-
i_boundary_cc = variables["Current collector current density"]
31-
phi_s_cn = variables["Negative current collector potential"]
32-
3328
if self.domain == "Negative":
29+
phi_s_cn = variables["Negative current collector potential"]
3430
lbc = (phi_s_cn, "Dirichlet")
3531
rbc = (pybamm.Scalar(0), "Neumann")
3632

3733
elif self.domain == "Positive":
3834
lbc = (pybamm.Scalar(0), "Neumann")
39-
sigma_eff = self.param.sigma_p * (1 - eps) ** self.param.b_p
35+
i_boundary_cc = variables["Current collector current density"]
36+
sigma_eff = self.param.sigma_p * variables["Positive electrode tortuosity"]
4037
rbc = (
4138
i_boundary_cc / pybamm.boundary_value(-sigma_eff, "right"),
4239
"Neumann",
4340
)
4441

42+
phi_s = variables[self.domain + " electrode potential"]
4543
self.boundary_conditions[phi_s] = {"left": lbc, "right": rbc}

pybamm/models/submodels/electrode/ohm/composite_ohm.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ def get_coupled_variables(self, variables):
3434
x_n = pybamm.standard_spatial_vars.x_n
3535
x_p = pybamm.standard_spatial_vars.x_p
3636

37-
eps_0 = variables[
38-
"Leading-order x-averaged " + self.domain.lower() + " electrode porosity"
37+
tor_0 = variables[
38+
"Leading-order x-averaged " + self.domain.lower() + " electrode tortuosity"
3939
]
4040
phi_s_cn = variables["Negative current collector potential"]
4141

4242
if self._domain == "Negative":
43-
sigma_eff_0 = self.param.sigma_n * (1 - eps_0) ** self.param.b_n
43+
sigma_eff_0 = self.param.sigma_n * tor_0
4444
phi_s = pybamm.PrimaryBroadcast(
4545
phi_s_cn, "negative electrode"
4646
) + pybamm.outer(
@@ -54,7 +54,7 @@ def get_coupled_variables(self, variables):
5454
]
5555
phi_e_p_av = variables["X-averaged positive electrolyte potential"]
5656

57-
sigma_eff_0 = self.param.sigma_p * (1 - eps_0) ** self.param.b_p
57+
sigma_eff_0 = self.param.sigma_p * tor_0
5858

5959
const = (
6060
delta_phi_p_av
@@ -80,8 +80,8 @@ def get_coupled_variables(self, variables):
8080
def set_boundary_conditions(self, variables):
8181

8282
phi_s = variables[self.domain + " electrode potential"]
83-
eps_0 = variables[
84-
"Leading-order x-averaged " + self.domain.lower() + " electrode porosity"
83+
tor_0 = variables[
84+
"Leading-order x-averaged " + self.domain.lower() + " electrode tortuosity"
8585
]
8686
i_boundary_cc_0 = variables["Leading-order current collector current density"]
8787

@@ -91,7 +91,7 @@ def set_boundary_conditions(self, variables):
9191

9292
elif self.domain == "Positive":
9393
lbc = (pybamm.Scalar(0), "Neumann")
94-
sigma_eff_0 = self.param.sigma_p * (1 - eps_0) ** self.param.b_p
94+
sigma_eff_0 = self.param.sigma_p * tor_0
9595
rbc = (-i_boundary_cc_0 / sigma_eff_0, "Neumann")
9696

9797
self.boundary_conditions[phi_s] = {"left": lbc, "right": rbc}

pybamm/models/submodels/electrode/ohm/full_ohm.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ def get_fundamental_variables(self):
3636
def get_coupled_variables(self, variables):
3737

3838
phi_s = variables[self.domain + " electrode potential"]
39-
eps = variables[self.domain + " electrode porosity"]
39+
tor = variables[self.domain + " electrode tortuosity"]
4040

4141
if self.domain == "Negative":
4242
sigma = self.param.sigma_n
43-
b = self.param.b_n
4443
elif self.domain == "Positive":
4544
sigma = self.param.sigma_p
46-
b = self.param.b_p
4745

48-
sigma_eff = sigma * (1 - eps) ** b
46+
sigma_eff = sigma * tor
4947
i_s = -sigma_eff * pybamm.grad(phi_s)
5048

5149
variables.update({self.domain + " electrode effective conductivity": sigma_eff})
@@ -72,7 +70,7 @@ def set_boundary_conditions(self, variables):
7270

7371
phi_s = variables[self.domain + " electrode potential"]
7472
phi_s_cn = variables["Negative current collector potential"]
75-
eps = variables[self.domain + " electrode porosity"]
73+
tor = variables[self.domain + " electrode tortuosity"]
7674
i_boundary_cc = variables["Current collector current density"]
7775

7876
if self.domain == "Negative":
@@ -81,7 +79,7 @@ def set_boundary_conditions(self, variables):
8179

8280
elif self.domain == "Positive":
8381
lbc = (pybamm.Scalar(0), "Neumann")
84-
sigma_eff = self.param.sigma_p * (1 - eps) ** self.param.b_p
82+
sigma_eff = self.param.sigma_p * tor
8583
rbc = (
8684
i_boundary_cc / pybamm.boundary_value(-sigma_eff, "right"),
8785
"Neumann",

pybamm/models/submodels/electrode/ohm/surface_form_ohm.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ def get_coupled_variables(self, variables):
3131
x_p = pybamm.standard_spatial_vars.x_p
3232
i_boundary_cc = variables["Current collector current density"]
3333
i_e = variables[self.domain + " electrolyte current density"]
34-
eps = variables[self.domain + " electrode porosity"]
34+
tor = variables[self.domain + " electrode tortuosity"]
3535
phi_s_cn = variables["Negative current collector potential"]
3636

3737
i_s = pybamm.PrimaryBroadcast(i_boundary_cc, self.domain_for_broadcast) - i_e
3838

3939
if self.domain == "Negative":
40-
conductivity = param.sigma_n * (1 - eps) ** param.b_n
40+
conductivity = param.sigma_n * tor
4141
phi_s = pybamm.PrimaryBroadcast(
4242
phi_s_cn, "negative electrode"
4343
) - pybamm.IndefiniteIntegral(i_s / conductivity, x_n)
@@ -47,7 +47,7 @@ def get_coupled_variables(self, variables):
4747
phi_e_s = variables["Separator electrolyte potential"]
4848
delta_phi_p = variables["Positive electrode surface potential difference"]
4949

50-
conductivity = param.sigma_p * (1 - eps) ** param.b_p
50+
conductivity = param.sigma_p * tor
5151
phi_s = -pybamm.IndefiniteIntegral(
5252
i_s / conductivity, x_p
5353
) + pybamm.PrimaryBroadcast(

0 commit comments

Comments
 (0)