Skip to main content
pybamm.JaxSolver integrates PyBaMM models using JAX, enabling JIT compilation, GPU/TPU execution, and end-to-end differentiation through the solver.
JaxSolver requires Python ≥ 3.11 and is not supported on Intel-based macOS (darwin/x86_64). Install the jax extra: pip install pybamm[jax].

Constructor

str
default:"\"BDF\""
Integration method:
str | None
default:"None"
Method for computing consistent initial conditions. None uses the BDF solver’s internal Newton chord method. Can be overridden with any BaseSolver-compatible method.
float
default:"1e-6"
Relative tolerance.
float
default:"1e-6"
Absolute tolerance.
float | None
default:"0"
Tolerance for extrapolation detection.
str
default:"\"warn\""
Behaviour on extrapolation: "warn", "error", or "ignore".
dict | None
default:"{}"
Additional options forwarded to the JAX integrator.

Requirements


get_solve

Returns a compiled JAX function for repeated fast solves.
The returned function is JIT-compiled on first call and cached. Subsequent calls with the same t_eval reuse the compiled function.

Examples

When using JaxSolver, the model must be set up with convert_to_format="jax" and must not contain any termination events (e.g. voltage cut-off events). A RuntimeError is raised otherwise.