Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: pybamm performance user guide #4772

Open
martinjrobins opened this issue Jan 17, 2025 · 1 comment · May be fixed by #4787
Open

docs: pybamm performance user guide #4772

martinjrobins opened this issue Jan 17, 2025 · 1 comment · May be fixed by #4787
Assignees

Comments

@martinjrobins
Copy link
Contributor

Description

I'd like to propose a series of notebooks added to our user guide, focusing on performance when running PyBaMM simulations. The titles of the notebooks and a brief description are as follows:

Understanding the PyBaMM pipeline and performance profile of the Simulation class

This notebook discusses:

  • the main steps that PyBaMM performs to go from an initial model to a final solution
  • how you can use this information to optimise the performance
  • how this relates to the Simulation class and its internal processing and caching of the pipeline

Using Input Parameters to efficiently re-run simulations with different parameters

  • Describe how input parameters can be used to efficiently re-run simulations with different parameters
  • Describe the limitations of using input parameters (cannot be used for geometic parameters, produce a slower model)

Understanding the PyBaMM solvers

  • Describe the different solvers available in PyBaMM in terms of their perfomance characteristics
    • IDAKLU - will be the default solver, in-built support for events and sensitivity analysis and generally more performant than CasADi
    • CasADi - current default, but not activly maintained and will eventually be deprecated
    • Scipy - mainly for comparison with other solvers, a pure python solver so will be slower than the otherS
    • JAX solver - pure JAX solver, no support for events.

run some benchmarks using SPM, SPMe and DFN to compare the performance of the different solvers

IDAKLU solver - choosing evaluation and interpolation points for efficient simulation

  • Describe how the IDAKLU solver does its time-stepping, using the provided evaluation and interpolation points
  • Describe how to choose the evaluation and interpolation points to get the best performance
  • Describe why evaluation points are neccessary for discontinuous inputs, describe how you can use smoothing to remove the need for evaluation points and speed up your simul

IDAKLU solver - tolerance and other solver options

  • describe how the solvers use tolerances to control the accuracy of the solution
  • describe how to choose tolerances for your problem

IDAKLU solver - output variables

  • Describe how a solution is stored in the solver and in pybamm.Solution.
  • Describe how by default pybamm supports any number of defined output variables, and these are calculated as a post-processing step from the final pybamm.Solution.
  • Describe how output variables can be used to evaluate a subset of variables during the simulation, and how this can be used to speed up the simulation and reduce memory use

IDAKLU solver - running multiple simulations in parallel

  • Describe how openmp parallelisation can be used to either:
    • run multiple simulations with different input parameters in parallel
    • run a single large simulation in parallel
  • describe the costs and benefits of running multiple simulations in parallel, and how you can use the num_threads and num_solvers option to control the number of thread

Motivation

to inform users on the internal workings of the pybamm solvers and pipeline, so they can increase the performance of their simulations and take advantage of all the features of the solvers.

Possible Implementation

a series of jupyter notebooks in the user guide

Additional context

No response

@martinjrobins martinjrobins self-assigned this Jan 17, 2025
@martinjrobins martinjrobins linked a pull request Jan 21, 2025 that will close this issue
8 tasks
@valentinsulzer
Copy link
Member

Great idea, we can also get rid of the "speeding up simulations" notebook which is casadi-specific and no longer required once IDAKLU works well across all use csaes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants