def METHOD_NAME(self, variables, domain, phase_name):
    Domain = domain.capitalize()
    if self.chemistry == "lithium-ion":
        reaction_names = [""]
        if phase_name == "":
            reaction_names += ["SEI "]
            if self.options.electrode_types["negative"] == "porous":
                # separate plating reaction only if the negative electrode is
                # porous, since plating is the main reaction
                # SEI on cracks only in a porous negative electrode
                reaction_names.extend(["lithium plating ", "SEI on cracks "])
    elif self.chemistry == "lead-acid":
        reaction_names = ["", "oxygen "]
    # Create separate 'new_variables' so that variables only get updated once
    # everything is computed
    new_variables = variables.copy()
    # Initialize "total reaction" variables
    # These will get populated by each reaction, 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
    new_variables.update(
        {
            f"Sum of {domain} electrode {phase_name}"
            "electrolyte reaction source terms [A.m-3]": 0,
            f"Sum of x-averaged {domain} electrode {phase_name}"
            "electrolyte reaction source terms [A.m-3]": 0,
            f"Sum of {domain} electrode {phase_name}"
            "volumetric interfacial current densities [A.m-3]": 0,
            f"Sum of x-averaged {domain} electrode {phase_name}"
            "volumetric interfacial current densities [A.m-3]": 0,
        }
    )
    for reaction_name in reaction_names:
        # Sum variables
        a_j_k = new_variables[
            f"{Domain} electrode {reaction_name}{phase_name}volumetric "
            "interfacial current density [A.m-3]"
        ]
        if self.chemistry == "lithium-ion":
            # Both the main reaction current contribute to the electrolyte reaction
            # current
            s_k = 1
        elif self.chemistry == "lead-acid":
            if reaction_name == "":  # main reaction
                s_k = self.param.domain_params[domain].prim.s_plus_S
            elif reaction_name == "oxygen ":
                s_k = self.param.s_plus_Ox
        new_variables[
            f"Sum of {domain} electrode {phase_name}"
            "electrolyte reaction source terms [A.m-3]"
        ] += (s_k * a_j_k)
        new_variables[
            f"Sum of x-averaged {domain} electrode {phase_name}"
            "electrolyte reaction source terms [A.m-3]"
        ] += pybamm.x_average(s_k * a_j_k)
        new_variables[
            f"Sum of {domain} electrode {phase_name}volumetric "
            "interfacial current densities [A.m-3]"
        ] += a_j_k
        new_variables[
            f"Sum of x-averaged {domain} electrode {phase_name}"
            "volumetric interfacial current densities [A.m-3]"
        ] += pybamm.x_average(a_j_k)
    variables.update(new_variables)
    return variables