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
- Install PyBaMM 25.12.2.
- Run the script below.
- 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
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
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
ZeroDivisionErrorbefore 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
ZeroDivisionErrorbefore any simulation begins.Minimal reproduction
Root cause
pybamm/input/parameters/lithium_ion/OKane2022.py, inSEI_limited_dead_lithium_OKane2022():L_seiis the SEI thickness variable, which is identically zero when the SEIsubmodel is disabled, so
pybamm.divideraises duringParameterValues.process_model.Scope
Tested with
ParameterValues("OKane2022"),SEI: "none":lithium platingoption"none""reversible""partially reversible"ZeroDivisionError"irreversible"SPMeandDFN— it occurs at parameterprocessing, so it is model independent.
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.OptionErrorexplaining 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
with an empty message, raised from
expression_tree/binary_operators.pyviaparameters/parameter_substitutor.py, with no reference to the optioncombination that caused it.
Environment