pybamm.
BaseSolver
(method=None, tol=1e-08)[source]¶Solve a discretised model.
Parameters: | tolerance (float, optional) – The tolerance for the solver (default is 1e-8). |
---|
compute_solution
(model, t_eval)[source]¶Calculate the solution of the model at specified times. Note: this does not execute the solver setup.
Parameters: |
|
---|
get_termination_reason
(solution, events)[source]¶Identify the cause for termination. In particular, if the solver terminated due to an event, (try to) pinpoint which event was responsible. Note that the current approach (evaluating all the events and then finding which one is smallest at the final timestep) is pretty crude, but is the easiest one that works for all the different solvers.
Parameters: |
|
---|
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 |
---|---|
Raises: | pybamm.SolverError – If the model contains any algebraic equations (in which case a DAE solver
should be used instead) |
solve
(model, t_eval)[source]¶Execute the solver setup and calculate the solution of the model at specified times.
Parameters: |
|
---|---|
Raises: |
|
step
(model, dt, npts=2)[source]¶Step the solution of the model forward by a given time increment. The first time this method is called it executes the necessary setup by calling self.set_up(model).
Parameters: |
|
---|---|
Raises: |
|
pybamm.
OdeSolver
(method=None, tol=1e-08)[source]¶Solve a discretised model.
Parameters: | tolerance (float, optional) – The tolerance for the solver (default is 1e-8). |
---|
compute_solution
(model, t_eval)[source]¶Calculate the solution of the model at specified times.
Parameters: |
|
---|
integrate
(derivs, y0, t_eval, events=None, mass_matrix=None, jacobian=None)[source]¶Solve a model defined by dydt with initial conditions y0.
Parameters: |
|
---|
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 |
---|---|
Raises: | pybamm.SolverError – If the model contains any algebraic equations (in which case a DAE solver
should be used instead) |
pybamm.
DaeSolver
(method=None, tol=1e-08, root_method='lm', root_tol=1e-06, max_steps=1000)[source]¶Solve a discretised model.
Parameters: |
|
---|
calculate_consistent_initial_conditions
(rhs, algebraic, y0_guess, jac=None)[source]¶Calculate consistent initial conditions for the algebraic equations through root-finding
Parameters: |
|
---|---|
Returns: | y0_consistent – Initial conditions that are consistent with the algebraic equations (roots of the algebraic equations) |
Return type: | array-like, same shape as y0_guess |
compute_solution
(model, t_eval)[source]¶Calculate the solution of the model at specified times.
Parameters: |
|
---|
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: |
|
---|
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 |
---|---|
Raises: | pybamm.SolverError – If the model contains any algebraic equations (in which case a DAE solver
should be used instead) |