pybamm.BatchStudy automates running many pybamm.Simulation instances — useful for parameter sweeps, model comparisons, and sensitivity analyses. After solving, results from all simulations are available via batch.sims and can be plotted together with batch.plot().
Constructor
Parameters
When
permutations=False, every non-None dict must have the same number of entries as models. A ValueError is raised otherwise.solve()
pybamm.Simulation.solve() for each simulation. After calling solve(), batch.sims contains a list of the solved pybamm.Simulation objects in the order they were run.
Use cases
Model comparison
Model comparison
Compare SPM, SPMe, and DFN under identical conditions:
model_comparison.py
Parameter sweep
Parameter sweep
Sweep over different C-rates using
permutations=False (one model, one C-rate per entry) or pair models with different parameter sets:parameter_sweep.py
Cartesian product of models and solvers
Cartesian product of models and solvers
With
permutations=True, every combination of the provided inputs is run:permutations.py
Accessing results
Afterbatch.solve(), iterate over batch.sims:
access_results.py
repeats > 1, sim.solution.solve_time and sim.solution.integration_time hold the average across repeats:
timing.py
Plotting
batch.plot() calls pybamm.dynamic_plot(batch.sims, ...) and returns a QuickPlot instance stored in batch.quick_plot.