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

Issue 579 volume fractions #726

Merged
merged 12 commits into from
Nov 13, 2019
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Features

- Separated active and inactive material volume fractions ([#726](https://github.com/pybamm-team/PyBaMM/pull/726))
- Added submodels for tortuosity ([#726](https://github.com/pybamm-team/PyBaMM/pull/726))
- Simplified the interface for setting current functions ([#723](https://github.com/pybamm-team/PyBaMM/pull/723))
- Added Heaviside operator ([#723](https://github.com/pybamm-team/PyBaMM/pull/723))
- Added Simulation class ([#693](https://github.com/pybamm-team/PyBaMM/pull/693))
Expand Down
1 change: 1 addition & 0 deletions docs/source/models/submodels/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Submodels
particle/index
porosity/index
thermal/index
tortuosity/index
6 changes: 6 additions & 0 deletions docs/source/models/submodels/tortuosity/base_tortuosity.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Base Model
===========

.. autoclass:: pybamm.tortuosity.BaseModel
:members:

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bruggeman Model
===============

.. autoclass:: pybamm.tortuosity.Bruggeman
:members:



9 changes: 9 additions & 0 deletions docs/source/models/submodels/tortuosity/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Tortuosity
==========

.. toctree::
:maxdepth: 1

base_tortuosity
bruggeman_tortuosity

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Negative electrode open-circuit potential [V],[function]lead_ocp_Bode1977,,
,,,
# Microstructure,,,
Negative electrode surface area density [m-1],2300000,,
Negative electrode Bruggeman coefficient,1.5,,
Negative electrode Bruggeman coefficient (electrolyte),1.5,,
Negative electrode Bruggeman coefficient (electrode),1.5,,
Negative electrode morphological parameter,0.6,srinivasan2003mathematical,
Negative electrode capacity [C.m-3],3473000000,,
,,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Positive electrode open-circuit potential [V],[function]lead_dioxide_ocp_Bode197
,,,
# Microstructure,,,
Positive electrode surface area density [m-1],23000000,,
Positive electrode Bruggeman coefficient,1.5,,
Positive electrode Bruggeman coefficient (electrolyte),1.5,,
Positive electrode Bruggeman coefficient (electrode),1.5,,
Positive electrode morphological parameter,0.6,srinivasan2003mathematical,
Positive electrode capacity [C.m-3],2745000000,,
,,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Name [units],Value,Reference,Notes
# Empty rows and rows starting with ‘#’ will be ignored,,,
,,,
Maximum porosity of separator,0.92,,
Separator Bruggeman coefficient,1.5,,
Separator Bruggeman coefficient (electrolyte),1.5,,
Separator Bruggeman coefficient (electrode),1.5,,
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Negative electrode diffusivity [m2.s-1],[function]graphite_mcmb2528_diffusivity_
Negative electrode OCP [V],[function]graphite_mcmb2528_ocp_Dualfoil1998,
,,,
# Microstructure,,,
Negative electrode porosity,0.3,Scott Moura FastDFN,
Negative electrode porosity,0.3,Scott Moura FastDFN,electrolyte volume fraction
Negative electrode active material volume fraction,0.7,,assuming zero binder volume fraction
Negative particle radius [m],1E-05,Scott Moura FastDFN,
Negative electrode surface area density [m-1],180000,Scott Moura FastDFN,
Negative electrode Bruggeman coefficient,1.5,Scott Moura FastDFN,
Negative electrode Bruggeman coefficient (electrolyte),1.5,Scott Moura FastDFN,
Negative electrode Bruggeman coefficient (electrode),1.5,Scott Moura FastDFN,
,,,
# Interfacial reactions,,,
Negative electrode cation signed stoichiometry,-1,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Positive electrode diffusivity [m2.s-1],[function]lico2_diffusivity_Dualfoil1998
Positive electrode OCP [V],[function]lico2_ocp_Dualfoil1998,
,,,
# Microstructure,,,
Positive electrode porosity,0.3,Scott Moura FastDFN,
Positive electrode porosity,0.3,Scott Moura FastDFN,electrolyte volume fraction
Positive electrode active material volume fraction,0.7,,assuming zero binder volume fraction
Positive particle radius [m],1E-05,Scott Moura FastDFN,
Positive electrode surface area density [m-1],150000,Scott Moura FastDFN,
Positive electrode Bruggeman coefficient,1.5,Scott Moura FastDFN,
Positive electrode Bruggeman coefficient (electrolyte),1.5,Scott Moura FastDFN,
Positive electrode Bruggeman coefficient (electrode),1.5,Scott Moura FastDFN,
,,,
# Interfacial reactions,,,
Positive electrode cation signed stoichiometry,-1,,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Name [units],Value,Reference,Notes
# Empty rows and rows starting with ‘#’ will be ignored,,,
,,,
Separator porosity,1,Scott Moura FastDFN,
Separator Bruggeman coefficient,1.5,Scott Moura FastDFN,
Separator Bruggeman coefficient (electrolyte),1.5,Scott Moura FastDFN,
Separator Bruggeman coefficient (electrode),1.5,Scott Moura FastDFN,
Separator density [kg.m-3],397,,
Separator specific heat capacity [J.kg-1.K-1],700,,
Separator thermal conductivity [W.m-1.K-1],0.16,,
1 change: 1 addition & 0 deletions pybamm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def version(formatted=False):
particle,
porosity,
thermal,
tortuosity,
)

#
Expand Down
12 changes: 11 additions & 1 deletion pybamm/models/full_battery_models/base_battery_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ def build_model(self):
# return to it later and try again. If setting coupled variables fails and
# there are no more submodels to try, raise an error.
submodels = list(self.submodels.keys())
count = 0
while len(submodels) > 0:
count += 1
for submodel_name, submodel in self.submodels.items():
if submodel_name in submodels:
pybamm.logger.debug(
Expand All @@ -429,7 +431,7 @@ def build_model(self):
)
submodels.remove(submodel_name)
except KeyError as key:
if len(submodels) == 1:
if len(submodels) == 1 or count == 100:
# no more submodels to try
raise pybamm.ModelError(
"""Submodel "{}" requires the variable {}, but it cannot be found.
Expand Down Expand Up @@ -491,6 +493,14 @@ def build_model(self):

self._built = True

def set_tortuosity_submodels(self):
self.submodels["electrolyte tortuosity"] = pybamm.tortuosity.Bruggeman(
self.param, "Electrolyte"
)
self.submodels["electrode tortuosity"] = pybamm.tortuosity.Bruggeman(
self.param, "Electrode"
)

def set_thermal_submodel(self):

if self.options["thermal"] == "isothermal":
Expand Down
1 change: 1 addition & 0 deletions pybamm/models/full_battery_models/lead_acid/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, options=None, name="Full model", build=True):
self.set_reactions()
self.set_interfacial_submodel()
self.set_porosity_submodel()
self.set_tortuosity_submodels()
self.set_convection_submodel()
self.set_electrolyte_submodel()
self.set_solid_submodel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, options=None, name="Composite model", build=True):
self.set_full_interface_submodel()
self.set_full_convection_submodel()
self.set_full_porosity_submodel()
self.set_tortuosity_submodels()
self.set_thermal_submodel()
self.set_current_collector_submodel()

Expand Down
9 changes: 9 additions & 0 deletions pybamm/models/full_battery_models/lead_acid/loqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, options=None, name="LOQS model", build=True):
self.set_interfacial_submodel()
self.set_convection_submodel()
self.set_porosity_submodel()
self.set_tortuosity_submodels()
self.set_negative_electrode_submodel()
self.set_electrolyte_submodel()
self.set_positive_electrode_submodel()
Expand Down Expand Up @@ -70,6 +71,14 @@ def set_porosity_submodel(self):
self.param
)

def set_tortuosity_submodels(self):
self.submodels[
"leading-order electrolyte tortuosity"
] = pybamm.tortuosity.Bruggeman(self.param, "Electrolyte")
self.submodels[
"leading-order electrode tortuosity"
] = pybamm.tortuosity.Bruggeman(self.param, "Electrode")

def set_convection_submodel(self):

if self.options["convection"] is False:
Expand Down
1 change: 1 addition & 0 deletions pybamm/models/full_battery_models/lithium_ion/dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, options=None, name="Doyle-Fuller-Newman model", build=True):

self.set_reactions()
self.set_porosity_submodel()
self.set_tortuosity_submodels()
self.set_convection_submodel()
self.set_interfacial_submodel()
self.set_particle_submodel()
Expand Down
1 change: 1 addition & 0 deletions pybamm/models/full_battery_models/lithium_ion/spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, options=None, name="Single Particle Model", build=True):
super().__init__(options, name)

self.set_porosity_submodel()
self.set_tortuosity_submodels()
self.set_convection_submodel()
self.set_interfacial_submodel()
self.set_particle_submodel()
Expand Down
9 changes: 9 additions & 0 deletions pybamm/models/full_battery_models/lithium_ion/spme.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(

self.set_reactions()
self.set_porosity_submodel()
self.set_tortuosity_submodels()
self.set_convection_submodel()
self.set_interfacial_submodel()
self.set_particle_submodel()
Expand All @@ -53,6 +54,14 @@ def set_porosity_submodel(self):

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

def set_tortuosity_submodels(self):
self.submodels["electrolyte tortuosity"] = pybamm.tortuosity.Bruggeman(
self.param, "Electrolyte", True
)
self.submodels["electrode tortuosity"] = pybamm.tortuosity.Bruggeman(
self.param, "Electrode", True
)

def set_convection_submodel(self):

self.submodels["convection"] = pybamm.convection.NoConvection(self.param)
Expand Down
16 changes: 14 additions & 2 deletions pybamm/models/submodels/base_submodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,25 @@ def domain(self):

@domain.setter
def domain(self, domain):
if domain in ["Negative", "Separator", "Positive"]:
ok_domain_list = [
"Negative",
"Separator",
"Positive",
"Negative electrode",
"Negative electrolyte",
"Separator electrolyte",
"Positive electrode",
"Positive electrolyte",
]
if domain in ok_domain_list:
self._domain = domain
elif domain is None:
pass
else:
raise pybamm.DomainError(
"Domain must be either 'Negative' or 'Positive' not {}".format(domain)
"Domain '{}' not recognised (must be one of {})".format(
domain, ok_domain_list
)
)

def set_domain_for_broadcast(self):
Expand Down
10 changes: 4 additions & 6 deletions pybamm/models/submodels/electrode/ohm/base_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,19 @@ def __init__(self, param, domain, reactions=None, set_positive_potential=True):

def set_boundary_conditions(self, variables):

phi_s = variables[self.domain + " electrode potential"]
eps = variables[self.domain + " electrode porosity"]
i_boundary_cc = variables["Current collector current density"]
phi_s_cn = variables["Negative current collector potential"]

if self.domain == "Negative":
phi_s_cn = variables["Negative current collector potential"]
lbc = (phi_s_cn, "Dirichlet")
rbc = (pybamm.Scalar(0), "Neumann")

elif self.domain == "Positive":
lbc = (pybamm.Scalar(0), "Neumann")
sigma_eff = self.param.sigma_p * (1 - eps) ** self.param.b_p
i_boundary_cc = variables["Current collector current density"]
sigma_eff = self.param.sigma_p * variables["Positive electrode tortuosity"]
rbc = (
i_boundary_cc / pybamm.boundary_value(-sigma_eff, "right"),
"Neumann",
)

phi_s = variables[self.domain + " electrode potential"]
self.boundary_conditions[phi_s] = {"left": lbc, "right": rbc}
14 changes: 7 additions & 7 deletions pybamm/models/submodels/electrode/ohm/composite_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def get_coupled_variables(self, variables):
x_n = pybamm.standard_spatial_vars.x_n
x_p = pybamm.standard_spatial_vars.x_p

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

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

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

const = (
delta_phi_p_av
Expand All @@ -80,8 +80,8 @@ def get_coupled_variables(self, variables):
def set_boundary_conditions(self, variables):

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

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

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

self.boundary_conditions[phi_s] = {"left": lbc, "right": rbc}
10 changes: 4 additions & 6 deletions pybamm/models/submodels/electrode/ohm/full_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ def get_fundamental_variables(self):
def get_coupled_variables(self, variables):

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

if self.domain == "Negative":
sigma = self.param.sigma_n
b = self.param.b_n
elif self.domain == "Positive":
sigma = self.param.sigma_p
b = self.param.b_p

sigma_eff = sigma * (1 - eps) ** b
sigma_eff = sigma * tor
i_s = -sigma_eff * pybamm.grad(phi_s)

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

phi_s = variables[self.domain + " electrode potential"]
phi_s_cn = variables["Negative current collector potential"]
eps = variables[self.domain + " electrode porosity"]
tor = variables[self.domain + " electrode tortuosity"]
i_boundary_cc = variables["Current collector current density"]

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

elif self.domain == "Positive":
lbc = (pybamm.Scalar(0), "Neumann")
sigma_eff = self.param.sigma_p * (1 - eps) ** self.param.b_p
sigma_eff = self.param.sigma_p * tor
rbc = (
i_boundary_cc / pybamm.boundary_value(-sigma_eff, "right"),
"Neumann",
Expand Down
6 changes: 3 additions & 3 deletions pybamm/models/submodels/electrode/ohm/surface_form_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ def get_coupled_variables(self, variables):
x_p = pybamm.standard_spatial_vars.x_p
i_boundary_cc = variables["Current collector current density"]
i_e = variables[self.domain + " electrolyte current density"]
eps = variables[self.domain + " electrode porosity"]
tor = variables[self.domain + " electrode tortuosity"]
phi_s_cn = variables["Negative current collector potential"]

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

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

conductivity = param.sigma_p * (1 - eps) ** param.b_p
conductivity = param.sigma_p * tor
phi_s = -pybamm.IndefiniteIntegral(
i_s / conductivity, x_p
) + pybamm.PrimaryBroadcast(
Expand Down
Loading