From d4a1cdde2a0a17a02e9aa0d3a86c6c17158e4572 Mon Sep 17 00:00:00 2001 From: Ferran Brosa Planella Date: Tue, 2 Feb 2021 17:39:32 +0100 Subject: [PATCH] #1349 Rob's suggestion --- .../base_electrolyte_conductivity.py | 35 ++++++++++++++--- .../full_conductivity.py | 39 +------------------ .../full_surface_form_conductivity.py | 1 + .../test_full_conductivity.py | 6 +++ 4 files changed, 38 insertions(+), 43 deletions(-) diff --git a/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py index 6a80ba6c19..877060cdce 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py @@ -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"] @@ -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"] @@ -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 diff --git a/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py index d495e5ea52..b62263fc20 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py @@ -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 diff --git a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/full_surface_form_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/full_surface_form_conductivity.py index 33255648b0..2903838ca6 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/full_surface_form_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/surface_potential_form/full_surface_form_conductivity.py @@ -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 diff --git a/tests/unit/test_models/test_submodels/test_electrolyte_conductivity/test_full_conductivity.py b/tests/unit/test_models/test_submodels/test_electrolyte_conductivity/test_full_conductivity.py index f1b76ca02d..affb87a6b2 100644 --- a/tests/unit/test_models/test_submodels/test_electrolyte_conductivity/test_full_conductivity.py +++ b/tests/unit/test_models/test_submodels/test_electrolyte_conductivity/test_full_conductivity.py @@ -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 "