Skip to content

Commit

Permalink
pybamm-team#1506 added temperature dependence, tests still not working
Browse files Browse the repository at this point in the history
  • Loading branch information
brosaplanella committed Jun 10, 2021
1 parent f6cb07a commit 7ac08d8
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 79 deletions.
4 changes: 2 additions & 2 deletions pybamm/models/full_battery_models/lead_acid/basic_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def __init__(self, name="Basic full model"):
######################
# Current in the solid
######################
i_s_n = -param.sigma_n * (1 - eps_n) ** param.b_s_n * pybamm.grad(phi_s_n)
sigma_eff_p = param.sigma_p * (1 - eps_p) ** param.b_s_p
i_s_n = -param.sigma_n(T) * (1 - eps_n) ** param.b_s_n * pybamm.grad(phi_s_n)
sigma_eff_p = param.sigma_p(T) * (1 - eps_p) ** param.b_s_p
i_s_p = -sigma_eff_p * pybamm.grad(phi_s_p)
# The `algebraic` dictionary contains differential equations, with the key being
# the main scalar variable of interest in the equation
Expand Down
4 changes: 2 additions & 2 deletions pybamm/models/full_battery_models/lithium_ion/basic_dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ def __init__(self, name="Doyle-Fuller-Newman model"):
######################
# Current in the solid
######################
sigma_eff_n = param.sigma_n * eps_s_n ** param.b_s_n
sigma_eff_n = param.sigma_n(T) * eps_s_n ** param.b_s_n
i_s_n = -sigma_eff_n * pybamm.grad(phi_s_n)
sigma_eff_p = param.sigma_p * eps_s_p ** param.b_s_p
sigma_eff_p = param.sigma_p(T) * eps_s_p ** param.b_s_p
i_s_p = -sigma_eff_p * pybamm.grad(phi_s_p)
# The `algebraic` dictionary contains differential equations, with the key being
# the main scalar variable of interest in the equation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def __init__(self, name="Doyle-Fuller-Newman half cell model", options=None):
######################
# Current in the solid
######################
sigma_eff_w = sigma_w * eps_s_w ** b_s_w
sigma_eff_w = sigma_w(T) * eps_s_w ** b_s_w
i_s_w = -sigma_eff_w * pybamm.grad(phi_s_w)
self.boundary_conditions[phi_s_w] = {
"left": (pybamm.Scalar(0), "Neumann"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ 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 @@ -70,8 +72,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)
R_cp = delta * R_cp_scaled / (l_cp * sigma_cp_dbl_prime)
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))

# Define effective current collector resistance
if self.options["dimensionality"] == 1:
Expand Down Expand Up @@ -331,6 +333,8 @@ 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 @@ -371,11 +375,11 @@ def __init__(self):
}

# Define effective current collector resistance
R_cc_n = delta * pybamm.yz_average(f_n) / (l_cn * sigma_cn_dbl_prime)
R_cc_n = delta * pybamm.yz_average(f_n) / (l_cn * sigma_cn_dbl_prime(T_cn))
R_cc_p = (
delta
* pybamm.BoundaryIntegral(f_p, "positive tab")
/ (l_cp * sigma_cp_dbl_prime)
/ (l_cp * sigma_cp_dbl_prime(T_cp))
)
R_cc = R_cc_n + R_cc_p
R_scale = param.potential_scale / param.I_typ
Expand Down
11 changes: 8 additions & 3 deletions pybamm/models/submodels/current_collector/potential_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ 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 * param.delta ** 2 * param.l_cn)
phi_s_cn: (param.sigma_cn(T_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 * param.delta ** 2 * param.l_cp)
i_boundary_cc: (param.sigma_cp(T_cp) * param.delta ** 2 * param.l_cp)
* pybamm.laplacian(phi_s_cp)
+ pybamm.source(i_boundary_cc, phi_s_cp),
}
Expand Down Expand Up @@ -91,6 +93,9 @@ 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 @@ -99,7 +104,7 @@ def set_boundary_conditions(self, variables):
pos_tab_bc = (
-applied_current
* cc_area
/ (param.sigma_cp * param.delta ** 2 * param.l_cp)
/ (param.sigma_cp(T_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,13 +57,16 @@ 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 * param.delta ** 2 * param.l_cn)
phi_s_cn: (param.sigma_cn(T_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 * param.delta ** 2 * param.l_cp)
i_boundary_cc: (param.sigma_cp(T_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
3 changes: 2 additions & 1 deletion pybamm/models/submodels/electrode/ohm/base_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def set_boundary_conditions(self, variables):
elif self.domain == "Positive":
lbc = (pybamm.Scalar(0), "Neumann")
i_boundary_cc = variables["Current collector current density"]
sigma_eff = self.param.sigma_p * variables["Positive electrode tortuosity"]
T_p = variables["Positive electrode temperature"]
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
8 changes: 5 additions & 3 deletions pybamm/models/submodels/electrode/ohm/composite_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ 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"]

if self._domain == "Negative":
sigma_eff_0 = self.param.sigma_n * tor_0
sigma_eff_0 = self.param.sigma_n(T) * tor_0
phi_s = phi_s_cn + (i_boundary_cc_0 / sigma_eff_0) * (
x_n * (x_n - 2 * l_n) / (2 * l_n)
)
Expand All @@ -52,7 +53,7 @@ def get_coupled_variables(self, variables):
]
phi_e_p_av = variables["X-averaged positive electrolyte potential"]

sigma_eff_0 = self.param.sigma_p * tor_0
sigma_eff_0 = self.param.sigma_p(T) * tor_0

const = (
delta_phi_p_av
Expand Down Expand Up @@ -80,14 +81,15 @@ 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"]

if self.domain == "Negative":
lbc = (pybamm.Scalar(0), "Dirichlet")
rbc = (pybamm.Scalar(0), "Neumann")

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

self.boundary_conditions[phi_s] = {"left": lbc, "right": rbc}
8 changes: 5 additions & 3 deletions pybamm/models/submodels/electrode/ohm/full_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ def get_coupled_variables(self, variables):

phi_s = variables[self.domain + " electrode potential"]
tor = variables[self.domain + " electrode tortuosity"]
T = variables[self.domain + " electrode temperature"]

if self.domain == "Negative":
sigma = self.param.sigma_n
sigma = self.param.sigma_n(T)
elif self.domain == "Positive":
sigma = self.param.sigma_p
sigma = self.param.sigma_p(T)

sigma_eff = sigma * tor
i_s = -sigma_eff * pybamm.grad(phi_s)
Expand Down Expand Up @@ -76,14 +77,15 @@ def set_boundary_conditions(self, variables):
phi_s = variables[self.domain + " electrode potential"]
phi_s_cn = variables["Negative current collector potential"]
tor = variables[self.domain + " electrode tortuosity"]
T = variables[self.domain + " electrode temperature"]

if self.domain == "Negative":
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 * tor
sigma_eff = self.param.sigma_p(T) * tor
i_boundary_cc = variables["Current collector current density"]
rbc = (
i_boundary_cc / pybamm.boundary_value(-sigma_eff, "right"),
Expand Down
5 changes: 3 additions & 2 deletions pybamm/models/submodels/electrode/ohm/surface_form_ohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ def get_coupled_variables(self, variables):
i_e = variables[self.domain + " electrolyte current density"]
tor = variables[self.domain + " electrode tortuosity"]
phi_s_cn = variables["Negative current collector potential"]
T = variables[self.domain + " electrode temperature"]

i_s = i_boundary_cc - i_e

if self.domain == "Negative":
conductivity = param.sigma_n * tor
conductivity = param.sigma_n(T) * tor
phi_s = phi_s_cn - pybamm.IndefiniteIntegral(i_s / conductivity, x_n)

elif self.domain == "Positive":

phi_e_s = variables["Separator electrolyte potential"]
delta_phi_p = variables["Positive electrode surface potential difference"]

conductivity = param.sigma_p * tor
conductivity = param.sigma_p(T) * tor
phi_s = -pybamm.IndefiniteIntegral(i_s / conductivity, x_p) + (
pybamm.boundary_value(phi_e_s, "right")
+ pybamm.boundary_value(delta_phi_p, "left")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def _get_conductivities(self, variables):
c_e = variables[self.domain + " electrolyte concentration"]
T = variables[self.domain + " electrode temperature"]
if self.domain == "Negative":
sigma = param.sigma_n
sigma = param.sigma_n(T)
elif self.domain == "Positive":
sigma = param.sigma_p
sigma = param.sigma_p(T)

kappa_eff = param.kappa_e(c_e, T) * tor_e
sigma_eff = sigma * tor_s
Expand Down
11 changes: 7 additions & 4 deletions pybamm/models/submodels/thermal/base_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ 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)
Q_s_cp = pybamm.Scalar(0)
Expand All @@ -225,16 +228,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 * pybamm.inner(
Q_s_cn = self.param.sigma_cn_prime(T_cn) * pybamm.inner(
pybamm.grad(phi_s_cn), pybamm.grad(phi_s_cn)
)
Q_s_cp = self.param.sigma_cp_prime * pybamm.inner(
Q_s_cp = self.param.sigma_cp_prime(T_cp) * 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 * pybamm.grad_squared(phi_s_cn)
Q_s_cp = self.param.sigma_cp_prime * pybamm.grad_squared(phi_s_cp)
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)
return Q_s_cn, Q_s_cp

def _x_average(self, var, var_cn, var_cp):
Expand Down
Loading

0 comments on commit 7ac08d8

Please sign in to comment.