diff --git a/CHANGELOG.md b/CHANGELOG.md index 56832775ae..c30b2c49f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Features +- Added the electrolyte overpotential and Ohmic losses for full conductivity, including surface form ([#1350](https://github.com/pybamm-team/PyBaMM/pull/1350)) - Added functionality to `Citations` to print formatted citations ([#1340](https://github.com/pybamm-team/PyBaMM/pull/1340)) - Updated the way events are handled in `CasadiSolver` for more accurate event location ([#1328](https://github.com/pybamm-team/PyBaMM/pull/1328)) - Added error message if initial conditions are outside the bounds of a variable ([#1326](https://github.com/pybamm-team/PyBaMM/pull/1326)) diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py index c422089ddd..8ff05fbda0 100644 --- a/pybamm/models/full_battery_models/base_battery_model.py +++ b/pybamm/models/full_battery_models/base_battery_model.py @@ -848,12 +848,10 @@ def set_voltage_variables(self): # Battery-wide variables V_dim = self.variables["Terminal voltage [V]"] - eta_e_av = self.variables.get("X-averaged electrolyte ohmic losses", 0) - eta_c_av = self.variables.get("X-averaged concentration overpotential", 0) - eta_e_av_dim = self.variables.get("X-averaged electrolyte ohmic losses [V]", 0) - eta_c_av_dim = self.variables.get( - "X-averaged concentration overpotential [V]", 0 - ) + eta_e_av = self.variables["X-averaged electrolyte ohmic losses"] + eta_c_av = self.variables["X-averaged concentration overpotential"] + eta_e_av_dim = self.variables["X-averaged electrolyte ohmic losses [V]"] + eta_c_av_dim = self.variables["X-averaged concentration overpotential [V]"] num_cells = pybamm.Parameter( "Number of cells connected in series to make a battery" ) diff --git a/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py index 440fd4e26c..877060cdce 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/base_electrolyte_conductivity.py @@ -291,6 +291,74 @@ def _get_whole_cell_variables(self, variables): 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"] + + T_n = variables["Negative electrode temperature"] + T_s = variables["Separator temperature"] + T_p = variables["Positive electrode temperature"] + + # 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_split_overpotential(eta_c_av, delta_phi_e_av)) + + return variables + def set_boundary_conditions(self, variables): phi_e = variables["Electrolyte potential"] self.boundary_conditions = { diff --git a/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py b/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py index 0a6d80071b..b62263fc20 100644 --- a/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py +++ b/pybamm/models/submodels/electrolyte_conductivity/full_conductivity.py @@ -45,6 +45,7 @@ def get_coupled_variables(self, variables): ) variables.update(self._get_standard_current_variables(i_e)) + 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 0bdff0e1bf..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 @@ -12,13 +12,19 @@ def test_public_functions(self): param = pybamm.LithiumIonParameters() a = pybamm.Scalar(1) surf = "electrode surface area to volume ratio" + a_n = pybamm.FullBroadcast(a, "negative electrode", "current collector") + a_s = pybamm.FullBroadcast(a, "separator", "current collector") + a_p = pybamm.FullBroadcast(a, "positive electrode", "current collector") + variables = { "Electrolyte tortuosity": a, - "Electrolyte concentration": pybamm.FullBroadcast( - a, - ["negative electrode", "separator", "positive electrode"], - "current collector", - ), + "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 " @@ -28,7 +34,7 @@ def test_public_functions(self): ["negative electrode", "separator", "positive electrode"], "current collector", ), - "Cell temperature": a, + "Cell temperature": pybamm.Concatenation(a_n, a_s, a_p), } submodel = pybamm.electrolyte_conductivity.Full(param) std_tests = tests.StandardSubModelTests(submodel, variables) diff --git a/tests/unit/test_models/test_submodels/test_electrolyte_conductivity/test_surface_form/test_full_surface_form_conductivity.py b/tests/unit/test_models/test_submodels/test_electrolyte_conductivity/test_surface_form/test_full_surface_form_conductivity.py index 30d8b88335..59c5e5388f 100644 --- a/tests/unit/test_models/test_submodels/test_electrolyte_conductivity/test_surface_form/test_full_surface_form_conductivity.py +++ b/tests/unit/test_models/test_submodels/test_electrolyte_conductivity/test_surface_form/test_full_surface_form_conductivity.py @@ -31,9 +31,11 @@ def test_public_functions(self): "Electrolyte potential": pybamm.Concatenation(a_n, a_s, a_p), "Negative electrode temperature": a_n, "Separator temperature": a_s, + "Separator electrolyte concentration": a_s, "Positive electrode temperature": a_p, "Negative electrode potential": a_n, "Positive electrode potential": a_p, + "Positive electrolyte concentration": a_p, } spf = pybamm.electrolyte_conductivity.surface_potential_form @@ -50,8 +52,12 @@ def test_public_functions(self): ), "Negative electrolyte potential": a_n, "Negative electrolyte current density": a_n, + "Negative electrolyte concentration": a_n, + "Negative electrode temperature": a_n, "Separator electrolyte potential": a_s, "Separator electrolyte current density": a_s, + "Separator electrolyte concentration": a_s, + "Separator temperature": a_s, "Positive electrode porosity": a_p, "Positive electrolyte tortuosity": a_p, "Positive electrode tortuosity": a_p,