Skip to content

Issue 1477 sensitivities for solvers#1552

Merged
martinjrobins merged 93 commits into
developfrom
issue-1477-idaklu-send
Aug 19, 2021
Merged

Issue 1477 sensitivities for solvers#1552
martinjrobins merged 93 commits into
developfrom
issue-1477-idaklu-send

Conversation

@martinjrobins

@martinjrobins martinjrobins commented Jul 16, 2021

Copy link
Copy Markdown
Contributor

Description

Adds functionality to calculate sensitivities. Specifically:

  • pybamm.base_solver.solve function can take a list of input parameters to calculate the sensitivities of the solution with respect to. Or it can be True to calculate the sensitivities for all input parameters. If this arg changes between different calls to solve, then the model is re-setup.
  • If model.convert_to_format = 'casadi', then sensitivities will be calculated by solving the explicit forward sensitivity equations. Any solver can be used, except for the IDKLU solver which uses CVODES forward sensitivity methods, see next item
  • For model.convert_to_format = 'casadi' or model.convert_to_format = 'jax', the IDKLU solver can use the CVODES package to calculate sensitivities.

Fixes #1477

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@valentinsulzer valentinsulzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THanks for taking this on @martinjrobins ! Just a few comments

Comment thread CHANGELOG.md Outdated
Comment thread sens-test-pybamm.py Outdated
Comment thread sens-test.py Outdated
Comment thread test-sensitivities.ipynb Outdated
Comment thread tests/unit/test_solvers/test_casadi_algebraic_solver.py

@valentinsulzer valentinsulzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Will just need to merge develop after #1596 to fix the github actions

@martinjrobins martinjrobins merged commit 404fa2e into develop Aug 19, 2021
@martinjrobins martinjrobins deleted the issue-1477-idaklu-send branch August 19, 2021 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDAKLU solver sensitivities using IDAS

2 participants