Skip to main content
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()

Arguments are forwarded to 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

Compare SPM, SPMe, and DFN under identical conditions:
model_comparison.py
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
With permutations=True, every combination of the provided inputs is run:
permutations.py

Accessing results

After batch.solve(), iterate over batch.sims:
access_results.py
If 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.
batch.create_gif() raises a ValueError if called before batch.solve(). If batch.plot() has not been called, it creates a QuickPlot internally using pybamm.QuickPlot(batch.sims) before generating the GIF.