A Simulation class for easy building and running of PyBaMM simulations.
model (pybamm.BaseModel
) – The model to be simulated
experiment (pybamm.Experiment
(optional)) – The experimental conditions under which to solve the model
geometry (pybamm.Geometry
(optional)) – The geometry upon which to solve the model
parameter_values (pybamm.ParameterValues
(optional)) – Parameters and their corresponding numerical values.
submesh_types (dict (optional)) – A dictionary of the types of submesh to use on each subdomain
var_pts (dict (optional)) – A dictionary of the number of points used by each spatial variable
spatial_methods (dict (optional)) – A dictionary of the types of spatial method to use on each domain (e.g. pybamm.FiniteVolume)
solver (pybamm.BaseSolver
(optional)) – The solver to use to solve the model.
output_variables (list (optional)) – A list of variables to plot automatically
C_rate (float (optional)) – The C-rate at which you would like to run a constant current (dis)charge.
A method to build the model into a system of matrices and vectors suitable for performing numerical computations. If the model has already been built or solved then this function will have no effect. This method will automatically set the parameters if they have not already been set.
check_model (bool, optional) – If True, model checks are performed after discretisation (see
pybamm.Discretisation.process_model()
). Default is True.
Similar to Simulation.build()
, but for the case of simulating an
experiment, where there may be several models to build
Generates x plots over a time span of t_eval and compiles them to create
a GIF. For more information see pybamm.QuickPlot.create_gif()
A method to quickly plot the outputs of the simulation. 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
.
Set up a simulation to run with an experiment. This creates a dictionary of inputs (current/voltage/power, running time, stopping condition) for each operating condition in the experiment. The model will then be solved by integrating the model successively with each group of inputs, one group at a time. This needs to be done here and not in the Experiment class because the nominal cell capacity (from the parameters) is used to convert C-rate to current.
Set up self.model to be able to run the experiment (new version). In this version, a new model is created for each step.
This increases set-up time since several models to be processed, but reduces simulation time since the model formulation is efficient.
A method to solve the model. This method will automatically build and set the model parameters if not already done so.
t_eval (numeric type, optional) –
The times (in seconds) at which to compute the solution. Can be provided as an array of times at which to return the solution, or as a list [t0, tf] where t0 is the initial time and tf is the final time. If provided as a list the solution is returned at 100 points within the interval [t0, tf].
If not using an experiment or running a drive cycle simulation (current provided as data) t_eval must be provided.
If running an experiment the values in t_eval are ignored, and the solution times are specified by the experiment.
If None and the parameter “Current function [A]” is read from data (i.e. drive cycle simulation) the model will be solved at the times provided in the data.
solver (pybamm.BaseSolver
, optional) – The solver to use to solve the model. If None, Simulation.solver is used
check_model (bool, optional) – If True, model checks are performed after discretisation (see
pybamm.Discretisation.process_model()
). Default is True.
save_at_cycles (int or list of ints, optional) – Which cycles to save the full sub-solutions for. If None, all cycles are saved. If int, every multiple of save_at_cycles is saved. If list, every cycle in the list is saved. The first cycle (cycle 1) is always saved.
calc_esoh (bool, optional) – Whether to include eSOH variables in the summary variables. If False then only summary variables that do not require the eSOH calculation are calculated. Default is True.
starting_solution (pybamm.Solution
) – The solution to start stepping from. If None (default), then self._solution
is used. Must be None if not using an experiment.
initial_soc (float, optional) – Initial State of Charge (SOC) for the simulation. Must be between 0 and 1. If given, overwrites the initial concentrations provided in the parameter set.
callbacks (list of callbacks, optional) – A list of callbacks to be called at each time step. Each callback must
implement all the methods defined in pybamm.callbacks.BaseCallback
.
**kwargs – Additional key-word arguments passed to solver.solve.
See pybamm.BaseSolver.solve()
.
A method to step the model forward one timestep. This method will automatically build and set the model parameters if not already done so.
dt (numeric type) – The timestep over which to step the solution
solver (pybamm.BaseSolver
) – The solver to use to solve the model.
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).
save (bool) – Turn on to store the solution of all previous timesteps
starting_solution (pybamm.Solution
) – The solution to start stepping from. If None (default), then self._solution
is used
**kwargs – Additional key-word arguments passed to solver.solve.
See pybamm.BaseSolver.step()
.