Skip to content

Commit

Permalink
pybamm-team#1506 make electronic conductivity function of temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
brosaplanella committed Jul 27, 2021
1 parent 1b5e5f3 commit 1a54286
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _get_standard_neg_pos_velocity_variables(self, v_box_n, v_box_p):
return variables

def _get_standard_neg_pos_acceleration_variables(self, div_v_box_n, div_v_box_p):
""" Acceleration in the electrodes """
"""Acceleration in the electrodes"""

acc_scale = self.param.velocity_scale / self.param.L_x

Expand All @@ -79,7 +79,7 @@ def _get_standard_neg_pos_acceleration_variables(self, div_v_box_n, div_v_box_p)
return variables

def _get_standard_neg_pos_pressure_variables(self, p_n, p_p):
""" Pressure in the electrodes """
"""Pressure in the electrodes"""

variables = {
"Negative electrode pressure": p_n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ def get_fundamental_variables(self):
sigma_cn_dbl_prime = param.sigma_cn_dbl_prime
sigma_cp_dbl_prime = param.sigma_cp_dbl_prime
delta = param.delta # aspect ratio
T_cn = self.variables["Negative current collector temperature"]
T_cp = self.variables["Positive current collector temperature"]

# Set model variables: Note: we solve using a scaled version that is
# better conditioned
Expand All @@ -72,8 +70,8 @@ def get_fundamental_variables(self):
R_cp_scaled = pybamm.Variable(
"Scaled positive current collector resistance", domain="current collector"
)
R_cn = delta * R_cn_scaled / (l_cn * sigma_cn_dbl_prime(T_cn))
R_cp = delta * R_cp_scaled / (l_cp * sigma_cp_dbl_prime(T_cp))
R_cn = delta * R_cn_scaled / (l_cn * sigma_cn_dbl_prime)
R_cp = delta * R_cp_scaled / (l_cp * sigma_cp_dbl_prime)

# Define effective current collector resistance
if self.options["dimensionality"] == 1:
Expand Down Expand Up @@ -333,8 +331,6 @@ def __init__(self):
sigma_cn_dbl_prime = param.sigma_cn_dbl_prime
sigma_cp_dbl_prime = param.sigma_cp_dbl_prime
delta = param.delta
T_cn = self.variables["Negative current collector temperature"]
T_cp = self.variables["Positive current collector temperature"]

# Set model variables -- we solve a auxilliary problem in each current collector
# then relate this to the potentials and resistances later
Expand Down Expand Up @@ -375,11 +371,11 @@ def __init__(self):
}

# Define effective current collector resistance
R_cc_n = delta * pybamm.yz_average(f_n) / (l_cn * sigma_cn_dbl_prime(T_cn))
R_cc_n = delta * pybamm.yz_average(f_n) / (l_cn * sigma_cn_dbl_prime)
R_cc_p = (
delta
* pybamm.BoundaryIntegral(f_p, "positive tab")
/ (l_cp * sigma_cp_dbl_prime(T_cp))
/ (l_cp * sigma_cp_dbl_prime)
)
R_cc = R_cc_n + R_cc_p
R_scale = param.potential_scale / param.I_typ
Expand Down
11 changes: 3 additions & 8 deletions pybamm/models/submodels/current_collector/potential_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ def set_algebraic(self, variables):
phi_s_cn = variables["Negative current collector potential"]
phi_s_cp = variables["Positive current collector potential"]
i_boundary_cc = variables["Current collector current density"]
T_cn = variables["Negative current collector temperature"]
T_cp = variables["Positive current collector temperature"]

self.algebraic = {
phi_s_cn: (param.sigma_cn(T_cn) * param.delta ** 2 * param.l_cn)
phi_s_cn: (param.sigma_cn * param.delta ** 2 * param.l_cn)
* pybamm.laplacian(phi_s_cn)
- pybamm.source(i_boundary_cc, phi_s_cn),
i_boundary_cc: (param.sigma_cp(T_cp) * param.delta ** 2 * param.l_cp)
i_boundary_cc: (param.sigma_cp * param.delta ** 2 * param.l_cp)
* pybamm.laplacian(phi_s_cp)
+ pybamm.source(i_boundary_cc, phi_s_cp),
}
Expand Down Expand Up @@ -93,9 +91,6 @@ def set_boundary_conditions(self, variables):
phi_s_cn = variables["Negative current collector potential"]
phi_s_cp = variables["Positive current collector potential"]

T_cn = variables["Negative current collector temperature"]
T_cp = variables["Positive current collector temperature"]

param = self.param
applied_current = variables["Total current density"]
cc_area = self._get_effective_current_collector_area()
Expand All @@ -104,7 +99,7 @@ def set_boundary_conditions(self, variables):
pos_tab_bc = (
-applied_current
* cc_area
/ (param.sigma_cp(T_cp) * param.delta ** 2 * param.l_cp)
/ (param.sigma_cp * param.delta ** 2 * param.l_cp)
)

# Boundary condition needs to be on the variables that go into the Laplacian,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,13 @@ def set_algebraic(self, variables):
i_boundary_cc_0 = variables["Leading-order current collector current density"]
c = variables["Lagrange multiplier"]

T_cn = variables["Negative current collector temperature"]
T_cp = variables["Positive current collector temperature"]

# Note that the second argument of 'source' must be the same as the argument
# in the laplacian (the variable to which the boundary conditions are applied)
self.algebraic = {
phi_s_cn: (param.sigma_cn(T_cn) * param.delta ** 2 * param.l_cn)
phi_s_cn: (param.sigma_cn * param.delta ** 2 * param.l_cn)
* pybamm.laplacian(phi_s_cn)
- pybamm.source(i_boundary_cc_0, phi_s_cn),
i_boundary_cc: (param.sigma_cp(T_cp) * param.delta ** 2 * param.l_cp)
i_boundary_cc: (param.sigma_cp * param.delta ** 2 * param.l_cp)
* pybamm.laplacian(phi_s_cp)
+ pybamm.source(i_boundary_cc_0, phi_s_cp)
+ c * pybamm.PrimaryBroadcast(cc_area, "current collector"),
Expand Down
4 changes: 3 additions & 1 deletion pybamm/models/submodels/electrode/ohm/base_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def set_boundary_conditions(self, variables):
lbc = (pybamm.Scalar(0), "Neumann")
i_boundary_cc = variables["Current collector current density"]
T_p = variables["Positive electrode temperature"]
sigma_eff = self.param.sigma_p(T_p) * variables["Positive electrode tortuosity"]
sigma_eff = (
self.param.sigma_p(T_p) * variables["Positive electrode tortuosity"]
)
rbc = (
i_boundary_cc / pybamm.boundary_value(-sigma_eff, "right"),
"Neumann",
Expand Down
4 changes: 2 additions & 2 deletions pybamm/models/submodels/electrode/ohm/composite_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_coupled_variables(self, variables):
"Leading-order x-averaged " + self.domain.lower() + " electrode tortuosity"
]
phi_s_cn = variables["Negative current collector potential"]
T = variables[self.domain + " electrode temperature"]
T = variables["X-averaged " + self.domain.lower() + " electrode temperature"]

if self._domain == "Negative":
sigma_eff_0 = self.param.sigma_n(T) * tor_0
Expand Down Expand Up @@ -81,7 +81,7 @@ def set_boundary_conditions(self, variables):
"Leading-order x-averaged " + self.domain.lower() + " electrode tortuosity"
]
i_boundary_cc_0 = variables["Leading-order current collector current density"]
T = variables[self.domain + " electrode temperature"]
T = variables["X-averaged " + self.domain.lower() + " electrode temperature"]

if self.domain == "Negative":
lbc = (pybamm.Scalar(0), "Dirichlet")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class BaseModel(pybamm.BaseSubModel):
"""Model to represent the behaviour of the external circuit. """
"""Model to represent the behaviour of the external circuit."""

def __init__(self, param):
super().__init__(param)
Expand All @@ -27,7 +27,7 @@ def set_rhs(self, variables):


class LeadingOrderBaseModel(BaseModel):
"""Model to represent the behaviour of the external circuit, at leading order. """
"""Model to represent the behaviour of the external circuit, at leading order."""

def __init__(self, param):
super().__init__(param)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class CurrentControl(BaseModel):
"""External circuit with current control. """
"""External circuit with current control."""

def __init__(self, param):
super().__init__(param)
Expand All @@ -30,7 +30,7 @@ def get_fundamental_variables(self):


class LeadingOrderCurrentControl(CurrentControl, LeadingOrderBaseModel):
"""External circuit with current control, for leading order models. """
"""External circuit with current control, for leading order models."""

def __init__(self, param):
super().__init__(param)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class FunctionControl(BaseModel):
"""External circuit with an arbitrary function. """
"""External circuit with an arbitrary function."""

def __init__(self, param, external_circuit_function):
super().__init__(param)
Expand Down Expand Up @@ -63,7 +63,7 @@ def constant_voltage(self, variables):


class PowerFunctionControl(FunctionControl):
"""External circuit with power control. """
"""External circuit with power control."""

def __init__(self, param):
super().__init__(param, self.constant_power)
Expand All @@ -77,7 +77,7 @@ def constant_power(self, variables):


class LeadingOrderFunctionControl(FunctionControl, LeadingOrderBaseModel):
"""External circuit with an arbitrary function, at leading order. """
"""External circuit with an arbitrary function, at leading order."""

def __init__(self, param, external_circuit_class):
super().__init__(param, external_circuit_class)
Expand All @@ -103,7 +103,7 @@ def constant_voltage(self, variables):


class LeadingOrderPowerFunctionControl(LeadingOrderFunctionControl):
"""External circuit with power control, at leading order. """
"""External circuit with power control, at leading order."""

def __init__(self, param):
super().__init__(param, self.constant_power)
Expand Down
4 changes: 2 additions & 2 deletions pybamm/models/submodels/interface/kinetics/butler_volmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _get_kinetics(self, j0, ne, eta_r, T):
return 2 * j0 * pybamm.sinh(prefactor * eta_r)

def _get_dj_dc(self, variables):
""" See :meth:`pybamm.interface.kinetics.BaseKinetics._get_dj_dc` """
"""See :meth:`pybamm.interface.kinetics.BaseKinetics._get_dj_dc`"""
c_e, delta_phi, j0, ne, ocp, T = self._get_interface_variables_for_first_order(
variables
)
Expand All @@ -47,7 +47,7 @@ def _get_dj_dc(self, variables):
)

def _get_dj_ddeltaphi(self, variables):
""" See :meth:`pybamm.interface.kinetics.BaseKinetics._get_dj_ddeltaphi` """
"""See :meth:`pybamm.interface.kinetics.BaseKinetics._get_dj_ddeltaphi`"""
_, delta_phi, j0, ne, ocp, T = self._get_interface_variables_for_first_order(
variables
)
Expand Down
4 changes: 2 additions & 2 deletions pybamm/models/submodels/interface/kinetics/tafel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _get_kinetics(self, j0, ne, eta_r, T):
return j0 * pybamm.exp((ne / (2 * (1 + self.param.Theta * T))) * eta_r)

def _get_dj_dc(self, variables):
""" See :meth:`pybamm.interface.kinetics.BaseKinetics._get_dj_dc` """
"""See :meth:`pybamm.interface.kinetics.BaseKinetics._get_dj_dc`"""
c_e, delta_phi, j0, ne, ocp, T = self._get_interface_variables_for_first_order(
variables
)
Expand All @@ -46,7 +46,7 @@ def _get_dj_dc(self, variables):
)

def _get_dj_ddeltaphi(self, variables):
""" See :meth:`pybamm.interface.kinetics.BaseKinetics._get_dj_ddeltaphi` """
"""See :meth:`pybamm.interface.kinetics.BaseKinetics._get_dj_ddeltaphi`"""
_, delta_phi, j0, ne, ocp, T = self._get_interface_variables_for_first_order(
variables
)
Expand Down
2 changes: 1 addition & 1 deletion pybamm/models/submodels/particle_cracking/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .base_cracking import BaseCracking
from .crack_propagation import CrackPropagation
from .swelling_only import SwellingOnly
from .swelling_only import SwellingOnly
10 changes: 4 additions & 6 deletions pybamm/models/submodels/thermal/base_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ def _current_collector_heating(self, variables):
# In the limit of infinitely large current collector conductivity (i.e.
# 0D current collectors), the Ohmic heating in the current collectors is
# zero
T_cn = variables["Negative current collector temperature"]
T_cp = variables["Positive current collector temperature"]

if self.cc_dimension == 0:
Q_s_cn = pybamm.Scalar(0)
Expand All @@ -228,16 +226,16 @@ def _current_collector_heating(self, variables):
phi_s_cn = variables["Negative current collector potential"]
phi_s_cp = variables["Positive current collector potential"]
if self.cc_dimension == 1:
Q_s_cn = self.param.sigma_cn_prime(T_cn) * pybamm.inner(
Q_s_cn = self.param.sigma_cn_prime * pybamm.inner(
pybamm.grad(phi_s_cn), pybamm.grad(phi_s_cn)
)
Q_s_cp = self.param.sigma_cp_prime(T_cp) * pybamm.inner(
Q_s_cp = self.param.sigma_cp_prime * pybamm.inner(
pybamm.grad(phi_s_cp), pybamm.grad(phi_s_cp)
)
elif self.cc_dimension == 2:
# Inner not implemented in 2D -- have to call grad_squared directly
Q_s_cn = self.param.sigma_cn_prime(T_cn) * pybamm.grad_squared(phi_s_cn)
Q_s_cp = self.param.sigma_cp_prime(T_cp) * pybamm.grad_squared(phi_s_cp)
Q_s_cn = self.param.sigma_cn_prime * pybamm.grad_squared(phi_s_cn)
Q_s_cp = self.param.sigma_cp_prime * pybamm.grad_squared(phi_s_cp)
return Q_s_cn, Q_s_cp

def _x_average(self, var, var_cn, var_cp):
Expand Down
66 changes: 26 additions & 40 deletions pybamm/parameters/lead_acid_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ def _set_dimensional_parameters(self):
self.Q_p_max_dimensional = pybamm.Parameter(
"Positive electrode volumetric capacity [C.m-3]"
)
# In lead-acid the current collector and electrodes are the same (same
# conductivity) but we correct here for Bruggeman. Note that because for
# lithium-ion we allow electrode conductivity to be a function of temperature,
# but not the current collector conductivity, here the latter is evaluated at
# T_ref.
self.sigma_cn_dimensional = (
self.sigma_n_dimensional(self.T_ref) * (1 - self.eps_n_max) ** self.b_s_n
)
self.sigma_cp_dimensional = (
self.sigma_p_dimensional(self.T_ref) * (1 - self.eps_p_max) ** self.b_s_p
)

# Electrochemical reactions
# Main
Expand Down Expand Up @@ -229,18 +240,6 @@ def sigma_p_dimensional(self, T):
"Positive electrode conductivity [S.m-1]", inputs
)

def sigma_cn_dimensional(self, T):
"""Dimensional electrical conductivity in negative electrode current
collector. In lead-acid the current collector and electrodes are the same (same
conductivity) but we correct here for Bruggeman"""
return self.sigma_n_dimensional(T) * (1 - self.eps_n_max) ** self.b_s_n

def sigma_cp_dimensional(self, T):
"""Dimensional electrical conductivity in positive electrode current
collector. In lead-acid the current collector and electrodes are the same (same
conductivity) but we correct here for Bruggeman"""
return self.sigma_p_dim(T) * (1 - self.eps_p_max) ** self.b_s_p

def t_plus(self, c_e, T):
"""Dimensionless transference number (i.e. c_e is dimensionless)"""
inputs = {"Electrolyte concentration [mol.m-3]": c_e * self.c_e_typ}
Expand Down Expand Up @@ -497,6 +496,15 @@ def _set_dimensionless_parameters(self):
)

# Electrode Properties
# Electrode Properties
self.sigma_cn = (
self.sigma_cn_dimensional * self.potential_scale / self.i_typ / self.L_x
)
self.sigma_cp = (
self.sigma_cp_dimensional * self.potential_scale / self.i_typ / self.L_x
)
self.sigma_cn_prime = self.sigma_cn * self.delta ** 2
self.sigma_cp_prime = self.sigma_cp * self.delta ** 2
self.delta_pore_n = 1 / (self.a_n_typ * self.L_x)
self.delta_pore_p = 1 / (self.a_p_typ * self.L_x)
self.Q_n_max = self.Q_n_max_dimensional / (self.c_e_typ * self.F)
Expand Down Expand Up @@ -681,33 +689,21 @@ def sigma_n(self, T):
T_dim = self.Delta_T * T + self.T_ref
return (
self.sigma_n_dimensional(T_dim)
* self.potential_scale / self.current_scale / self.L_x
* self.potential_scale
/ self.current_scale
/ self.L_x
)

def sigma_p(self, T):
"""Dimensionless positive electrode electrical conductivity"""
T_dim = self.Delta_T * T + self.T_ref
return (
self.sigma_p_dimensional(T_dim)
* self.potential_scale / self.current_scale / self.L_x
)

def sigma_cn(self, T):
"""Dimensionless negative electrode current collector electrical conductivity"""
T_dim = self.Delta_T * T + self.T_ref
return (
self.sigma_cn_dimensional(T_dim)
* self.potential_scale / self.current_scale / self.L_x
* self.potential_scale
/ self.current_scale
/ self.L_x
)

def sigma_cp(self, T):
"""Dimensionless positive electrode current collector electrical conductivity"""
T_dim = self.Delta_T * T + self.T_ref
return (
self.sigma_cp_dimensional(T_dim)
* self.potential_scale / self.current_scale / self.L_x
)

def sigma_n_prime(self, T):
"""Rescaled dimensionless negative electrode electrical conductivity"""
return self.sigma_n(T) * self.delta ** 2
Expand All @@ -716,16 +712,6 @@ def sigma_p_prime(self, T):
"""Rescaled dimensionless positive electrode electrical conductivity"""
return self.sigma_p(T) * self.delta ** 2

def sigma_cn_prime(self, T):
"""Rescaled dimensionless negative electrode current collector electrical
conductivity"""
return self.sigma_cn(T) * self.delta ** 2

def sigma_cp_prime(self, T):
"""Rescaled dimensionless positive electrode current collector electrical
conductivity"""
return self.sigma_cp(T) * self.delta ** 2

def D_e(self, c_e, T):
"""Dimensionless electrolyte diffusivity"""
c_e_dimensional = c_e * self.c_e_typ
Expand Down
Loading

0 comments on commit 1a54286

Please sign in to comment.