Skip to main content
pybamm.ScipySolver wraps scipy.integrate.solve_ivp and is the easiest way to get started when your model produces a pure ODE system.
ScipySolver does not support DAE (differential-algebraic) models. Most lithium-ion models (SPM, SPMe, DFN) include algebraic equations and require CasadiSolver or IDAKLUSolver.

Constructor

pybamm.ScipySolver(
    method="BDF",
    rtol=1e-6,
    atol=1e-6,
    extrap_tol=None,
    on_extrapolation=None,
    extra_options=None,
)
method
str
default:"\"BDF\""
Integration method passed to solve_ivp. Supported values:
MethodDescription
"BDF"Implicit BDF (default); good for stiff problems
"RK45"Explicit Runge-Kutta 4(5); non-stiff problems
"RK23"Explicit Runge-Kutta 2(3)
"DOP853"Explicit Runge-Kutta of order 8
"Radau"Implicit Runge-Kutta (Radau IIA); stiff
"LSODA"Automatic stiff/non-stiff switching
rtol
float
default:"1e-6"
Relative tolerance.
atol
float
default:"1e-6"
Absolute tolerance.
extrap_tol
float | None
default:"0"
Tolerance for detecting extrapolation beyond the solved interval.
on_extrapolation
str
default:"\"warn\""
Behaviour on extrapolation: "warn", "error", or "ignore".
extra_options
dict | None
default:"{}"
Additional keyword arguments forwarded to solve_ivp (e.g. {"max_step": 10}).

Examples

import pybamm

# SPM with "reformulated" option produces a pure ODE
model = pybamm.lithium_ion.SPM()

param = pybamm.ParameterValues("Chen2020")
solver = pybamm.ScipySolver(method="BDF")

sim = pybamm.Simulation(model, parameter_values=param, solver=solver)
sol = sim.solve([0, 3600])
print(sol["Terminal voltage [V]"].entries[-1])
Sensitivity analysis is not supported by ScipySolver. Use IDAKLUSolver if you need parameter sensitivities.

Build docs developers (and LLMs) love