pybamm.Simulation class is the primary entry point for running PyBaMM simulations. It wraps a model together with parameter values, geometry, mesh, discretisation, and solver into a single object, and provides a simple solve() method.
Creating a simulation
At minimum, aSimulation requires a model:
Simulation uses the model’s defaults for geometry, mesh types, spatial methods, parameter values, and solver.
Full constructor signature
Passing parameters
Pass aParameterValues object to override the model defaults:
ParameterValues.
Passing a solver
Solving
1
Without an experiment
When not using a For a 1C discharge, a safe upper bound is 3700 seconds:You can also pass an array to request the solution at specific times:
pybamm.Experiment, you must provide a time span as [t0, tf] in seconds. PyBaMM returns the solution at 100 evenly-spaced points within this interval (or the adaptive solver’s natural steps).2
With an experiment
When passing a
pybamm.Experiment, the solution times are determined by the experiment. Do not pass t_eval:3
Setting initial SOC
Pass
initial_soc to start at a specific state of charge (0 to 1):Convenience: C-rate
UseC_rate on the Simulation to set the discharge current automatically:
Additional solve options
Accessing the solution
After callingsolve(), the solution is available as sim.solution or as the return value:
Common variables
Cycle and step data (experiments)
For experiment simulations, the solution is organised into cycles and steps:Saving and loading
Simulations can be saved to disk using Python’spickle module:
Saving is not supported when
model.convert_to_format == "python". Use model.convert_to_format = "casadi" (the default) instead.