Class containing the solution of, and various attributes associated with, a PyBaMM model.
all_ts (numpy.array
, size (n,) (or list of these)) – A one-dimensional array containing the times at which the solution is evaluated.
A list of times can be provided instead to initialize a solution with
sub-solutions.
all_ys (numpy.array
, size (m, n) (or list of these)) – A two-dimensional array containing the values of the solution. y[i, :] is the
vector of solutions at time t[i].
A list of ys can be provided instead to initialize a solution with
sub-solutions.
all_models (pybamm.BaseModel
) – The model that was used to calculate the solution.
A list of models can be provided instead to initialize a solution with
sub-solutions that have been calculated using those models.
all_inputs (dict (or list of these)) – The inputs that were used to calculate the solution A list of inputs can be provided instead to initialize a solution with sub-solutions.
t_event (numpy.array
, size (1,)) – A zero-dimensional array containing the time at which the event happens.
y_event (numpy.array
, size (m,)) – A one-dimensional array containing the value of the solution at the time when
the event happens.
termination (str) – String to indicate why the solution terminated
sensitivities (bool or dict) – True if sensitivities included as the solution of the explicit forwards equations. False if no sensitivities included/wanted. Dict if sensitivities are provided as a dict of {parameter: sensitivities} pairs.
Model(s) used for solution
A Solution object that only contains the first state. This is faster to evaluate than the full solution when only the first state is needed (e.g. to initialize a model with the solution)
A Solution object that only contains the final state. This is faster to evaluate than the full solution when only the final state is needed (e.g. to initialize a model with the solution)
A method to quickly plot the outputs of the solution. Creates a
pybamm.QuickPlot
object (with keyword arguments ‘kwargs’) and
then calls pybamm.QuickPlot.dynamic_plot()
.
output_variables (list, optional) – A list of the variables to plot.
**kwargs – Additional keyword arguments passed to
pybamm.QuickPlot.dynamic_plot()
.
For a list of all possible keyword arguments see pybamm.QuickPlot
.
Save solution data only (raw arrays)
filename (str, optional) – The name of the file to save data to. If None, then a str is returned
variables (list, optional) – List of variables to save. If None, saves all of the variables that have been created so far
to_format (str, optional) –
The format to save to. Options are:
’pickle’ (default): creates a pickle file with the data dictionary
’matlab’: creates a .mat file, for loading in matlab
’csv’: creates a csv file (0D variables only)
’json’: creates a json file
short_names (dict, optional) – Dictionary of shortened names to use when saving. This may be necessary when saving to MATLAB, since no spaces or special characters are allowed in MATLAB variable names. Note that not all the variables need to be given a short name.
data – str if ‘csv’ or ‘json’ is chosen and filename is None, otherwise None
str, optional
np_array
Values of the sensitivities. Returns a dict of param_name
List of sub solutions that have been concatenated to form the full solution
Times at which the solution is evaluated
Time at which the event happens
Reason for termination
Values of the solution
Value of the solution at the time of the event