Skip to main content

Solver Comparison


Choosing a Solver

  • Most lithium-ion models (SPM, SPMe, DFN) include algebraic equations (DAEs). Use IDAKLUSolver (default in pybamm.Simulation) for best performance.
  • Drive-cycle simulations with no voltage events: use CasadiSolver(mode="fast") or IDAKLUSolver.
  • Simple ODE-only models (equivalent circuit, 0D): ScipySolver works well and has minimal dependencies.
  • Batch parameter sweeps on GPU/TPU: JaxSolver with method="RK45" enables JIT compilation.

BaseSolver Common Interface

All solvers inherit from pybamm.BaseSolver and share the following constructor parameters and methods.

Constructor Parameters

str
default:"None"
Integration method name. Meaning is solver-specific.
float
default:"1e-6"
Relative tolerance.
float
default:"1e-6"
Absolute tolerance.
str | algebraic solver
default:"None"
Method used to compute consistent initial conditions for DAE problems. Options include "casadi", "lm", "hybr", or a PyBaMM algebraic solver class.
float
default:"1e-6"
Tolerance for the initial-condition root-finding step.
float
default:"-1e-10"
Tolerance for detecting extrapolation beyond the solved time span.
str
default:"\"warn\""
Behaviour when extrapolation is detected. One of "warn", "error", or "ignore".
list[str]
default:"[]"
If specified, only these variables are computed and returned (reduces memory usage).

solve

Solve the model over the time span t_eval and return a pybamm.Solution object.

step

Advance the solution by a single time step dt. Useful for online / real-time simulation.

Setting Tolerances

For production simulations with lithium-ion physics models, IDAKLUSolver is the recommended starting point. It handles both ODE and DAE systems, supports sparse KLU factorisation, and exposes a rich options dict for fine-tuning.