Previous topic

Base Solvers

Next topic

Scikits.odes Solvers

This Page

Scipy Solver

class pybamm.ScipySolver(method='BDF', tol=1e-08)[source]

Solve a discretised model, using scipy.integrate.solve_ivp.

Parameters:
  • method (str, optional) – The method to use in solve_ivp (default is “BDF”)
  • tolerance (float, optional) – The tolerance for the solver (default is 1e-8). Set as the both reltol and abstol in solve_ivp.
integrate(derivs, y0, t_eval, events=None, mass_matrix=None, jacobian=None)[source]

Solve a model defined by dydt with initial conditions y0.

Parameters:
  • derivs (method) – A function that takes in t (size (1,)), y (size (n,)) and returns the time-derivative dydt (size (n,))
  • y0 (numpy.array, size (n,)) – The initial conditions
  • t_eval (numpy.array, size (k,)) – The times at which to compute the solution
  • events (method, optional) – A function that takes in t and y and returns conditions for the solver to stop
  • mass_matrix (array_like, optional) – The (sparse) mass matrix for the chosen spatial method.
  • jacobian (method, optional) – A function that takes in t and y and returns the Jacobian. If None, the solver will approximate the Jacobian.
Returns:

An object containing the times and values of the solution, as well as various diagnostic messages.

Return type:

object