Solve a discretised model.
method (str, optional) – The method to use for integration, specific to each solver
rtol (float, optional) – The relative tolerance for the solver (default is 1e-6).
atol (float, optional) – The absolute tolerance for the solver (default is 1e-6).
root_method (str or pybamm algebraic solver class, optional) – The method to use to find initial conditions (for DAE solvers). If a solver class, must be an algebraic solver class. If “casadi”, the solver uses casadi’s Newton rootfinding algorithm to find initial conditions. Otherwise, the solver uses ‘scipy.optimize.root’ with method specified by ‘root_method’ (e.g. “lm”, “hybr”, …)
root_tol (float, optional) – The tolerance for the initial-condition solver (default is 1e-6).
extrap_tol (float, optional) – The tolerance to assert whether extrapolation occurs or not. Default is 0.
Calculate consistent state for the algebraic equations through root-finding. model.y0 is used as the initial guess for rootfinding
model (pybamm.BaseModel
) – The model for which to calculate initial conditions.
time (float) – The time at which to calculate the states
inputs (dict, optional) – Any input parameters to pass to the model when solving
y0_consistent – Initial conditions that are consistent with the algebraic equations (roots of the algebraic equations). If self.root_method == None then returns model.y0.
array-like, same shape as y0_guess
Check if extrapolation occurred for any of the interpolants. Note that with the current approach (evaluating all the events at the solution times) some extrapolations might not be found if they only occurred for a small period of time.
solution (pybamm.Solution
) – The solution object
events (dict) – Dictionary of events
Identify the cause for termination. In particular, if the solver terminated due to an event, (try to) pinpoint which event was responsible. If an event occurs the event time and state are added to the solution object. 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.
solution (pybamm.Solution
) – The solution object
events (dict) – Dictionary of events
Unpack model, perform checks, and calculate jacobian.
model (pybamm.BaseModel
) – The model whose solution to calculate. Must have attributes rhs and
initial_conditions
inputs (dict, optional) – Any input parameters to pass to the model when solving
t_eval (numeric type, optional) – The times (in seconds) at which to compute the solution
Execute the solver setup and calculate the solution of the model at specified times.
model (pybamm.BaseModel
) – The model whose solution to calculate. Must have attributes rhs and
initial_conditions
t_eval (numeric type) – The times (in seconds) at which to compute the solution
external_variables (dict) – A dictionary of external variables and their corresponding values at the current time
inputs (dict or list, optional) – A dictionary or list of dictionaries describing any input parameters to pass to the model when solving
initial_conditions (pybamm.Symbol
, optional) – Initial conditions to use when solving the model. If None (default),
model.concatenated_initial_conditions is used. Otherwise, must be a symbol
of size len(model.rhs) + len(model.algebraic).
nproc (int, optional) – Number of processes to use when solving for more than one set of input parameters. Defaults to value returned by “os.cpu_count()”.
calculate_sensitivites (list of str or bool) – If true, solver calculates sensitivities of all input parameters. If only a subset of sensitivities are required, can also pass a list of input parameter names
If type of inputs is list, return a list of corresponding
pybamm.Solution
objects.
pybamm.Solution
or list of pybamm.Solution
objects.
pybamm.ModelError – If an empty model is passed (model.rhs = {} and model.algebraic={} and model.variables = {})
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).
old_solution (pybamm.Solution
or None) – The previous solution to be added to. If None, a new solution is created.
model (pybamm.BaseModel
) – The model whose solution to calculate. Must have attributes rhs and
initial_conditions
dt (numeric type) – The timestep (in seconds) over which to step the solution
npts (int, optional) – The number of points at which the solution will be returned during the step dt. default is 2 (returns the solution at t0 and t0 + dt).
external_variables (dict) – A dictionary of external variables and their corresponding values at the current time
inputs (dict, optional) – Any input parameters to pass to the model when solving
save (bool) – Turn on to store the solution of all previous timesteps
pybamm.ModelError – If an empty model is passed (model.rhs = {} and model.algebraic = {} and model.variables = {})