Skip to content

Commit

Permalink
pybamm-team#1349 Rob's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
brosaplanella committed Feb 2, 2021
1 parent 05a040c commit d4a1cdd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ def _get_whole_cell_variables(self, variables):
The variables including the whole-cell electrolyte potentials
and currents.
"""
param = self.param

phi_e_n = variables["Negative electrolyte potential"]
phi_e_s = variables["Separator electrolyte potential"]
Expand All @@ -285,6 +284,36 @@ def _get_whole_cell_variables(self, variables):
i_e_p = variables["Positive electrolyte current density"]
i_e = pybamm.Concatenation(i_e_n, i_e_s, i_e_p)

variables.update(
self._get_standard_potential_variables(phi_e_n, phi_e_s, phi_e_p)
)
variables.update(self._get_standard_current_variables(i_e))

return variables

def _get_electrolyte_overpotentials(self, variables):
"""
A private function to obtain the electrolyte overpotential and Ohmic losses.
Note: requires 'variables' to contain the potential, electrolyte concentration
and temperature the subdomains: 'negative electrode', 'separator', and
'positive electrode'.
Parameters
----------
variables : dict
The variables that have been set in the rest of the model.
Returns
-------
variables : dict
The variables including the whole-cell electrolyte potentials
and currents.
"""
param = self.param

phi_e_n = variables["Negative electrolyte potential"]
phi_e_p = variables["Positive electrolyte potential"]

c_e_n = variables["Negative electrolyte concentration"]
c_e_s = variables["Separator electrolyte concentration"]
c_e_p = variables["Positive electrolyte concentration"]
Expand Down Expand Up @@ -326,10 +355,6 @@ def _get_whole_cell_variables(self, variables):
pybamm.x_average(phi_e_p) - pybamm.x_average(phi_e_n) - eta_c_av
)

variables.update(
self._get_standard_potential_variables(phi_e_n, phi_e_s, phi_e_p)
)
variables.update(self._get_standard_current_variables(i_e))
variables.update(self._get_split_overpotential(eta_c_av, delta_phi_e_av))

return variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,50 +39,13 @@ def get_coupled_variables(self, variables):
c_e = variables["Electrolyte concentration"]
phi_e = variables["Electrolyte potential"]

c_e_n, c_e_s, c_e_p = c_e.orphans
phi_e_n, _, phi_e_p = phi_e.orphans
T_n, T_s, T_p = T.orphans

i_e = (param.kappa_e(c_e, T) * tor * param.gamma_e / param.C_e) * (
param.chi(c_e, T) * (1 + param.Theta * T) * pybamm.grad(c_e) / c_e
- pybamm.grad(phi_e)
)

# concentration overpotential
indef_integral_n = pybamm.IndefiniteIntegral(
param.chi(c_e_n, T_n)
* (1 + param.Theta * T_n)
* pybamm.grad(c_e_n)
/ c_e_n,
pybamm.standard_spatial_vars.x_n,
)
indef_integral_s = pybamm.IndefiniteIntegral(
param.chi(c_e_s, T_s)
* (1 + param.Theta * T_s)
* pybamm.grad(c_e_s)
/ c_e_s,
pybamm.standard_spatial_vars.x_s,
)
indef_integral_p = pybamm.IndefiniteIntegral(
param.chi(c_e_p, T_p)
* (1 + param.Theta * T_p)
* pybamm.grad(c_e_p)
/ c_e_p,
pybamm.standard_spatial_vars.x_p,
)

integral_n = indef_integral_n
integral_s = indef_integral_s + pybamm.boundary_value(integral_n, "right")
integral_p = indef_integral_p + pybamm.boundary_value(integral_s, "right")

eta_c_av = pybamm.x_average(integral_p) - pybamm.x_average(integral_n)

delta_phi_e_av = (
pybamm.x_average(phi_e_p) - pybamm.x_average(phi_e_n) - eta_c_av
)

variables.update(self._get_standard_current_variables(i_e))
variables.update(self._get_split_overpotential(eta_c_av, delta_phi_e_av))
variables.update(self._get_electrolyte_overpotentials(variables))

return variables

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def get_coupled_variables(self, variables):

if self.domain == "Positive":
variables.update(self._get_whole_cell_variables(variables))
variables.update(self._get_electrolyte_overpotentials(variables))

return variables

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def test_public_functions(self):
variables = {
"Electrolyte tortuosity": a,
"Electrolyte concentration": pybamm.Concatenation(a_n, a_s, a_p),
"Negative electrolyte concentration": a_n,
"Separator electrolyte concentration": a_s,
"Positive electrolyte concentration": a_p,
"Negative electrode temperature": a_n,
"Separator temperature": a_s,
"Positive electrode temperature": a_p,
"Negative "
+ surf: pybamm.FullBroadcast(a, "negative electrode", "current collector"),
"Positive "
Expand Down

0 comments on commit d4a1cdd

Please sign in to comment.