Previous topic

Scipy Solver

Next topic

Solution

This Page

Scikits.odes Solvers

class pybamm.ScikitsOdeSolver(method='cvode', tol=1e-08, linsolver='dense')[source]

Solve a discretised model, using scikits.odes.

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.
  • linsolver (str, optional) – Can be ‘dense’ (= default), ‘lapackdense’, ‘spgmr’, ‘spbcgs’, ‘sptfqmr’
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 and y and returns the time-derivative dydt
  • y0 (numeric type) – The initial conditions
  • t_eval (numeric type) – 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. (see SUNDIALS docs. <https://computation.llnl.gov/projects/sundials>).
class pybamm.ScikitsDaeSolver(method='ida', tol=1e-08, root_method='lm', root_tol=1e-06, max_steps=1000)[source]

Solve a discretised model, using scikits.odes.

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.
  • root_method (str, optional) – The method to use to find initial conditions (default is “lm”)
  • tolerance – The tolerance for the initial-condition solver (default is 1e-8).
  • max_steps (int, optional) – The maximum number of steps the solver will take before terminating (default is 1000).
integrate(residuals, y0, t_eval, events=None, mass_matrix=None, jacobian=None)[source]

Solve a DAE model defined by residuals with initial conditions y0.

Parameters:
  • residuals (method) – A function that takes in t, y and ydot and returns the residuals of the equations
  • y0 (numeric type) – The initial conditions
  • t_eval (numeric type) – 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. (see SUNDIALS docs. <https://computation.llnl.gov/projects/sundials>).