pybamm.CasadiSolver wraps the CasADi integrator (backed by SUNDIALS CVODES/IDA) and adds battery-specific logic for event detection and step-and-check integration.
Constructor
Relative tolerance for the integrator.
Absolute tolerance for the integrator.
Method for computing consistent initial conditions for DAE systems.
"casadi" uses CasADi’s Newton rootfinder. Any valid scipy.optimize.root method string (e.g. "lm", "hybr") is also accepted.Tolerance for the root-finding step.
Maximum number of times the step size may be halved before raising an error.
Maximum global step size (seconds) in
"safe" mode. Defaults to 600 s when None.Tolerance for detecting extrapolation beyond the solved interval.
Behaviour when extrapolation is detected:
"error", "warn", or "ignore".Options forwarded to the CasADi integrator at creation time. Useful keys include
"max_num_steps" and "print_stats". See the CasADi docs for the full list.Options forwarded to the CasADi integrator at call time.
If
True, return a partial Solution when the solver fails mid-simulation instead of raising an error.Whether to perturb algebraic initial conditions to avoid singularities. Defaults to
True in "safe" mode, False otherwise.LRU cache size for compiled CasADi integrators. Set to
0 for unbounded caching.Modes
| Mode | Description | Recommended for |
|---|---|---|
"safe" | Step-and-check in global steps of dt_max, detecting events | Full charge/discharge cycles |
"fast" | Direct integration; events are not tracked | Drive cycles, no cut-off events |
"fast with events" | Direct integration then retroactively locates events (experimental) | Testing |
"safe without grid" | Step-by-step without pre-building the time grid (experimental) | Memory-constrained runs |