Skip to content

SEI="none" with "partially reversible" lithium plating raises ZeroDivisionError during parameter processing #5709

Description

@dikshant1103-beep

Description

I believe this is a validation issue rather than a solver issue.

When using the OKane2022 parameter set, the option combination

  • SEI: "none"
  • lithium plating: "partially reversible"

is accepted during model construction but fails during parameter processing with a bare ZeroDivisionError before any simulation begins.

The OKane2022 dead-lithium decay model is defined as SEI-limited and divides by the SEI thickness, which is identically zero when the SEI submodel is disabled.

The resulting exception contains no message and the traceback terminates inside expression_tree/binary_operators.py, making it difficult to determine that the failure is caused by an incompatible option combination rather than by the solver or the user's model.

Steps to reproduce

  1. Install PyBaMM 25.12.2.
  2. Run the script below.
  3. Observe that parameter processing raises ZeroDivisionError before any simulation begins.

Minimal reproduction

import pybamm

model = pybamm.lithium_ion.SPMe(
    options={"lithium plating": "partially reversible", "SEI": "none"}
)
sim = pybamm.Simulation(model, parameter_values=pybamm.ParameterValues("OKane2022"))
sim.solve([0, 300], initial_soc=0.5)   # ZeroDivisionError (no message)

Root cause

pybamm/input/parameters/lithium_ion/OKane2022.py, in
SEI_limited_dead_lithium_OKane2022():

gamma_0 = pybamm.Parameter("Dead lithium decay constant [s-1]")
L_sei_0 = pybamm.Parameter("Initial SEI thickness [m]")

gamma = gamma_0 * L_sei_0 / L_sei      # L_sei == 0 when SEI option is "none"

L_sei is the SEI thickness variable, which is identically zero when the SEI
submodel is disabled, so pybamm.divide raises during
ParameterValues.process_model.

Scope

Tested with ParameterValues("OKane2022"), SEI: "none":

lithium plating option result
"none" ok
"reversible" ok
"partially reversible" ZeroDivisionError
"irreversible" ok
  • Reproduces identically with SPMe and DFN — it occurs at parameter
    processing, so it is model independent.
  • OKane2022 is the only shipped parameter set containing lithium-plating
    parameters, so this is reachable by any user who turns SEI off while keeping
    partially-reversible plating.

Expected behaviour

The option combination should be rejected during model construction or parameter processing with a clear pybamm.OptionError explaining that "partially reversible" lithium plating requires an active SEI submodel when using the OKane2022 parameterization.

The current behaviour is difficult to diagnose because the exception is raised deep inside parameter processing rather than during option validation.

Actual behaviour

ZeroDivisionError

with an empty message, raised from expression_tree/binary_operators.py via
parameters/parameter_substitutor.py, with no reference to the option
combination that caused it.

Environment

  • PyBaMM 25.12.2 (pip, site-packages)
  • Python 3.13.11
  • Linux 6.8.0-136-generic, x86_64, glibc 2.35
  • numpy 2.0.2, scipy 1.17.1, casadi 3.6.7

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions