Skip to content

Commit

Permalink
Merge pull request #2144 from pybamm-team/issue-2026-total-reaction
Browse files Browse the repository at this point in the history
Issue 2026 total reaction
  • Loading branch information
valentinsulzer authored Jul 7, 2022
2 parents 6a51492 + 864cfcb commit 6877eac
Show file tree
Hide file tree
Showing 17 changed files with 339 additions and 346 deletions.
27 changes: 0 additions & 27 deletions pybamm/models/full_battery_models/base_battery_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,33 +712,6 @@ def set_standard_output_variables(self):
{"y": var.y, "y [m]": var.y * L_z, "z": var.z, "z [m]": var.z * L_z}
)

# Initialize "total reaction" variables
# These will get populated by the "get_coupled_variables" methods, and then used
# later by "set_rhs" or "set_algebraic", which ensures that we always have
# added all the necessary variables by the time the sum is used
self.variables.update(
{
"Sum of electrolyte reaction source terms": 0,
"Sum of positive electrode electrolyte reaction source terms": 0,
"Sum of x-averaged positive electrode "
"electrolyte reaction source terms": 0,
"Sum of interfacial current densities": 0,
"Sum of positive electrode interfacial current densities": 0,
"Sum of x-averaged positive electrode interfacial current densities": 0,
}
)
if not self.half_cell:
self.variables.update(
{
"Sum of negative electrode electrolyte reaction source terms": 0,
"Sum of x-averaged negative electrode "
"electrolyte reaction source terms": 0,
"Sum of negative electrode interfacial current densities": 0,
"Sum of x-averaged negative electrode interfacial current densities"
"": 0,
}
)

def build_fundamental_and_external(self):
# Get the fundamental variables
for submodel_name, submodel in self.submodels.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,8 @@ def set_sei_submodel(self):
def set_lithium_plating_submodel(self):

self.submodels["lithium plating"] = pybamm.lithium_plating.NoPlating(self.param)

def set_total_kinetics_submodel(self):
self.submodels["total interface"] = pybamm.kinetics.TotalKinetics(
self.param, "lead-acid", self.options
)
1 change: 1 addition & 0 deletions pybamm/models/full_battery_models/lead_acid/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, options=None, name="Full model", build=True):
self.set_current_collector_submodel()
self.set_sei_submodel()
self.set_lithium_plating_submodel()
self.set_total_kinetics_submodel()

if build:
self.build_model()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, options=None, name="Composite model", build=True):
self.set_current_collector_submodel()
self.set_sei_submodel()
self.set_lithium_plating_submodel()
self.set_total_kinetics_submodel()

if build:
self.build_model()
Expand Down
1 change: 1 addition & 0 deletions pybamm/models/full_battery_models/lead_acid/loqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, options=None, name="LOQS model", build=True):
self.set_current_collector_submodel()
self.set_sei_submodel()
self.set_lithium_plating_submodel()
self.set_total_kinetics_submodel()

if build:
self.build_model()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def set_submodels(self, build):
self.set_convection_submodel()
self.set_open_circuit_potential_submodel()
self.set_intercalation_kinetics_submodel()
self.set_other_reaction_submodels_to_zero()
self.set_particle_submodel()
self.set_solid_submodel()
self.set_electrolyte_submodel()
Expand All @@ -63,6 +62,7 @@ def set_submodels(self, build):

self.set_sei_submodel()
self.set_lithium_plating_submodel()
self.set_total_kinetics_submodel()

if self.half_cell:
# This also removes "negative electrode" submodels, so should be done last
Expand Down Expand Up @@ -251,16 +251,10 @@ def set_lithium_plating_submodel(self):
self.param, self.x_average, self.options
)

def set_other_reaction_submodels_to_zero(self):
for domain in ["Negative", "Positive"]:
self.submodels[
f"{domain.lower()} oxygen interface"
] = pybamm.kinetics.NoReaction(self.param, domain, "lithium-ion oxygen")
self.submodels[
f"{domain.lower()} oxygen open circuit potential"
] = pybamm.open_circuit_potential.SingleOpenCircuitPotential(
self.param, domain, "lithium-ion oxygen", self.options
)
def set_total_kinetics_submodel(self):
self.submodels["total interface"] = pybamm.kinetics.TotalKinetics(
self.param, "lithium-ion", self.options
)

def set_crack_submodel(self):
for domain in ["Negative", "Positive"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,13 @@ def get_coupled_variables(self, variables):
variables.update(
self._get_standard_surface_potential_difference_variables(delta_phi)
)
if (
"X-averaged"
+ self.domain.lower()
+ "electrode surface potential difference"
not in variables
):
delta_phi_av = pybamm.x_average(delta_phi)
variables.update(
self._get_standard_average_surface_potential_difference_variables(
delta_phi_av
)

delta_phi_av = pybamm.x_average(delta_phi)
variables.update(
self._get_standard_average_surface_potential_difference_variables(
delta_phi_av
)
)
return variables

def set_boundary_conditions(self, variables):
Expand Down
Loading

0 comments on commit 6877eac

Please sign in to comment.