Skip to main content
PyBaMM provides several solvers suited to different use cases. All solvers accept a common set of tolerance parameters and are interchangeable — you pass a solver instance to pybamm.Simulation.

Solver overview

CasadiSolver

The recommended general-purpose solver. Uses CasADi for JIT-compiled, efficient integration. Supports DAEs, events, and multiple operating modes.

IDAKLUSolver

High-performance solver using SUNDIALS IDA with the KLU sparse direct solver. The fastest option for most PyBaMM models, especially in experiment mode or when solving many steps.

ScipySolver

Wraps scipy.integrate.solve_ivp. Easy to use and well-understood, but does not support DAEs or sensitivity analysis. Good for ODE-only models and debugging.

JaxSolver

JAX-compiled solver, enabling JIT compilation and automatic differentiation. Requires Python ≥ 3.11 and is not available on Intel macOS.

CasadiSolver

The default solver for most models. It compiles the model to a CasADi function and integrates using the CVODES/IDA integrators inside CasADi.

Modes

The mode parameter controls the integration strategy:

Key options

IDAKLUSolver

The fastest solver for PyBaMM models. Uses the SUNDIALS IDA time integrator with the KLU sparse linear solver, called via the pybammsolvers package.

Key options

output_variables for speed

When you only need a small set of outputs, specifying output_variables avoids computing and storing the full state vector:

Parallel solving

IDAKLUSolver can solve multiple input sets in parallel using OpenMP threads:

ScipySolver

Wraps scipy.integrate.solve_ivp. Only supports ODE models (no algebraic equations), so it cannot solve DFN or SPMe without modification.
ScipySolver does not support sensitivity analysis and cannot solve DAE systems. It is best suited to ODE-only models or for quick debugging.

JaxSolver

A JAX-based solver that enables JIT compilation and compatibility with JAX’s automatic differentiation.
The model must be built with JAX format:
JAX solver requirements:
  • Python ≥ 3.11
  • Not available on Intel macOS
  • Install with: pip install pybamm[jax]
  • Does not support models with termination events
  • Requires model.convert_to_format = "jax"

Passing a solver to Simulation

You can also override the solver at solve time:

Choosing a solver

Adjusting tolerances

All solvers accept rtol (relative) and atol (absolute) tolerance parameters. Tighter tolerances improve accuracy at the cost of speed:
For degradation studies requiring many cycles, start with IDAKLUSolver and loosen tolerances (rtol=1e-4) for speed. For a single precise discharge, use CasadiSolver with default tolerances.