Solvers

Base Solvers

# Algebraic Solvers¶

class pybamm.AlgebraicSolver(method='lm', tol=1e-06)[source]

Solve a discretised model which contains only (time independent) algebraic equations using a root finding algorithm. Note: this solver could be extended for quasi-static models, or models in which the time derivative is manually discretised and results in a (possibly nonlinear) algebaric system at each time level.

Parameters: method (str, optional) – The method to use to solve the system (default is “lm”) tolerance (float, optional) – The tolerance for the solver (default is 1e-6).
root(algebraic, y0_guess, jacobian=None)[source]

Calculate the solution of the algebraic equations through root-finding

Parameters: algebraic (method) – Function that takes in y and returns the value of the algebraic equations y0_guess (array-like) – Array of the user’s guess for the solution, used to initialise the root finding algorithm jacobian (method, optional) – A function that takes in t and y and returns the Jacobian. If None, the solver will approximate the Jacobian if required.
set_up(model)[source]

Unpack model, perform checks, simplify and calculate jacobian.

Parameters: model (pybamm.BaseModel) – The model whose solution to calculate. Must have attributes rhs and initial_conditions concatenated_algebraic (pybamm.Concatenation) – Algebraic equations, which should evaluate to zero jac (pybamm.SparseStack) – Jacobian matrix for the differential and algebraic equations pybamm.SolverError – If the model contains any time derivatives, i.e. rhs equations (in which case an ODE or DAE solver should be used instead)
solve(model)[source]

Calculate the solution of the model.

Parameters: model (pybamm.BaseModel) – The model whose solution to calculate. Must only contain algebraic equations.